smart-webcomponents-react 14.2.83 → 14.3.0
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/alertwindow/alertwindow.d.ts +5 -5
- package/alertwindow/alertwindow.esm.js +10 -85
- package/alertwindow/alertwindow.umd.js +1134 -1209
- package/array/array.d.ts +5 -5
- package/array/array.esm.js +13 -88
- package/array/array.umd.js +752 -827
- package/barcode/barcode.d.ts +3 -3
- package/barcode/barcode.esm.js +6 -61
- package/barcode/barcode.umd.js +311 -366
- package/button/dropdownbutton.d.ts +2 -2
- package/button/multisplitbutton.d.ts +2 -2
- package/calendar/calendar.d.ts +2 -2
- package/calendar/calendar.esm.js +4 -49
- package/calendar/calendar.umd.js +710 -755
- package/card/cardview.d.ts +1 -1
- package/cardview/cardview.d.ts +1 -1
- package/cardview/cardview.esm.js +2 -37
- package/cardview/cardview.umd.js +515 -550
- package/chart/chart.d.ts +9 -9
- package/chart/chart.esm.js +18 -133
- package/chart/chart.umd.js +822 -937
- package/chart/ganttchart.d.ts +20 -20
- package/combobox/combobox.d.ts +4 -4
- package/combobox/combobox.esm.js +8 -73
- package/combobox/combobox.umd.js +1341 -1406
- package/datetimepicker/datetimepicker.d.ts +1 -1
- package/datetimepicker/datetimepicker.esm.js +2 -37
- package/datetimepicker/datetimepicker.umd.js +826 -861
- package/dialogwindow/dialogwindow.d.ts +5 -5
- package/dialogwindow/dialogwindow.esm.js +10 -85
- package/dialogwindow/dialogwindow.umd.js +1134 -1209
- package/dockinglayout/dockinglayout.d.ts +7 -7
- package/dockinglayout/dockinglayout.esm.js +14 -109
- package/dockinglayout/dockinglayout.umd.js +765 -860
- package/dropdownbutton/dropdownbutton.d.ts +2 -2
- package/dropdownbutton/dropdownbutton.esm.js +4 -49
- package/dropdownbutton/dropdownbutton.umd.js +527 -572
- package/dropdownlist/dropdownlist.d.ts +4 -4
- package/dropdownlist/dropdownlist.esm.js +8 -73
- package/dropdownlist/dropdownlist.umd.js +1275 -1340
- package/editor/editor.d.ts +11 -9
- package/editor/editor.esm.js +14 -109
- package/editor/editor.umd.js +911 -1006
- package/fileupload/fileupload.d.ts +2 -1
- package/filterbuilder/filterbuilder.d.ts +1 -1
- package/filterbuilder/filterbuilder.esm.js +2 -37
- package/filterbuilder/filterbuilder.umd.js +463 -498
- package/filterpanel/filterpanel.d.ts +1 -1
- package/filterpanel/filterpanel.esm.js +2 -37
- package/filterpanel/filterpanel.umd.js +354 -389
- package/form/form.d.ts +1 -1
- package/form/form.esm.js +4 -49
- package/form/form.umd.js +1016 -1061
- package/form/formgroup.d.ts +1 -1
- package/ganttchart/ganttchart.d.ts +20 -20
- package/ganttchart/ganttchart.esm.js +40 -265
- package/ganttchart/ganttchart.umd.js +1666 -1891
- package/gauge/gauge.d.ts +2 -2
- package/gauge/gauge.esm.js +4 -49
- package/gauge/gauge.umd.js +664 -709
- package/grid/grid.d.ts +56 -51
- package/grid/grid.esm.js +96 -460
- package/grid/grid.umd.js +2107 -2471
- package/index.d.ts +45 -3
- package/input/input.d.ts +2 -2
- package/input/input.esm.js +4 -49
- package/input/input.umd.js +505 -550
- package/input/numberinput.d.ts +2 -2
- package/input/phoneinput.d.ts +4 -4
- package/kanban/kanban.d.ts +6 -6
- package/kanban/kanban.esm.js +12 -97
- package/kanban/kanban.umd.js +1334 -1419
- package/layout/dockinglayout.d.ts +7 -7
- package/listbox/listbox.d.ts +5 -5
- package/listbox/listbox.esm.js +10 -85
- package/listbox/listbox.umd.js +1170 -1245
- package/listmenu/listmenu.d.ts +1 -1
- package/listmenu/listmenu.esm.js +2 -37
- package/listmenu/listmenu.umd.js +1005 -1040
- package/menu/listmenu.d.ts +1 -1
- package/menu/menu.d.ts +1 -1
- package/menu/menu.esm.js +2 -37
- package/menu/menu.umd.js +1025 -1060
- package/multilinetextbox/multilinetextbox.d.ts +1 -1
- package/multilinetextbox/multilinetextbox.esm.js +2 -37
- package/multilinetextbox/multilinetextbox.umd.js +907 -942
- package/multilinewindow/multilinewindow.d.ts +5 -5
- package/multilinewindow/multilinewindow.esm.js +10 -85
- package/multilinewindow/multilinewindow.umd.js +1134 -1209
- package/multisplitbutton/multisplitbutton.d.ts +2 -2
- package/multisplitbutton/multisplitbutton.esm.js +4 -49
- package/multisplitbutton/multisplitbutton.umd.js +941 -986
- package/numberinput/numberinput.d.ts +2 -2
- package/numberinput/numberinput.esm.js +4 -49
- package/numberinput/numberinput.umd.js +348 -393
- package/numerictextbox/numerictextbox.d.ts +1 -1
- package/numerictextbox/numerictextbox.esm.js +2 -37
- package/numerictextbox/numerictextbox.umd.js +592 -627
- package/package.json +1 -1
- package/phoneinput/phoneinput.d.ts +4 -4
- package/phoneinput/phoneinput.esm.js +8 -73
- package/phoneinput/phoneinput.umd.js +386 -451
- package/pivottable/pivottable.d.ts +3 -3
- package/pivottable/pivottable.esm.js +6 -61
- package/pivottable/pivottable.umd.js +762 -817
- package/progresswindow/progresswindow.d.ts +5 -5
- package/progresswindow/progresswindow.esm.js +10 -85
- package/progresswindow/progresswindow.umd.js +1134 -1209
- package/promptwindow/promptwindow.d.ts +5 -5
- package/promptwindow/promptwindow.esm.js +10 -85
- package/promptwindow/promptwindow.umd.js +1134 -1209
- package/qrcode/qrcode.d.ts +3 -3
- package/qrcode/qrcode.esm.js +6 -61
- package/qrcode/qrcode.umd.js +333 -388
- package/querybuilder/querybuilder.d.ts +6 -1
- package/querybuilder/querybuilder.esm.js +14 -38
- package/querybuilder/querybuilder.umd.js +446 -470
- package/rating/rating.d.ts +1 -1
- package/rating/rating.esm.js +2 -37
- package/rating/rating.umd.js +261 -296
- package/scheduler/scheduler.d.ts +17 -17
- package/scheduler/scheduler.esm.js +34 -229
- package/scheduler/scheduler.umd.js +1782 -1977
- package/slider/slider.d.ts +2 -2
- package/slider/slider.esm.js +4 -49
- package/slider/slider.umd.js +642 -687
- package/source/modules/smart.accordion.js +1 -1
- package/source/modules/smart.array.js +2 -2
- 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 +4 -4
- package/source/modules/smart.carousel.js +1 -1
- package/source/modules/smart.chart.js +1 -1
- 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 +2 -2
- package/source/modules/smart.colorpicker.js +2 -2
- package/source/modules/smart.combobox.js +2 -2
- package/source/modules/smart.common.js +1 -1
- package/source/modules/smart.countryinput.js +2 -2
- package/source/modules/smart.dateinput.js +3 -3
- package/source/modules/smart.daterangeinput.js +4 -4
- 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 +2 -2
- package/source/modules/smart.editor.js +5 -5
- package/source/modules/smart.element.js +1 -1
- package/source/modules/smart.fileupload.js +3 -3
- package/source/modules/smart.form.js +2 -2
- package/source/modules/smart.formulaparser.js +1 -1
- package/source/modules/smart.ganttchart.js +5 -5
- package/source/modules/smart.gauge.js +1 -1
- package/source/modules/smart.grid.js +14 -14
- package/source/modules/smart.gridpanel.js +4 -4
- 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 +2 -2
- 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 +2 -2
- package/source/modules/smart.multisplitbutton.js +2 -2
- package/source/modules/smart.numberinput.js +2 -2
- package/source/modules/smart.numerictextbox.js +2 -2
- 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 +3 -3
- package/source/modules/smart.progressbar.js +1 -1
- package/source/modules/smart.qrcode.js +1 -1
- package/source/modules/smart.querybuilder.js +5 -5
- package/source/modules/smart.radiobutton.js +1 -1
- package/source/modules/smart.rating.js +1 -1
- package/source/modules/smart.router.js +1 -1
- package/source/modules/smart.scheduler.js +4 -4
- 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 +3 -3
- package/source/modules/smart.tabs.js +1 -1
- package/source/modules/smart.tank.js +1 -1
- package/source/modules/smart.textarea.js +2 -2
- package/source/modules/smart.textbox.js +2 -2
- 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 +1 -1
- package/source/modules/smart.validator.js +1 -1
- package/source/modules/smart.window.js +2 -2
- 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 +1 -1
- 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 +2 -2
- package/source/smart.element.js +1 -1
- package/source/smart.elements.js +17 -17
- package/source/smart.export.js +1 -1
- package/source/smart.fileupload.js +2 -2
- package/source/smart.filter.js +1 -1
- package/source/smart.filterbuilder.js +2 -2
- package/source/smart.filterpanel.js +1 -1
- 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 +1 -1
- 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 +2 -2
- package/source/smart.grid.pager.js +1 -1
- package/source/smart.grid.reorder.js +1 -1
- package/source/smart.grid.resize.js +2 -2
- package/source/smart.grid.row.js +1 -1
- package/source/smart.grid.select.js +2 -2
- package/source/smart.grid.sort.js +1 -1
- package/source/smart.grid.toolbar.js +2 -2
- package/source/smart.grid.tree.js +1 -1
- package/source/smart.grid.view.js +2 -2
- package/source/smart.gridpanel.js +1 -1
- package/source/smart.input.js +2 -2
- package/source/smart.kanban.js +2 -2
- package/source/smart.layout.js +1 -1
- package/source/smart.led.js +1 -1
- package/source/smart.listbox.js +2 -2
- 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.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.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 +1 -1
- 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 +1 -1
- 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/default/scss/smart.grid.scss +10 -3
- package/source/styles/default/smart.grid.css +7 -3
- package/source/styles/smart.default.css +1 -1
- package/source/typescript/smart.editor.d.ts +4 -2
- package/source/typescript/smart.elements.d.ts +45 -3
- package/source/typescript/smart.fileupload.d.ts +2 -1
- package/source/typescript/smart.grid.d.ts +34 -0
- package/source/typescript/smart.querybuilder.d.ts +5 -0
- package/splitter/splitter.d.ts +3 -3
- package/splitter/splitter.esm.js +6 -61
- package/splitter/splitter.umd.js +901 -956
- package/table/pivottable.d.ts +3 -3
- package/table/table.d.ts +7 -7
- package/table/table.esm.js +14 -109
- package/table/table.umd.js +1278 -1373
- package/tabs/tabs.d.ts +4 -4
- package/tabs/tabs.esm.js +8 -73
- package/tabs/tabs.umd.js +875 -940
- package/tabs/tabswindow.d.ts +5 -5
- package/tabswindow/tabswindow.d.ts +5 -5
- package/tabswindow/tabswindow.esm.js +10 -85
- package/tabswindow/tabswindow.umd.js +1134 -1209
- package/tank/tank.d.ts +2 -2
- package/tank/tank.esm.js +4 -49
- package/tank/tank.umd.js +598 -643
- package/textbox/multilinetextbox.d.ts +1 -1
- package/textbox/numerictextbox.d.ts +1 -1
- package/timepicker/datetimepicker.d.ts +1 -1
- package/toast/toast.d.ts +1 -1
- package/toast/toast.esm.js +2 -37
- package/toast/toast.umd.js +397 -432
- package/tree/tree.d.ts +4 -4
- package/tree/tree.esm.js +8 -73
- package/tree/tree.umd.js +1310 -1375
- package/waitwindow/waitwindow.d.ts +5 -5
- package/waitwindow/waitwindow.esm.js +10 -85
- package/waitwindow/waitwindow.umd.js +1134 -1209
- package/window/alertwindow.d.ts +5 -5
- package/window/dialogwindow.d.ts +5 -5
- package/window/multilinewindow.d.ts +5 -5
- package/window/progresswindow.d.ts +5 -5
- package/window/promptwindow.d.ts +5 -5
- package/window/tabswindow.d.ts +5 -5
- package/window/waitwindow.d.ts +5 -5
- package/window/window.d.ts +5 -5
- package/window/window.esm.js +10 -85
- package/window/window.umd.js +1134 -1209
|
@@ -803,7 +803,7 @@ Smart("smart-color-input",class extends Smart.Input{static get properties(){retu
|
|
|
803
803
|
/***/ 7855:
|
|
804
804
|
/***/ (() => {
|
|
805
805
|
|
|
806
|
-
Smart("smart-editor",class extends Smart.ContentElement{static get properties(){return{autoLoad:{value:!1,type:"boolean"},autoSave:{value:!1,type:"boolean"},autoSaveInterval:{value:1e3,type:"number"},autoExpand:{value:!1,type:"boolean"},charCountFormatFunction:{value:null,type:"function?"},contentFiltering:{value:{attributes:{value:[],type:"array"},attributeFilterMode:{allowedValues:["blackList","whiteList"],value:"blackList",type:"string"},tags:{value:[],type:"array"},tagFilterMode:{allowedValues:["blackList","whiteList"],value:"blackList",type:"string"},styleAttributes:{value:[],type:"array"},styleAttributeFilterMode:{allowedValues:["blackList","whiteList"],value:"blackList",type:"string"}},type:"object"},contextMenu:{allowedValues:["default","browser","none"],value:"default",type:"string"},contextMenuDataSource:{value:null,type:"any",reflectToAttribute:!1},dataExport:{value:{style:{value:null,type:"object"},fileName:{value:"smartEditor",type:"string?"},pageOrientation:{value:"portrait",type:"string"}},type:"object"},disableEditing:{value:!1,type:"boolean"},disableSearchBar:{value:!1,type:"boolean"},editMode:{allowedValues:["html","markdown"],value:"html",type:"string"},enableHtmlEncode:{value:!1,type:"boolean"},enableTabKey:{value:!1,type:"boolean"},findAndReplaceTimeout:{value:50,type:"number"},hideToolbar:{value:!1,type:"boolean"},hideInlineToolbar:{value:!1,type:"boolean"},imageFormat:{allowedValues:["blob","base64"],value:"base64",type:"string"},innerHTML:{type:"string",validator:"_sanitize",reflectToAttribute:!1},inlineToolbarOffset:{value:[0,-5],type:"array"},iframeSettings:{value:{attributes:{value:null,type:"object?"},enabled:{value:!1,type:"boolean"},resources:{value:null,type:"object?"}},type:"object"},maxCharCount:{value:null,type:"number?"},messages:{extend:!0,value:{en:{invalidValue:"{{elementType}}: Invalid {{property}} value. {{property}} should be of type {{typeOne}} or {{typeTwo}}.",incorrectArgument:"{{elementType}}: Incorrect argument {{argumentName}} in method {{methodName}}.",permissionsRequired:"{{elementType}}: Permissions are required for the following action {{actionName}}.",timeout:"{{elementType}}: The import request has timed out.",importError:"{{elementType}}: The import request errored with the following status: {{status}}.",exportError:"{{elementType}}: The Export request errored with the following status: {{status}}.",ok:"Ok",cancel:"Cancel",alignLeft:"Align Left",alignCenter:"Align Center",alignRight:"Align Right",alignJustify:"Align Justify",segoeUi:"Segoe UI",arial:"Arial",georgia:"Georgia",impact:"Impact",tahoma:"Tahoma",timesNewRoman:"Times New Roman",verdana:"Verdana",p:"Paragraph",pre:"Code",code:"Code",blockquote:"Quotation",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",h6:"Heading 6",bold:"Bold",italic:"Italic",underline:"Underline",strikethrough:"Strikethrough",orderedlist:"Ordered List",unorderedlist:"Unordered List",subscript:"Subscript",superscript:"Superscript",alignment:"Alignments",fontname:"Font Name",fontsize:"Font Size",formats:"Formats",backgroundcolor:"Background Color",fontcolor:"Font Color",redo:"Redo",undo:"Undo",indent:"Indent",outdent:"Outdent",createlink:"Hyperlink",hyperlink:"Hyperlink",editlink:"Hyperlink",removelink:"Remove link",openlink:"Open link",image:"Image",video:"Video",table:"Table",lowercase:"Lower Case",uppercase:"Upper Case",print:" Print",cut:" Cut",copy:" Copy",paste:" Paste",clearformat:"Clear Format",fullscreen:"Full Screen",restore:"Restore Screen",sourcecode:"Source Code",preview:"Preview",splitmode:"Split Editor",address:"Web Address",text:"Display Text",addressPlaceholder:"http://example.com",textPlaceholder:"Enter Text",targetPlaceholder:"Select Target",titlePlaceholder:"Enter a Title",urlPlaceholder:"http://example.com/image.png",srcPlaceholder:"https://www.youtube.com/embed/video_link",thumbnail:"Or provide a URL as a video thumbnail",thumbnailPlaceholder:"https://www.link-to-thumbnail.jpg",videoUrl:"Video URL",videoUrlPlaceholder:"https://www.youtube.com/video_link",captionPlaceholder:"Caption",altPlaceholder:"Alternative Text",widthPlaceholder:"auto",heightPlaceholder:"auto",target:"Open Link in",linkBlankDescr:"New Window",linkSelfDescr:"Same Window",linkParentDescr:"Parent Frame",linkTopDescr:"Full Body of the Window",linkCustomDescr:"Custom Frame Name",title:"Title",url:"Or provide the URL to an image",src:"Or provide the URL to an embed video",width:"Width",height:"Height",alt:"Alternative Text",caption:"Caption",display:"Display",displayPlaceholder:"Display",displayBlock:"Block",displayInline:"Inline",draggable:"Enable Dragging",resizable:"Enable Resizing",browse:"Browse",connectionError:"{{elementType}}: File Upload requires connection to the server.",wrongItemIndex:"{{elementType}}: There is no file with such an index in the list of uploaded files.",tooLongFileName:"{{elementType}}: File name is too long.",totalFiles:"Total files: ",cancelFile:"Cancel File",dashedborders:"Dashed Borders",altrows:"Alternate Rows",insertRowBefore:"Insert Row Before",insertRowAfter:"Insert Row After",deleteRow:"Delete Row",insertColumnLeft:"Insert Column Left",insertColumnRight:"Insert Column Right",deleteColumn:"Delete Column",alignTop:"Align Top",alignMiddle:"Align Middle",alignBottom:"Align Bottom",delete:"Delete",tablerows:"Table Rows",tablecolumns:"Table Columns",tablevalign:"Table Cell Vertical Align",tablestyle:"Table Style",tableheader:"Table Header",buttonLabel:"Custom Table",pasteLabel:"Choose the paste format action:",cols:"Columns",rows:"Rows",alphabet:"abcdefghijklmnopqrstuvwxyz",header:"Header",column:"Column",plainText:"Plain Text",keepFormat:"Keep Format",cleanFormat:"Clean Format",roleDescription:"Text Editor",iframeTitle:"Editor Content is Encloused in it's own DOM inside an iFrame",toolbarButtonAriaLabel:"Toolbar Toggle Button",primaryToolbarAriaLabel:"Primary Toolbar",secondaryToolbarAriaLabel:"Secondary Toolbar",inputAriaLabel:"Enter Text",homeTab:"Home",viewTab:"View",insertTab:"Insert",layoutTab:"Layout",undoGroup:"Undo",clipboardGroup:"Clipboard",fontGroup:"Font",paragraphGroup:"Paragraph",editingGroup:"Editing",tableGroup:"Tables",imageGroup:"Images",videoGroup:"Videos",linkGroup:"Links",viewsGroup:"Views",deleteGroup:"Delete",findandreplace:"Find and Replace",requiredMessage:"The content of the Editor cannot be empty",tableProperties:"Table Properties",imageProperties:"Image Properties",videoProperties:"Video Properties",linkProperties:"Link Properties",selectAll:"Select All",deleteTable:"Delete Table",deleteImage:"Delete Image",deleteVideo:"Delete Video",createLink:"Create Link",deleteLink:"Delete Link",copyImage:"Copy",cutImage:"Cut",copyVideo:"Copy",cutVideo:"Cut",find:"Find",findPlaceholder:"",replace:"Replace",replaceWith:"Replace With",replaceAll:"Replace All",replacePlaceholder:"",results:"Results",resultsPlaceholder:"No match",matchCase:"Match Case",searchPlaceholder:"Search..."}}},name:{value:null,type:"string?"},pasteFormat:{allowedValues:["prompt","plainText","keepFormat","cleanFormat"],value:"keepFormat",type:"string"},placeholder:{value:"",type:"string"},removeStylesOnClearFormat:{value:!1,type:"boolean"},required:{value:!1,type:"boolean"},sanitized:{value:!1,type:"boolean"},showCharCount:{value:!1,type:"boolean"},splitModeRefreshTimeout:{value:100,type:"number"},toolbarItems:{value:["bold","italic","underline","|","formats","alignment","orderedList","unorderedList","|","hyperlink","image","video","|","sourceCode","undo","redo"],reflectToAttribute:!1,type:"array"},toolbarMode:{allowedValues:["menu","singleLineRibbon"],value:"menu",type:"string"},toolbarRibbonConfig:{value:[{name:"homeTab",groups:[{name:"undoGroup",items:["undo","redo"]},{name:"clipboardGroup",items:["cut","copy","paste"]},{name:"fontGroup",items:["fontName","fontSize","backgroundColor","fontColor","clearFormat","formats","bold","italic","underline","strikethrough","superscript","subscript"]},{name:"paragraphGroup",items:["orderedList","unorderedList","indent","outdent","alignment"]},{name:"editingGroup",items:["findAndReplace"]}]},{name:"insertTab",groups:[{name:"tableGroup",items:["table"]},{name:"imageGroup",items:["image"]},{name:"videoGroup",items:["video"]},{name:"linkGroup",items:["createLink","removeLink"]}]},{name:"viewTab",groups:[{name:"viewsGroup",items:["fullScreen","sourceCode","splitMode"]}]},{name:"layoutTab",hidden:!0,groups:[{name:"deleteGroup",items:["delete"]},{name:"tableGroup",items:["table","tableHeader","tableRows","tableColumns","tableVAlign","tableStyle",""]},{name:"imageGroup",items:["image","caption"]},{name:"videoGroup",items:["video","caption"]}]}],type:"array"},toolbarViewMode:{allowedValues:["toggle","multiRow","scroll"],value:"toggle",type:"string"},toolbarSticky:{value:!1,type:"boolean"},spellCheck:{value:!0,type:"boolean"},value:{value:"",type:"string",validator:"_sanitize",reflectToAttribute:!1},windowCustomizationFunction:{value:null,reflectToAttribute:!1,type:"function?"}}}static get listeners(){return{"document.down":"_documentDownHandler","document.move":"_documentMoveHandler","document.up":"_documentUpHandler","document.dragstart":"_dragStartHandler","document.selectstart":"_selectStartHandler","document.selectionchange":"_selectionChangeHandler","container.dragend":"_dragEndHandler","container.drop":"_dropHandler","container.change":"_changeHandler","container.beforeinput":"_beforeInputHandler","container.input":"_afterInputHandler","contentContainer.contextmenu":"_contextMenuHandler","contentContainer.keydown":"_editableElementKeyDownHandler","contentContainer.keyup":"_updateOnInputChange","contentContainer.paste":"_updateOnInputChange","input.focus":"_editableElementFocusHandler","input.blur":"_editableElementBlurHandler","input.change":"_inputChangeEvent","editableElement.focus":"_editableElementFocusHandler","editableElement.blur":"_editableElementBlurHandler","editableElement.wheel":"_editableElementWheelHandler","editableElement.move":"_editableElementMoveHandler",touchmove:"_touchmoveHandler",resize:"_resizeHandler"}}static get requires(){return{"Smart.Button":"smart.button.js","Smart.Window":"smart.window.js","Smart.Tooltip":"smart.tooltip.js"}}static get styleUrls(){return["smart.editor.css"]}template(){return'<div id="container" role="presentation">\n <div id="toolbar" class="smart-editor-toolbar" role="presentation">\n <div id="toolbarItemsPrimary" class="smart-editor-toolbar-items-primary" role="toolbar"></div>\n <div id="toolbarToggleButton" class="smart-editor-toolbar-toggle-button" role="button"></div>\n <div id="toolbarItemsSecondary" class="smart-editor-toolbar-items-secondary" role="toolbar"></div>\n </div>\n <div id="contentContainer" class="smart-editor-content-container" role="presentation">\n <div class="smart-editor-editable" contenteditable="true" id="editableElement" aria-placeholder="[[placeholder]]"\n inner-h-t-m-l="[[innerHTML]]" spellcheck="[[spellCheck]]" role="textbox" aria-multiline="true"><content></content></div>\n <textarea name="[[name]]" id="input" class="smart-hidden" placeholder="[[placeholder]]" aria-placeholder="[[placeholder]]"\n spellcheck="[[spellCheck]]" autocapitalize="none" autocomplete="off"></textarea>\n </div>\n </div>'}propertyChangedHandler(e,t,o){const n=this;switch(e){case"contentFiltering":case"contentFiltering_attributes":case"contentFiltering_attributeFilterMode":case"contentFiltering_tags":case"contentFiltering_tagFilterMode":case"contentFiltering_styleAttributes":case"contentFiltering_styleAttributeFilterMode":n._handleContentFiltering();break;case"disabled":case"disableEditing":n.$.input.readonly=o,n.$.editableElement.setAttribute("contenteditable",!o),"disabled"===e&&n._setFocusable();break;case"disableSearchBar":n._closeSearchToolbar();break;case"enableHtmlEncode":{const e=n.$.input;e.classList.contains("smart-hidden")||(e.value=n._getInputValue());break}case"hideToolbar":o&&n._updateToolbarItems(void 0,n.$.toolbar);break;case"innerHTML":case"value":n._handleInputContent(e,o),n.$.fireEvent("change",{oldValue:n._value||t,value:n._value=n._getCurrentValue()});break;case"editMode":n._handleEditMode(o);break;case"hideInlineToolbar":{const e=n.$.inlineToolbar;e&&e.visible&&e.classList.contains("smart-editor-inline-toolbar")&&e.close();break}case"toolbarViewMode":n._toggleToolbar("toggle"===o);break;case"toolbarMode":case"toolbarRibbonConfig":n._handleToolbarMode();break;case"locale":delete n._toolbarItemsObj,delete n._inlineToolbarItemsObj,n._refreshToolbarItems(n._getToolbarItems()),n._closeToolbar(),n._closeWindow();break;case"iframeSettings":n._handleInputElement();break;case"maxCharCount":n._handleMaxCharCount(),n._setCharCount();break;case"name":o&&"markdown"!==n.editMode&&(n.$.input.value=n._getInputValue(n.$.editableElement.innerHTML.trim()));break;case"placeholder":n._handlePlaceholder();break;case"pasteFormat":n._closeWindow();break;case"readonly":n.$.input.readonly=o,n.$.editableElement.setAttribute("contenteditable","markdown"!==n.editMode&&!o),n._closePopups(),n._setResizeFrame(),n._closeWindow();break;case"showCharCount":n._setCharCount();break;case"rightToLeft":case"animation":case"theme":n._updateIframeBody();break;case"toolbarItems":n._handleToolbarItems();break;default:super.propertyChangedHandler(e,t,o)}}_handleToolbarItems(){const e=this,t=e.$.toolbarItemsPrimary,o=e.$.toolbarItemsSecondary;if(t.innerHTML=o.innerHTML="",delete e._toolbarItemsObj,delete e._inlineToolbarItemsObj,e._refreshToolbarItems(e._getToolbarItems()),"toggle"===e.toolbarViewMode){const n=e.$.toolbarToggleButton;t.scrollHeight!==t.offsetHeight||o.children.length?n.classList.remove("smart-visibility-hidden"):n.classList.add("smart-visibility-hidden")}}render(){const e=this,t=()=>0===e.offsetWidth||0===e.offsetHeight,o=()=>{e._isMobile=Smart.Utilities.Core.isMobile,e._isFireFox=Smart.Utilities.Core.Browser.Firefox,e._isSafari=Smart.Utilities.Core.Browser.Safari,e._isMacOS=(window.navigator.platform||"").indexOf("Mac")>-1,e._handleMaxCharCount(),e._handleInputContent(),e._setToolbarVisibility(),e._handleToolbarMode(),e._handleInputElement(),e._handleEditMode(),e._predefPropertyGetter(),e._setCharCount(),e._setFocusable(),e._setAriaSettings(),e.autoExpand&&e.expandToolbar(),e.isInitialized=!0,e.checkLicense()};if(t())return requestAnimationFrame((()=>{e.isInitialized||t()?e._createInterval=setInterval((()=>{e.isInitialized||t()||(o(),clearInterval(e._createInterval))}),100):o()})),void super.render();o(),super.render()}detached(){const e=this;super.detached(),delete e._dragDetails,delete e._resizeFrameObj,delete e._toolbarItemClick,e._endInlineToolbarClick(),e._closeWindow(),e._closeToolbarItemDropDown(e.$.inputPopup),e._closeToolbarItemDropDown(e.$.colorInputPopup),e._closeContextMenu(),e._closeToolbar(),e._handleTableSelection()}focus(){const e=this,t="markdown"===e.editMode?e.$.input:e.$.editableElement;t&&t.focus()}blur(){const e=this,t="markdown"===e.editMode?e.$.input:e.$.editableElement;t&&t.blur()}clearState(){const e=this;e.id?window.localStorage.removeItem("smartEditor"+e.id):e.warn(e.localize("noId"))}collapseToolbar(){this._toggleToolbar(!0)}disableToolbarItem(e){this._setToolbarItemAttr(e,"disabled",!0)}enableToolbarItem(e){this._setToolbarItemAttr(e,"disabled",!1)}expandToolbar(){this._toggleToolbar()}executeCommand(e,t){return this.$.editableElement.getRootNode().execCommand(e,!1,t)}exportData(e,t){this._handleDataExport(e,t)}importData(e,t){"string"==typeof e&&(e={url:e}),t||(t={}),this._ajax(e,t)}fullScreenMode(e){const t=this;t.$.fireEvent("actionStart",{name:"fullScreenMode"}).defaultPrevented||(t._handleFullScreenMode(t._toggleItem("fullscreen",e)),t.$.fireEvent("actionEnd",{name:"fullScreenMode"}))}getCharCount(){const e=this;if("html"===e.editMode){const t=e.$.editableElement,o=t.textContent.length,n=t.innerText.length;return n&&o?n:0}return e.$.input.value.length}getSelectionRange(){return this._selectionRange}clearContent(){const e=this;e._setResizeFrame(),e.$.editableElement.innerHTML=e.$.input.value=""}getHTML(){const e=this;if("markdown"===e.editMode){const t=e.$.input;return window.marked?window.marked(t.value):t.value}return e.$.editableElement.innerHTML}getText(){const e=this;return"markdown"===e.editMode?e.$.input.value:e.$.editableElement.textContent}loadState(e){const t=this;t.id?(e||(e=window.localStorage.getItem("smartEditor"+t.id)),"string"==typeof e&&(t.set("value",e),t.$.editableElement.innerHTML=t.$.input.value=e)):t.warn(t.localize("noId"))}showMessage(e,t){const o=this;if(!e||!o.isRendered)return;if(!Smart.Toast)return void o.error(o.localize("missingReference",{elementType:o.nodeName.toLowerCase(),methodName:"showMessage",files:"smart.toast.js"}));o._setToast();const n=o.$.toast;if(n){let a;if("object"==typeof t)for(let e in t)"iconType"===e?a=t[e]:n[e]=t[e];if(!o.$.container.contains(n)){const e=o.$toast;o._toastVisibilityHandler||(o._toastVisibilityHandler=e=>{const t=e.type;"close"===e.type&&e.detail.instance===o._requiredMessage&&delete o._requiredMessage,e.stopPropagation(),o.$.fireEvent("message"+t.slice(0,1).toUpperCase()+t.slice(1),e.detail)},e.listen("open",o._toastVisibilityHandler),e.listen("close",o._toastVisibilityHandler)),o.$.container.appendChild(n)}return n.open(e+"",a)}}hideMessage(e){const t=this.$.toast;t&&(void 0===e?t.closeAll():t.closeItem(e))}hideLastMessage(){const e=this.$.toast;e&&e.closeLast()}selectAll(){this._selectAll()}selectRange(e,t){const o=this,n=o.$.editableElement.getRootNode();if(!n)return;e=parseInt(e),t=parseInt(t),e=Math.min(e,t),t=Math.max(e,t);const a=o.$.input,i=o.$.editableElement,r="markdown"===o.editMode||o.$.editableElement.classList.contains("smart-hidden")?a:i,l=o.$.iframe,[s,d]=l?[l.contentWindow,l.contentDocument]:[window,document],c=s.getSelection();let m=n.activeElement;if((!m||m!==a&&m!==i||m.classList.contains("smart-hidden"))&&(r.focus(),m=r),c.removeAllRanges(),delete o._selectionRange,!isNaN(e)&&!isNaN(t)&&e!==t){if(m===a)a.setSelectionRange(e,t),o._selectionRange={selectionStart:e,selectionEnd:t};else{const n=o._getNodes(i,e,t).nodes;for(let e=0,t=n.length;e<t;e+=1){const{node:t,index:a,startIndex:i}=n[e],r=d.createRange();t.nodeType===Node.TEXT_NODE?(r.setStart(t,Math.max(0,i)),r.setEnd(t,Math.min(a,t.nodeValue.length))):r.selectNodeContents(t),c.addRange(r),o._selectionRange=r}}o._updateToolbarItems()}}saveState(){const e=this;e.id?window.localStorage.setItem("smartEditor"+e.id,e.$.editableElement.innerHTML):e.warn(e.localize("noId"))}splitMode(e){const t=this;t.$.fireEvent("actionStart",{name:"splitMode"}).defaultPrevented||(t._handleSplitMode(t._toggleItem("splitmode",e)),t.$.fireEvent("actionEnd",{name:"splitMode"}))}previewMode(e){const t=this;t.$.contentContainer.hasAttribute("split-mode")||t.$.fireEvent("actionStart",{name:"sourcecode"}).defaultPrevented||(t._handleSourceCodeMode(t._toggleItem("sourcecode",e)),t.$.fireEvent("actionEnd",{name:"sourcecode"}))}print(){this._handlePrint()}updateToolbarItem(e,t){const o=this,n=o.toolbarItems;let a;if("string"==typeof e?a=n.find((t=>t.name===e)):"number"==typeof e&&(a=n[e]),a){o._closePopups(),o._closeWindow(),delete o._toolbarItemsObj[a.name],delete o._inlineToolbarItemsObj[a.name];for(let e in t)a[e]=t[e];return o._refreshToolbarItems(o._getToolbarItems()),!0}}_toggleItem(e,t){const o=this._toolbarItemsObj;if(!o)return;const n=o[e],a=this.$.toolbar.querySelector(`.smart-editor-toolbar-item[item-name="${e}"]`);return n&&a?((t=n.value=void 0===t?!n.value:!!t)?(a.setAttribute("checked",""),a.setAttribute("aria-pressed",!0)):(a.removeAttribute("checked"),a.setAttribute("aria-pressed",!1)),a):void 0}_ajax(e,t={}){const o=this;let n="GET",a=e.url,i=null,r=!0;if(e.type&&(n=e.type),e.data)if("GET"===n){a+="?";for(let t in e.data)Object.prototype.hasOwnProperty.call(e.data,t)&&(a+=encodeURI(t+"="+e.data[t]+"&"));"&"===a.charAt(a.length-1)&&(a=a.slice(0,a.length-1))}else"POST"===n&&(i=JSON.stringify(e.data));t&&!1===t.async&&(r=!1),void 0!==window.fetch&&r?o._ajaxFetch(e,t,n,a,i):o._ajaxXMLHttpRequest(e,t,n,a,i,r)}_ajaxFetch(e,t,o,n,a){const i=this,r={method:o};let l,s,d;t&&t.contentType&&(r.headers=new Headers({"Content-Type":t.contentType})),null!==a&&(r.body=a),e.timeout&&(s=setTimeout((function(){d=!0}),e.timeout)),t.beforeSend&&!1===t.beforeSend(r,t)||fetch(n,r).then((function(e){if(d)throw l=408,i.error(i.localize("timeout",{elementType:i.nodeName.toLowerCase()}));if(s&&clearTimeout(s),l=e.status,!e.ok)throw i.error(i.localize("importError",{elementType:i.nodeName.toLowerCase(),status:e.statusText}));return e.text()})).then((e=>i._ajaxComplete(t,e,l))).catch((function(e){t&&t.loadError&&t.loadError(l,e)}))}_ajaxXMLHttpRequest(e,t,o,n,a,i){const r=new XMLHttpRequest,l=this;r.open(o,n,i),r.ontimeout=function(){t&&t.loadError&&t.loadError(408,"timeout")},r.onload=function(){if(4===r.readyState){const o=r.status;let n=r.response;o>=200&&o<=299?("json"===e.dataType&&(n=JSON.parse(n)),l._ajaxComplete(t,n,o)):t&&t.loadError&&t.loadError(o,n)}},r.onerror=function(){t&&t.loadError&&t.loadError(r.status,r.response)},t&&t.contentType&&r.setRequestHeader("Content-Type",t.contentType),i&&e.timeout&&(r.timeout=e.timeout),t.beforeSend&&!1===t.beforeSend(r,t)||r.send(a)}_ajaxComplete(e,t){if(e){if(e.beforeLoadComplete){const o=e.beforeLoadComplete(t);o&&(t=o)}this._handleInputContent("value",t)}}_afterInputHandler(e){const t=this,o=t._beforeInputObj,n=t.$.editableElement,a=!n.innerHTML;let i,r;if(o&&o.type&&(i=o.type,r=o.rangeDetails),delete t._beforeInputObj,a&&(t._setResizeFrame(),t._closeToolbar()),"insertParagraph"===i||a){let e=t._getSelectionRange().startContainer;if(e.nodeType===Node.TEXT_NODE&&(e=e.parentElement),e&&e.classList&&(e.closest(".smart-editor-image-caption")||e.closest(".smart-editor-editable table")))return;const o=t.$.iframe,[i,r]=o?[o.contentWindow,o.contentDocument]:[window,document];("div"===i.getSelection().anchorNode.nodeName.toLowerCase()||e===n&&a)&&r.execCommand("insertHTML",!1,"<p><br></p>")}else if(i&&r&&i.indexOf("delete")>-1){const e=t._resizeFrameObj;e&&e.target&&!n.contains(e.target)&&t._setResizeFrame()}n.textContent.length&&n.innerText.length?n.removeAttribute("show-placeholder"):n.setAttribute("show-placeholder",""),t.name&&e.target===t.$.editableElement&&"markdown"!==t.editMode&&(t.$.input.value=t._getInputValue(t.$.editableElement.innerHTML.trim())),t._setCharCount()}_beforeInputHandler(e){const t=this,o=t.$.iframe,n=t.$.contentContainer,a=t.$.editableElement,i=(o?o.contentWindow:window).getSelection().getRangeAt(0),r=e.inputType,l=i.startContainer;let s;if(r&&(s=r.indexOf("delete")>-1,t._beforeInputObj={type:r,rangeDetails:{startOffset:i.startOffset,endOffset:i.endOffset,startContainer:i.startContainer,endContainer:i.endContainer}}),s&&a.contains(l))if(l===i.endContainer&&i.startOffset===i.endOffset){const e=t._resizeFrameObj;let o=l;if(e&&e.target&&e.target.contains(l))return;if(o.nodeType!==Node.TEXT_NODE&&o.innerHTML.length){if(o===a)return;o.remove()}else{let e=o.parentElement,t=o.previousElementSibling;for(;!t&&e;)t=e.previousElementSibling,e=e.parentElement;a!==t&&a.contains(t)&&!t.innerHTML.length&&t.remove()}}else i.deleteContents(),e.preventDefault();if(!n.classList.contains("char-count-maxed")||s){if("insertParagraph"===r){const e=t._getSelectionRange().startContainer;e.nodeType===Node.TEXT_NODE&&e.parentElement===a&&a.getRootNode().execCommand("formatBlock",!1,"p")}}else e.preventDefault()}_changeHandler(e){const t=this,o=e.target,n=e.detail,a=o.closest(".smart-editor-toolbar-item");if(e.stopPropagation(),t._toolbarItemsObj||t._inlineToolbarItemsObj)return a&&o===t.$.inputPopup||o===t.$.colorInputPopup?(t._ignoreSelectionChange=!0,t._updateToolbarItem(a,n),void delete t._ignoreSelectionChange):void 0}_contextMenuHandler(e){const t=this,o=t.contextMenu;"browser"!==o?(e.preventDefault(),"none"!==o?t._openContextMenu(e):t._closeContextMenu()):t._closeContextMenu()}_closeContextMenu(){const e=this.$.inlineToolbar,t=this.$.fireEvent("dropDownToolbarClosing",{target:e}).defaultPrevented;e&&e.visible&&e.classList.contains("smart-editor-context-menu")&&!t&&e.close()}_openContextMenu(e){const t=this,o=e.target;let n=t.$.inlineToolbar;if(n||(n=t._createToolbar()),t.$.fireEvent("contextMenuOpening",{target:n}).defaultPrevented)return;t._setupToolbar(o,"context"),n.parentElement||t.getShadowRootOrBody().appendChild(n),n.clear(),t._setContextMenuContent(o);const a=t.getBoundingClientRect();n.style.left=Math.min(e.pageX+1,a.right+window.pageXOffset-n.offsetWidth)+"px",n.style.top=Math.min(e.pageY+1,a.bottom+window.pageYOffset-n.offsetHeight)+"px",n.open()}_setContextMenuContent(e){const t=this;if(!e)return;let o=t._contextList,n=t._getContextMenuTargetType(e),a=t._getContextMenuDataSource(e,n);o||(t._contextList=o=document.createElement("div"),o.classList.add("smart-editor-context-menu-item-container"));const i=document.createDocumentFragment(),r=a.length;let l=o.children;for(;l.length>r;)l[0].remove();l=Array.from(l);for(let o=0;o<r;o++){const r=a[o];let s,d,c=l[o];if("object"==typeof r?(s=r.label,d=r.value):s=d=r+"",c||(c=document.createElement("div"),c.classList.add("smart-editor-context-menu-item"),c.setAttribute("role","option")),c.removeAttribute("disabled"),"deleteLink"!==r||"image"!==n||e.closest(".smart-editor-editable a")){if("cut"===r||"copy"===r){const e=t._getSelectionRange();(void 0!==e.selectionStart?e.selectionStart:e.startOffset)===(void 0!==e.selectionEnd?e.selectionEnd:e.endOffset)&&c.setAttribute("disabled","")}}else c.setAttribute("disabled","");c.parentElement||i.appendChild(c),c.innerHTML=t.localize(s)||s,c.setAttribute("value",d)}o.appendChild(i),t.$.inlineToolbar.appendChild(o)}_getContextMenuTargetType(e){let t;return t=e.closest(".smart-editor-editable table")?"table":e.closest(".smart-editor-editable img")?"image":e.closest(".smart-editor-video-container")?"video":e.closest(".smart-editor-editable a")?"link":"text",t}_getContextMenuDataSource(e,t){if(!t)return[];const o=this.contextMenuDataSource;let n;switch(t){case"table":n=["tableProperties","insertRowAfter","insertRowBefore","insertColumnLeft","insertColumnRight","deleteRow","deleteColumn","deleteTable","selectAll"];break;case"image":n=["imageProperties","copyImage","cutImage","createLink","deleteLink","deleteImage","caption"];break;case"video":n=["videoProperties","copyVideo","cutVideo","deleteVideo","caption"];break;case"link":n=["linkProperties","deleteLink","selectAll"];break;default:n=["copy","cut","paste","selectAll"]}return o&&(n="function"==typeof o?o(e,t,n):Array.isArray(o)?o:[]),n}_updateToolbarItem(e,t){const o=this,n=o.editMode,a=e.getAttribute("item-name"),i=o.$.toolbarItemsPrimary,r=o.$.toolbarItemsSecondary,l=o.$.inlineToolbar,s="markdown"===n?o.$.input:o.$.editableElement,d=(e,n,a)=>{n&&(n.label=t["alignment"===n.name?"value":"label"],n.value=t.value,e&&o._setItemValue(e,n),a&&o._updateToolbarTarget(n))};if(l&&l.contains(e)?(d(e,o._inlineToolbarItemsObj[a],!0),o._toolbarItemsObj&&o._toolbarItemsObj[a]&&d(o.$.toolbar.querySelector(`.smart-editor-toolbar-item[item-name=${a}]`),o._toolbarItemsObj[a])):(i.contains(e)||r.contains(e))&&o._toolbarItemsObj&&(d(e,o._toolbarItemsObj[a],!0),l&&l.visible&&o._inlineToolbarItemsObj&&d(l.querySelector(`.smart-editor-toolbar-item[item-name=${a}]`),o._inlineToolbarItemsObj[a])),s.getRootNode().activeElement!==s){const e=o._selectionRange,t=s.scrollTop;e&&("markdown"===n?o._setSelectionRange(s,e.selectionStart,e.selectionEnd):o._setSelectionRange(e.startContainer,e.startOffset,e.endOffset)),s.focus({preventScroll:!0}),o._isSafari&&t&&(s.scrollTop=t)}}_updateToolbarTarget(e){const t=this,o=t._resizeFrameObj;if(!e)return;const n=t.$.inlineToolbar;let a;o&&o.target?a=o.target:n&&n.visible&&(a=n.selector,a=a.closest?a.closest(".smart-editor-editable img")||a.closest(".smart-editor-editable table"):void 0);const i=a?a.nodeName.toLowerCase():"";if(a&&"img"===i)return"alignment"===e.name&&(a.closest(".smart-editor-image-container")||a).setAttribute("alignment",e.value),t._setResizeFrame(a),void(n&&n.visible&&n.reposition());if(a&&"table"===i)return void t._handleTableToolbarAction(e,a);const r=t._getSelectionRange();if(r&&(r.startContainer||void 0!==r.selectionStart)){const o=e.name;if(t.$.fireEvent("actionStart",{name:o}).defaultPrevented)return;switch(o){case"backgroundcolor":t._handleBackgroundColor(e);break;case"fontcolor":t._handleFontColor(e);break;case"alignment":t._handleTextAlignment(e);break;case"fontsize":t._handleFontSize(e);break;case"fontname":t._handleFontName(e);break;case"formats":t._handleFormats(e);break;case"paste":t._handlePaste(e);break;default:{const t=r.startContainer.closest?r.startContainer:r.startContainer.parentElement;return void(t&&t.closest&&t.setAttribute(e.name,e.value))}}o&&t.$.fireEvent("actionEnd",{name:o})}}_setSelectionRange(e,t,o){const n=this,a=n.$.iframe,i=n.editMode;let r;if(n.disabled)return;if("markdown"===i||n.$.editableElement.classList.contains("smart-hidden")){r=n.$.input,n._selectionRange={selectionStart:void 0!==t?t:r.selectionStart,selectionEnd:void 0!==o?o:r.selectionEnd};const e=n._selectionRange;return void(n._selectionChangeFired||r.setSelectionRange(e.selectionStart,e.selectionEnd))}const l=(a?a.contentWindow:window).getSelection();let s;if(r=n.$.editableElement,e){if(s=document.createRange(),"number"==typeof t&&"number"==typeof o)try{s.setStart(e,parseInt(t)),s.setEnd(e,parseInt(o))}catch(t){s.selectNodeContents(e)}else"img"===e.nodeName.toLowerCase()||e.classList.contains("smart-editor-video-container")?(s.setStartBefore(e),s.setEndAfter(e),s.selectNode(e)):s.selectNodeContents(e);l.removeAllRanges(),l.addRange(s)}else l.rangeCount&&(s=l.getRangeAt(0));try{s&&s.startContainer&&r.contains(s.startContainer)&&(n._selectionRange=s)}catch(e){}n._selectionRange||(s=document.createRange(),s.selectNodeContents(r),s.collapse(!0),n._selectionRange=s)}_getSelectionRange(){const e=this,t=e.editMode;let o=e._selectionRange;return o&&("markdown"===t&&void 0===o.selectionStart||"html"===t&&void 0===o.startContainer)&&(delete e._selectionRange,o=void 0),o||e._setSelectionRange(),e._selectionRange}_setCharCount(){const e=this,t=e.$.contentContainer;if(!e.showCharCount)return void t.removeAttribute("char-count");const o=e.maxCharCount;let n,a;if("html"===e.editMode){const t=e.$.editableElement,o=t.textContent.length,n=t.innerText.length;a=n&&o?n:0}else a=e.$.input.value.length;if(n=e.charCountFormatFunction?e.charCountFormatFunction(a,o)+"":o?`${a} / ${o}`:a+"",t.setAttribute("char-count",n),null===o)return void t.classList.remove("char-count-low","char-count-medium");const i=parseFloat((a/o).toFixed(2));t.classList[i>=.7&&i<=.9?"add":"remove"]("char-count-warning"),t.classList[i>=.9?"add":"remove"]("char-count-error"),t.classList[a>=o?"add":"remove"]("char-count-maxed")}_documentDownHandler(e){const t=this,o=t.$.iframe,n=t.$.inlineToolbar,a=t.$.window,i=e.originalEvent||e,r=t.shadowRoot||t.isInShadowDOM?i.composedPath()[0]:i.target;if(n&&n.contains(r)){const e=r.closest(".smart-editor-toolbar-item");return t._handleToolbarItemDown(e,r),void i.preventDefault()}if(t.$.container.contains(r)||o&&o.contentDocument.body.contains(r))return void t._handleDownInside(i,r);const l=r.closest(".smart-input-drop-down-menu");let s;if(l&&(s=l.ownerElement),a&&a.opened&&!a.contains(s||r)&&a.close(),t._handleTableSelection(),s&&(t.$.toolbarItemsPrimary.contains(s)||t.$.toolbarItemsSecondary.contains(s)||n&&n.contains(s)))return t._toolbarItemClick={},void i.preventDefault();t._setResizeFrame(),t._closePopups()}_handleDownInside(e,t){const o=this,n=e.originalEvent||e,a=t.closest(".smart-editor-toolbar-item"),i=o.$.inlineToolbar,r=t.classList.contains("smart-editor-video-container")?t:null,l=o.$.window;let s=o._editorVideoItemClick;if(s&&(r&&s.dragElement&&s.dragElement.remove(),delete o._editorVideoItemClick,s=void 0),t===o.$.toolbarToggleButton)o._toolbarItemClick={},e.preventDefault();else{if(a)return o._handleToolbarItemDown(a,t),void e.preventDefault();if(t.closest(".smart-editor-toolbar-tab"))e.preventDefault();else if(r)s||(s=o._editorVideoItemClick={target:t,originalSelectionRange:o._selectionRange}),e.preventDefault(),!1!==r.getAttribute("draggable")&&r.querySelector("video")?(s.dragElement=o._createWhiteSpaceChar(t,r),o._setSelectionRange(t)):s.dragElement&&(s.dragElement.remove(),delete s.dragElement);else if(t.closest(".smart-editor-search-bar"))o._searchBarDown={target:t},t.closest(".smart-search-input")||e.preventDefault();else{const e={x:n.pageX+window.pageXOffset,y:n.pageY+window.pageYOffset};l&&l.opened&&l.close();const a=o._getInlineToolbarTarget(t,e);if(a){const t=o.$.contentContainer;t.contains(t.getRootNode().activeElement)||o._focusEditableElement(),o._handleInlineToolbarItemDown(a,e)}else!i||i.contains(t)&&i.classList.contains("smart-editor-drop-down-toolbar")||(o._closeToolbar(),o._handleTableSelection())}}o._closeToolbarItemDropDown(o.$.inputPopup),o._closeToolbarItemDropDown(o.$.colorInputPopup)}_handleToolbarItemDown(e,t){const o=this,n=o.$.inlineToolbar,a=o.$.window;if(!e)return;const i=e.getAttribute("item-type"),r=e.getAttribute("item-name");switch(!a||!a.opened||a._target&&a._target.item.name===r||a.close(),o._toolbarItemClick={toolbarItem:e},o._resizeFrameObj&&o._resizeFrameObj.target?o._toolbarItemClick.target=o._resizeFrameObj.target:o._setResizeFrame(),o._setSelectionRange(),i){case"button":["hyperlink","createlink","image","video"].includes(r)?o._toolbarItemClick.callback=o._toggleWindow:"table"===r&&(o._toolbarItemClick.callback=n&&n.contains(e)?o._toggleWindow:o._toggleDropDownToolbar);break;case"toggle":e.toggleAttribute("checked"),e.hasAttribute("checked")?e.setAttribute("aria-pressed",!0):e.setAttribute("aria-pressed",!1),o._closeToolbarItemDropDown(o.$.inputPopup),o._closeToolbarItemDropDown(o.$.colorInputPopup);break;case"drop-down":o._toolbarItemClick.callback=o._toggleItemDropDown;break;case"color-input":t.closest(".smart-editor-item-drop-down-button")&&(o._toolbarItemClick.callback=o._toggleItemDropDown)}}_handleInlineToolbarItemDown(e,t){const o=this,n=e.closest(".smart-editor-editable table"),a=o.$.editableElement;if(o._inlineToolbarClickObj&&o._inlineToolbarClickObj.target&&(o._inlineToolbarClickObj.target.removeAttribute("drag-id"),o._inlineToolbarClickObj.dragElement&&o._inlineToolbarClickObj.dragElement.removeAttribute("drag-id")),o._inlineToolbarClickObj={},e)if("img"===e.nodeName.toLowerCase())e.setAttribute("drag-id",Math.random().toString(36).substr(2,5));else if(e.classList.contains("smart-editor-video-container")){const t=e.querySelector("video, iframe");t&&(t.setAttribute("drag-id",Math.random().toString(36).substr(2,5)),o._inlineToolbarClickObj.dragElement=t)}if(n&&a.hasAttribute("table-cell-resize")){const i=a.getAttribute("table-cell-resize");o._inlineToolbarClickObj.resizeDetails={x:t.x,y:t.y,position:i,target:"vertical"===i?e.closest("tr"):e,table:n},e=void 0}o._handleTableSelection(e),o._inlineToolbarClickObj.target=e,o._inlineToolbarClickObj.dragTarget=e}_getInlineToolbarTarget(e,t){const o=this;let n,a=e.closest(".smart-editor-editable img")||e.closest(".smart-editor-editable a")||e.closest(".smart-editor-video-container");return a||(n=e.closest(".smart-editor-editable table"),n&&(a=e.closest(".smart-editor-editable td")||e.closest(".smart-editor-editable th"))),e.closest(".smart-editor-resize-frame")&&o._resizeFrameObj?(o._resizeFrameObj.resizeDetails={x:t.x,y:t.y,position:e.getAttribute("position")},a=o._resizeFrameObj.target):a&&(a&&"img"===a.nodeName.toLowerCase()||n||a.classList.contains("smart-editor-video-container"))||o._setResizeFrame(),a}_documentMoveHandler(e){const t=this,o=t._resizeFrameObj,n=t._inlineToolbarClickObj,a=e.originalEvent||e;o&&o.resizeDetails?t._handleFrameResize(a):n&&n.resizeDetails&&t._handleTableCellResize(a)}_touchmoveHandler(e){const t=this,o=t._resizeFrameObj;t._isMobile&&o&&o.target&&(o.resizeDetails?(e.preventDefault(),e.stopPropagation()):(t._closeToolbar(),t._setResizeFrame()))}_dragStartHandler(e){const t=this,o=t._resizeFrameObj,n=t._inlineToolbarClickObj;if(o&&o.resizeDetails||n&&n.resizeDetails)return e.preventDefault(),void delete t._dragDetails;if(!t.$.contentContainer.contains(e.target))return;if(!n||!n.target)return void e.preventDefault();const a=t._inlineToolbarClickObj.target;if(a&&(["img","table"].indexOf(a.nodeName.toLowerCase())>-1||a.classList.contains("smart-editor-video-container"))){if("false"===a.getAttribute("draggable"))return void e.preventDefault();const o=e.target,n=o.parentElement,i=o.closest(".smart-editor-image-container");t._closeToolbar(),t._setResizeFrame(),t._dragDetails={target:o,scrollTop:t.$.editableElement.scrollTop,container:i,anchor:n&&"a"===n.nodeName.toLowerCase()?n:void 0,caption:i?i.querySelector(".smart-editor-image-caption"):void 0}}}_dropHandler(){const e=this;e._isFireFox&&e._dragEndHandler()}_dragEndHandler(){const e=this,t=e.$.inlineToolbar,o=e._dragDetails;if(o){const n=o.target,a=o.container,i=e.$.editableElement,r=i.querySelector(`[drag-id="${n.getAttribute("drag-id")}"]`);if(r){const n=o.anchor;if(r.removeAttribute("drag-id"),a&&!a.contains(r)&&r.parentElement){const e=o.caption;let t=r.parentElement;if(t.classList.contains("smart-editor-video-container")){const e=t;t=t.parentElement,e.remove(),t.appendChild(r)}a.remove(),a.innerHTML="",t.insertBefore(a,r),a.appendChild(r),e&&a.appendChild(e)}n&&r.parentElement!==n&&(n.innerHTML="",r.parentElement.insertBefore(n,r),n.appendChild(r)),void 0!==o.scrollTop&&(i.scrollTop=o.scrollTop),requestAnimationFrame((()=>e._setResizeFrame(r)));const l=e._resizeFrameObj;if(e._editorVideoItemClick){const t=i.querySelectorAll('.smart-editor-video-white-space, div[pseudo="-webkit-media-controls"]');for(let e=0,o=t.length;e<o;e+=1)t[e].remove();delete e._editorVideoItemClick}(!t||t&&!t.visible)&&l&&l.target&&e._openInlineToolbar(l.target)}return void delete e._dragDetails}e._setSelectionRange();const n=e._getSelectionRange();n&&n.startOffset!==n.endOffset&&(e._handleInlineToolbar(n.startContainer),e._focusEditableElement())}_documentUpHandler(e){const t=this,o=t._resizeFrameObj,n=t.$.inlineToolbar,a=e.originalEvent||e,i=t.shadowRoot||t.isInShadowDOM?a.composedPath()[0]:a.target;if(o&&(o.resizeDetails&&o.target&&(o.target.removeAttribute("dragged"),t.$.fireEvent("resizeEnd",{target:o.target})),delete o.resizeDetails),t._dragDetails)return t._endInlineToolbarClick(),void delete t._toolbarItemClick;const r=t.$.iframe;if(t.$.container.contains(i)||n&&n.contains(i)||r&&r.contentDocument.body.contains(i)){const e=i.closest(".smart-editor-toolbar-item");e?t._handleToolbarUp(e):t._handleContentUp(a,i)}t._endInlineToolbarClick(),delete t._searchBarDown,delete t._dragDetails,delete t._toolbarItemClick}_handleToolbarUp(e){const t=this,o=t._toolbarItemClick,n=e.getAttribute("item-type");if(o&&o.toolbarItem===e){const e=o.toolbarItem;"custom"!==n&&(t._handleToolbarItemClick(event,e),t._focusEditableElement())}}_handleContentUp(e,t){const o=this,n=o._inlineToolbarClickObj,a=o.$.toolbarToggleButton,i=o._editorVideoItemClick,r=void 0!==e.button&&2===e.button;if(r||t!==a&&!a.contains(t))if(t.classList.contains("smart-editor-toolbar-tab"))o.$.toolbar.hasAttribute("expanded")?t.hasAttribute("checked")||o._selectToolbarTab(t):(o._selectToolbarTab(t),o._toggleSecondaryToolbar(t.hasAttribute("checked")));else if(i&&t.classList.contains("smart-editor-video-container")&&t===i.target)o._setResizeFrame(t),o._focusEditableElement();else if(n){const e=n.target;e&&(e===t||e.contains(t))&&(r?o._setResizeFrame(e):o._handleInlineToolbar(e),o._focusEditableElement())}else if(!r&&(o.$.editableElement.contains(t)||"markdown"===o.editMode&&t===o.$.input)){const e=o.$.iframe,t=e?e.contentWindow:window;requestAnimationFrame((()=>{e&&o._setSelectionRange();const n=o._getSelectionRange();if(n instanceof t.Range){let e=n.startContainer;n.startOffset!==n.endOffset&&(o._handleInlineToolbar(e),o._focusEditableElement())}}))}else!r&&t.closest(".smart-editor-search-bar")&&o._handleSearchButtonClick(t.closest(".smart-search-button"));else o._toggleToolbar(o.$.toolbar.hasAttribute("expanded"))}_toggleSecondaryToolbar(e){const t=this,o=t.$.toolbar,n=t.$.toolbarItemsPrimary,a=t.$.toolbarItemsSecondary,i=()=>{o.hasAttribute("expanded")?(a.classList.remove("smart-drop-down"),o.contains(a)||o.appendChild(a),a.style.top=""):(a.classList.add("smart-drop-down"),o.contains(a)&&o.parentElement.insertBefore(a,o.nextElementSibling),a.style.top=n.offsetTop+n.offsetHeight+"px")};if(!e&&(a.classList.add("smart-visibility-hidden"),t.hasAnimation))return a.addEventListener("transitionend",i,{once:!0}),void a.addEventListener("transitioncancel",i,{once:!0});i(),e&&(t._setToolbarGroupHeight(),a.classList.remove("smart-visibility-hidden"))}_setToolbarGroupHeight(){const e=this.$.toolbarItemsSecondary,t=e.children;if(e.style.height="","menu"===this.toolbarMode)return;let o;for(let e=0,n=t.length;e<n;e+=1){const n=t[e].offsetHeight;(void 0===o||o<n)&&(o=n)}void 0!==o&&(e.style.height=o+"px")}_endInlineToolbarClick(){const e=this,t=e._inlineToolbarClickObj;if(t){const o=t.resizeDetails;if(!e._dragDetails&&t.target&&(t.target.removeAttribute("drag-id"),t.dragElement&&t.dragElement.removeAttribute("drag-id")),o&&o.target){if("horizontal"===o.position){const e=o.cells,t=o.table.offsetWidth;e&&e.forEach((e=>{e.style.width&&(e.style.width=100*parseFloat((e.offsetWidth/t).toFixed(2))+"%")}))}e.$.editableElement.removeAttribute("table-cell-resize"),o.target.removeAttribute("resizing"),o.isInlineToolbarOpened&&e._handleInlineToolbar(o.target)}delete e._inlineToolbarClickObj}}_updateToolbarItems(e,t){const o=this;if(o._dragDetails||o.readonly||o.disabled)return;if("markdown"===o.editMode)return void o._updateToolbarItemsMarkdown(e);const n=o._getSelectionRange(),a=o.$.inlineToolbar;let i,r;if(!n)return;if(t||(t=o.$.toolbar),a&&t!==a&&!o.hideInlineToolbar&&a.visible&&(o._updateToolbarItems(e,a),i=!0),t!==o.$.toolbar||o.hideToolbar?i||o.hideInlineToolbar||(r=o._inlineToolbarItemsObj):r=o._toolbarItemsObj,!r)return;const l=o.$.editableElement;let s,d=n.startOffset>n.endOffset?n.endContainer:n.startContainer;if(d&&(d.closest||(d=d.parentElement),d&&d.closest)){e||(e=["alignment","bold","italic","strikethrough","underline","fontsize","fontname","formats","fontcolor","backgroundcolor","orderedlist","unorderedlist","subscript","superscript"]);for(let n=0,a=e.length;n<a;n+=1){const a=e[n],i=r[a];if(i){let e;if("alignment"===a)e=d.style.textAlign;else if("bold"===a)e=!!o._getNodeFromList(d,["b","strong","h1","h2","h3","h4","h5","h6"]);else if("italic"===a)e=!!o._getNodeFromList(d,["i"]);else if("underline"===a)e=!!o._getNodeFromList(d,["u"]);else if("strikethrough"===a)e=!!o._getNodeFromList(d,["strike"]);else if("fontsize"===a){const t=d.closest(".smart-editor-editable font");t&&(e=t.style.fontSize),e||(s||(s=window.getComputedStyle(d)),e=s.fontSize),e=parseInt(e),isNaN(e)&&(e="")}else if("fontname"===a){const t=d.closest(".smart-editor-editable font");t&&t.hasAttribute("face")?e=t.getAttribute("face"):(s||(s=window.getComputedStyle(d)),e=s.fontFamily.split(",")[0])}else if("formats"===a&&d!==l){const t=i.dataSource;if(e="",t){const n=t.map((e=>e.value));e=o._getNodeFromList(d,n)||""}}else if("fontcolor"===a){const t=d.closest(".smart-editor-editable font");t?e=t.color:(s||(s=window.getComputedStyle(d)),e=s.color)}else"backgroundcolor"===a?(e=o._getNodeBackgroundColor(d),e||(s||(s=window.getComputedStyle(d)),e=s.backgroundColor)):"orderedlist"===a||"unorderedlist"===a?e=!!d.closest(`.smart-editor-editable ${"orderedlist"===a?"ol":"ul"} li`):"subscript"===a?e=!!d.closest(".smart-editor-editable sub"):"superscript"===a&&(e=!!d.closest(".smart-editor-editable sup"));if(!e&&i.dataSource){const t=i.dataSource[0];t&&(e=t.value||t)}null!==e&&(i.value=e,o._setItemValue(t.querySelector(`.smart-editor-toolbar-item[item-name=${a}]`),i))}}}}_updateToolbarItemsMarkdown(e){const t=this,o=t._getSelectionRange();if(!o||void 0===o.selectionStart)return;const n=o.selectionStart;e||(e=["bold","italic","strikethrough","underline","formats","orderedlist","unorderedlist","subscript","superscript"]);for(let o=0,a=e.length;o<a;o+=1){const a=e[o],i=t._toolbarItemsObj[a];if(i){let e;if("bold"===a)e=!!t._getMarkdownItem(n,"**"),e||(e=!!t._getMarkdownItem(n,"__"));else if("italic"===a)e=!!t._getMarkdownItem(n,"*"),e||(e=!!t._getMarkdownItem(n,"_"));else if("strikethrough"===a)e=!!t._getMarkdownItem(n,"~~");else if("underline"===a)e=!!t._getMarkdownItem(n,"<ins>","</ins>");else if("formats"===a){const o=i.dataSource;if(e="",o){const a=o.map((e=>e.value));e:for(let o=0,i=a.length;o<i;o+=1)if(e=t._getMarkdownFormat(n,a[o]),e&&void 0!==e.formatName){e=e.formatName;break e}}}else"orderedlist"===a||"unorderedlist"===a?e=!!t._getMarkdownFormat(n,a):"subscript"===a?e=!!t._getMarkdownItem(n,"<sub>","</sub>"):"superscript"===a&&(e=!!t._getMarkdownItem(n,"<sup>","</sup>"));if(!e&&i.dataSource){const t=i.dataSource[0];t&&(e=t.value||t)}null!==e&&(i.value=e,t._setItemValue(t.$.toolbar.querySelector(`.smart-editor-toolbar-item[item-name=${a}]`),i))}}}_getMarkdownItem(e,t,o=t){const n=this.$.input.value,a=n.lastIndexOf(t,Math.max(0,e-1)),i=n.indexOf(o,a>-1?a+t.length:e);if(!(a<0||a>e||i<0||i<e||n.slice(a,e).indexOf("\n")>-1||n.slice(e,i).indexOf("\n")>-1))return" "!==n[a+1]&&n[a-1]!==t&&n[a+1]!==t&&" "!==n[i-1]&&n[i-1]!==t&&n[i+1]!==t?{startIndex:a,endIndex:i+o.length}:void 0}_getMarkdownFormat(e,t){const o=this.$.input.value,n=o.lastIndexOf("\n",Math.max(0,e-1))+1,a=o.slice(n,e);let i;switch(t){case"h1":i="# ";break;case"h2":i="## ";break;case"h3":i="### ";break;case"h4":i="#### ";break;case"h5":i="##### ";break;case"h6":i="###### ";break;case"code":case"pre":i="```";break;case"blockquote":i="> ";break;case"orderedlist":{const e=/^\s*([0-9]+\.{1}\s+)/gs.exec(a);return e?{formatName:t,occuranceIndex:n+e.input.indexOf(e[1])}:void 0}case"unorderedlist":{const e=/^\s*([-+*]{1}\s+)/gs.exec(a);return e?{formatName:t,occuranceIndex:n+e.input.indexOf(e[1])}:void 0}default:i=t+""}const r=a.indexOf(i);if(r>=0&&r<=3&&a.slice(r,i.length)===i)return{formatName:t,occuranceIndex:n+r,markdown:i}}_getNodeFromList(e,t){const o=this.$.editableElement;if(e&&t)for(;e&&e!==o;){const o=e.nodeName.toLocaleLowerCase();if(t.indexOf(o)>-1)return o;e=e.parentElement}}_getNodeBackgroundColor(e){const t=this.$.editableElement;for(;e&&e!==t;){const t=e.style.backgroundColor;if(t)return t;e=e.parentElement}}_editableElementBlurHandler(e){const t=this,o=t.$.editableElement,n=t.$.contentContainer;if(!t._toolbarItemClick&&!n.contains(n.getRootNode().activeElement)){const a=t._value,i=()=>{n.removeAttribute("required"),t._requiredMessage&&(t.hideMessage(t._requiredMessage),delete t._requiredMessage)},r=t._getCurrentValue();if(t.required){const e=t.$.editableElement;"markdown"===t.editMode&&!t.$.input.value||"markdown"!==t.editMode&&!e.textContent&&!e.querySelectorAll("img, table").length?(n.hasAttribute("required")||n.setAttribute("required",""),t._requiredMessage||(t._requiredMessage=t.showMessage(t.localize("requiredMessage"),{autoClose:!1,iconType:"error"}))):i()}else i();a!==r&&(t.$.fireEvent("change",{oldValue:a,value:r}),t.name&&e.target===o&&"markdown"!==t.editMode&&(t.$.input.value=t._getInputValue(o.innerHTML.trim()))),t.removeAttribute("focus"),t.removeAttribute("aria-activedescendant")}}_editableElementFocusHandler(e){const t=this,o=t.editMode,n="markdown"===o?t.$.input:t.$.editableElement;let a=t._autoSaveObj;t.setAttribute("focus",""),e.target.id&&t.setAttribute("aria-activedescendant",e.target.id),t._value=t._getCurrentValue(),t.autoSave?(a||(a=t._autoSaveObj={}),clearInterval(a.interval),a.interval=setInterval((()=>{n.getRootNode().activeElement!==n&&clearInterval(a.interval),window.localStorage.setItem("smartEditor"+t.id,"markdown"===o?n.value:n.innerHTML)}),t.autoSaveInterval)):a&&(clearInterval(a.interval),delete t._autoSaveObj)}_inputChangeEvent(e){e.stopPropagation()}_updateOnInputChange(e){const t=this,o=t.$.editableElement,n=e.target,a=t.$.input,i=n.classList.contains("smart-search-input"),r=()=>{const e=l===a?a.value:t.$.editableElement.innerHTML;void 0!==s&&e!==s&&t.$.fireEvent("changing",{value:e,oldValue:t._changingValue})};if("paste"===e.type&&o.contains(n)){const o=e.clipboardData;if(o&&o.types.length){const n=o.types.indexOf("text/html")>-1?"text/html":"text/plain",[a,i]=["\x3c!--StartFragment--\x3e","\x3c!--EndFragment--\x3e"];let r=o.getData(n);e.preventDefault();let l=(e.clipboardData||e.originalEvent.clipboardData).items,s=null;for(let e=0;e<l.length;e++)0===l[e].type.indexOf("image")&&(s=l[e].getAsFile());if(null!==s){let e=new FileReader;return e.onload=function(e){t.$.editableElement.getRootNode().execCommand("insertHTML",!1,`<img src="${e.target.result}"/>`)},void e.readAsDataURL(s)}r.indexOf(a)>-1&&r.indexOf(i)>-1&&(r=r.slice(r.indexOf(a),r.indexOf(i))),t._handlePasteAction(r,{advanced:!0,value:t.pasteFormat},n)}}const l=o.getRootNode().activeElement,s=t._changingValue;if(!t.$.contentContainer.hasAttribute("split-mode")){if(clearTimeout(t._refreshTimeout),delete t._refreshTimeout,i){const o=t.findAndReplaceTimeout,n=e.key;if(clearTimeout(t._findAndReplaceTimeout),!n||"enter"===n.toLowerCase())return;return void(o?t._findAndReplaceTimeout=setTimeout((()=>t._applySearching(e.target.value)),o):t._applySearching(e.target.value))}const o=t._resizeFrameObj?t._resizeFrameObj.target:void 0;return o&&!o.parentElement&&(t._setResizeFrame(),t._closeToolbar()),void r()}r(),clearTimeout(t._refreshTimeout);let d=t.$.input.value;t._refreshTimeout=setTimeout((()=>{clearTimeout(t._refreshTimeout),"markdown"===t.editMode?t.$.editableElement.innerHTML=window.marked?window.marked(d):d:l===a?t.$.editableElement.innerHTML=t._getInputValue(d,!0):t.$.input.value=t._getInputValue(t.$.editableElement.innerHTML.trim())}),t.splitModeRefreshTimeout)}_editableElementWheelHandler(){const e=this.$.inlineToolbar;this._setResizeFrame(),e&&e.visible&&e.close()}_editableElementKeyDownHandler(e){const t=this,o=t.$.editableElement,n=t.$.input,a=e.target.getRootNode().activeElement,i=e.key.toLowerCase(),r=t._isMacOS&&e.metaKey||e.ctrlKey;if(!t.disabled&&!t.readonly){switch(i){case"a":if(!r){t._changingValue=a===o?o.innerHTML:n.value;break}if(a.classList.contains("smart-editor-image-caption"))return e.preventDefault(),t._setSelectionRange(a),void t._handleInlineToolbar(t._getSelectionRange().startContainer);if(t._tableCell)return e.preventDefault(),t._setSelectionRange(t._tableCell),void t._handleInlineToolbar(t._getSelectionRange().startContainer);break;case"backspace":case"delete":{const i=t._resizeFrameObj?t._resizeFrameObj.target:void 0;i&&("img"===i.nodeName.toLowerCase()||i.classList.contains("smart-editor-video-container"))&&(e.preventDefault(),t._deleteResizeFrameTarget(i)),t._changingValue=a===o?o.innerHTML:n.value;break}case"enter":if(!t.disableSearchBar){const o=t._searchToolbar;o&&!o.classList.contains("smart-visibility-hidden")&&(e.preventDefault(),t._highlightSearchResult(!e.shiftKey))}break;case"escape":a===o?t._closeToolbar():a.classList.contains("smart-search-input")&&t._closeSearchToolbar();break;case"tab":t.enableTabKey&&(e.preventDefault(),t._handleTabInsert());break;default:t._handleToolbarShortcuts(e,a)}t._closeToolbar()}}_handleToolbarShortcuts(e,t){const o=this,n=o.$.editableElement,a=o.$.input,i=e.key,r=o._isMacOS&&e.metaKey||e.ctrlKey;if(!r)return void(o._changingValue=t===n?n.innerHTML:a.value);const l=o._resizeFrameObj;let s;switch(l&&l.target&&(s=l.target),i.toLocaleLowerCase()){case"b":e.preventDefault(),o._handleTextDecorations("bold");break;case"c":r&&s&&o._handleImageCopy(s);break;case"x":r&&s&&o._handleImageCut(s);break;case"k":e.preventDefault(),o._openWindow({name:"hyperlink"});break;case"i":e.shiftKey?(e.preventDefault(),o._openWindow({name:"image"},s)):(e.preventDefault(),o._handleTextDecorations("italic"));break;case"e":e.shiftKey?(e.preventDefault(),o._openWindow({name:"table"},s)):(e.preventDefault(),o._updateToolbarTarget({name:"alignment",value:"center"}));break;case"u":e.shiftKey?(e.preventDefault(),o._handleTextCase("uppercase")):(e.preventDefault(),o._handleTextDecorations("underline"));break;case"s":e.shiftKey&&(e.preventDefault(),o._handleTextDecorations("strikethrough"));break;case"l":e.shiftKey?(e.preventDefault(),o._handleTextCase("lowercase")):(e.preventDefault(),o._updateToolbarTarget({name:"alignment",value:"left"}));break;case"+":e.shiftKey&&(e.preventDefault(),o._handleSubSuperScript("superscript"));break;case"=":e.shiftKey?(e.preventDefault(),o._handleSubSuperScript("superscript")):(e.preventDefault(),o._handleSubSuperScript("subscript"));break;case"]":e.preventDefault(),o._handleIndentation("indent");break;case"[":e.preventDefault(),o._handleIndentation("outdent");break;case"h":if(e.shiftKey){const t=o._toolbarItemsObj.sourcecode;t&&(t.value=void 0===t.value||!t.value),e.preventDefault(),o._handleSourceCodeMode()}break;case"f":if(e.shiftKey){const t=o._toolbarItemsObj.fullscreen;t&&(t.value=void 0===t.value||!t.value),e.preventDefault(),o._handleFullScreenMode()}else!r||o.disableSearchBar||"html"!==o.editMode||n.classList.contains("smart-hidden")||(e.preventDefault(),o._openSearchBar());break;case"j":e.preventDefault(),o._updateToolbarTarget({name:"alignment",value:"justify"});break;case"r":e.shiftKey?(e.preventDefault(),o._handleClearFormat()):(e.preventDefault(),o._updateToolbarTarget({name:"alignment",value:"right"}));break;case"o":e.shiftKey?(e.preventDefault(),o._handleList("orderedlist")):e.altKey&&(e.preventDefault(),o._handleList("unorderedlist"))}}_editableElementMoveHandler(e){const t=this,o=t.$.editableElement,n=e.originalEvent||e,a=n.clientX,i=n.clientY,r=t.shadowRoot||t.isInShadowDOM?n.composedPath()[0]:n.target;if(e.stopPropagation(),!r||!r.closest||t._isMobile||"false"===o.getAttribute("contenteditable"))return void o.removeAttribute("table-cell-resize");const l=t._inlineToolbarClickObj;if(l&&l.resizeDetails||t._dragDetails)return;const s=r.tagName.toLowerCase();if(!r.closest(".smart-editor-editable table")||"td"!==s&&"th"!==s)return void o.removeAttribute("table-cell-resize");const d=r.getBoundingClientRect();i<d.bottom+5&&i>d.bottom-5?o.setAttribute("table-cell-resize","vertical"):a<d.right+5&&a>d.right-5&&r.nextElementSibling?o.setAttribute("table-cell-resize","horizontal"):o.removeAttribute("table-cell-resize")}_focusEditableElement(){const e=this,t=e.$.iframe,o=e.editMode;let n=e.$.editableElement;if(("markdown"===o||n.classList.contains("smart-hidden"))&&(n=e.$.input),t&&t.focus({preventScroll:!0}),n.getRootNode().activeElement!==n){const a=e._getSelectionRange(),i=n.scrollTop,r=t?t.contentWindow:window;if(n.focus({preventScroll:!0}),e._isSafari&&i&&(n.scrollTop=i),"markdown"===o||n.classList.contains("smart-hidden"))return void(void 0!==a.selectionStart&&e._setSelectionRange(a.selectionStart,a.selectionEnd));if(a instanceof r.Range){const e=(t?t.contentWindow:window).getSelection();e.removeAllRanges(),e.addRange(a)}}}_getTextFromCarret(){const e=this._getSelectionRange(),t=e.startContainer,o=t.textContent;let n,a;if(!e.toString()&&o.length>0&&o.indexOf(" ")>-1){const t=o.slice(0,e.startOffset).lastIndexOf(" ")+1;let i=o.slice(e.endOffset).indexOf(" ");i<0&&(i=o.length-1),n=t>-1?t:e.startOffset,a=Math.max(e.endOffset,e.endOffset+i)}else n=0,a=t.length;return{selectionStartIndex:n,selectionEndIndex:a}}_handleSearchButtonClick(e){const t=this;if(!e)return;const o=e.classList;o.contains("smart-search-button")&&(o.contains("prev")?t._highlightSearchResult():o.contains("next")?t._highlightSearchResult(!0):o.contains("close")&&t._closeSearchToolbar())}_highlightSearchResult(e){const t=this,o=t.$.contentContainer,n=t.$.editableElement.querySelectorAll(".find-and-replace-match"),a=o.querySelector(".smart-search-input-container"),i=n.length;for(let o=0,r=i;o<r;o+=1){const r=n[o];if(r.classList.contains("selected")){const l=e?Math.min(i-1,o+1):Math.max(0,o-1),s=n[l];return s&&(s.classList.add("selected"),a.setAttribute("selected",l+1),t._scrollToMarker(s)),void(s!==r&&r.classList.remove("selected"))}}}_handleToolbarItemClick(e,t){const o=this;if(!t)return;const n=o.$.inlineToolbar,a=o._toolbarItemClick,i=t.getAttribute("item-type"),r=t.getAttribute("item-name");let l,s;if(e&&(l=e.originalEvent||e,s=o.shadowRoot||o.isInShadowDOM?l.composedPath()[0]:l.target),"custom"!==i&&l&&(o.hasRippleAnimation&&"delimiter"!==i&&Smart.Utilities.Animation.Ripple.animate(s,l.pageX,l.pageY),a&&a.callback))return a.callback.call(o,t,a.target),void o.$.fireEvent("toobarItemClick",{value:r,originalEvent:l});o.$.fireEvent("actionStart",{name:r}).defaultPrevented||(o._handleToolbarItemAction(t),o._closeToolbarItemDropDown(o.$.inputPopup),o._closeToolbarItemDropDown(o.$.colorInputPopup),n&&n.close(),l&&o.$.fireEvent("toobarItemClick",{value:r,originalEvent:l}),r&&o.$.fireEvent("actionEnd",{name:r}))}_handleToolbarItemAction(e){const t=this,o=t._toolbarItemClick;if(!e)return;const n=e.getAttribute("item-type"),a=e.getAttribute("item-name");if("custom"!==n)switch(a){case"bold":case"italic":case"underline":case"strikethrough":t._handleTextDecorations(a);break;case"clearformat":t._handleClearFormat();break;case"redo":case"undo":t._handleUndoRedo(a);break;case"lowercase":case"uppercase":t._handleTextCase(a);break;case"backgroundcolor":t._handleBackgroundColor(e.getAttribute("item-value"));break;case"fontcolor":t._handleFontColor(e.getAttribute("item-value"));break;case"findandreplace":case"editlink":t._openWindow(e);break;case"openlink":{const o=t.$.inlineToolbar;if(o&&o.contains(e)){const e=o.selector;let t;e.nodeName!==Node.TEXT_NODE&&(t=e.closest(".smart-editor-editable a")),t&&window.open(t.href,t.target)}break}case"caption":{if(!o)break;const e=o.target;if(e&&"img"===e.nodeName.toLowerCase()){const o=e.closest(".smart-editor-image-container");let n;o&&o.querySelector(".smart-editor-image-caption")||(n=t.localize("captionPlaceholder")),t._handleImgCaption(e,{caption:n,focusCaption:!0})}else if(e.classList.contains("smart-editor-video-container")){const o=e.querySelectorAll(".smart-editor-video-container > video, .smart-editor-video-container > iframe");let n;e.querySelector(".smart-editor-image-caption")||(n=t.localize("captionPlaceholder")),t._handleVideoCaption(o[0]||o[1],{caption:n,focusCaption:!0})}break}case"cut":case"copy":case"paste":t._handleClipboardAction(a);break;case"delete":t._resizeFrameObj&&t._resizeFrameObj.target?t._deleteResizeFrameTarget(o.target):t._handleTextDelete();break;case"removelink":o&&t._handleLinkRemove(o.target);break;case"tableheader":case"tablerows":case"tablecolumns":case"tablevalign":case"tablestyle":t._handleTableToolbarAction(e);break;case"sourcecode":t._handleSourceCodeMode(e);break;case"splitmode":t._handleSplitMode(e);break;case"fullscreen":t._handleFullScreenMode(e);break;case"orderedlist":case"unorderedlist":t._handleList(a);break;case"indent":case"outdent":t._handleIndentation(a);break;case"subscript":case"superscript":t._handleSubSuperScript(a);break;case"print":t._handlePrint();break;default:t._inlineToolbarItemsObj?t._updateEditorViaWindow(t._inlineToolbarItemsObj[a]):t._toolbarItemsObj&&t._updateEditorViaWindow(t._toolbarItemsObj[a])}}_handleCommonToolbarAction(e,t){const o=this;if("html"===o.editMode){const n=o._getSelectionRange(),a=o.$.iframe,[i,r]=a?[a.contentDocument,a.contentWindow]:[document,window];let l,s=n.startContainer;if(!s)return;const d=e=>"string"==typeof e?("removeFormat"===e&&o.removeStylesOnClearFormat&&o._removeNodeStyles(n.commonAncestorContainer),i.execCommand(e)):"object"==typeof e?i.execCommand(e.name,!1,e.value):void 0;if(n.startOffset===n.endOffset&&s.nodeType===Node.TEXT_NODE){const{selectionStartIndex:e,selectionEndIndex:t}=o._getTextFromCarret();l=n.startOffset-e,o._setSelectionRange(s,e,t)}d(e)&&void 0!==l&&o._setSelectionRange(r.getSelection().focusNode,l,l),t&&o._updateToolbarItems(t)}}_handleClearFormat(){this._handleCommonToolbarAction("removeFormat")}_handleFontName(e){this._handleCommonToolbarAction(e)}_handleFontSize(e){const t=this;if("markdown"===t.editMode)return;const o=t._getSelectionRange();let n,a=o.startContainer;if(a){if(o.startOffset===o.endOffset){if(a.nodeType!==Node.TEXT_NODE){const n=document.createElement("font");return o.insertNode(n),t._setSelectionRange(n),void(n.style.fontSize=e.value+"px")}{const{selectionStartIndex:e,selectionEndIndex:i}=t._getTextFromCarret();n=o.startOffset-e,t._setSelectionRange(a,e,i)}}if((t.$.editableElement.getRootNode()||document).execCommand("fontSize",!1,3)){const a=t.$.iframe,i=a?a.contentWindow:window;if(o.commonAncestorContainer.closest){const t=o.commonAncestorContainer.querySelectorAll("font[size]");for(let o=0,n=t.length;o<n;o+=1){const n=t[o];n.removeAttribute("size"),n.style.fontSize=e.value+"px"}}else{const t=i.getSelection().focusNode;if(!t)return;const o=t.closest?t.closest(".smart-editor-editable font"):t.parentElement;"font"===o.nodeName.toLowerCase()&&(o.removeAttribute("size"),o.style.fontSize=e.value+"px")}void 0!==n&&t._setSelectionRange(i.getSelection().focusNode,n,n)}}}_handleFormats(e){const t=this;if("markdown"!==t.editMode)t._getSelectionRange().startContainer&&t.$.editableElement.getRootNode().execCommand("formatBlock",!1,e.value);else{let o;switch(e.value){case"h1":o="#";break;case"h2":o="##";break;case"h3":o="###";break;case"h4":o="####";break;case"h5":o="#####";break;case"h6":o="######";break;case"code":case"pre":o="```\n\n```";break;case"blockquote":o=">";break;case"p":o="";break;default:o=e.value}const n=e.dataSource,a=t.$.input.selectionStart;if(n){const e=n.map((e=>e.value));for(let o=0,n=e.length;o<n;o+=1){const n=t._getMarkdownFormat(a,e[o]);if(n&&void 0!==n.formatName){t._removeMarkDown(n.markdown,n.occuranceIndex,!0);break}}}0===o.indexOf("#")||0===o.indexOf(">")?(o+=" ",t._insertMarkDown(o,t.$.input.selectionStart+o.length,!0)):t._insertMarkDown(o,t.$.input.selectionStart+o.length/2)}}_handleSubSuperScript(e){const t=this;"markdown"!==t.editMode?t._handleCommonToolbarAction(e,["subscript","superscript"]):t._handleMarkdownItem(e)}_handleMarkdownItem(e){const t=this,o=t.$.input,n=t._getSelectionRange(),a=n.selectionStart,i=n.selectionEnd;let r,l,s,d=o.value;switch(e){case"bold":l="**",s="**";break;case"italic":l="*",s="*";break;case"underline":l="<ins>",s="</ins>";break;case"strikethrough":l="~~",s="~~";break;case"subscript":l="<sub>",s="</sub>";break;case"superscript":l="<sup>",s="</sup>"}if(void 0!==a&&a!==i){const e=l.length,n=s.length;if(r=d.slice(a,i),d.slice(a-e,a)===l&&d.slice(i,i+n)===s)return o.value=d.slice(0,a-e)+r+d.slice(i+n),t._refreshMarkdownPreview(),void t._setSelectionRange(o,a-e,i-e)}l&&s&&t._insertMarkDown(l+s,o.selectionStart+l.length)}_handleTextDecorations(e){const t=this;if("markdown"===t.editMode)return void t._handleMarkdownItem(e);const o=t._getSelectionRange();let n,a=o.startContainer;if(a){if(o.startOffset===o.endOffset&&a.nodeType===Node.TEXT_NODE){const{selectionStartIndex:e,selectionEndIndex:i}=t._getTextFromCarret();n=o.startOffset-e,t._setSelectionRange(a,e,i)}if((t.$.editableElement.getRootNode()||document).execCommand(e))if(void 0!==n){const e=t.$.iframe,o=e?e.contentWindow:window,a=o.getSelection().focusNode;a.textContent=a.textContent.trim(),t._setSelectionRange(o.getSelection().focusNode,n,n)}else t._setSelectionRange();t._updateToolbarItems([e])}}_handlePasteAction(e,t,o){if(!e)return;const n=this;if(t&&!t.name&&"prompt"===n.pasteFormat){const a={name:"paste",text:e,textType:o};return t&&(a.value=t.value,a.advanced=t.advanced),void n._openWindow(a)}n._handleTextPaste(e,t,o)}_handleTextPaste(e,t,o){const n=this,a=n.$.input;if(n.$.contentContainer.classList.contains("char-count-maxed"))return;if("markdown"===n.editMode)return n._insertMarkDown(e),void n._setCharCount();e=e.replace(/<!--StartFragment-->|<!--EndFragment-->/gi,"");let i,r,l=n.pasteFormat;if(t&&t.advanced&&(l=t.value),!o||"plainText"===l){const t=document.createElement("div");t.innerHTML=e,e=t.innerText}const s=e.toLocaleLowerCase();if(i=document.createElement("span"),i.innerHTML=e,s.indexOf("<video")>-1||s.indexOf("<iframe")>-1||s.indexOf("smart-editor-image-caption")>-1){const e=i.querySelectorAll("video, iframe"),t=i.querySelector(".smart-editor-image-caption"),o=e.length>0;let n=document.createDocumentFragment();for(let t=0,o=e.length;t<o;t+=1)n.appendChild(e[t]);if(t&&(t.removeAttribute("style"),n.appendChild(t)),o||t){const e=document.createElement("span");i.classList.add("smart-editor-image-container"),o&&i.classList.add("smart-editor-video-container"),i.setAttribute("contenteditable",!1),n.childElementCount&&(i.innerHTML="",i.appendChild(n)),e.appendChild(i),i=e}}if("cleanFormat"===l&&n._removeNodeStyles(i),o&&"text/plain"!==o||(i=document.createTextNode(i.innerHTML),r=Node.TEXT_NODE),a.getRootNode().activeElement===a){const e=a.value;return a.value=e.slice(0,a.selectionStart)+(r===Node.TEXT_NODE?i.textContent:i.innerHTML)+e.slice(a.selectionEnd),void n._setCharCount()}const d=n._getSelectionRange(),c=n.$.iframe,[m,u]=c?[c.contentWindow,c.contentDocument]:[window,document];if(!(d instanceof m.Range))return u.execCommand("paste"),void n._handleContentFiltering();if(d.deleteContents(),i.childNodes.length)for(;i.lastChild;)d.insertNode(i.lastChild);else d.insertNode(i);d.collapse(),n._handleContentFiltering()}_removeNodeStyles(e){if(e&&e.nodeType!==Node.TEXT_NODE){const t=e.querySelectorAll("style, [style]");for(let e=0,o=t.length;e<o;e+=1){const o=t[e];"style"===o.nodeName.toLowerCase()?o.remove():t[e].removeAttribute("style")}e.removeAttribute("style")}}_handlePaste(e){const t=this,o=navigator.clipboard,n=o.read?"read":"readText",a=()=>{o[n]&&o[n]().then((o=>{if(Array.isArray(o)&&o.length){const n=o[0],a=n.types.indexOf("text/html")>-1?"text/html":"text/plain";n.getType(a).then((o=>{o.text().then((o=>t._handlePasteAction(o,e,a)))}))}else"string"==typeof o&&t._handlePasteAction(o,e)}))};if(navigator.permissions&&navigator.permissions.query&&!t._isFireFox)try{navigator.permissions.query({name:"clipboard-read"}).then((e=>{("granted"===e.state||"prompt"===e.state&&o[n])&&a()}))}catch(e){t.error(t.localize("permissionsRequired",{elementType:t.nodeName.toLowerCase(),actionName:"paste"}))}else if(o[n])return void a();t.$.editableElement.getRootNode().execCommand("paste")}_handlePasteViaWindow(e){const t=this,o=t._getItemOptionsViaWindow(e);if(!e||"paste"!==e.name)return;let n=t.pasteFormat;for(let e in o)if(o[e]){n=e;break}e.value=n,t._handleTextPaste(e.text,e,e.textType)}_handleClipboardAction(e){const t=this,o=t.editMode,n=t.$.input;if("paste"===e)return void t._handlePaste();const a=t._getSelectionRange();if(("copy"===e||"cut"===e)&&(document.execCommand("copy"),"cut"===e))if("markdown"===o){const e=n.value,o=n.selectionStart;n.value=e.slice(0,o)+e.slice(n.selectionEnd),t._setSelectionRange(n,o,o),t._refreshMarkdownPreview()}else a.deleteContents()}_handleLinkRemove(e){const t=this;let o;if(e&&"img"===e.nodeName.toLowerCase())o=e.closest(".smart-editor-editable a"),o&&(o.parentElement.insertBefore(e,o),o.remove());else{const e=t.$.iframe;let o,n;e?(o=e.contentDocument,n=e.contentWindow):(o=document,n=window);const a=n.getSelection(),i=t._getSelectionRange();a.removeAllRanges(),a.addRange(i);const r=a.anchorNode?a.anchorNode.parentElement:void 0;if(!r||"a"!==r.nodeName.toLowerCase())return;i.selectNode(a.anchorNode),o.execCommand("unlink",!1,!1)}}_handleBackgroundColor(e){const t=this;if("markdown"===t.editMode)return;const o=t.$.iframe,n="string"==typeof e?e:e.value,[a,i]=o?[o.contentDocument,o.contentWindow]:[document,window],r=t.$.inlineToolbar,l=t._getSelectionRange(),s=r&&r.visible?r.selector:l.commonAncestorContainer;let d;if(s&&["th","td"].indexOf(s.nodeName.toLowerCase())>-1){if(l.startOffset===l.endOffset)return void(s.style.backgroundColor=n);d=s.style.backgroundColor}const c=l.startOffset,m=l.endOffset,u=l.startContainer;let b;if(u&&u.nodeType===Node.TEXT_NODE&&l.startOffset===l.endOffset){const{selectionStartIndex:e,selectionEndIndex:o}=t._getTextFromCarret();b=l.startOffset-e,t._setSelectionRange(u,e,o)}else u.closest&&c!==m&&t._setSelectionRange(u,c,m);const p=a.execCommand("hiliteColor",!1,n&&"transparent"!==n?n:"transparent");s&&d?s.style.backgroundColor=d:p&&void 0!==b&&t._setSelectionRange(i.getSelection().focusNode,b,b)}_handleFontColor(e){const t=this;if("markdown"===t.editMode)return;const o=t._getSelectionRange(),n="string"==typeof e?e:e.value,a=o.startContainer,i=t.$.iframe,r=n?"foreColor":"removeFormat",[l,s]=i?[i.contentDocument,i.contentWindow]:[document,window];let d;if(a&&a.nodeType===Node.TEXT_NODE&&o.startOffset===o.endOffset){const e=a.parentElement;if("font"===e.nodeName.toLocaleLowerCase())return void(e.color=n);const{selectionStartIndex:i,selectionEndIndex:r}=t._getTextFromCarret();d=o.startOffset-i,t._setSelectionRange(a,i,r)}l.execCommand(r,!1,n)&&void 0!==d&&t._setSelectionRange(s.getSelection().focusNode,d,d)}_handlePrint(){const e=this,t=e.dataExport.fileName;e.dataExport.fileName=null;const o=window.open("","","width=800,height=500"),n=o.document.open(),a='<!DOCTYPE html><html><head><meta charset="utf-8" /><title>'+t+"</title></head><body>"+e._handleDataExport("html")+"</body></html>";try{n.write(a),n.close(),setTimeout((function(){o.print(),o.close()}),100)}catch(e){}e.dataExport.fileName=t}_handleDataExport(e,t){const o=this;if(!Smart.Utilities.DataExporter)return void o.error(o.localize("missingReference",{elementType:o.nodeName.toLowerCase(),methodName:"exportData",files:"smart.export.js"}));try{new JSZip}catch(e){return void o.error(o.localize("missingReference",{elementType:o.nodeName.toLowerCase(),methodName:"exportData",files:"jszip.min.js"}))}if("pdf"===e&&!window.pdfMake)return void o.error(o.localize("missingReference",{elementType:o.nodeName.toLowerCase(),methodName:"exportData",files:"pdfMake.min.js"}));if("pdf"===e)return void o._exportToPDF(o.dataExport.fileName,e);let n;if("markdown"===o.editMode){const t=o.$.input;n="md"!==e&&window.marked?window.marked(t.value):t.value}else n=o.$.editableElement["pdf"===e?"textContent":"innerHTML"];const a=new Smart.Utilities.DataExporter({exportHeader:!1,pageOrientation:o.dataExport.pageOrientation,style:o.dataExport.style}),i=[{value:n}];return o._setExportStyles(a,e),a.exportData(i,e,o.dataExport.fileName,t)}_exportToPDF(e,t){const o=this,n=o.$.editableElement,a=window.getComputedStyle(o),i=o.dataExport.style,r={pageOrientation:o.pageOrientation||"portrait",info:{title:"smartEditor",creator:"Smart",producer:"Smart"}};if(i&&(r.styles=i),r.defaultStyle={fontSize:parseFloat(a.fontSize)},"markdown"===o.editMode){const e=o.$.input,a=document.createElement("div");let i;"md"!==t?n.classList.contains("smart-hidden")?(a.innerHTML=window.marked?window.marked(e.value):e.value,i=o._processHTMLAsPDFObject(a,[])):i=o._processHTMLAsPDFObject(n,[]):(a.innerHTML=e.value,i=o._processHTMLAsPDFObject(a,[])),r.content=i}else r.content=o._processHTMLAsPDFObject(o.$.editableElement,[]);try{pdfMake.createPdf(r).download(e)}catch(e){console.error(o.localize("exportError",{elementType:o.nodeName.toLowerCase(),status:e.toString()}))}}_processHTMLAsPDFObject(e,t,o){const n=this,a={},i=["left","center","right"],r=e.childNodes,l=["td","th"].indexOf(e.nodeName.toLowerCase())>-1;for(let o=0,s=r.length;o<s;o+=1){const s=r[o],d=s.nodeName.toLowerCase(),c=s.nodeType===Node.TEXT_NODE;let m;if("table"===d){const e=s.querySelectorAll("thead tr"),t=s.querySelectorAll("thead tr:last-of-type td, thead tr:last-of-type th"),o=s.querySelectorAll("tbody tr:last-of-type td, tbody tr:last-of-type th"),a=t.length?t:o,i=s.querySelectorAll("body tr");let r=e.length;if(!r)for(let e=0,t=i.length;e<t&&Array.from(i[e].children).every((e=>"th"===e.nodeName.toLowerCase()));e+=1)r++;m={table:{headerRows:r,widths:(()=>{const e=Math.round(100/a.length)+"%";let t=[];for(let o=0,n=a.length;o<n;o+=1)t.push(e);return t})(),body:(()=>{let e=[];for(let t=0,o=i.length;t<o;t+=1){const o=i[t],r=o.children;let l=[];for(let e=0,t=o.childElementCount;e<t;e+=1){const t=n._processHTMLAsPDFObject(r[e],[],!0);if(o.childElementCount<a.length){let e;for(e=Array.isArray(t)&&1===t.length?t[0]:{text:t},e.colSpan=Math.round(a.length/o.childElementCount),l.push(e);l.length<a.length;)l.push({text:""})}else l.push(1===t.length?t[0]:t)}e.push(l)}return e})()}}}else if("ul"===d)m={ul:n._processHTMLAsPDFObject(s,[])};else if("ol"===d)m={ol:n._processHTMLAsPDFObject(s,[])};else if("img"===d){const e=document.createElement("canvas"),t=e.getContext("2d");let o;e.width=s.naturalWidth||s.width,e.height=s.naturalHeight||s.height,t.drawImage(s,0,0);try{o=e.toDataURL("image/png")}catch(e){console.error(n.localize("exportError",{elementType:n.nodeName.toLowerCase(),status:e.toString()}));continue}if(o.indexOf("image/png")<0){console.error(n.localize("exportError",{elementType:n.nodeName.toLowerCase(),status:"Invalid image"}));continue}m={image:o,width:s.width,height:s.height}}else"a"===d?(m={},s.childElementCount?s.querySelector("img")&&(m=n._processHTMLAsPDFObject(s,[],!0)[0]||{}):m.text=s.textContent,m.link=s.href):s.childElementCount?t=t.concat(n._processHTMLAsPDFObject(s,[],!0)):m={text:s.textContent.trim()?s.textContent:"\n"};if(m){const o=window.getComputedStyle(c?e:s);if(!c||l){const e=o.backgroundColor,t=parseFloat(o.fontSize);isNaN(t)||(m.fontSize=t),m.alignment=a.alignment=i.indexOf(o.textAlign)>-1?o.textAlign:i[0],"rgba(0, 0, 0, 0)"!==e&&"transparent"!==e&&(m.fillColor=a.fillColor=n._RGBAtoHex(e)),parseInt(o.fontWeight)>500&&(m.bold=!0),"italic"===o.fontStyle&&(m.italics=!0)}m.inlineElement=c||o.display.indexOf("inline")>-1,m.color=a.color=n._RGBAtoHex(o.color),t.push(m)}}return 1===t.length?t:o||l?(a[t.every((e=>e.inlineElement&&!e.image))?"text":"stack"]=t,[a]):t}_RGBAtoHex(e){const t=/rgb[a]?\(\s*(\d+),\s*(\d+),\s*(\d+),?\s*(\d*.\d+|\d+)?\)/gi.exec(e.replace(/\s/g,""));if(null===t)return e;const o=parseFloat(t[1]).toString(16).toUpperCase(),n=parseFloat(t[2]).toString(16).toUpperCase(),a=parseFloat(t[3]).toString(16).toUpperCase();return"#"+"0".repeat(2-o.length)+o+"0".repeat(2-n.length)+n+"0".repeat(2-a.length)+a}_setExportStyles(e,t){const o=this;if(e.style)return;const n=window.getComputedStyle(o),a=n.getPropertyValue("--smart-border-width")||"1px",i=n.getPropertyValue("--smart-border")||"black",r=n.getPropertyValue("--smart-editor-table-column-width")||"initial",l=n.getPropertyValue("--smart-editor-table-cell-min-height")||"20px",s=n.getPropertyValue("--smart-editor-table-cell-min-width")||l,d=n.getPropertyValue("--smart-surface")||"#333",c=n.getPropertyValue("--smart-alternation-index0-background")||d;e.style={border:"initial",width:"100%",height:o.$.editableElement.scrollHeight+"px",removeDefault:!0,custom:`\n ${"html"===t&&o.rightToLeft?"body { direction: rtl; }":""}\n\n .column table {\n width: 100%;\n border-collapse: collapse;\n empty-cells: show;\n border-spacing: 0;\n table-layout: fixed;\n }\n \n .column td, .column th {\n border: ${a} solid ${i};\n width: ${r};\n min-height: ${l};\n min-width: ${s};\n padding: 2px 5px;\n vertical-align: middle;\n }\n \n .column table img {\n max-width: 100%;\n }\n \n .column table table {\n width: 100%;\n }\n \n .column table th {\n background: ${d};\n }\n\n .column th:empty::before,\n .column td:empty::before {\n content: 'A';\n visibility: hidden;\n }\n \n .column table[dashed-borders] th, .column table[dashed-borders] td {\n border-style: dashed;\n }\n \n .column table[alternation] tr:nth-child(2n) {\n background-color: ${c};\n }\n \n .column .smart-editor-image-container {\n display: inline-block;\n }\n \n .column .smart-editor-image-container[display="block"] {\n display: block;\n }\n \n .column .smart-editor-image-container[display="block"][alignment="left"] img {\n margin-left: 0;\n }\n \n .column .smart-editor-image-container[display="block"][alignment="left"] .smart-editor-image-caption {\n text-align: left;\n }\n \n .column .smart-editor-image-container[display="block"][alignment="right"] img {\n margin-right: 0;\n }\n \n .column .smart-editor-image-container[display="block"][alignment="right"] .smart-editor-image-caption {\n text-align: right;\n }\n \n .column .smart-editor-image-container:not([display="block"])[alignment="left"] {\n float: left;\n }\n \n .column .smart-editor-image-container:not([display="block"])[alignment="right"] {\n float: right;\n }\n \n .column .smart-editor-image-container .smart-editor-image-caption {\n display: block;\n text-align: center;\n outline: none;\n }`}}_handleSourceCodeMode(e){const t=this,o=t.editMode,n=t._toolbarItemsObj.sourcecode;let a;if(t.$.contentContainer.hasAttribute("split-mode"))return;e?a=e.hasAttribute("checked"):(a=n?n.value:!t.classList.contains("preview-mode"),e=t.$.toolbar.querySelector('.smart-editor-toolbar-item[item-name="sourcecode"]')),t._closePopups(),t._closeWindow(),t._closeSearchToolbar(),t._setResizeFrame(),t._handleTableSelection();const i=t.$.editableElement,r=t.$.input;"markdown"===o?a&&i.classList.contains("smart-hidden")?(i.innerHTML=window.marked?window.marked(r.value):r.value,i.classList.remove("smart-hidden"),r.classList.add("smart-hidden"),i.focus({preventScroll:!0})):!a&&r.classList.contains("smart-hidden")&&(i.classList.add("smart-hidden"),r.classList.remove("smart-hidden"),r.focus({preventScroll:!0})):a&&r.classList.contains("smart-hidden")?(r.value=t._getInputValue(i.innerHTML),i.classList.add("smart-hidden"),r.classList.remove("smart-hidden"),r.focus({preventScroll:!0})):!a&&i.classList.contains("smart-hidden")&&(i.innerHTML=t._getInputValue(r.value,!0),r.classList.add("smart-hidden"),i.classList.remove("smart-hidden"),i.focus({preventScroll:!0}),t._handleContentFiltering()),a?t.classList.add("preview-mode"):t.classList.remove("preview-mode"),n&&(n.value=a),e&&n&&(a?(e.setAttribute("checked",""),e.setAttribute("aria-pressed",!0)):(e.removeAttribute("checked"),e.setAttribute("aria-pressed",!1)),t._setTextSelection(),t._setToolbarItemAttr("sourcecode","disabled",n.disabled))}_setTextSelection(){const e=this,t=e.$.input,o=e.$.editableElement,n=e._selectionRange;if(!n)return;const a=n.commonAncestorContainer;if(a){if(t.classList.contains("smart-hidden"))return;const i=e._getParentCharDetails(n.startContainer,a),r=e._getParentCharDetails(n.endContainer,a),l=e._getSiblingsCharOffset(i.parentElement,r.parentElement),{charOffset:s}=e._getParentCharDetails(a,o),d=n.startOffset+i.charOffset+s,c=n.endOffset+r.charOffset+l+s;e._setSelectionRange(t,d,c)}else if(!o.classList.contains("smart-hidden")){const a=n.selectionStart,i=n.selectionEnd,r=t.value;if(void 0===a||void 0===i||a===i&&(r.length===a||0===a))return;if(0===a&&i===o.innerHTML.length)return void e._setSelectionRange(o);const l=e._getNodeByChartOffset(o.firstChild,a,i);if(!l)return;const{node:s,charOffset:d}=l;e._setSelectionRange(s,a-d,i-d)}}_getNodeByChartOffset(e,t,o){const n=this;let a=0;for(;e;){const i=e.outerHTML||e.textContent,r=i.length;if(a<=t&&a+r>=o){e.tagName&&(a+=e.outerHTML.slice(0,i.indexOf(e.innerHTML)).length);const r=n._getNodeByChartOffset(e.firstChild,t-a,o-a);return r?{node:r.node,charOffset:r.charOffset+a}:{node:e,charOffset:a}}e=e.nextSibling,a+=r}}_getParentCharDetails(e,t){let o=0;if(e===t)return{charOffset:o,parentElement:e.parentElement};let n=e,a=e.innerHTML||e.textContent,i=e.parentElement;for(;i&&i!==t&&t.contains(i);){const e=i.outerHTML;o+=e.indexOf(a),a=e,n=i,i=i.parentElement}return o+=(t.innerHTML||t.textContent).indexOf(a),{charOffset:o,parentElement:n}}_getPreSiblingOffset(e,t){let o=0,n=e.textContent,a=e.previousSibling;for(;a&&t.contains(a);){const e=a.outerHTML||a.textContent;n=e+n,o+=e.length,a=a.previousSibling}return o}_getSiblingsCharOffset(e,t){let o=0,n=e.nextSibling;if(e===t)return o;for(;n&&n!==t;)o+=(n.outerHTML||n.textContent).length,n=n.nextSibling;return o}_handleFullScreenMode(e){const t=this,o=t._toolbarItemsObj.fullscreen;let n;e?n=e.hasAttribute("checked"):(n=o?o.value:!t.classList.contains("full-screen-mode"),e=t.$.toolbar.querySelector('.smart-editor-toolbar-item[item-name="fullscreen"]')),t._closePopups(),t._setResizeFrame(),t._handleTableSelection(),n?(t.classList.add("full-screen-mode"),t._lastToolbarExpandedState=t.$.toolbar.hasAttribute("expanded")):(t.classList.remove("full-screen-mode"),t._lastToolbarExpandedState&&t._toggleToolbar()),o&&(o.value=n),e&&o&&(n?(e.setAttribute("cheched",""),e.setAttribute("aria-pressed",!0)):(e.removeAttribute("checked"),e.setAttribute("aria-pressed",!1)),o.disabled?(e.setAttribute("disabled",""),e.setAttribute("aria-disabled",!0)):(e.removeAttribute("disabled"),e.removeAttribute("aria-disabled")))}_handleSplitMode(e){const t=this,o=t.$.editableElement,n=t.$.input,a=t.$.contentContainer,i=t._toolbarItemsObj,r=i.splitmode,l=i.sourcecode,s=e?e.hasAttribute("checked"):!a.hasAttribute("split-mode"),d=t.editMode;t._closePopups(),s?("markdown"===d?o.innerHTML=window.marked?window.marked(n.value):n.value:n.value=o.innerHTML.trim(),a.setAttribute("split-mode",""),n.classList.remove("smart-hidden"),o.classList.remove("smart-hidden"),l&&t._setToolbarItemAttr("sourcecode","disabled",!0)):(a.removeAttribute("split-mode",""),"markdown"===d?o.classList.add("smart-hidden"):n.classList.add("smart-hidden"),l&&t._setToolbarItemAttr("sourcecode","disabled",!1)),r&&(r.value=s),e||(e=t.$.toolbar.querySelector('.smart-editor-toolbar-item[item-name="splitmode"]')),e&&(s?(e.setAttribute("checked",""),e.setAttribute("aria-pressed",!0)):(e.removeAttribute("checked"),e.setAttribute("aria-pressed",!1))),t._resizeFrameObj&&t._setResizeFrame(t._resizeFrameObj.target),t.classList.contains("preview-mode")&&t._handleSourceCodeMode()}_handleUndoRedo(e){this.$.editableElement.getRootNode().execCommand(e)}_handleTextCase(e){const t=this;if("markdown"===t.editMode)return;const o=t._getSelectionRange(),n=o.startContainer;if(!n)return;const a=n.textContent;let i,r,l,s,d=o.startOffset;n.nodeType===Node.TEXT_NODE&&o.startOffset===o.endOffset?(({selectionStartIndex:l,selectionEndIndex:s}=t._getTextFromCarret()),r=a.slice(l,s)):([l,s]=[d,o.endOffset],r=a.slice(d,o.endOffset),i=o.endOffset),r="lowercase"===e?r.toLowerCase():r.toUpperCase(),n.textContent=a.slice(0,l)+r+a.slice(s),t._setSelectionRange(n,d,i||d)}_handleList(e){const t=this;if(!e)return;if("markdown"===t.editMode){const o="orderedlist"===e?"1. ":"- ",n=t.$.input.selectionStart,a=t._getMarkdownFormat(n,"orderedlist"),i=t._getMarkdownFormat(n,"unorderedlist");if(a&&(t._removeMarkDown(o,a.occuranceIndex,"orderedlist"!==e),"orderedlist"===e))return;if(i&&(t._removeMarkDown(o,i.occuranceIndex,"unorderedlist"!==e),"unorderedlist"===e))return;return void t._insertMarkDown(o,t.$.input.selectionStart+o.length,!0)}let o,n,a=t._getSelectionRange();if(a.startContainer===a.endContainer&&(o=a.startOffset,n=a.endOffset),t.$.editableElement.getRootNode().execCommand("insert"+e,!1)){const e=t.$.iframe;a=(e?e.contentWindow:window).getSelection(),void 0!==n&&void 0!==n&&t._setSelectionRange(a.focusNode,o,n),t._updateToolbarItems(["orderedlist","unorderedlist"])}}_handleIndentation(e){"markdown"!==this.editMode&&this.$.editableElement.getRootNode().execCommand(e,!1)}_handleTextDelete(){this.$.editableElement.getRootNode().execCommand("delete")}_handleTabInsert(){this.$.editableElement.getRootNode().execCommand("insertHTML",!1,"	")}_handleTableToolbarAction(e,t){const o=this,n=o._toolbarItemClick;if(!t&&n&&(t=n.target),!t||"table"!==t.nodeName.toLowerCase()||!e)return;const a=e.getAttribute?e.getAttribute("item-name"):e.name,i=o.$.inlineToolbar;let r=e;if(r.closest){const e=o.$.inlineToolbar;r=(e&&e.contains(r)?o._inlineToolbarItemsObj:o._toolbarItemsObj)[a]}if(!n&&o.$.fireEvent("actionStart",{name:a}).defaultPrevented)return;switch(a){case"backgroundcolor":o._handleBackgroundColor(r);break;case"fontcolor":o._handleFontColor(r);break;case"fontsize":o._handleFontSize(r);break;case"tableheader":o._handleTableHeader(t);break;case"tablerows":o._handleTableRows(t,r);break;case"tablecolumns":o._handleTableColumns(t,r);break;case"tablevalign":o._handleTableVAlignment(t,r);break;case"alignment":o._handleTextAlignment(r);break;case"tablestyle":o._handleTableStyle(t,r);break;default:o._handleToolbarItemAction(e)}!n&&a&&o.$.fireEvent("actionEnd",{name:a}),i&&i.visible&&(o.$.editableElement.contains(i.selector)?i.reposition():o._closeToolbar());const l=o._getSelectionRange().startContainer;let s;if(l.nodeType===Node.TEXT_NODE){const e=l.parentElement;s=e.closest("th")||e.closest("td")}else s=["th","td"].indexOf(l.nodeName.toLowerCase())>-1;o._setResizeFrame(s&&t.contains(l)?t:void 0)}_handleTableHeader(e,t){let o,n,a=e.querySelector("th"),i=e.querySelector("tbody tr"),r=e.querySelector("thead");if(i&&(n=Array.from(i.children)),t||!r&&!a){if(void 0===t||!0===t){let t=e.querySelectorAll("tbody tr:first-of-type td").length;r||(r=document.createElement("thead")),o=r.querySelector("tr"),o||(o=document.createElement("tr"));const a=Array.from(o.children);for(;a.length>t;)a.pop().remove();for(let e=a.length;e<t;e+=1){const t=document.createElement("th");n[e]&&(t.style.width=n[e].style.width,n[e].style.width=""),o.appendChild(t)}r.appendChild(o),e.insertBefore(r,e.querySelector("tbody")||e.querySelector("tr"))}}else r&&r.remove(),a&&(o=a.closest("tr"),o&&o.remove(),Array.from(o.children).forEach(((e,t)=>n[t].style.width=e.style.width)))}_handleTableRows(e,t){if(!e)return;const o=this,n=o.$.inlineToolbar.selector,a=n.nodeName.toLocaleLowerCase();let i;if(!(n&&["th","td"].indexOf(a)>-1))return;if(i=n.closest("tr"),!i)return;const r=t.value,l=i.closest("thead");switch(r){case"insertRowAfter":case"insertRowBefore":{const t=document.createElement("tr"),o=i.parentElement;if(!o)break;const n=e.querySelector("tr").childElementCount,l="th"===a?"th":"td";for(let e=0;e<n;e+=1)t.appendChild(document.createElement(l));o.insertBefore(t,r.indexOf("Before")>-1?i:i.nextElementSibling);break}case"deleteRow":o._closeToolbar(),i.remove(),l&&!l.children.length&&l.remove()}const s=e.querySelectorAll("tr").length;s?(e.setAttribute("aria-rowcount",s),o._resizeFrameObj&&o._setResizeFrame(o._resizeFrameObj.target)):e.remove()}_handleTableColumns(e,t){if(!e)return;const o=this,n=o.$.inlineToolbar.selector;if(!(n&&["th","td"].indexOf(n.nodeName.toLowerCase())>-1))return;const a=t.value,i=Array.from(e.querySelectorAll("tr"));if(!i.length)return o._closeToolbar(),void e.remove();const r=Array.from(n.parentElement.children).indexOf(n);switch(a){case"insertColumnLeft":case"insertColumnRight":{const e=a.indexOf("Left")>-1;for(let t=0,o=i.length;t<o;t+=1){const o=i[t],n=o.children[r];if(n){const t="th"===n.tagName.toLowerCase()?"th":"td";o.insertBefore(document.createElement(t),e?n:n.nextElementSibling)}}break}case"deleteColumn":o._closeToolbar();for(let e=0,t=i.length;e<t;e+=1){const t=i[e].children[r];t&&t.remove()}}const l=i[0].children.length;l?(e.setAttribute("aria-colcount",l),o._resizeFrameObj&&o._setResizeFrame(o._resizeFrameObj.target)):e.remove()}_handleTextAlignment(e){if("markdown"===this.editMode)return;const t="justify"===e.value?"full":e.value;this.$.editableElement.getRootNode().execCommand("justify"+t.charAt(0).toUpperCase()+t.slice(1),!1,null)}_handleTableVAlignment(e,t){const o=this.$.inlineToolbar;if(!o)return;const n=o.selector;n&&["th","td"].indexOf(n.nodeName.toLowerCase())>-1&&(n.style.verticalAlign=t.value)}_handleTableStyle(e,t){const o=this.$.inlineToolbar.selector;if(o&&["th","td"].indexOf(o.nodeName.toLowerCase())>-1)switch(t.value){case"altrows":e.toggleAttribute("alternation");break;case"dashedborders":e.toggleAttribute("dashed-borders")}}_handleInlineToolbar(e){const t=this,o=e.nodeName.toLowerCase();"a"===o?(t._openInlineToolbar(e),t._refreshToolbarTabs()):"img"===o||["td","th"].indexOf(o)>-1?(t._setResizeFrame(e),t._openInlineToolbar(e),t._refreshToolbarTabs()):e.nodeType===Node.TEXT_NODE&&e.textContent.trim().length&&t._openInlineToolbar(e)}_handleTableCellResize(e){const t=this,o=t._inlineToolbarClickObj,n=o?o.resizeDetails:void 0;if(!n)return;const a=n.target,i=n.position,r=t.$.inlineToolbar;switch(n.started||t.$.fireEvent("resizeStart",{target:a}),a.setAttribute("resizing",""),n.started=!0,r&&r.visible&&(n.isInlineToolbarOpened=!0,t._closeToolbar()),i){case"horizontal":{const o=e.pageX+window.pageXOffset;if(t._setTableResizeDetails(n),!n.shrinkingCell)break;t._handleHorizontalTableCellResize(n,o);break}case"vertical":{const o=n.table;o.style.height&&(o.querySelectorAll("tr").forEach((e=>e.style.height=e.offsetHeight+"px")),o.style.height=""),t._resizeFrameObj&&t._resizeFrameObj.target&&t._setResizeFrame();const i=e.pageY+window.pageYOffset,r=n.y-i;let l=a.offsetHeight;l-=r,a.style.height=Math.max(1,l)+"px",l===a.offsetHeight&&(n.y=i+Math.abs(Math.min(0,l)));break}}}_setTableResizeDetails(e){const t=e.table,o=e.target;let n,a=e.expandingCell,i=e.shrinkingCell,r=e.isLastCell,l=e.areAllCellsResized;if(!a){const i=t.querySelector("tr"),r=Array.from(o.parentElement.children).indexOf(o);n=e.cells=Array.from(i.children),a=e.expandingCell=n[r]}e.shrinkingCell||(i=e.shrinkingCell=a.nextElementSibling,l=e.areAllCellsResized=!n.some((e=>e!==a&&e!==i&&!e.style.width)),r=e.isLastCell=l&&null===i.nextElementSibling,l&&!e.lastCell&&(e.lastCell=n[n.length-1]),r&&(i.style.width=""))}_handleHorizontalTableCellResize(e,t){const o=30,n=e.isLastCell;let a=e.expandingCell,i=e.shrinkingCell,r=a.offsetWidth,l=i.offsetWidth,s=e.x-t;const d=e.x-r+o,c=e.x+i.offsetWidth-o;if(n){const n=r+l-o;a.style.width=Math.min(Math.max(o,r-s),n)+"px",a.offsetWidth!==r&&(e.x=Math.min(c,Math.max(d,t)))}else{let n;s>0&&([a,i]=[i,a],[r,l]=[l,r],s*=-1),i.style.width=Math.max(o,l+s)+"px",n=i.offsetWidth-l,a.style.width=Math.max(o,a.offsetWidth-n)+"px",0!==n&&(e.x=Math.min(c,Math.max(d,t))),e.lastCell&&(e.lastCell.style.width="")}}_handleFrameResize(e){const t=this,o=t._resizeFrameObj;if(!o)return;t._closeToolbar();const n=o.resizableElement||o.target,a=o.resizeDetails,i=a.position,r=e.pageX+window.pageXOffset,l=e.pageY+window.pageYOffset,s=a.x-r,d=a.y-l;let c,m;c=n.offsetWidth,m=n.offsetHeight,a.started||(o.target.setAttribute("dragged",""),t.$.fireEvent("resizeStart",{target:n})),a.started=!0;const u=c,b=m,p=t.rightToLeft?-1:1;switch(i){case"top-left":n.style.width=Math.max(0,u+p*s)+"px",n.style.height=Math.max(0,b+d)+"px",c=n.offsetWidth,m=n.offsetHeight,u!==c&&(a.x-=p*(c-u)),b!==m&&(a.y-=m-b);break;case"bottom-left":n.style.width=Math.max(0,u+p*s)+"px",n.style.height=Math.max(0,b-d)+"px",c=n.offsetWidth,m=n.offsetHeight,u!==c&&(a.x-=p*(c-u)),b!==m&&(a.y+=m-b);break;case"bottom-right":n.style.width=Math.max(0,u-p*s)+"px",n.style.height=Math.max(0,b-d)+"px",c=n.offsetWidth,m=n.offsetHeight,u!==c&&(a.x+=p*(c-u)),b!==m&&(a.y+=m-b);break;case"top-right":n.style.width=Math.max(0,u+p*-s)+"px",n.style.height=Math.max(0,b+d)+"px",c=n.offsetWidth,m=n.offsetHeight,b!==m&&(a.y-=m-b),u!==c&&(a.x+=p*(c-u));break;case"top-center":n.style.height=Math.max(0,b+d)+"px",m=n.offsetHeight,b!==m&&(a.y-=m-b);break;case"bottom-center":n.style.height=Math.max(0,b-d)+"px",m=n.offsetHeight,b!==m&&(a.y+=m-b);break;case"left-center":n.style.width=Math.max(0,u+p*s)+"px",c=n.offsetWidth,u!==c&&(a.x-=p*(c-u));break;case"right-center":n.style.width=Math.max(0,u-p*s)+"px",c=n.offsetWidth,u!==c&&(a.x+=p*(c-u))}t._positionResizeHandles()}_deleteResizeFrameTarget(e){const t=this,o=t._getSelectionRange();if(e)if("img"===e.nodeName.toLowerCase()){const o=e.closest(".smart-editor-editable .smart-editor-image-container"),n=(o||e).parentElement,a=n&&"a"===n.nodeName.toLowerCase()?n:void 0;t._setResizeFrame(),(a||o||e).remove(),URL.revokeObjectURL(e.src)}else if(e.classList.contains("smart-editor-video-container")){const o=e.querySelector(".smart-editor-video-container video, .smart-editor-video-container > iframe");t._setResizeFrame(),e.remove(),o&&URL.revokeObjectURL(o.src)}else if("table"===e.nodeName.toLowerCase()){const o=e.closest(".smart-editor-editable table");o&&(t._setResizeFrame(),o.remove())}t._setCharCount(),t._setSelectionRange(o.startContainer,o.startOffset,o.endOffset),t._focusEditableElement()}_setResizeFrame(e,t){const o=this,n=o.$.editableElement;let a,i=e?e.nodeName.toLowerCase():"",r=o._resizeFrameObj;if("td"!==i&&"th"!==i||(e=e.closest(".smart-editor-editable table")),i=e?e.nodeName.toLowerCase():"",e&&e.parentElement&&("img"===i||"table"===i||e.classList.contains("smart-editor-video-container"))&&"false"!==n.getAttribute("contenteditable"))if(r?a=r.element:(r=o._resizeFrameObj={},a=r.element=document.createElement("span"),a.classList.add("smart-editor-resize-frame"),a.innerHTML='<span position="top-left"></span><span position="top-right"></span>\n <span position="bottom-left"></span><span position="bottom-right"></span>\n <span position="top-center"></span><span position="bottom-center"></span>\n <span position="left-center"></span><span position="right-center"></span>'),r.target&&r.target.removeAttribute("show-resize-frame"),r.target=e,e.classList.contains("smart-editor-video-container")?r.resizableElement=e.querySelector("video, iframe"):delete r.resizableElement,o._refreshToolbarTabs(),"false"!==e.getAttribute("resizable")){if(e.setAttribute("show-resize-frame",""),o._positionResizeHandles(),a.parentElement||o.$.contentContainer.appendChild(a),!t&&"img"===i){const e=o.$.iframe;(e?e.contentWindow:window).getSelection().collapse(null),o._updateToolbarItems()}}else e.removeAttribute("show-resize-frame");else{if(r){if(r.element.remove(),r.target){const e=n.querySelectorAll("[show-resize-frame]");for(let t=0,o=e.length;t<o;t+=1)e[t].removeAttribute("show-resize-frame")}delete r.target}o._refreshToolbarTabs()}}_setToast(){const e=this;let t=e.$.toast;return t||(e.$.toast=t=document.createElement("smart-toast"),t.appendTo=e.$.container,t.showCloseButton=!0,t.itemClass="smart-editor-message",e.$toast=Smart.Utilities.Extend(t)),t.rightToLeft=e.rightToLeft,t.theme=e.theme,t.animation=e.animation,t}_positionResizeHandles(){const e=this,t=e._resizeFrameObj;if(!e._resizeFrameObj)return;const o=t.element,n=e.rightToLeft,a=n?"right":"left",i=(t.resizableElement||t.target).getBoundingClientRect(),r=o.children,l=r[0],s=r[1],d=r[2],c=r[3],m=r[4],u=r[5],b=r[6],p=r[7],h=e.$.editableElement,g=e.$.contentContainer.getBoundingClientRect(),f=i.top-g.top+h.offsetTop,_=i.width,v=i.height;let w;n?(w=g.right-i.right+(h.offsetLeft+h.offsetWidth-g.width),l.style.left=d.style.left=b.style.left=""):(w=i.left-g.left+h.offsetLeft,l.style.right=d.style.right=b.style.right=""),l.style.top=s.style.top=m.style.top=f+"px",l.style[a]=d.style[a]=b.style[a]=w+"px",d.style.top=c.style.top=u.style.top=f+v+"px",s.style[a]=c.style[a]=p.style[a]=_+w+"px",m.style[a]=u.style[a]=w+_/2+"px",b.style.top=p.style.top=f+v/2+"px"}_openInlineToolbar(e){const t=this,o=t.$.editableElement;let n=t.$.inlineToolbar;if(t._closeToolbarItemDropDown(t.$.inputPopup),t._closeToolbarItemDropDown(t.$.colorInputPopup),"false"===o.getAttribute("contenteditable")||t.hideInlineToolbar)return void(n&&n.visible&&n.close());if(n||(n=t._createToolbar()),t.$.fireEvent("inlineToolbarOpening",{target:n}).defaultPrevented)return;t._setupToolbar(e,"inline"),n.parentElement||t.getShadowRootOrBody().appendChild(n);const a=t._getInlineToolbarContent(e);n.clear(),a instanceof DocumentFragment&&(n.appendChild(a),n.open(),t._setAriaOwns(n)),t._updateToolbarItems(void 0,n)}_closeToolbar(){const e=this,t=e.$.inlineToolbar;if(t){const o=t.classList,n=o.contains("smart-editor-context-menu")?"contextMenu":o.contains("smart-editor-inline-toolbar")?"inlineToolbar":"dropDownToolbar";if(e.$.fireEvent(n+"Closing",{target:t}).defaultPrevented)return;t.close()}}_closePopups(){const e=this;e._closeToolbar(),e._closeToolbarItemDropDown(e.$.inputPopup),e._closeToolbarItemDropDown(e.$.colorInputPopup)}_createToolbar(){const e=this;let t=e.$.inlineToolbar;return t||(t=document.createElement("smart-tooltip"),e.$.inlineToolbar=t,e.$inlineToolbar=Smart.Utilities.Extend(t),t)}_setupToolbar(e,t){const o=this,n=o.$.iframe,a=o.$.inlineToolbar,i=o.$inlineToolbar;if(!a.visible){const e=e=>o._tooltipVisibilityHandler.call(o,e),t=e=>o._tooltipVisibilityHandler.call(o,e),n=e=>o._tooltipChangeHandler.call(o,e),a=e=>o._tooltipClickHandler.call(o,e),r=e=>o._tooltipTransitionEndHandler.call(o,e);i.unlisten("open"),i.unlisten("close"),i.unlisten("change"),i.unlisten("click"),i.unlisten("transitionend"),i.listen("open",e),i.listen("close",t),i.listen("change",n),i.listen("click",a),i.listen("transitionend",r)}if(a.locale=o.locale,a.rightToLeft=o.rightToLeft,a.theme=o.theme,a.animation=o.animation,a.openMode="manual","inline"===t)a.position="auto",a.iframeRect=n?n.getBoundingClientRect():null,a.arrow=!0,a.align="center",a.offset=o.inlineToolbarOffset,a.classList.add("smart-editor-toolbar","smart-editor-inline-toolbar"),a.classList.remove("smart-editor-drop-down-toolbar","smart-editor-context-menu"),a.setAttribute("role","tooltip"),a.setAttribute("aria-label","Inline Toolbar");else{if("context"!==t)return a.position="auto",a.iframeRect=null,a.arrow=!1,a.align=o.rightToLeft?"right":"left",a.offset=[0,-5],a.selector=e,a.classList.add("smart-editor-toolbar","smart-editor-drop-down-toolbar"),a.classList.remove("smart-editor-inline-toolbar","smart-editor-context-menu"),a.setAttribute("role","tooltip"),void a.setAttribute("aria-label","Drop Down Toolbar");a.position="absolute",a.arrow=!1,a.classList.add("smart-editor-context-menu"),a.classList.remove("smart-editor-toolbar","smart-editor-drop-down-toolbar","smart-editor-inline-toolbar"),a.setAttribute("role","listbox"),a.setAttribute("aria-label","Context Menu")}if(a.selector&&!a.selector.closest&&delete a.selector.getBoundingClientRect,e.closest)a.selector=e;else{const t=e.parentElement,n=o._getSelectionRange();t.getBoundingClientRect=()=>n.getBoundingClientRect(),a.selector=t}}_getInlineToolbarContent(e){const t=this,o=t.$.inlineToolbar;if(o.innerHTML&&o.selector.nodeName===e.nodeName)return;let n;const a=t._toolbarItemsObj,i=e.nodeName.toLowerCase(),r=(e=[])=>{let t;for(let o=0,n=e.length;o<n;o+=1){const n=a[e[o]];if(n){t=n;break}}return t};let l;switch(i){case"a":l=r(["hyperlink","createlink"]);break;case"#text":l=r(["cut","copy","paste"]);break;case"img":l=r(["image"]);break;case"td":case"th":l=r(["table"]);break;default:return}return n=l&&Array.isArray(l.inlineToolbarItems)?l.inlineToolbarItems:t._getDefaultInlineToolbarItems(e,i),n.length?t._getToolbarItems(o,n):void 0}_getDefaultInlineToolbarItems(e,t){let o;switch(t){case"a":o=["openlink","editlink","removelink"];break;case"#text":o=["cut","copy","paste"];break;case"img":o=["image","alignment","createlink","delete","caption"],e.closest(".smart-editor-editable a")&&o.splice(o.indexOf("createlink")+1,0,"openlink","removelink");break;case"td":case"th":o=["table","tableheader","tablerows","tablecolumns","backgroundcolor","delete","alignment","tablevalign","tablestyle"];break;default:return[]}return o}_getNodes(e,t=0,o,n=0){const a=this,i=e.childNodes;let r=[];for(let e=0,l=i.length;e<l;e+=1){const l=i[e];if(l.childElementCount){const e=a._getNodes(l,t,o,n);if(n=e.index,e.nodes.length&&(r=r.concat(e.nodes)),n>=o)break}else if(l.nodeType===Node.TEXT_NODE){const e=l.nodeValue;if(!e.trim())continue;const a=e.length;if(n+a>t&&r.push({node:l,index:o-n,startIndex:Math.max(0,t-n)}),(n+=a)>o)break}else if((n+=(l.textContent||l.innerText||l.innerHTML).length)>t&&r.push({node:l,index:n}),n>o)break}return{nodes:r,index:n}}_tooltipChangeHandler(e){const t=this,o=e.target,n=t.$.inlineToolbar;n&&n.classList.contains("smart-editor-drop-down-toolbar")&&n.visible&&n.contains(o)?o.classList.contains("smart-table-picker")&&(t._handleTableInsert({cells:e.detail.value}),n.close()):t._changeHandler(e)}_tooltipClickHandler(e){const t=this,o=e.target,n=t.$.inlineToolbar;if(n&&n.classList.contains("smart-editor-drop-down-toolbar")&&n.contains(e.target)&&o.closest(".smart-table-picker-button")){const e=t._getSelectionRange();let o;return e.startContainer&&["th","td"].indexOf(e.startContainer.nodeName.toLowerCase())>-1&&(o=e.startContainer.closest(".smart-editor-editable table")),void t._openWindow(n.selector,o)}if(n&&n.classList.contains("smart-editor-context-menu")){const n=o.closest(".smart-editor-context-menu-item");if(n)return void t._handleContextMenuItemClick(e,n)}}_tooltipVisibilityHandler(e){const t=this,o=t.$.inlineToolbar,n=e.type;if(e.target!==o)return;const a=t.$.inlineToolbar,i=t.$inlineToolbar;let r;r=o.classList.contains("smart-editor-toolbar")?(o.classList.contains("smart-editor-drop-down-toolbar")?"inline":"dropDown")+"Toolbar":"contextMenu",e.stopPropagation(),"close"===e.type?(a.selector&&!a.selector.closest&&delete a.selector.getBoundingClientRect,a.hasAnimation||(i.unlisten(e.type),i.unlisten("change"),i.unlisten("click"),a.remove(),t._focusEditableElement()),t._setAriaOwns(o)):"open"===e.type&&t._setAriaOwns(o),t.$.fireEvent(r+n.slice(0,1).toUpperCase()+n.slice(1),Object.assign({target:e.target},e.detail))}_tooltipTransitionEndHandler(e){const t=this;if(!(e.target instanceof Smart.Tooltip))return;const o=t.$.inlineToolbar,n=t.$inlineToolbar;o.visible||(n.unlisten("transitionend"),o.style.top=o.style.left=0,o.remove(),t._setAriaOwns(o))}_toggleItemDropDown(e){const t=this,o=e.getAttribute("item-type");let n;if("drop-down"===o?(t.$.inputPopup||(t.$.inputPopup=document.createElement("smart-input")),n=t.$.inputPopup):"color-input"===o&&(t.$.colorInputPopup||(t.$.colorInputPopup=document.createElement("smart-color-input")),n=t.$.colorInputPopup),n.noRipple=!0,t.$.inputPopup&&n===t.$.colorInputPopup&&t.$.inputPopup.parentElement?t._closeToolbarItemDropDown(t.$.inputPopup):t.$.colorInputPopup&&n===t.$.inputPopup&&t.$.colorInputPopup.parentElement&&t._closeToolbarItemDropDown(t.$.colorInputPopup),n)if(n.locale=t.locale,n.rightToLeft=t.rightToLeft,n.theme=t.theme,n.animation=t.animation,e.contains(n)&&n.opened)t._closeToolbarItemDropDown(n);else{const o=t.$.inlineToolbar;o&&!o.contains(e)&&t._closeToolbar(),n.remove(),t._openToolbarItemDropDown(e,n)}}_toggleDropDownToolbar(e){const t=this;if(!e)return;if("table"!==e.getAttribute("item-name"))return;const o=t.$.inlineToolbar;if(o&&o.visible&&o.classList.contains("smart-editor-drop-down-toolbar")){if(o.contains(e)){const o=t._getSelectionRange();let n;return o.startContainer&&["th","td"].indexOf(o.startContainer.nodeName.toLowerCase())>-1&&(n=o.startContainer.closest(".smart-editor-editable table")),void t._openWindow(e,n)}o.classList.contains("smart-editor-drop-down-toolbar")&&o.close()}else t._closeToolbarItemDropDown(t.$.inputPopup),t._closeToolbarItemDropDown(t.$.colorInputPopup),t._openDropDownToolbar(e)}_openDropDownToolbar(e){const t=this;let o=t.$.inlineToolbar;o||(o=t._createToolbar()),t.$.fireEvent("dropDownToolbarOpening",{target:o}).defaultPrevented||(t._setupToolbar(e,"dropDown"),o.parentElement||t.getShadowRootOrBody().appendChild(o),t._setDropDownToolbarContent(e),o.open(),t._setAriaControls(e,o))}_setDropDownToolbarContent(e){const t=this,o=t.$.inlineToolbar,n=e.getAttribute("item-name");let a=t._dropDownToolbarObj;a||(a=t._dropDownToolbarObj={});let i=a[n];i||(i=document.createElement("smart-table-picker"),a[n]=i),i.rightToLeft=t.rightToLeft,i.locale=t.locale,i.messages=t.messages,i.value=[],o.contains(i)||(o.clear(),o.appendChild(i))}_openSearchBar(){const e=this,t=e.$.editableElement,o=e.$.contentContainer;let n=e._searchToolbar;if(e.disableSearchBar||t.classList.contains("smart-hidden"))return void(n&&n.remove());n||(n=e._searchToolbar=document.createElement("div"),n.classList.add("smart-editor-search-bar"),n.innerHTML='<span class="smart-search-input-container">\n <input class="smart-search-input"></input>\n </span>\n <smart-button class="smart-search-button prev"></smart-button>\n <smart-button class="smart-search-button next"></smart-button>\n <smart-button class="smart-search-button close"></smart-button>'),n.ontransitionend=null;const a=e.animation,i=e.theme,r=e.rightToLeft,l=n.children;let s;for(let t=0,o=l.length;t<o;t+=1){const o=l[t];if(o.classList.contains("smart-search-input-container")){const t=o.firstElementChild;t.placeholder=e.localize("searchPlaceholder"),s=t}o.animation=a,o.theme=i,o.rightToLeft=r}if(o.contains(n)||o.appendChild(n),n.classList.remove("smart-visibility-hidden"),s){const t=e.$.iframe,o=(t?t.contentWindow:window).getSelection().toString();s.value=o,s.focus({preventScroll:!0}),o&&e._applySearching(o)}delete e._lastSearchQuery}_closeSearchToolbar(){const e=this,t=e._searchToolbar;if(t&&!t.classList.contains("smart-visibility-hidden")){t.classList.add("smart-visibility-hidden"),t.ontransitionend=()=>{t.remove(),t.ontransitionend=null};const o=Array.from(e.$.editableElement.querySelectorAll(".find-and-replace-match"));for(let e=0,t=o.length;e<t;e+=1){const t=o[e];t.outerHTML=t.textContent}e._focusEditableElement()}}_toggleWindow(e,t){const o=this;if(!e)return;const n=e.getAttribute("item-name"),a=o.$.window;if(!a)return void o._openWindow(e,t);const i=a._target?a._target.item:void 0;!i||i.name!==n||i.name===n&&!a.opened?o._openWindow(e,t):a.close()}_openWindow(e,t){const o=this;if(!e||!o._toolbarItemsObj||o._window&&o._window.opened)return;let n;t&&t.classList.contains("smart-editor-video-container")&&(t=t.querySelector(".smart-editor-video-container > video, .smart-editor-video-container > iframe"));const a=o.$.editableElement;if(e.closest){if(!e.classList.contains("smart-editor-toolbar-item"))return;n=(e.closest(".smart-editor-inline-toolbar")?o._inlineToolbarItemsObj:o._toolbarItemsObj)[e.getAttribute("item-name")]}else"object"==typeof e&&"string"==typeof e.name&&(n=e);if(!n||"findandreplace"===n.name&&a.classList.contains("smart-hidden"))return;const i=o._createWindow(n);o.$.fireEvent("dialogOpening",{target:i,item:n}).defaultPrevented||(o._closeToolbarItemDropDown(o.$.inputPopup),o._closeToolbarItemDropDown(o.$.colorInputPopup),i._target={item:n,itemTarget:t,originalTarget:e},o._closeToolbar(),i.parentElement||o.getShadowRootOrBody().appendChild(i),i.isCompleted?o._setupWindow():i.whenReady((()=>o._setupWindow())))}_closeWindow(){const e=this,t=e.$.window;t&&t.opened&&(e.$.fireEvent("dialogClosing",{target:t,item:t._target.item}).defaultPrevented||t.close())}_setupWindow(){const e=this,t=e.$.window,o=t._target,n=o.item;function a(){e._positionWindow(),t.opened?(t.bringToFront(),t._handleActiveState(),t._onOpenCallback&&t._onOpenCallback()):t.open()}if(t.locale=e.locale,t.rightToLeft=e.rightToLeft,t.theme=e.theme,t.animation=e.animation,e.windowCustomizationFunction?e.windowCustomizationFunction(t,n):(e._setPopupWindowTemplate("header",n),e._setPopupWindowTemplate("footer",n),e._setPopupWindowTemplate("content",n)),!t.opened){const o=e.$window,n=t=>e._windowOpenHandler.call(e,t),a=t=>e._windowCloseHandler.call(e,t),i=t=>e._windowClickHandler.call(e,t),r=t=>e._windowChangeHandler.call(e,t),l=t=>e._windowKeyDownHandler.call(e,t),s=t=>e._windowKeyUpHandler.call(e,t),d=t=>e._windowTransitionendHandler.call(e,t),c=t=>e._fileUploadCompletedHandler.call(e,t),m=t=>e._fileUploadErrorHandler.call(e,t);o.unlisten("transitionend"),o.unlisten("open"),o.unlisten("close"),o.unlisten("click"),o.unlisten("change"),o.unlisten("keydown"),o.unlisten("keyup"),o.unlisten("uploadCompleted"),o.unlisten("uploadError"),t._onOpenCallback=()=>{((t.shadowRoot||t).querySelector(".smart-editor-window-editor:not(.smart-hidden) .smart-input.smart-element")||t).focus({preventScroll:!0})},t.hasAnimation&&o.listen("transitionend",d),o.listen("open",n),o.listen("close",a),o.listen("click",i),o.listen("change",r),o.listen("keydown",l),o.listen("keyup",s),o.listen("uploadCompleted",c),o.listen("uploadError",m)}t.shadowRoot?e._onShadowDomLoaded(t,"smart.window.css",a):a(),e._setAriaOwns(t),e._setAriaControls(o.originalTarget,t)}_setPopupWindowTemplate(e,t){const o=this,n=o.$.window;if(!n)return;if("content"===e)return void o._setWindowContent(t);n[e+"Template"]||(n[e+"Template"]=o._createWindowTemplate(e));const a=n._target.item;if("header"===e)n.label=o.localize(a.name)||"";else if("footer"===e){const e=(n.shadowRoot||n).querySelectorAll(".smart-editor-window-button"),a="findandreplace"===t.name;for(let t=0;t<e.length;t++){const n=e[t];n.innerHTML='<span class="smart-icon"></span>',n.theme=o.theme,n.rightToLeft=o.rightToLeft,n.animation=o.animation,n.classList.contains("ok")?a?(n.classList.add("replace"),n.innerHTML+=o.localize("replace"),n.setAttribute("aria-label","replace")):(n.classList.remove("replace"),n.innerHTML+=o.localize("ok"),n.setAttribute("aria-label","ok")):n.classList.contains("cancel")?(n.innerHTML+=o.localize("cancel"),n.setAttribute("aria-label","cancel")):a?(n.classList.contains("replace-all")&&(n.innerHTML+=o.localize("replaceAll"),n.setAttribute("aria-label","replaceAll")),n.classList.remove("smart-hidden")):n.classList.add("smart-hidden");const i=n.querySelector(".smart-ripple");i&&i.parentElement.removeChild(i)}}}_setWindowContent(e){const t=this,o=t.$.window,n=o._target.originalTarget,a=[].slice.call(o.getElementsByClassName("smart-editor-window-editor"));if((!o.innerHTML||a.length)&&n){switch(e.name){case"createlink":case"editlink":case"hyperlink":case"image":case"video":case"table":case"paste":case"findandreplace":t._createWindowEditors(e)}n.id&&o.setAttribute("aria-controls",n.id)}}_createWindowEditors(e){const t=this,o=t.$.window,n=e.name;let a,i=t._windowEditors,r=o.querySelector(".smart-editor-window-content-wrapper");r||(r=document.createElement("div"),r.classList.add("smart-editor-window-content-wrapper"),o.appendChild(r)),t._windowEditors||(i=t._windowEditors={}),i&&(a=i[n]),a||(a=document.createElement("div"),a.classList.add(`smart-editor-window-${n}`),a.innerHTML=t._getWindowEditorTemplate(n),i[n]=a),r.contains(a)||(r.innerHTML="",r.appendChild(a));const l=a.querySelectorAll(".smart-editor-window-editor[type]");for(let e=0;e<l.length;e++)t._setPopupWindowEditor(l[e])}_getWindowEditorTemplate(e){switch(e){case"createlink":case"editlink":case"hyperlink":return'\n <div class="smart-editor-window-editor" type="address">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="text">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="title">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="target">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>';case"image":return'\n <div class="smart-editor-window-editor" type="file">\n <smart-file-upload item-editor></smart-file-upload>\n </div>\n <div class="smart-editor-window-editor" type="url">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="width">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="height">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="alt">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="title">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="caption">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="display">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="alignment">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="draggable">\n <smart-check-box item-editor></smart-check-box>\n </div>\n <div class="smart-editor-window-editor" type="resizable">\n <smart-check-box item-editor></smart-check-box>\n </div>';case"table":return'\n <div class="smart-editor-window-editor" type="cols">\n <label></label>\n <smart-number-input item-editor></smart-number-input>\n </div>\n <div class="smart-editor-window-editor" type="rows">\n <label></label>\n <smart-number-input item-editor></smart-number-input>\n </div>\n <div class="smart-editor-window-editor" type="width">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="height">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="tableheader">\n <smart-check-box item-editor></smart-check-box>\n </div>\n <div class="smart-editor-window-editor" type="altrows">\n <smart-check-box item-editor></smart-check-box>\n </div>\n <div class="smart-editor-window-editor" type="dashedborders">\n <smart-check-box item-editor></smart-check-box>\n </div>\n <div class="smart-editor-window-editor" type="resizable">\n <smart-check-box item-editor></smart-check-box>\n </div>';case"paste":return'\n <div class="smart-editor-window-editor" type="keepFormat">\n <label></label>\n <smart-radio-button checked group-name="editorPasteViaWindow" item-editor></smart-radio-button>\n </div>\n <div class="smart-editor-window-editor" type="cleanFormat">\n <smart-radio-button group-name="editorPasteViaWindow" item-editor></smart-radio-button>\n </div>\n <div class="smart-editor-window-editor" type="plainText">\n <smart-radio-button group-name="editorPasteViaWindow" item-editor></smart-radio-button>\n </div>';case"findandreplace":return'\n <div class="smart-editor-window-editor" type="find">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="replaceWith">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="results">\n <label></label>\n <smart-list-box virtualized item-editor></smart-list-box>\n </div>\n <div class="smart-editor-window-editor" type="matchCase">\n <smart-check-box item-editor></smart-check-box>\n </div>';case"video":return'\n <div class="smart-editor-window-editor" type="file">\n <smart-file-upload item-editor></smart-file-upload>\n </div>\n <div class="smart-editor-window-editor" type="src">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="width">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="height">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="thumbnail">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="videoUrl">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="alt">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="title">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="caption">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="display">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="alignment">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="draggable">\n <smart-check-box item-editor></smart-check-box>\n </div>\n <div class="smart-editor-window-editor" type="resizable">\n <smart-check-box item-editor></smart-check-box>\n </div>';default:return""}}_setPopupWindowEditor(e){const t=this,o=e.getAttribute("type"),n=e.querySelector("label"),a=t.$.window._target,i=a.item,r="markdown"===t.editMode,l=i.editor;let s,d=e.querySelector("[item-editor]");if(n&&("paste"===i.name?(n.id=t.id+"pasteLabel",n.innerHTML=t.localize("pasteLabel")||""):(n.id=t.id+o+"Label",n.innerHTML=t.localize(o)||"")),!d)return;const c=t._toolbarItemClick;let m;switch(m=c?c.target:a.itemTarget,i.name){case"hyperlink":case"createlink":case"editlink":{const n=t._getSelectionRange();let a=n.startContainer;a&&"a"!==a.nodeName.toLowerCase()&&(a=a.parentElement),a&&"a"===a.nodeName.toLowerCase()?"address"===o?s=a.getAttribute("href"):"text"===o?s=a.textContent:"title"===o?s=a.title:"target"===o&&(s=a.target):s="text"===o?r?t.$.input.value.slice(n.selectionStart,n.selectionEnd):n.toString():l&&void 0!==l[o]?l[o]+"":"","target"===o&&r||m&&"img"===m.nodeName.toLowerCase()&&["title","text"].indexOf(o)>-1?e.classList.add("smart-hidden"):e.classList.remove("smart-hidden");break}case"video":case"image":{const n=t._toolbarItemClick,d=n?n.target:a.itemTarget;if(d&&["img","video","iframe"].indexOf(d.nodeName.toLowerCase())>-1){const e=d.closest(".smart-editor-image-container");switch(o){case"file":d.file instanceof File&&(s=d.file);break;case"url":case"src":s=d.file instanceof File?"":d.getAttribute("src")||"";break;case"alt":s=d.alt;break;case"title":s=d.title;break;case"width":if(s=d.style.width||(e?e.style.width:""),!s){const e=d.getAttribute("width");e&&(s=e)}break;case"height":if(s=d.style.height||(e?e.style.height:""),!s){const e=d.getAttribute("height");e&&(s=e)}break;case"caption":if(e){const t=e.querySelector(".smart-editor-image-caption");t&&(s=t.textContent)}void 0===s&&(s="");break;case"alignment":s=(e||d).getAttribute("alignment")||"";break;case"display":s=(e||d).getAttribute("display")||"";break;case"draggable":case"resizable":{const t=("video"===i.name?e:d).getAttribute(o);s=null==t||"true"===t;break}}}else s=l?("draggable"===o||"resizable"===o)&&void 0===l[o]||(void 0!==l[o]?l[o]+"":""):"width"===o?480:"height"===o?270:"draggable"===o||"resizable"===o||"";r&&["file","url","videoUrl","alt","title","thumbnail"].indexOf(o)<0||!r&&"video"===i.name&&["alt","thumbnail","videoUrl"].indexOf(o)>-1?e.classList.add("smart-hidden"):e.classList.remove("smart-hidden");break}case"table":{const t=a.itemTarget&&"table"===a.itemTarget.nodeName.toLowerCase()?a.itemTarget:void 0;switch(o){case"width":case"height":s=t?t.style[o]:l&&void 0!==l[o]?l[o]:"";break;case"cols":s=t?t.querySelector("tbody > tr").children.length+"":l&&void 0!==l[o]?l[o]:"1";break;case"rows":s=t?t.querySelectorAll("tbody > tr").length+"":l&&void 0!==l[o]?l[o]:"1";break;case"tableheader":s=!!r||(t?null!==t.querySelector("thead"):!(!l||void 0===l[o])&&l[o]);break;case"altrows":s=t?t.hasAttribute("alternation"):!(!l||void 0===l[o])&&l[o];break;case"dashedborders":s=t?t.hasAttribute("dashed-borders"):!(!l||void 0===l[o])&&l[o];break;case"resizable":s=t?!("false"===t.getAttribute("resizable")):!l||void 0===l[o]||l[o]}r&&["cols","rows","tableheader"].indexOf(o)<0?e.classList.add("smart-hidden"):e.classList.remove("smart-hidden");break}case"paste":s=o===t.pasteFormat;break;case"findandreplace":s=l&&void 0!==l[o]?l[o]:""}t._setupEditorElement(d,o,s),t._setEditorCommonProperties(d)}_setupEditorElement(e,t,o){const n=this,a=n.$.window._target.item,i=a.editor,r="markdown"===n.editMode;if((e instanceof Smart.CheckBox||e instanceof Smart.RadioButton)&&(e.innerHTML=n.localize(t)||"",e.checked=!!o),e instanceof Smart.NumberInput)e.min=1,e.value=parseInt(o);else{if(e instanceof Smart.FileUpload)return"file"===t&&e.isCompleted&&(e.cancelAll(),o&&e.addFile(o)),e.uploadUrl="",e.removeUrl="",e.autoUpload=!1,i&&(i.uploadUrl&&(e.uploadUrl=i.uploadUrl,e.autoUpload=!0),i.removeUrl&&(e.removeUrl=i.removeUrl)),e.dropZone=e.parentElement,e.accept=a.allowedTypes||(r||"video"!==a.name?"image/*":"video/mp4,video/x-m4v,video/*"),void(e.hideFooter=!0);if(e instanceof Smart.ListBox)e.selectionMode="one",e.itemHeight=35;else{if("string"==typeof e.placeholder&&(e.placeholder=n.localize(t+"Placeholder")||""),e.dropDownClassList&&(e.dropDownClassList=["smart-editor-input"]),void 0!==e.dataSource){if("target"===t||"alignment"===t||"display"===t){e.dataSource.length||(e.dataSource=n._getDefaultDataSource(t)),"alignment"!==t||o||(o="center");const a=o?e.dataSource.find((e=>"object"==typeof e&&e.value===o)):void 0;a&&"object"==typeof a&&(o=a.label||o),e.readonly=!a&&!o||a&&""!==a.value}else e.dataSource=[];"string"==typeof e.dropDownButtonPosition&&(e.dropDownButtonPosition=e.dataSource.length?n.rightToLeft?"left":"right":"none")}e.value=void 0===o?"":o+""}}}_setEditorCommonProperties(e){const t=this;if(e){const o=e.messages,n=t.messages,a=t.locale;for(let e in o.en){const t=n[a][e];void 0!==t&&(o[a]||(o[a]={}),o[a][e]=t)}e.locale=t.locale,e.rightToLeft=t.rightToLeft,e.animation=t.animation,e.theme=t.theme}}_createWindow(){const e=this,t=e.$.window;if(t)return t;const o=document.createElement("smart-window");return o.classList.add("smart-editor-window"),o.id=e.id+"Window",o.setAttribute("smart-id","window"),e.$.window=o,e.$window=Smart.Utilities.Extend(o),o.rightToLeft=e.rightToLeft,o.theme=e.theme,o.animation=e.animation,o.disableSnap=!0,o.headerButtons=["close"],o}_createWindowTemplate(e){const t=this,o=t.animation,n=t.theme,a=t.rightToLeft;let i;return"footer"===e&&(i=document.createElement("template"),i.innerHTML=`<smart-button class="smart-editor-window-button primary replace replace-all smart-hidden"\n animation="${o}" theme="${n}" ${a?"right-to-left":""}>\n </smart-button>\n <smart-button class="smart-editor-window-button ok primary"\n animation="${o}" theme="${n}" ${a?"right-to-left":""}>\n </smart-button>\n <smart-button class="smart-editor-window-button cancel"\n animation="${o}" theme="${n}" ${a?"right-to-left":""}>\n </smart-button>`),i}_positionWindow(){const e=this,t=e.getShadowRootOrBody(),o=e.$.window;if(!o||!t.contains(o))return;const n=e.getBoundingClientRect();o.opened||(o.style.left=o.style.top=""),o.style.left=Math.max(n.left+window.pageXOffset,n.left+window.pageXOffset+n.width/2-o.offsetWidth/2)+"px",o.style.top=Math.max(n.top+window.pageYOffset,n.top+window.pageYOffset+n.height/2-o.offsetHeight/2)+"px"}_windowChangeHandler(e){const t=this,o=e.detail,n=t.$.window._target.item;let a=(e.originalEvent||e).target;const i=a.closest(".smart-editor-window-editor");if(!a.hasAttribute("item-editor")||!n||!i)return;const r=i.getAttribute("type");if(n.name.indexOf("link")>0&&"target"===r&&a instanceof Smart.Input)a.readonly=!!o.value.length;else if(t._windowEditors&&n.name.indexOf("findandreplace")>-1)if("results"===r&&a instanceof Smart.ListBox)t._handleMarkerSelection(e.target);else if("matchCase"===r&&a instanceof Smart.CheckBox){const e=i.parentElement.querySelector('.smart-editor-window-editor[type="find"] [item-editor]');e&&t._findMatches(e.value)}}_windowClickHandler(e){const t=this;let o=(e.originalEvent||e).target;o.shadowRoot&&(o=(e.originalEvent||e).composedPath()[0]);const n=t.$.window,a=n._target,i=o.closest(".smart-editor-window-button");if(n&&i&&a){if("findandreplace"===a.item.name){const e=i.classList,o=i.classList.contains("replace-all");if(o||e.contains("ok"))return void t._replaceMatches(n._target.item,o)}else if(i.classList.contains("ok")&&!1===t._updateEditorViaWindow(a.item))return;n.close(),delete n._target}}_windowCloseHandler(e){const t=this,o=e.target;if(!o.classList.contains("smart-editor-window"))return;const n=t.$window;if(n){t.$.fireEvent("dialogClose",{target:e.target,item:e.target._target.item}),n.unlisten("close"),n.unlisten("click"),n.unlisten("change"),n.unlisten("keydown"),n.unlisten("uploadCompleted"),n.unlisten("uploadError"),t.hasAttribute("aria-owns")&&t.removeAttribute("aria-owns"),t.hasAnimation||(o.remove(),t._setAriaOwns(o));const a=o._target,i=a.itemTarget;if("findandreplace"===a.item.name&&t._findMatches(""),t._focusEditableElement(),i&&["img","th","td","table"].indexOf(i.nodeName.toLowerCase())>-1)return void t._setResizeFrame(i)}}_windowKeyDownHandler(e){const t=this,o=t.$.window;if("Enter"!==e.key||!o._target)return;const n=o._target.item,a=o.getRootNode().activeElement;if(n&&a.closest(".smart-editor-window-editor")){if(!1===t._updateEditorViaWindow(n))return;e.stopPropagation(),e.preventDefault(),o.close(),delete o._target}}_windowKeyUpHandler(e){const t=this,o=e.target;if(o.closest('.smart-editor-window-editor[type="find"]')){const e=o.closest("[item-editor]");if(e){const o=t.findAndReplaceTimeout;if(clearTimeout(t._findAndReplaceTimeout),"html"!==t.editMode)return;o?t._findAndReplaceTimeout=setTimeout((()=>t._findMatches(e.value)),o):t._findMatches(e.value)}}}_windowOpenHandler(e){const t=this,o=e.target;if(!o.classList.contains("smart-editor-window"))return;const n=t.$window;if(n){const a=o._target.item;if(t._setAriaOwns(o),t.$.fireEvent("dialogOpen",{target:e.target,item:a}),n.unlisten("open"),"findandreplace"===a.name){const e=o.querySelector('.smart-editor-window-editor[type="find"] [item-editor]');t._findMatches(e?e.value:"")}}}_windowTransitionendHandler(e){const t=this,o=e.target;o.classList.contains("smart-editor-window")&&(o.opened||"visibility"!==e.propertyName||(t.$window.unlisten("transitionend"),t.$.window.remove(),t._setAriaOwns(o)))}_updateEditorViaWindow(e){const t=this;if(!e||!t._windowEditors)return;const o=t.$.iframe,n=t.$.editableElement;let a,i;t.$.contentContainer.contains(n.getRootNode().activeElement)||t._focusEditableElement(),o?(a=o.contentWindow,i=a.getSelection()):(a=window,i=window.getSelection());const r=t._windowEditors[e.name],l=t._getSelectionRange();let s;if(r&&!t.$.fireEvent("actionStart",{name:e.name}).defaultPrevented){switch(l instanceof a.Range&&(i.removeAllRanges(),i.addRange(l)),e.name){case"editlink":case"createlink":case"hyperlink":s=t._handleLinksInsert(e);break;case"image":s=t._handleImageInsert(e);break;case"table":t._handleTableInsert(t._getItemOptionsViaWindow(e));break;case"paste":t._handlePasteViaWindow(e);break;case"video":s=t._handleVideoInsert(e)}return t.$.fireEvent("actionEnd",{name:e.name}),s?(s(),!1):void 0}}_focusFirstInputCallback(e,t){const o=this._windowEditors[e];if(o)return()=>{const e=o.querySelector(`.smart-editor-window-editor[type="${t}"] .smart-input[item-editor]`);e&&e.focus({preventScroll:!0})}}_fileUploadCompletedHandler(e){const t=this.$.window;let o;t&&t.opened&&t._target&&(o=t._target.item),e.stopPropagation(),this.$.fireEvent("imageUploadSuccess",Object.assign({target:e.target,toolbarItem:o},e.detail))}_fileUploadErrorHandler(e){const t=this.$.window;let o;t&&t.opened&&t._target&&(o=t._target.item),e.stopPropagation(),this.$.fireEvent("imageUploadFailed",Object.assign({target:e.target,toolbarItem:o},e.detail))}_replaceMatches(e,t){const o=this,n=o.$.editableElement;if(!e||!o._windowEditors||"html"!==o.editMode||n.classList.contains("smart-hidden"))return;const a=o._getItemOptionsViaWindow(e),i=o._windowEditors[e.name],r=i.querySelector('.smart-editor-window-editor[type="results"] smart-list-box[item-editor]'),l=i.querySelector('.smart-editor-window-editor[type="results"] label'),s=r.selectedIndexes;if(!a||!s||!s.length)return;const d=a.replaceWith,c=Array.from(n.querySelectorAll(".find-and-replace-match"));for(let e=0,o=c.length;e<o;e+=1){const o=c[e];(t||s.indexOf(e)>-1)&&(o.outerHTML=d)}t?r.dataSource=[]:s.forEach((e=>r.removeAt(e))),o._setFindAndReplaceLabel(l,r)}_findMatches(e){const t=this,o=t.$.editableElement,n=t._windowEditors,a=n?n.findandreplace:void 0,i=a.querySelector('.smart-editor-window-editor[type="results"] smart-list-box[item-editor]'),r=a.querySelector('.smart-editor-window-editor[type="results"] label'),l=a.querySelector('.smart-editor-window-editor[type="matchCase"] smart-check-box[item-editor]'),s=t.$.window.querySelectorAll(".smart-editor-window-button.replace");i&&"smart-list-box"===i.nodeName.toLowerCase()&&(i.dataSource=[]),t._findAndReplaceTimeout&&(clearTimeout(t._findAndReplaceTimeout),delete t._findAndReplaceTimeout);const d=Array.from(o.querySelectorAll(".find-and-replace-match"));for(let e=0,t=d.length;e<t;e+=1){const t=d[e];t.outerHTML=t.textContent}if("html"===t.editMode)if(e){i.dataSource=t._getFindMarkers(o,new RegExp(e,"gm"+(l.checked?"":"i")),[]),i.select("0"),t._setFindAndReplaceLabel(r,i);for(let e=0,t=s.length;e<t;e+=1)s[e].disabled=!1}else{t._setFindAndReplaceLabel(r);for(let e=0,t=s.length;e<t;e+=1)s[e].disabled=!0}}_clearSearchToolbar(){const e=this,t=e._searchToolbar;t&&!t.classList.contains("smart-visibility-hidden")&&(t.value="",delete e._lastSearchQuery)}_applySearching(e){const t=this,o=t.$.editableElement;if(t._lastSearchQuery===e||o.classList.contains("smart-hidden"))return;const n=t.$.contentContainer.querySelector(".smart-search-input-container");let a;t._findAndReplaceTimeout&&(clearTimeout(t._findAndReplaceTimeout),delete t._findAndReplaceTimeout);const i=Array.from(o.querySelectorAll(".find-and-replace-match"));for(let e=0,t=i.length;e<t;e+=1){const t=i[e];t.outerHTML=t.textContent}if("html"===t.editMode){if(e){a=t._getFindMarkers(o,new RegExp(e,"gmi"),[]).length;const n=o.querySelector(".find-and-replace-match");n&&(n.classList.add("selected"),t._scrollToMarker(n))}n&&(n.setAttribute("matches",a||0),n.setAttribute("selected",a?1:0)),t._lastSearchQuery=e}}_scrollToMarker(e){const t=this,o=t._searchToolbar,n=o&&!t._searchToolbar.classList.contains("smart-visibility-hidden")?o.offsetHeight:0,a=t.$.editableElement,i=a.getBoundingClientRect(),r=e.getBoundingClientRect(),l=a.scrollLeft,s=a.scrollTop,d=i.height,c=i.width,m=r.height,u=r.width,b=r.top-i.top+s,p=r.left-i.left+l;s+n>b||l>p?a.scrollTo(p-c,b-n-10):(s+d<b+m||l+c<p+u)&&a.scrollTo(p+u-c,b+m-d)}_setFindAndReplaceLabel(e,t){if(!e)return;const o=t?t.items.length:0;if(!t||!o)return e.removeAttribute("matches"),void e.removeAttribute("selected");if(e){const n=t.selectedIndexes[0];e.setAttribute("matches",o),e.setAttribute("selected",n?n+1:1)}}_getFindMarkers(e,t,o){const n=this,a=Array.from(e.childNodes);for(let e=0,i=a.length;e<i;e+=1){const i=a[e];if(i.childElementCount)n._getFindMarkers(i,t,o);else if(i.textContent){const e=document.createDocumentFragment(),n=i.textContent;let a,r=0;if(n.matchAll)a=Array.from(n.matchAll(t));else{let e;for(a=[];e=t.exec(n);)a.push(e)}if(a.forEach((t=>{const n=t.input,a=t.index,i=t[0],l=n.substring(r,a),s=o.length,d=document.createElement("span");l.length&&e.appendChild(document.createTextNode(l)),d.classList.add("find-and-replace-match"),d.setAttribute("match-id",s),d.textContent=i,e.appendChild(d);const c=n.substring(Math.max(0,a-10),a),m=n.substr(a+i.length,10);o.push({label:`${a>0?"...":""}${c}<b>${i}</b>${m}${a<n.length-1?"...":""}`,value:s}),r=a+i.length})),!e.childElementCount)continue;const l=i.textContent.substr(r);l&&e.appendChild(document.createTextNode(l)),i.nodeType===Node.TEXT_NODE?(i.parentElement.insertBefore(e,i),i.remove()):(i.innerHTML="",i.appendChild(e))}}return o}_handleMarkerSelection(e){const t=this,o=e.selectedValues[0],n=t.$.editableElement.querySelectorAll(`.find-and-replace-match.selected, .find-and-replace-match[match-id="${o}"]`);let a;for(let e=0,t=n.length;e<t;e+=1){const t=n[e];t.getAttribute("match-id")===o?(t.classList.add("selected"),a=t):t.classList.remove("selected")}a&&t._scrollToMarker(a);const i=t._windowEditors,r=i?i.findandreplace:void 0,l=r?r.querySelector('.smart-editor-window-editor[type="results"] label'):void 0;if(l){const t=e.selectedIndexes;l.setAttribute("selected",t.length?t[0]+1:0)}}_handleImageInsert(e){const t=this,o=t._getItemOptionsViaWindow(e),n=t.$.window;if(!n)return;let a,i,r,l,s,d=n._target.itemTarget;if(o.file.length?(l=o.file[0],a=URL.createObjectURL(l)):o.url&&(a=o.url+""),!a&&o)return t._focusFirstInputCallback(e.name,"url");if("markdown"===t.editMode)return i=o.title?` "${o.title}"`:"",void t._insertMarkDown(``);const c=t.$.iframe,m=t.$.editableElement,u=c?c.contentDocument:document;if(!d||"img"!==d.nodeName.toLowerCase()){const e=t.id+"newImage"+Math.random().toString(36).substr(2,5);s=u.execCommand("insertHTML",!1,`<img id="${e}"></img>`),d=m.querySelector("#"+e)}if(d&&"img"===d.nodeName.toLowerCase()){const e="inline"===o.display.toLowerCase()?"inline":"block",n=o.width+"",i=o.height+"";if(t._handleImgCaption(d,o),s&&(d.id=""),URL.revokeObjectURL(d.src),d.src=a,l&&(d.file=l,"base64"===t.imageFormat)){const e=new FileReader;e.readAsDataURL(l),e.onload=()=>d.src=e.result}if(d.removeAttribute("width"),d.removeAttribute("height"),d.style.width=n&&"auto"!==n?parseFloat(n)+(n.indexOf("%")>-1?"%":"px"):"",d.style.height=i&&"auto"!==i?parseFloat(i)+(i.indexOf("%")>-1?"%":"px"):"",o.alt&&(d.alt=o.alt),o.title&&(d.title=o.title),o.alignment){const e=o.alignment.toLowerCase();r=e.indexOf("left")>-1?"left":e.indexOf("right")>-1?"right":"center"}d.setAttribute("resizable",o.resizable),d.setAttribute("draggable",o.draggable);const c=d.closest(".smart-editor-image-container");c?(c.setAttribute("alignment",r),c.setAttribute("display",e),d.removeAttribute("alignment"),d.removeAttribute("display")):(d.setAttribute("alignment",r),d.setAttribute("display",e))}}_handleVideoInsert(e){const t=this,o=t._getItemOptionsViaWindow(e),n=t.$.window;if(!n)return;let a,i,r,l,s=n._target.itemTarget;if(o.file.length?(r=o.file[0],a=URL.createObjectURL(r),s&&"video"!==s.nodeName.toLowerCase()&&(s.remove(),s=void 0)):(o.src||o.videoUrl)&&(a=(o.src||o.videoUrl)+"",s&&"iframe"!==s.nodeName.toLowerCase()&&(s.remove(),s=void 0)),s&&s.file&&(r=s.file),!a&&!r&&o)return t._focusFirstInputCallback(e.name,"src");if("markdown"===t.editMode)return i=o.title?` "${o.title}"`:"",void t._insertMarkDown(`[](${o.videoUrl} ${i})`);const d=t.$.iframe,c=t.$.editableElement,m=d?d.contentDocument:document;if(!r||s&&"video"===s.nodeName.toLowerCase()){if(!(r||s&&"iframe"===s.nodeName.toLowerCase())){const e=t.id+"newVideo"+Math.random().toString(36).substr(2,5);l=m.execCommand("insertHTML",!1,`<iframe id="${e}" frameborder="0" allowfullscreen></iframe>`),s=c.querySelector("#"+e)}}else{const e=t.id+"newVideo"+Math.random().toString(36).substr(2,5);l=m.execCommand("insertHTML",!1,`<video id="${e}"></video>`),s=c.querySelector("#"+e)}if(s){if(l&&s.removeAttribute("id"),URL.revokeObjectURL(s.src),s.controls=!0,s.frameborder=0,s.allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",t._handleVideoCaption(s,o),void 0!==o.width){const e=o.width+"";s.style.width=e?e+(e.indexOf("%")<0?"px":""):""}if(void 0!==o.height){const e=o.height+"";s.style.height=e?e+(e.indexOf("%")<0?"px":""):""}if(r){if(s.file===r)return;if(s.file=r,"base64"===t.imageFormat){const e=new FileReader;e.readAsDataURL(r),e.onload=()=>s.src=e.result}}else s.src!==a&&(s.src=a)}}_insertMarkDown(e,t,o){const n=this;if("markdown"!==n.editMode)return;const a=n.$.input,i=n._getSelectionRange(),r=i.selectionStart,l=i.selectionEnd;let s,d=a.value;if(void 0!==r&&r!==l&&(s=d.slice(r,l)),o){let t=d.lastIndexOf("\n",r-1)+1;for(;" "===d[t+1];)t++;a.value=d.slice(0,t)+e+d.slice(t)}else a.value=d.slice(0,a.selectionStart)+e+d.slice(a.selectionEnd);void 0!==r&&(void 0===t&&(t=r+e.length),s?o?n._setSelectionRange(a,r+e.length,l+e.length):(d=a.value,a.value=d.slice(0,t)+s+d.slice(t),n._setSelectionRange(a,t,t+s.length)):n._setSelectionRange(a,t,t)),n._refreshMarkdownPreview()}_removeMarkDown(e,t,o){const n=this,a=n.$.input,i=a.value,r=n._getSelectionRange(),l=r.selectionStart,s=r.selectionEnd,d=e.length;a.value=i.slice(0,t)+i.slice(t+d),n._setSelectionRange(a,l-d,s-d),o||n._refreshMarkdownPreview()}_handleLinksInsert(e){const t=this,o=t.$.window,n=t.editMode,a=t._getItemOptionsViaWindow(e);if(!a.address)return t._focusFirstInputCallback(e.name,"address");if("markdown"===n){let e;return e=a.title?`[${a.text}](${a.address}, "${a.title}")`:`[${a.text}](${a.address})`,void t._insertMarkDown(e)}const i=t.$.iframe,[r,l]=i?[i.contentDocument,i.contentWindow]:[document,window],s=l.getSelection();let d,c,m=s.anchorNode?s.anchorNode.parentElement:void 0,u=o&&o._target?o._target.itemTarget:void 0;u&&"img"===u.nodeName.toLowerCase()?(d=o._target.itemTarget,m=d.parentElement,m&&"a"===m.nodeName.toLowerCase()||(m=document.createElement("a"),d.parentElement.insertBefore(m,d),m.appendChild(d))):m=s.anchorNode?s.anchorNode.parentElement:void 0,a.address&&"a"!==m.nodeName.toLowerCase()&&(c=r.execCommand("createLink",!1,a.address),m=s.anchorNode.parentElement),"a"===m.nodeName.toLowerCase()&&(a.address?c||m.setAttribute("href",a.address):m.setAttribute("href",""),a.text?m.textContent=a.text:m.innerHTML||(m.textContent=a.address||""),m.title=a.title||"",m.target=a.target||"",d||s.selectAllChildren(m))}_refreshMarkdownPreview(){const e=this,t=e.$.input;if(e.$.contentContainer.hasAttribute("split-mode")){let o=t.value;e.$.editableElement.innerHTML=window.marked?window.marked(o):o}}_handleImgCaption(e,t){const o=this;if(!t)return;let n,a=e.closest(".smart-editor-image-container");const i=e.nodeName.toLowerCase(),r="video"===i||"iframe"===i&&e.src.indexOf("/embed")>-1;if(t.caption||r){if(a||(a=document.createElement("span"),a.classList.add("smart-editor-image-container"),a.setAttribute("draggable",!1),a.setAttribute("contenteditable",!1),e.hasAttribute("alignment")&&a.setAttribute("alignment",e.getAttribute("alignment")),e.hasAttribute("display")&&a.setAttribute("display",e.getAttribute("display")),e.parentElement.insertBefore(a,e),a.appendChild(e)),a.classList[r?"add":"remove"]("smart-editor-video-container"),n=a.querySelector(".smart-editor-image-caption"),n||(n=document.createElement("span"),n.setAttribute("contenteditable",!0),n.classList.add("smart-editor-image-caption"),a.appendChild(n)),n.textContent=t.caption,t.focusCaption)return delete o._toolbarItemClick,o._setSelectionRange(n),o._setResizeFrame(),void o.$.editableElement.scrollTo(n.offsetLeft,n.offsetTop)}else!t.caption&&a&&(a.hasAttribute("alignment")&&e.setAttribute("alignment",a.getAttribute("alignment")),a.hasAttribute("display")&&e.setAttribute("display",a.getAttribute("display")),a.parentElement.insertBefore(e,a),a.remove());o._resizeFrameObj&&o._resizeFrameObj.target&&o._setResizeFrame(o._resizeFrameObj.target,!0)}_handleVideoCaption(e,t){const o=this,n=e?e.nodeName.toLowerCase():void 0;if(!t||"video"!==n&&"iframe"!==n)return;let a=e.closest(".smart-editor-video-container");if(a||(a=document.createElement("span"),a.classList.add("smart-editor-image-container","smart-editor-video-container"),a.setAttribute("contenteditable",!1),e.parentElement.insertBefore(a,e),a.appendChild(e)),a.setAttribute("resizable",t.resizable),!1===t.draggable?a.setAttribute("draggable",!1):a.removeAttribute("draggable"),t.title&&(e.title=t.title),t.alignment){let e=t.alignment.toLowerCase();e=e.indexOf("left")>-1?"left":e.indexOf("right")>-1?"right":"center",a.setAttribute("alignment",e)}if(t.display){const e="inline"===t.display.toLowerCase()?"inline":"block";a.setAttribute("display",e)}if(t.caption){let e=a.querySelector(".smart-editor-image-caption");if(e||(e=document.createElement("span"),e.setAttribute("contenteditable",!0),e.classList.add("smart-editor-image-caption"),a.appendChild(e)),e.textContent=t.caption,t.focusCaption)return delete o._toolbarItemClick,o._setSelectionRange(e),o._setResizeFrame(),void o.$.editableElement.scrollTo(e.offsetLeft,e.offsetTop)}else if(!t.caption){let e=a.querySelector(".smart-editor-image-caption");e&&e.remove()}o._resizeFrameObj&&o._resizeFrameObj.target&&o._setResizeFrame(o._resizeFrameObj.target,!0)}_handleTableInsert(e){const t=this,o=t.editMode;if(!e)return;if("markdown"===o)return void t._insertTableMarkdown(e);const n=t._getSelectionRange();let a,i,r,l;if(e.cells){const t=e.cells;[r,l]=[t[1],t[0]]}else{let t=n.startContainer;[r,l]=[parseInt(e.cols),parseInt(e.rows)],t.nodeType===Node.TEXT_NODE&&(t=t.parentElement),a=t&&t.closest&&t.closest(".smart-editor-editable table")}if(!a){const e=t.$.editableElement,o=t.$.iframe,r=(o?o.contentWindow:window).getSelection();r.removeAllRanges(),r.addRange(n);const l=t.id+"newTable"+Math.random().toString(36).substr(2,5);i=(o?o.contentDocument:document).execCommand("insertHTML",!1,`<table id="${l}"><tbody></tbody></table>`),a=e.querySelector("#"+l)}if(a&&"table"===a.nodeName.toLowerCase()){let o,n=a.querySelector("tbody");for(n?o=Array.from(n.children):(a.innerHTML="<tbody></tbody>",n=a.firstElementChild,o=[]);o.length>l;)o.pop().remove();for(let e=o.length,t=l;e<t;e+=1)o.push(document.createElement("tr"));for(let e=0,t=o.length;e<t;e+=1){const t=o[e],a=Array.from(t.children);for(;a.length>r;)a.pop().remove();for(let e=0,o=r;e<o;e+=1){let o=a[e];o||(o=t.appendChild(document.createElement("td")))}t.parentElement||n.appendChild(t)}void 0===e.tableheader?e.tableheader=!!a.querySelector("th"):void 0===e.altrows?e.altrows=a.hasAttribute("alternation"):void 0===e.dashedborders?e.dashedborders=a.hasAttribute("dashed-borders"):void 0===e.resizable&&(e.resizable="false"!==a.getAttribute("resizable")),t._handleTableHeader(a,e.tableheader),e.altrows?a.setAttribute("alternation",""):a.removeAttribute("alternation"),e.dashedborders?a.setAttribute("dashed-borders",""):a.removeAttribute("dashed-borders");const s=e.width,d=e.height;a.style.width=s?s+(s.indexOf("%")<0?"px":""):"",a.style.height=d?d+(d.indexOf("%")<0?"px":""):"",i&&a.removeAttribute("id"),a.setAttribute("aria-rowcount",l),a.setAttribute("aria-colcount",r),a.setAttribute("resizable",e.resizable)}t._setResizeFrame(a)}_insertTableMarkdown(e){const t=this,o=e.cells,[n,a]=o?[o[1],o[0]]:[parseInt(e.cols),parseInt(e.rows)],i=t.localize("alphabet"),r=t.localize("header"),l=t.localize("column");let s="";if(!1!==e.tableheader){let e="",t=Math.max(3,r.length)+3;for(;t>0;)e+="-",t--;for(let e=1;e<=n;e+=1)s+=`| ${r} ${e} `;s+="|\n";for(let t=0;t<n;t++)s+=`|${e} `;s+="|\n"}for(let e=0;e<a;e++){const t=i[Math.max(0,e-1)%i.length].toUpperCase();for(let e=1;e<=n;e+=1)s+=`| ${l} ${t} ${e} `;s+="|\n"}t._insertMarkDown(s)}_handleTableSelection(e){const t=this,o=t.$.editableElement;if(t._tableCell&&t._tableCell.removeAttribute("selected"),"false"!==o.getAttribute("contenteditable"))return e&&["th","td"].indexOf(e.nodeName.toLowerCase())>-1?(t._tableCell=e,void e.setAttribute("selected","")):void delete t._tableCell}_getItemOptionsViaWindow(e){const t=this._windowEditors[e.name];if(!t)return;const o=t.children;let n={};for(let e=0,t=o.length;e<t;e+=1){const t=o[e].getAttribute("type"),a=o[e].querySelector("[item-editor]");let i;if(t){if(a instanceof Smart.Input)if(void 0===a.$.input.dataValue&&a.dataSource&&a.dataSource.length){const e=a.dataSource[0];i="string"==typeof e?e:e.value||e.label}else i=a.$.input.dataValue||a.value;else a instanceof Smart.CheckBox||a instanceof Smart.RadioButton?i=a.checked:a instanceof Smart.FileUpload?i=a.value:a instanceof Smart.ListBox&&(i=a.selectedIndexes);n[t]=i}}return n}_closeToolbarItemDropDown(e){const t=this,o=()=>{e.opened||e.remove()};e&&(e.opened?(e.hasAnimation&&(e.removeEventListener("transitionend",o),e.addEventListener("transitionend",o,{once:!0})),e.close(),t._setAriaOwns(e)):o())}_openToolbarItemDropDown(e,t){const o=this,n=e.getBoundingClientRect();o._setupDropDown(e,t),t.style.width=n.width+"px",t.style.height=n.height+"px",e.contains(t)||e.appendChild(t),t.open(),o._setAriaOwns(t),o._setAriaControls(e,t)}_setupDropDown(e,t){const o=this,n=o.$.inlineToolbar,a=n&&n.contains(e)?o._inlineToolbarItemsObj:o._toolbarItemsObj,i=a?a[e.getAttribute("item-name")]:void 0;let r;if(i&&(r=i.dataSource),r||(r=[]),t instanceof Smart.ColorInput?t.dropDownClassList=["smart-editor-color-input"]:(t.dropDownClassList=["smart-editor-input"],t.dropDownHeight=310),t.classList.add("smart-editor-item-drop-down"),t.readonly=!0,t.dataSource=r,t.dropDownOpenMode="manual",t.dropDownButtonPosition=o.rightToLeft?"left":"right",void 0!==i.value){const e=i.name;t.value=e.indexOf("table")>-1||e.indexOf("paste")>-1?"":i.value+""}else t.value=""}_toggleToolbar(e){const t=this,o=t.$.toolbar,n=t.$.contentContainer,a=t.toolbarViewMode,i="toggle"===a,r=t.$.toolbarToggleButton,l=t.$.toolbarItemsPrimary,s=t.hasAnimation;o.style.transition=s&&i?"none":"",o.style.height="";const d=o.offsetHeight,c=n.offsetHeight;if(e&&"toggle"===a){if(r.removeAttribute("checked"),r.setAttribute("aria-pressed",!1),!o.hasAttribute("expanded"))return void(o.style.transition="");o.removeAttribute("expanded")}else{if(r.setAttribute("checked",""),r.setAttribute("aria-pressed",!0),o.hasAttribute("expanded"))return o.style.transition="",void(t.$.toolbarItemsSecondary.innerHTML&&t._refreshToolbarItems());"scroll"!==a?o.setAttribute("expanded",""):o.removeAttribute("expanded")}if(t._refreshToolbarItems(),"menu"!==t.toolbarMode)return void(o.hasAttribute("expanded")?(l.querySelector(".smart-editor-toolbar-tab[checked]")||t._selectToolbarTab(l.firstElementChild),t._toggleSecondaryToolbar(!0)):(t._selectToolbarTab(null),t._toggleSecondaryToolbar()));if(!i)return;const m=o.offsetHeight,u=t.$.inlineToolbar;u&&u.visible&&u.reposition(),t._resizeFrameObj&&t._setResizeFrame(t._resizeFrameObj.target),o.style.height=d+"px",n.style.height=c+"px",s?requestAnimationFrame((()=>{o.style.transition="",o.style.height=m+"px",n.style.height=c+d-m+"px",requestAnimationFrame((()=>o.style.height=n.style.height=""))})):(o.style.transition="",o.style.height=m+"px",n.style.height=c+d-m+"px",requestAnimationFrame((()=>o.style.height=n.style.height="")))}_predefPropertyGetter(e="value"){const t=this;Object.defineProperty(t,e,{get:function(){return t.context===t?t.properties[e].value:t._getCurrentValue()},set(o){t._properties[e].value=t._getCurrentValue(),t.updateProperty(t,t._properties[e],o)}})}_getCurrentValue(){const e=this;if("markdown"===e.editMode)return e.$.input.value;let t=e.$.editableElement.innerHTML;return e.enableHtmlEncode&&(t=t.replaceAll("<","<").replaceAll(">",">")),t}_getInputValue(e,t){const o=this.$.input;return void 0===e&&(e=o.value),e=!t&&this.enableHtmlEncode?e.replaceAll("<","<").replaceAll(">",">"):e.replaceAll("<","<").replaceAll(">",">")}_handleEditMode(e){const t=this,o=t.$.input,n=t.$.editableElement,a=t.editMode,i=t._toolbarItemsObj.sourcecode,r=!!i&&i.value;t._closePopups(),"html"===e?r?o.value=n.innerHTML:n.innerHTML=o.value:"markdown"===e&&(r?n.innerHTML=window.marked?window.marked(o.value):o.value:o.value=n.textContent,t._closeSearchToolbar()),t.$.contentContainer.hasAttribute("split-mode")||("markdown"===a?r?(o.classList.add("smart-hidden"),n.classList.remove("smart-hidden")):(o.classList.remove("smart-hidden"),n.classList.add("smart-hidden")):r?(o.classList.remove("smart-hidden"),n.classList.add("smart-hidden")):(o.classList.add("smart-hidden"),n.classList.remove("smart-hidden"))),t.readonly||t.disableEditing||t.$.editableElement.setAttribute("contenteditable","markdown"!==a)}_handleInputContent(e,t){const o=this,n=o.$.editableElement,a=o.$.input,i=o.editMode;if(!o.isRendered&&o.autoLoad){const e=window.localStorage.getItem("smartEditor"+o.id);e&&o.set("value",e)}const r=o.value;void 0===t&&r&&(t=r),void 0!==t?"html"===i?o.$.editableElement.innerHTML=t:o.$.input.value=t:t||"markdown"!==i||(o.$.input.value=o.$.editableElement.textContent),o.$.contentContainer.hasAttribute("split-mode")?"markdown"===i?n.innerHTML=window.marked?window.marked(a.value):a.value:a.value=n.innerHTML.trim():o.classList.contains("preview-mode")&&("markdown"===i?n.innerHTML=window.marked?window.marked(a.value):a.value:a.value=n.innerHTML),n.textContent.length&&n.innerText.length?(n.removeAttribute("show-placeholder"),o._handleContentFiltering()):n.setAttribute("show-placeholder",""),o._clearSearchToolbar()}_sanitize(e,t){return this.sanitized?t.replaceAll(/(<[\/]?script[>]?)|([on].*=['"`]?.*['"`]?)|(SRC=['"`]?javascript:['"`]?)/gim,""):t}_handleContentFiltering(){const e=this,t=e.contentFiltering;if("html"===!e.editMode)return;const o=t.tags.map((e=>e.trim())),n=t.attributes.map((e=>e.trim())),a=t.styleAttributes.map((e=>e.trim()));if(!o.length&&!n.length&&!a.length)return;const i=t.tagFilterMode,r=t.attributeFilterMode,l=t.styleAttributeFilterMode;let s=e.$.editableElement.innerHTML;if(o.length){const e=new RegExp(/<\s*\/?\s*([a-z0-9]+).*?>/,"gmi");let t,n=[];for(;null!==(t=e.exec(s));){const e=t[1],a=o.indexOf(e)>-1;(a&&"blackList"===i||!a&&"whiteList"===i)&&n.push(t[0])}n.forEach((e=>s=s.replace(e,"")))}e.$.editableElement.innerHTML=s;const d=e.$.editableElement.querySelectorAll("*");for(let e=0,t=d.length;e<t;e+=1){const t=d[e];if(n.length){const e=Array.from(t.attributes);for(let o=0,a=e.length;o<a;o+=1){const a=e[o].name,i=n.indexOf(a)>-1;(i&&"blackList"===r||!i&&"whiteList"===r)&&t.removeAttribute(a)}}if(a.length){const e=t.getAttribute("style");if(!e)continue;const o=e.split(";");let n=[];for(let e=0,t=o.length;e<t;e+=1){const t=o[e],i=t.indexOf(":"),r=a.indexOf(t.slice(0,i>0?i:void 0))>-1;(r&&"whiteList"===l||!r&&"blackList"===l)&&n.push(t)}o.length&&(n.length?t.setAttribute("style",n.join(";")):t.removeAttribute("style"))}}e._setCharCount()}_handleContextMenuItemClick(e,t){if(!t||!t.classList.contains("smart-editor-context-menu-item"))return;const o=this,n=o.$.inlineToolbar,a=t.getAttribute("value");if(!n)return;const i=n.selector;switch(a){case"imageProperties":o._openWindow({name:"image"},i.closest(".smart-editor-editable img"));break;case"linkProperties":o._openWindow({name:"hyperlink"});break;case"tableProperties":o._openWindow({name:"table"},i.closest(".smart-editor-editable table"));break;case"videoProperties":{const e=i.closest(".smart-editor-video-container");if(e){const t=e.querySelectorAll(".smart-editor-video-container > video, .smart-editor-video-container > iframe");o._openWindow({name:"video"},t[0]||t[1])}break}case"insertRowAfter":case"insertRowBefore":case"deleteRow":o._handleTableRows(i.closest(".smart-editor-editable table"),{value:a});break;case"insertColumnLeft":case"insertColumnRight":case"deleteColumn":o._handleTableColumns(i.closest(".smart-editor-editable table"),{value:a});break;case"deleteImage":case"deleteTable":{const e=o._resizeFrameObj?o._resizeFrameObj.target:void 0;e&&o._deleteResizeFrameTarget(e);break}case"deleteVideo":{const e=i.closest(".smart-editor-video-container");if(e){const t=o._resizeFrameObj?o._resizeFrameObj.target:void 0;if(t===e){o._deleteResizeFrameTarget(t);break}e.remove()}break}case"createLink":o._openWindow({name:"hyperlink"},i.closest(".smart-editor-editable img"));break;case"deleteLink":o._handleLinkRemove(i);break;case"copyImage":o._handleImageCopy(i.closest(".smart-editor-editable img"));break;case"cutImage":o._handleImageCut(i.closest(".smart-editor-editable img"));break;case"copyVideo":o._handleImageCopy(i.closest(".smart-editor-video-container"));break;case"cutVideo":o._handleImageCut(i.closest(".smart-editor-video-container"));break;case"copy":case"cut":case"paste":o._handleClipboardAction(a);break;case"caption":{const e=i.closest(".smart-editor-editable img");let t;if(e&&"img"===e.nodeName.toLowerCase()){const n=e.closest(".smart-editor-image-container");n&&n.querySelector(".smart-editor-image-caption")||(t=o.localize("captionPlaceholder")),o._handleImgCaption(e,{caption:t,focusCaption:!0})}else if(i.classList.contains("smart-editor-video-container")){const e=i.querySelectorAll(".smart-editor-video-container > video, .smart-editor-video-container > iframe");i.querySelector(".smart-editor-image-caption")||(t=o.localize("captionPlaceholder")),o._handleVideoCaption(e[0]||e[1],{caption:t,focusCaption:!0})}break}case"selectAll":o._selectAll()}o.$.fireEvent("contextMenuItemClick",{originalEvent:e,value:a}),o._closeContextMenu()}_handleImageCopy(e){const t=this;if(!e||"img"!==e.nodeName.toLowerCase()&&!e.classList.contains("smart-editor-video-container"))return;const o=t._createWhiteSpaceChar(e,e.classList.contains("smart-editor-video-container")?e:void 0);t._setSelectionRange(e),t.$.editableElement.getRootNode().execCommand("copy"),o&&o.remove()}_handleImageCut(e){const t=this;if(!e||"img"!==e.nodeName.toLowerCase()&&!e.classList.contains("smart-editor-video-container"))return;const o=t._createWhiteSpaceChar(e,e.classList.contains("smart-editor-video-container")?e:void 0);t._setSelectionRange(e),t.$.editableElement.getRootNode().execCommand("cut"),t._setResizeFrame(),o&&o.remove()}_createWhiteSpaceChar(e,t){if(!t)return;const o=document.createElement("span");return o.innerHTML=" ",o.classList.add("smart-editor-video-white-space"),e.appendChild(o),o}_handleInputElement(){const e=this,t=e.iframeSettings,o=e.$.contentContainer,n=e.$.container,a=e.$.editableElement,i=e.$.input,r=e.readonly,l=e.disableEditing;if(a.contentEditable=!r&&!l,i.readonly=r||l,e._handlePlaceholder(),e._closePopups(),t.enabled?e._handleIframeSettings():n.contains(o)||(n.appendChild(o),a.setAttribute("contenteditable",!0),e.$.iframe&&(e.$.iframe.remove(),e._removeIframeEventListeners(),delete e.$.iframe)),"markdown"===e.editMode){const t=e.$.editableElement;e.$.input.classList.remove("smart-hidden"),t.classList.add("smart-hidden")}}_handleToolbarMode(){const e=this,t=e.$.toolbar,o=e.$.toolbarItemsSecondary,n=e.toolbarMode;e.$.toolbarItemsPrimary.innerHTML=o.innerHTML="","menu"===n?(o.classList.remove("smart-drop-down"),o.style.top=o.style.height="",t.contains(o)||t.appendChild(o),e._refreshToolbarItems(e._getToolbarItems())):(e._setToolbarTabs(),e._setToolbarItemGroups(),e._toolbarItemsObj||(e._toolbarItemsObj={}),e._refreshToolbarItems()),e._setToolbarGroupHeight()}_setToolbarTabs(){const e=this,t=e.toolbarRibbonConfig,o=e.$.toolbarToggleButton,n=e.$.toolbarItemsPrimary,a=n.querySelectorAll(".smart-editor-toolbar-tab"),i=document.createDocumentFragment();let r;for(let o=0,n=t.length;o<n;o+=1){const n=t[o];let l=a[o];l||(l=document.createElement("div")),l.classList.add("smart-editor-toolbar-tab"),l.setAttribute("tab-name",n.name),l.textContent=e.localize(n.name),!r&&l.hasAttribute("checked")&&(r=l),r!==l&&l.removeAttribute("checked"),l.classList[n.hidden?"add":"remove"]("smart-hidden"),i.appendChild(l)}o.hasAttribute("checked")&&!r&&i.children[0].setAttribute("checked",""),n.appendChild(i)}_setToolbarItemGroups(){const e=this,t=e.toolbarRibbonConfig,o=Array.from(e.$.toolbarItemsPrimary.querySelectorAll(".smart-editor-toolbar-tab")).find((e=>e.hasAttribute("checked")));if(!t||!o)return;const n=o.getAttribute("tab-name"),a=t.find((e=>e.name===n)),i=a?a.groups:null,r=e.$.toolbarItemsSecondary,l="singleLineRibbon"===e.toolbarMode;if(r.innerHTML="",!Array.isArray(i))return;const s=r.querySelectorAll(".smart-editor-toolbar-tab-group"),d=document.createDocumentFragment();for(let t=0,o=i.length;t<o;t+=1){const o=i[t],n=o.name;let a=s[t];if(a||(a=document.createElement("div")),l)a.innerHTML="",a.appendChild(e._getToolbarItems(e.$.toolbar,o.items));else{a.innerHTML='<div class="smart-editor-tab-group-container"></div><div class="smart-editor-tab-group-label"></div>';const t=a.firstElementChild;a.lastElementChild.innerHTML=e.localize(n),t.appendChild(e._getToolbarItems(e.$.toolbar,o.items))}a.classList.add("smart-editor-toolbar-tab-group"),a.setAttribute("group-name",n),d.appendChild(a)}r.appendChild(d),r.classList.remove("smart-visibility-hidden"),e._refreshToolbarTabs()}_refreshToolbarTabs(){const e=this,t=e._resizeFrameObj,o=Array.from(e.$.toolbarItemsPrimary.children).find((e=>"layouttab"===(e.getAttribute("tab-name")||"").toLowerCase()));if(!o)return;if(!t||!t.target||"singleLineRibbon"!==e.toolbarMode)return o.classList.add("smart-hidden"),void(o.hasAttribute("checked")&&e._selectToolbarTab(e.$.toolbarItemsPrimary.firstElementChild));const n=e.$.toolbarItemsSecondary.children,a=t.target,i=a.nodeName.toLowerCase();let r,l,s;for(let e=0,t=n.length;e<t;e+=1){const t=n[e],o=t.getAttribute("group-name");"tableGroup"===o?(l=t,l.classList.add("smart-hidden")):"imageGroup"===o?(r=t,r.classList.add("smart-hidden")):"videoGroup"===o&&(s=t,s.classList.add("smart-hidden"))}"table"===i?(o.classList.remove("smart-hidden"),l&&l.classList.remove("smart-hidden")):"img"===i?(o.classList.remove("smart-hidden"),r&&r.classList.remove("smart-hidden")):a.classList.contains("smart-editor-video-container")?(o.classList.remove("smart-hidden"),s&&s.classList.remove("smart-hidden")):o.classList.add("smart-hidden")}_handlePlaceholder(){const e=this.$.editableElement,t=this.placeholder;t?e.setAttribute("placeholder",t):e.removeAttribute("placeholder")}_handleIframeSettings(){const e=this;if(!e.iframeSettings.enabled)return;let t=e.$.iframe;t||(t=e.$.iframe=document.createElement("iframe")),t.parentElement||e.$.container.appendChild(t),!t.contentWindow.marked&&window.marked&&(t.contentWindow.marked=window.marked),e._handleIframeBody(),e._handleIframeAttributes(),e._handleIframeResources()}_removeIframeEventListeners(){const e=this,t=e.$.iframe.contentDocument,o=e.$iframe;o&&(o.unlisten("down"),o.unlisten("move"),o.unlisten("up")),t.removeEventListener("dragstart",e._iframeDragStartHandler),t.removeEventListener("dragend",e._iframeDragEndHandler),t.removeEventListener("selectionchange",e._iframeSelectionChangeHandler)}_handleIframeBody(){const e=this,t=e.$.iframe.contentDocument,o=t.body;if(!o)return;let n=e.$iframe;o.classList.add("smart-editor","smart-element","smart-editor-iframe-body"),o.appendChild(e.$.contentContainer),e._updateIframeBody(),n||(n=e.$iframe=Smart.Utilities.Extend(o)),e._iframeDownHandler=t=>e._documentDownHandler.call(e,t),e._iframeMoveHandler=t=>e._documentMoveHandler.call(e,t),e._iframeUpHandler=t=>e._documentUpHandler.call(e,t),e._iframeDragStartHandler=t=>e._dragStartHandler.call(e,t),e._iframeDragEndHandler=t=>e._dragEndHandler.call(e,t),e._iframeSelectionChangeHandler=t=>e._selectionChangeHandler.call(e,t),e._removeIframeEventListeners(),n.listen("down",e._iframeDownHandler),n.listen("move",e._iframeMoveHandler),n.listen("up",e._iframeUpHandler),t.addEventListener("dragstart",e._iframeDragStartHandler),t.addEventListener("dragend",e._iframeDragEndHandler),t.addEventListener("selectionchange",e._iframeSelectionChangeHandler)}_updateIframeBody(){const e=this,t=e.$.iframe;if(!t)return;const o=t.contentDocument.body;o&&(e.rightToLeft?o.setAttribute("right-to-left",""):o.removeAttribute("right-to-left"),e.theme?o.setAttribute("theme",e.theme):o.removeAttribute("theme"),o.setAttribute("animation",e.animation))}_handleIframeAttributes(){const e=this,t=e.$.iframe,o=e.iframeSettings.attributes;if(!t)return;if(t.hasAttribute("title")||t.setAttribute("title",e.localize("iframeTitle")),!o||"object"!=typeof o)return;const n=e.$.editableElement;for(let e in o){const a=o[e];"readonly"===e?n.setAttribute("contenteditable",!a):t[e]=a}}_handleIframeResources(){const e=this.iframeSettings.resources,t=this.$.iframe;if(!t||"object"!=typeof e)return;const o=document.styleSheets,n=t.contentDocument,a=n.head,i=n.body;for(let e in o){const n=o[e],a=n.ownerNode;"text/css"===n.type&&a&&["link","style"].indexOf(a.nodeName.toLocaleLowerCase())>-1&&t.contentDocument.head.appendChild(n.ownerNode.cloneNode())}for(let t in e){const o=t,n=e[t];let r;if((o+"").indexOf("style")>-1||"link"===o?(r=document.createElement("link"),r.rel="stylesheet",r.type="text/css","string"==typeof n&&(r.href=n)):"script"===o&&(r=document.createElement("script"),r.type="text/javascript","string"==typeof n&&(r.src=n)),"object"==typeof n&&"[object Object]"===n.toString())for(let e in n)r[e]=n[e];"module"===r.type?i.appendChild(r):a.appendChild(r)}}_handleMaxCharCount(){const e=this,t=e.$.input;null!==e.maxCharCount?t.maxLength=e.maxCharCount:t.removeAttribute("maxlength")}_getToolbarItems(e,t){const o=this;e||(e=o.$.toolbar),t||(t=o.toolbarItems);const n=e===o.$.toolbar?"toolbar":"inlineToolbar",a=e.querySelectorAll(".smart-editor-toolbar-item"),i=document.createDocumentFragment();for(let e=0,r=t.length;e<r;e+=1){const r=o._getToolbarItemDetails(n,t[e]),l=r.name,s=r.type;let d=a[e];if(d?"custom"===d.getAttribute("item-type")&&(d.innerHTML=""):(d=document.createElement("div"),d.classList.add("smart-editor-toolbar-item")),"color-input"===s)d.innerHTML||(d.innerHTML=`<div class="smart-editor-item-action-button" item-name="${l}"></div>\n <div class="smart-editor-item-drop-down-button"></div>`);else if("custom"===s){const e=r.template;d.innerHTML="",e&&e.closest&&!d.contains(e)?d.appendChild(e):"string"!=typeof e||d.innerHTML?"function"==typeof e&&e(d,r):d.innerHTML=e||""}else"toggle"===s&&(r.value?(d.setAttribute("checked",""),d.setAttribute("aria-pressed",!0)):(d.removeAttribute("checked"),d.setAttribute("aria-pressed",!1)),d.innerHTML&&(d.innerHTML=""));r.disabled||"paste"===l&&o._isFireFox?(d.setAttribute("disabled",""),d.setAttribute("aria-disabled",!0)):(d.removeAttribute("disabled"),d.removeAttribute("aria-disabled")),d.setAttribute("role","delimiter"===s?"separator":"button"),"color-input"===s||"drop-down"===s?d.setAttribute("aria-haspopup",!0):d.removeAttribute("aria-haspopup"),o._setItemValue(d,r),r.title?d.setAttribute("title",r.title):d.removeAttribute("title"),d.setAttribute("item-name",l),d.setAttribute("item-type",s),d.style.width=r.width||"",i.appendChild(d)}return i}_setItemValue(e,t){const o=this;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"))))}_refreshToolbarItems(e){const t=this,o=t.$.toolbar,n=t.$.toolbarToggleButton,a=t.$.toolbarItemsPrimary,i=t.$.toolbarItemsSecondary;if("menu"===t.toolbarMode){if(a.scrollTop=a.scrollLeft=0,e)a.appendChild(e);else{const e=Array.from(i.children),t=document.createDocumentFragment(),o=e.length;for(let n=0;n<o;n+=1)t.appendChild(e[n]);o>0&&a.appendChild(t)}if("toggle"===t.toolbarViewMode){const e=a.offsetHeight;if(o.hasAttribute("expanded")){let t=[];e:for(;a.scrollHeight>e;){const e=a.lastElementChild;if(!e)break e;t.push(e),e.remove()}t.reverse();for(let e=0,o=t.length;e<o;e+=1)i.appendChild(t[e])}else a.scrollHeight===e&&n.classList.add("smart-visibility-hidden")}}else n.classList.remove("smart-visibility-hidden")}_resizeHandler(e){const t=this,o=t.$.inlineToolbar;if(e.target===t){if("toggle"===t.toolbarViewMode){const e=t.$.toolbarItemsPrimary,o=t.$.toolbarItemsSecondary;t.$.toolbar.hasAttribute("expanded")&&t._refreshToolbarItems();const n=t.$.toolbarToggleButton;e.scrollHeight!==e.offsetHeight||o.children.length?n.classList.remove("smart-visibility-hidden"):n.classList.add("smart-visibility-hidden")}if("menu"===t.toolbarMode||t.$.toolbarItemsSecondary.classList.contains("smart-visibility-hidden")||t._setToolbarGroupHeight(),o&&o.visible){const e=o.selector;e.classList.contains("smart-editor-toolbar-item")&&e.offsetTop>=t.$.toolbar.offsetHeight?o.close():o.reposition()}t._positionWindow(),t._resizeFrameObj&&t._setResizeFrame(t._resizeFrameObj.target)}}_setToolbarItemAttr(e,t,o){const n=this,a=n.$.toolbar,i=n.$.inlineToolbar,r=[n._toolbarItemsObj,n._inlineToolbarItemsObj];for(let n=0,l=r.length;n<l;n+=1){const l=r[n],s=l?l[e]:void 0;if(s){const n=l==l?a:i;if(s[t]=o,!n||!n.parentElement)continue;const r=n.querySelector(`.smart-editor-toolbar-item[item-name="${e}"]`);if(!r)continue;null==o||!1===o?(r.removeAttribute(t),"disabled"===t&&r.removeAttribute("aria-disabled")):(r.setAttribute(t,o),"disabled"===t&&r.setAttribute("aria-disabled",!0))}}}_setToolbarVisibility(){const e=this,t=e.$.toolbar,o=e.$.toolbarToggleButton;"toggle"!==e.toolbarViewMode||o.hasAttribute("checked")?t.setAttribute("expanded",""):t.removeAttribute("expanded")}_getToolbarItemDetails(e,t){const o=this;let n,a=o[`_${e}ItemsObj`];if(n="string"==typeof t?t:"object"==typeof t&&t.name?t.name+"":"",n=n.trim().toLowerCase(),a){if(void 0!==a[n])return a[n]}else a=o[`_${e}ItemsObj`]={};const i=a[n]={};return i.title=t.title||o.localize(n),i.name=n,i.toolbarName=e,i.advanced=!!t.advanced,i.inlineToolbarItems=t.inlineToolbarItems,o._setItemType(t,i,n),o._setItemData(t,i,n),o._setItemTemplate(t,i,n),o._setItemSpecifics(t,i,n),i}_setItemType(e,t,o){let n;if(t){switch(o){case"sourcecode":case"splitmode":case"fullscreen":n="toggle";break;case"alignment":case"fontname":case"fontsize":case"formats":case"tablerows":case"tablecolumns":case"tablevalign":case"tablestyle":n="drop-down";break;case"backgroundcolor":case"fontcolor":n="color-input";break;case"bold":case"italic":case"underline":case"strikethrough":case"delete":case"redo":case"undo":case"indent":case"outdent":case"openlink":case"editlink":case"createlink":case"removelink":case"hyperlink":case"cut":case"copy":case"image":case"video":case"lowercase":case"uppercase":case"print":case"caption":case"clearformat":case"table":case"tableheader":case"orderedlist":case"unorderedlist":case"subscript":case"superscript":case"findandreplace":n="button";break;case"paste":n=t.advanced?"drop-down":"button";break;default:n="string"==typeof e?"delimiter":"custom"}t.type=n}}_setItemData(e,t,o){const n=this;let a,i;if(!t||!e)return;const r=t.type;let l=e.width;if("drop-down"===r||"color-input"===r){if("object"==typeof e&&(a=e.dataSource,void 0!==e.value&&(i=e.value+"")),a&&Array.isArray(a)||(a=n._getDefaultDataSource(o,t)),void 0===i&&("fontsize"===t.name&&(i=parseInt(window.getComputedStyle(n.$.editableElement).fontSize)),isNaN(i)&&a.length)){const e=a[0];i=e["alignment"===o?"value":"label"]||e}o.indexOf("table")>-1&&(i="")}void 0!==l&&("number"==typeof l?l+="px":(l+="",l.includes("%")||(l=parseFloat(e.width),l=isNaN(l)?"":l+"px"))),t.dataSource=a,t.value=i,t.disabled=!!e.disabled,t.width=l}_setItemSpecifics(e,t,o){if(!t||"object"!=typeof e)return;let n=e.editor,a=t.editor;if(a||(a=t.editor={}),!n)return;let i=[],r=[];switch(o){case"createlink":case"removelink":case"hyperlink":i=["address","text","target"];break;case"image":i=["allowedTypes","uploadUrl","removeUrl","path","display"],r=["draggable","resizable"];break;case"table":i=["cols","rows","tableheader"],r=["altrows","dashedborders","resizable"]}for(let e in n){let t=n[e];void 0!==t&&(i.indexOf(e)>-1?"display"===e?t="block"===t?"block":"inline":t+="":r.indexOf(e)>-1?t=!!t:"width"!==e&&"height"!==e||"string"==typeof t||(t+="px"),a[e]=t)}}_getDefaultDataSource(e,t){const o=this;let n=[];switch(e){case"alignment":n=[{label:o.localize("alignLeft"),value:"left",icon:"editor-icon"},{label:o.localize("alignCenter"),value:"center",icon:"editor-icon"},{label:o.localize("alignRight"),value:"right",icon:"editor-icon"}],t&&"toolbar"===t.toolbarName&&n.push({label:o.localize("alignJustify"),value:"justify",icon:"editor-icon"});break;case"display":n=[{label:o.localize("displayInline"),value:"inline"},{label:o.localize("displayBlock"),value:"block"}];break;case"fontname":["segoeUi","arial","georgia","impact","tahoma","timesNewRoman","verdana"].forEach((e=>{n.push({label:o.localize(e),value:e})}));break;case"fontsize":["8","10","12","14","18","24","36"].forEach((e=>{n.push({label:e,value:e})}));break;case"formats":["p","pre","blockquote","h1","h2","h3","h4"].forEach((e=>{n.push({label:o.localize(e),value:e})}));break;case"backgroundcolor":case"fontcolor":["#000000","#FFFFFF","#D50000","#E67C73","#F4511E","#F6BF26","#33B679","#0B8043","#039BE5","#3F51B5","#7986CB","#8E24AA","#616161",""].forEach((e=>{n.push({label:e,value:e})}));break;case"paste":n=[{label:o.localize("plainText"),value:"plainText"},{label:o.localize("keepFormat"),value:"keepFormat"},{label:o.localize("cleanFormat"),value:"cleanFormat"}];break;case"target":n=[{label:o.localize("linkBlankDescr"),value:"_blank"},{label:o.localize("linkSelfDescr"),value:"_self"},{label:o.localize("linkParentDescr"),value:"_parent"},{label:o.localize("linkTopDescr"),value:"_top"},{label:o.localize("linkCustomDescr"),value:""}];break;case"tablerows":n=[{label:o.localize("insertRowBefore"),value:"insertRowBefore",icon:"editor-icon"},{label:o.localize("insertRowAfter"),value:"insertRowAfter",icon:"editor-icon"},{label:o.localize("deleteRow"),value:"deleteRow",icon:"editor-icon"}];break;case"tablecolumns":n=[{label:o.localize("insertColumnLeft"),value:"insertColumnLeft",icon:"editor-icon"},{label:o.localize("insertColumnRight"),value:"insertColumnRight",icon:"editor-icon"},{label:o.localize("deleteColumn"),value:"deleteColumn",icon:"editor-icon"}];break;case"tablevalign":n=[{label:o.localize("alignTop"),value:"top"},{label:o.localize("alignMiddle"),value:"middle"},{label:o.localize("alignBottom"),value:"bottom"}];break;case"tablestyle":n=[{label:o.localize("dashedborders"),value:"dashedborders"},{label:o.localize("altrows"),value:"altrows"}]}return n}_setItemTemplate(e,t){let o=e.template;t&&(o?(o&&o.closest?o="content"in o?document.importNode(o.content,!0):o:"function"==typeof o?o=o.bind(this):"string"==typeof o&&(o=document.getElementById(o)||o),t.template=o):delete t.template)}_setAriaSettings(){const e=this,t=e.$.input,o=e.$.editableElement;e.setAttribute("role","application"),e.setAttribute("aria-roledescription",e.localize("roleDescription")),e.$.toolbarToggleButton.setAttribute("aria-label",e.localize("toolbarButtonAriaLabel")),e.$.toolbarItemsPrimary.setAttribute("aria-label",e.localize("primaryToolbarAriaLabel")),e.$.toolbarItemsSecondary.setAttribute("aria-label",e.localize("secondaryToolbarAriaLabel")),t.setAttribute("aria-label",e.localize("inputAreaLabel")),t.id=e.id+"TextArea",o.id=e.id+"EditableElement",o.setAttribute("aria-label",e.localize("inputAriaLabel"))}_setAriaControls(e,t){const o=this;e&&e.nodeName&&(t.id||(t.id=o.id+"Popup"+Math.floor(65536*(1+Math.random())).toString(16).substring(1)),e.setAttribute("aria-controls",t.id))}_setAriaOwns(e){const t=this;if(!e)return;const o=e.id;let n=(t.getAttribute("aria-owns")||"").split(" ").filter((e=>e.length));const a=n.indexOf(o);if(a>-1){if(e.parentElement&&(e.opened||e.visible))return;n.splice(a,1)}else n.push(o);n.length?t.setAttribute("aria-owns",n.join(" ")):t.removeAttribute("aria-owns")}_setFocusable(){const e=this,t=e.$.editableElement;if(e.disabled||e.unfocusable)return void(t&&t.removeAttribute("tabindex"));const o=e.tabIndex>0?e.tabIndex:0;t&&(t.tabIndex=o)}_selectAll(){const e=this,t=e.$.input,o=e.$.editableElement;t.classList.contains("smart-hidden")||t.select(),o.classList.contains("smart-hidden")||e._setSelectionRange(o)}_selectStartHandler(e){const t=this._resizeFrameObj,o=this._inlineToolbarClickObj;(t&&t.resizeDetails||o&&o.resizeDetails)&&e.preventDefault()}_selectionChangeHandler(e){const t=this;if(t.disabled||!e.target.getSelection)return;const o=e.target.getSelection().focusNode;if(t.$.contentContainer.contains(o)){if(t._ignoreSelectionChange||o.classList&&o.classList.contains("smart-search-input"))return;t._selectionChangeFired=!0,t._setSelectionRange(),t._updateToolbarItems(),delete t._selectionChangeFired}}_selectToolbarTab(e){const t=this,o=t.$.toolbar,n=t.$.toolbarItemsPrimary,a=e&&!e.hasAttribute("checked"),i=n.querySelectorAll(".smart-editor-toolbar-tab");for(let t=0,o=i.length;t<o;t+=1){const o=i[t];e===o&&a?o.setAttribute("checked",""):o.removeAttribute("checked")}let r=t._tabSelectionBar;r||(t._tabSelectionBar=r=document.createElement("div"),r.classList.add("smart-editor-toolbar-tab-selection-bar")),r.classList.add("smart-visibility-hidden"),e&&e.hasAttribute("checked")?(o.setAttribute("toolbar-tab-selected",""),r.style.left=e.offsetLeft+"px",r.style.width=e.offsetWidth+"px",n.contains(r)||n.appendChild(r),t._setToolbarItemGroups(),requestAnimationFrame((()=>r.classList.remove("smart-visibility-hidden")))):o.removeAttribute("toolbar-tab-selected")}}),Smart("smart-table-picker",class extends Smart.BaseElement{static get properties(){return{columns:{value:10,type:"number"},messages:{extend:!0,value:{en:{buttonLabel:"Insert Table"}}},rows:{value:3,type:"number"},value:{value:[],type:"array"}}}static get listeners(){return{"tableGrid.mouseover":"_cellOver","tableGrid.mouseleave":"_cellLeave","tableGrid.click":"_cellOver"}}template(){return'<div id="container" role="presentation">\n <div id="tableGrid" class="smart-table-picker-grid" role="presentation"></div>\n <div class="smart-table-picker-separator" role="separator"></div>\n <smart-button id="tableButton" class="smart-table-picker-button" right-to-left="[[rightToLeft]]"></smart-button>\n </div>'}propertyChangedHandler(e,t,o){const n=this;switch(e){case"value":n._selectCell(o,t,!0);break;case"rows":case"columns":n._createTableGrid();break;case"messages":n._setTableButton();break;default:super.propertyChangedHandler(e,t,o)}}render(){const e=this;e._isMobile=Smart.Utilities.Core.isMobile,e._createTableGrid(),e._setTableButton(),e._setAria(),super.render()}_setAria(){this.setAttribute("role","grid")}_createTableGrid(){const e=this,t=e.$.tableGrid,o=e.columns,n=e.rows,a=t.children,i=document.createDocumentFragment();let r=a.length;for(;r>n;){const e=a[0];if(!e)break;e.remove(),r--}for(let e=r,t=n;e<t;e+=1){const e=document.createElement("div");e.setAttribute("role","row"),i.appendChild(e)}i.children.length&&t.appendChild(i);for(let e=0,t=n;e<t;e+=1){const t=a[e],n=t.children;let i=n.length;for(;i>o&&n[0];)n[0].remove(),i--;for(let e=i,n=o;e<n;e+=1){const e=document.createElement("span");e.setAttribute("role","gridcell"),e.classList.add("smart-table-picker-cell"),t.appendChild(e)}}e._selectCell(e.value)}_cellOver(e){const t=this,o=e.target;let n=[];if(!t.$.tableGrid.contains(o))return void t._selectCell(t.value);const a=o.closest(".smart-table-picker-cell");if(a){const o=a.parentElement,i=Array.from(o.children);n[0]=Math.max(0,Array.from(t.$.tableGrid.children).indexOf(o)+1),n[1]=Math.max(0,i.indexOf(a)+1),t._selectCell(n,t.value,"click"===e.type)}}_cellLeave(){this._selectCell(this.value)}_selectCell(e,t,o){const n=this,a=n.$.tableGrid,i=Array.from(a.children),r=i.length;let l=0,s=0;e&&(l=e[0]||0,s=e[1]||0);for(let e=0,t=r;e<t;e+=1){const t=i[e].children;if(l<e+1)for(let e=0,o=t.length;e<o;e+=1)t[e].removeAttribute("selected");else for(let e=0,o=t.length;e<o;e+=1)s>=e+1?t[e].setAttribute("selected",""):t[e].removeAttribute("selected")}a.setAttribute("value",l+"x"+s),o&&(void 0===t&&(t=n.value),n.set("value",[l,s]),t[0]===l&&t[1]===s||n.$.fireEvent("change",{value:e,oldValue:t}))}_setTableButton(){this.$.tableButton.innerHTML=this.localize("buttonLabel")}});
|
|
806
|
+
Smart("smart-editor",class extends Smart.ContentElement{static get properties(){return{autoLoad:{value:!1,type:"boolean"},autoSave:{value:!1,type:"boolean"},autoSaveInterval:{value:1e3,type:"number"},autoExpand:{value:!1,type:"boolean"},charCountFormatFunction:{value:null,type:"function?"},contentFiltering:{value:{attributes:{value:[],type:"array"},attributeFilterMode:{allowedValues:["blackList","whiteList"],value:"blackList",type:"string"},tags:{value:[],type:"array"},tagFilterMode:{allowedValues:["blackList","whiteList"],value:"blackList",type:"string"},styleAttributes:{value:[],type:"array"},styleAttributeFilterMode:{allowedValues:["blackList","whiteList"],value:"blackList",type:"string"}},type:"object"},contextMenu:{allowedValues:["default","browser","none"],value:"default",type:"string"},contextMenuDataSource:{value:null,type:"any",reflectToAttribute:!1},dataExport:{value:{style:{value:null,type:"object"},fileName:{value:"smartEditor",type:"string?"},pageOrientation:{value:"portrait",type:"string"}},type:"object"},disableEditing:{value:!1,type:"boolean"},disableSearchBar:{value:!1,type:"boolean"},editMode:{allowedValues:["html","markdown"],value:"html",type:"string"},enableHtmlEncode:{value:!1,type:"boolean"},enableTabKey:{value:!1,type:"boolean"},findAndReplaceTimeout:{value:50,type:"number"},hideToolbar:{value:!1,type:"boolean"},hideInlineToolbar:{value:!1,type:"boolean"},imageFormat:{allowedValues:["blob","base64"],value:"base64",type:"string"},imageName:{value:"userfile[]",type:"string"},innerHTML:{type:"string",validator:"_sanitize",reflectToAttribute:!1},inlineToolbarOffset:{value:[0,-5],type:"array"},iframeSettings:{value:{attributes:{value:null,type:"object?"},enabled:{value:!1,type:"boolean"},resources:{value:null,type:"object?"}},type:"object"},maxCharCount:{value:null,type:"number?"},messages:{extend:!0,value:{en:{invalidValue:"{{elementType}}: Invalid {{property}} value. {{property}} should be of type {{typeOne}} or {{typeTwo}}.",incorrectArgument:"{{elementType}}: Incorrect argument {{argumentName}} in method {{methodName}}.",permissionsRequired:"{{elementType}}: Permissions are required for the following action {{actionName}}.",timeout:"{{elementType}}: The import request has timed out.",importError:"{{elementType}}: The import request errored with the following status: {{status}}.",exportError:"{{elementType}}: The Export request errored with the following status: {{status}}.",ok:"Ok",cancel:"Cancel",alignLeft:"Align Left",alignCenter:"Align Center",alignRight:"Align Right",alignJustify:"Align Justify",segoeUi:"Segoe UI",arial:"Arial",georgia:"Georgia",impact:"Impact",tahoma:"Tahoma",timesNewRoman:"Times New Roman",verdana:"Verdana",p:"Paragraph",pre:"Code",code:"Code",blockquote:"Quotation",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",h6:"Heading 6",bold:"Bold",italic:"Italic",underline:"Underline",strikethrough:"Strikethrough",orderedlist:"Ordered List",unorderedlist:"Unordered List",subscript:"Subscript",superscript:"Superscript",alignment:"Alignments",fontname:"Font Name",fontsize:"Font Size",formats:"Formats",backgroundcolor:"Background Color",fontcolor:"Font Color",redo:"Redo",undo:"Undo",indent:"Indent",outdent:"Outdent",createlink:"Hyperlink",hyperlink:"Hyperlink",editlink:"Hyperlink",removelink:"Remove link",openlink:"Open link",image:"Image",video:"Video",table:"Table",lowercase:"Lower Case",uppercase:"Upper Case",print:" Print",cut:" Cut",copy:" Copy",paste:" Paste",clearformat:"Clear Format",fullscreen:"Full Screen",restore:"Restore Screen",sourcecode:"Source Code",preview:"Preview",splitmode:"Split Editor",address:"Web Address",text:"Display Text",addressPlaceholder:"http://example.com",textPlaceholder:"Enter Text",targetPlaceholder:"Select Target",titlePlaceholder:"Enter a Title",urlPlaceholder:"http://example.com/image.png",srcPlaceholder:"https://www.youtube.com/embed/video_link",thumbnail:"Or provide a URL as a video thumbnail",thumbnailPlaceholder:"https://www.link-to-thumbnail.jpg",videoUrl:"Video URL",videoUrlPlaceholder:"https://www.youtube.com/video_link",captionPlaceholder:"Caption",altPlaceholder:"Alternative Text",widthPlaceholder:"auto",heightPlaceholder:"auto",target:"Open Link in",linkBlankDescr:"New Window",linkSelfDescr:"Same Window",linkParentDescr:"Parent Frame",linkTopDescr:"Full Body of the Window",linkCustomDescr:"Custom Frame Name",title:"Title",url:"Or provide the URL to an image",src:"Or provide the URL to an embed video",width:"Width",height:"Height",alt:"Alternative Text",caption:"Caption",display:"Display",displayPlaceholder:"Display",displayBlock:"Block",displayInline:"Inline",draggable:"Enable Dragging",resizable:"Enable Resizing",browse:"Browse",connectionError:"{{elementType}}: File Upload requires connection to the server.",wrongItemIndex:"{{elementType}}: There is no file with such an index in the list of uploaded files.",tooLongFileName:"{{elementType}}: File name is too long.",totalFiles:"Total files: ",cancelFile:"Cancel File",dashedborders:"Dashed Borders",altrows:"Alternate Rows",insertRowBefore:"Insert Row Before",insertRowAfter:"Insert Row After",deleteRow:"Delete Row",insertColumnLeft:"Insert Column Left",insertColumnRight:"Insert Column Right",deleteColumn:"Delete Column",alignTop:"Align Top",alignMiddle:"Align Middle",alignBottom:"Align Bottom",delete:"Delete",tablerows:"Table Rows",tablecolumns:"Table Columns",tablevalign:"Table Cell Vertical Align",tablestyle:"Table Style",tableheader:"Table Header",buttonLabel:"Custom Table",pasteLabel:"Choose the paste format action:",cols:"Columns",rows:"Rows",alphabet:"abcdefghijklmnopqrstuvwxyz",header:"Header",column:"Column",plainText:"Plain Text",keepFormat:"Keep Format",cleanFormat:"Clean Format",roleDescription:"Text Editor",iframeTitle:"Editor Content is Encloused in it's own DOM inside an iFrame",toolbarButtonAriaLabel:"Toolbar Toggle Button",primaryToolbarAriaLabel:"Primary Toolbar",secondaryToolbarAriaLabel:"Secondary Toolbar",inputAriaLabel:"Enter Text",homeTab:"Home",viewTab:"View",insertTab:"Insert",layoutTab:"Layout",undoGroup:"Undo",clipboardGroup:"Clipboard",fontGroup:"Font",paragraphGroup:"Paragraph",editingGroup:"Editing",tableGroup:"Tables",imageGroup:"Images",videoGroup:"Videos",linkGroup:"Links",viewsGroup:"Views",deleteGroup:"Delete",findandreplace:"Find and Replace",requiredMessage:"The content of the Editor cannot be empty",tableProperties:"Table Properties",imageProperties:"Image Properties",videoProperties:"Video Properties",linkProperties:"Link Properties",selectAll:"Select All",deleteTable:"Delete Table",deleteImage:"Delete Image",deleteVideo:"Delete Video",createLink:"Create Link",deleteLink:"Delete Link",copyImage:"Copy",cutImage:"Cut",copyVideo:"Copy",cutVideo:"Cut",find:"Find",findPlaceholder:"",replace:"Replace",replaceWith:"Replace With",replaceAll:"Replace All",replacePlaceholder:"",results:"Results",resultsPlaceholder:"No match",matchCase:"Match Case",searchPlaceholder:"Search..."}}},name:{value:null,type:"string?"},pasteFormat:{allowedValues:["prompt","plainText","keepFormat","cleanFormat"],value:"keepFormat",type:"string"},postData:{value:null,type:"object"},placeholder:{value:"",type:"string"},removeStylesOnClearFormat:{value:!1,type:"boolean"},required:{value:!1,type:"boolean"},sanitized:{value:!1,type:"boolean"},showCharCount:{value:!1,type:"boolean"},splitModeRefreshTimeout:{value:100,type:"number"},toolbarItems:{value:["bold","italic","underline","|","formats","alignment","orderedList","unorderedList","|","hyperlink","image","video","|","sourceCode","undo","redo"],reflectToAttribute:!1,type:"array"},toolbarMode:{allowedValues:["menu","singleLineRibbon"],value:"menu",type:"string"},toolbarRibbonConfig:{value:[{name:"homeTab",groups:[{name:"undoGroup",items:["undo","redo"]},{name:"clipboardGroup",items:["cut","copy","paste"]},{name:"fontGroup",items:["fontName","fontSize","backgroundColor","fontColor","clearFormat","formats","bold","italic","underline","strikethrough","superscript","subscript"]},{name:"paragraphGroup",items:["orderedList","unorderedList","indent","outdent","alignment"]},{name:"editingGroup",items:["findAndReplace"]}]},{name:"insertTab",groups:[{name:"tableGroup",items:["table"]},{name:"imageGroup",items:["image"]},{name:"videoGroup",items:["video"]},{name:"linkGroup",items:["createLink","removeLink"]}]},{name:"viewTab",groups:[{name:"viewsGroup",items:["fullScreen","sourceCode","splitMode"]}]},{name:"layoutTab",hidden:!0,groups:[{name:"deleteGroup",items:["delete"]},{name:"tableGroup",items:["table","tableHeader","tableRows","tableColumns","tableVAlign","tableStyle",""]},{name:"imageGroup",items:["image","caption"]},{name:"videoGroup",items:["video","caption"]}]}],type:"array"},toolbarViewMode:{allowedValues:["toggle","multiRow","scroll"],value:"toggle",type:"string"},toolbarSticky:{value:!1,type:"boolean"},spellCheck:{value:!0,type:"boolean"},value:{value:"",type:"string",validator:"_sanitize",reflectToAttribute:!1},validateFile:{value:null,type:"function?",reflectToAttribute:!1},uploadUrl:{value:"",type:"string",reflectToAttribute:!1},removeUrl:{value:"",type:"string",reflectToAttribute:!1},onImageRemove:{value:null,type:"function?"},autoUpload:{value:!0,type:"boolean"},windowCustomizationFunction:{value:null,reflectToAttribute:!1,type:"function?"}}}static get listeners(){return{"document.down":"_documentDownHandler","document.move":"_documentMoveHandler","document.up":"_documentUpHandler","document.dragstart":"_dragStartHandler","document.selectstart":"_selectStartHandler","document.selectionchange":"_selectionChangeHandler","container.dragend":"_dragEndHandler","container.drop":"_dropHandler","container.change":"_changeHandler","container.beforeinput":"_beforeInputHandler","container.input":"_afterInputHandler","contentContainer.contextmenu":"_contextMenuHandler","contentContainer.keydown":"_editableElementKeyDownHandler","contentContainer.keyup":"_updateOnInputChange","contentContainer.paste":"_updateOnInputChange","input.focus":"_editableElementFocusHandler","input.blur":"_editableElementBlurHandler","input.change":"_inputChangeEvent","editableElement.focus":"_editableElementFocusHandler","editableElement.blur":"_editableElementBlurHandler","editableElement.wheel":"_editableElementWheelHandler","editableElement.move":"_editableElementMoveHandler",touchmove:"_touchmoveHandler",resize:"_resizeHandler"}}static get requires(){return{"Smart.Button":"smart.button.js","Smart.Window":"smart.window.js","Smart.Tooltip":"smart.tooltip.js"}}static get styleUrls(){return["smart.editor.css"]}template(){return'<div id="container" role="presentation">\n <div id="toolbar" class="smart-editor-toolbar" role="presentation">\n <div id="toolbarItemsPrimary" class="smart-editor-toolbar-items-primary" role="toolbar"></div>\n <div id="toolbarToggleButton" class="smart-editor-toolbar-toggle-button" role="button"></div>\n <div id="toolbarItemsSecondary" class="smart-editor-toolbar-items-secondary" role="toolbar"></div>\n </div>\n <div id="contentContainer" class="smart-editor-content-container" role="presentation">\n <div class="smart-editor-editable" contenteditable="true" id="editableElement" aria-placeholder="[[placeholder]]"\n inner-h-t-m-l="[[innerHTML]]" spellcheck="[[spellCheck]]" role="textbox" aria-multiline="true"><content></content></div>\n <textarea name="[[name]]" id="input" class="smart-hidden" placeholder="[[placeholder]]" aria-placeholder="[[placeholder]]"\n spellcheck="[[spellCheck]]" autocapitalize="none" autocomplete="off"></textarea>\n </div>\n </div>'}propertyChangedHandler(e,t,o){const a=this;switch(e){case"contentFiltering":case"contentFiltering_attributes":case"contentFiltering_attributeFilterMode":case"contentFiltering_tags":case"contentFiltering_tagFilterMode":case"contentFiltering_styleAttributes":case"contentFiltering_styleAttributeFilterMode":a._handleContentFiltering();break;case"disabled":case"disableEditing":a.$.input.readonly=o,a.$.editableElement.setAttribute("contenteditable",!o),"disabled"===e&&a._setFocusable();break;case"disableSearchBar":a._closeSearchToolbar();break;case"enableHtmlEncode":{const e=a.$.input;e.classList.contains("smart-hidden")||(e.value=a._getInputValue());break}case"hideToolbar":o&&a._updateToolbarItems(void 0,a.$.toolbar);break;case"innerHTML":case"value":a._handleInputContent(e,o),a.$.fireEvent("change",{oldValue:a._value||t,value:a._value=a._getCurrentValue()});break;case"editMode":a._handleEditMode(o);break;case"hideInlineToolbar":{const e=a.$.inlineToolbar;e&&e.visible&&e.classList.contains("smart-editor-inline-toolbar")&&e.close();break}case"toolbarViewMode":a._toggleToolbar("toggle"===o);break;case"toolbarMode":case"toolbarRibbonConfig":a._handleToolbarMode();break;case"locale":delete a._toolbarItemsObj,delete a._inlineToolbarItemsObj,a._refreshToolbarItems(a._getToolbarItems()),a._closeToolbar(),a._closeWindow();break;case"iframeSettings":a._handleInputElement();break;case"maxCharCount":a._handleMaxCharCount(),a._setCharCount();break;case"name":o&&"markdown"!==a.editMode&&(a.$.input.value=a._getInputValue(a.$.editableElement.innerHTML.trim()));break;case"placeholder":a._handlePlaceholder();break;case"pasteFormat":a._closeWindow();break;case"readonly":a.$.input.readonly=o,a.$.editableElement.setAttribute("contenteditable","markdown"!==a.editMode&&!o),a._closePopups(),a._setResizeFrame(),a._closeWindow();break;case"showCharCount":a._setCharCount();break;case"rightToLeft":case"animation":case"theme":a._updateIframeBody();break;case"toolbarItems":a._handleToolbarItems();break;default:super.propertyChangedHandler(e,t,o)}}_handleToolbarItems(){const e=this,t=e.$.toolbarItemsPrimary,o=e.$.toolbarItemsSecondary;if(t.innerHTML=o.innerHTML="",delete e._toolbarItemsObj,delete e._inlineToolbarItemsObj,e._refreshToolbarItems(e._getToolbarItems()),"toggle"===e.toolbarViewMode){const a=e.$.toolbarToggleButton;t.scrollHeight!==t.offsetHeight||o.children.length?a.classList.remove("smart-visibility-hidden"):a.classList.add("smart-visibility-hidden")}}render(){const e=this,t=()=>0===e.offsetWidth||0===e.offsetHeight,o=()=>{e._isMobile=Smart.Utilities.Core.isMobile,e._isFireFox=Smart.Utilities.Core.Browser.Firefox,e._isSafari=Smart.Utilities.Core.Browser.Safari,e._isMacOS=(window.navigator.platform||"").indexOf("Mac")>-1,e._handleMaxCharCount(),e._handleInputContent(),e._setToolbarVisibility(),e._handleToolbarMode(),e._handleInputElement(),e._handleEditMode(),e._predefPropertyGetter(),e._setCharCount(),e._setFocusable(),e._setAriaSettings(),e.autoExpand&&e.expandToolbar(),e.isInitialized=!0,e.checkLicense()};if(t())return requestAnimationFrame((()=>{e.isInitialized||t()?e._createInterval=setInterval((()=>{e.isInitialized||t()||(o(),clearInterval(e._createInterval))}),100):o()})),void super.render();o(),super.render()}detached(){const e=this;super.detached(),delete e._dragDetails,delete e._resizeFrameObj,delete e._toolbarItemClick,e._endInlineToolbarClick(),e._closeWindow(),e._closeToolbarItemDropDown(e.$.inputPopup),e._closeToolbarItemDropDown(e.$.colorInputPopup),e._closeContextMenu(),e._closeToolbar(),e._handleTableSelection()}focus(){const e=this,t="markdown"===e.editMode?e.$.input:e.$.editableElement;t&&t.focus()}blur(){const e=this,t="markdown"===e.editMode?e.$.input:e.$.editableElement;t&&t.blur()}clearState(){const e=this;e.id?window.localStorage.removeItem("smartEditor"+e.id):e.warn(e.localize("noId"))}collapseToolbar(){this._toggleToolbar(!0)}disableToolbarItem(e){this._setToolbarItemAttr(e,"disabled",!0)}enableToolbarItem(e){this._setToolbarItemAttr(e,"disabled",!1)}expandToolbar(){this._toggleToolbar()}executeCommand(e,t){return this.$.editableElement.getRootNode().execCommand(e,!1,t)}exportData(e,t){this._handleDataExport(e,t)}importData(e,t){"string"==typeof e&&(e={url:e}),t||(t={}),this._ajax(e,t)}fullScreenMode(e){const t=this;t.$.fireEvent("actionStart",{name:"fullScreenMode"}).defaultPrevented||(t._handleFullScreenMode(t._toggleItem("fullscreen",e)),t.$.fireEvent("actionEnd",{name:"fullScreenMode"}))}getCharCount(){const e=this;if("html"===e.editMode){const t=e.$.editableElement,o=t.textContent.length,a=t.innerText.length;return a&&o?a:0}return e.$.input.value.length}getSelectionRange(){return this._selectionRange}clearContent(){const e=this;e._setResizeFrame(),e.$.editableElement.innerHTML=e.$.input.value=""}getHTML(){const e=this;if("markdown"===e.editMode){const t=e.$.input;return window.marked?window.marked(t.value):t.value}return e.$.editableElement.innerHTML}getText(){const e=this;return"markdown"===e.editMode?e.$.input.value:e.$.editableElement.textContent}loadState(e){const t=this;t.id?(e||(e=window.localStorage.getItem("smartEditor"+t.id)),"string"==typeof e&&(t.set("value",e),t.$.editableElement.innerHTML=t.$.input.value=e)):t.warn(t.localize("noId"))}showMessage(e,t){const o=this;if(!e||!o.isRendered)return;if(!Smart.Toast)return void o.error(o.localize("missingReference",{elementType:o.nodeName.toLowerCase(),methodName:"showMessage",files:"smart.toast.js"}));o._setToast();const a=o.$.toast;if(a){let n;if("object"==typeof t)for(let e in t)"iconType"===e?n=t[e]:a[e]=t[e];if(!o.$.container.contains(a)){const e=o.$toast;o._toastVisibilityHandler||(o._toastVisibilityHandler=e=>{const t=e.type;"close"===e.type&&e.detail.instance===o._requiredMessage&&delete o._requiredMessage,e.stopPropagation(),o.$.fireEvent("message"+t.slice(0,1).toUpperCase()+t.slice(1),e.detail)},e.listen("open",o._toastVisibilityHandler),e.listen("close",o._toastVisibilityHandler)),o.$.container.appendChild(a)}return a.open(e+"",n)}}hideMessage(e){const t=this.$.toast;t&&(void 0===e?t.closeAll():t.closeItem(e))}hideLastMessage(){const e=this.$.toast;e&&e.closeLast()}selectAll(){this._selectAll()}selectRange(e,t){const o=this,a=o.$.editableElement.getRootNode();if(!a)return;e=parseInt(e),t=parseInt(t),e=Math.min(e,t),t=Math.max(e,t);const n=o.$.input,i=o.$.editableElement,r="markdown"===o.editMode||o.$.editableElement.classList.contains("smart-hidden")?n:i,l=o.$.iframe,[s,d]=l?[l.contentWindow,l.contentDocument]:[window,document],c=s.getSelection();let m=a.activeElement;if((!m||m!==n&&m!==i||m.classList.contains("smart-hidden"))&&(r.focus(),m=r),c.removeAllRanges(),delete o._selectionRange,!isNaN(e)&&!isNaN(t)&&e!==t){if(m===n)n.setSelectionRange(e,t),o._selectionRange={selectionStart:e,selectionEnd:t};else{const a=o._getNodes(i,e,t).nodes;for(let e=0,t=a.length;e<t;e+=1){const{node:t,index:n,startIndex:i}=a[e],r=d.createRange();t.nodeType===Node.TEXT_NODE?(r.setStart(t,Math.max(0,i)),r.setEnd(t,Math.min(n,t.nodeValue.length))):r.selectNodeContents(t),c.addRange(r),o._selectionRange=r}}o._updateToolbarItems()}}saveState(){const e=this;e.id?window.localStorage.setItem("smartEditor"+e.id,e.$.editableElement.innerHTML):e.warn(e.localize("noId"))}splitMode(e){const t=this;t.$.fireEvent("actionStart",{name:"splitMode"}).defaultPrevented||(t._handleSplitMode(t._toggleItem("splitmode",e)),t.$.fireEvent("actionEnd",{name:"splitMode"}))}previewMode(e){const t=this;t.$.contentContainer.hasAttribute("split-mode")||t.$.fireEvent("actionStart",{name:"sourcecode"}).defaultPrevented||(t._handleSourceCodeMode(t._toggleItem("sourcecode",e)),t.$.fireEvent("actionEnd",{name:"sourcecode"}))}print(){this._handlePrint()}updateToolbarItem(e,t){const o=this,a=o.toolbarItems;let n;if("string"==typeof e?n=a.find((t=>t.name===e)):"number"==typeof e&&(n=a[e]),n){o._closePopups(),o._closeWindow(),delete o._toolbarItemsObj[n.name],delete o._inlineToolbarItemsObj[n.name];for(let e in t)n[e]=t[e];return o._refreshToolbarItems(o._getToolbarItems()),!0}}_toggleItem(e,t){const o=this._toolbarItemsObj;if(!o)return;const a=o[e],n=this.$.toolbar.querySelector(`.smart-editor-toolbar-item[item-name="${e}"]`);return a&&n?((t=a.value=void 0===t?!a.value:!!t)?(n.setAttribute("checked",""),n.setAttribute("aria-pressed",!0)):(n.removeAttribute("checked"),n.setAttribute("aria-pressed",!1)),n):void 0}_ajax(e,t={}){const o=this;let a="GET",n=e.url,i=null,r=!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&&(i=JSON.stringify(e.data));t&&!1===t.async&&(r=!1),void 0!==window.fetch&&r?o._ajaxFetch(e,t,a,n,i):o._ajaxXMLHttpRequest(e,t,a,n,i,r)}_ajaxFetch(e,t,o,a,n){const i=this,r={method:o};let l,s,d;t&&t.contentType&&(r.headers=new Headers({"Content-Type":t.contentType})),null!==n&&(r.body=n),e.timeout&&(s=setTimeout((function(){d=!0}),e.timeout)),t.beforeSend&&!1===t.beforeSend(r,t)||fetch(a,r).then((function(e){if(d)throw l=408,i.error(i.localize("timeout",{elementType:i.nodeName.toLowerCase()}));if(s&&clearTimeout(s),l=e.status,!e.ok)throw i.error(i.localize("importError",{elementType:i.nodeName.toLowerCase(),status:e.statusText}));return e.text()})).then((e=>i._ajaxComplete(t,e,l))).catch((function(e){t&&t.loadError&&t.loadError(l,e)}))}_ajaxXMLHttpRequest(e,t,o,a,n,i){const r=new XMLHttpRequest,l=this;r.open(o,a,i),r.ontimeout=function(){t&&t.loadError&&t.loadError(408,"timeout")},r.onload=function(){if(4===r.readyState){const o=r.status;let a=r.response;o>=200&&o<=299?("json"===e.dataType&&(a=JSON.parse(a)),l._ajaxComplete(t,a,o)):t&&t.loadError&&t.loadError(o,a)}},r.onerror=function(){t&&t.loadError&&t.loadError(r.status,r.response)},t&&t.contentType&&r.setRequestHeader("Content-Type",t.contentType),i&&e.timeout&&(r.timeout=e.timeout),t.beforeSend&&!1===t.beforeSend(r,t)||r.send(n)}_ajaxComplete(e,t){if(e){if(e.beforeLoadComplete){const o=e.beforeLoadComplete(t);o&&(t=o)}this._handleInputContent("value",t)}}_afterInputHandler(e){const t=this,o=t._beforeInputObj,a=t.$.editableElement,n=!a.innerHTML;let i,r;if(o&&o.type&&(i=o.type,r=o.rangeDetails),delete t._beforeInputObj,n&&(t._setResizeFrame(),t._closeToolbar()),"insertParagraph"===i||n){let e=t._getSelectionRange().startContainer;if(e.nodeType===Node.TEXT_NODE&&(e=e.parentElement),e&&e.classList&&(e.closest(".smart-editor-image-caption")||e.closest(".smart-editor-editable table")))return;const o=t.$.iframe,[i,r]=o?[o.contentWindow,o.contentDocument]:[window,document];("div"===i.getSelection().anchorNode.nodeName.toLowerCase()||e===a&&n)&&r.execCommand("insertHTML",!1,"<p><br></p>")}else if(i&&r&&i.indexOf("delete")>-1){const e=t._resizeFrameObj;e&&e.target&&!a.contains(e.target)&&t._setResizeFrame()}a.textContent.length&&a.innerText.length?a.removeAttribute("show-placeholder"):a.setAttribute("show-placeholder",""),t.name&&e.target===t.$.editableElement&&"markdown"!==t.editMode&&(t.$.input.value=t._getInputValue(t.$.editableElement.innerHTML.trim())),t._setCharCount()}_beforeInputHandler(e){const t=this,o=t.$.iframe,a=t.$.contentContainer,n=t.$.editableElement,i=(o?o.contentWindow:window).getSelection().getRangeAt(0),r=e.inputType,l=i.startContainer;let s;if(r&&(s=r.indexOf("delete")>-1,t._beforeInputObj={type:r,rangeDetails:{startOffset:i.startOffset,endOffset:i.endOffset,startContainer:i.startContainer,endContainer:i.endContainer}}),s&&n.contains(l))if(l===i.endContainer&&i.startOffset===i.endOffset){const e=t._resizeFrameObj;let o=l;if(e&&e.target&&e.target.contains(l))return;if(o.nodeType!==Node.TEXT_NODE&&o.innerHTML.length){if(o===n)return;o.remove()}else{let e=o.parentElement,t=o.previousElementSibling;for(;!t&&e;)t=e.previousElementSibling,e=e.parentElement;n!==t&&n.contains(t)&&!t.innerHTML.length&&t.remove()}}else i.deleteContents(),e.preventDefault();if(!a.classList.contains("char-count-maxed")||s){if("insertParagraph"===r){const e=t._getSelectionRange().startContainer;e.nodeType===Node.TEXT_NODE&&e.parentElement===n&&n.getRootNode().execCommand("formatBlock",!1,"p")}}else e.preventDefault()}_changeHandler(e){const t=this,o=e.target,a=e.detail,n=o.closest(".smart-editor-toolbar-item");if(e.stopPropagation(),t._toolbarItemsObj||t._inlineToolbarItemsObj)return n&&o===t.$.inputPopup||o===t.$.colorInputPopup?(t._ignoreSelectionChange=!0,t._updateToolbarItem(n,a),void delete t._ignoreSelectionChange):void 0}_contextMenuHandler(e){const t=this,o=t.contextMenu;"browser"!==o?(e.preventDefault(),"none"!==o?t._openContextMenu(e):t._closeContextMenu()):t._closeContextMenu()}_closeContextMenu(){const e=this.$.inlineToolbar,t=this.$.fireEvent("dropDownToolbarClosing",{target:e}).defaultPrevented;e&&e.visible&&e.classList.contains("smart-editor-context-menu")&&!t&&e.close()}_openContextMenu(e){const t=this,o=e.target;let a=t.$.inlineToolbar;if(a||(a=t._createToolbar()),t.$.fireEvent("contextMenuOpening",{target:a}).defaultPrevented)return;t._setupToolbar(o,"context"),a.parentElement||t.getShadowRootOrBody().appendChild(a),a.clear(),t._setContextMenuContent(o);const n=t.getBoundingClientRect();a.style.left=Math.min(e.pageX+1,n.right+window.pageXOffset-a.offsetWidth)+"px",a.style.top=Math.min(e.pageY+1,n.bottom+window.pageYOffset-a.offsetHeight)+"px",a.open()}_setContextMenuContent(e){const t=this;if(!e)return;let o=t._contextList,a=t._getContextMenuTargetType(e),n=t._getContextMenuDataSource(e,a);o||(t._contextList=o=document.createElement("div"),o.classList.add("smart-editor-context-menu-item-container"));const i=document.createDocumentFragment(),r=n.length;let l=o.children;for(;l.length>r;)l[0].remove();l=Array.from(l);for(let o=0;o<r;o++){const r=n[o];let s,d,c=l[o];if("object"==typeof r?(s=r.label,d=r.value):s=d=r+"",c||(c=document.createElement("div"),c.classList.add("smart-editor-context-menu-item"),c.setAttribute("role","option")),c.removeAttribute("disabled"),"deleteLink"!==r||"image"!==a||e.closest(".smart-editor-editable a")){if("cut"===r||"copy"===r){const e=t._getSelectionRange();(void 0!==e.selectionStart?e.selectionStart:e.startOffset)===(void 0!==e.selectionEnd?e.selectionEnd:e.endOffset)&&c.setAttribute("disabled","")}}else c.setAttribute("disabled","");c.parentElement||i.appendChild(c),c.innerHTML=t.localize(s)||s,c.setAttribute("value",d)}o.appendChild(i),t.$.inlineToolbar.appendChild(o)}_getContextMenuTargetType(e){let t;return t=e.closest(".smart-editor-editable table")?"table":e.closest(".smart-editor-editable img")?"image":e.closest(".smart-editor-video-container")?"video":e.closest(".smart-editor-editable a")?"link":"text",t}_getContextMenuDataSource(e,t){if(!t)return[];const o=this.contextMenuDataSource;let a;switch(t){case"table":a=["tableProperties","insertRowAfter","insertRowBefore","insertColumnLeft","insertColumnRight","deleteRow","deleteColumn","deleteTable","selectAll"];break;case"image":a=["imageProperties","copyImage","cutImage","createLink","deleteLink","deleteImage","caption"];break;case"video":a=["videoProperties","copyVideo","cutVideo","deleteVideo","caption"];break;case"link":a=["linkProperties","deleteLink","selectAll"];break;default:a=["copy","cut","paste","selectAll"]}return o&&(a="function"==typeof o?o(e,t,a):Array.isArray(o)?o:[]),a}_updateToolbarItem(e,t){const o=this,a=o.editMode,n=e.getAttribute("item-name"),i=o.$.toolbarItemsPrimary,r=o.$.toolbarItemsSecondary,l=o.$.inlineToolbar,s="markdown"===a?o.$.input:o.$.editableElement,d=(e,a,n)=>{a&&(a.label=t["alignment"===a.name?"value":"label"],a.value=t.value,e&&o._setItemValue(e,a),n&&o._updateToolbarTarget(a))};if(l&&l.contains(e)?(d(e,o._inlineToolbarItemsObj[n],!0),o._toolbarItemsObj&&o._toolbarItemsObj[n]&&d(o.$.toolbar.querySelector(`.smart-editor-toolbar-item[item-name=${n}]`),o._toolbarItemsObj[n])):(i.contains(e)||r.contains(e))&&o._toolbarItemsObj&&(d(e,o._toolbarItemsObj[n],!0),l&&l.visible&&o._inlineToolbarItemsObj&&d(l.querySelector(`.smart-editor-toolbar-item[item-name=${n}]`),o._inlineToolbarItemsObj[n])),s.getRootNode().activeElement!==s){const e=o._selectionRange,t=s.scrollTop;e&&("markdown"===a?o._setSelectionRange(s,e.selectionStart,e.selectionEnd):o._setSelectionRange(e.startContainer,e.startOffset,e.endOffset)),s.focus({preventScroll:!0}),o._isSafari&&t&&(s.scrollTop=t)}}_updateToolbarTarget(e){const t=this,o=t._resizeFrameObj;if(!e)return;const a=t.$.inlineToolbar;let n;o&&o.target?n=o.target:a&&a.visible&&(n=a.selector,n=n.closest?n.closest(".smart-editor-editable img")||n.closest(".smart-editor-editable table"):void 0);const i=n?n.nodeName.toLowerCase():"";if(n&&"img"===i)return"alignment"===e.name&&(n.closest(".smart-editor-image-container")||n).setAttribute("alignment",e.value),t._setResizeFrame(n),void(a&&a.visible&&a.reposition());if(n&&"table"===i)return void t._handleTableToolbarAction(e,n);const r=t._getSelectionRange();if(r&&(r.startContainer||void 0!==r.selectionStart)){const o=e.name;if(t.$.fireEvent("actionStart",{name:o}).defaultPrevented)return;switch(o){case"backgroundcolor":t._handleBackgroundColor(e);break;case"fontcolor":t._handleFontColor(e);break;case"alignment":t._handleTextAlignment(e);break;case"fontsize":t._handleFontSize(e);break;case"fontname":t._handleFontName(e);break;case"formats":t._handleFormats(e);break;case"paste":t._handlePaste(e);break;default:{const t=r.startContainer.closest?r.startContainer:r.startContainer.parentElement;return void(t&&t.closest&&t.setAttribute(e.name,e.value))}}o&&t.$.fireEvent("actionEnd",{name:o})}}_setSelectionRange(e,t,o){const a=this,n=a.$.iframe,i=a.editMode;let r;if(a.disabled)return;if("markdown"===i||a.$.editableElement.classList.contains("smart-hidden")){r=a.$.input,a._selectionRange={selectionStart:void 0!==t?t:r.selectionStart,selectionEnd:void 0!==o?o:r.selectionEnd};const e=a._selectionRange;return void(a._selectionChangeFired||r.setSelectionRange(e.selectionStart,e.selectionEnd))}const l=(n?n.contentWindow:window).getSelection();let s;if(r=a.$.editableElement,e){if(s=document.createRange(),"number"==typeof t&&"number"==typeof o)try{s.setStart(e,parseInt(t)),s.setEnd(e,parseInt(o))}catch(t){s.selectNodeContents(e)}else"img"===e.nodeName.toLowerCase()||e.classList.contains("smart-editor-video-container")?(s.setStartBefore(e),s.setEndAfter(e),s.selectNode(e)):s.selectNodeContents(e);l.removeAllRanges(),l.addRange(s)}else l.rangeCount&&(s=l.getRangeAt(0));try{s&&s.startContainer&&r.contains(s.startContainer)&&(a._selectionRange=s)}catch(e){}a._selectionRange||(s=document.createRange(),s.selectNodeContents(r),s.collapse(!0),a._selectionRange=s)}_getSelectionRange(){const e=this,t=e.editMode;let o=e._selectionRange;return o&&("markdown"===t&&void 0===o.selectionStart||"html"===t&&void 0===o.startContainer)&&(delete e._selectionRange,o=void 0),o||e._setSelectionRange(),e._selectionRange}_setCharCount(){const e=this,t=e.$.contentContainer;if(!e.showCharCount)return void t.removeAttribute("char-count");const o=e.maxCharCount;let a,n;if("html"===e.editMode){const t=e.$.editableElement,o=t.textContent.length,a=t.innerText.length;n=a&&o?a:0}else n=e.$.input.value.length;if(a=e.charCountFormatFunction?e.charCountFormatFunction(n,o)+"":o?`${n} / ${o}`:n+"",t.setAttribute("char-count",a),null===o)return void t.classList.remove("char-count-low","char-count-medium");const i=parseFloat((n/o).toFixed(2));t.classList[i>=.7&&i<=.9?"add":"remove"]("char-count-warning"),t.classList[i>=.9?"add":"remove"]("char-count-error"),t.classList[n>=o?"add":"remove"]("char-count-maxed")}_documentDownHandler(e){const t=this,o=t.$.iframe,a=t.$.inlineToolbar,n=t.$.window,i=e.originalEvent||e,r=t.shadowRoot||t.isInShadowDOM?i.composedPath()[0]:i.target;if(a&&a.contains(r)){const e=r.closest(".smart-editor-toolbar-item");return t._handleToolbarItemDown(e,r),void i.preventDefault()}if(t.$.container.contains(r)||o&&o.contentDocument.body.contains(r))return void t._handleDownInside(i,r);const l=r.closest(".smart-input-drop-down-menu");let s;if(l&&(s=l.ownerElement),n&&n.opened&&!n.contains(s||r)&&n.close(),t._handleTableSelection(),s&&(t.$.toolbarItemsPrimary.contains(s)||t.$.toolbarItemsSecondary.contains(s)||a&&a.contains(s)))return t._toolbarItemClick={},void i.preventDefault();t._setResizeFrame(),t._closePopups()}_handleDownInside(e,t){const o=this,a=e.originalEvent||e,n=t.closest(".smart-editor-toolbar-item"),i=o.$.inlineToolbar,r=t.classList.contains("smart-editor-video-container")?t:null,l=o.$.window;let s=o._editorVideoItemClick;if(s&&(r&&s.dragElement&&s.dragElement.remove(),delete o._editorVideoItemClick,s=void 0),t===o.$.toolbarToggleButton)o._toolbarItemClick={},e.preventDefault();else{if(n)return o._handleToolbarItemDown(n,t),void e.preventDefault();if(t.closest(".smart-editor-toolbar-tab"))e.preventDefault();else if(r)s||(s=o._editorVideoItemClick={target:t,originalSelectionRange:o._selectionRange}),e.preventDefault(),!1!==r.getAttribute("draggable")&&r.querySelector("video")?(s.dragElement=o._createWhiteSpaceChar(t,r),o._setSelectionRange(t)):s.dragElement&&(s.dragElement.remove(),delete s.dragElement);else if(t.closest(".smart-editor-search-bar"))o._searchBarDown={target:t},t.closest(".smart-search-input")||e.preventDefault();else{const e={x:a.pageX+window.pageXOffset,y:a.pageY+window.pageYOffset};l&&l.opened&&l.close();const n=o._getInlineToolbarTarget(t,e);if(n){const t=o.$.contentContainer;t.contains(t.getRootNode().activeElement)||o._focusEditableElement(),o._handleInlineToolbarItemDown(n,e)}else!i||i.contains(t)&&i.classList.contains("smart-editor-drop-down-toolbar")||(o._closeToolbar(),o._handleTableSelection())}}o._closeToolbarItemDropDown(o.$.inputPopup),o._closeToolbarItemDropDown(o.$.colorInputPopup)}_handleToolbarItemDown(e,t){const o=this,a=o.$.inlineToolbar,n=o.$.window;if(!e)return;const i=e.getAttribute("item-type"),r=e.getAttribute("item-name");switch(!n||!n.opened||n._target&&n._target.item.name===r||n.close(),o._toolbarItemClick={toolbarItem:e},o._resizeFrameObj&&o._resizeFrameObj.target?o._toolbarItemClick.target=o._resizeFrameObj.target:o._setResizeFrame(),o._setSelectionRange(),i){case"button":["hyperlink","createlink","image","video"].includes(r)?o._toolbarItemClick.callback=o._toggleWindow:"table"===r&&(o._toolbarItemClick.callback=a&&a.contains(e)?o._toggleWindow:o._toggleDropDownToolbar);break;case"toggle":e.toggleAttribute("checked"),e.hasAttribute("checked")?e.setAttribute("aria-pressed",!0):e.setAttribute("aria-pressed",!1),o._closeToolbarItemDropDown(o.$.inputPopup),o._closeToolbarItemDropDown(o.$.colorInputPopup);break;case"drop-down":o._toolbarItemClick.callback=o._toggleItemDropDown;break;case"color-input":t.closest(".smart-editor-item-drop-down-button")&&(o._toolbarItemClick.callback=o._toggleItemDropDown)}}_handleInlineToolbarItemDown(e,t){const o=this,a=e.closest(".smart-editor-editable table"),n=o.$.editableElement;if(o._inlineToolbarClickObj&&o._inlineToolbarClickObj.target&&(o._inlineToolbarClickObj.target.removeAttribute("drag-id"),o._inlineToolbarClickObj.dragElement&&o._inlineToolbarClickObj.dragElement.removeAttribute("drag-id")),o._inlineToolbarClickObj={},e)if("img"===e.nodeName.toLowerCase())e.setAttribute("drag-id",Math.random().toString(36).substr(2,5));else if(e.classList.contains("smart-editor-video-container")){const t=e.querySelector("video, iframe");t&&(t.setAttribute("drag-id",Math.random().toString(36).substr(2,5)),o._inlineToolbarClickObj.dragElement=t)}if(a&&n.hasAttribute("table-cell-resize")){const i=n.getAttribute("table-cell-resize");o._inlineToolbarClickObj.resizeDetails={x:t.x,y:t.y,position:i,target:"vertical"===i?e.closest("tr"):e,table:a},e=void 0}o._handleTableSelection(e),o._inlineToolbarClickObj.target=e,o._inlineToolbarClickObj.dragTarget=e}_getInlineToolbarTarget(e,t){const o=this;let a,n=e.closest(".smart-editor-editable img")||e.closest(".smart-editor-editable a")||e.closest(".smart-editor-video-container");return n||(a=e.closest(".smart-editor-editable table"),a&&(n=e.closest(".smart-editor-editable td")||e.closest(".smart-editor-editable th"))),e.closest(".smart-editor-resize-frame")&&o._resizeFrameObj?(o._resizeFrameObj.resizeDetails={x:t.x,y:t.y,position:e.getAttribute("position")},n=o._resizeFrameObj.target):n&&(n&&"img"===n.nodeName.toLowerCase()||a||n.classList.contains("smart-editor-video-container"))||o._setResizeFrame(),n}_documentMoveHandler(e){const t=this,o=t._resizeFrameObj,a=t._inlineToolbarClickObj,n=e.originalEvent||e;o&&o.resizeDetails?t._handleFrameResize(n):a&&a.resizeDetails&&t._handleTableCellResize(n)}_touchmoveHandler(e){const t=this,o=t._resizeFrameObj;t._isMobile&&o&&o.target&&(o.resizeDetails?(e.preventDefault(),e.stopPropagation()):(t._closeToolbar(),t._setResizeFrame()))}_dragStartHandler(e){const t=this,o=t._resizeFrameObj,a=t._inlineToolbarClickObj;if(o&&o.resizeDetails||a&&a.resizeDetails)return e.preventDefault(),void delete t._dragDetails;if(!t.$.contentContainer.contains(e.target))return;if(!a||!a.target)return void e.preventDefault();const n=t._inlineToolbarClickObj.target;if(n&&(["img","table"].indexOf(n.nodeName.toLowerCase())>-1||n.classList.contains("smart-editor-video-container"))){if("false"===n.getAttribute("draggable"))return void e.preventDefault();const o=e.target,a=o.parentElement,i=o.closest(".smart-editor-image-container");t._closeToolbar(),t._setResizeFrame(),t._dragDetails={target:o,scrollTop:t.$.editableElement.scrollTop,container:i,anchor:a&&"a"===a.nodeName.toLowerCase()?a:void 0,caption:i?i.querySelector(".smart-editor-image-caption"):void 0}}}_dropHandler(){const e=this;e._isFireFox&&e._dragEndHandler()}_dragEndHandler(){const e=this,t=e.$.inlineToolbar,o=e._dragDetails;if(o){const a=o.target,n=o.container,i=e.$.editableElement,r=i.querySelector(`[drag-id="${a.getAttribute("drag-id")}"]`);if(r){const a=o.anchor;if(r.removeAttribute("drag-id"),n&&!n.contains(r)&&r.parentElement){const e=o.caption;let t=r.parentElement;if(t.classList.contains("smart-editor-video-container")){const e=t;t=t.parentElement,e.remove(),t.appendChild(r)}n.remove(),n.innerHTML="",t.insertBefore(n,r),n.appendChild(r),e&&n.appendChild(e)}a&&r.parentElement!==a&&(a.innerHTML="",r.parentElement.insertBefore(a,r),a.appendChild(r)),void 0!==o.scrollTop&&(i.scrollTop=o.scrollTop),requestAnimationFrame((()=>e._setResizeFrame(r)));const l=e._resizeFrameObj;if(e._editorVideoItemClick){const t=i.querySelectorAll('.smart-editor-video-white-space, div[pseudo="-webkit-media-controls"]');for(let e=0,o=t.length;e<o;e+=1)t[e].remove();delete e._editorVideoItemClick}(!t||t&&!t.visible)&&l&&l.target&&e._openInlineToolbar(l.target)}return void delete e._dragDetails}e._setSelectionRange();const a=e._getSelectionRange();a&&a.startOffset!==a.endOffset&&(e._handleInlineToolbar(a.startContainer),e._focusEditableElement())}_documentUpHandler(e){const t=this,o=t._resizeFrameObj,a=t.$.inlineToolbar,n=e.originalEvent||e,i=t.shadowRoot||t.isInShadowDOM?n.composedPath()[0]:n.target;if(o&&(o.resizeDetails&&o.target&&(o.target.removeAttribute("dragged"),t.$.fireEvent("resizeEnd",{target:o.target})),delete o.resizeDetails),t._dragDetails)return t._endInlineToolbarClick(),void delete t._toolbarItemClick;const r=t.$.iframe;if(t.$.container.contains(i)||a&&a.contains(i)||r&&r.contentDocument.body.contains(i)){const e=i.closest(".smart-editor-toolbar-item");e?t._handleToolbarUp(e):t._handleContentUp(n,i)}t._endInlineToolbarClick(),delete t._searchBarDown,delete t._dragDetails,delete t._toolbarItemClick}_handleToolbarUp(e){const t=this,o=t._toolbarItemClick,a=e.getAttribute("item-type");if(o&&o.toolbarItem===e){const e=o.toolbarItem;"custom"!==a&&(t._handleToolbarItemClick(event,e),t._focusEditableElement())}}_handleContentUp(e,t){const o=this,a=o._inlineToolbarClickObj,n=o.$.toolbarToggleButton,i=o._editorVideoItemClick,r=void 0!==e.button&&2===e.button;if(r||t!==n&&!n.contains(t))if(t.classList.contains("smart-editor-toolbar-tab"))o.$.toolbar.hasAttribute("expanded")?t.hasAttribute("checked")||o._selectToolbarTab(t):(o._selectToolbarTab(t),o._toggleSecondaryToolbar(t.hasAttribute("checked")));else if(i&&t.classList.contains("smart-editor-video-container")&&t===i.target)o._setResizeFrame(t),o._focusEditableElement();else if(a){const e=a.target;e&&(e===t||e.contains(t))&&(r?o._setResizeFrame(e):o._handleInlineToolbar(e),o._focusEditableElement())}else if(!r&&(o.$.editableElement.contains(t)||"markdown"===o.editMode&&t===o.$.input)){const e=o.$.iframe,t=e?e.contentWindow:window;requestAnimationFrame((()=>{e&&o._setSelectionRange();const a=o._getSelectionRange();if(a instanceof t.Range){let e=a.startContainer;a.startOffset!==a.endOffset&&(o._handleInlineToolbar(e),o._focusEditableElement())}}))}else!r&&t.closest(".smart-editor-search-bar")&&o._handleSearchButtonClick(t.closest(".smart-search-button"));else o._toggleToolbar(o.$.toolbar.hasAttribute("expanded"))}_toggleSecondaryToolbar(e){const t=this,o=t.$.toolbar,a=t.$.toolbarItemsPrimary,n=t.$.toolbarItemsSecondary,i=()=>{o.hasAttribute("expanded")?(n.classList.remove("smart-drop-down"),o.contains(n)||o.appendChild(n),n.style.top=""):(n.classList.add("smart-drop-down"),o.contains(n)&&o.parentElement.insertBefore(n,o.nextElementSibling),n.style.top=a.offsetTop+a.offsetHeight+"px")};if(!e&&(n.classList.add("smart-visibility-hidden"),t.hasAnimation))return n.addEventListener("transitionend",i,{once:!0}),void n.addEventListener("transitioncancel",i,{once:!0});i(),e&&(t._setToolbarGroupHeight(),n.classList.remove("smart-visibility-hidden"))}_setToolbarGroupHeight(){const e=this.$.toolbarItemsSecondary,t=e.children;if(e.style.height="","menu"===this.toolbarMode)return;let o;for(let e=0,a=t.length;e<a;e+=1){const a=t[e].offsetHeight;(void 0===o||o<a)&&(o=a)}void 0!==o&&(e.style.height=o+"px")}_endInlineToolbarClick(){const e=this,t=e._inlineToolbarClickObj;if(t){const o=t.resizeDetails;if(!e._dragDetails&&t.target&&(t.target.removeAttribute("drag-id"),t.dragElement&&t.dragElement.removeAttribute("drag-id")),o&&o.target){if("horizontal"===o.position){const e=o.cells,t=o.table.offsetWidth;e&&e.forEach((e=>{e.style.width&&(e.style.width=100*parseFloat((e.offsetWidth/t).toFixed(2))+"%")}))}e.$.editableElement.removeAttribute("table-cell-resize"),o.target.removeAttribute("resizing"),o.isInlineToolbarOpened&&e._handleInlineToolbar(o.target)}delete e._inlineToolbarClickObj}}_updateToolbarItems(e,t){const o=this;if(o._dragDetails||o.readonly||o.disabled)return;if("markdown"===o.editMode)return void o._updateToolbarItemsMarkdown(e);const a=o._getSelectionRange(),n=o.$.inlineToolbar;let i,r;if(!a)return;if(t||(t=o.$.toolbar),n&&t!==n&&!o.hideInlineToolbar&&n.visible&&(o._updateToolbarItems(e,n),i=!0),t!==o.$.toolbar||o.hideToolbar?i||o.hideInlineToolbar||(r=o._inlineToolbarItemsObj):r=o._toolbarItemsObj,!r)return;const l=o.$.editableElement;let s,d=a.startOffset>a.endOffset?a.endContainer:a.startContainer;if(d&&(d.closest||(d=d.parentElement),d&&d.closest)){e||(e=["alignment","bold","italic","strikethrough","underline","fontsize","fontname","formats","fontcolor","backgroundcolor","orderedlist","unorderedlist","subscript","superscript"]);for(let a=0,n=e.length;a<n;a+=1){const n=e[a],i=r[n];if(i){let e;if("alignment"===n)e=d.style.textAlign;else if("bold"===n)e=!!o._getNodeFromList(d,["b","strong","h1","h2","h3","h4","h5","h6"]);else if("italic"===n)e=!!o._getNodeFromList(d,["i"]);else if("underline"===n)e=!!o._getNodeFromList(d,["u"]);else if("strikethrough"===n)e=!!o._getNodeFromList(d,["strike"]);else if("fontsize"===n){const t=d.closest(".smart-editor-editable font");t&&(e=t.style.fontSize),e||(s||(s=window.getComputedStyle(d)),e=s.fontSize),e=parseInt(e),isNaN(e)&&(e="")}else if("fontname"===n){const t=d.closest(".smart-editor-editable font");t&&t.hasAttribute("face")?e=t.getAttribute("face"):(s||(s=window.getComputedStyle(d)),e=s.fontFamily.split(",")[0])}else if("formats"===n&&d!==l){const t=i.dataSource;if(e="",t){const a=t.map((e=>e.value));e=o._getNodeFromList(d,a)||""}}else if("fontcolor"===n){const t=d.closest(".smart-editor-editable font");t?e=t.color:(s||(s=window.getComputedStyle(d)),e=s.color)}else"backgroundcolor"===n?(e=o._getNodeBackgroundColor(d),e||(s||(s=window.getComputedStyle(d)),e=s.backgroundColor)):"orderedlist"===n||"unorderedlist"===n?e=!!d.closest(`.smart-editor-editable ${"orderedlist"===n?"ol":"ul"} li`):"subscript"===n?e=!!d.closest(".smart-editor-editable sub"):"superscript"===n&&(e=!!d.closest(".smart-editor-editable sup"));if(!e&&i.dataSource){const t=i.dataSource[0];t&&(e=t.value||t)}null!==e&&(i.value=e,o._setItemValue(t.querySelector(`.smart-editor-toolbar-item[item-name=${n}]`),i))}}}}_updateToolbarItemsMarkdown(e){const t=this,o=t._getSelectionRange();if(!o||void 0===o.selectionStart)return;const a=o.selectionStart;e||(e=["bold","italic","strikethrough","underline","formats","orderedlist","unorderedlist","subscript","superscript"]);for(let o=0,n=e.length;o<n;o+=1){const n=e[o],i=t._toolbarItemsObj[n];if(i){let e;if("bold"===n)e=!!t._getMarkdownItem(a,"**"),e||(e=!!t._getMarkdownItem(a,"__"));else if("italic"===n)e=!!t._getMarkdownItem(a,"*"),e||(e=!!t._getMarkdownItem(a,"_"));else if("strikethrough"===n)e=!!t._getMarkdownItem(a,"~~");else if("underline"===n)e=!!t._getMarkdownItem(a,"<ins>","</ins>");else if("formats"===n){const o=i.dataSource;if(e="",o){const n=o.map((e=>e.value));e:for(let o=0,i=n.length;o<i;o+=1)if(e=t._getMarkdownFormat(a,n[o]),e&&void 0!==e.formatName){e=e.formatName;break e}}}else"orderedlist"===n||"unorderedlist"===n?e=!!t._getMarkdownFormat(a,n):"subscript"===n?e=!!t._getMarkdownItem(a,"<sub>","</sub>"):"superscript"===n&&(e=!!t._getMarkdownItem(a,"<sup>","</sup>"));if(!e&&i.dataSource){const t=i.dataSource[0];t&&(e=t.value||t)}null!==e&&(i.value=e,t._setItemValue(t.$.toolbar.querySelector(`.smart-editor-toolbar-item[item-name=${n}]`),i))}}}_getMarkdownItem(e,t,o=t){const a=this.$.input.value,n=a.lastIndexOf(t,Math.max(0,e-1)),i=a.indexOf(o,n>-1?n+t.length:e);if(!(n<0||n>e||i<0||i<e||a.slice(n,e).indexOf("\n")>-1||a.slice(e,i).indexOf("\n")>-1))return" "!==a[n+1]&&a[n-1]!==t&&a[n+1]!==t&&" "!==a[i-1]&&a[i-1]!==t&&a[i+1]!==t?{startIndex:n,endIndex:i+o.length}:void 0}_getMarkdownFormat(e,t){const o=this.$.input.value,a=o.lastIndexOf("\n",Math.max(0,e-1))+1,n=o.slice(a,e);let i;switch(t){case"h1":i="# ";break;case"h2":i="## ";break;case"h3":i="### ";break;case"h4":i="#### ";break;case"h5":i="##### ";break;case"h6":i="###### ";break;case"code":case"pre":i="```";break;case"blockquote":i="> ";break;case"orderedlist":{const e=/^\s*([0-9]+\.{1}\s+)/gs.exec(n);return e?{formatName:t,occuranceIndex:a+e.input.indexOf(e[1])}:void 0}case"unorderedlist":{const e=/^\s*([-+*]{1}\s+)/gs.exec(n);return e?{formatName:t,occuranceIndex:a+e.input.indexOf(e[1])}:void 0}default:i=t+""}const r=n.indexOf(i);if(r>=0&&r<=3&&n.slice(r,i.length)===i)return{formatName:t,occuranceIndex:a+r,markdown:i}}_getNodeFromList(e,t){const o=this.$.editableElement;if(e&&t)for(;e&&e!==o;){const o=e.nodeName.toLocaleLowerCase();if(t.indexOf(o)>-1)return o;e=e.parentElement}}_getNodeBackgroundColor(e){const t=this.$.editableElement;for(;e&&e!==t;){const t=e.style.backgroundColor;if(t)return t;e=e.parentElement}}_editableElementBlurHandler(e){const t=this,o=t.$.editableElement,a=t.$.contentContainer;if(!t._toolbarItemClick&&!a.contains(a.getRootNode().activeElement)){const n=t._value,i=()=>{a.removeAttribute("required"),t._requiredMessage&&(t.hideMessage(t._requiredMessage),delete t._requiredMessage)},r=t._getCurrentValue();if(t.required){const e=t.$.editableElement;"markdown"===t.editMode&&!t.$.input.value||"markdown"!==t.editMode&&!e.textContent&&!e.querySelectorAll("img, table").length?(a.hasAttribute("required")||a.setAttribute("required",""),t._requiredMessage||(t._requiredMessage=t.showMessage(t.localize("requiredMessage"),{autoClose:!1,iconType:"error"}))):i()}else i();n!==r&&(t.$.fireEvent("change",{oldValue:n,value:r}),t.name&&e.target===o&&"markdown"!==t.editMode&&(t.$.input.value=t._getInputValue(o.innerHTML.trim()))),t.removeAttribute("focus"),t.removeAttribute("aria-activedescendant")}}_editableElementFocusHandler(e){const t=this,o=t.editMode,a="markdown"===o?t.$.input:t.$.editableElement;let n=t._autoSaveObj;t.setAttribute("focus",""),e.target.id&&t.setAttribute("aria-activedescendant",e.target.id),t._value=t._getCurrentValue(),t.autoSave?(n||(n=t._autoSaveObj={}),clearInterval(n.interval),n.interval=setInterval((()=>{a.getRootNode().activeElement!==a&&clearInterval(n.interval),window.localStorage.setItem("smartEditor"+t.id,"markdown"===o?a.value:a.innerHTML)}),t.autoSaveInterval)):n&&(clearInterval(n.interval),delete t._autoSaveObj)}_inputChangeEvent(e){e.stopPropagation()}_updateOnInputChange(e){const t=this,o=t.$.editableElement,a=e.target,n=t.$.input,i=a.classList.contains("smart-search-input"),r=()=>{const e=l===n?n.value:t.$.editableElement.innerHTML;void 0!==s&&e!==s&&t.$.fireEvent("changing",{value:e,oldValue:t._changingValue})};if("paste"===e.type&&o.contains(a)){const o=e.clipboardData;if(o&&o.types.length){const a=o.types.indexOf("text/html")>-1?"text/html":"text/plain",[n,i]=["\x3c!--StartFragment--\x3e","\x3c!--EndFragment--\x3e"];let r=o.getData(a);e.preventDefault();let l=(e.clipboardData||e.originalEvent.clipboardData).items,s=null;for(let e=0;e<l.length;e++)0===l[e].type.indexOf("image")&&(s=l[e].getAsFile());if(null!==s){let e=new FileReader;return e.onload=function(e){t.$.editableElement.getRootNode().execCommand("insertHTML",!1,`<img src="${e.target.result}"/>`)},void e.readAsDataURL(s)}r.indexOf(n)>-1&&r.indexOf(i)>-1&&(r=r.slice(r.indexOf(n),r.indexOf(i))),t._handlePasteAction(r,{advanced:!0,value:t.pasteFormat},a)}}const l=o.getRootNode().activeElement,s=t._changingValue;if(!t.$.contentContainer.hasAttribute("split-mode")){if(clearTimeout(t._refreshTimeout),delete t._refreshTimeout,i){const o=t.findAndReplaceTimeout,a=e.key;if(clearTimeout(t._findAndReplaceTimeout),!a||"enter"===a.toLowerCase())return;return void(o?t._findAndReplaceTimeout=setTimeout((()=>t._applySearching(e.target.value)),o):t._applySearching(e.target.value))}const o=t._resizeFrameObj?t._resizeFrameObj.target:void 0;return o&&!o.parentElement&&(t._setResizeFrame(),t._closeToolbar()),void r()}r(),clearTimeout(t._refreshTimeout);let d=t.$.input.value;t._refreshTimeout=setTimeout((()=>{clearTimeout(t._refreshTimeout),"markdown"===t.editMode?t.$.editableElement.innerHTML=window.marked?window.marked(d):d:l===n?t.$.editableElement.innerHTML=t._getInputValue(d,!0):t.$.input.value=t._getInputValue(t.$.editableElement.innerHTML.trim())}),t.splitModeRefreshTimeout)}_editableElementWheelHandler(){const e=this.$.inlineToolbar;this._setResizeFrame(),e&&e.visible&&e.close()}_editableElementKeyDownHandler(e){const t=this,o=t.$.editableElement,a=t.$.input,n=e.target.getRootNode().activeElement,i=e.key.toLowerCase(),r=t._isMacOS&&e.metaKey||e.ctrlKey;if(!t.disabled&&!t.readonly){switch(i){case"a":if(!r){t._changingValue=n===o?o.innerHTML:a.value;break}if(n.classList.contains("smart-editor-image-caption"))return e.preventDefault(),t._setSelectionRange(n),void t._handleInlineToolbar(t._getSelectionRange().startContainer);if(t._tableCell)return e.preventDefault(),t._setSelectionRange(t._tableCell),void t._handleInlineToolbar(t._getSelectionRange().startContainer);break;case"backspace":case"delete":{const i=t._resizeFrameObj?t._resizeFrameObj.target:void 0;i&&("img"===i.nodeName.toLowerCase()||i.classList.contains("smart-editor-video-container"))&&(e.preventDefault(),t._deleteResizeFrameTarget(i)),t._changingValue=n===o?o.innerHTML:a.value;break}case"enter":if(!t.disableSearchBar){const o=t._searchToolbar;o&&!o.classList.contains("smart-visibility-hidden")&&(e.preventDefault(),t._highlightSearchResult(!e.shiftKey))}break;case"escape":n===o?t._closeToolbar():n.classList.contains("smart-search-input")&&t._closeSearchToolbar();break;case"tab":t.enableTabKey&&(e.preventDefault(),t._handleTabInsert());break;default:t._handleToolbarShortcuts(e,n)}t._closeToolbar()}}_handleToolbarShortcuts(e,t){const o=this,a=o.$.editableElement,n=o.$.input,i=e.key,r=o._isMacOS&&e.metaKey||e.ctrlKey;if(!r)return void(o._changingValue=t===a?a.innerHTML:n.value);const l=o._resizeFrameObj;let s;switch(l&&l.target&&(s=l.target),i.toLocaleLowerCase()){case"b":e.preventDefault(),o._handleTextDecorations("bold");break;case"c":r&&s&&o._handleImageCopy(s);break;case"x":r&&s&&o._handleImageCut(s);break;case"k":e.preventDefault(),o._openWindow({name:"hyperlink"});break;case"i":e.shiftKey?(e.preventDefault(),o._openWindow({name:"image"},s)):(e.preventDefault(),o._handleTextDecorations("italic"));break;case"e":e.shiftKey?(e.preventDefault(),o._openWindow({name:"table"},s)):(e.preventDefault(),o._updateToolbarTarget({name:"alignment",value:"center"}));break;case"u":e.shiftKey?(e.preventDefault(),o._handleTextCase("uppercase")):(e.preventDefault(),o._handleTextDecorations("underline"));break;case"s":e.shiftKey&&(e.preventDefault(),o._handleTextDecorations("strikethrough"));break;case"l":e.shiftKey?(e.preventDefault(),o._handleTextCase("lowercase")):(e.preventDefault(),o._updateToolbarTarget({name:"alignment",value:"left"}));break;case"+":e.shiftKey&&(e.preventDefault(),o._handleSubSuperScript("superscript"));break;case"=":e.shiftKey?(e.preventDefault(),o._handleSubSuperScript("superscript")):(e.preventDefault(),o._handleSubSuperScript("subscript"));break;case"]":e.preventDefault(),o._handleIndentation("indent");break;case"[":e.preventDefault(),o._handleIndentation("outdent");break;case"h":if(e.shiftKey){const t=o._toolbarItemsObj.sourcecode;t&&(t.value=void 0===t.value||!t.value),e.preventDefault(),o._handleSourceCodeMode()}break;case"f":if(e.shiftKey){const t=o._toolbarItemsObj.fullscreen;t&&(t.value=void 0===t.value||!t.value),e.preventDefault(),o._handleFullScreenMode()}else!r||o.disableSearchBar||"html"!==o.editMode||a.classList.contains("smart-hidden")||(e.preventDefault(),o._openSearchBar());break;case"j":e.preventDefault(),o._updateToolbarTarget({name:"alignment",value:"justify"});break;case"r":e.shiftKey?(e.preventDefault(),o._handleClearFormat()):(e.preventDefault(),o._updateToolbarTarget({name:"alignment",value:"right"}));break;case"o":e.shiftKey?(e.preventDefault(),o._handleList("orderedlist")):e.altKey&&(e.preventDefault(),o._handleList("unorderedlist"))}}_editableElementMoveHandler(e){const t=this,o=t.$.editableElement,a=e.originalEvent||e,n=a.clientX,i=a.clientY,r=t.shadowRoot||t.isInShadowDOM?a.composedPath()[0]:a.target;if(e.stopPropagation(),!r||!r.closest||t._isMobile||"false"===o.getAttribute("contenteditable"))return void o.removeAttribute("table-cell-resize");const l=t._inlineToolbarClickObj;if(l&&l.resizeDetails||t._dragDetails)return;const s=r.tagName.toLowerCase();if(!r.closest(".smart-editor-editable table")||"td"!==s&&"th"!==s)return void o.removeAttribute("table-cell-resize");const d=r.getBoundingClientRect();i<d.bottom+5&&i>d.bottom-5?o.setAttribute("table-cell-resize","vertical"):n<d.right+5&&n>d.right-5&&r.nextElementSibling?o.setAttribute("table-cell-resize","horizontal"):o.removeAttribute("table-cell-resize")}_focusEditableElement(){const e=this,t=e.$.iframe,o=e.editMode;let a=e.$.editableElement;if(("markdown"===o||a.classList.contains("smart-hidden"))&&(a=e.$.input),t&&t.focus({preventScroll:!0}),a.getRootNode().activeElement!==a){const n=e._getSelectionRange(),i=a.scrollTop,r=t?t.contentWindow:window;if(a.focus({preventScroll:!0}),e._isSafari&&i&&(a.scrollTop=i),"markdown"===o||a.classList.contains("smart-hidden"))return void(void 0!==n.selectionStart&&e._setSelectionRange(n.selectionStart,n.selectionEnd));if(n instanceof r.Range){const e=(t?t.contentWindow:window).getSelection();e.removeAllRanges(),e.addRange(n)}}}_getTextFromCarret(){const e=this._getSelectionRange(),t=e.startContainer,o=t.textContent;let a,n;if(!e.toString()&&o.length>0&&o.indexOf(" ")>-1){const t=o.slice(0,e.startOffset).lastIndexOf(" ")+1;let i=o.slice(e.endOffset).indexOf(" ");i<0&&(i=o.length-1),a=t>-1?t:e.startOffset,n=Math.max(e.endOffset,e.endOffset+i)}else a=0,n=t.length;return{selectionStartIndex:a,selectionEndIndex:n}}_handleSearchButtonClick(e){const t=this;if(!e)return;const o=e.classList;o.contains("smart-search-button")&&(o.contains("prev")?t._highlightSearchResult():o.contains("next")?t._highlightSearchResult(!0):o.contains("close")&&t._closeSearchToolbar())}_highlightSearchResult(e){const t=this,o=t.$.contentContainer,a=t.$.editableElement.querySelectorAll(".find-and-replace-match"),n=o.querySelector(".smart-search-input-container"),i=a.length;for(let o=0,r=i;o<r;o+=1){const r=a[o];if(r.classList.contains("selected")){const l=e?Math.min(i-1,o+1):Math.max(0,o-1),s=a[l];return s&&(s.classList.add("selected"),n.setAttribute("selected",l+1),t._scrollToMarker(s)),void(s!==r&&r.classList.remove("selected"))}}}_handleToolbarItemClick(e,t){const o=this;if(!t)return;const a=o.$.inlineToolbar,n=o._toolbarItemClick,i=t.getAttribute("item-type"),r=t.getAttribute("item-name");let l,s;if(e&&(l=e.originalEvent||e,s=o.shadowRoot||o.isInShadowDOM?l.composedPath()[0]:l.target),"custom"!==i&&l&&(o.hasRippleAnimation&&"delimiter"!==i&&Smart.Utilities.Animation.Ripple.animate(s,l.pageX,l.pageY),n&&n.callback))return n.callback.call(o,t,n.target),void o.$.fireEvent("toobarItemClick",{value:r,originalEvent:l});o.$.fireEvent("actionStart",{name:r}).defaultPrevented||(o._handleToolbarItemAction(t),o._closeToolbarItemDropDown(o.$.inputPopup),o._closeToolbarItemDropDown(o.$.colorInputPopup),a&&a.close(),l&&o.$.fireEvent("toobarItemClick",{value:r,originalEvent:l}),r&&o.$.fireEvent("actionEnd",{name:r}))}_handleToolbarItemAction(e){const t=this,o=t._toolbarItemClick;if(!e)return;const a=e.getAttribute("item-type"),n=e.getAttribute("item-name");if("custom"!==a)switch(n){case"bold":case"italic":case"underline":case"strikethrough":t._handleTextDecorations(n);break;case"clearformat":t._handleClearFormat();break;case"redo":case"undo":t._handleUndoRedo(n);break;case"lowercase":case"uppercase":t._handleTextCase(n);break;case"backgroundcolor":t._handleBackgroundColor(e.getAttribute("item-value"));break;case"fontcolor":t._handleFontColor(e.getAttribute("item-value"));break;case"findandreplace":case"editlink":t._openWindow(e);break;case"openlink":{const o=t.$.inlineToolbar;if(o&&o.contains(e)){const e=o.selector;let t;e.nodeName!==Node.TEXT_NODE&&(t=e.closest(".smart-editor-editable a")),t&&window.open(t.href,t.target)}break}case"caption":{if(!o)break;const e=o.target;if(e&&"img"===e.nodeName.toLowerCase()){const o=e.closest(".smart-editor-image-container");let a;o&&o.querySelector(".smart-editor-image-caption")||(a=t.localize("captionPlaceholder")),t._handleImgCaption(e,{caption:a,focusCaption:!0})}else if(e.classList.contains("smart-editor-video-container")){const o=e.querySelectorAll(".smart-editor-video-container > video, .smart-editor-video-container > iframe");let a;e.querySelector(".smart-editor-image-caption")||(a=t.localize("captionPlaceholder")),t._handleVideoCaption(o[0]||o[1],{caption:a,focusCaption:!0})}break}case"cut":case"copy":case"paste":t._handleClipboardAction(n);break;case"delete":t._resizeFrameObj&&t._resizeFrameObj.target?t._deleteResizeFrameTarget(o.target):t._handleTextDelete();break;case"removelink":o&&t._handleLinkRemove(o.target);break;case"tableheader":case"tablerows":case"tablecolumns":case"tablevalign":case"tablestyle":t._handleTableToolbarAction(e);break;case"sourcecode":t._handleSourceCodeMode(e);break;case"splitmode":t._handleSplitMode(e);break;case"fullscreen":t._handleFullScreenMode(e);break;case"orderedlist":case"unorderedlist":t._handleList(n);break;case"indent":case"outdent":t._handleIndentation(n);break;case"subscript":case"superscript":t._handleSubSuperScript(n);break;case"print":t._handlePrint();break;default:t._inlineToolbarItemsObj?t._updateEditorViaWindow(t._inlineToolbarItemsObj[n]):t._toolbarItemsObj&&t._updateEditorViaWindow(t._toolbarItemsObj[n])}}_handleCommonToolbarAction(e,t){const o=this;if("html"===o.editMode){const a=o._getSelectionRange(),n=o.$.iframe,[i,r]=n?[n.contentDocument,n.contentWindow]:[document,window];let l,s=a.startContainer;if(!s)return;const d=e=>"string"==typeof e?("removeFormat"===e&&o.removeStylesOnClearFormat&&o._removeNodeStyles(a.commonAncestorContainer),i.execCommand(e)):"object"==typeof e?i.execCommand(e.name,!1,e.value):void 0;if(a.startOffset===a.endOffset&&s.nodeType===Node.TEXT_NODE){const{selectionStartIndex:e,selectionEndIndex:t}=o._getTextFromCarret();l=a.startOffset-e,o._setSelectionRange(s,e,t)}d(e)&&void 0!==l&&o._setSelectionRange(r.getSelection().focusNode,l,l),t&&o._updateToolbarItems(t)}}_handleClearFormat(){this._handleCommonToolbarAction("removeFormat")}_handleFontName(e){this._handleCommonToolbarAction(e)}_handleFontSize(e){const t=this;if("markdown"===t.editMode)return;const o=t._getSelectionRange();let a,n=o.startContainer;if(n){if(o.startOffset===o.endOffset){if(n.nodeType!==Node.TEXT_NODE){const a=document.createElement("font");return o.insertNode(a),t._setSelectionRange(a),void(a.style.fontSize=e.value+"px")}{const{selectionStartIndex:e,selectionEndIndex:i}=t._getTextFromCarret();a=o.startOffset-e,t._setSelectionRange(n,e,i)}}if((t.$.editableElement.getRootNode()||document).execCommand("fontSize",!1,3)){const n=t.$.iframe,i=n?n.contentWindow:window;if(o.commonAncestorContainer.closest){const t=o.commonAncestorContainer.querySelectorAll("font[size]");for(let o=0,a=t.length;o<a;o+=1){const a=t[o];a.removeAttribute("size"),a.style.fontSize=e.value+"px"}}else{const t=i.getSelection().focusNode;if(!t)return;const o=t.closest?t.closest(".smart-editor-editable font"):t.parentElement;"font"===o.nodeName.toLowerCase()&&(o.removeAttribute("size"),o.style.fontSize=e.value+"px")}void 0!==a&&t._setSelectionRange(i.getSelection().focusNode,a,a)}}}_handleFormats(e){const t=this;if("markdown"!==t.editMode)t._getSelectionRange().startContainer&&t.$.editableElement.getRootNode().execCommand("formatBlock",!1,e.value);else{let o;switch(e.value){case"h1":o="#";break;case"h2":o="##";break;case"h3":o="###";break;case"h4":o="####";break;case"h5":o="#####";break;case"h6":o="######";break;case"code":case"pre":o="```\n\n```";break;case"blockquote":o=">";break;case"p":o="";break;default:o=e.value}const a=e.dataSource,n=t.$.input.selectionStart;if(a){const e=a.map((e=>e.value));for(let o=0,a=e.length;o<a;o+=1){const a=t._getMarkdownFormat(n,e[o]);if(a&&void 0!==a.formatName){t._removeMarkDown(a.markdown,a.occuranceIndex,!0);break}}}0===o.indexOf("#")||0===o.indexOf(">")?(o+=" ",t._insertMarkDown(o,t.$.input.selectionStart+o.length,!0)):t._insertMarkDown(o,t.$.input.selectionStart+o.length/2)}}_handleSubSuperScript(e){const t=this;"markdown"!==t.editMode?t._handleCommonToolbarAction(e,["subscript","superscript"]):t._handleMarkdownItem(e)}_handleMarkdownItem(e){const t=this,o=t.$.input,a=t._getSelectionRange(),n=a.selectionStart,i=a.selectionEnd;let r,l,s,d=o.value;switch(e){case"bold":l="**",s="**";break;case"italic":l="*",s="*";break;case"underline":l="<ins>",s="</ins>";break;case"strikethrough":l="~~",s="~~";break;case"subscript":l="<sub>",s="</sub>";break;case"superscript":l="<sup>",s="</sup>"}if(void 0!==n&&n!==i){const e=l.length,a=s.length;if(r=d.slice(n,i),d.slice(n-e,n)===l&&d.slice(i,i+a)===s)return o.value=d.slice(0,n-e)+r+d.slice(i+a),t._refreshMarkdownPreview(),void t._setSelectionRange(o,n-e,i-e)}l&&s&&t._insertMarkDown(l+s,o.selectionStart+l.length)}_handleTextDecorations(e){const t=this;if("markdown"===t.editMode)return void t._handleMarkdownItem(e);const o=t._getSelectionRange();let a,n=o.startContainer;if(n){if(o.startOffset===o.endOffset&&n.nodeType===Node.TEXT_NODE){const{selectionStartIndex:e,selectionEndIndex:i}=t._getTextFromCarret();a=o.startOffset-e,t._setSelectionRange(n,e,i)}if((t.$.editableElement.getRootNode()||document).execCommand(e))if(void 0!==a){const e=t.$.iframe,o=e?e.contentWindow:window,n=o.getSelection().focusNode;n.textContent=n.textContent.trim(),t._setSelectionRange(o.getSelection().focusNode,a,a)}else t._setSelectionRange();t._updateToolbarItems([e])}}_handlePasteAction(e,t,o){if(!e)return;const a=this;if(t&&!t.name&&"prompt"===a.pasteFormat){const n={name:"paste",text:e,textType:o};return t&&(n.value=t.value,n.advanced=t.advanced),void a._openWindow(n)}a._handleTextPaste(e,t,o)}_handleTextPaste(e,t,o){const a=this,n=a.$.input;if(a.$.contentContainer.classList.contains("char-count-maxed"))return;if("markdown"===a.editMode)return a._insertMarkDown(e),void a._setCharCount();e=e.replace(/<!--StartFragment-->|<!--EndFragment-->/gi,"");let i,r,l=a.pasteFormat;if(t&&t.advanced&&(l=t.value),!o||"plainText"===l){const t=document.createElement("div");t.innerHTML=e,e=t.innerText}const s=e.toLocaleLowerCase();if(i=document.createElement("span"),i.innerHTML=e,s.indexOf("<video")>-1||s.indexOf("<iframe")>-1||s.indexOf("smart-editor-image-caption")>-1){const e=i.querySelectorAll("video, iframe"),t=i.querySelector(".smart-editor-image-caption"),o=e.length>0;let a=document.createDocumentFragment();for(let t=0,o=e.length;t<o;t+=1)a.appendChild(e[t]);if(t&&(t.removeAttribute("style"),a.appendChild(t)),o||t){const e=document.createElement("span");i.classList.add("smart-editor-image-container"),o&&i.classList.add("smart-editor-video-container"),i.setAttribute("contenteditable",!1),a.childElementCount&&(i.innerHTML="",i.appendChild(a)),e.appendChild(i),i=e}}if("cleanFormat"===l&&a._removeNodeStyles(i),o&&"text/plain"!==o||(i=document.createTextNode(i.innerHTML),r=Node.TEXT_NODE),n.getRootNode().activeElement===n){const e=n.value;return n.value=e.slice(0,n.selectionStart)+(r===Node.TEXT_NODE?i.textContent:i.innerHTML)+e.slice(n.selectionEnd),void a._setCharCount()}const d=a._getSelectionRange(),c=a.$.iframe,[m,u]=c?[c.contentWindow,c.contentDocument]:[window,document];if(!(d instanceof m.Range))return u.execCommand("paste"),void a._handleContentFiltering();if(d.deleteContents(),i.childNodes.length)for(;i.lastChild;)d.insertNode(i.lastChild);else d.insertNode(i);d.collapse(),a._handleContentFiltering()}_removeNodeStyles(e){if(e&&e.nodeType!==Node.TEXT_NODE){const t=e.querySelectorAll("style, [style]");for(let e=0,o=t.length;e<o;e+=1){const o=t[e];"style"===o.nodeName.toLowerCase()?o.remove():t[e].removeAttribute("style")}e.removeAttribute("style")}}_handlePaste(e){const t=this,o=navigator.clipboard,a=o.read?"read":"readText",n=()=>{o[a]&&o[a]().then((o=>{if(Array.isArray(o)&&o.length){const a=o[0],n=a.types.indexOf("text/html")>-1?"text/html":"text/plain";a.getType(n).then((o=>{o.text().then((o=>t._handlePasteAction(o,e,n)))}))}else"string"==typeof o&&t._handlePasteAction(o,e)}))};if(navigator.permissions&&navigator.permissions.query&&!t._isFireFox)try{navigator.permissions.query({name:"clipboard-read"}).then((e=>{("granted"===e.state||"prompt"===e.state&&o[a])&&n()}))}catch(e){t.error(t.localize("permissionsRequired",{elementType:t.nodeName.toLowerCase(),actionName:"paste"}))}else if(o[a])return void n();t.$.editableElement.getRootNode().execCommand("paste")}_handlePasteViaWindow(e){const t=this,o=t._getItemOptionsViaWindow(e);if(!e||"paste"!==e.name)return;let a=t.pasteFormat;for(let e in o)if(o[e]){a=e;break}e.value=a,t._handleTextPaste(e.text,e,e.textType)}_handleClipboardAction(e){const t=this,o=t.editMode,a=t.$.input;if("paste"===e)return void t._handlePaste();const n=t._getSelectionRange();if(("copy"===e||"cut"===e)&&(document.execCommand("copy"),"cut"===e))if("markdown"===o){const e=a.value,o=a.selectionStart;a.value=e.slice(0,o)+e.slice(a.selectionEnd),t._setSelectionRange(a,o,o),t._refreshMarkdownPreview()}else n.deleteContents()}_handleLinkRemove(e){const t=this;let o;if(e&&"img"===e.nodeName.toLowerCase())o=e.closest(".smart-editor-editable a"),o&&(o.parentElement.insertBefore(e,o),o.remove());else{const e=t.$.iframe;let o,a;e?(o=e.contentDocument,a=e.contentWindow):(o=document,a=window);const n=a.getSelection(),i=t._getSelectionRange();n.removeAllRanges(),n.addRange(i);const r=n.anchorNode?n.anchorNode.parentElement:void 0;if(!r||"a"!==r.nodeName.toLowerCase())return;i.selectNode(n.anchorNode),o.execCommand("unlink",!1,!1)}}_handleBackgroundColor(e){const t=this;if("markdown"===t.editMode)return;const o=t.$.iframe,a="string"==typeof e?e:e.value,[n,i]=o?[o.contentDocument,o.contentWindow]:[document,window],r=t.$.inlineToolbar,l=t._getSelectionRange(),s=r&&r.visible?r.selector:l.commonAncestorContainer;let d;if(s&&["th","td"].indexOf(s.nodeName.toLowerCase())>-1){if(l.startOffset===l.endOffset)return void(s.style.backgroundColor=a);d=s.style.backgroundColor}const c=l.startOffset,m=l.endOffset,u=l.startContainer;let b;if(u&&u.nodeType===Node.TEXT_NODE&&l.startOffset===l.endOffset){const{selectionStartIndex:e,selectionEndIndex:o}=t._getTextFromCarret();b=l.startOffset-e,t._setSelectionRange(u,e,o)}else u.closest&&c!==m&&t._setSelectionRange(u,c,m);const p=n.execCommand("hiliteColor",!1,a&&"transparent"!==a?a:"transparent");s&&d?s.style.backgroundColor=d:p&&void 0!==b&&t._setSelectionRange(i.getSelection().focusNode,b,b)}_handleFontColor(e){const t=this;if("markdown"===t.editMode)return;const o=t._getSelectionRange(),a="string"==typeof e?e:e.value,n=o.startContainer,i=t.$.iframe,r=a?"foreColor":"removeFormat",[l,s]=i?[i.contentDocument,i.contentWindow]:[document,window];let d;if(n&&n.nodeType===Node.TEXT_NODE&&o.startOffset===o.endOffset){const e=n.parentElement;if("font"===e.nodeName.toLocaleLowerCase())return void(e.color=a);const{selectionStartIndex:i,selectionEndIndex:r}=t._getTextFromCarret();d=o.startOffset-i,t._setSelectionRange(n,i,r)}l.execCommand(r,!1,a)&&void 0!==d&&t._setSelectionRange(s.getSelection().focusNode,d,d)}_handlePrint(){const e=this,t=e.dataExport.fileName;e.dataExport.fileName=null;const o=window.open("","","width=800,height=500"),a=o.document.open(),n='<!DOCTYPE html><html><head><meta charset="utf-8" /><title>'+t+"</title></head><body>"+e._handleDataExport("html")+"</body></html>";try{a.write(n),a.close(),setTimeout((function(){o.print(),o.close()}),100)}catch(e){}e.dataExport.fileName=t}_handleDataExport(e,t){const o=this;if(!Smart.Utilities.DataExporter)return void o.error(o.localize("missingReference",{elementType:o.nodeName.toLowerCase(),methodName:"exportData",files:"smart.export.js"}));try{new JSZip}catch(e){return void o.error(o.localize("missingReference",{elementType:o.nodeName.toLowerCase(),methodName:"exportData",files:"jszip.min.js"}))}if("pdf"===e&&!window.pdfMake)return void o.error(o.localize("missingReference",{elementType:o.nodeName.toLowerCase(),methodName:"exportData",files:"pdfMake.min.js"}));if("pdf"===e)return void o._exportToPDF(o.dataExport.fileName,e);let a;if("markdown"===o.editMode){const t=o.$.input;a="md"!==e&&window.marked?window.marked(t.value):t.value}else a=o.$.editableElement["pdf"===e?"textContent":"innerHTML"];const n=new Smart.Utilities.DataExporter({exportHeader:!1,pageOrientation:o.dataExport.pageOrientation,style:o.dataExport.style}),i=[{value:a}];return o._setExportStyles(n,e),n.exportData(i,e,o.dataExport.fileName,t)}_exportToPDF(e,t){const o=this,a=o.$.editableElement,n=window.getComputedStyle(o),i=o.dataExport.style,r={pageOrientation:o.pageOrientation||"portrait",info:{title:"smartEditor",creator:"Smart",producer:"Smart"}};if(i&&(r.styles=i),r.defaultStyle={fontSize:parseFloat(n.fontSize)},"markdown"===o.editMode){const e=o.$.input,n=document.createElement("div");let i;"md"!==t?a.classList.contains("smart-hidden")?(n.innerHTML=window.marked?window.marked(e.value):e.value,i=o._processHTMLAsPDFObject(n,[])):i=o._processHTMLAsPDFObject(a,[]):(n.innerHTML=e.value,i=o._processHTMLAsPDFObject(n,[])),r.content=i}else r.content=o._processHTMLAsPDFObject(o.$.editableElement,[]);try{pdfMake.createPdf(r).download(e)}catch(e){console.error(o.localize("exportError",{elementType:o.nodeName.toLowerCase(),status:e.toString()}))}}_processHTMLAsPDFObject(e,t,o){const a=this,n={},i=["left","center","right"],r=e.childNodes,l=["td","th"].indexOf(e.nodeName.toLowerCase())>-1;for(let o=0,s=r.length;o<s;o+=1){const s=r[o],d=s.nodeName.toLowerCase(),c=s.nodeType===Node.TEXT_NODE;let m;if("table"===d){const e=s.querySelectorAll("thead tr"),t=s.querySelectorAll("thead tr:last-of-type td, thead tr:last-of-type th"),o=s.querySelectorAll("tbody tr:last-of-type td, tbody tr:last-of-type th"),n=t.length?t:o,i=s.querySelectorAll("body tr");let r=e.length;if(!r)for(let e=0,t=i.length;e<t&&Array.from(i[e].children).every((e=>"th"===e.nodeName.toLowerCase()));e+=1)r++;m={table:{headerRows:r,widths:(()=>{const e=Math.round(100/n.length)+"%";let t=[];for(let o=0,a=n.length;o<a;o+=1)t.push(e);return t})(),body:(()=>{let e=[];for(let t=0,o=i.length;t<o;t+=1){const o=i[t],r=o.children;let l=[];for(let e=0,t=o.childElementCount;e<t;e+=1){const t=a._processHTMLAsPDFObject(r[e],[],!0);if(o.childElementCount<n.length){let e;for(e=Array.isArray(t)&&1===t.length?t[0]:{text:t},e.colSpan=Math.round(n.length/o.childElementCount),l.push(e);l.length<n.length;)l.push({text:""})}else l.push(1===t.length?t[0]:t)}e.push(l)}return e})()}}}else if("ul"===d)m={ul:a._processHTMLAsPDFObject(s,[])};else if("ol"===d)m={ol:a._processHTMLAsPDFObject(s,[])};else if("img"===d){const e=document.createElement("canvas"),t=e.getContext("2d");let o;e.width=s.naturalWidth||s.width,e.height=s.naturalHeight||s.height,t.drawImage(s,0,0);try{o=e.toDataURL("image/png")}catch(e){console.error(a.localize("exportError",{elementType:a.nodeName.toLowerCase(),status:e.toString()}));continue}if(o.indexOf("image/png")<0){console.error(a.localize("exportError",{elementType:a.nodeName.toLowerCase(),status:"Invalid image"}));continue}m={image:o,width:s.width,height:s.height}}else"a"===d?(m={},s.childElementCount?s.querySelector("img")&&(m=a._processHTMLAsPDFObject(s,[],!0)[0]||{}):m.text=s.textContent,m.link=s.href):s.childElementCount?t=t.concat(a._processHTMLAsPDFObject(s,[],!0)):m={text:s.textContent.trim()?s.textContent:"\n"};if(m){const o=window.getComputedStyle(c?e:s);if(!c||l){const e=o.backgroundColor,t=parseFloat(o.fontSize);isNaN(t)||(m.fontSize=t),m.alignment=n.alignment=i.indexOf(o.textAlign)>-1?o.textAlign:i[0],"rgba(0, 0, 0, 0)"!==e&&"transparent"!==e&&(m.fillColor=n.fillColor=a._RGBAtoHex(e)),parseInt(o.fontWeight)>500&&(m.bold=!0),"italic"===o.fontStyle&&(m.italics=!0)}m.inlineElement=c||o.display.indexOf("inline")>-1,m.color=n.color=a._RGBAtoHex(o.color),t.push(m)}}return 1===t.length?t:o||l?(n[t.every((e=>e.inlineElement&&!e.image))?"text":"stack"]=t,[n]):t}_RGBAtoHex(e){const t=/rgb[a]?\(\s*(\d+),\s*(\d+),\s*(\d+),?\s*(\d*.\d+|\d+)?\)/gi.exec(e.replace(/\s/g,""));if(null===t)return e;const o=parseFloat(t[1]).toString(16).toUpperCase(),a=parseFloat(t[2]).toString(16).toUpperCase(),n=parseFloat(t[3]).toString(16).toUpperCase();return"#"+"0".repeat(2-o.length)+o+"0".repeat(2-a.length)+a+"0".repeat(2-n.length)+n}_setExportStyles(e,t){const o=this;if(e.style)return;const a=window.getComputedStyle(o),n=a.getPropertyValue("--smart-border-width")||"1px",i=a.getPropertyValue("--smart-border")||"black",r=a.getPropertyValue("--smart-editor-table-column-width")||"initial",l=a.getPropertyValue("--smart-editor-table-cell-min-height")||"20px",s=a.getPropertyValue("--smart-editor-table-cell-min-width")||l,d=a.getPropertyValue("--smart-surface")||"#333",c=a.getPropertyValue("--smart-alternation-index0-background")||d;e.style={border:"initial",width:"100%",height:o.$.editableElement.scrollHeight+"px",removeDefault:!0,custom:`\n ${"html"===t&&o.rightToLeft?"body { direction: rtl; }":""}\n\n .column table {\n width: 100%;\n border-collapse: collapse;\n empty-cells: show;\n border-spacing: 0;\n table-layout: fixed;\n }\n \n .column td, .column th {\n border: ${n} solid ${i};\n width: ${r};\n min-height: ${l};\n min-width: ${s};\n padding: 2px 5px;\n vertical-align: middle;\n }\n \n .column table img {\n max-width: 100%;\n }\n \n .column table table {\n width: 100%;\n }\n \n .column table th {\n background: ${d};\n }\n\n .column th:empty::before,\n .column td:empty::before {\n content: 'A';\n visibility: hidden;\n }\n \n .column table[dashed-borders] th, .column table[dashed-borders] td {\n border-style: dashed;\n }\n \n .column table[alternation] tr:nth-child(2n) {\n background-color: ${c};\n }\n \n .column .smart-editor-image-container {\n display: inline-block;\n }\n \n .column .smart-editor-image-container[display="block"] {\n display: block;\n }\n \n .column .smart-editor-image-container[display="block"][alignment="left"] img {\n margin-left: 0;\n }\n \n .column .smart-editor-image-container[display="block"][alignment="left"] .smart-editor-image-caption {\n text-align: left;\n }\n \n .column .smart-editor-image-container[display="block"][alignment="right"] img {\n margin-right: 0;\n }\n \n .column .smart-editor-image-container[display="block"][alignment="right"] .smart-editor-image-caption {\n text-align: right;\n }\n \n .column .smart-editor-image-container:not([display="block"])[alignment="left"] {\n float: left;\n }\n \n .column .smart-editor-image-container:not([display="block"])[alignment="right"] {\n float: right;\n }\n \n .column .smart-editor-image-container .smart-editor-image-caption {\n display: block;\n text-align: center;\n outline: none;\n }`}}_handleSourceCodeMode(e){const t=this,o=t.editMode,a=t._toolbarItemsObj.sourcecode;let n;if(t.$.contentContainer.hasAttribute("split-mode"))return;e?n=e.hasAttribute("checked"):(n=a?a.value:!t.classList.contains("preview-mode"),e=t.$.toolbar.querySelector('.smart-editor-toolbar-item[item-name="sourcecode"]')),t._closePopups(),t._closeWindow(),t._closeSearchToolbar(),t._setResizeFrame(),t._handleTableSelection();const i=t.$.editableElement,r=t.$.input;"markdown"===o?n&&i.classList.contains("smart-hidden")?(i.innerHTML=window.marked?window.marked(r.value):r.value,i.classList.remove("smart-hidden"),r.classList.add("smart-hidden"),i.focus({preventScroll:!0})):!n&&r.classList.contains("smart-hidden")&&(i.classList.add("smart-hidden"),r.classList.remove("smart-hidden"),r.focus({preventScroll:!0})):n&&r.classList.contains("smart-hidden")?(r.value=t._getInputValue(i.innerHTML),i.classList.add("smart-hidden"),r.classList.remove("smart-hidden"),r.focus({preventScroll:!0})):!n&&i.classList.contains("smart-hidden")&&(i.innerHTML=t._getInputValue(r.value,!0),r.classList.add("smart-hidden"),i.classList.remove("smart-hidden"),i.focus({preventScroll:!0}),t._handleContentFiltering()),n?t.classList.add("preview-mode"):t.classList.remove("preview-mode"),a&&(a.value=n),e&&a&&(n?(e.setAttribute("checked",""),e.setAttribute("aria-pressed",!0)):(e.removeAttribute("checked"),e.setAttribute("aria-pressed",!1)),t._setTextSelection(),t._setToolbarItemAttr("sourcecode","disabled",a.disabled))}_setTextSelection(){const e=this,t=e.$.input,o=e.$.editableElement,a=e._selectionRange;if(!a)return;const n=a.commonAncestorContainer;if(n){if(t.classList.contains("smart-hidden"))return;const i=e._getParentCharDetails(a.startContainer,n),r=e._getParentCharDetails(a.endContainer,n),l=e._getSiblingsCharOffset(i.parentElement,r.parentElement),{charOffset:s}=e._getParentCharDetails(n,o),d=a.startOffset+i.charOffset+s,c=a.endOffset+r.charOffset+l+s;e._setSelectionRange(t,d,c)}else if(!o.classList.contains("smart-hidden")){const n=a.selectionStart,i=a.selectionEnd,r=t.value;if(void 0===n||void 0===i||n===i&&(r.length===n||0===n))return;if(0===n&&i===o.innerHTML.length)return void e._setSelectionRange(o);const l=e._getNodeByChartOffset(o.firstChild,n,i);if(!l)return;const{node:s,charOffset:d}=l;e._setSelectionRange(s,n-d,i-d)}}_getNodeByChartOffset(e,t,o){const a=this;let n=0;for(;e;){const i=e.outerHTML||e.textContent,r=i.length;if(n<=t&&n+r>=o){e.tagName&&(n+=e.outerHTML.slice(0,i.indexOf(e.innerHTML)).length);const r=a._getNodeByChartOffset(e.firstChild,t-n,o-n);return r?{node:r.node,charOffset:r.charOffset+n}:{node:e,charOffset:n}}e=e.nextSibling,n+=r}}_getParentCharDetails(e,t){let o=0;if(e===t)return{charOffset:o,parentElement:e.parentElement};let a=e,n=e.innerHTML||e.textContent,i=e.parentElement;for(;i&&i!==t&&t.contains(i);){const e=i.outerHTML;o+=e.indexOf(n),n=e,a=i,i=i.parentElement}return o+=(t.innerHTML||t.textContent).indexOf(n),{charOffset:o,parentElement:a}}_getPreSiblingOffset(e,t){let o=0,a=e.textContent,n=e.previousSibling;for(;n&&t.contains(n);){const e=n.outerHTML||n.textContent;a=e+a,o+=e.length,n=n.previousSibling}return o}_getSiblingsCharOffset(e,t){let o=0,a=e.nextSibling;if(e===t)return o;for(;a&&a!==t;)o+=(a.outerHTML||a.textContent).length,a=a.nextSibling;return o}_handleFullScreenMode(e){const t=this,o=t._toolbarItemsObj.fullscreen;let a;e?a=e.hasAttribute("checked"):(a=o?o.value:!t.classList.contains("full-screen-mode"),e=t.$.toolbar.querySelector('.smart-editor-toolbar-item[item-name="fullscreen"]')),t._closePopups(),t._setResizeFrame(),t._handleTableSelection(),a?(t.classList.add("full-screen-mode"),t._lastToolbarExpandedState=t.$.toolbar.hasAttribute("expanded")):(t.classList.remove("full-screen-mode"),t._lastToolbarExpandedState&&t._toggleToolbar()),o&&(o.value=a),e&&o&&(a?(e.setAttribute("cheched",""),e.setAttribute("aria-pressed",!0)):(e.removeAttribute("checked"),e.setAttribute("aria-pressed",!1)),o.disabled?(e.setAttribute("disabled",""),e.setAttribute("aria-disabled",!0)):(e.removeAttribute("disabled"),e.removeAttribute("aria-disabled")))}_handleSplitMode(e){const t=this,o=t.$.editableElement,a=t.$.input,n=t.$.contentContainer,i=t._toolbarItemsObj,r=i.splitmode,l=i.sourcecode,s=e?e.hasAttribute("checked"):!n.hasAttribute("split-mode"),d=t.editMode;t._closePopups(),s?("markdown"===d?o.innerHTML=window.marked?window.marked(a.value):a.value:a.value=o.innerHTML.trim(),n.setAttribute("split-mode",""),a.classList.remove("smart-hidden"),o.classList.remove("smart-hidden"),l&&t._setToolbarItemAttr("sourcecode","disabled",!0)):(n.removeAttribute("split-mode",""),"markdown"===d?o.classList.add("smart-hidden"):a.classList.add("smart-hidden"),l&&t._setToolbarItemAttr("sourcecode","disabled",!1)),r&&(r.value=s),e||(e=t.$.toolbar.querySelector('.smart-editor-toolbar-item[item-name="splitmode"]')),e&&(s?(e.setAttribute("checked",""),e.setAttribute("aria-pressed",!0)):(e.removeAttribute("checked"),e.setAttribute("aria-pressed",!1))),t._resizeFrameObj&&t._setResizeFrame(t._resizeFrameObj.target),t.classList.contains("preview-mode")&&t._handleSourceCodeMode()}_handleUndoRedo(e){this.$.editableElement.getRootNode().execCommand(e)}_handleTextCase(e){const t=this;if("markdown"===t.editMode)return;const o=t._getSelectionRange(),a=o.startContainer;if(!a)return;const n=a.textContent;let i,r,l,s,d=o.startOffset;a.nodeType===Node.TEXT_NODE&&o.startOffset===o.endOffset?(({selectionStartIndex:l,selectionEndIndex:s}=t._getTextFromCarret()),r=n.slice(l,s)):([l,s]=[d,o.endOffset],r=n.slice(d,o.endOffset),i=o.endOffset),r="lowercase"===e?r.toLowerCase():r.toUpperCase(),a.textContent=n.slice(0,l)+r+n.slice(s),t._setSelectionRange(a,d,i||d)}_handleList(e){const t=this;if(!e)return;if("markdown"===t.editMode){const o="orderedlist"===e?"1. ":"- ",a=t.$.input.selectionStart,n=t._getMarkdownFormat(a,"orderedlist"),i=t._getMarkdownFormat(a,"unorderedlist");if(n&&(t._removeMarkDown(o,n.occuranceIndex,"orderedlist"!==e),"orderedlist"===e))return;if(i&&(t._removeMarkDown(o,i.occuranceIndex,"unorderedlist"!==e),"unorderedlist"===e))return;return void t._insertMarkDown(o,t.$.input.selectionStart+o.length,!0)}let o,a,n=t._getSelectionRange();if(n.startContainer===n.endContainer&&(o=n.startOffset,a=n.endOffset),t.$.editableElement.getRootNode().execCommand("insert"+e,!1)){const e=t.$.iframe;n=(e?e.contentWindow:window).getSelection(),void 0!==a&&void 0!==a&&t._setSelectionRange(n.focusNode,o,a),t._updateToolbarItems(["orderedlist","unorderedlist"])}}_handleIndentation(e){"markdown"!==this.editMode&&this.$.editableElement.getRootNode().execCommand(e,!1)}_handleTextDelete(){this.$.editableElement.getRootNode().execCommand("delete")}_handleTabInsert(){this.$.editableElement.getRootNode().execCommand("insertHTML",!1,"	")}_handleTableToolbarAction(e,t){const o=this,a=o._toolbarItemClick;if(!t&&a&&(t=a.target),!t||"table"!==t.nodeName.toLowerCase()||!e)return;const n=e.getAttribute?e.getAttribute("item-name"):e.name,i=o.$.inlineToolbar;let r=e;if(r.closest){const e=o.$.inlineToolbar;r=(e&&e.contains(r)?o._inlineToolbarItemsObj:o._toolbarItemsObj)[n]}if(!a&&o.$.fireEvent("actionStart",{name:n}).defaultPrevented)return;switch(n){case"backgroundcolor":o._handleBackgroundColor(r);break;case"fontcolor":o._handleFontColor(r);break;case"fontsize":o._handleFontSize(r);break;case"tableheader":o._handleTableHeader(t);break;case"tablerows":o._handleTableRows(t,r);break;case"tablecolumns":o._handleTableColumns(t,r);break;case"tablevalign":o._handleTableVAlignment(t,r);break;case"alignment":o._handleTextAlignment(r);break;case"tablestyle":o._handleTableStyle(t,r);break;default:o._handleToolbarItemAction(e)}!a&&n&&o.$.fireEvent("actionEnd",{name:n}),i&&i.visible&&(o.$.editableElement.contains(i.selector)?i.reposition():o._closeToolbar());const l=o._getSelectionRange().startContainer;let s;if(l.nodeType===Node.TEXT_NODE){const e=l.parentElement;s=e.closest("th")||e.closest("td")}else s=["th","td"].indexOf(l.nodeName.toLowerCase())>-1;o._setResizeFrame(s&&t.contains(l)?t:void 0)}_handleTableHeader(e,t){let o,a,n=e.querySelector("th"),i=e.querySelector("tbody tr"),r=e.querySelector("thead");if(i&&(a=Array.from(i.children)),t||!r&&!n){if(void 0===t||!0===t){let t=e.querySelectorAll("tbody tr:first-of-type td").length;r||(r=document.createElement("thead")),o=r.querySelector("tr"),o||(o=document.createElement("tr"));const n=Array.from(o.children);for(;n.length>t;)n.pop().remove();for(let e=n.length;e<t;e+=1){const t=document.createElement("th");a[e]&&(t.style.width=a[e].style.width,a[e].style.width=""),o.appendChild(t)}r.appendChild(o),e.insertBefore(r,e.querySelector("tbody")||e.querySelector("tr"))}}else r&&r.remove(),n&&(o=n.closest("tr"),o&&o.remove(),Array.from(o.children).forEach(((e,t)=>a[t].style.width=e.style.width)))}_handleTableRows(e,t){if(!e)return;const o=this,a=o.$.inlineToolbar.selector,n=a.nodeName.toLocaleLowerCase();let i;if(!(a&&["th","td"].indexOf(n)>-1))return;if(i=a.closest("tr"),!i)return;const r=t.value,l=i.closest("thead");switch(r){case"insertRowAfter":case"insertRowBefore":{const t=document.createElement("tr"),o=i.parentElement;if(!o)break;const a=e.querySelector("tr").childElementCount,l="th"===n?"th":"td";for(let e=0;e<a;e+=1)t.appendChild(document.createElement(l));o.insertBefore(t,r.indexOf("Before")>-1?i:i.nextElementSibling);break}case"deleteRow":o._closeToolbar(),i.remove(),l&&!l.children.length&&l.remove()}const s=e.querySelectorAll("tr").length;s?(e.setAttribute("aria-rowcount",s),o._resizeFrameObj&&o._setResizeFrame(o._resizeFrameObj.target)):e.remove()}_handleTableColumns(e,t){if(!e)return;const o=this,a=o.$.inlineToolbar.selector;if(!(a&&["th","td"].indexOf(a.nodeName.toLowerCase())>-1))return;const n=t.value,i=Array.from(e.querySelectorAll("tr"));if(!i.length)return o._closeToolbar(),void e.remove();const r=Array.from(a.parentElement.children).indexOf(a);switch(n){case"insertColumnLeft":case"insertColumnRight":{const e=n.indexOf("Left")>-1;for(let t=0,o=i.length;t<o;t+=1){const o=i[t],a=o.children[r];if(a){const t="th"===a.tagName.toLowerCase()?"th":"td";o.insertBefore(document.createElement(t),e?a:a.nextElementSibling)}}break}case"deleteColumn":o._closeToolbar();for(let e=0,t=i.length;e<t;e+=1){const t=i[e].children[r];t&&t.remove()}}const l=i[0].children.length;l?(e.setAttribute("aria-colcount",l),o._resizeFrameObj&&o._setResizeFrame(o._resizeFrameObj.target)):e.remove()}_handleTextAlignment(e){if("markdown"===this.editMode)return;const t="justify"===e.value?"full":e.value;this.$.editableElement.getRootNode().execCommand("justify"+t.charAt(0).toUpperCase()+t.slice(1),!1,null)}_handleTableVAlignment(e,t){const o=this.$.inlineToolbar;if(!o)return;const a=o.selector;a&&["th","td"].indexOf(a.nodeName.toLowerCase())>-1&&(a.style.verticalAlign=t.value)}_handleTableStyle(e,t){const o=this.$.inlineToolbar.selector;if(o&&["th","td"].indexOf(o.nodeName.toLowerCase())>-1)switch(t.value){case"altrows":e.toggleAttribute("alternation");break;case"dashedborders":e.toggleAttribute("dashed-borders")}}_handleInlineToolbar(e){const t=this,o=e.nodeName.toLowerCase();"a"===o?(t._openInlineToolbar(e),t._refreshToolbarTabs()):"img"===o||["td","th"].indexOf(o)>-1?(t._setResizeFrame(e),t._openInlineToolbar(e),t._refreshToolbarTabs()):e.nodeType===Node.TEXT_NODE&&e.textContent.trim().length&&t._openInlineToolbar(e)}_handleTableCellResize(e){const t=this,o=t._inlineToolbarClickObj,a=o?o.resizeDetails:void 0;if(!a)return;const n=a.target,i=a.position,r=t.$.inlineToolbar;switch(a.started||t.$.fireEvent("resizeStart",{target:n}),n.setAttribute("resizing",""),a.started=!0,r&&r.visible&&(a.isInlineToolbarOpened=!0,t._closeToolbar()),i){case"horizontal":{const o=e.pageX+window.pageXOffset;if(t._setTableResizeDetails(a),!a.shrinkingCell)break;t._handleHorizontalTableCellResize(a,o);break}case"vertical":{const o=a.table;o.style.height&&(o.querySelectorAll("tr").forEach((e=>e.style.height=e.offsetHeight+"px")),o.style.height=""),t._resizeFrameObj&&t._resizeFrameObj.target&&t._setResizeFrame();const i=e.pageY+window.pageYOffset,r=a.y-i;let l=n.offsetHeight;l-=r,n.style.height=Math.max(1,l)+"px",l===n.offsetHeight&&(a.y=i+Math.abs(Math.min(0,l)));break}}}_setTableResizeDetails(e){const t=e.table,o=e.target;let a,n=e.expandingCell,i=e.shrinkingCell,r=e.isLastCell,l=e.areAllCellsResized;if(!n){const i=t.querySelector("tr"),r=Array.from(o.parentElement.children).indexOf(o);a=e.cells=Array.from(i.children),n=e.expandingCell=a[r]}e.shrinkingCell||(i=e.shrinkingCell=n.nextElementSibling,l=e.areAllCellsResized=!a.some((e=>e!==n&&e!==i&&!e.style.width)),r=e.isLastCell=l&&null===i.nextElementSibling,l&&!e.lastCell&&(e.lastCell=a[a.length-1]),r&&(i.style.width=""))}_handleHorizontalTableCellResize(e,t){const o=30,a=e.isLastCell;let n=e.expandingCell,i=e.shrinkingCell,r=n.offsetWidth,l=i.offsetWidth,s=e.x-t;const d=e.x-r+o,c=e.x+i.offsetWidth-o;if(a){const a=r+l-o;n.style.width=Math.min(Math.max(o,r-s),a)+"px",n.offsetWidth!==r&&(e.x=Math.min(c,Math.max(d,t)))}else{let a;s>0&&([n,i]=[i,n],[r,l]=[l,r],s*=-1),i.style.width=Math.max(o,l+s)+"px",a=i.offsetWidth-l,n.style.width=Math.max(o,n.offsetWidth-a)+"px",0!==a&&(e.x=Math.min(c,Math.max(d,t))),e.lastCell&&(e.lastCell.style.width="")}}_handleFrameResize(e){const t=this,o=t._resizeFrameObj;if(!o)return;t._closeToolbar();const a=o.resizableElement||o.target,n=o.resizeDetails,i=n.position,r=e.pageX+window.pageXOffset,l=e.pageY+window.pageYOffset,s=n.x-r,d=n.y-l;let c,m;c=a.offsetWidth,m=a.offsetHeight,n.started||(o.target.setAttribute("dragged",""),t.$.fireEvent("resizeStart",{target:a})),n.started=!0;const u=c,b=m,p=t.rightToLeft?-1:1;switch(i){case"top-left":a.style.width=Math.max(0,u+p*s)+"px",a.style.height=Math.max(0,b+d)+"px",c=a.offsetWidth,m=a.offsetHeight,u!==c&&(n.x-=p*(c-u)),b!==m&&(n.y-=m-b);break;case"bottom-left":a.style.width=Math.max(0,u+p*s)+"px",a.style.height=Math.max(0,b-d)+"px",c=a.offsetWidth,m=a.offsetHeight,u!==c&&(n.x-=p*(c-u)),b!==m&&(n.y+=m-b);break;case"bottom-right":a.style.width=Math.max(0,u-p*s)+"px",a.style.height=Math.max(0,b-d)+"px",c=a.offsetWidth,m=a.offsetHeight,u!==c&&(n.x+=p*(c-u)),b!==m&&(n.y+=m-b);break;case"top-right":a.style.width=Math.max(0,u+p*-s)+"px",a.style.height=Math.max(0,b+d)+"px",c=a.offsetWidth,m=a.offsetHeight,b!==m&&(n.y-=m-b),u!==c&&(n.x+=p*(c-u));break;case"top-center":a.style.height=Math.max(0,b+d)+"px",m=a.offsetHeight,b!==m&&(n.y-=m-b);break;case"bottom-center":a.style.height=Math.max(0,b-d)+"px",m=a.offsetHeight,b!==m&&(n.y+=m-b);break;case"left-center":a.style.width=Math.max(0,u+p*s)+"px",c=a.offsetWidth,u!==c&&(n.x-=p*(c-u));break;case"right-center":a.style.width=Math.max(0,u-p*s)+"px",c=a.offsetWidth,u!==c&&(n.x+=p*(c-u))}t._positionResizeHandles()}_deleteResizeFrameTarget(e){const t=this,o=t._getSelectionRange();if(e)if("img"===e.nodeName.toLowerCase()){const o=e.closest(".smart-editor-editable .smart-editor-image-container"),l=(o||e).parentElement,s=l&&"a"===l.nodeName.toLowerCase()?l:void 0;if(t._setResizeFrame(),(s||o||e).remove(),URL.revokeObjectURL(e.src),t.removeUrl){let o=new FormData,l=new XMLHttpRequest;const s=(e,t)=>{let o=e.split(","),a=o[0].match(/:(.*?);/)[1],n=atob(o[1]),i=n.length,r=new Uint8Array(i);for(;i--;)r[i]=n.charCodeAt(i);return new File([r],t,{type:a})};a=e.src,n=e.name,i=e=>{o.append(t.imageName,e),l.open("POST",t.removeUrl),l.send(o)},(r=new Image).crossOrigin="Anonymous",r.onload=function(){var e=document.createElement("canvas"),t=e.getContext("2d");e.height=this.naturalHeight,e.width=this.naturalWidth,t.drawImage(this,0,0);var o=e.toDataURL("image/jpeg");i(s(o,n))},r.src=a}t.onImageRemove&&t.onImageRemove(e.src)}else if(e.classList.contains("smart-editor-video-container")){const o=e.querySelector(".smart-editor-video-container video, .smart-editor-video-container > iframe");t._setResizeFrame(),e.remove(),o&&URL.revokeObjectURL(o.src)}else if("table"===e.nodeName.toLowerCase()){const o=e.closest(".smart-editor-editable table");o&&(t._setResizeFrame(),o.remove())}var a,n,i,r;t._setCharCount(),t._setSelectionRange(o.startContainer,o.startOffset,o.endOffset),t._focusEditableElement()}_setResizeFrame(e,t){const o=this,a=o.$.editableElement;let n,i=e?e.nodeName.toLowerCase():"",r=o._resizeFrameObj;if("td"!==i&&"th"!==i||(e=e.closest(".smart-editor-editable table")),i=e?e.nodeName.toLowerCase():"",e&&e.parentElement&&("img"===i||"table"===i||e.classList.contains("smart-editor-video-container"))&&"false"!==a.getAttribute("contenteditable"))if(r?n=r.element:(r=o._resizeFrameObj={},n=r.element=document.createElement("span"),n.classList.add("smart-editor-resize-frame"),n.innerHTML='<span position="top-left"></span><span position="top-right"></span>\n <span position="bottom-left"></span><span position="bottom-right"></span>\n <span position="top-center"></span><span position="bottom-center"></span>\n <span position="left-center"></span><span position="right-center"></span>'),r.target&&r.target.removeAttribute("show-resize-frame"),r.target=e,e.classList.contains("smart-editor-video-container")?r.resizableElement=e.querySelector("video, iframe"):delete r.resizableElement,o._refreshToolbarTabs(),"false"!==e.getAttribute("resizable")){if(e.setAttribute("show-resize-frame",""),o._positionResizeHandles(),n.parentElement||o.$.contentContainer.appendChild(n),!t&&"img"===i){const e=o.$.iframe;(e?e.contentWindow:window).getSelection().collapse(null),o._updateToolbarItems()}}else e.removeAttribute("show-resize-frame");else{if(r){if(r.element.remove(),r.target){const e=a.querySelectorAll("[show-resize-frame]");for(let t=0,o=e.length;t<o;t+=1)e[t].removeAttribute("show-resize-frame")}delete r.target}o._refreshToolbarTabs()}}_setToast(){const e=this;let t=e.$.toast;return t||(e.$.toast=t=document.createElement("smart-toast"),t.appendTo=e.$.container,t.showCloseButton=!0,t.itemClass="smart-editor-message",e.$toast=Smart.Utilities.Extend(t)),t.rightToLeft=e.rightToLeft,t.theme=e.theme,t.animation=e.animation,t}_positionResizeHandles(){const e=this,t=e._resizeFrameObj;if(!e._resizeFrameObj)return;const o=t.element,a=e.rightToLeft,n=a?"right":"left",i=(t.resizableElement||t.target).getBoundingClientRect(),r=o.children,l=r[0],s=r[1],d=r[2],c=r[3],m=r[4],u=r[5],b=r[6],p=r[7],h=e.$.editableElement,g=e.$.contentContainer.getBoundingClientRect(),f=i.top-g.top+h.offsetTop,_=i.width,v=i.height;let w;a?(w=g.right-i.right+(h.offsetLeft+h.offsetWidth-g.width),l.style.left=d.style.left=b.style.left=""):(w=i.left-g.left+h.offsetLeft,l.style.right=d.style.right=b.style.right=""),l.style.top=s.style.top=m.style.top=f+"px",l.style[n]=d.style[n]=b.style[n]=w+"px",d.style.top=c.style.top=u.style.top=f+v+"px",s.style[n]=c.style[n]=p.style[n]=_+w+"px",m.style[n]=u.style[n]=w+_/2+"px",b.style.top=p.style.top=f+v/2+"px"}_openInlineToolbar(e){const t=this,o=t.$.editableElement;let a=t.$.inlineToolbar;if(t._closeToolbarItemDropDown(t.$.inputPopup),t._closeToolbarItemDropDown(t.$.colorInputPopup),"false"===o.getAttribute("contenteditable")||t.hideInlineToolbar)return void(a&&a.visible&&a.close());if(a||(a=t._createToolbar()),t.$.fireEvent("inlineToolbarOpening",{target:a}).defaultPrevented)return;t._setupToolbar(e,"inline"),a.parentElement||t.getShadowRootOrBody().appendChild(a);const n=t._getInlineToolbarContent(e);a.clear(),n instanceof DocumentFragment&&(a.appendChild(n),a.open(),t._setAriaOwns(a)),t._updateToolbarItems(void 0,a)}_closeToolbar(){const e=this,t=e.$.inlineToolbar;if(t){const o=t.classList,a=o.contains("smart-editor-context-menu")?"contextMenu":o.contains("smart-editor-inline-toolbar")?"inlineToolbar":"dropDownToolbar";if(e.$.fireEvent(a+"Closing",{target:t}).defaultPrevented)return;t.close()}}_closePopups(){const e=this;e._closeToolbar(),e._closeToolbarItemDropDown(e.$.inputPopup),e._closeToolbarItemDropDown(e.$.colorInputPopup)}_createToolbar(){const e=this;let t=e.$.inlineToolbar;return t||(t=document.createElement("smart-tooltip"),e.$.inlineToolbar=t,e.$inlineToolbar=Smart.Utilities.Extend(t),t)}_setupToolbar(e,t){const o=this,a=o.$.iframe,n=o.$.inlineToolbar,i=o.$inlineToolbar;if(!n.visible){const e=e=>o._tooltipVisibilityHandler.call(o,e),t=e=>o._tooltipVisibilityHandler.call(o,e),a=e=>o._tooltipChangeHandler.call(o,e),n=e=>o._tooltipClickHandler.call(o,e),r=e=>o._tooltipTransitionEndHandler.call(o,e);i.unlisten("open"),i.unlisten("close"),i.unlisten("change"),i.unlisten("click"),i.unlisten("transitionend"),i.listen("open",e),i.listen("close",t),i.listen("change",a),i.listen("click",n),i.listen("transitionend",r)}if(n.locale=o.locale,n.rightToLeft=o.rightToLeft,n.theme=o.theme,n.animation=o.animation,n.openMode="manual","inline"===t)n.position="auto",n.iframeRect=a?a.getBoundingClientRect():null,n.arrow=!0,n.align="center",n.offset=o.inlineToolbarOffset,n.classList.add("smart-editor-toolbar","smart-editor-inline-toolbar"),n.classList.remove("smart-editor-drop-down-toolbar","smart-editor-context-menu"),n.setAttribute("role","tooltip"),n.setAttribute("aria-label","Inline Toolbar");else{if("context"!==t)return n.position="auto",n.iframeRect=null,n.arrow=!1,n.align=o.rightToLeft?"right":"left",n.offset=[0,-5],n.selector=e,n.classList.add("smart-editor-toolbar","smart-editor-drop-down-toolbar"),n.classList.remove("smart-editor-inline-toolbar","smart-editor-context-menu"),n.setAttribute("role","tooltip"),void n.setAttribute("aria-label","Drop Down Toolbar");n.position="absolute",n.arrow=!1,n.classList.add("smart-editor-context-menu"),n.classList.remove("smart-editor-toolbar","smart-editor-drop-down-toolbar","smart-editor-inline-toolbar"),n.setAttribute("role","listbox"),n.setAttribute("aria-label","Context Menu")}if(n.selector&&!n.selector.closest&&delete n.selector.getBoundingClientRect,e.closest)n.selector=e;else{const t=e.parentElement,a=o._getSelectionRange();t.getBoundingClientRect=()=>a.getBoundingClientRect(),n.selector=t}}_getInlineToolbarContent(e){const t=this,o=t.$.inlineToolbar;if(o.innerHTML&&o.selector.nodeName===e.nodeName)return;let a;const n=t._toolbarItemsObj,i=e.nodeName.toLowerCase(),r=(e=[])=>{let t;for(let o=0,a=e.length;o<a;o+=1){const a=n[e[o]];if(a){t=a;break}}return t};let l;switch(i){case"a":l=r(["hyperlink","createlink"]);break;case"#text":l=r(["cut","copy","paste"]);break;case"img":l=r(["image"]);break;case"td":case"th":l=r(["table"]);break;default:return}return a=l&&Array.isArray(l.inlineToolbarItems)?l.inlineToolbarItems:t._getDefaultInlineToolbarItems(e,i),a.length?t._getToolbarItems(o,a):void 0}_getDefaultInlineToolbarItems(e,t){let o;switch(t){case"a":o=["openlink","editlink","removelink"];break;case"#text":o=["cut","copy","paste"];break;case"img":o=["image","alignment","createlink","delete","caption"],e.closest(".smart-editor-editable a")&&o.splice(o.indexOf("createlink")+1,0,"openlink","removelink");break;case"td":case"th":o=["table","tableheader","tablerows","tablecolumns","backgroundcolor","delete","alignment","tablevalign","tablestyle"];break;default:return[]}return o}_getNodes(e,t=0,o,a=0){const n=this,i=e.childNodes;let r=[];for(let e=0,l=i.length;e<l;e+=1){const l=i[e];if(l.childElementCount){const e=n._getNodes(l,t,o,a);if(a=e.index,e.nodes.length&&(r=r.concat(e.nodes)),a>=o)break}else if(l.nodeType===Node.TEXT_NODE){const e=l.nodeValue;if(!e.trim())continue;const n=e.length;if(a+n>t&&r.push({node:l,index:o-a,startIndex:Math.max(0,t-a)}),(a+=n)>o)break}else if((a+=(l.textContent||l.innerText||l.innerHTML).length)>t&&r.push({node:l,index:a}),a>o)break}return{nodes:r,index:a}}_tooltipChangeHandler(e){const t=this,o=e.target,a=t.$.inlineToolbar;a&&a.classList.contains("smart-editor-drop-down-toolbar")&&a.visible&&a.contains(o)?o.classList.contains("smart-table-picker")&&(t._handleTableInsert({cells:e.detail.value}),a.close()):t._changeHandler(e)}_tooltipClickHandler(e){const t=this,o=e.target,a=t.$.inlineToolbar;if(a&&a.classList.contains("smart-editor-drop-down-toolbar")&&a.contains(e.target)&&o.closest(".smart-table-picker-button")){const e=t._getSelectionRange();let o;return e.startContainer&&["th","td"].indexOf(e.startContainer.nodeName.toLowerCase())>-1&&(o=e.startContainer.closest(".smart-editor-editable table")),void t._openWindow(a.selector,o)}if(a&&a.classList.contains("smart-editor-context-menu")){const a=o.closest(".smart-editor-context-menu-item");if(a)return void t._handleContextMenuItemClick(e,a)}}_tooltipVisibilityHandler(e){const t=this,o=t.$.inlineToolbar,a=e.type;if(e.target!==o)return;const n=t.$.inlineToolbar,i=t.$inlineToolbar;let r;r=o.classList.contains("smart-editor-toolbar")?(o.classList.contains("smart-editor-drop-down-toolbar")?"inline":"dropDown")+"Toolbar":"contextMenu",e.stopPropagation(),"close"===e.type?(n.selector&&!n.selector.closest&&delete n.selector.getBoundingClientRect,n.hasAnimation||(i.unlisten(e.type),i.unlisten("change"),i.unlisten("click"),n.remove(),t._focusEditableElement()),t._setAriaOwns(o)):"open"===e.type&&t._setAriaOwns(o),t.$.fireEvent(r+a.slice(0,1).toUpperCase()+a.slice(1),Object.assign({target:e.target},e.detail))}_tooltipTransitionEndHandler(e){const t=this;if(!(e.target instanceof Smart.Tooltip))return;const o=t.$.inlineToolbar,a=t.$inlineToolbar;o.visible||(a.unlisten("transitionend"),o.style.top=o.style.left=0,o.remove(),t._setAriaOwns(o))}_toggleItemDropDown(e){const t=this,o=e.getAttribute("item-type");let a;if("drop-down"===o?(t.$.inputPopup||(t.$.inputPopup=document.createElement("smart-input")),a=t.$.inputPopup):"color-input"===o&&(t.$.colorInputPopup||(t.$.colorInputPopup=document.createElement("smart-color-input")),a=t.$.colorInputPopup),a.noRipple=!0,t.$.inputPopup&&a===t.$.colorInputPopup&&t.$.inputPopup.parentElement?t._closeToolbarItemDropDown(t.$.inputPopup):t.$.colorInputPopup&&a===t.$.inputPopup&&t.$.colorInputPopup.parentElement&&t._closeToolbarItemDropDown(t.$.colorInputPopup),a)if(a.locale=t.locale,a.rightToLeft=t.rightToLeft,a.theme=t.theme,a.animation=t.animation,e.contains(a)&&a.opened)t._closeToolbarItemDropDown(a);else{const o=t.$.inlineToolbar;o&&!o.contains(e)&&t._closeToolbar(),a.remove(),t._openToolbarItemDropDown(e,a)}}_toggleDropDownToolbar(e){const t=this;if(!e)return;if("table"!==e.getAttribute("item-name"))return;const o=t.$.inlineToolbar;if(o&&o.visible&&o.classList.contains("smart-editor-drop-down-toolbar")){if(o.contains(e)){const o=t._getSelectionRange();let a;return o.startContainer&&["th","td"].indexOf(o.startContainer.nodeName.toLowerCase())>-1&&(a=o.startContainer.closest(".smart-editor-editable table")),void t._openWindow(e,a)}o.classList.contains("smart-editor-drop-down-toolbar")&&o.close()}else t._closeToolbarItemDropDown(t.$.inputPopup),t._closeToolbarItemDropDown(t.$.colorInputPopup),t._openDropDownToolbar(e)}_openDropDownToolbar(e){const t=this;let o=t.$.inlineToolbar;o||(o=t._createToolbar()),t.$.fireEvent("dropDownToolbarOpening",{target:o}).defaultPrevented||(t._setupToolbar(e,"dropDown"),o.parentElement||t.getShadowRootOrBody().appendChild(o),t._setDropDownToolbarContent(e),o.open(),t._setAriaControls(e,o))}_setDropDownToolbarContent(e){const t=this,o=t.$.inlineToolbar,a=e.getAttribute("item-name");let n=t._dropDownToolbarObj;n||(n=t._dropDownToolbarObj={});let i=n[a];i||(i=document.createElement("smart-table-picker"),n[a]=i),i.rightToLeft=t.rightToLeft,i.locale=t.locale,i.messages=t.messages,i.value=[],o.contains(i)||(o.clear(),o.appendChild(i))}_openSearchBar(){const e=this,t=e.$.editableElement,o=e.$.contentContainer;let a=e._searchToolbar;if(e.disableSearchBar||t.classList.contains("smart-hidden"))return void(a&&a.remove());a||(a=e._searchToolbar=document.createElement("div"),a.classList.add("smart-editor-search-bar"),a.innerHTML='<span class="smart-search-input-container">\n <input class="smart-search-input"></input>\n </span>\n <smart-button class="smart-search-button prev"></smart-button>\n <smart-button class="smart-search-button next"></smart-button>\n <smart-button class="smart-search-button close"></smart-button>'),a.ontransitionend=null;const n=e.animation,i=e.theme,r=e.rightToLeft,l=a.children;let s;for(let t=0,o=l.length;t<o;t+=1){const o=l[t];if(o.classList.contains("smart-search-input-container")){const t=o.firstElementChild;t.placeholder=e.localize("searchPlaceholder"),s=t}o.animation=n,o.theme=i,o.rightToLeft=r}if(o.contains(a)||o.appendChild(a),a.classList.remove("smart-visibility-hidden"),s){const t=e.$.iframe,o=(t?t.contentWindow:window).getSelection().toString();s.value=o,s.focus({preventScroll:!0}),o&&e._applySearching(o)}delete e._lastSearchQuery}_closeSearchToolbar(){const e=this,t=e._searchToolbar;if(t&&!t.classList.contains("smart-visibility-hidden")){t.classList.add("smart-visibility-hidden"),t.ontransitionend=()=>{t.remove(),t.ontransitionend=null};const o=Array.from(e.$.editableElement.querySelectorAll(".find-and-replace-match"));for(let e=0,t=o.length;e<t;e+=1){const t=o[e];t.outerHTML=t.textContent}e._focusEditableElement()}}_toggleWindow(e,t){const o=this;if(!e)return;const a=e.getAttribute("item-name"),n=o.$.window;if(!n)return void o._openWindow(e,t);const i=n._target?n._target.item:void 0;!i||i.name!==a||i.name===a&&!n.opened?o._openWindow(e,t):n.close()}_openWindow(e,t){const o=this;if(!e||!o._toolbarItemsObj||o._window&&o._window.opened)return;let a;t&&t.classList.contains("smart-editor-video-container")&&(t=t.querySelector(".smart-editor-video-container > video, .smart-editor-video-container > iframe"));const n=o.$.editableElement;if(e.closest){if(!e.classList.contains("smart-editor-toolbar-item"))return;a=(e.closest(".smart-editor-inline-toolbar")?o._inlineToolbarItemsObj:o._toolbarItemsObj)[e.getAttribute("item-name")]}else"object"==typeof e&&"string"==typeof e.name&&(a=e);if(!a||"findandreplace"===a.name&&n.classList.contains("smart-hidden"))return;const i=o._createWindow(a);o.$.fireEvent("dialogOpening",{target:i,item:a}).defaultPrevented||(o._closeToolbarItemDropDown(o.$.inputPopup),o._closeToolbarItemDropDown(o.$.colorInputPopup),i._target={item:a,itemTarget:t,originalTarget:e},o._closeToolbar(),i.parentElement||o.getShadowRootOrBody().appendChild(i),i.isCompleted?o._setupWindow():i.whenReady((()=>o._setupWindow())))}_closeWindow(){const e=this,t=e.$.window;t&&t.opened&&(e.$.fireEvent("dialogClosing",{target:t,item:t._target.item}).defaultPrevented||t.close())}_setupWindow(){const e=this,t=e.$.window,o=t._target,a=o.item;function n(){e._positionWindow(),t.opened?(t.bringToFront(),t._handleActiveState(),t._onOpenCallback&&t._onOpenCallback()):t.open()}if(t.locale=e.locale,t.rightToLeft=e.rightToLeft,t.theme=e.theme,t.animation=e.animation,e.windowCustomizationFunction?e.windowCustomizationFunction(t,a):(e._setPopupWindowTemplate("header",a),e._setPopupWindowTemplate("footer",a),e._setPopupWindowTemplate("content",a)),!t.opened){const o=e.$window,a=t=>e._windowOpenHandler.call(e,t),n=t=>e._windowCloseHandler.call(e,t),i=t=>e._windowClickHandler.call(e,t),r=t=>e._windowChangeHandler.call(e,t),l=t=>e._windowKeyDownHandler.call(e,t),s=t=>e._windowKeyUpHandler.call(e,t),d=t=>e._windowTransitionendHandler.call(e,t),c=t=>e._fileUploadCompletedHandler.call(e,t),m=t=>e._fileUploadErrorHandler.call(e,t);o.unlisten("transitionend"),o.unlisten("open"),o.unlisten("close"),o.unlisten("click"),o.unlisten("change"),o.unlisten("keydown"),o.unlisten("keyup"),o.unlisten("uploadCompleted"),o.unlisten("uploadError"),t._onOpenCallback=()=>{((t.shadowRoot||t).querySelector(".smart-editor-window-editor:not(.smart-hidden) .smart-input.smart-element")||t).focus({preventScroll:!0})},t.hasAnimation&&o.listen("transitionend",d),o.listen("open",a),o.listen("close",n),o.listen("click",i),o.listen("change",r),o.listen("keydown",l),o.listen("keyup",s),o.listen("uploadCompleted",c),o.listen("uploadError",m)}t.shadowRoot?e._onShadowDomLoaded(t,"smart.window.css",n):n(),e._setAriaOwns(t),e._setAriaControls(o.originalTarget,t)}_setPopupWindowTemplate(e,t){const o=this,a=o.$.window;if(!a)return;if("content"===e)return void o._setWindowContent(t);a[e+"Template"]||(a[e+"Template"]=o._createWindowTemplate(e));const n=a._target.item;if("header"===e)a.label=o.localize(n.name)||"";else if("footer"===e){const e=(a.shadowRoot||a).querySelectorAll(".smart-editor-window-button"),n="findandreplace"===t.name;for(let t=0;t<e.length;t++){const a=e[t];a.innerHTML='<span class="smart-icon"></span>',a.theme=o.theme,a.rightToLeft=o.rightToLeft,a.animation=o.animation,a.classList.contains("ok")?n?(a.classList.add("replace"),a.innerHTML+=o.localize("replace"),a.setAttribute("aria-label","replace")):(a.classList.remove("replace"),a.innerHTML+=o.localize("ok"),a.setAttribute("aria-label","ok")):a.classList.contains("cancel")?(a.innerHTML+=o.localize("cancel"),a.setAttribute("aria-label","cancel")):n?(a.classList.contains("replace-all")&&(a.innerHTML+=o.localize("replaceAll"),a.setAttribute("aria-label","replaceAll")),a.classList.remove("smart-hidden")):a.classList.add("smart-hidden");const i=a.querySelector(".smart-ripple");i&&i.parentElement.removeChild(i)}}}_setWindowContent(e){const t=this,o=t.$.window,a=o._target.originalTarget,n=[].slice.call(o.getElementsByClassName("smart-editor-window-editor"));if((!o.innerHTML||n.length)&&a){switch(e.name){case"createlink":case"editlink":case"hyperlink":case"image":case"video":case"table":case"paste":case"findandreplace":t._createWindowEditors(e)}a.id&&o.setAttribute("aria-controls",a.id)}}_createWindowEditors(e){const t=this,o=t.$.window,a=e.name;let n,i=t._windowEditors,r=o.querySelector(".smart-editor-window-content-wrapper");r||(r=document.createElement("div"),r.classList.add("smart-editor-window-content-wrapper"),o.appendChild(r)),t._windowEditors||(i=t._windowEditors={}),i&&(n=i[a]),n||(n=document.createElement("div"),n.classList.add(`smart-editor-window-${a}`),n.innerHTML=t._getWindowEditorTemplate(a),i[a]=n),r.contains(n)||(r.innerHTML="",r.appendChild(n));const l=n.querySelectorAll(".smart-editor-window-editor[type]");for(let e=0;e<l.length;e++)t._setPopupWindowEditor(l[e])}_getWindowEditorTemplate(e){switch(e){case"createlink":case"editlink":case"hyperlink":return'\n <div class="smart-editor-window-editor" type="address">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="text">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="title">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="target">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>';case"image":return'\n <div class="smart-editor-window-editor" type="file">\n <smart-file-upload item-editor></smart-file-upload>\n </div>\n <div class="smart-editor-window-editor" type="url">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="width">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="height">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="alt">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="title">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="caption">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="display">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="alignment">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="draggable">\n <smart-check-box item-editor></smart-check-box>\n </div>\n <div class="smart-editor-window-editor" type="resizable">\n <smart-check-box item-editor></smart-check-box>\n </div>';case"table":return'\n <div class="smart-editor-window-editor" type="cols">\n <label></label>\n <smart-number-input item-editor></smart-number-input>\n </div>\n <div class="smart-editor-window-editor" type="rows">\n <label></label>\n <smart-number-input item-editor></smart-number-input>\n </div>\n <div class="smart-editor-window-editor" type="width">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="height">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="tableheader">\n <smart-check-box item-editor></smart-check-box>\n </div>\n <div class="smart-editor-window-editor" type="altrows">\n <smart-check-box item-editor></smart-check-box>\n </div>\n <div class="smart-editor-window-editor" type="dashedborders">\n <smart-check-box item-editor></smart-check-box>\n </div>\n <div class="smart-editor-window-editor" type="resizable">\n <smart-check-box item-editor></smart-check-box>\n </div>';case"paste":return'\n <div class="smart-editor-window-editor" type="keepFormat">\n <label></label>\n <smart-radio-button checked group-name="editorPasteViaWindow" item-editor></smart-radio-button>\n </div>\n <div class="smart-editor-window-editor" type="cleanFormat">\n <smart-radio-button group-name="editorPasteViaWindow" item-editor></smart-radio-button>\n </div>\n <div class="smart-editor-window-editor" type="plainText">\n <smart-radio-button group-name="editorPasteViaWindow" item-editor></smart-radio-button>\n </div>';case"findandreplace":return'\n <div class="smart-editor-window-editor" type="find">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="replaceWith">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="results">\n <label></label>\n <smart-list-box virtualized item-editor></smart-list-box>\n </div>\n <div class="smart-editor-window-editor" type="matchCase">\n <smart-check-box item-editor></smart-check-box>\n </div>';case"video":return'\n <div class="smart-editor-window-editor" type="file">\n <smart-file-upload item-editor></smart-file-upload>\n </div>\n <div class="smart-editor-window-editor" type="src">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="width">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="height">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="thumbnail">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="videoUrl">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="alt">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="title">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="caption">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="display">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="alignment">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="draggable">\n <smart-check-box item-editor></smart-check-box>\n </div>\n <div class="smart-editor-window-editor" type="resizable">\n <smart-check-box item-editor></smart-check-box>\n </div>';default:return""}}_setPopupWindowEditor(e){const t=this,o=e.getAttribute("type"),a=e.querySelector("label"),n=t.$.window._target,i=n.item,r="markdown"===t.editMode,l=i.editor;let s,d=e.querySelector("[item-editor]");if(a&&("paste"===i.name?(a.id=t.id+"pasteLabel",a.innerHTML=t.localize("pasteLabel")||""):(a.id=t.id+o+"Label",a.innerHTML=t.localize(o)||"")),!d)return;const c=t._toolbarItemClick;let m;switch(m=c?c.target:n.itemTarget,i.name){case"hyperlink":case"createlink":case"editlink":{const a=t._getSelectionRange();let n=a.startContainer;n&&"a"!==n.nodeName.toLowerCase()&&(n=n.parentElement),n&&"a"===n.nodeName.toLowerCase()?"address"===o?s=n.getAttribute("href"):"text"===o?s=n.textContent:"title"===o?s=n.title:"target"===o&&(s=n.target):s="text"===o?r?t.$.input.value.slice(a.selectionStart,a.selectionEnd):a.toString():l&&void 0!==l[o]?l[o]+"":"","target"===o&&r||m&&"img"===m.nodeName.toLowerCase()&&["title","text"].indexOf(o)>-1?e.classList.add("smart-hidden"):e.classList.remove("smart-hidden");break}case"video":case"image":{const a=t._toolbarItemClick,d=a?a.target:n.itemTarget;if(d&&["img","video","iframe"].indexOf(d.nodeName.toLowerCase())>-1){const e=d.closest(".smart-editor-image-container");switch(o){case"file":d.file instanceof File&&(s=d.file);break;case"url":case"src":s=d.file instanceof File?"":d.getAttribute("src")||"";break;case"alt":s=d.alt;break;case"title":s=d.title;break;case"width":if(s=d.style.width||(e?e.style.width:""),!s){const e=d.getAttribute("width");e&&(s=e)}break;case"height":if(s=d.style.height||(e?e.style.height:""),!s){const e=d.getAttribute("height");e&&(s=e)}break;case"caption":if(e){const t=e.querySelector(".smart-editor-image-caption");t&&(s=t.textContent)}void 0===s&&(s="");break;case"alignment":s=(e||d).getAttribute("alignment")||"";break;case"display":s=(e||d).getAttribute("display")||"";break;case"draggable":case"resizable":{const t=("video"===i.name?e:d).getAttribute(o);s=null==t||"true"===t;break}}}else s=l?("draggable"===o||"resizable"===o)&&void 0===l[o]||(void 0!==l[o]?l[o]+"":""):"width"===o?480:"height"===o?270:"draggable"===o||"resizable"===o||"";r&&["file","url","videoUrl","alt","title","thumbnail"].indexOf(o)<0||!r&&"video"===i.name&&["alt","thumbnail","videoUrl"].indexOf(o)>-1?e.classList.add("smart-hidden"):e.classList.remove("smart-hidden");break}case"table":{const t=n.itemTarget&&"table"===n.itemTarget.nodeName.toLowerCase()?n.itemTarget:void 0;switch(o){case"width":case"height":s=t?t.style[o]:l&&void 0!==l[o]?l[o]:"";break;case"cols":s=t?t.querySelector("tbody > tr").children.length+"":l&&void 0!==l[o]?l[o]:"1";break;case"rows":s=t?t.querySelectorAll("tbody > tr").length+"":l&&void 0!==l[o]?l[o]:"1";break;case"tableheader":s=!!r||(t?null!==t.querySelector("thead"):!(!l||void 0===l[o])&&l[o]);break;case"altrows":s=t?t.hasAttribute("alternation"):!(!l||void 0===l[o])&&l[o];break;case"dashedborders":s=t?t.hasAttribute("dashed-borders"):!(!l||void 0===l[o])&&l[o];break;case"resizable":s=t?!("false"===t.getAttribute("resizable")):!l||void 0===l[o]||l[o]}r&&["cols","rows","tableheader"].indexOf(o)<0?e.classList.add("smart-hidden"):e.classList.remove("smart-hidden");break}case"paste":s=o===t.pasteFormat;break;case"findandreplace":s=l&&void 0!==l[o]?l[o]:""}t._setupEditorElement(d,o,s),t._setEditorCommonProperties(d)}_setupEditorElement(e,t,o){const a=this,n=a.$.window._target.item,i=n.editor,r="markdown"===a.editMode;if((e instanceof Smart.CheckBox||e instanceof Smart.RadioButton)&&(e.innerHTML=a.localize(t)||"",e.checked=!!o),e instanceof Smart.NumberInput)e.min=1,e.value=parseInt(o);else{if(e instanceof Smart.FileUpload)return"file"===t&&e.isCompleted&&(e.cancelAll(),o&&e.addFile(o)),e.uploadUrl="",e.removeUrl="",e.autoUpload=!1,a.postData?e.postData=a.postData:a.getAttribute("post-data")&&(e.postData=JSON.parse(a.getAttribute("post-data"))),a.uploadUrl&&(e.uploadUrl=a.uploadUrl,a._fileUpload=e,a._fileUpload.name=a.imageName,e.autoUpload=a.autoUpload),a.removeUrl&&(e.removeUrl=a.removeUrl),a.validateFile&&(e.validateFile=a.validateFile),i&&(i.uploadUrl&&(e.uploadUrl=i.uploadUrl,e.autoUpload=!0),i.removeUrl&&(e.removeUrl=i.removeUrl)),e.dropZone=e.parentElement,e.accept=n.allowedTypes||(r||"video"!==n.name?"image/*":"video/mp4,video/x-m4v,video/*"),void(e.hideFooter=!0);if(e instanceof Smart.ListBox)e.selectionMode="one",e.itemHeight=35;else{if("string"==typeof e.placeholder&&(e.placeholder=a.localize(t+"Placeholder")||""),e.dropDownClassList&&(e.dropDownClassList=["smart-editor-input"]),void 0!==e.dataSource){if("target"===t||"alignment"===t||"display"===t){e.dataSource.length||(e.dataSource=a._getDefaultDataSource(t)),"alignment"!==t||o||(o="center");const n=o?e.dataSource.find((e=>"object"==typeof e&&e.value===o)):void 0;n&&"object"==typeof n&&(o=n.label||o),e.readonly=!n&&!o||n&&""!==n.value}else e.dataSource=[];"string"==typeof e.dropDownButtonPosition&&(e.dropDownButtonPosition=e.dataSource.length?a.rightToLeft?"left":"right":"none")}e.value=void 0===o?"":o+""}}}_setEditorCommonProperties(e){const t=this;if(e){const o=e.messages,a=t.messages,n=t.locale;for(let e in o.en){const t=a[n][e];void 0!==t&&(o[n]||(o[n]={}),o[n][e]=t)}e.locale=t.locale,e.rightToLeft=t.rightToLeft,e.animation=t.animation,e.theme=t.theme}}_createWindow(){const e=this,t=e.$.window;if(t)return t;const o=document.createElement("smart-window");return o.classList.add("smart-editor-window"),o.id=e.id+"Window",o.setAttribute("smart-id","window"),e.$.window=o,e.$window=Smart.Utilities.Extend(o),o.rightToLeft=e.rightToLeft,o.theme=e.theme,o.animation=e.animation,o.disableSnap=!0,o.headerButtons=["close"],o}_createWindowTemplate(e){const t=this,o=t.animation,a=t.theme,n=t.rightToLeft;let i;return"footer"===e&&(i=document.createElement("template"),i.innerHTML=`<smart-button class="smart-editor-window-button primary replace replace-all smart-hidden"\n animation="${o}" theme="${a}" ${n?"right-to-left":""}>\n </smart-button>\n <smart-button class="smart-editor-window-button ok primary"\n animation="${o}" theme="${a}" ${n?"right-to-left":""}>\n </smart-button>\n <smart-button class="smart-editor-window-button cancel"\n animation="${o}" theme="${a}" ${n?"right-to-left":""}>\n </smart-button>`),i}_positionWindow(){const e=this,t=e.getShadowRootOrBody(),o=e.$.window;if(!o||!t.contains(o))return;const a=e.getBoundingClientRect();o.opened||(o.style.left=o.style.top=""),o.style.left=Math.max(a.left+window.pageXOffset,a.left+window.pageXOffset+a.width/2-o.offsetWidth/2)+"px",o.style.top=Math.max(a.top+window.pageYOffset,a.top+window.pageYOffset+a.height/2-o.offsetHeight/2)+"px"}_windowChangeHandler(e){const t=this,o=e.detail,a=t.$.window._target.item;let n=(e.originalEvent||e).target;const i=n.closest(".smart-editor-window-editor");if(!n.hasAttribute("item-editor")||!a||!i)return;const r=i.getAttribute("type");if(a.name.indexOf("link")>0&&"target"===r&&n instanceof Smart.Input)n.readonly=!!o.value.length;else if(t._windowEditors&&a.name.indexOf("findandreplace")>-1)if("results"===r&&n instanceof Smart.ListBox)t._handleMarkerSelection(e.target);else if("matchCase"===r&&n instanceof Smart.CheckBox){const e=i.parentElement.querySelector('.smart-editor-window-editor[type="find"] [item-editor]');e&&t._findMatches(e.value)}}_windowClickHandler(e){const t=this;let o=(e.originalEvent||e).target;o.shadowRoot&&(o=(e.originalEvent||e).composedPath()[0]);const a=t.$.window,n=a._target,i=o.closest(".smart-editor-window-button");if(a&&i&&n){if("findandreplace"===n.item.name){const e=i.classList,o=i.classList.contains("replace-all");if(o||e.contains("ok"))return void t._replaceMatches(a._target.item,o)}else if(i.classList.contains("ok")&&!1===t._updateEditorViaWindow(n.item))return;a.close(),delete a._target}}_windowCloseHandler(e){const t=this,o=e.target;if(!o.classList.contains("smart-editor-window"))return;const a=t.$window;if(a){t.$.fireEvent("dialogClose",{target:e.target,item:e.target._target.item}),a.unlisten("close"),a.unlisten("click"),a.unlisten("change"),a.unlisten("keydown"),a.unlisten("uploadCompleted"),a.unlisten("uploadError"),t.hasAttribute("aria-owns")&&t.removeAttribute("aria-owns"),t.hasAnimation||(o.remove(),t._setAriaOwns(o));const n=o._target,i=n.itemTarget;if("findandreplace"===n.item.name&&t._findMatches(""),t._focusEditableElement(),i&&["img","th","td","table"].indexOf(i.nodeName.toLowerCase())>-1)return void t._setResizeFrame(i)}}_windowKeyDownHandler(e){const t=this,o=t.$.window;if("Enter"!==e.key||!o._target)return;const a=o._target.item,n=o.getRootNode().activeElement;if(a&&n.closest(".smart-editor-window-editor")){if(!1===t._updateEditorViaWindow(a))return;e.stopPropagation(),e.preventDefault(),o.close(),delete o._target}}_windowKeyUpHandler(e){const t=this,o=e.target;if(o.closest('.smart-editor-window-editor[type="find"]')){const e=o.closest("[item-editor]");if(e){const o=t.findAndReplaceTimeout;if(clearTimeout(t._findAndReplaceTimeout),"html"!==t.editMode)return;o?t._findAndReplaceTimeout=setTimeout((()=>t._findMatches(e.value)),o):t._findMatches(e.value)}}}_windowOpenHandler(e){const t=this,o=e.target;if(!o.classList.contains("smart-editor-window"))return;const a=t.$window;if(a){const n=o._target.item;if(t._setAriaOwns(o),t.$.fireEvent("dialogOpen",{target:e.target,item:n}),a.unlisten("open"),"findandreplace"===n.name){const e=o.querySelector('.smart-editor-window-editor[type="find"] [item-editor]');t._findMatches(e?e.value:"")}}}_windowTransitionendHandler(e){const t=this,o=e.target;o.classList.contains("smart-editor-window")&&(o.opened||"visibility"!==e.propertyName||(t.$window.unlisten("transitionend"),t.$.window.remove(),t._setAriaOwns(o)))}_updateEditorViaWindow(e){const t=this;if(!e||!t._windowEditors)return;const o=t.$.iframe,a=t.$.editableElement;let n,i;t.$.contentContainer.contains(a.getRootNode().activeElement)||t._focusEditableElement(),o?(n=o.contentWindow,i=n.getSelection()):(n=window,i=window.getSelection());const r=t._windowEditors[e.name],l=t._getSelectionRange();let s;if(r&&!t.$.fireEvent("actionStart",{name:e.name}).defaultPrevented){switch(l instanceof n.Range&&(i.removeAllRanges(),i.addRange(l)),e.name){case"editlink":case"createlink":case"hyperlink":s=t._handleLinksInsert(e);break;case"image":s=t._handleImageInsert(e);break;case"table":t._handleTableInsert(t._getItemOptionsViaWindow(e));break;case"paste":t._handlePasteViaWindow(e);break;case"video":s=t._handleVideoInsert(e)}return t.$.fireEvent("actionEnd",{name:e.name}),s?(s(),!1):void 0}}_focusFirstInputCallback(e,t){const o=this._windowEditors[e];if(o)return()=>{const e=o.querySelector(`.smart-editor-window-editor[type="${t}"] .smart-input[item-editor]`);e&&e.focus({preventScroll:!0})}}_fileUploadCompletedHandler(e){const t=this.$.window;let o;t&&t.opened&&t._target&&(o=t._target.item),e.stopPropagation(),this.$.fireEvent("imageUploadSuccess",Object.assign({target:e.target,toolbarItem:o},e.detail));const a=e.detail.fileURL,n=e.detail.serverResponse,i=t.querySelector('[type="url"] [item-editor]');a?(i.value=a,i._details=e.detail):n&&(Array.isArray(n)?e.detail.serverResponse[0].file_url?i.value=e.detail.serverResponse[0].file_url:e.detail.serverResponse[0].fileURL&&(i.value=e.detail.serverResponse[0].fileURL):e.detail.serverResponse.file_url?i.value=e.detail.serverResponse.file_url:e.detail.serverResponse.fileURL&&(i.value=e.detail.serverResponse.fileURL))}_fileUploadErrorHandler(e){const t=this.$.window;let o;t&&t.opened&&t._target&&(o=t._target.item),e.stopPropagation(),this.$.fireEvent("imageUploadFailed",Object.assign({target:e.target,toolbarItem:o},e.detail))}_replaceMatches(e,t){const o=this,a=o.$.editableElement;if(!e||!o._windowEditors||"html"!==o.editMode||a.classList.contains("smart-hidden"))return;const n=o._getItemOptionsViaWindow(e),i=o._windowEditors[e.name],r=i.querySelector('.smart-editor-window-editor[type="results"] smart-list-box[item-editor]'),l=i.querySelector('.smart-editor-window-editor[type="results"] label'),s=r.selectedIndexes;if(!n||!s||!s.length)return;const d=n.replaceWith,c=Array.from(a.querySelectorAll(".find-and-replace-match"));for(let e=0,o=c.length;e<o;e+=1){const o=c[e];(t||s.indexOf(e)>-1)&&(o.outerHTML=d)}t?r.dataSource=[]:s.forEach((e=>r.removeAt(e))),o._setFindAndReplaceLabel(l,r)}_findMatches(e){const t=this,o=t.$.editableElement,a=t._windowEditors,n=a?a.findandreplace:void 0,i=n.querySelector('.smart-editor-window-editor[type="results"] smart-list-box[item-editor]'),r=n.querySelector('.smart-editor-window-editor[type="results"] label'),l=n.querySelector('.smart-editor-window-editor[type="matchCase"] smart-check-box[item-editor]'),s=t.$.window.querySelectorAll(".smart-editor-window-button.replace");i&&"smart-list-box"===i.nodeName.toLowerCase()&&(i.dataSource=[]),t._findAndReplaceTimeout&&(clearTimeout(t._findAndReplaceTimeout),delete t._findAndReplaceTimeout);const d=Array.from(o.querySelectorAll(".find-and-replace-match"));for(let e=0,t=d.length;e<t;e+=1){const t=d[e];t.outerHTML=t.textContent}if("html"===t.editMode)if(e){i.dataSource=t._getFindMarkers(o,new RegExp(e,"gm"+(l.checked?"":"i")),[]),i.select("0"),t._setFindAndReplaceLabel(r,i);for(let e=0,t=s.length;e<t;e+=1)s[e].disabled=!1}else{t._setFindAndReplaceLabel(r);for(let e=0,t=s.length;e<t;e+=1)s[e].disabled=!0}}_clearSearchToolbar(){const e=this,t=e._searchToolbar;t&&!t.classList.contains("smart-visibility-hidden")&&(t.value="",delete e._lastSearchQuery)}_applySearching(e){const t=this,o=t.$.editableElement;if(t._lastSearchQuery===e||o.classList.contains("smart-hidden"))return;const a=t.$.contentContainer.querySelector(".smart-search-input-container");let n;t._findAndReplaceTimeout&&(clearTimeout(t._findAndReplaceTimeout),delete t._findAndReplaceTimeout);const i=Array.from(o.querySelectorAll(".find-and-replace-match"));for(let e=0,t=i.length;e<t;e+=1){const t=i[e];t.outerHTML=t.textContent}if("html"===t.editMode){if(e){n=t._getFindMarkers(o,new RegExp(e,"gmi"),[]).length;const a=o.querySelector(".find-and-replace-match");a&&(a.classList.add("selected"),t._scrollToMarker(a))}a&&(a.setAttribute("matches",n||0),a.setAttribute("selected",n?1:0)),t._lastSearchQuery=e}}_scrollToMarker(e){const t=this,o=t._searchToolbar,a=o&&!t._searchToolbar.classList.contains("smart-visibility-hidden")?o.offsetHeight:0,n=t.$.editableElement,i=n.getBoundingClientRect(),r=e.getBoundingClientRect(),l=n.scrollLeft,s=n.scrollTop,d=i.height,c=i.width,m=r.height,u=r.width,b=r.top-i.top+s,p=r.left-i.left+l;s+a>b||l>p?n.scrollTo(p-c,b-a-10):(s+d<b+m||l+c<p+u)&&n.scrollTo(p+u-c,b+m-d)}_setFindAndReplaceLabel(e,t){if(!e)return;const o=t?t.items.length:0;if(!t||!o)return e.removeAttribute("matches"),void e.removeAttribute("selected");if(e){const a=t.selectedIndexes[0];e.setAttribute("matches",o),e.setAttribute("selected",a?a+1:1)}}_getFindMarkers(e,t,o){const a=this,n=Array.from(e.childNodes);for(let e=0,i=n.length;e<i;e+=1){const i=n[e];if(i.childElementCount)a._getFindMarkers(i,t,o);else if(i.textContent){const e=document.createDocumentFragment(),a=i.textContent;let n,r=0;if(a.matchAll)n=Array.from(a.matchAll(t));else{let e;for(n=[];e=t.exec(a);)n.push(e)}if(n.forEach((t=>{const a=t.input,n=t.index,i=t[0],l=a.substring(r,n),s=o.length,d=document.createElement("span");l.length&&e.appendChild(document.createTextNode(l)),d.classList.add("find-and-replace-match"),d.setAttribute("match-id",s),d.textContent=i,e.appendChild(d);const c=a.substring(Math.max(0,n-10),n),m=a.substr(n+i.length,10);o.push({label:`${n>0?"...":""}${c}<b>${i}</b>${m}${n<a.length-1?"...":""}`,value:s}),r=n+i.length})),!e.childElementCount)continue;const l=i.textContent.substr(r);l&&e.appendChild(document.createTextNode(l)),i.nodeType===Node.TEXT_NODE?(i.parentElement.insertBefore(e,i),i.remove()):(i.innerHTML="",i.appendChild(e))}}return o}_handleMarkerSelection(e){const t=this,o=e.selectedValues[0],a=t.$.editableElement.querySelectorAll(`.find-and-replace-match.selected, .find-and-replace-match[match-id="${o}"]`);let n;for(let e=0,t=a.length;e<t;e+=1){const t=a[e];t.getAttribute("match-id")===o?(t.classList.add("selected"),n=t):t.classList.remove("selected")}n&&t._scrollToMarker(n);const i=t._windowEditors,r=i?i.findandreplace:void 0,l=r?r.querySelector('.smart-editor-window-editor[type="results"] label'):void 0;if(l){const t=e.selectedIndexes;l.setAttribute("selected",t.length?t[0]+1:0)}}_handleImageInsert(e){const t=this,o=t._getItemOptionsViaWindow(e),a=t.$.window;if(!a)return;let n,i,r,l,s,d=a._target.itemTarget;if(o.file.length?(l=o.file[0],n=URL.createObjectURL(l)):o.url&&(n=o.url+""),!n&&o)return t._focusFirstInputCallback(e.name,"url");if("markdown"===t.editMode)return i=o.title?` "${o.title}"`:"",void t._insertMarkDown(``);const c=t.$.iframe,m=t.$.editableElement,u=c?c.contentDocument:document;if(!d||"img"!==d.nodeName.toLowerCase()){const e=t.id+"newImage"+Math.random().toString(36).substr(2,5);s=u.execCommand("insertHTML",!1,`<img id="${e}"></img>`),d=m.querySelector("#"+e)}if(d&&"img"===d.nodeName.toLowerCase()){const e="inline"===o.display.toLowerCase()?"inline":"block",a=o.width+"",i=o.height+"";if(t._handleImgCaption(d,o),s&&(d.id=""),URL.revokeObjectURL(d.src),d.src=n,l&&(d.file=l,"base64"===t.imageFormat)){const e=new FileReader;e.readAsDataURL(l),e.onload=()=>d.src=e.result}if(t.uploadUrl&&t._fileUpload&&(d.name=n.replace(t.uploadUrl+"/",""),!t.autoUpload)){const e=e=>{t.$.fireEvent("imageUploadSuccess",e.detail);const o=e.detail.fileURL,a=e.detail.serverResponse;o?d.src=o:a&&(Array.isArray(a)?e.detail.serverResponse[0].file_url?d.src=e.detail.serverResponse[0].file_url:e.detail.serverResponse[0].fileURL&&(d.src=e.detail.serverResponse[0].fileURL):e.detail.serverResponse.file_url?d.src=e.detail.serverResponse.file_url:e.detail.serverResponse.fileURL&&(d.src=e.detail.serverResponse.fileURL))};t._fileUpload.onuploadcompleted=e,t._fileUpload.onuploaderror=e=>{console.error(e.detail)},t._fileUpload.uploadAll()}if(d.removeAttribute("width"),d.removeAttribute("height"),d.style.width=a&&"auto"!==a?parseFloat(a)+(a.indexOf("%")>-1?"%":"px"):"",d.style.height=i&&"auto"!==i?parseFloat(i)+(i.indexOf("%")>-1?"%":"px"):"",o.alt&&(d.alt=o.alt),o.title&&(d.title=o.title),o.alignment){const e=o.alignment.toLowerCase();r=e.indexOf("left")>-1?"left":e.indexOf("right")>-1?"right":"center"}d.setAttribute("resizable",o.resizable),d.setAttribute("draggable",o.draggable);const c=d.closest(".smart-editor-image-container");c?(c.setAttribute("alignment",r),c.setAttribute("display",e),d.removeAttribute("alignment"),d.removeAttribute("display")):(d.setAttribute("alignment",r),d.setAttribute("display",e))}}_handleVideoInsert(e){const t=this,o=t._getItemOptionsViaWindow(e),a=t.$.window;if(!a)return;let n,i,r,l,s=a._target.itemTarget;if(o.file.length?(r=o.file[0],n=URL.createObjectURL(r),s&&"video"!==s.nodeName.toLowerCase()&&(s.remove(),s=void 0)):(o.src||o.videoUrl)&&(n=(o.src||o.videoUrl)+"",s&&"iframe"!==s.nodeName.toLowerCase()&&(s.remove(),s=void 0)),s&&s.file&&(r=s.file),!n&&!r&&o)return t._focusFirstInputCallback(e.name,"src");if("markdown"===t.editMode)return i=o.title?` "${o.title}"`:"",void t._insertMarkDown(`[](${o.videoUrl} ${i})`);const d=t.$.iframe,c=t.$.editableElement,m=d?d.contentDocument:document;if(!r||s&&"video"===s.nodeName.toLowerCase()){if(!(r||s&&"iframe"===s.nodeName.toLowerCase())){const e=t.id+"newVideo"+Math.random().toString(36).substr(2,5);l=m.execCommand("insertHTML",!1,`<iframe id="${e}" frameborder="0" allowfullscreen></iframe>`),s=c.querySelector("#"+e)}}else{const e=t.id+"newVideo"+Math.random().toString(36).substr(2,5);l=m.execCommand("insertHTML",!1,`<video id="${e}"></video>`),s=c.querySelector("#"+e)}if(s){if(l&&s.removeAttribute("id"),URL.revokeObjectURL(s.src),s.controls=!0,s.frameborder=0,s.allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",t._handleVideoCaption(s,o),void 0!==o.width){const e=o.width+"";s.style.width=e?e+(e.indexOf("%")<0?"px":""):""}if(void 0!==o.height){const e=o.height+"";s.style.height=e?e+(e.indexOf("%")<0?"px":""):""}if(r){if(s.file===r)return;if(s.file=r,"base64"===t.imageFormat){const e=new FileReader;e.readAsDataURL(r),e.onload=()=>s.src=e.result}}else s.src!==n&&(s.src=n)}}_insertMarkDown(e,t,o){const a=this;if("markdown"!==a.editMode)return;const n=a.$.input,i=a._getSelectionRange(),r=i.selectionStart,l=i.selectionEnd;let s,d=n.value;if(void 0!==r&&r!==l&&(s=d.slice(r,l)),o){let t=d.lastIndexOf("\n",r-1)+1;for(;" "===d[t+1];)t++;n.value=d.slice(0,t)+e+d.slice(t)}else n.value=d.slice(0,n.selectionStart)+e+d.slice(n.selectionEnd);void 0!==r&&(void 0===t&&(t=r+e.length),s?o?a._setSelectionRange(n,r+e.length,l+e.length):(d=n.value,n.value=d.slice(0,t)+s+d.slice(t),a._setSelectionRange(n,t,t+s.length)):a._setSelectionRange(n,t,t)),a._refreshMarkdownPreview()}_removeMarkDown(e,t,o){const a=this,n=a.$.input,i=n.value,r=a._getSelectionRange(),l=r.selectionStart,s=r.selectionEnd,d=e.length;n.value=i.slice(0,t)+i.slice(t+d),a._setSelectionRange(n,l-d,s-d),o||a._refreshMarkdownPreview()}_handleLinksInsert(e){const t=this,o=t.$.window,a=t.editMode,n=t._getItemOptionsViaWindow(e);if(!n.address)return t._focusFirstInputCallback(e.name,"address");if("markdown"===a){let e;return e=n.title?`[${n.text}](${n.address}, "${n.title}")`:`[${n.text}](${n.address})`,void t._insertMarkDown(e)}const i=t.$.iframe,[r,l]=i?[i.contentDocument,i.contentWindow]:[document,window],s=l.getSelection();let d,c,m=s.anchorNode?s.anchorNode.parentElement:void 0,u=o&&o._target?o._target.itemTarget:void 0;u&&"img"===u.nodeName.toLowerCase()?(d=o._target.itemTarget,m=d.parentElement,m&&"a"===m.nodeName.toLowerCase()||(m=document.createElement("a"),d.parentElement.insertBefore(m,d),m.appendChild(d))):m=s.anchorNode?s.anchorNode.parentElement:void 0,n.address&&"a"!==m.nodeName.toLowerCase()&&(c=r.execCommand("createLink",!1,n.address),m=s.anchorNode.parentElement),"a"===m.nodeName.toLowerCase()&&(n.address?c||m.setAttribute("href",n.address):m.setAttribute("href",""),n.text?m.textContent=n.text:m.innerHTML||(m.textContent=n.address||""),m.title=n.title||"",m.target=n.target||"",d||s.selectAllChildren(m))}_refreshMarkdownPreview(){const e=this,t=e.$.input;if(e.$.contentContainer.hasAttribute("split-mode")){let o=t.value;e.$.editableElement.innerHTML=window.marked?window.marked(o):o}}_handleImgCaption(e,t){const o=this;if(!t)return;let a,n=e.closest(".smart-editor-image-container");const i=e.nodeName.toLowerCase(),r="video"===i||"iframe"===i&&e.src.indexOf("/embed")>-1;if(t.caption||r){if(n||(n=document.createElement("span"),n.classList.add("smart-editor-image-container"),n.setAttribute("draggable",!1),n.setAttribute("contenteditable",!1),e.hasAttribute("alignment")&&n.setAttribute("alignment",e.getAttribute("alignment")),e.hasAttribute("display")&&n.setAttribute("display",e.getAttribute("display")),e.parentElement.insertBefore(n,e),n.appendChild(e)),n.classList[r?"add":"remove"]("smart-editor-video-container"),a=n.querySelector(".smart-editor-image-caption"),a||(a=document.createElement("span"),a.setAttribute("contenteditable",!0),a.classList.add("smart-editor-image-caption"),n.appendChild(a)),a.textContent=t.caption,t.focusCaption)return delete o._toolbarItemClick,o._setSelectionRange(a),o._setResizeFrame(),void o.$.editableElement.scrollTo(a.offsetLeft,a.offsetTop)}else!t.caption&&n&&(n.hasAttribute("alignment")&&e.setAttribute("alignment",n.getAttribute("alignment")),n.hasAttribute("display")&&e.setAttribute("display",n.getAttribute("display")),n.parentElement.insertBefore(e,n),n.remove());o._resizeFrameObj&&o._resizeFrameObj.target&&o._setResizeFrame(o._resizeFrameObj.target,!0)}_handleVideoCaption(e,t){const o=this,a=e?e.nodeName.toLowerCase():void 0;if(!t||"video"!==a&&"iframe"!==a)return;let n=e.closest(".smart-editor-video-container");if(n||(n=document.createElement("span"),n.classList.add("smart-editor-image-container","smart-editor-video-container"),n.setAttribute("contenteditable",!1),e.parentElement.insertBefore(n,e),n.appendChild(e)),n.setAttribute("resizable",t.resizable),!1===t.draggable?n.setAttribute("draggable",!1):n.removeAttribute("draggable"),t.title&&(e.title=t.title),t.alignment){let e=t.alignment.toLowerCase();e=e.indexOf("left")>-1?"left":e.indexOf("right")>-1?"right":"center",n.setAttribute("alignment",e)}if(t.display){const e="inline"===t.display.toLowerCase()?"inline":"block";n.setAttribute("display",e)}if(t.caption){let e=n.querySelector(".smart-editor-image-caption");if(e||(e=document.createElement("span"),e.setAttribute("contenteditable",!0),e.classList.add("smart-editor-image-caption"),n.appendChild(e)),e.textContent=t.caption,t.focusCaption)return delete o._toolbarItemClick,o._setSelectionRange(e),o._setResizeFrame(),void o.$.editableElement.scrollTo(e.offsetLeft,e.offsetTop)}else if(!t.caption){let e=n.querySelector(".smart-editor-image-caption");e&&e.remove()}o._resizeFrameObj&&o._resizeFrameObj.target&&o._setResizeFrame(o._resizeFrameObj.target,!0)}_handleTableInsert(e){const t=this,o=t.editMode;if(!e)return;if("markdown"===o)return void t._insertTableMarkdown(e);const a=t._getSelectionRange();let n,i,r,l;if(e.cells){const t=e.cells;[r,l]=[t[1],t[0]]}else{let t=a.startContainer;[r,l]=[parseInt(e.cols),parseInt(e.rows)],t.nodeType===Node.TEXT_NODE&&(t=t.parentElement),n=t&&t.closest&&t.closest(".smart-editor-editable table")}if(!n){const e=t.$.editableElement,o=t.$.iframe,r=(o?o.contentWindow:window).getSelection();r.removeAllRanges(),r.addRange(a);const l=t.id+"newTable"+Math.random().toString(36).substr(2,5);i=(o?o.contentDocument:document).execCommand("insertHTML",!1,`<table id="${l}"><tbody></tbody></table>`),n=e.querySelector("#"+l)}if(n&&"table"===n.nodeName.toLowerCase()){let o,a=n.querySelector("tbody");for(a?o=Array.from(a.children):(n.innerHTML="<tbody></tbody>",a=n.firstElementChild,o=[]);o.length>l;)o.pop().remove();for(let e=o.length,t=l;e<t;e+=1)o.push(document.createElement("tr"));for(let e=0,t=o.length;e<t;e+=1){const t=o[e],n=Array.from(t.children);for(;n.length>r;)n.pop().remove();for(let e=0,o=r;e<o;e+=1){let o=n[e];o||(o=t.appendChild(document.createElement("td")))}t.parentElement||a.appendChild(t)}void 0===e.tableheader?e.tableheader=!!n.querySelector("th"):void 0===e.altrows?e.altrows=n.hasAttribute("alternation"):void 0===e.dashedborders?e.dashedborders=n.hasAttribute("dashed-borders"):void 0===e.resizable&&(e.resizable="false"!==n.getAttribute("resizable")),t._handleTableHeader(n,e.tableheader),e.altrows?n.setAttribute("alternation",""):n.removeAttribute("alternation"),e.dashedborders?n.setAttribute("dashed-borders",""):n.removeAttribute("dashed-borders");const s=e.width,d=e.height;n.style.width=s?s+(s.indexOf("%")<0?"px":""):"",n.style.height=d?d+(d.indexOf("%")<0?"px":""):"",i&&n.removeAttribute("id"),n.setAttribute("aria-rowcount",l),n.setAttribute("aria-colcount",r),n.setAttribute("resizable",e.resizable)}t._setResizeFrame(n)}_insertTableMarkdown(e){const t=this,o=e.cells,[a,n]=o?[o[1],o[0]]:[parseInt(e.cols),parseInt(e.rows)],i=t.localize("alphabet"),r=t.localize("header"),l=t.localize("column");let s="";if(!1!==e.tableheader){let e="",t=Math.max(3,r.length)+3;for(;t>0;)e+="-",t--;for(let e=1;e<=a;e+=1)s+=`| ${r} ${e} `;s+="|\n";for(let t=0;t<a;t++)s+=`|${e} `;s+="|\n"}for(let e=0;e<n;e++){const t=i[Math.max(0,e-1)%i.length].toUpperCase();for(let e=1;e<=a;e+=1)s+=`| ${l} ${t} ${e} `;s+="|\n"}t._insertMarkDown(s)}_handleTableSelection(e){const t=this,o=t.$.editableElement;if(t._tableCell&&t._tableCell.removeAttribute("selected"),"false"!==o.getAttribute("contenteditable"))return e&&["th","td"].indexOf(e.nodeName.toLowerCase())>-1?(t._tableCell=e,void e.setAttribute("selected","")):void delete t._tableCell}_getItemOptionsViaWindow(e){const t=this._windowEditors[e.name];if(!t)return;const o=t.children;let a={};for(let e=0,t=o.length;e<t;e+=1){const t=o[e].getAttribute("type"),n=o[e].querySelector("[item-editor]");let i;if(t){if(n instanceof Smart.Input)if(void 0===n.$.input.dataValue&&n.dataSource&&n.dataSource.length){const e=n.dataSource[0];i="string"==typeof e?e:e.value||e.label}else i=n.$.input.dataValue||n.value;else n instanceof Smart.CheckBox||n instanceof Smart.RadioButton?i=n.checked:n instanceof Smart.FileUpload?i=n.value:n instanceof Smart.ListBox&&(i=n.selectedIndexes);a[t]=i}}return a}_closeToolbarItemDropDown(e){const t=this,o=()=>{e.opened||e.remove()};e&&(e.opened?(e.hasAnimation&&(e.removeEventListener("transitionend",o),e.addEventListener("transitionend",o,{once:!0})),e.close(),t._setAriaOwns(e)):o())}_openToolbarItemDropDown(e,t){const o=this,a=e.getBoundingClientRect();o._setupDropDown(e,t),t.style.width=a.width+"px",t.style.height=a.height+"px",e.contains(t)||e.appendChild(t),t.open(),o._setAriaOwns(t),o._setAriaControls(e,t)}_setupDropDown(e,t){const o=this,a=o.$.inlineToolbar,n=a&&a.contains(e)?o._inlineToolbarItemsObj:o._toolbarItemsObj,i=n?n[e.getAttribute("item-name")]:void 0;let r;if(i&&(r=i.dataSource),r||(r=[]),t instanceof Smart.ColorInput?t.dropDownClassList=["smart-editor-color-input"]:(t.dropDownClassList=["smart-editor-input"],t.dropDownHeight=310),t.classList.add("smart-editor-item-drop-down"),t.readonly=!0,t.dataSource=r,t.dropDownOpenMode="manual",t.dropDownButtonPosition=o.rightToLeft?"left":"right",void 0!==i.value){const e=i.name;t.value=e.indexOf("table")>-1||e.indexOf("paste")>-1?"":i.value+""}else t.value=""}_toggleToolbar(e){const t=this,o=t.$.toolbar,a=t.$.contentContainer,n=t.toolbarViewMode,i="toggle"===n,r=t.$.toolbarToggleButton,l=t.$.toolbarItemsPrimary,s=t.hasAnimation;o.style.transition=s&&i?"none":"",o.style.height="";const d=o.offsetHeight,c=a.offsetHeight;if(e&&"toggle"===n){if(r.removeAttribute("checked"),r.setAttribute("aria-pressed",!1),!o.hasAttribute("expanded"))return void(o.style.transition="");o.removeAttribute("expanded")}else{if(r.setAttribute("checked",""),r.setAttribute("aria-pressed",!0),o.hasAttribute("expanded"))return o.style.transition="",void(t.$.toolbarItemsSecondary.innerHTML&&t._refreshToolbarItems());"scroll"!==n?o.setAttribute("expanded",""):o.removeAttribute("expanded")}if(t._refreshToolbarItems(),"menu"!==t.toolbarMode)return void(o.hasAttribute("expanded")?(l.querySelector(".smart-editor-toolbar-tab[checked]")||t._selectToolbarTab(l.firstElementChild),t._toggleSecondaryToolbar(!0)):(t._selectToolbarTab(null),t._toggleSecondaryToolbar()));if(!i)return;const m=o.offsetHeight,u=t.$.inlineToolbar;u&&u.visible&&u.reposition(),t._resizeFrameObj&&t._setResizeFrame(t._resizeFrameObj.target),o.style.height=d+"px",a.style.height=c+"px",s?requestAnimationFrame((()=>{o.style.transition="",o.style.height=m+"px",a.style.height=c+d-m+"px",requestAnimationFrame((()=>o.style.height=a.style.height=""))})):(o.style.transition="",o.style.height=m+"px",a.style.height=c+d-m+"px",requestAnimationFrame((()=>o.style.height=a.style.height="")))}_predefPropertyGetter(e="value"){const t=this;Object.defineProperty(t,e,{get:function(){return t.context===t?t.properties[e].value:t._getCurrentValue()},set(o){t._properties[e].value=t._getCurrentValue(),t.updateProperty(t,t._properties[e],o)}})}_getCurrentValue(){const e=this;if("markdown"===e.editMode)return e.$.input.value;let t=e.$.editableElement.innerHTML;return e.enableHtmlEncode&&(t=t.replaceAll("<","<").replaceAll(">",">")),t}_getInputValue(e,t){const o=this.$.input;return void 0===e&&(e=o.value),e=!t&&this.enableHtmlEncode?e.replaceAll("<","<").replaceAll(">",">"):e.replaceAll("<","<").replaceAll(">",">")}_handleEditMode(e){const t=this,o=t.$.input,a=t.$.editableElement,n=t.editMode,i=t._toolbarItemsObj.sourcecode,r=!!i&&i.value;t._closePopups(),"html"===e?r?o.value=a.innerHTML:a.innerHTML=o.value:"markdown"===e&&(r?a.innerHTML=window.marked?window.marked(o.value):o.value:o.value=a.textContent,t._closeSearchToolbar()),t.$.contentContainer.hasAttribute("split-mode")||("markdown"===n?r?(o.classList.add("smart-hidden"),a.classList.remove("smart-hidden")):(o.classList.remove("smart-hidden"),a.classList.add("smart-hidden")):r?(o.classList.remove("smart-hidden"),a.classList.add("smart-hidden")):(o.classList.add("smart-hidden"),a.classList.remove("smart-hidden"))),t.readonly||t.disableEditing||t.$.editableElement.setAttribute("contenteditable","markdown"!==n)}_handleInputContent(e,t){const o=this,a=o.$.editableElement,n=o.$.input,i=o.editMode;if(!o.isRendered&&o.autoLoad){const e=window.localStorage.getItem("smartEditor"+o.id);e&&o.set("value",e)}const r=o.value;void 0===t&&r&&(t=r),void 0!==t?"html"===i?o.$.editableElement.innerHTML=t:o.$.input.value=t:t||"markdown"!==i||(o.$.input.value=o.$.editableElement.textContent),o.$.contentContainer.hasAttribute("split-mode")?"markdown"===i?a.innerHTML=window.marked?window.marked(n.value):n.value:n.value=a.innerHTML.trim():o.classList.contains("preview-mode")&&("markdown"===i?a.innerHTML=window.marked?window.marked(n.value):n.value:n.value=a.innerHTML),a.textContent.length&&a.innerText.length?(a.removeAttribute("show-placeholder"),o._handleContentFiltering()):a.setAttribute("show-placeholder",""),o._clearSearchToolbar()}_sanitize(e,t){return this.sanitized?t.replaceAll(/(<[\/]?script[>]?)|([on].*=['"`]?.*['"`]?)|(SRC=['"`]?javascript:['"`]?)/gim,""):t}_handleContentFiltering(){const e=this,t=e.contentFiltering;if("html"===!e.editMode)return;const o=t.tags.map((e=>e.trim())),a=t.attributes.map((e=>e.trim())),n=t.styleAttributes.map((e=>e.trim()));if(!o.length&&!a.length&&!n.length)return;const i=t.tagFilterMode,r=t.attributeFilterMode,l=t.styleAttributeFilterMode;let s=e.$.editableElement.innerHTML;if(o.length){const e=new RegExp(/<\s*\/?\s*([a-z0-9]+).*?>/,"gmi");let t,a=[];for(;null!==(t=e.exec(s));){const e=t[1],n=o.indexOf(e)>-1;(n&&"blackList"===i||!n&&"whiteList"===i)&&a.push(t[0])}a.forEach((e=>s=s.replace(e,"")))}e.$.editableElement.innerHTML=s;const d=e.$.editableElement.querySelectorAll("*");for(let e=0,t=d.length;e<t;e+=1){const t=d[e];if(a.length){const e=Array.from(t.attributes);for(let o=0,n=e.length;o<n;o+=1){const n=e[o].name,i=a.indexOf(n)>-1;(i&&"blackList"===r||!i&&"whiteList"===r)&&t.removeAttribute(n)}}if(n.length){const e=t.getAttribute("style");if(!e)continue;const o=e.split(";");let a=[];for(let e=0,t=o.length;e<t;e+=1){const t=o[e],i=t.indexOf(":"),r=n.indexOf(t.slice(0,i>0?i:void 0))>-1;(r&&"whiteList"===l||!r&&"blackList"===l)&&a.push(t)}o.length&&(a.length?t.setAttribute("style",a.join(";")):t.removeAttribute("style"))}}e._setCharCount()}_handleContextMenuItemClick(e,t){if(!t||!t.classList.contains("smart-editor-context-menu-item"))return;const o=this,a=o.$.inlineToolbar,n=t.getAttribute("value");if(!a)return;const i=a.selector;switch(n){case"imageProperties":o._openWindow({name:"image"},i.closest(".smart-editor-editable img"));break;case"linkProperties":o._openWindow({name:"hyperlink"});break;case"tableProperties":o._openWindow({name:"table"},i.closest(".smart-editor-editable table"));break;case"videoProperties":{const e=i.closest(".smart-editor-video-container");if(e){const t=e.querySelectorAll(".smart-editor-video-container > video, .smart-editor-video-container > iframe");o._openWindow({name:"video"},t[0]||t[1])}break}case"insertRowAfter":case"insertRowBefore":case"deleteRow":o._handleTableRows(i.closest(".smart-editor-editable table"),{value:n});break;case"insertColumnLeft":case"insertColumnRight":case"deleteColumn":o._handleTableColumns(i.closest(".smart-editor-editable table"),{value:n});break;case"deleteImage":case"deleteTable":{const e=o._resizeFrameObj?o._resizeFrameObj.target:void 0;e&&o._deleteResizeFrameTarget(e);break}case"deleteVideo":{const e=i.closest(".smart-editor-video-container");if(e){const t=o._resizeFrameObj?o._resizeFrameObj.target:void 0;if(t===e){o._deleteResizeFrameTarget(t);break}e.remove()}break}case"createLink":o._openWindow({name:"hyperlink"},i.closest(".smart-editor-editable img"));break;case"deleteLink":o._handleLinkRemove(i);break;case"copyImage":o._handleImageCopy(i.closest(".smart-editor-editable img"));break;case"cutImage":o._handleImageCut(i.closest(".smart-editor-editable img"));break;case"copyVideo":o._handleImageCopy(i.closest(".smart-editor-video-container"));break;case"cutVideo":o._handleImageCut(i.closest(".smart-editor-video-container"));break;case"copy":case"cut":case"paste":o._handleClipboardAction(n);break;case"caption":{const e=i.closest(".smart-editor-editable img");let t;if(e&&"img"===e.nodeName.toLowerCase()){const a=e.closest(".smart-editor-image-container");a&&a.querySelector(".smart-editor-image-caption")||(t=o.localize("captionPlaceholder")),o._handleImgCaption(e,{caption:t,focusCaption:!0})}else if(i.classList.contains("smart-editor-video-container")){const e=i.querySelectorAll(".smart-editor-video-container > video, .smart-editor-video-container > iframe");i.querySelector(".smart-editor-image-caption")||(t=o.localize("captionPlaceholder")),o._handleVideoCaption(e[0]||e[1],{caption:t,focusCaption:!0})}break}case"selectAll":o._selectAll()}o.$.fireEvent("contextMenuItemClick",{originalEvent:e,value:n}),o._closeContextMenu()}_handleImageCopy(e){const t=this;if(!e||"img"!==e.nodeName.toLowerCase()&&!e.classList.contains("smart-editor-video-container"))return;const o=t._createWhiteSpaceChar(e,e.classList.contains("smart-editor-video-container")?e:void 0);t._setSelectionRange(e),t.$.editableElement.getRootNode().execCommand("copy"),o&&o.remove()}_handleImageCut(e){const t=this;if(!e||"img"!==e.nodeName.toLowerCase()&&!e.classList.contains("smart-editor-video-container"))return;const o=t._createWhiteSpaceChar(e,e.classList.contains("smart-editor-video-container")?e:void 0);t._setSelectionRange(e),t.$.editableElement.getRootNode().execCommand("cut"),t._setResizeFrame(),o&&o.remove()}_createWhiteSpaceChar(e,t){if(!t)return;const o=document.createElement("span");return o.innerHTML=" ",o.classList.add("smart-editor-video-white-space"),e.appendChild(o),o}_handleInputElement(){const e=this,t=e.iframeSettings,o=e.$.contentContainer,a=e.$.container,n=e.$.editableElement,i=e.$.input,r=e.readonly,l=e.disableEditing;if(n.contentEditable=!r&&!l,i.readonly=r||l,e._handlePlaceholder(),e._closePopups(),t.enabled?e._handleIframeSettings():a.contains(o)||(a.appendChild(o),n.setAttribute("contenteditable",!0),e.$.iframe&&(e.$.iframe.remove(),e._removeIframeEventListeners(),delete e.$.iframe)),"markdown"===e.editMode){const t=e.$.editableElement;e.$.input.classList.remove("smart-hidden"),t.classList.add("smart-hidden")}}_handleToolbarMode(){const e=this,t=e.$.toolbar,o=e.$.toolbarItemsSecondary,a=e.toolbarMode;e.$.toolbarItemsPrimary.innerHTML=o.innerHTML="","menu"===a?(o.classList.remove("smart-drop-down"),o.style.top=o.style.height="",t.contains(o)||t.appendChild(o),e._refreshToolbarItems(e._getToolbarItems())):(e._setToolbarTabs(),e._setToolbarItemGroups(),e._toolbarItemsObj||(e._toolbarItemsObj={}),e._refreshToolbarItems()),e._setToolbarGroupHeight()}_setToolbarTabs(){const e=this,t=e.toolbarRibbonConfig,o=e.$.toolbarToggleButton,a=e.$.toolbarItemsPrimary,n=a.querySelectorAll(".smart-editor-toolbar-tab"),i=document.createDocumentFragment();let r;for(let o=0,a=t.length;o<a;o+=1){const a=t[o];let l=n[o];l||(l=document.createElement("div")),l.classList.add("smart-editor-toolbar-tab"),l.setAttribute("tab-name",a.name),l.textContent=e.localize(a.name),!r&&l.hasAttribute("checked")&&(r=l),r!==l&&l.removeAttribute("checked"),l.classList[a.hidden?"add":"remove"]("smart-hidden"),i.appendChild(l)}o.hasAttribute("checked")&&!r&&i.children[0].setAttribute("checked",""),a.appendChild(i)}_setToolbarItemGroups(){const e=this,t=e.toolbarRibbonConfig,o=Array.from(e.$.toolbarItemsPrimary.querySelectorAll(".smart-editor-toolbar-tab")).find((e=>e.hasAttribute("checked")));if(!t||!o)return;const a=o.getAttribute("tab-name"),n=t.find((e=>e.name===a)),i=n?n.groups:null,r=e.$.toolbarItemsSecondary,l="singleLineRibbon"===e.toolbarMode;if(r.innerHTML="",!Array.isArray(i))return;const s=r.querySelectorAll(".smart-editor-toolbar-tab-group"),d=document.createDocumentFragment();for(let t=0,o=i.length;t<o;t+=1){const o=i[t],a=o.name;let n=s[t];if(n||(n=document.createElement("div")),l)n.innerHTML="",n.appendChild(e._getToolbarItems(e.$.toolbar,o.items));else{n.innerHTML='<div class="smart-editor-tab-group-container"></div><div class="smart-editor-tab-group-label"></div>';const t=n.firstElementChild;n.lastElementChild.innerHTML=e.localize(a),t.appendChild(e._getToolbarItems(e.$.toolbar,o.items))}n.classList.add("smart-editor-toolbar-tab-group"),n.setAttribute("group-name",a),d.appendChild(n)}r.appendChild(d),r.classList.remove("smart-visibility-hidden"),e._refreshToolbarTabs()}_refreshToolbarTabs(){const e=this,t=e._resizeFrameObj,o=Array.from(e.$.toolbarItemsPrimary.children).find((e=>"layouttab"===(e.getAttribute("tab-name")||"").toLowerCase()));if(!o)return;if(!t||!t.target||"singleLineRibbon"!==e.toolbarMode)return o.classList.add("smart-hidden"),void(o.hasAttribute("checked")&&e._selectToolbarTab(e.$.toolbarItemsPrimary.firstElementChild));const a=e.$.toolbarItemsSecondary.children,n=t.target,i=n.nodeName.toLowerCase();let r,l,s;for(let e=0,t=a.length;e<t;e+=1){const t=a[e],o=t.getAttribute("group-name");"tableGroup"===o?(l=t,l.classList.add("smart-hidden")):"imageGroup"===o?(r=t,r.classList.add("smart-hidden")):"videoGroup"===o&&(s=t,s.classList.add("smart-hidden"))}"table"===i?(o.classList.remove("smart-hidden"),l&&l.classList.remove("smart-hidden")):"img"===i?(o.classList.remove("smart-hidden"),r&&r.classList.remove("smart-hidden")):n.classList.contains("smart-editor-video-container")?(o.classList.remove("smart-hidden"),s&&s.classList.remove("smart-hidden")):o.classList.add("smart-hidden")}_handlePlaceholder(){const e=this.$.editableElement,t=this.placeholder;t?e.setAttribute("placeholder",t):e.removeAttribute("placeholder")}_handleIframeSettings(){const e=this;if(!e.iframeSettings.enabled)return;let t=e.$.iframe;t||(t=e.$.iframe=document.createElement("iframe")),t.parentElement||e.$.container.appendChild(t),!t.contentWindow.marked&&window.marked&&(t.contentWindow.marked=window.marked),e._handleIframeBody(),e._handleIframeAttributes(),e._handleIframeResources()}_removeIframeEventListeners(){const e=this,t=e.$.iframe.contentDocument,o=e.$iframe;o&&(o.unlisten("down"),o.unlisten("move"),o.unlisten("up")),t.removeEventListener("dragstart",e._iframeDragStartHandler),t.removeEventListener("dragend",e._iframeDragEndHandler),t.removeEventListener("selectionchange",e._iframeSelectionChangeHandler)}_handleIframeBody(){const e=this,t=e.$.iframe.contentDocument,o=t.body;if(!o)return;let a=e.$iframe;o.classList.add("smart-editor","smart-element","smart-editor-iframe-body"),o.appendChild(e.$.contentContainer),e._updateIframeBody(),a||(a=e.$iframe=Smart.Utilities.Extend(o)),e._iframeDownHandler=t=>e._documentDownHandler.call(e,t),e._iframeMoveHandler=t=>e._documentMoveHandler.call(e,t),e._iframeUpHandler=t=>e._documentUpHandler.call(e,t),e._iframeDragStartHandler=t=>e._dragStartHandler.call(e,t),e._iframeDragEndHandler=t=>e._dragEndHandler.call(e,t),e._iframeSelectionChangeHandler=t=>e._selectionChangeHandler.call(e,t),e._removeIframeEventListeners(),a.listen("down",e._iframeDownHandler),a.listen("move",e._iframeMoveHandler),a.listen("up",e._iframeUpHandler),t.addEventListener("dragstart",e._iframeDragStartHandler),t.addEventListener("dragend",e._iframeDragEndHandler),t.addEventListener("selectionchange",e._iframeSelectionChangeHandler)}_updateIframeBody(){const e=this,t=e.$.iframe;if(!t)return;const o=t.contentDocument.body;o&&(e.rightToLeft?o.setAttribute("right-to-left",""):o.removeAttribute("right-to-left"),e.theme?o.setAttribute("theme",e.theme):o.removeAttribute("theme"),o.setAttribute("animation",e.animation))}_handleIframeAttributes(){const e=this,t=e.$.iframe,o=e.iframeSettings.attributes;if(!t)return;if(t.hasAttribute("title")||t.setAttribute("title",e.localize("iframeTitle")),!o||"object"!=typeof o)return;const a=e.$.editableElement;for(let e in o){const n=o[e];"readonly"===e?a.setAttribute("contenteditable",!n):t[e]=n}}_handleIframeResources(){const e=this.iframeSettings.resources,t=this.$.iframe;if(!t||"object"!=typeof e)return;const o=document.styleSheets,a=t.contentDocument,n=a.head,i=a.body;for(let e in o){const a=o[e],n=a.ownerNode;"text/css"===a.type&&n&&["link","style"].indexOf(n.nodeName.toLocaleLowerCase())>-1&&t.contentDocument.head.appendChild(a.ownerNode.cloneNode())}for(let t in e){const o=t,a=e[t];let r;if((o+"").indexOf("style")>-1||"link"===o?(r=document.createElement("link"),r.rel="stylesheet",r.type="text/css","string"==typeof a&&(r.href=a)):"script"===o&&(r=document.createElement("script"),r.type="text/javascript","string"==typeof a&&(r.src=a)),"object"==typeof a&&"[object Object]"===a.toString())for(let e in a)r[e]=a[e];"module"===r.type?i.appendChild(r):n.appendChild(r)}}_handleMaxCharCount(){const e=this,t=e.$.input;null!==e.maxCharCount?t.maxLength=e.maxCharCount:t.removeAttribute("maxlength")}_getToolbarItems(e,t){const o=this;e||(e=o.$.toolbar),t||(t=o.toolbarItems);const a=e===o.$.toolbar?"toolbar":"inlineToolbar",n=e.querySelectorAll(".smart-editor-toolbar-item"),i=document.createDocumentFragment();for(let e=0,r=t.length;e<r;e+=1){const r=o._getToolbarItemDetails(a,t[e]),l=r.name,s=r.type;let d=n[e];if(d?"custom"===d.getAttribute("item-type")&&(d.innerHTML=""):(d=document.createElement("div"),d.classList.add("smart-editor-toolbar-item")),"color-input"===s)d.innerHTML||(d.innerHTML=`<div class="smart-editor-item-action-button" item-name="${l}"></div>\n <div class="smart-editor-item-drop-down-button"></div>`);else if("custom"===s){const e=r.template;d.innerHTML="",e&&e.closest&&!d.contains(e)?d.appendChild(e):"string"!=typeof e||d.innerHTML?"function"==typeof e&&e(d,r):d.innerHTML=e||""}else"toggle"===s&&(r.value?(d.setAttribute("checked",""),d.setAttribute("aria-pressed",!0)):(d.removeAttribute("checked"),d.setAttribute("aria-pressed",!1)),d.innerHTML&&(d.innerHTML=""));r.disabled||"paste"===l&&o._isFireFox?(d.setAttribute("disabled",""),d.setAttribute("aria-disabled",!0)):(d.removeAttribute("disabled"),d.removeAttribute("aria-disabled")),d.setAttribute("role","delimiter"===s?"separator":"button"),"color-input"===s||"drop-down"===s?d.setAttribute("aria-haspopup",!0):d.removeAttribute("aria-haspopup"),o._setItemValue(d,r),r.title?d.setAttribute("title",r.title):d.removeAttribute("title"),d.setAttribute("item-name",l),d.setAttribute("item-type",s),d.style.width=r.width||"",i.appendChild(d)}return i}_setItemValue(e,t){const o=this;let a=t.value;e&&t&&("button"===t.type?a?(e.setAttribute("checked",""),e.setAttribute("aria-pressed",!0)):(e.removeAttribute("checked"),e.setAttribute("aria-pressed",!1)):(a||"color-input"!==t.type?["fontname","formats"].indexOf(t.name)>-1&&(a=o.localize(t.value)||t.label||t.value):a="transparent",a?(e.setAttribute("item-value",a),e.style.setProperty("--item-value",a)):(e.removeAttribute("item-value"),e.style.removeProperty("--item-value"))))}_refreshToolbarItems(e){const t=this,o=t.$.toolbar,a=t.$.toolbarToggleButton,n=t.$.toolbarItemsPrimary,i=t.$.toolbarItemsSecondary;if("menu"===t.toolbarMode){if(n.scrollTop=n.scrollLeft=0,e)n.appendChild(e);else{const e=Array.from(i.children),t=document.createDocumentFragment(),o=e.length;for(let a=0;a<o;a+=1)t.appendChild(e[a]);o>0&&n.appendChild(t)}if("toggle"===t.toolbarViewMode){const e=n.offsetHeight;if(o.hasAttribute("expanded")){let t=[];e:for(;n.scrollHeight>e;){const e=n.lastElementChild;if(!e)break e;t.push(e),e.remove()}t.reverse();for(let e=0,o=t.length;e<o;e+=1)i.appendChild(t[e])}else n.scrollHeight===e&&a.classList.add("smart-visibility-hidden")}}else a.classList.remove("smart-visibility-hidden")}_resizeHandler(e){const t=this,o=t.$.inlineToolbar;if(e.target===t){if("toggle"===t.toolbarViewMode){const e=t.$.toolbarItemsPrimary,o=t.$.toolbarItemsSecondary;t.$.toolbar.hasAttribute("expanded")&&t._refreshToolbarItems();const a=t.$.toolbarToggleButton;e.scrollHeight!==e.offsetHeight||o.children.length?a.classList.remove("smart-visibility-hidden"):a.classList.add("smart-visibility-hidden")}if("menu"===t.toolbarMode||t.$.toolbarItemsSecondary.classList.contains("smart-visibility-hidden")||t._setToolbarGroupHeight(),o&&o.visible){const e=o.selector;e.classList.contains("smart-editor-toolbar-item")&&e.offsetTop>=t.$.toolbar.offsetHeight?o.close():o.reposition()}t._positionWindow(),t._resizeFrameObj&&t._setResizeFrame(t._resizeFrameObj.target)}}_setToolbarItemAttr(e,t,o){const a=this,n=a.$.toolbar,i=a.$.inlineToolbar,r=[a._toolbarItemsObj,a._inlineToolbarItemsObj];for(let a=0,l=r.length;a<l;a+=1){const l=r[a],s=l?l[e]:void 0;if(s){const a=l==l?n:i;if(s[t]=o,!a||!a.parentElement)continue;const r=a.querySelector(`.smart-editor-toolbar-item[item-name="${e}"]`);if(!r)continue;null==o||!1===o?(r.removeAttribute(t),"disabled"===t&&r.removeAttribute("aria-disabled")):(r.setAttribute(t,o),"disabled"===t&&r.setAttribute("aria-disabled",!0))}}}_setToolbarVisibility(){const e=this,t=e.$.toolbar,o=e.$.toolbarToggleButton;"toggle"!==e.toolbarViewMode||o.hasAttribute("checked")?t.setAttribute("expanded",""):t.removeAttribute("expanded")}_getToolbarItemDetails(e,t){const o=this;let a,n=o[`_${e}ItemsObj`];if(a="string"==typeof t?t:"object"==typeof t&&t.name?t.name+"":"",a=a.trim().toLowerCase(),n){if(void 0!==n[a])return n[a]}else n=o[`_${e}ItemsObj`]={};const i=n[a]={};return i.title=t.title||o.localize(a),i.name=a,i.toolbarName=e,i.advanced=!!t.advanced,i.inlineToolbarItems=t.inlineToolbarItems,o._setItemType(t,i,a),o._setItemData(t,i,a),o._setItemTemplate(t,i,a),o._setItemSpecifics(t,i,a),i}_setItemType(e,t,o){let a;if(t){switch(o){case"sourcecode":case"splitmode":case"fullscreen":a="toggle";break;case"alignment":case"fontname":case"fontsize":case"formats":case"tablerows":case"tablecolumns":case"tablevalign":case"tablestyle":a="drop-down";break;case"backgroundcolor":case"fontcolor":a="color-input";break;case"bold":case"italic":case"underline":case"strikethrough":case"delete":case"redo":case"undo":case"indent":case"outdent":case"openlink":case"editlink":case"createlink":case"removelink":case"hyperlink":case"cut":case"copy":case"image":case"video":case"lowercase":case"uppercase":case"print":case"caption":case"clearformat":case"table":case"tableheader":case"orderedlist":case"unorderedlist":case"subscript":case"superscript":case"findandreplace":a="button";break;case"paste":a=t.advanced?"drop-down":"button";break;default:a="string"==typeof e?"delimiter":"custom"}t.type=a}}_setItemData(e,t,o){const a=this;let n,i;if(!t||!e)return;const r=t.type;let l=e.width;if("drop-down"===r||"color-input"===r){if("object"==typeof e&&(n=e.dataSource,void 0!==e.value&&(i=e.value+"")),n&&Array.isArray(n)||(n=a._getDefaultDataSource(o,t)),void 0===i&&("fontsize"===t.name&&(i=parseInt(window.getComputedStyle(a.$.editableElement).fontSize)),isNaN(i)&&n.length)){const e=n[0];i=e["alignment"===o?"value":"label"]||e}o.indexOf("table")>-1&&(i="")}void 0!==l&&("number"==typeof l?l+="px":(l+="",l.includes("%")||(l=parseFloat(e.width),l=isNaN(l)?"":l+"px"))),t.dataSource=n,t.value=i,t.disabled=!!e.disabled,t.width=l}_setItemSpecifics(e,t,o){if(!t||"object"!=typeof e)return;let a=e.editor,n=t.editor;if(n||(n=t.editor={}),!a)return;let i=[],r=[];switch(o){case"createlink":case"removelink":case"hyperlink":i=["address","text","target"];break;case"image":i=["allowedTypes","uploadUrl","removeUrl","path","display"],r=["draggable","resizable"];break;case"table":i=["cols","rows","tableheader"],r=["altrows","dashedborders","resizable"]}for(let e in a){let t=a[e];void 0!==t&&(i.indexOf(e)>-1?"display"===e?t="block"===t?"block":"inline":t+="":r.indexOf(e)>-1?t=!!t:"width"!==e&&"height"!==e||"string"==typeof t||(t+="px"),n[e]=t)}}_getDefaultDataSource(e,t){const o=this;let a=[];switch(e){case"alignment":a=[{label:o.localize("alignLeft"),value:"left",icon:"editor-icon"},{label:o.localize("alignCenter"),value:"center",icon:"editor-icon"},{label:o.localize("alignRight"),value:"right",icon:"editor-icon"}],t&&"toolbar"===t.toolbarName&&a.push({label:o.localize("alignJustify"),value:"justify",icon:"editor-icon"});break;case"display":a=[{label:o.localize("displayInline"),value:"inline"},{label:o.localize("displayBlock"),value:"block"}];break;case"fontname":["segoeUi","arial","georgia","impact","tahoma","timesNewRoman","verdana"].forEach((e=>{a.push({label:o.localize(e),value:e})}));break;case"fontsize":["8","10","12","14","18","24","36"].forEach((e=>{a.push({label:e,value:e})}));break;case"formats":["p","pre","blockquote","h1","h2","h3","h4"].forEach((e=>{a.push({label:o.localize(e),value:e})}));break;case"backgroundcolor":case"fontcolor":["#000000","#FFFFFF","#D50000","#E67C73","#F4511E","#F6BF26","#33B679","#0B8043","#039BE5","#3F51B5","#7986CB","#8E24AA","#616161",""].forEach((e=>{a.push({label:e,value:e})}));break;case"paste":a=[{label:o.localize("plainText"),value:"plainText"},{label:o.localize("keepFormat"),value:"keepFormat"},{label:o.localize("cleanFormat"),value:"cleanFormat"}];break;case"target":a=[{label:o.localize("linkBlankDescr"),value:"_blank"},{label:o.localize("linkSelfDescr"),value:"_self"},{label:o.localize("linkParentDescr"),value:"_parent"},{label:o.localize("linkTopDescr"),value:"_top"},{label:o.localize("linkCustomDescr"),value:""}];break;case"tablerows":a=[{label:o.localize("insertRowBefore"),value:"insertRowBefore",icon:"editor-icon"},{label:o.localize("insertRowAfter"),value:"insertRowAfter",icon:"editor-icon"},{label:o.localize("deleteRow"),value:"deleteRow",icon:"editor-icon"}];break;case"tablecolumns":a=[{label:o.localize("insertColumnLeft"),value:"insertColumnLeft",icon:"editor-icon"},{label:o.localize("insertColumnRight"),value:"insertColumnRight",icon:"editor-icon"},{label:o.localize("deleteColumn"),value:"deleteColumn",icon:"editor-icon"}];break;case"tablevalign":a=[{label:o.localize("alignTop"),value:"top"},{label:o.localize("alignMiddle"),value:"middle"},{label:o.localize("alignBottom"),value:"bottom"}];break;case"tablestyle":a=[{label:o.localize("dashedborders"),value:"dashedborders"},{label:o.localize("altrows"),value:"altrows"}]}return a}_setItemTemplate(e,t){let o=e.template;t&&(o?(o&&o.closest?o="content"in o?document.importNode(o.content,!0):o:"function"==typeof o?o=o.bind(this):"string"==typeof o&&(o=document.getElementById(o)||o),t.template=o):delete t.template)}_setAriaSettings(){const e=this,t=e.$.input,o=e.$.editableElement;e.setAttribute("role","application"),e.setAttribute("aria-roledescription",e.localize("roleDescription")),e.$.toolbarToggleButton.setAttribute("aria-label",e.localize("toolbarButtonAriaLabel")),e.$.toolbarItemsPrimary.setAttribute("aria-label",e.localize("primaryToolbarAriaLabel")),e.$.toolbarItemsSecondary.setAttribute("aria-label",e.localize("secondaryToolbarAriaLabel")),t.setAttribute("aria-label",e.localize("inputAreaLabel")),t.id=e.id+"TextArea",o.id=e.id+"EditableElement",o.setAttribute("aria-label",e.localize("inputAriaLabel"))}_setAriaControls(e,t){const o=this;e&&e.nodeName&&(t.id||(t.id=o.id+"Popup"+Math.floor(65536*(1+Math.random())).toString(16).substring(1)),e.setAttribute("aria-controls",t.id))}_setAriaOwns(e){const t=this;if(!e)return;const o=e.id;let a=(t.getAttribute("aria-owns")||"").split(" ").filter((e=>e.length));const n=a.indexOf(o);if(n>-1){if(e.parentElement&&(e.opened||e.visible))return;a.splice(n,1)}else a.push(o);a.length?t.setAttribute("aria-owns",a.join(" ")):t.removeAttribute("aria-owns")}_setFocusable(){const e=this,t=e.$.editableElement;if(e.disabled||e.unfocusable)return void(t&&t.removeAttribute("tabindex"));const o=e.tabIndex>0?e.tabIndex:0;t&&(t.tabIndex=o)}_selectAll(){const e=this,t=e.$.input,o=e.$.editableElement;t.classList.contains("smart-hidden")||t.select(),o.classList.contains("smart-hidden")||e._setSelectionRange(o)}_selectStartHandler(e){const t=this._resizeFrameObj,o=this._inlineToolbarClickObj;(t&&t.resizeDetails||o&&o.resizeDetails)&&e.preventDefault()}_selectionChangeHandler(e){const t=this;if(t.disabled||!e.target.getSelection)return;const o=e.target.getSelection().focusNode;if(t.$.contentContainer.contains(o)){if(t._ignoreSelectionChange||o.classList&&o.classList.contains("smart-search-input"))return;t._selectionChangeFired=!0,t._setSelectionRange(),t._updateToolbarItems(),delete t._selectionChangeFired}}_selectToolbarTab(e){const t=this,o=t.$.toolbar,a=t.$.toolbarItemsPrimary,n=e&&!e.hasAttribute("checked"),i=a.querySelectorAll(".smart-editor-toolbar-tab");for(let t=0,o=i.length;t<o;t+=1){const o=i[t];e===o&&n?o.setAttribute("checked",""):o.removeAttribute("checked")}let r=t._tabSelectionBar;r||(t._tabSelectionBar=r=document.createElement("div"),r.classList.add("smart-editor-toolbar-tab-selection-bar")),r.classList.add("smart-visibility-hidden"),e&&e.hasAttribute("checked")?(o.setAttribute("toolbar-tab-selected",""),r.style.left=e.offsetLeft+"px",r.style.width=e.offsetWidth+"px",a.contains(r)||a.appendChild(r),t._setToolbarItemGroups(),requestAnimationFrame((()=>r.classList.remove("smart-visibility-hidden")))):o.removeAttribute("toolbar-tab-selected")}}),Smart("smart-table-picker",class extends Smart.BaseElement{static get properties(){return{columns:{value:10,type:"number"},messages:{extend:!0,value:{en:{buttonLabel:"Insert Table"}}},rows:{value:3,type:"number"},value:{value:[],type:"array"}}}static get listeners(){return{"tableGrid.mouseover":"_cellOver","tableGrid.mouseleave":"_cellLeave","tableGrid.click":"_cellOver"}}template(){return'<div id="container" role="presentation">\n <div id="tableGrid" class="smart-table-picker-grid" role="presentation"></div>\n <div class="smart-table-picker-separator" role="separator"></div>\n <smart-button id="tableButton" class="smart-table-picker-button" right-to-left="[[rightToLeft]]"></smart-button>\n </div>'}propertyChangedHandler(e,t,o){const a=this;switch(e){case"value":a._selectCell(o,t,!0);break;case"rows":case"columns":a._createTableGrid();break;case"messages":a._setTableButton();break;default:super.propertyChangedHandler(e,t,o)}}render(){const e=this;e._isMobile=Smart.Utilities.Core.isMobile,e._createTableGrid(),e._setTableButton(),e._setAria(),super.render()}_setAria(){this.setAttribute("role","grid")}_createTableGrid(){const e=this,t=e.$.tableGrid,o=e.columns,a=e.rows,n=t.children,i=document.createDocumentFragment();let r=n.length;for(;r>a;){const e=n[0];if(!e)break;e.remove(),r--}for(let e=r,t=a;e<t;e+=1){const e=document.createElement("div");e.setAttribute("role","row"),i.appendChild(e)}i.children.length&&t.appendChild(i);for(let e=0,t=a;e<t;e+=1){const t=n[e],a=t.children;let i=a.length;for(;i>o&&a[0];)a[0].remove(),i--;for(let e=i,a=o;e<a;e+=1){const e=document.createElement("span");e.setAttribute("role","gridcell"),e.classList.add("smart-table-picker-cell"),t.appendChild(e)}}e._selectCell(e.value)}_cellOver(e){const t=this,o=e.target;let a=[];if(!t.$.tableGrid.contains(o))return void t._selectCell(t.value);const n=o.closest(".smart-table-picker-cell");if(n){const o=n.parentElement,i=Array.from(o.children);a[0]=Math.max(0,Array.from(t.$.tableGrid.children).indexOf(o)+1),a[1]=Math.max(0,i.indexOf(n)+1),t._selectCell(a,t.value,"click"===e.type)}}_cellLeave(){this._selectCell(this.value)}_selectCell(e,t,o){const a=this,n=a.$.tableGrid,i=Array.from(n.children),r=i.length;let l=0,s=0;e&&(l=e[0]||0,s=e[1]||0);for(let e=0,t=r;e<t;e+=1){const t=i[e].children;if(l<e+1)for(let e=0,o=t.length;e<o;e+=1)t[e].removeAttribute("selected");else for(let e=0,o=t.length;e<o;e+=1)s>=e+1?t[e].setAttribute("selected",""):t[e].removeAttribute("selected")}n.setAttribute("value",l+"x"+s),o&&(void 0===t&&(t=a.value),a.set("value",[l,s]),t[0]===l&&t[1]===s||a.$.fireEvent("change",{value:e,oldValue:t}))}_setTableButton(){this.$.tableButton.innerHTML=this.localize("buttonLabel")}});
|
|
807
807
|
|
|
808
808
|
/***/ }),
|
|
809
809
|
|
|
@@ -824,21 +824,21 @@ Smart.Utilities.Assign("DataExporter",class{constructor(e,t,a,o){const l=this;e|
|
|
|
824
824
|
/***/ 5039:
|
|
825
825
|
/***/ (() => {
|
|
826
826
|
|
|
827
|
-
Smart("smart-file-upload",class extends Smart.BaseElement{static get properties(){return{accept:{value:null,type:"string?"},appendTo:{value:null,type:"any"},autoUpload:{value:!1,type:"boolean"},directory:{value:!1,type:"boolean"},dropZone:{value:null,type:"any"},hideFooter:{value:!1,type:"boolean"},itemTemplate:{value:null,type:"any"},messages:{value:{en:{browse:"Browse",uploadFile:"Upload File",cancelFile:"Cancel File",pauseFile:"Pause File",uploadAll:"Upload All",cancelAll:"Cancel All",pauseAll:"Pause All",totalFiles:"Total files: ",connectionError:"{{elementType}}: File Upload requires connection to the server.",wrongItemIndex:"{{elementType}}: There is no file with such an index in the list of uploaded files.",tooLongFileName:"{{elementType}}: File name is too long."}},type:"object",extend:!0},multiple:{value:!1,type:"boolean"},name:{value:"",type:"string"},responseHandler:{value:null,type:"function?",reflectToAttribute:!1},setHeaders:{value:null,type:"function?",reflectToAttribute:!1},showProgress:{value:!1,type:"boolean"},validateFile:{value:null,type:"function?",reflectToAttribute:!1},uploadUrl:{value:"",type:"string",reflectToAttribute:!1},removeUrl:{value:"",type:"string",reflectToAttribute:!1}}}static get listeners(){return{"browseButton.click":"browse","browseButton.focus":"_focusHandler","browseButton.blur":"_blurHandler","browseInput.change":"_browseInputChangeHandler","selectedFiles.click":"_selectedFilesClickHandler","uploadAllButton.click":"uploadAll","cancelAllButton.click":"cancelAll","pauseAllButton.click":"pauseAll","dropZone.dragenter":"_dropZoneHandler","dropZone.dragleave":"_dropZoneHandler","dropZone.dragover":"_dropZoneHandler","dropZone.drop":"_dropZoneHandler",resize:"_handleComponentsByAvailableHeight"}}_blurHandler(){this.$.fireEvent("blur")}_focusHandler(){this.$.fireEvent("focus")}static get requires(){return{"Smart.Button":"smart.button.js","Smart.ProgressBar":"smart.progressbar.js"}}static get styleUrls(){return["smart.fileupload.css"]}template(){return'<div id="container" role="presentation">\n <div id="fileUploadHeader" class="smart-file-upload-header" role="presentation">\n <smart-button class="smart-browse-button" id="browseButton" disabled="[[disabled]]" theme="[[theme]]" right-to-left="[[rightToLeft]]"></smart-button>\n <input type="file" class="smart-browse-input" id="browseInput" name="[[name]]" animation="[[animation]]" disabled="[[disabled]]" unfocusable="[[unfocusable]]" multiple="[[multiple]]" webkitdirectory="[[directory]]" mozdirectory="[[directory]]" />\n </div>\n <div id="fileUploadContainer" class="smart-file-upload-container">\n <div id="dropZone" class="smart-drop-zone" aria-label="Drag files here"></div>\n <div id="selectedFiles" class="smart-selected-files" role="list" aria-label="Selected files"></div>\n </div>\n <div id="totalFiles" class="smart-total-files smart-hidden" role="presentation">Total flies: 0</div>\n <div id="fileUploadFooter" class="smart-file-upload-footer smart-hidden"><smart-button class="smart-upload-all-button success" id="uploadAllButton" animation="[[animation]]" disabled="[[disabled]]" unfocusable="[[unfocusable]]"" theme="[[theme]]" right-to-left="[[rightToLeft]]"></smart-button><smart-button class="smart-cancel-all-button error" id="cancelAllButton" animation="[[animation]]" disabled="[[disabled]]" unfocusable="[[unfocusable]]" theme="[[theme]]" right-to-left="[[rightToLeft]]"></smart-button><smart-button class="smart-pause-all-button primary" id="pauseAllButton" animation="[[animation]]" disabled="[[disabled]]" unfocusable="[[unfocusable]]" theme="[[theme]]" right-to-left="[[rightToLeft]]"></smart-button></div>\n </div>'}propertyChangedHandler(e,t,l){const s=this;switch(super.propertyChangedHandler(e,t,l),e){case"accept":s.$.browseInput.accept=l;break;case"dropZone":case"appendTo":s._handleContainers();break;case"messages":case"locale":s._updateTextValues();break;case"multiple":s.$.browseButton.disabled=!!(!s.multiple&&s._selectedFiles.length>0||s.disabled),!l&&s._selectedFiles.length>1&&(s._selectedFiles.splice(1),s._renderSelectedFiles());break;case"itemTemplate":s._items.length>0&&(s._renderSelectedFiles(),s._handleComponentsByAvailableHeight());break;case"rightToLeft":s._items&&s._items.forEach((e=>{const t=e.querySelector("smart-progress-bar");t&&(t.rightToLeft=l),l?e.setAttribute("right-to-left",""):e.removeAttribute("right-to-left")})),l?s.$.dropZone.setAttribute("right-to-left",""):s.$.dropZone.removeAttribute("right-to-left")}}attached(){super.attached(),this._handleContainers()}detached(){super.detached();const e=this;e.$.fileUploadContainer.contains(e.$.dropZone)||e.$.fileUploadContainer.insertBefore(e.$.dropZone,e.$.fileUploadContainer.firstChild),e.$.fileUploadContainer.contains(e.$.selectedFiles)||e.$.fileUploadContainer.appendChild(e.$.selectedFiles)}ready(){super.ready();const e=this;e.$.dropZone.id||(e.$.dropZone.id=e.id+"DropZone"),e.$.selectedFiles.id||(e.$.selectedFiles.id=e.id+"SelectedFiles"),e.$.fileUploadContainer.setAttribute("aria-owns",e.$.dropZone.id+" "+e.$.selectedFiles.id),e.setAttribute("role","dialog"),e.rightToLeft?e.$.dropZone.setAttribute("right-to-left",""):e.$.dropZone.removeAttribute("right-to-left"),e._setInitialValues(),e._updateTextValues(),e._handleContainers(),e._handleComponentsByAvailableHeight()}browse(){const e=this;e.disabled||!e.multiple&&e._selectedFiles.length>0||e.$.browseInput.click()}addFile(e){const t=this,l=t.multiple;let s=t._selectedFiles;s&&(l||!s.length)&&e instanceof File&&("function"!=typeof t.validateFile||t.validateFile(e))&&(s=s.push(e),t._renderSelectedFiles([e]),t.$.browseButton.disabled=!!(!l&&s.length>0||t.disabled),t.$.browseInput.value="")}cancelAll(){const e=this;if(!e.disabled&&0!==e._items.length){for(let t=e._items.length-1;t>=0;t--)e.cancelFile(e._items[t].index);e.$.browseButton.disabled=!!(!e.multiple&&e._selectedFiles.length>0||e.disabled)}}cancelFile(e){const t=this,l=()=>{t.$.selectedFiles.removeChild(s),t._selectedFiles.splice(i,1),t._items.splice(i,1),t.$.fireEvent("uploadCanceled",{filename:s.file.name,type:s.file.type,size:s.file.size,index:s.index}),t.$.browseButton.disabled=!!(!t.multiple&&t._selectedFiles.length>0||t.disabled),0===t._selectedFiles.length&&t.$.fileUploadFooter.classList.add("smart-hidden"),t._handleComponentsByAvailableHeight()};if("number"!=typeof e||t.disabled||0===t._selectedFiles.length)return;const s=t._getFileItem(e,!0);if(!s)return void t.error(t.localize("wrongItemIndex",{elementType:t.nodeName.toLowerCase()}));const i=t._items.indexOf(s),a=t._selectedFiles[i];if(s&&s.xhr&&s.xhr.abort(),!t.removeUrl)return void l();let n=new FormData,r=new XMLHttpRequest;n.append("userfile[]",a),r.open("POST",t.removeUrl),t.setHeaders&&"function"==typeof t.setHeaders&&t.setHeaders(r,a),r.onload=function(){r.status>=200&&r.status<=299?l():t.$.fireEvent("uploadCanceledError",{filename:s.file.name,type:s.file.type,size:s.file.size,status:r.status,index:s.index})},r.onreadystatechange=function(){t.responseHandler&&"function"==typeof t.responseHandler&&t.responseHandler(r)},r.send(n)}get value(){return this._selectedFiles}get files(){return this._selectedFiles}pauseAll(){const e=this;if(!e.disabled&&0!==e._items.length)for(let t=e._items.length-1;t>=0;t--){let l=e._items[t];l.xhr&&l.xhr.abort()}}pauseFile(e){const t=this;if("number"!=typeof e&&"string"!=typeof e||t.disabled||0===t._items.length)return;const l=t._getFileItem(e,!0);l?(l.classList.remove("smart-uploading-start"),l&&l.xhr&&l.xhr.abort(),t.$.fireEvent("uploadPaused",{filename:l.file.name,type:l.file.type,size:l.file.size,index:l.index})):t.error(t.localize("wrongItemIndex",{elementType:t.nodeName.toLowerCase()}))}uploadAll(){const e=this;if(!e.disabled&&0!==e._items.length)for(let t=e._items.length-1;t>=0;t--)e._items[t].uploading||e.uploadFile(e._items[t].index)}uploadFile(e){const t=this;let l=!1;if("number"!=typeof e||t.disabled||0===t._selectedFiles.length)return;const s=t._getFileItem(e,!0);if(!s)return;let i=new FormData,a=t.showProgress?s.getElementsByTagName("smart-progress-bar")[0]:null,n=s.file;s.classList.remove("smart-pause","smart-error"),s.classList.add("smart-uploading-start"),i.append("userfile[]",n);let r=new XMLHttpRequest;r.open("POST",t.uploadUrl),t.setHeaders&&"function"==typeof t.setHeaders&&t.setHeaders(r,n),t.$.fireEvent("uploadStarted",{filename:s.file.name,type:s.file.type,size:s.file.size,index:s.index}),r.upload.onprogress=function(e){l||(l=!0,s.classList.remove("smart-uploading-start"),s.classList.add("smart-uploading"),s.uploading=!0,s.xhr=r),a&&(a.value=Math.round(e.loaded/e.total*100)),s.classList.remove("smart-pause","smart-error")},r.onabort=function(){s.classList.remove("smart-uploading-start","smart-uploading"),s.classList.add("smart-pause"),s.addEventListener("animationend",(function(){s.classList.remove("smart-pause","smart-error")}))},r.onerror=function(){s.classList.remove("smart-uploading-start","smart-uploading"),s.classList.add("smart-error"),s.addEventListener("animationend",(function(){s.classList.remove("smart-pause","smart-error")}))},r.onload=function(){if(l=!1,s.classList.remove("smart-uploading-start","smart-uploading"),r.status>=200&&r.status<=299){let e=t._items.indexOf(s);t.$.selectedFiles.removeChild(s),t._selectedFiles.splice(t._selectedFiles.indexOf(n),1),t._items.splice(e,1),t.$.browseButton.disabled=!!(!t.multiple&&t._selectedFiles.length>0||t.disabled),t.$.fireEvent("uploadCompleted",{filename:s.file.name,type:s.file.type,size:s.file.size,status:r.status,index:s.index}),0===t._selectedFiles.length&&t.$.fileUploadFooter.classList.add("smart-hidden")}else s.classList.add("smart-error"),s.classList.remove("smart-uploading"),t.$.fireEvent("uploadError",{filename:s.file.name,type:s.file.type,size:s.file.size,status:r.status,index:s.index})},r.onreadystatechange=function(){t.responseHandler&&"function"==typeof t.responseHandler&&t.responseHandler(r)},r.send(i)}_selectedFilesClickHandler(e){const t=this;if(t.disabled)return;const l=e.target,s=l.closest(".smart-item-upload-button"),i=l.closest(".smart-item-cancel-button"),a=l.closest(".smart-item-pause-button"),n=l.closest(".smart-file");s?t.uploadFile(n.index):i?t.cancelFile(n.index):a&&t.pauseFile(n.index)}_browseInputChangeHandler(){const e=this,t=e._filterNewFiles(Array.from(e.$.browseInput.files));let l=[];e.disabled||0===t.length||(l=e.validateFile&&"function"==typeof e.validateFile?t.filter((t=>!!e.validateFile(t)||(e.$.fireEvent("validationError",{filename:t.name,type:t.type,size:t.size}),!1))):t,e._selectedFiles=e._selectedFiles.concat(l),0!==e._selectedFiles.length&&(e._renderSelectedFiles(l),e.$.browseButton.disabled=!!(!e.multiple&&e._selectedFiles.length>0||e.disabled),e.$.browseInput.value="",e.autoUpload&&e.uploadAll()))}_defaultItemTemplate(e,t){const l=this,s=l.localize("uploadFile"),i=l.localize("cancelFile"),a=l.localize("pauseFile"),n=l.rightToLeft?"right-to-left ":"";return`<span id="${l.id+"File"+t+"Name"}" class="smart-item-name">${e}</span><span class="smart-item-upload-button" title="${s}" role="button" aria-label="${s}"></span><span class="smart-item-cancel-button" title="${i}" role="button" aria-label="${i}"></span><span class="smart-item-pause-button" title="${a}" role="button" aria-label="${a}"></span><smart-progress-bar ${n}aria-label="Upload progress"></smart-progress-bar>`}_dropZoneHandler(e){const t=this;if(e.preventDefault(),e.stopPropagation(),!t.disabled)if("dragenter"!==e.type&&"dragleave"!==e.type){if("drop"===e.type){if(t.$.dropZone.classList.remove("smart-drag-over"),!t.multiple&&t._selectedFiles.length>0)return;if(e.dataTransfer&&e.dataTransfer.files&&e.dataTransfer.files.length){const l=t._filterNewFiles(Array.from(e.dataTransfer.files));if(0===l.length)return;t.multiple||l.splice(1);let s=[];if(t.disabled)return;if(s=t.validateFile&&"function"==typeof t.validateFile?l.filter((e=>!!t.validateFile(e)||(t.$.fireEvent("validationError",{filename:e.name,type:e.type,size:e.size}),!1))):l,t._selectedFiles=t._selectedFiles.concat(s),0===t._selectedFiles.length)return;t._renderSelectedFiles(l)}t.$.browseButton.disabled=!!(!t.multiple&&t._selectedFiles.length>0||t.disabled)}}else"dragenter"===e.type?t.$.dropZone.classList.add("smart-drag-over"):t.$.dropZone.classList.remove("smart-drag-over")}_filterNewFiles(e){const t=this;let l=[];for(let s=0;s<e.length;s++){let i=!0;for(let l=0;l<t._selectedFiles.length;l++){const a=t._selectedFiles[l],n=e[s];if(n.name===a.name&&n.size===a.size&&n.type===a.type&&n.lastModified===a.lastModified){i=!1;break}}i&&l.push(e[s])}return l}_getFileItem(e,t){const l=this;let s=null;if(e&&("string"==typeof e||"number"==typeof e)){if(!l._items||0===l._items.length)return null;for(let i=0;i<l._items.length;i++){const a=l._items[i];(t&&a.index===parseInt(e)||a.file.name===e)&&(s=a)}return s}}_handleContainers(){const e=this,t=e._validateDOMElement(e.dropZone),l=e._validateDOMElement(e.appendTo);t?t.appendChild(e.$.dropZone):e.$.fileUploadContainer.insertBefore(e.$.dropZone,e.$.fileUploadContainer.firstChild),l?l.appendChild(e.$.selectedFiles):e.$.fileUploadContainer.appendChild(e.$.selectedFiles)}_handleItemTemplate(e,t){const l=this;let s=l.itemTemplate;if("content"in document.createElement("template")){if(!s)return l._defaultItemTemplate(e,t);if("string"==typeof s&&(s=document.getElementById(s)),null!==s&&"content"in s)return s.innerHTML.replace(/{{\w+}}/g,e);l.error(l.localize("invalidTemplate",{elementType:l.nodeName.toLowerCase(),property:"template"}))}else l.error(l.localize("htmlTemplateNotSuported",{elementType:l.nodeName.toLowerCase()}))}_renderSelectedFiles(e){const t=this,l=document.createDocumentFragment(),s=e||t._selectedFiles;e||(t._items=[],t.$.selectedFiles.innerHTML="");for(let e=0;e<s.length;e++){const i=t.directory?s[e].webkitRelativePath:s[e].name,a=document.createElement("div");t._incrementIndex++,a.className="smart-file",a.index=t._incrementIndex,a.setAttribute("item-id",t._incrementIndex),a.innerHTML=t.itemTemplate?t._handleItemTemplate(i,t._incrementIndex):t._defaultItemTemplate(i,t._incrementIndex),a.file=s[e],a.uploading=!1,a.xhr=null,a.setAttribute("role","listitem"),a.setAttribute("aria-labelledby",t.id+"File"+t._incrementIndex+"Name"),t.rightToLeft&&a.setAttribute("right-to-left",""),l.appendChild(a),t._items.push(a),t.$.fireEvent("fileSelected",{filename:s[e].name,type:s[e].type,size:s[e].size,index:a.index})}t.$.selectedFiles.appendChild(l),t.$.fileUploadFooter.classList.remove("smart-hidden"),t._handleComponentsByAvailableHeight()}_setInitialValues(){const e=this;e.$.browseInput.accept=e.accept,e._selectedFiles=[],e._items=[],e._incrementIndex=0}_updateTextValues(){const e=this,t=["browse","uploadAll","cancelAll","pauseAll"];for(let l=0;l<t.length;l++){const s=t[l],i=s+"Button";e.$[i].innerHTML=e.localize(s)}for(let t=0;t<e._selectedFiles.length;t++){const l=e._items[t];l.querySelector(".smart-item-upload-button").title=e.localize("uploadFile"),l.querySelector(".smart-item-cancel-button").title=e.localize("cancelFile"),l.querySelector(".smart-item-pause-button").title=e.localize("pauseFile")}}_validateDOMElement(e){if(e)return"string"==typeof e?document.getElementById(e):e instanceof HTMLElement?e:void 0}refresh(){this._handleComponentsByAvailableHeight()}_handleComponentsByAvailableHeight(){const e=this;if(e._calculateAvailableContainerHeight(),e._elementsAutoHeight>e.offsetHeight){if(e.$.container.classList.add("smart-overflow"),e._containerOverflows=!0,e._rowHeight){const t=parseInt(e._availableHeight/e._rowHeight);for(let l=0;l<e._items.length;l++){const s=e._items[l];l<t?s.classList.remove("smart-hidden"):s.classList.add("smart-hidden")}e._items.length>t?(e.$.totalFiles.innerHTML=e.localize("totalFiles")+e._items.length,e.$.totalFiles.classList.remove("smart-hidden")):e.$.totalFiles.classList.add("smart-hidden")}}else""===e.dropZone&&e._elementsAutoHeight<e.offsetHeight&&(e.$.container.classList.remove("smart-overflow"),e._containerOverflows=!1)}_calculateAvailableContainerHeight(){const e=this,t=window.getComputedStyle(e.$.fileUploadContainer,null),l=parseInt(t.getPropertyValue("margin-top"))+parseInt(t.getPropertyValue("margin-bottom"))+parseInt(t.getPropertyValue("padding-top"))+parseInt(t.getPropertyValue("padding-bottom")),s=e.$.container.querySelector(".smart-file"),i=e.$.fileUploadHeader.offsetHeight,a=e.$.fileUploadFooter.offsetHeight,n=e.style.height;let r=0;s&&(e._rowHeight=s.offsetHeight),e.style.height="auto",e._containerOverflows&&e.$.container.classList.remove("smart-overflow"),e._elementsAutoHeight=e.offsetHeight,e.style.height=n,e._containerOverflows&&e.$.container.classList.add("smart-overflow"),e.$.totalFiles.classList.contains("smart-hidden")&&(e.$.totalFiles.classList.remove("smart-hidden"),r=e.$.totalFiles.offsetHeight,e.$.totalFiles.classList.add("smart-hidden")),e._availableHeight=e.offsetHeight-(i+a)-l-r}});
|
|
827
|
+
Smart("smart-file-upload",class extends Smart.BaseElement{static get properties(){return{accept:{value:null,type:"string?"},appendTo:{value:null,type:"any"},autoUpload:{value:!1,type:"boolean"},directory:{value:!1,type:"boolean"},dropZone:{value:null,type:"any"},hideFooter:{value:!1,type:"boolean"},itemTemplate:{value:null,type:"any"},messages:{value:{en:{browse:"Browse",uploadFile:"Upload File",cancelFile:"Cancel File",pauseFile:"Pause File",uploadAll:"Upload All",cancelAll:"Cancel All",pauseAll:"Pause All",totalFiles:"Total files: ",connectionError:"{{elementType}}: File Upload requires connection to the server.",wrongItemIndex:"{{elementType}}: There is no file with such an index in the list of uploaded files.",tooLongFileName:"{{elementType}}: File name is too long."}},type:"object",extend:!0},multiple:{value:!1,type:"boolean"},name:{value:"userfile[]",type:"string"},postData:{value:null,type:"object"},responseHandler:{value:null,type:"function?",reflectToAttribute:!1},setHeaders:{value:null,type:"function?",reflectToAttribute:!1},showProgress:{value:!1,type:"boolean"},validateFile:{value:null,type:"function?",reflectToAttribute:!1},uploadUrl:{value:"",type:"string",reflectToAttribute:!1},removeUrl:{value:"",type:"string",reflectToAttribute:!1}}}static get listeners(){return{"browseButton.click":"browse","browseButton.focus":"_focusHandler","browseButton.blur":"_blurHandler","browseInput.change":"_browseInputChangeHandler","selectedFiles.click":"_selectedFilesClickHandler","uploadAllButton.click":"uploadAll","cancelAllButton.click":"cancelAll","pauseAllButton.click":"pauseAll","dropZone.dragenter":"_dropZoneHandler","dropZone.dragleave":"_dropZoneHandler","dropZone.dragover":"_dropZoneHandler","dropZone.drop":"_dropZoneHandler",resize:"_handleComponentsByAvailableHeight"}}_blurHandler(){this.$.fireEvent("blur")}_focusHandler(){this.$.fireEvent("focus")}static get requires(){return{"Smart.Button":"smart.button.js","Smart.ProgressBar":"smart.progressbar.js"}}static get styleUrls(){return["smart.fileupload.css"]}template(){return'<div id="container" role="presentation">\n <div id="fileUploadHeader" class="smart-file-upload-header" role="presentation">\n <smart-button class="smart-browse-button" id="browseButton" disabled="[[disabled]]" theme="[[theme]]" right-to-left="[[rightToLeft]]"></smart-button>\n <input type="file" class="smart-browse-input" id="browseInput" name="[[name]]" animation="[[animation]]" disabled="[[disabled]]" unfocusable="[[unfocusable]]" multiple="[[multiple]]" webkitdirectory="[[directory]]" mozdirectory="[[directory]]" />\n </div>\n <div id="fileUploadContainer" class="smart-file-upload-container">\n <div id="dropZone" class="smart-drop-zone" aria-label="Drag files here"></div>\n <div id="selectedFiles" class="smart-selected-files" role="list" aria-label="Selected files"></div>\n </div>\n <div id="totalFiles" class="smart-total-files smart-hidden" role="presentation">Total flies: 0</div>\n <div id="fileUploadFooter" class="smart-file-upload-footer smart-hidden"><smart-button class="smart-upload-all-button success" id="uploadAllButton" animation="[[animation]]" disabled="[[disabled]]" unfocusable="[[unfocusable]]"" theme="[[theme]]" right-to-left="[[rightToLeft]]"></smart-button><smart-button class="smart-cancel-all-button error" id="cancelAllButton" animation="[[animation]]" disabled="[[disabled]]" unfocusable="[[unfocusable]]" theme="[[theme]]" right-to-left="[[rightToLeft]]"></smart-button><smart-button class="smart-pause-all-button primary" id="pauseAllButton" animation="[[animation]]" disabled="[[disabled]]" unfocusable="[[unfocusable]]" theme="[[theme]]" right-to-left="[[rightToLeft]]"></smart-button></div>\n </div>'}propertyChangedHandler(e,t,l){const s=this;switch(super.propertyChangedHandler(e,t,l),e){case"accept":s.$.browseInput.accept=l;break;case"dropZone":case"appendTo":s._handleContainers();break;case"messages":case"locale":s._updateTextValues();break;case"multiple":s.$.browseButton.disabled=!!(!s.multiple&&s._selectedFiles.length>0||s.disabled),!l&&s._selectedFiles.length>1&&(s._selectedFiles.splice(1),s._renderSelectedFiles());break;case"itemTemplate":s._items.length>0&&(s._renderSelectedFiles(),s._handleComponentsByAvailableHeight());break;case"rightToLeft":s._items&&s._items.forEach((e=>{const t=e.querySelector("smart-progress-bar");t&&(t.rightToLeft=l),l?e.setAttribute("right-to-left",""):e.removeAttribute("right-to-left")})),l?s.$.dropZone.setAttribute("right-to-left",""):s.$.dropZone.removeAttribute("right-to-left")}}attached(){super.attached(),this._handleContainers()}detached(){super.detached();const e=this;e.$.fileUploadContainer.contains(e.$.dropZone)||e.$.fileUploadContainer.insertBefore(e.$.dropZone,e.$.fileUploadContainer.firstChild),e.$.fileUploadContainer.contains(e.$.selectedFiles)||e.$.fileUploadContainer.appendChild(e.$.selectedFiles)}ready(){super.ready();const e=this;e.$.dropZone.id||(e.$.dropZone.id=e.id+"DropZone"),e.$.selectedFiles.id||(e.$.selectedFiles.id=e.id+"SelectedFiles"),e.$.fileUploadContainer.setAttribute("aria-owns",e.$.dropZone.id+" "+e.$.selectedFiles.id),e.setAttribute("role","dialog"),e.rightToLeft?e.$.dropZone.setAttribute("right-to-left",""):e.$.dropZone.removeAttribute("right-to-left"),e._setInitialValues(),e._updateTextValues(),e._handleContainers(),e._handleComponentsByAvailableHeight()}browse(){const e=this;e.disabled||!e.multiple&&e._selectedFiles.length>0||e.$.browseInput.click()}addFile(e){const t=this,l=t.multiple;let s=t._selectedFiles;s&&(l||!s.length)&&e instanceof File&&("function"!=typeof t.validateFile||t.validateFile(e))&&(s=s.push(e),t._renderSelectedFiles([e]),t.$.browseButton.disabled=!!(!l&&s.length>0||t.disabled),t.$.browseInput.value="")}cancelAll(){const e=this;if(!e.disabled&&0!==e._items.length){for(let t=e._items.length-1;t>=0;t--)e.cancelFile(e._items[t].index);e.$.browseButton.disabled=!!(!e.multiple&&e._selectedFiles.length>0||e.disabled)}}cancelFile(e){const t=this,l=()=>{t.$.selectedFiles.removeChild(s),t._selectedFiles.splice(i,1),t._items.splice(i,1),t.$.fireEvent("uploadCanceled",{filename:s.file.name,type:s.file.type,size:s.file.size,index:s.index}),t.$.browseButton.disabled=!!(!t.multiple&&t._selectedFiles.length>0||t.disabled),0===t._selectedFiles.length&&t.$.fileUploadFooter.classList.add("smart-hidden"),t._handleComponentsByAvailableHeight()};if("number"!=typeof e||t.disabled||0===t._selectedFiles.length)return;const s=t._getFileItem(e,!0);if(!s)return void t.error(t.localize("wrongItemIndex",{elementType:t.nodeName.toLowerCase()}));const i=t._items.indexOf(s),a=t._selectedFiles[i];if(s&&s.xhr&&s.xhr.abort(),!t.removeUrl)return void l();let n=new FormData,r=new XMLHttpRequest;n.append(t.name,a),r.open("POST",t.removeUrl),t.setHeaders&&"function"==typeof t.setHeaders&&t.setHeaders(r,a),r.onload=function(){r.status>=200&&r.status<=299?l():t.$.fireEvent("uploadCanceledError",{filename:s.file.name,type:s.file.type,size:s.file.size,status:r.status,index:s.index})},r.onreadystatechange=function(){t.responseHandler&&"function"==typeof t.responseHandler&&t.responseHandler(r)},r.send(n)}get value(){return this._selectedFiles}get files(){return this._selectedFiles}pauseAll(){const e=this;if(!e.disabled&&0!==e._items.length)for(let t=e._items.length-1;t>=0;t--){let l=e._items[t];l.xhr&&l.xhr.abort()}}pauseFile(e){const t=this;if("number"!=typeof e&&"string"!=typeof e||t.disabled||0===t._items.length)return;const l=t._getFileItem(e,!0);l?(l.classList.remove("smart-uploading-start"),l&&l.xhr&&l.xhr.abort(),t.$.fireEvent("uploadPaused",{filename:l.file.name,type:l.file.type,size:l.file.size,index:l.index})):t.error(t.localize("wrongItemIndex",{elementType:t.nodeName.toLowerCase()}))}uploadAll(){const e=this;if(!e.disabled&&0!==e._items.length)for(let t=e._items.length-1;t>=0;t--)e._items[t].uploading||e.uploadFile(e._items[t].index)}uploadFile(e){const t=this;let l=!1;if("number"!=typeof e||t.disabled||0===t._selectedFiles.length)return;const s=t._getFileItem(e,!0);if(!s)return;let i=new FormData,a=t.showProgress?s.getElementsByTagName("smart-progress-bar")[0]:null,n=s.file,r="";t.postData?r=JSON.stringify(t.postData):t.getAttribute("post-data")&&(r=t.getAttribute("post-data")),r&&""!==r&&i.append("postData",r),s.classList.remove("smart-pause","smart-error"),s.classList.add("smart-uploading-start"),i.append(t.name,n);let o=new XMLHttpRequest;o.open("POST",t.uploadUrl),t.setHeaders&&"function"==typeof t.setHeaders&&t.setHeaders(o,n),t.$.fireEvent("uploadStarted",{filename:s.file.name,type:s.file.type,size:s.file.size,index:s.index}),o.upload.onprogress=function(e){l||(l=!0,s.classList.remove("smart-uploading-start"),s.classList.add("smart-uploading"),s.uploading=!0,s.xhr=o),a&&(a.value=Math.round(e.loaded/e.total*100)),s.classList.remove("smart-pause","smart-error")},o.onabort=function(){s.classList.remove("smart-uploading-start","smart-uploading"),s.classList.add("smart-pause"),s.addEventListener("animationend",(function(){s.classList.remove("smart-pause","smart-error")}))},o.onerror=function(){s.classList.remove("smart-uploading-start","smart-uploading"),s.classList.add("smart-error"),s.addEventListener("animationend",(function(){s.classList.remove("smart-pause","smart-error")}))},o.onload=function(){if(l=!1,s.classList.remove("smart-uploading-start","smart-uploading"),o.status>=200&&o.status<=299){let e=t._items.indexOf(s);t.$.selectedFiles.removeChild(s),t._selectedFiles.splice(t._selectedFiles.indexOf(n),1),t._items.splice(e,1),t.$.browseButton.disabled=!!(!t.multiple&&t._selectedFiles.length>0||t.disabled);let l=t.uploadUrl+"/"+s.file.name;o.fileURL&&(l=o.file_url);let i=!1;o.response&&("string"==typeof o.response?(i=o.response,i&&i.indexOf("[{")>=0&&(i=JSON.parse(i))):i=JSON.parse(o.response),i&&(Array.isArray(i)?i[0].file_url?l=i[0].file_url:i[0].fileURL&&(l=i[0].fileURL):i.file_url?l=i.file_url:i.fileURL&&(l=i.fileURL))),t.$.fireEvent("uploadCompleted",{filename:s.file.name,type:s.file.type,size:s.file.size,status:o.status,index:s.index,fileURL:l,serverResponse:i}),0===t._selectedFiles.length&&t.$.fileUploadFooter.classList.add("smart-hidden")}else{s.classList.add("smart-error"),s.classList.remove("smart-uploading");let e="no server response";o.response&&(e="string"==typeof o.response?o.response:JSON.parse(o.response)),t.$.fireEvent("uploadError",{filename:s.file.name,type:s.file.type,size:s.file.size,status:o.status,index:s.index,serverResponse:e})}},o.onreadystatechange=function(){t.responseHandler&&"function"==typeof t.responseHandler&&t.responseHandler(o)},o.send(i)}_selectedFilesClickHandler(e){const t=this;if(t.disabled)return;const l=e.target,s=l.closest(".smart-item-upload-button"),i=l.closest(".smart-item-cancel-button"),a=l.closest(".smart-item-pause-button"),n=l.closest(".smart-file");s?t.uploadFile(n.index):i?t.cancelFile(n.index):a&&t.pauseFile(n.index)}_browseInputChangeHandler(){const e=this,t=e._filterNewFiles(Array.from(e.$.browseInput.files));let l=[];e.disabled||0===t.length||(l=e.validateFile&&"function"==typeof e.validateFile?t.filter((t=>!!e.validateFile(t)||(e.$.fireEvent("validationError",{filename:t.name,type:t.type,size:t.size}),!1))):t,e._selectedFiles=e._selectedFiles.concat(l),0!==e._selectedFiles.length&&(e._renderSelectedFiles(l),e.$.browseButton.disabled=!!(!e.multiple&&e._selectedFiles.length>0||e.disabled),e.$.browseInput.value="",e.autoUpload&&e.uploadAll()))}_defaultItemTemplate(e,t){const l=this,s=l.localize("uploadFile"),i=l.localize("cancelFile"),a=l.localize("pauseFile"),n=l.rightToLeft?"right-to-left ":"";return`<span id="${l.id+"File"+t+"Name"}" class="smart-item-name">${e}</span><span class="smart-item-upload-button" title="${s}" role="button" aria-label="${s}"></span><span class="smart-item-cancel-button" title="${i}" role="button" aria-label="${i}"></span><span class="smart-item-pause-button" title="${a}" role="button" aria-label="${a}"></span><smart-progress-bar ${n}aria-label="Upload progress"></smart-progress-bar>`}_dropZoneHandler(e){const t=this;if(e.preventDefault(),e.stopPropagation(),!t.disabled)if("dragenter"!==e.type&&"dragleave"!==e.type){if("drop"===e.type){if(t.$.dropZone.classList.remove("smart-drag-over"),!t.multiple&&t._selectedFiles.length>0)return;if(e.dataTransfer&&e.dataTransfer.files&&e.dataTransfer.files.length){const l=t._filterNewFiles(Array.from(e.dataTransfer.files));if(0===l.length)return;t.multiple||l.splice(1);let s=[];if(t.disabled)return;if(s=t.validateFile&&"function"==typeof t.validateFile?l.filter((e=>!!t.validateFile(e)||(t.$.fireEvent("validationError",{filename:e.name,type:e.type,size:e.size}),!1))):l,t._selectedFiles=t._selectedFiles.concat(s),0===t._selectedFiles.length)return;t._renderSelectedFiles(l)}t.$.browseButton.disabled=!!(!t.multiple&&t._selectedFiles.length>0||t.disabled)}}else"dragenter"===e.type?t.$.dropZone.classList.add("smart-drag-over"):t.$.dropZone.classList.remove("smart-drag-over")}_filterNewFiles(e){const t=this;let l=[];for(let s=0;s<e.length;s++){let i=!0;for(let l=0;l<t._selectedFiles.length;l++){const a=t._selectedFiles[l],n=e[s];if(n.name===a.name&&n.size===a.size&&n.type===a.type&&n.lastModified===a.lastModified){i=!1;break}}i&&l.push(e[s])}return l}_getFileItem(e,t){const l=this;let s=null;if(e&&("string"==typeof e||"number"==typeof e)){if(!l._items||0===l._items.length)return null;for(let i=0;i<l._items.length;i++){const a=l._items[i];(t&&a.index===parseInt(e)||a.file.name===e)&&(s=a)}return s}}_handleContainers(){const e=this,t=e._validateDOMElement(e.dropZone),l=e._validateDOMElement(e.appendTo);t?t.appendChild(e.$.dropZone):e.$.fileUploadContainer.insertBefore(e.$.dropZone,e.$.fileUploadContainer.firstChild),l?l.appendChild(e.$.selectedFiles):e.$.fileUploadContainer.appendChild(e.$.selectedFiles)}_handleItemTemplate(e,t){const l=this;let s=l.itemTemplate;if("content"in document.createElement("template")){if(!s)return l._defaultItemTemplate(e,t);if("string"==typeof s&&(s=document.getElementById(s)),null!==s&&"content"in s)return s.innerHTML.replace(/{{\w+}}/g,e);l.error(l.localize("invalidTemplate",{elementType:l.nodeName.toLowerCase(),property:"template"}))}else l.error(l.localize("htmlTemplateNotSuported",{elementType:l.nodeName.toLowerCase()}))}_renderSelectedFiles(e){const t=this,l=document.createDocumentFragment(),s=e||t._selectedFiles;e||(t._items=[],t.$.selectedFiles.innerHTML="");for(let e=0;e<s.length;e++){const i=t.directory?s[e].webkitRelativePath:s[e].name,a=document.createElement("div");t._incrementIndex++,a.className="smart-file",a.index=t._incrementIndex,a.setAttribute("item-id",t._incrementIndex),a.innerHTML=t.itemTemplate?t._handleItemTemplate(i,t._incrementIndex):t._defaultItemTemplate(i,t._incrementIndex),a.file=s[e],a.uploading=!1,a.xhr=null,a.setAttribute("role","listitem"),a.setAttribute("aria-labelledby",t.id+"File"+t._incrementIndex+"Name"),t.rightToLeft&&a.setAttribute("right-to-left",""),l.appendChild(a),t._items.push(a),t.$.fireEvent("fileSelected",{filename:s[e].name,type:s[e].type,size:s[e].size,index:a.index})}t.$.selectedFiles.appendChild(l),t.$.fileUploadFooter.classList.remove("smart-hidden"),t._handleComponentsByAvailableHeight()}_setInitialValues(){const e=this;e.$.browseInput.accept=e.accept,e._selectedFiles=[],e._items=[],e._incrementIndex=0}_updateTextValues(){const e=this,t=["browse","uploadAll","cancelAll","pauseAll"];for(let l=0;l<t.length;l++){const s=t[l],i=s+"Button";e.$[i].innerHTML=e.localize(s)}for(let t=0;t<e._selectedFiles.length;t++){const l=e._items[t];l.querySelector(".smart-item-upload-button").title=e.localize("uploadFile"),l.querySelector(".smart-item-cancel-button").title=e.localize("cancelFile"),l.querySelector(".smart-item-pause-button").title=e.localize("pauseFile")}}_validateDOMElement(e){if(e)return"string"==typeof e?document.getElementById(e):e instanceof HTMLElement?e:void 0}refresh(){this._handleComponentsByAvailableHeight()}_handleComponentsByAvailableHeight(){const e=this;if(e._calculateAvailableContainerHeight(),e._elementsAutoHeight>e.offsetHeight){if(e.$.container.classList.add("smart-overflow"),e._containerOverflows=!0,e._rowHeight){const t=parseInt(e._availableHeight/e._rowHeight);for(let l=0;l<e._items.length;l++){const s=e._items[l];l<t?s.classList.remove("smart-hidden"):s.classList.add("smart-hidden")}e._items.length>t?(e.$.totalFiles.innerHTML=e.localize("totalFiles")+e._items.length,e.$.totalFiles.classList.remove("smart-hidden")):e.$.totalFiles.classList.add("smart-hidden")}}else""===e.dropZone&&e._elementsAutoHeight<e.offsetHeight&&(e.$.container.classList.remove("smart-overflow"),e._containerOverflows=!1)}_calculateAvailableContainerHeight(){const e=this,t=window.getComputedStyle(e.$.fileUploadContainer,null),l=parseInt(t.getPropertyValue("margin-top"))+parseInt(t.getPropertyValue("margin-bottom"))+parseInt(t.getPropertyValue("padding-top"))+parseInt(t.getPropertyValue("padding-bottom")),s=e.$.container.querySelector(".smart-file"),i=e.$.fileUploadHeader.offsetHeight,a=e.$.fileUploadFooter.offsetHeight,n=e.style.height;let r=0;s&&(e._rowHeight=s.offsetHeight),e.style.height="auto",e._containerOverflows&&e.$.container.classList.remove("smart-overflow"),e._elementsAutoHeight=e.offsetHeight,e.style.height=n,e._containerOverflows&&e.$.container.classList.add("smart-overflow"),e.$.totalFiles.classList.contains("smart-hidden")&&(e.$.totalFiles.classList.remove("smart-hidden"),r=e.$.totalFiles.offsetHeight,e.$.totalFiles.classList.add("smart-hidden")),e._availableHeight=e.offsetHeight-(i+a)-l-r}});
|
|
828
828
|
|
|
829
829
|
/***/ }),
|
|
830
830
|
|
|
831
831
|
/***/ 8588:
|
|
832
832
|
/***/ (() => {
|
|
833
833
|
|
|
834
|
-
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",value:[]},dropDownHeight:{type:"any",value:200},dropDownOpenMode:{allowedValues:["default","manual"],value:"default",type:"string"},dropDownWidth:{type:"any",value:null},dropDownButtonPosition:{allowedValues:["none","left","right"],value:"none",type:"string"},dropDownOpenPosition:{allowedValues:["bottom","top"],value:"bottom",type:"string"},hint:{type:"string",value:""},inputPurpose:{type:"string",value:"off"},items:{type:"number",value:8},minLength:{type:"number",value:1},name:{value:"",type:"string"},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><input 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><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","dropDownButton.down":"_dropDownButtonDownHandler","inputContainer.down":"_downHandler","document.up":"_documentUpHandler"}}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 a=this.dataSource[this.selectedIndex];if(!a)return;const r=this.context;this.context=this,this.$.input.dataValue=this.selectedValue="string"==typeof a?a:a.value,this.setAttribute("data-value",this.$.input.dataValue);let o=t.dataSource;"string"==typeof o&&(o=t.$.deserialize(o,"array"));for(let e=0;e<o.length;e++){let a=o[e];"string"!=typeof a&&"number"!=typeof a&&(a.value===t.$.input.dataValue?a.selected=!0:a.selected=!1)}this.context=r}else{const e=this.context;this.context=this,this.$.input.dataValue=this.selectedValue="",this.setAttribute("data-value",this.$.input.dataValue),this.selectedIndex=-1;let a=t.dataSource;if("string"==typeof a&&(a=t.$.deserialize(a,"array")),a&&Array.isArray(a))for(let e=0;e<a.length;e++){let r=a[e];"string"!=typeof r&&(r.value===t.$.input.dataValue?r.selected=!0:r.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,a=t.shadowRoot||t.isInShadowDOM?e.originalEvent.composedPath()[0]:e.originalEvent.target;a!==t&&a!==t.$.dropDownButton&&a!==t.$.input&&a!==t.$.arrow?t.$.scrollView.contains(a.shadowParent||a)?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,a=t.$.input,r=a.value,o=a.selectionStart,l=a.selectionEnd;if(!e.clipboardData&&!window.clipboardData)return;const n=(e.clipboardData||window.clipboardData).getData("text");let s=r.slice(0,o)+n,i=s.length;s+=r.slice(l),e.preventDefault(),t.set("value",s),t.setAttribute("data-value",s),a.setSelectionRange(i,i),t._refreshSelectedIndex()}_refreshSelectedIndex(){const e=this;let t=e.dataSource;if(t){let a=-1,r=null;if(e.dataSource instanceof Promise)return;if("function"==typeof e.dataSource)return;"string"==typeof t&&(t=e.$.deserialize(t,"array"));for(let o=0;o<t.length;o++){let l=t[o];if("number"!=typeof l&&"boolean"!=typeof l||(l=""+l),"string"==typeof l){if(l===e.value){a=o,r=e.value;break}}else l&&(delete l.selected,l.label===e.value&&(a=o,r=l.value,l.selected=!0))}e.set("selectedIndex",a,!1),e.set("selectedValue",r,!1),-1===e.selectedIndex&&(e.$.input.dataValue=null)}}selectItem(e){const t=this;let a=t.dataSource;if("string"==typeof a&&(a=t.$.deserialize(a,"array")),a)for(let r=0;r<a.length;r++){const o=a[r];if(t.set("selectedIndex",-1),t.set("value",""),t.$.input.dataValue=null,"string"==typeof o){if(o===e)return t.set("selectedIndex",r,!1),t.set("value",t.$.input.dataValue=e),void t.setAttribute("data-value",t.$.input.dataValue)}else if(o.value===e)return t.set("selectedIndex",r,!1),t.set("value",o.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 a=0;a<t.dataSource.length;a++){const r=t.dataSource[a];if(r.value===e)return r}return null}getPrevItem(){const e=this,t=e.getSelectedItem();if(e.dataSource&&t)for(let a=0;a<e.dataSource.length;a++)if(e.dataSource[a].value===t.value)return e.dataSource[a-1];return null}getNextItem(){const e=this,t=e.getSelectedItem();if(e.dataSource&&t)for(let a=0;a<e.dataSource.length;a++)if(e.dataSource[a].value===t.value)return e.dataSource[a+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")}_performSelect(){const e=this,t=e.$.menu.querySelector(".active"),a=t.getAttribute("data-label"),r=t.dataValue,o=e.value,l=e.$.input.dataValue;e.set("value",a),e.$.input.dataValue=r,e.setAttribute("data-value",r),e.set("selectedIndex",t.index),e.set("selectedValues",[e.$.input.dataValue]),e.set("selectedValue",e.$.input.dataValue);let n=e.dataSource;if("string"==typeof n&&(n=e.$.deserialize(n,"array")),n&&Array.isArray(n))for(let t=0;t<n.length;t++){let a=n[t];"string"!=typeof a&&"number"!=typeof a&&(a.value===e.$.input.dataValue?a.selected=!0:a.selected=!1)}e.close(),a===o&&r===l||(e.$.fireEvent("change",{value:r,label:a,oldValue:l,oldLabel:o}),e._updateTargetValue())}_open(){const e=this;if(e.opened)return;const t=window.scrollX,a=window.scrollY;let r=e.getBoundingClientRect(),o=0,l=0;if(e.timer&&clearTimeout(e.timer),e.getRootNode()&&e.getRootNode().host?e.getRootNode().host.shadowRoot.appendChild(e.$.scrollView):document.body.appendChild(e.$.scrollView),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();o=e.left,l=e.top}e.$.scrollView.style.setProperty("--smart-input-drop-down-menu-width",""),e.$.scrollView.style.left=-3+r.left+t-o+"px",e.$.scrollView.classList.remove("open"),"bottom"===e.dropDownOpenPosition?e.$.scrollView.style.top=r.bottom+a-l+1+"px":e.$.scrollView.style.top=r.top-e.$.scrollView.offsetHeight+a-l+1+"px",e.opening=!0,e._positionTimer&&clearInterval(e._positionTimer),e._positionTimer=setInterval((()=>{const t=e.getBoundingClientRect();if(e.opening)e.opening=!1,r=t;else if(Math.abs(parseInt(t.top)-parseInt(r.top))>=10||Math.abs(parseInt(t.left)-parseInt(r.left))>=10){const a=window.scrollX,r=window.scrollY;return e.$.scrollView.style.left=-3+t.left+a-o+"px",void("bottom"===e.dropDownOpenPosition?e.$.scrollView.style.top=t.bottom+r-l+1+"px":e.$.scrollView.style.top=t.top-e.$.scrollView.offsetHeight+r-l+1+"px")}}),50),e.$.scrollView.onpointerdown=function(){e._isPointerDown=!0},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 a=parseFloat(t)/100;e.$.scrollView.style.setProperty("--smart-input-drop-down-menu-width",e.offsetWidth*a+"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 a=e.$.menu.querySelectorAll("li");for(let t=0;t<a.length;t++)e._maxDropDownWidth=Math.max((a[t].firstElementChild||a[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;if(t.query=t.$.input.value,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 a=t.context;t.context=t,t._process(e),t.context=a}),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(),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 a=e.$.menu.querySelector(".active");if(a){const t=e.$.input.dataValue;for(let r=0;r<e.$.menu.children.length;r++){const o=e.$.menu.children[r],l=o.getAttribute("data-label"),n=o.dataValue;if(void 0!==t&&n===t||void 0===t&&l===e.$.input.value){a.classList.remove("active"),o.classList.add("active"),e._setActiveDescendant(o),e.$.input.dataValue=n,e.setAttribute("data-value",n);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.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 a,r=[],o=[],l=[];if(e&&""===e[0])return e;for(;a=e.shift();){let e=a.label||a;e=""+e,e.toLowerCase().indexOf(t.query.toLowerCase())?~e.indexOf(t.query)?o.push(a):l.push(a):r.push(a)}return r.concat(o,l)}_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 a=0,r=-1,o=null;const l=e.map((function(e){let l=e,n=e;"object"==typeof e&&(l=e.label,n=void 0!==e.value?e.value:l),l=""+l;const s=document.createElement("li"),i=document.createElement("a");if(i.href="#",s.id=t.id+"Item"+Math.floor(65536*(1+Math.random())).toString(16).substring(1),s.setAttribute("data-label",l),s.index=a++,s.dataValue=n,"string"==typeof n?s.setAttribute("value",n):s.setAttribute("value",JSON.stringify(n)),s.setAttribute("role","option"),s.setAttribute("aria-label",l),void 0!==e.menuLabel?(l=e.menuLabel,i.innerHTML=l):i.innerHTML=t.highlighter?t.highlighter(l):t._highlighter(l),i.setAttribute("aria-hidden",!0),e.disabled&&s.classList.add("smart-disabled"),e.icon&&(i.classList.add("icon"),i.classList.add(e.icon)),e.prefix){const t=document.createElement("span");t.innerHTML=e.prefix,i.classList.add("has-prefix"),i.innerHTML=t.innerHTML+i.innerHTML}if(e.suffix){const t=document.createElement("span");t.innerHTML=e.suffix,i.classList.add("has-suffix"),i.innerHTML=i.innerHTML+t.innerHTML}if(e.dataset)for(let t in e.dataset)s.setAttribute("data-"+t,e.dataset[t]);if(e.className){const t=e.className.split(" ");for(let e=0;e<t.length;e++)s.classList.add(t[e].trim())}return void 0!==t.selectedValue&&void 0!==e.value&&""!==t.selectedValue&&t.selectedValue===e.value&&(e.selected=!0,o=e,r=s.index,s.classList.add("active")),s.appendChild(i),s}));function n(){const e=t.$.menu.getElementsByClassName("active");e[0]&&e[0].classList.remove("active"),this.classList.add("active"),t._setActiveDescendant(this)}-1===r&&l.length>0&&(l[0].classList.add("active"),t._setActiveDescendant(l[0])),o&&(t.$.input.value=o.label,t.$.input.dataValue=o.value,t.setAttribute("data-value",t.$.input.dataValue)),t.$.menu.innerHTML="";for(let e=0;e<l.length;e++){const a=l[e];t.$.menu.appendChild(a),a.onmouseenter=n,a.onmouseleave=function(){this.classList.remove("active"),t._setActiveDescendant(null)},a.onclick=n}}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 a=t.nextElementSibling;a||(a=e.$.menu.firstElementChild),a.classList.add("active"),e._setActiveDescendant(a),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 a=t.previousElementSibling;a||(a=e.$.menu.lastElementChild),a.classList.add("active"),e._setActiveDescendant(a),e.ensureVisible()}_move(e){const t=this;if(t.readonly&&!t.opened){if("ArrowUp"===e.key){const a=t.getPrevItem();a&&t.selectItem(a.value),e.preventDefault()}if("ArrowDown"===e.key){const a=t.getNextItem();a&&t.selectItem(a.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;t._suppressKeyPressRepeat=![40,38,9,13,27,16,17,18].includes(e.keyCode),t._oldValue=t.$.input.value,e.shiftKey||e.altKey||e.ctrlKey||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)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:t._lookup(e),!t.opened||e.ctrlKey||e.shiftKey||(e.stopPropagation(),e.preventDefault()),t.$.fireEvent("changing",{value:t.$.input.value,oldValue:t._oldValue}),t.$.input.dataValue=t.$.input.value,t.setAttribute("data-value",t.$.input.dataValue),t._updateTargetValue()}}propertyChangedHandler(e,t,a){super.propertyChangedHandler(e,t,a);const r=this;if("innerHTML"===e&&(r._getDataSourceFromOption(),r._setSelection(!1)),"selectedValue"===e){let e=-1;if(r.dataSource&&Array.isArray(r.dataSource)&&r.dataSource.forEach(((t,r)=>{"string"==typeof t?t===a&&(e=r):t&&t.value===a&&(e=r)})),e>=0){const t=r.context;r.context=r,r.selectedIndex=e,r.context=t}r._setSelection()}if("selectedIndex"===e){let e=r.dataSource;if(r.selectedValue=null,e&&Array.isArray(e))for(let t=0;t<e.length;t++){let a=e[t];"string"!=typeof a&&"number"!=typeof a&&(a.selected=!1)}r._setSelection()}else if("dataSource"===e){if(r.dataSource&&Array.isArray(r.dataSource)){let e=-1;if(r.dataSource.forEach(((t,a)=>{t.selected&&(e=a)})),e>=0){const t=r.context;r.context=r,r.selectedIndex=e,r.context=t}}r._setSelection(!1)}else if("dropDownClassList"===e){const e=r.$.scrollView;for(let a=0,r=t.length;a<r;a+=1)e.classList.remove(t[a]);for(let t=0,r=a.length;t<r;t+=1)e.classList.add(a[t])}else if("dropDownHeight"===e)"auto"!==r.dropDownHeight?r.$.scrollView.style.setProperty("--smart-input-drop-down-menu-height",r.dropDownHeight+"px"):r.$.scrollView.style.setProperty("--smart-input-drop-down-menu-height","auto");else if("opened"===e)r.opened=t,a?r.open():r.close();else if("placeholder"===e){if(r.readonly){const e=r.getAttribute("aria-label");if(e&&e!==t)return;a?r.setAttribute("aria-label",a):r.removeAttribute("aria-label")}}else if("selectedValues"===e)if(null===a)r.$.input.value="",r.$.input.dataValue=a,r.setAttribute("data-value",a),r._refreshSelectedIndex();else{const e=a.join(","),t=r.value;r.$.input.dataValue=e,r._setSelection(),r.propertyChangedHandler("value",t,r.value)}else"value"===e?(r.displayMember!==r.valueMember&&"string"!=typeof a?(r.set("value",a[r.displayMember]),r.$.input.dataValue=a[r.valueMember],r.setAttribute("data-value",r.$.input.dataValue)):(r.$.input.value=r.$.input.dataValue=a,r.setAttribute("data-value",a)),r._refreshSelectedIndex()):"readonly"===e?(r._setAriaRelations(),r._setInputPurpose()):"theme"===e||"rightToLeft"===e?r.$.scrollView[e]=a:"inputPurpose"===e?r._setInputPurpose():"inverted"===e?a?r.$.scrollView.setAttribute("inverted",""):r.$.scrollView.removeAttribute("inverted"):"disabled"!==e&&"unfocusable"!==e||r._setFocusable()}_updateTargetValue(){const e=this;if(e.dataset.target){const t=document.querySelector(e.dataset.target);if(t){const a=e.dataset.property,r=e.value;a&&void 0!==t[a]&&(t[a]=r)}}}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 a=[];for(let e=0;e<t.length;e++){const r=t[e],o=r.hasAttribute("selected"),l=(""+r.textContent).trim(),n=(""+r.innerHTML).trim(),s=r.hasAttribute("value")?r.getAttribute("value"):l,i=r.hasAttribute("disabled");a.push({label:l,menuLabel:n,value:s,disabled:i,selected:o,className:r.className,dataset:r.dataset}),r.classList.add("smart-hidden")}e.dataSource=a}}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 a=e.$.scrollView;for(let e=0,r=t.length;e<r;e+=1)a.classList.add(t[e]);e.opened&&(e.opened=!1,e.open());const r=e.$.menu;r&&(r.setAttribute("role","presentation"),a.appendChild(r)),"auto"!==e.dropDownHeight?a.style.setProperty("--smart-input-drop-down-menu-height",e.dropDownHeight+"px"):a.style.setProperty("--smart-input-drop-down-menu-height","auto"),a.classList.add("smart-input-drop-down-menu");for(let t=0;t<e.classList.length;t++){const r=e.classList[t];"smart-element"!==r&&"smart-input"!==r&&a.classList.add(r+"-drop-down-menu")}a.id=e.id+"_"+e.tagName.toLowerCase()+"_menu_"+Math.floor(65536*(1+Math.random())).toString(16).substring(1),a.ownerElement=e;let o=e.dataSource;if("string"==typeof o&&(o=e.$.deserialize(o,"array")),o&&o.length&&Array.isArray(o)){let t=-1;if(o.forEach(((e,a)=>{e.selected&&(t=a)})),t>=0){e.selectedIndex=t;const a=o[t];e.selectedValue="string"==typeof a?o[t]:o[t].value}}e._setAriaRelations(),e._setInputPurpose(),e._setSelection(),e.isInitialized=!0,super.render()}_setSelection(e){const t=this;let a=t.dataSource;if("string"==typeof a&&(a=t.$.deserialize(a,"array")),t.selectedIndex>=0&&a&&a.length>0){let r=a[t.selectedIndex];if("number"!=typeof r&&"boolean"!=typeof r||(r=""+r),"string"==typeof r){let e=t.$.input.dataValue,a=t.value;t.set("value",r),t.$.input.dataValue=r,t.$.input.setAttribute("data-value",r),t.selectedValues=[t.$.input.dataValue],t.isInitialized&&(t.$.fireEvent("change",{value:t.value,label:t.label,oldValue:e,oldLabel:a}),t._updateTargetValue())}else{let a=t.$.input.dataValue,o=t.value;r&&(void 0!==r.value?(t.set("value",void 0!==r.value?r.value+"":""),t.$.input.dataValue=r.value,t.$.input.setAttribute("data-value",r.value),t.selectedValues=[t.$.input.dataValue]):r.label&&(t.selectedValues=[r.value]),r.label&&t.set("value",r.label)),t.isInitialized&&!1!==e&&(t.$.fireEvent("change",{value:t.$.input.dataValue,label:r.value,oldValue:a,oldLabel:o}),t._updateTargetValue())}}}_createElement(){const e=this,t=document.createElement("ul"),a=document.createElement("smart-scroll-viewer");a.rightToLeft=e.rightToLeft,a.theme=e.theme,a.horizontalScrollBarVisibility="hidden",e.inverted?a.setAttribute("inverted",""):a.removeAttribute("inverted"),e.$.scrollView=a,e.$.menu=t,e._setFocusable(),e.$.menu.onclick=function(t){const a=t.target.closest("li");t.stopPropagation(),t.preventDefault(),e._performSelect(),a&&e.$.fireEvent("itemClick",{item:a,label:a.getAttribute("aria-label"),value:a.dataValue}),e.$.input.focus()}}_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")}});
|
|
834
|
+
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",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"],value:"bottom",type:"string"},hint:{type:"string",value:""},inputPurpose:{type:"string",value:"off"},items:{type:"number",value:8},minLength:{type:"number",value:1},name:{value:"",type:"string"},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><input 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><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","dropDownButton.down":"_dropDownButtonDownHandler","inputContainer.down":"_downHandler","document.up":"_documentUpHandler"}}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 r=t.dataSource;"string"==typeof r&&(r=t.$.deserialize(r,"array"));for(let e=0;e<r.length;e++){let o=r[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,r=o.selectionStart,l=o.selectionEnd;if(!e.clipboardData&&!window.clipboardData)return;const n=(e.clipboardData||window.clipboardData).getData("text");let s=a.slice(0,r)+n,i=s.length;s+=a.slice(l),e.preventDefault(),t.set("value",s),t.setAttribute("data-value",s),o.setSelectionRange(i,i),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 r=0;r<t.length;r++){let l=t[r];if("number"!=typeof l&&"boolean"!=typeof l||(l=""+l),"string"==typeof l){if(l===e.value){o=r,a=e.value;break}}else l&&(delete l.selected,l.label===e.value&&(o=r,a=l.value,l.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 r=o[a];if(t.set("selectedIndex",-1),t.set("value",""),t.$.input.dataValue=null,"string"==typeof r){if(r===e)return t.set("selectedIndex",a,!1),t.set("value",t.$.input.dataValue=e),void t.setAttribute("data-value",t.$.input.dataValue)}else if(r.value===e)return t.set("selectedIndex",a,!1),t.set("value",r.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")}_performSelect(){const e=this,t=e.$.menu.querySelector(".active"),o=t.getAttribute("data-label"),a=t.dataValue,r=e.value,l=e.$.input.dataValue;e.set("value",o),e.$.input.dataValue=a,e.setAttribute("data-value",a),e.set("selectedIndex",t.index),e.set("selectedValues",[e.$.input.dataValue]),e.set("selectedValue",e.$.input.dataValue);let n=e.dataSource;if("string"==typeof n&&(n=e.$.deserialize(n,"array")),n&&Array.isArray(n))for(let t=0;t<n.length;t++){let o=n[t];"string"!=typeof o&&"number"!=typeof o&&(o.value===e.$.input.dataValue?o.selected=!0:o.selected=!1)}e.close(),o===r&&a===l||(e.$.fireEvent("change",{value:a,label:o,oldValue:l,oldLabel:r}),e._updateTargetValue())}_open(){const e=this;if(e.opened)return;const t=window.scrollX,o=window.scrollY;let a=e.getBoundingClientRect(),r=0,l=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();r=e.left,l=e.top}if(e.$.scrollView.style.setProperty("--smart-input-drop-down-menu-width",""),e.$.scrollView.style.left=-3+a.left+t-r+"px",e.$.scrollView.classList.remove("open"),"bottom"===e.dropDownOpenPosition?e.$.scrollView.style.top=a.bottom+o-l+1+"px":e.$.scrollView.style.top=a.top-e.$.scrollView.offsetHeight+o-l+1+"px",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-r+"px",void("bottom"===e.dropDownOpenPosition?e.$.scrollView.style.top=t.bottom+a-l+1+"px":e.$.scrollView.style.top=t.top-e.$.scrollView.offsetHeight+a-l+1+"px")}}),50)),e.$.scrollView.onpointerdown=function(){e._isPointerDown=!0},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;if(t.query=t.$.input.value,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 o=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,o):o(t.dataSource)}_downHandler(e){const t=this;t.readonly&&t._dropDownButtonDownHandler(e)}_dropDownButtonDownHandler(e){const t=this;return"manual"!==t.dropDownOpenMode&&t._toggle(),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 r=e.$.menu.children[a],l=r.getAttribute("data-label"),n=r.dataValue;if(void 0!==t&&n===t||void 0===t&&l===e.$.input.value){o.classList.remove("active"),r.classList.add("active"),e._setActiveDescendant(r),e.$.input.dataValue=n,e.setAttribute("data-value",n);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.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=[],r=[],l=[];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)?r.push(o):l.push(o):a.push(o)}return a.concat(r,l)}_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,r=null;const l=e.map((function(e){let l=e,n=e;"object"==typeof e&&(l=e.label,n=void 0!==e.value?e.value:l),l=""+l,l=l.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,""");const s=document.createElement("li"),i=document.createElement("a");if(i.href="#",s.id=t.id+"Item"+Math.floor(65536*(1+Math.random())).toString(16).substring(1),s.setAttribute("data-label",l),s.index=o++,s.dataValue=n,"string"==typeof n?s.setAttribute("value",n):s.setAttribute("value",JSON.stringify(n)),s.setAttribute("role","option"),s.setAttribute("aria-label",l),void 0!==e.menuLabel?(l=e.menuLabel,i.innerHTML=l):i.innerHTML=t.highlighter?t.highlighter(l):t._highlighter(l),i.setAttribute("aria-hidden",!0),e.disabled&&s.classList.add("smart-disabled"),e.icon&&(i.classList.add("icon"),i.classList.add(e.icon)),e.prefix){const t=document.createElement("span");t.innerHTML=e.prefix,i.classList.add("has-prefix"),i.innerHTML=t.innerHTML+i.innerHTML}if(e.suffix){const t=document.createElement("span");t.innerHTML=e.suffix,i.classList.add("has-suffix"),i.innerHTML=i.innerHTML+t.innerHTML}if(e.dataset)for(let t in e.dataset)s.setAttribute("data-"+t,e.dataset[t]);if(e.className){const t=e.className.split(" ");for(let e=0;e<t.length;e++)s.classList.add(t[e].trim())}return void 0!==t.selectedValue&&void 0!==e.value&&""!==t.selectedValue&&t.selectedValue===e.value&&(e.selected=!0,r=e,a=s.index,s.classList.add("active")),s.appendChild(i),s}));function n(){const e=t.$.menu.getElementsByClassName("active");e[0]&&e[0].classList.remove("active"),this.classList.add("active"),t._setActiveDescendant(this)}-1===a&&l.length>0&&(l[0].classList.add("active"),t._setActiveDescendant(l[0])),r&&(t.$.input.value=r.label,t.$.input.dataValue=r.value,t.setAttribute("data-value",t.$.input.dataValue)),t.$.menu.innerHTML="";for(let e=0;e<l.length;e++){const o=l[e];t.$.menu.appendChild(o),o.onmouseenter=n,o.onmouseleave=function(){this.classList.remove("active"),t._setActiveDescendant(null)},o.onclick=n}}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;t._suppressKeyPressRepeat=![40,38,9,13,27,16,17,18].includes(e.keyCode),t._oldValue=t.$.input.value,e.shiftKey||e.altKey||e.ctrlKey||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)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:t._lookup(e),!t.opened||e.ctrlKey||e.shiftKey||(e.stopPropagation(),e.preventDefault()),t.$.fireEvent("changing",{value:t.$.input.value,oldValue:t._oldValue}),t.$.input.dataValue=t.$.input.value,t.setAttribute("data-value",t.$.input.dataValue),t._updateTargetValue()}}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;a.$.input.dataValue=e,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],r=a.hasAttribute("selected"),l=(""+a.textContent).trim(),n=(""+a.innerHTML).trim(),s=a.hasAttribute("value")?a.getAttribute("value"):l,i=a.hasAttribute("disabled");o.push({label:l,menuLabel:n,value:s,disabled:i,selected:r,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 r=e.dataSource;if("string"==typeof r&&(r=e.$.deserialize(r,"array")),r&&r.length&&Array.isArray(r)){let t=-1;if(r.forEach(((e,o)=>{e.selected&&(t=o)})),t>=0){e.selectedIndex=t;const o=r[t];e.selectedValue="string"==typeof o?r[t]:r[t].value}}e._setAriaRelations(),e._setInputPurpose(),e._setSelection(),e.isInitialized=!0,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 e=t.$.input.dataValue,o=t.value;t.set("value",a),t.$.input.dataValue=a,t.$.input.setAttribute("data-value",a),t.selectedValues=[t.$.input.dataValue],t.isInitialized&&(t.$.fireEvent("change",{value:t.value,label:t.label,oldValue:e,oldLabel:o}),t._updateTargetValue())}else{let o=t.$.input.dataValue,r=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:r}),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.onclick=function(t){const o=t.target.closest("li");t.stopPropagation(),t.preventDefault(),e._performSelect(),o&&e.$.fireEvent("itemClick",{item:o,label:o.getAttribute("aria-label"),value:o.dataValue}),a.focus()}}_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")}});
|
|
835
835
|
|
|
836
836
|
/***/ }),
|
|
837
837
|
|
|
838
838
|
/***/ 5707:
|
|
839
839
|
/***/ (() => {
|
|
840
840
|
|
|
841
|
-
Smart("smart-list-item",class extends Smart.ContentElement{static get properties(){return{alternationIndex:{value:-1,type:"int"},color:{value:"",type:"string"},displayMode:{allowedValues:["plain","checkBox","radioButton"],value:"plain",type:"string"},grouped:{value:!1,type:"boolean"},selected:{value:!1,type:"boolean"},value:{value:"",type:"string"},label:{value:"",type:"string"},details:{value:"",type:"string"},group:{value:"",type:"string"},hidden:{value:!1,type:"boolean"},readonly:{value:!1,type:"boolean"}}}get hasStyleObserver(){return!1}get enableShadowDOM(){return!1}get _focused(){const e=this;return void 0===e.__focused&&(e.__focused=!1),e.__focused}set _focused(e){const t=this;t.__focused=e,e?(t.setAttribute("focus",""),t.ownerListBox&&t.ownerListBox.ownerElement&&Smart.ComboBox&&t.ownerListBox.ownerElement instanceof Smart.ComboBox&&t.ownerListBox.ownerElement.$.input.setAttribute("aria-activedescendant",t.id)):t.removeAttribute("focus")}template(){return'<div id="container">\n <span id=\'itemInput\' class=\'smart-input smart-hidden\'></span>\n <span class="smart-overlay" id="overlay"></span>\n <div id="itemContainer" class="smart-content smart-list-item-container"><span class="smart-content-label" inner-h-t-m-l=\'[[innerHTML]]\' role="presentation"><content></content></span><span inner-h-t-m-l=\'[[details]]\' id="details" class="smart-content-details"></span></div>\n </div>'}appendChild(e){const t=this;if(!t.isCompleted||e.classList&&e.classList.contains("smart-ripple")){const e=Array.prototype.slice.call(arguments,2);return HTMLElement.prototype.appendChild.apply(t,e.concat(Array.prototype.slice.call(arguments)))}window.smartBlazor?t.$.itemContainer.appendChild(e):(t.$.itemContainer.innerHTML="",e instanceof HTMLElement&&t.$.itemContainer.appendChild(e))}insertBefore(e,t){const i=this;if(!i.isCompleted){const e=Array.prototype.slice.call(arguments,2);return HTMLElement.prototype.insertBefore.apply(i,e.concat(Array.prototype.slice.call(arguments)))}t.parentNode.insertBefore(e,t)}removeChild(e){const t=this;if(!t.isCompleted||e.classList.contains("smart-ripple")){const e=Array.prototype.slice.call(arguments,2);return HTMLElement.prototype.removeChild.apply(t,e.concat(Array.prototype.slice.call(arguments)))}e instanceof HTMLElement&&t.$.itemContainer.removeChild(e)}attached(){super.attached(),this.ownerListBox=this.getListBox()}static get listeners(){return{mouseenter:"_itemOnMouseEnter",mouseleave:"_itemOnMouseLeave"}}ready(){super.ready();const e=this;e.setAttribute("role","option"),""!==e.label?e.innerHTML=e.label:""!==e.innerHTML&&(e.label=e.innerHTML),e._setDisplayMode(e.displayMode),e._setItemColor(),e.$.container.noRipple=!0;const t=e.closest("smart-list-box");if(t&&t.isRendered){if(cancelAnimationFrame(Smart.ListBox.processTimer),t._inLazyInit||t._isUpdating)return;Smart.ListBox.processTimer=requestAnimationFrame((()=>{t._lazyInitItems()}))}}propertyChangedHandler(e,t,i){const r=this;if(super.propertyChangedHandler(e,t,i),"hidden"===e)i?r.$.addClass("smart-hidden"):r.$.removeClass("smart-hidden");else if("color"===e)r._setItemColor();else if("displayMode"===e)r._setDisplayMode(i);else if("label"===e||"value"===e){const t=r.context;r.context=document,"label"===e&&(r.innerHTML=i);const o=r.getListBox();o&&(o._applyTemplate(r),o.onItemUpdated(r)),r.context=t}else if("details"===e){const e=r.context;r.context=document,r.$.details.innerHTML=i;const t=r.getListBox();t&&t.onItemUpdated(r),r.context=e}else if("innerHTML"===e){const e=r.getListBox();e&&e.onItemUpdated(r)}else if("selected"===e)if(i)r.setAttribute("aria-selected",!0);else{const e=r.getListBox();r.readonly||r.disabled||!e||-1===["oneOrManyExtended","zeroOrMany","oneOrMany","checkBox"].indexOf(e.selectionMode)?r.removeAttribute("aria-selected"):r.setAttribute("aria-selected",!1)}}getListBox(){const e=this;if(!Smart.ListBox)return e.getRootNode().host;let t=e.parentNode;for(;t instanceof Smart.ListBox==0&&null!==t;)t=t.parentNode;return!t&&Smart.EnableShadowDOM?e.getRootNode().host:t}_itemOnMouseEnter(){const e=this;!e.disabled&&e.ownerListBox&&(Smart.ListBox.DragDrop.Dragging&&e.ownerListBox.allowDrop&&(Smart.ListBox.DragDrop.DropDetails={item:e,position:"bottom"}),e.ownerListBox.$.verticalScrollBar.thumbCapture||e.ownerListBox.$.horizontalScrollBar.thumbCapture||e.setAttribute("hover",""))}_itemOnMouseMove(e){const t=this;if(t.ownerListBox&&Smart.ListBox.DragDrop.Dragging&&t.ownerListBox.allowDrop&&!Smart.Utilities.Core.isMobile){const i=[].slice.call(t.ownerListBox.getElementsByClassName("smart-list-item-bottom-line-feedback"));for(let e=0;e<i.length;e++)i[e].$.removeClass("smart-list-item-line-feedback"),i[e].$.removeClass("smart-list-item-bottom-line-feedback");if(Smart.ListBox.DragDrop.DropDetails={item:t,position:"top"},!t.ownerListBox._areCSSVarsSupported){if(t.ownerListBox._indexOf(t)===t.ownerListBox._items.length-1||t.parentNode.lastElementChild===t){const i=t.getBoundingClientRect();e.pageY-window.pageYOffset>i.top+i.height/2-1&&(Smart.ListBox.DragDrop.DropDetails={item:t,position:"bottom"})}return}if(t.$.removeClass("smart-list-item-line-feedback"),t.$.removeClass("smart-list-item-bottom-line-feedback"),t.ownerListBox.sorted&&t.ownerListBox.autoSort)return;const r=t.ownerListBox._items.filter((e=>!e.hidden));if(r.indexOf(t)===r.length-1||t.parentNode.lastElementChild===t){const i=t.getBoundingClientRect();e.pageY-window.pageYOffset>i.top+i.height/2-1?(t.$.addClass("smart-list-item-bottom-line-feedback"),Smart.ListBox.DragDrop.DropDetails={item:t,position:"bottom"}):arguments[1]||t.$.addClass("smart-list-item-line-feedback")}else arguments[1]||t.$.addClass("smart-list-item-line-feedback")}}_itemOnMouseLeave(){const e=this;e.ownerListBox&&(Smart.ListBox.DragDrop.Dragging&&(e.$.removeClass("smart-list-item-line-feedback"),e.$.removeClass("smart-list-item-bottom-line-feedback")),e.removeAttribute("hover"))}_setDisplayMode(e){const t=this,i=t.getListBox();if(i){const r="checkBox"===i.selectionMode||"radioButton"===i.selectionMode?i.selectionMode:"plain";t.displayMode=e=r}"plain"!==e?t.$itemInput.removeClass("smart-hidden"):t.$itemInput.addClass("smart-hidden")}_setItemColor(){const e=this,t=e.querySelector(".smart-content-label"),i=/(^#[0-9A-F]{3}$)|(^#[0-9A-F]{6}$)|(^#[0-9A-F]{8}$)/i.test(e.color)?e.color:"";t.style.backgroundColor=i,t.style.color=e._getContrastColor(i)}_getContrastColor(e){if(!e)return"";let t=(i=e.slice(1,3),r=e.slice(3,5),o=e.slice(5,7),[parseInt(i,16),parseInt(r,16),parseInt(o,16)]);var i,r,o;return parseFloat(((.299*t[0]+.61*t[1]+.114*t[2])/255).toFixed(2))>.65?"#000000":"#FFFFFF"}}),Smart("smart-list-items-group",class extends Smart.ContentElement{static get properties(){return{label:{value:"",type:"string"}}}get enableShadowDOM(){return!1}template(){return'<div id="container" role="presentation">\n <span id="itemsLabel" class="smart-list-items-group-label">[[label]]</span>\n <div id="listItemsGroupContainer" inner-h-t-m-l=\'[[innerHTML]]\' class="smart-list-items-group-container" role="presentation">\n <content></content>\n </div>\n </div>'}appendChild(e){const t=this;if(!t.isCompleted){const e=Array.prototype.slice.call(arguments,2);return HTMLElement.prototype.appendChild.apply(t,e.concat(Array.prototype.slice.call(arguments)))}e instanceof HTMLElement&&t.$.listItemsGroupContainer.appendChild(e)}removeChild(e){const t=this;if(!t.isCompleted){const e=Array.prototype.slice.call(arguments,2);return HTMLElement.prototype.removeChild.apply(t,e.concat(Array.prototype.slice.call(arguments)))}e instanceof HTMLElement&&t.$.listItemsGroupContainer.removeChild(e)}getListBox(){let e=this.parentNode;for(;e instanceof Smart.ListBox==0&&null!==e;)e=e.parentNode;return e}attached(){const e=this;super.attached(),e.ownerListBox||(e.ownerListBox=e.getListBox()),e.setAttribute("role","group"),e.$.itemsLabel.id||(e.$.itemsLabel.id=e.id+"Label"),e.setAttribute("aria-labelledby",e.$.itemsLabel.id)}}),Smart("smart-list-box",class extends Smart.ScrollViewer{static get properties(){return{allowDrag:{value:!1,type:"boolean"},allowDrop:{value:!1,type:"boolean"},alternationStart:{value:0,type:"int"},alternationEnd:{value:0,type:"int"},alternationCount:{value:0,type:"int"},autoSort:{value:!0,type:"boolean"},dataSource:{value:null,type:"any?",reflectToAttribute:!1},dragFeedbackFormatFunction:{value:null,type:"function?"},dragOffset:{value:[10,10],type:"array"},displayLoadingIndicator:{value:!1,type:"boolean"},displayMember:{value:"",type:"string"},shadowDomMode:{allowedValues:["light","shadow"],value:"shadow",type:"string"},dropAction:{value:"move",type:"string",allowedValues:["copy","move","none"]},editable:{value:!1,type:"boolean"},filterable:{value:!1,type:"boolean"},filterCallback:{value:null,type:"function?"},filterMode:{value:"containsIgnoreCase",allowedValues:["contains","containsIgnoreCase","doesNotContain","doesNotContainIgnoreCase","equals","equalsIgnoreCase","startsWith","startsWithIgnoreCase","endsWith","endsWithIgnoreCase","custom"],type:"string"},filterInputPlaceholder:{value:"",type:"string"},grouped:{value:!1,type:"boolean"},groupMember:{value:"",type:"string"},itemTemplate:{value:null,type:"any"},itemHeight:{value:null,type:"number?"},incrementalSearchDelay:{value:700,type:"number?"},incrementalSearchMode:{value:"startsWithIgnoreCase",allowedValues:["contains","containsIgnoreCase","doesNotContain","doesNotContainIgnoreCase","equals","equalsIgnoreCase","startsWith","startsWithIgnoreCase","endsWith","endsWithIgnoreCase"],type:"string"},itemMeasureMode:{value:"auto",allowedValues:["auto","precise"],type:"string"},loadingIndicatorPlaceholder:{value:"Loading...",type:"string"},loadingIndicatorPosition:{value:"center",allowedValues:["bottom","center","top"],type:"string"},messages:{extend:!0,value:{en:{overridingProperties:'{{elementType}}: Overriding properties {{property1}} and {{property2}} applied. The "{{property1}}" property is used by default.',invalidIndex:'{{elementType}}: "{{method}}" method accepts an index of type number or an Array of numbers.',indexOutOfBound:'{{elementType}}: Out of bound index/indexes in "{{method}}" method.',invalidItem:'{{elementType}}: "{{method}}" method accepts an object or an array of objects as it\'s second parameter.',invalidSettings:'{{elementType}}: "{{method}}" method accepts a string or an object as it\'s second parameter.'}},type:"object"},name:{value:"",type:"string"},placeholder:{value:"No Items",type:"string"},selectedIndexes:{value:[],type:"array"},selectedValues:{value:[],type:"array"},selectionMode:{value:"oneOrManyExtended",allowedValues:["none","oneOrManyExtended","zeroOrMany","oneOrMany","zeroOrOne","zeroAndOne","one","checkBox","radioButton"],type:"string"},selectionChangeAction:{value:"release",allowedValues:["press","release"],type:"string"},sorted:{value:!1,type:"boolean"},sortDirection:{value:"asc",type:"string"},topVisibleIndex:{value:-1,type:"int"},type:{value:"list",type:"string",defaultReflectToAttribute:!0,readonly:!0},valueMember:{value:"",type:"string"},virtualized:{value:!1,type:"boolean"}}}static get requires(){return{"Smart.ScrollBar":"smart.scrollbar.js"}}static get styleUrls(){return["smart.listbox.css","smart.dropdown.css","smart.scrollbar.css"]}static get listeners(){return{focus:"_focusHandler",blur:"_blurHandler","container.wheel":"_mouseWheelHandler","editInput.change":"_editInputEventHandler","editInput.blur":"_editInputEventHandler","editInput.keydown":"_editInputEventHandler","horizontalScrollBar.change":"_horizontalScrollbarHandler","itemsInnerContainer.down":"_downHandler","itemsInnerContainer.dblclick":"_dblclickEventHandler","itemsInnerContainer.move":"_itemsContainerMoveHandler","itemsContainer.mouseleave":"_mouseLeaveHandler","itemsInnerContainer.touchmove":"_touchmoveHandler","itemsInnerContainer.touchstart":"_touchstartHandler","document.move":"_moveHandler",keydown:"_keyDownHandler",keyup:"_keyUpHandler",resize:"_resizeHandler",selectstart:"_selectStartHandler",styleChanged:"_styleChangedHandler",swipeleft:"_swipeLeftHandler",swiperight:"_swipeRightHandler",touchmove:"_overriddenHandler",touchstart:"_overriddenHandler","verticalScrollBar.change":"_verticalScrollbarHandler"}}template(){return'<div id="container" class="smart-container" role="presentation">\n <div class="smart-list-box-filter-input-container smart-hidden" id="filterInputContainer" role="presentation"><input id="filterInput" disabled="[[disabled]]" placeholder=\'[[filterInputPlaceholder]]\' role="searchbox" aria-label="[[filterInputPlaceholder]]"></div>\n <div id="itemsContainer" class="smart-list-items-container" role="presentation">\n <div id="placeholder" class="smart-placeholder" role="presentation" aria-hidden="true">[[placeholder]]</div>\n <div id="itemsInnerContainer" inner-h-t-m-l=\'[[innerHTML]]\' class="smart-list-items-inner-container" role="presentation">\n <content></content>\n </div>\n <input type="text" id="editInput" class= "smart-hidden"/>\n </div>\n <smart-scroll-bar wait theme="[[theme]]" right-to-left="[[rightToLeft]]" id="verticalScrollBar" disabled="[[disabled]]" orientation="vertical"></smart-scroll-bar>\n <smart-scroll-bar wait theme="[[theme]]" right-to-left="[[rightToLeft]]" id="horizontalScrollBar" disabled="[[disabled]]"></smart-scroll-bar>\n <div id="loadingIndicatorContainer" class="smart-loader-container" role="presentation">\n <span id="loadingIndicator" class="smart-loader" role="img" aria-label="[[loadingIndicatorPlaceholder]]"></span>\n <span id="loadingIndicatorPlaceHolder" class="smart-loader-label smart-hidden">[[loadingIndicatorPlaceholder]]</span>\n </div>\n <input id="hiddenInput" type="hidden" name="[[name]]">\n </div>'}get value(){const e=this;return e.isRendered&&e._selectedItems.length>0?e._selectedItems.map((e=>({label:e.label,value:e.value}))):null}set value(e){const t=this;if(Array.isArray(e)){const i=t.context;t.context=t,t._isUpdating++,t.selectedValues=[],t.clearSelection();for(let i=0;i<e.length;i++){const r=e[i],o=t.getItem(r);o&&("oneOrManyExtended"===t.selectionMode?t._select(o):t.select(o))}return t.context=i,void t._isUpdating--}const i=t.getItem(e);i&&t.select(i)}get _selectedItems(){const e=this,t=[];if(e.isRendered)for(let i=0;i<e._items.length;i++){const r=e._items[i];r.selected&&t.push(r)}return t}_mouseLeaveHandler(){const e=[].slice.call(this.getElementsByClassName("smart-list-item-bottom-line-feedback"));for(let t=0;t<e.length;t++)e[t].$.removeClass("smart-list-item-line-feedback"),e[t].$.removeClass("smart-list-item-bottom-line-feedback")}_downHandler(e){const t=this;if(t.disabled||t.displayLoadingIndicator||t.readonly)return;let i=e.originalEvent.target,r=null;if(!(i instanceof Smart.ListItem)||i.disabled||i.hidden||i instanceof Smart.ListItemsGroup)for(;i.parentElement;){if(i instanceof Smart.ListItem&&!i.disabled&&!i.hidden&&!(i instanceof Smart.ListItemsGroup)){r=i.dataItem;break}i=i.parentElement}else r=i.dataItem;Smart.ListBox.DragDrop.StartTime=new Date,Smart.ListBox.DragDrop.StartPosition={left:e.pageX,top:e.pageY},r&&(e.stopPropagation(),t.hasRippleAnimation&&(r.readonly||r.disabled||Smart.Utilities.Animation.Ripple.animate(i.$.overlay,e.pageX,e.pageY)),Smart.Utilities.Core.isMobile||"press"!==t.selectionChangeAction||(t._focus(r),t.select(r)),!Smart.ListBox.DragDrop.Feedback&&t.allowDrag&&(Smart.ListBox.DragDrop.DraggedFrom=t,Smart.ListBox.DragDrop.Feedback=document.createElement("span"),t.rightToLeft?Smart.ListBox.DragDrop.Feedback.setAttribute("right-to-left",!0):Smart.ListBox.DragDrop.Feedback.removeAttribute("right-to-left"),t.dragFeedbackFormatFunction?Smart.ListBox.DragDrop.Feedback.innerHTML=t.dragFeedbackFormatFunction(r):Smart.ListBox.DragDrop.Feedback.appendChild(r.offsetHeight?r.cloneNode(!0):t._createItem(r)),Smart.ListBox.DragDrop.Item=r,Smart.Utilities.Extend(Smart.ListBox.DragDrop.Feedback).addClass("smart-popup smart-list-item smart-list-item-feedback")))}_dblclickEventHandler(e){const t=this;if(!t.editable)return;const i=e.target.closest("smart-list-item");i instanceof Smart.ListItem&&!i.disabled&&!i.readonly?(t.$.editInput.dir=t.rightToLeft?"rtl":"ltr",t.$.editInput.style.width=t.$.itemsInnerContainer.offsetWidth+"px",t.$.editInput.owner=i,t.$.editInput.value=i.label,t.$.editInput.style.height=i.offsetHeight+"px",t.$.editInput.style.top=i.offsetTop+t.$.itemsInnerContainer.offsetTop+"px",t.$.editInput.setAttribute("aria-label","Edit item "+i.label),t.$editInput.hasClass("smart-hidden")&&t.$editInput.removeClass("smart-hidden"),t.$.editInput.focus({preventScroll:!0})):t.$editInput.addClass("smart-hidden")}_editInputEventHandler(e){const t=this;if("blur"===e.type||"keydown"===e.type&&"Escape"===e.key)return t.$editInput.hasClass("smart-hidden")||t.$editInput.addClass("smart-hidden"),void t.focus();if("keydown"===e.type||t.$editInput.hasClass("smart-hidden"))return;const i=e.target;if(e.stopPropagation(),i.owner.label!==i.value&&(i.owner.label=i.value,t.itemTemplate&&t._applyTemplate(i.owner),t.dataSource)){const e=i.owner.dataIndex,r=t.dataSource[e];r&&(t.displayMember?r[t.displayMember]=i.value:r.label=i.value)}t.$editInput.addClass("smart-hidden"),t.$.fireEvent("itemLabelChange",{selected:i.owner.selected,disabled:i.owner.disabled,index:t._indexOf(i.owner),label:i.owner.label,value:i.owner.value})}_pointerUpHandler(e){const t=this;let i=e.originalEvent,r=i.target;(t.shadowRoot||t.isInShadowDOM)&&(r=i.originalEvent?i.originalEvent.composedPath()[0]:i.composedPath()[0]);const o=e=>{const i=e.ownerListBox;i.disabled||i!==t||i.displayLoadingIndicator||"none"===i.selectionMode||e.grouped||e.readonly||(i._focus(e),i.select(e),Smart.ListBox.DragDrop.StartPosition=null,t.$.fireEvent("itemClick",{selected:r.selected,disabled:r.disabled,index:t._indexOf(r),label:r.label,value:r.value}))};if(!(i.target instanceof Smart.ListItem)||i.target.disabled||i.target instanceof Smart.ListItemsGroup){for(;r.parentElement;){if(r instanceof Smart.ListItem&&!r.disabled&&!(r instanceof Smart.ListItemsGroup))return void o(r.dataItem);r=r.parentElement}if(this.shadowRoot&&"shadow"===this.shadowDomMode){const e=i.composedPath();for(let t=0;t<e.length;t++){const i=e[t];i instanceof Smart.ListItem&&!i.disabled&&o(i.dataItem)}}}else o(r.dataItem)}_upHandler(e){const t=this;if(super._upHandler(),!t.disabled&&!t.readonly&&Smart.ListBox.DragDrop.StartPosition){if(Smart.Utilities.Core.isMobile&&!Smart.ListBox.DragDrop.Dragging){const i=Math.abs(e.pageX-Smart.ListBox.DragDrop.StartPosition.left),r=Math.abs(e.pageY-Smart.ListBox.DragDrop.StartPosition.top);let o=i>=0&&i<=3&&r>=0&&r<=3;if(Smart.Utilities.Core.isMobile&&new Date-Smart.ListBox.DragDrop.StartTime>=300&&(o=!1,Smart.ListBox.DragDrop.StartTime=null),o){const i=e.originalEvent.target.closest("smart-list-box");i?i._pointerUpHandler(e):t._pointerUpHandler(e),Smart.ListBox.DragDrop.StartPosition=null}else{let t=e.originalEvent.target;if(!(e.target instanceof Smart.ListItem)||t.readonly||e.target.disabled||e.target instanceof Smart.ListItemsGroup)for(;t.parentElement;){if(t instanceof Smart.ListItem&&!t.readonly&&!t.disabled&&!(t instanceof Smart.ListItemsGroup)){e.stopPropagation();break}t=t.parentElement}else e.stopPropagation()}}else if(!Smart.Utilities.Core.isMobile&&!Smart.ListBox.DragDrop.Dragging&&"release"===t.selectionChangeAction){const i=(t.shadowRoot||t.isInShadowDOM?e.originalEvent.composedPath()[0]:e.originalEvent.target).closest("smart-list-box");i?i._pointerUpHandler(e):t._pointerUpHandler(e)}if(Smart.ListBox.DragDrop.Feedback){let i;if(Smart.ListBox.DragDrop.Feedback.parentNode&&Smart.ListBox.DragDrop.Feedback.parentNode.removeChild(Smart.ListBox.DragDrop.Feedback),Smart.ListBox.DragDrop.Feedback=null,Smart.Utilities.Core.isMobile&&Smart.ListBox.DragDrop.Dragging)for(let t=0;t<Smart.ListBox.DragDrop.ListBoxes.length;t++){const r=Smart.ListBox.DragDrop.ListBoxes[t],o=r.getBoundingClientRect();if(r.allowDrop&&!r.closest(".smart-visibility-hidden")&&o.left<=e.clientX&&e.clientX<=o.left+o.width&&o.top<=e.clientY&&e.clientY<=o.top+o.height){i=r;const t=r._items.filter((e=>!e.hidden));for(let i=0;i<t.length;i++){const s=t[i],n=s.getBoundingClientRect();if((t.indexOf(s)===t.length-1||s.parentNode.lastElementChild===s)&&e.clientY>=o.top+s.offsetTop-r.scrollTop+n.height/2&&e.clientY<=o.top-r.scrollTop+s.offsetTop+n.height){Smart.ListBox.DragDrop.DropDetails={item:s,position:"bottom"};break}if(e.clientY>=o.top+s.offsetTop-r.scrollTop&&e.clientY<=o.top+s.offsetTop+n.height-r.scrollTop){Smart.ListBox.DragDrop.DropDetails={item:s,position:"top"};break}}}}if(Smart.ListBox.DragDrop.Dragging){if(Smart.ListBox.DragDrop.DropDetails){let r=Smart.ListBox.DragDrop.DropDetails.item,o=Smart.ListBox.DragDrop.Item;const s=o.ownerListBox;let n=e.originalEvent.target;if(t.isInShadowDOM&&(n=e.originalEvent?e.originalEvent.composedPath()[0]:e.composedPath()[0]),i=!i&&n.closest?n.closest("smart-list-box"):i,document.body.classList.remove("smart-dragging"),r.$.removeClass("smart-list-item-line-feedback"),r.$.removeClass("smart-list-item-bottom-line-feedback"),i&&r.ownerListBox!==i&&i.items.length>0&&(r=i.items[i.items.length-1]),Smart.ListBox.DragDrop.Item===r||i!==r.ownerListBox&&!Smart.Utilities.Core.isMobile)i&&0===i._items.length&&"none"!==i.dropAction&&("move"===i.dropAction?Smart.ListBox.DragDrop.Item.ownerListBox.removeChild(Smart.ListBox.DragDrop.Item):"copy"===i.dropAction&&(o=o.cloneNode(!0)),i.appendChild(o));else if("none"!==o.ownerListBox.dropAction){r.ownerListBox!==o.ownerListBox&&"move"===o.ownerListBox.dropAction&&Smart.ListBox.DragDrop.Item.ownerListBox.removeChild(Smart.ListBox.DragDrop.Item),"copy"===o.ownerListBox.dropAction&&(o=o.cloneNode(!0)),Smart.ListBox.DragDrop.Item.group=r.group;const e=r.ownerListBox;"checkBox"!==e.selectionMode&&"radioButton"!==e.selectionMode&&e.clearSelection(),"top"===Smart.ListBox.DragDrop.DropDetails.position?e.insertBefore(o,r):r.parentNode.lastElementChild===r?e.appendChild(o):e.appendChild(o,r),e.ensureVisible(o),"checkBox"===e.selectionMode||"radioButton"===e.selectionMode?(e._focus(o),e._refreshSelection()):(e.clearSelection(),e.select(o))}o.selected&&i!==s&&s._refreshSelection();const l=Smart.ListBox.DragDrop.Item,a=l.ownerListBox;l.displayMode="checkBox"===a.selectionMode||"radioButton"===a.selectionMode?a.selectionMode:"plain",a.$.fireEvent("dragEnd",{item:l,target:r,data:Smart.ListBox.DragDrop,previousContainer:s,container:i,originalEvent:e}),a._focus(l)}else{const t=Smart.ListBox.DragDrop.Item,i=t.ownerListBox;t.displayMode="checkBox"===i.selectionMode||"radioButton"===i.selectionMode?i.selectionMode:"plain",document.body.classList.remove("smart-dragging"),i.$.fireEvent("dragEnd",{item:t,target:null,data:Smart.ListBox.DragDrop,previousContainer:i,container:i,originalEvent:e}),i._focus(t)}e.preventDefault()}delete Smart.ListBox.DragDrop.DraggedFrom,Smart.ListBox.DragDrop.Dragging=!1,Smart.ListBox.DragDrop.Item=null,Smart.ListBox.DragDrop.DropDetails=null}for(let e=0;e<Smart.ListBox.DragDrop.ListBoxes.length;e++){const t=Smart.ListBox.DragDrop.ListBoxes[e];t._dragInterval&&clearInterval(t._dragInterval)}}}_itemsContainerMoveHandler(e){const t=this;if(Smart.ListBox.DragDrop.Dragging)return t._applyItemFeedback(e),t._moveHandler(e),e.originalEvent.preventDefault(),e.originalEvent.stopPropagation(),!1}_touchmoveHandler(e){if(Smart.ListBox.DragDrop.Dragging&&e.cancelable)return e.preventDefault(),void e.stopPropagation();super._touchmoveHandler(e)}_applyItemFeedback(e){const t=this,i=e.originalEvent.target,r=i.closest?i.closest("smart-list-item"):i;Smart.Utilities.Core.isMobile?Smart.ListBox.DragDrop.DropDetails={item:Smart.ListBox.DragDrop.Item,position:"bottom"}:0!==t.items.length&&(r?r._itemOnMouseMove(e):t.items[t.items.length-1]._itemOnMouseMove(e,!0))}_moveHandler(e){const t=this;if(!Smart.ListBox.DragDrop.Feedback||Smart.ListBox.DragDrop.DraggedFrom!==t)return;const i=t.dragOffset;if(Smart.ListBox.DragDrop.Dragging){Smart.ListBox.DragDrop.Feedback.style.left=i[0]+e.pageX+"px",Smart.ListBox.DragDrop.Feedback.style.top=i[1]+e.pageY+"px",t.$.fireEvent("dragging",{item:Smart.ListBox.DragDrop.Item,data:Smart.ListBox.DragDrop,originalEvent:e.originalEvent});for(let t=0;t<Smart.ListBox.DragDrop.ListBoxes.length;t++){const i=Smart.ListBox.DragDrop.ListBoxes[t];i._dragInterval&&clearInterval(i._dragInterval),i._dragInterval=setInterval((function(){const t=i.getBoundingClientRect();t.left<=e.clientX&&t.left+t.width>=e.clientX&&(e.clientY>=t.top&&e.clientY<=t.top+20?i.scrollTop-=2:e.clientY>=t.top+t.height-20&&e.clientY<=t.top+t.height&&(i.scrollTop+=2))}),1)}return e.preventDefault(),e.stopPropagation(),e.originalEvent.preventDefault(),e.originalEvent.stopPropagation(),!1}{const r=Math.abs(e.pageX-Smart.ListBox.DragDrop.StartPosition.left),o=Math.abs(e.pageY-Smart.ListBox.DragDrop.StartPosition.top),s=new Date-Smart.ListBox.DragDrop.StartTime;let n=r>=5&&r<=15||o>=5&&o<=15;if(Smart.Utilities.Core.isMobile&&(s<300||s>1e3)&&(n=!1),n){Smart.ListBox.DragDrop.Dragging=!0,Smart.ListBox.DragDrop.Feedback.style.left=i[0]+e.pageX+"px",Smart.ListBox.DragDrop.Feedback.style.top=i[1]+e.pageY+"px",t.getShadowRootOrBody().appendChild(Smart.ListBox.DragDrop.Feedback),e.preventDefault(),e.stopPropagation(),e.originalEvent.preventDefault(),e.originalEvent.stopPropagation();const r=Smart.ListBox.DragDrop.Item,o=r.ownerListBox;o.$.fireEvent("dragStart",{item:r,data:Smart.ListBox.DragDrop,container:o,previousContainer:o,originalEvent:e.originalEvent}),document.body.classList.add("smart-dragging")}}}_focusHandler(){this._focused=!0,this.setAttribute("focus","")}_blurHandler(){this._focused=!1,this.removeAttribute("focus")}appendChild(e){const t=this;if(!t.isCompleted){const e=Array.prototype.slice.call(arguments,2);return HTMLElement.prototype.appendChild.apply(t,e.concat(Array.prototype.slice.call(arguments)))}t.isVirtualized?(t._items.indexOf(e)>-1&&t._items.splice(t._items.indexOf(e),1),t._items.push(e)):(e.dataItem=e,t.shadowRoot&&"light"===t.shadowDomMode?t.appendChild(e):t.$.itemsInnerContainer.appendChild(e),t._items.indexOf(e)>-1&&t._items.splice(t._items.indexOf(e),1),t._items.push(e)),t._refreshItems(),t._refreshSelection()}insertBefore(e,t){const i=this;if(!i.isCompleted){const e=Array.prototype.slice.call(arguments,2);return HTMLElement.prototype.insertBefore.apply(i,e.concat(Array.prototype.slice.call(arguments)))}i.isVirtualized?(i._items.indexOf(e)>-1&&i._items.splice(i._items.indexOf(e),1),i._items.splice(i._indexOf(t),0,e)):(e.dataItem=e,t.parentNode.insertBefore(e,t),i._items.indexOf(e)>-1&&i._items.splice(i._items.indexOf(e),1),i._items.splice(i._indexOf(t),0,e)),i._refreshItems(),i._refreshSelection()}removeChild(e){const t=this;if(!t.isCompleted){const e=Array.prototype.slice.call(arguments,2);return HTMLElement.prototype.removeChild.apply(t,e.concat(Array.prototype.slice.call(arguments)))}if(t.isVirtualized)t._items.splice(t._indexOf(e),1);else if(e.parentNode){const i=t.selectedIndexes.slice(0),r=t.selectedValues.slice(0),o=i.indexOf(e.dataIndex);e.parentNode.removeChild(e),o>-1&&(i.splice(o,1),r.splice(o,1),t.selectedIndexes=i,t.selectedValues=r)}t._refreshItems()}propertyChangedHandler(e,t,i){if("dataSource"===e&&(!i||i&&Array.isArray(i)&&0===i.length))return void this.clearItems();super.propertyChangedHandler(e,t,i);const r=this;switch(e){case"innerHTML":r.clearSelection(),r._dataBind(),r.innerHTML=r.content=Smart.Utilities.Core.html(r.$.content);break;case"dataSource":case"valueMember":case"groupMember":case"displayMember":r.clearSelection(),r._dataBind(),r._applyDefaultSelection();break;case"disabled":case"unfocusable":r._setFocusable();break;case"displayLoadingIndicator":r._setLoadingIndicatorVisibility();break;case"filterable":r._refreshFilter(),r._refreshLayout();break;case"grouped":if(i?r._group():r._ungroup(),"radioButton"===r.selectionMode){if(r.selectedValues.length>0){const e=r.selectedValues;r.clearSelection(),r.select(e[0])}}else r._refreshSelection();r._refreshLayout();break;case"itemTemplate":{if(null===i||""===i)return r._items.map((e=>e.innerHTML=e.label)),delete r._bindingDetails,void r._refreshLayout();const e=r.querySelectorAll("smart-list-item"),t=function(){r._handleItemTemplate(i)&&(r._items.map((e=>r._applyTemplate(e))),r._refreshLayout()),r.ownerElement&&r.ownerElement._setDropDownSize&&r.ownerElement._setDropDownSize(),r.$.fireEvent("bindingComplete")};0===e.length?t():r._ensureItemsReady(e,t);break}case"selectedIndexes":case"selectedValues":{let o=r.selectedIndexes.slice(0),s=r.selectedValues.slice(0);if(!r._items||0===r._items.length)return r.selectedIndexes=[],r.selectedValues=[],void(r.$.hiddenInput.value=r.selectedValues.toString());if(r._propertyChanging=!0,"selectedIndexes"===e){o=t.slice(0),r.clearSelection();for(let e=0;e<i.length;e++){const t=i[e],o=r._items[t];o&&("oneOrManyExtended"===r.selectionMode||"oneOrMany"===r.selectionMode?(r.selectedIndexes.length>0&&0===e&&r.clearSelection(),r._select(o)):r.select(o))}}else{s=t.slice(0),r.selectedValues=[],r.clearSelection();for(let e=0;e<i.length;e++){const t=i[e],o=r.getItem(t);o&&("oneOrManyExtended"===r.selectionMode?r._select(o):r.select(o))}}if(r.selectedIndexes.length>0&&r._focus(r._items[r.selectedIndexes[0]]),r._propertyChanging=!1,JSON.stringify(s)!==JSON.stringify(r.selectedValues.slice(0))){let e=[],t=[];for(let e=0;e<o.length;e++)r.selectedIndexes.indexOf(o[e])<0&&t.push(r._items[o[e]]);for(let t=0;t<r.selectedIndexes.length;t++)o.indexOf(r.selectedIndexes[t])<0&&e.push(r._items[r.selectedIndexes[t]]);let i={addedItems:e,removedItems:t};if(r.selectedIndexes.length>0){const e=r._items[r.selectedIndexes[r.selectedIndexes.length-1]];void 0!==e&&(i.selected=e.selected,i.disabled=e.disabled,i.index=r._indexOf(e),i.label=e.label,i.value=e.value)}else i.selected=!1,i.disabled=!1,i.index=-1,i.label="",i.value="";r.$.fireEvent("change",i),r._updateTargetValue()}break}case"selectionMode":{const e="checkBox"===r.selectionMode||"radioButton"===r.selectionMode?r.selectionMode:"plain",o=r.selectedIndexes.slice(0),s=r.selectedValues.slice(0);r._propertyChanging=!0;const n=r.selectedValues;r.setAttribute("aria-multiselectable",-1!==["oneOrManyExtended","zeroOrMany","oneOrMany","checkBox","radioButton"].indexOf(i)),r.selectedValues=[],r.clearSelection();for(let e=0;e<n.length;e++){const t=n[e],i=r.getItem(t);i&&("oneOrManyExtended"===r.selectionMode?r._select(i):r.select(i))}if(r._items.forEach((t=>t.displayMode=e)),r._recycle(),r._propertyChanging=!1,JSON.stringify(s)!==JSON.stringify(r.selectedValues.slice(0))){let e=[],t=[];for(let e=0;e<o.length;e++)r.selectedIndexes.indexOf(o[e])<0&&t.push(r._items[o[e]]);for(let t=0;t<r.selectedIndexes.length;t++)o.indexOf(r.selectedIndexes[t])<0&&e.push(r._items[r.selectedIndexes[t]]);let i={addedItems:e,removedItems:t};if(o.length>0){const e=r._items[o[o.length-1]];e&&(i.selected=e.selected,i.disabled=e.disabled,i.index=r._indexOf(e),i.label=e.label,i.value=e.value)}r.$.fireEvent("change",i),r._updateTargetValue()}r._applyAriaSelected(),"checkBox"!==i&&"radioButton"!==i&&"checkBox"!==t&&"radioButton"!==t||r._refreshLayout();break}case"topVisibleIndex":r._setTopVisibleIndex(i);break;case"autoSort":r._canSort=i;break;case"alternationStart":case"alternationEnd":case"alternationCount":r._refreshItems(),r._refreshLayout();break;case"sortDirection":case"sorted":{r._canSort=!0,i?r._sort():r._unsort();const e=r.selectedValues;r.selectedValues=[],r._refreshSelection();for(let t=0;t<e.length;t++){const i=e[t],o=r.getItem(i);o&&("oneOrManyExtended"===r.selectionMode?r._select(o):r.select(o))}r._refreshLayout(),r._canSort=r.autoSort;break}}}_refreshSelection(){const e=this;if(!e._items||0===e._items.length)return;const t=e.selectedValues;e.selectedIndexes=[],e.selectedValues=[];for(let i=0;i<e._items.length;i++){const r=e._items[i];r.selected=!1,t.indexOf(r.value)>-1&&e.select(r)}e._recycle()}clearSelection(){const e=this;if(!e._items||0===e._items.length)return;let t=[];for(let i=0;i<e._items.length;i++)e._items[i].selected&&t.push(e._items[i]);e._items.map((e=>e.selected=!1)),e.selectedValues.slice(0);const i=e.selectedIndexes.slice(0);if(e.selectedIndexes=[],e.selectedValues=[],e.$.hiddenInput.value=e.selectedValues.toString(),e._recycle(),e.context!==e){let r={addedItems:[],removedItems:t};if(i.length>0){const t=e._items[i[i.length-1]];t&&(r.selected=t.selected,r.disabled=t.disabled,r.index=e._indexOf(t),r.label=t.label,r.value=t.value)}e.$.fireEvent("change",r),e._updateTargetValue()}}ensureVisible(e){const t=this;if(e)return!("string"==typeof e&&!(e=t.getItem(e))||(t.isVirtualized||t.$.itemsContainer.scrollTop===t.scrollTop||(t.scrollTop=t.$.itemsContainer.scrollTop),e.top+e.height>=t.scrollTop+t.offsetHeight&&(t.scrollTop=t.scrollTop+e.height,t.isVirtualized||(t.$.itemsContainer.scrollTop=t.scrollTop)),(e.top<=t.scrollTop||e.top>=t.scrollTop+t.$.itemsContainer.offsetHeight)&&(t.scrollTop=e.top,t.isVirtualized||(t.$.itemsContainer.scrollTop=t.scrollTop)),0===t._indexOf(e)||1===t._indexOf(e)&&t._items.length>1&&t._items[0].grouped?(t.scrollTop=0,t.isVirtualized||(t.$.itemsContainer.scrollTop=t.scrollTop)):t._indexOf(e)===t._items.length-1&&(t.scrollTop=t.scrollHeight,t.isVirtualized||(t.$.itemsContainer.scrollTop=t.scrollTop)),0))}get items(){const e=this;if(!window.__karma__&&!window.karma&&e instanceof Element&&e.isRendered&&e.hasAttribute&&e.hasAttribute("smart-blazor")){let t=[];for(let i=0;i<e._items.length;i++){const r=e._items[i];t.push({label:r.label,value:r.value})}return t}return e._filteredItems?e._filteredItems:e._items}getItems(){const e=this,t=e._filteredItems?e._filteredItems:e._items;let i=[];if(t&&t.length>0)for(let e=0;e<t.length;e++){const r=t[e];i.push({label:r.label,value:r.value})}return i}ready(){super.ready();const e=this;if(e.shadowRoot&&"light"===e.shadowDomMode){const t=document.createDocumentFragment();[].slice.call(e.$.itemsInnerContainer.children).map((e=>t.appendChild(e))),e.appendChild(t),e.$.itemsInnerContainer.appendChild(document.createElement("slot"))}e._areCSSVarsSupported=Smart.Utilities.Core.CSSVariablesSupport(),e.isUpdating=0,e._scrollView&&(e._scrollView=new Smart.Utilities.Scroll(e,e.$.horizontalScrollBar,e.$.verticalScrollBar),e._scrollView.hScrollBar.$.addClass("smart-hidden"),e._scrollView.vScrollBar.$.addClass("smart-hidden"));const t=e._scrollView.vScrollBar,i=e._scrollView.hScrollBar;t.hasStyleObserver=!1,i.hasStyleObserver=!1,t.hasResizeObserver=!1,i.hasResizeObserver=!1,t.wait=!1,i.wait=!1,e._setFocusable()}render(){const e=this;e.setAttribute("role","listbox"),e.setAttribute("aria-orientation","vertical"),e.$.verticalScrollBar.setAttribute("aria-controls",e.id),e.$.horizontalScrollBar.setAttribute("aria-controls",e.id),e._keysPressed={},e._incrementalSearchQuery="",e._incrementalSearchItems=[],e._canSort=!0,e._previousEntry="",e._setLoadingIndicatorVisibility(),e._refreshFilter(),e._initializeInnerHTML(),e._dataBind(),e._applyDefaultSelection(),e.enableShadowDOM&&HTMLElement.prototype.appendChild.apply(e,[e.$.hiddenInput]),e.setAttribute("aria-multiselectable",-1!==["oneOrManyExtended","zeroOrMany","oneOrMany","checkBox","radioButton"].indexOf(e.selectionMode)),super.render()}_lazyInitItems(){const e=this;if(e._inLazyInit)return cancelAnimationFrame(Smart.ListBox.processTimer),void delete Smart.ListBox.processTimer;e._inLazyInit=!0,e.dataSource||(e.clearSelection(),e._dataBind(),e._applyDefaultSelection()),cancelAnimationFrame(Smart.ListBox.processTimer),delete Smart.ListBox.processTimer,e._inLazyInit=!1}_applyDefaultSelection(){const e=this;!e._focusedItem&&e._items&&e._items.length>0&&0===e.selectedIndexes.length&&("one"!==e.selectionMode&&"oneOrMany"!==e.selectionMode&&"oneOrManyExtended"!==e.selectionMode||e.select(e._items[0]))}attached(){const e=this;super.attached(),Smart.ListBox.DragDrop||(Smart.ListBox.DragDrop={ListBoxes:[]}),Smart.ListBox.DragDrop.ListBoxes.push(e),e._scrollView||(e._scrollView=new Smart.Utilities.Scroll(e,e.$.horizontalScrollBar,e.$.verticalScrollBar)),e.selectedIndexes.length>0&&e._items&&e.ensureVisible(e._items[e.selectedIndexes[0]])}detached(){const e=this;if(super.detached(),e._scrollView&&(e._scrollView.unlisten(),delete e._scrollView),Smart.ListBox.DragDrop&&Smart.ListBox.DragDrop.ListBoxes){const t=Smart.ListBox.DragDrop.ListBoxes.indexOf(e);Smart.ListBox.DragDrop.ListBoxes.splice(t,1)}}_createItem(e,t,i){const r=this,o="checkBox"===r.selectionMode||"radioButton"===r.selectionMode?r.selectionMode:"plain",s=i?{}:document.createElement("smart-list-item");s.ownerListBox=r,"number"==typeof e&&(e=""+e);const n=function(t,i){return void 0!==e[t]?""+e[t]:e[i]};let l="string"==typeof e?e:n(r.displayMember,"label"),a="string"==typeof e?e:n(r.valueMember,"value"),d=n(r.groupMember,"group");return void 0===l&&(l=void 0!==t?""+t:""),s.label=s.innerHTML=""+l,void 0===a&&(a=void 0!==t?""+t:l),e.color&&(s.color=e.color),s.value=""+a,s.displayMode=o,s.selected=!!e.selected&&e.selected,s.disabled=!!e.disabled&&e.disabled,s.dataItem=s,void 0!==t&&(s.dataIndex=t),r._alternateItem(s),e.title&&(s.title=e.title),d&&(s.group=""+d),s}_alternateItem(e){const t=this,i=t.alternationStart,r=t.alternationEnd>0?t.alternationEnd:1/0;t.alternationCount<=0||(void 0===t._alternationIndexCounter&&(t._alternationIndexCounter=0),e.dataIndex>=i&&e.dataIndex<=r&&(e.alternationIndex=t._alternationIndexCounter++,t._alternationIndexCounter===t.alternationCount&&(t._alternationIndexCounter=0)))}_beginUpdate(){this.isUpdating++}_isUpdating(){return this.isUpdating>0}_endUpdate(){this.isUpdating--}get _scrollHeight(){const e=this;if(0===e._items.length||e._items.filter((e=>!e.hidden)).length<1)return 0;let t=0;if(e.isVirtualized){if(e.__scrollHeight)return e.__scrollHeight;if(0===e._items.length)return 0;e.isUpdating++;const i=e._createItem(e.dataSource[0]);e.$.itemsInnerContainer.appendChild(i);for(let r=0;r<e._items.length;r++){const o=e._items[r];o.hidden?(o.height=0,o.top=t):(e.itemHeight?(e.itemHeight<32&&(e.itemHeight=32),o.height=e.itemHeight):(i.$&&i.$.itemContainer?i.$.itemContainer.firstElementChild.innerHTML=o.label:i.label=o.label,o.height=i.offsetHeight),o.top=t,t+=o.height)}e.$.itemsInnerContainer.removeChild(i),e.__scrollHeight=t-e.$.itemsInnerContainer.offsetHeight,e.filterable&&(e.__scrollHeight+=e.$.filterInput.offsetHeight),t=e.__scrollHeight,e.isUpdating--}else{for(let i=0;i<e._items.length;i++){const r=e._items[i];r.hidden?(r.height=0,r.top=t):(e.itemHeight?"auto"!==e.itemHeight&&(r.height=e.itemHeight,r.style.height=r.height+"px"):r.height=r.offsetHeight,r.top=r.offsetTop,t+=r.height)}t=e.$.itemsInnerContainer.scrollHeight-e.$.itemsInnerContainer.offsetHeight,e.filterable&&t>0&&(t+=e.$.filterInput.offsetHeight),e.__scrollHeight=t}return t}_initializeRecyclingItems(){const e=this;if(!e.dataSource||e.dataSource&&0===e.dataSource.length||!e.isVirtualized)return;let t=0,i=e.offsetHeight||400;e.$.itemsInnerContainer.innerHTML="",e._recyclingItems=[];const r=function(){for(let r=0;r<e.dataSource.length;r++){const o=e.dataSource[r],s=e._createItem(o);if(e.itemHeight&&"auto"!==e.itemHeight&&(s.style.height=e.itemHeight+"px"),e.$.itemsInnerContainer.appendChild(s),t+=s.offsetHeight,s.dataItem=e._items[r],e._recyclingItems.push(s),t>1.5*i)break}};r();let o=0;for(;t<1.5*i&&++o<5;)r()}_dataBind(){const e=this;if(e._scrollView||(e._scrollView=new Smart.Utilities.Scroll(e,e.$.horizontalScrollBar,e.$.verticalScrollBar)),"function"==typeof e.dataSource&&(e._items=[],delete e._filteredItems),"string"==typeof e.dataSource&&(e.dataSource=JSON.parse(e.dataSource)),null!==e.dataSource&&Array.isArray(e.dataSource)){e.isUpdating++;const t=t=>{e._items=[],e._groups=[],delete e._filteredItems;const i=e.dataSource;for(let r=0;r<i.length;r++){const o=i[r],s=e._createItem(o,r,!t);e._items[r]=s,t&&t.appendChild(s)}};if(e.isVirtualized)t(),e._initializeRecyclingItems();else{const i=document.createDocumentFragment();e.$.itemsInnerContainer.innerHTML="",t(i),e.$.itemsInnerContainer.appendChild(i)}e.isUpdating--}const t=e.shadowRoot?e.shadowRoot.querySelectorAll("smart-list-item"):e.querySelectorAll("smart-list-item"),i=function(){e.isUpdating++,e.dataSource||(e._initializeHtmlListItems(),e._initializeHtmlListGroups()),e.grouped&&e._group(),e.sorted&&e._sort(),e._refreshLayout(),e._initializeSelection(),e.isInitialized=!0,e._canSort=e.autoSort,e.isUpdating--,e.itemTemplate&&e._handleItemTemplate(e.itemTemplate)&&(e._items.map((t=>e._applyTemplate(t))),e._refreshLayout()),e.__onCompleted&&(e._onCompleted=e.__onCompleted,e.__onCompleted=null,e._onCompleted()),e.topVisibleIndex>-1&&e._setTopVisibleIndex(e.topVisibleIndex),e.$.fireEvent("bindingComplete"),e._updateTopVisibleIndex(),0===e._items.length&&e.clearItems(),e._applyAriaSelected()};0===t.length?i():(e._onCompleted&&(e.__onCompleted=e._onCompleted,e._onCompleted=null),e._ensureItemsReady(t,i))}_ensureItemsReady(e,t){const i=this,r=function(){const i=function(t){for(let i=0;i<e.length;i++)e[i].context="node"===t?e[i]:document};i("node"),t(),i()};if(0===e.length)r();else{i._nodesReadyListeners=0;for(let t=0;t<e.length;t++){const o=e[t],s=function(){i._nodesReadyListeners--,0===i._nodesReadyListeners&&(r(),delete i._nodesReadyListeners)}.bind(i);o.isCompleted||(i._nodesReadyListeners++,o._onCompleted=s)}0===i._nodesReadyListeners&&r()}}_initializeInnerHTML(){const e=this;e.$.itemsInnerContainer.innerHTML.indexOf("<option")>=0?e.$.itemsInnerContainer.innerHTML=e.$.itemsInnerContainer.innerHTML.replace(/<optgroup/gi,"<smart-list-items-group").replace(/<\/optgroup/gi,"</smart-list-items-group").replace(/<option/gi,"<smart-list-item").replace(/<\/option/gi,"</smart-list-item"):e.$.itemsInnerContainer.innerHTML.indexOf("<ul")>=0&&(e.$.itemsInnerContainer.innerHTML=e.$.itemsInnerContainer.innerHTML.replace(/<ul/gi,"<smart-list-items-group").replace(/<\/ul/gi,"</smart-list-items-group").replace(/<li/gi,"<smart-list-item").replace(/<\/li/gi,"</smart-list-item"))}_initializeHtmlListItems(){const e=this,t=e.shadowRoot&&"shadow"===e.shadowDomMode?e.shadowRoot.querySelectorAll("smart-list-item"):e.querySelectorAll("smart-list-item"),i="checkBox"===e.selectionMode||"radioButton"===e.selectionMode?e.selectionMode:"plain",r=function(e,t,i){return void 0!==e[t]?""+e[t]:e[i]};e._items=[];let o=0;for(let s=0;s<t.length;s++){const n=t[s];n.dataIndex=s,n.label=n.innerHTML,n.dataItem=n,n.top||(n.top=o),n.height||(n.height=n.offsetHeight),o+=n.height,n.value||(n.value=""+s);const l=r(n,e.displayMember,"label"),a=r(n,e.valueMember,"value"),d=r(n,e.groupMember,"group");n.label!==l&&(n.label=l),n.value!==a&&(n.value=a),n.group!==d&&(n.group=d);const c=n.context;n.context=document,n.displayMode=i,n.context=c,e._alternateItem(n),n.selected&&(e.selectedIndexes.push(s),e.selectedValues.push(n.value)),e._items.push(n)}e.itemTemplate&&e._handleItemTemplate(e.itemTemplate)&&e._items.map((t=>e._applyTemplate(t)))}_group(){const e=this;e.isUpdating++;let t=[],i=[];e._canSort&&e._unsort();for(let i=0;i<e._items.length;i++){const r=e._items[i];let o=r.group?r.group.trim():r.innerHTML.charAt(0)||r.label.charAt(0);o+=" ",t[o]?t[o].items.push(r):t[t.length++]=t[o]={items:[r],label:o}}if(e.isVirtualized){e._groups=[];for(let e=0;e<t.length;e++){const r=t[e];r.dataIndex=e,r.grouped=!0,r.hidden=!1,r.displayMode="plain",i.push(r);for(let o=0;o<t[e].items.length;o++){const e=r.items[o];e.group=r,i.push(e)}}e._groups=t,e._items=i}else{for(;e.$.itemsInnerContainer.firstChild;)e.$.itemsInnerContainer.removeChild(e.$.itemsInnerContainer.firstChild);const r=document.createDocumentFragment();e._groups=[];for(let o=0;o<t.length;o++){const s=t[o],n=document.createElement("smart-list-items-group");n.label=s.label,n.dataIndex=o;for(let e=0;e<t[o].items.length;e++){const t=s.items[e];i.push(t),t.group=s.label,n.appendChild(t)}e._groups.push(n),r.appendChild(n)}e._items=i,/Trident|Edge/.test(navigator.userAgent)?setTimeout((function(){e.$.itemsInnerContainer.appendChild(r)}),50):e.$.itemsInnerContainer.appendChild(r)}e.sorted&&e._sort(),e.isUpdating--}_ungroup(){const e=this;e.isUpdating++,e._groups=[],e._canSort&&e._unsort();let t=[];if(e.isVirtualized)for(let i=0;i<e._items.length;i++){const r=e._items[i];r.grouped||t.push(r)}else{const i=document.createDocumentFragment();for(let r=0;r<e._items.length;r++){const o=e._items[r];i.appendChild(o),t.push(o)}t.length>0&&(e.$.itemsInnerContainer.innerHTML="",e.$.itemsInnerContainer.appendChild(i))}e._items=t,e.sorted&&e._sort(),e.isUpdating--}_initializeHtmlListGroups(){const e=this,t=e.$.itemsInnerContainer.querySelectorAll("smart-list-items-group");e._groups=[];for(let i=0;i<t.length;i++){const r=t[i];r.dataIndex=i,e._groups.push(r)}}_initializeSelection(){const e=this,t=e.selectedIndexes.slice(0),i=e.selectedValues.slice(0);e.clearSelection(),"oneOrManyExtended"===e.selectionMode&&(e._keysPressed.Control=!0);for(let r=0;r<e._items.length;r++){const o=e._items[r];(t.indexOf(r)>=0||i.indexOf(o.value||o.label)>=0)&&(e._focusedItem&&(e._focusedItem._focused=!1),e._focusedItem=null,e.select(o))}"oneOrManyExtended"===e.selectionMode&&(e._keysPressed.Control=!1)}onItemUpdated(){const e=this;e.isInitialized&&!e._isUpdating()&&(e.isUpdating++,e._refreshLayout(),e.isUpdating--)}_refreshItems(){const e=this;if(e.isInitialized&&!e._isUpdating()){if(e.isUpdating++,e.grouped?e._ungroup():e.sorted&&e._canSort&&e._unsort(),!e.isVirtualized){e._items=[];const t=e.shadowRoot?e.shadowRoot.querySelectorAll("smart-list-item"):e.querySelectorAll("smart-list-item");for(let i=0;i<t.length;i++)t[i].dataIndex=i,e._alternateItem(t[i]),e._items.push(t[i])}e.grouped?e._group():e.sorted&&e._sort(),e._refreshLayout(),e.isUpdating--}}_applyIncrementalSearch(e){const t=this;null===t.incrementalSearchDelay||isNaN(t.incrementalSearchDelay)||["Shift","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Control","Home","End","PageUp","PageDown"].indexOf(e)>-1||(0!==t._incrementalSearchQuery.indexOf(e)&&(t._incrementalSearchQuery+=e),t._incrementalSearchTimer&&clearTimeout(t._incrementalSearchTimer),t._incrementalSearch(),t._incrementalSearchTimer=setTimeout((function(){t._incrementalSearchQuery=""}),t.incrementalSearchDelay))}select(e){const t=this;if(("string"!=typeof e||(e=t.getItem(e)))&&("number"!=typeof e||(e=t.getItem(e)))&&!(e.grouped||e.readonly||!t._items.length||e instanceof HTMLElement&&!t.contains(e))){if("none"===t.selectionMode)return t.selectedIndexes=[],void(t.selectedValues=[]);switch(!t._focusedItem!==e&&"none"!==t.selectionMode&&(t._focusedItem&&(t._focusedItem._focused=!1),t._focusedItem=e,e._focused=!0),t.selectionMode){case"one":case"zeroAndOne":return(1!==t.selectedIndexes.length||t.selectedIndexes[0]!==t._indexOf(e))&&(t._previouslySelectedIndexes=t.selectedIndexes,t.selectedIndexes.length>=1&&t.clearSelection(),t._select(e),delete t._previouslySelectedIndexes,!0);case"zeroOrOne":return 1===t.selectedIndexes.length&&t.selectedIndexes[0]===t._indexOf(e)?(t.unselect(e),!0):(t._previouslySelectedIndexes=t.selectedIndexes,t.selectedIndexes.length>=1&&t.clearSelection(),t._select(e),delete t._previouslySelectedIndexes,!0);case"radioButton":if(t._previouslySelectedIndexes=t.selectedIndexes,t.$.itemsInnerContainer.querySelectorAll("smart-list-items-group").length>0){const i=e.parentNode;if(!e.selected){for(let e in i.children){const r=i.children[e];r.selected&&t.unselect(r)}t._select(e)}return delete t._previouslySelectedIndexes,!0}if(t.isVirtualized&&t._groups.length>0){const i=e.group;if(!e.selected){for(let e in i.items){const r=i.items[e];r.selected&&t.unselect(r)}t._select(e)}return delete t._previouslySelectedIndexes,!0}return e.selected||(t.selectedIndexes.length>=1&&t.clearSelection(),t._select(e)),delete t._previouslySelectedIndexes,!0;case"oneOrMany":return e.selected?t.selectedIndexes.length>1&&t.unselect(e):t._select(e),!0;case"zeroOrMany":case"checkBox":return e.selected?t.unselect(e):t._select(e),!0;case"oneOrManyExtended":{const i=t.selectedValues;if(t._keysPressed.Control)return t.selectedIndexes.length>1&&e.selected?(t.unselect(e),t._focus(t._items[t.selectedIndexes[0]])):t._select(e),!0;if(t._keysPressed.Shift){const r=t._items[t.selectedIndexes[0]];let o;t.clearSelection();const s=i.indexOf(r.value)>=0||r.selected;if(t._select(r,s),t._indexOf(r)>t._indexOf(e))for(o=t._indexOf(r)-1;o>=t._indexOf(e);){const e=t._items[o],r=i.indexOf(e.value)>=0||e.selected;t._select(e,r),o--}else for(o=t._indexOf(r)+1;o<=t._indexOf(e);){const e=t._items[o],r=i.indexOf(e.value)>=0||e.selected;t._select(e,r),o++}const n=[];for(let e=0;e<i.length;e++)n.push(t.getItem(i[e]));if(n.length>0&&!t._propertyChanging){let r=[];for(let e=0;e<t.selectedValues.length;e++){const o=t.selectedValues[e];i.indexOf(o)<0&&r.push(t.getItem(o))}t.$.fireEvent("change",{addedItems:r,removedItems:n,selected:e.selected,disabled:e.disabled,index:t._indexOf(e),label:e.label,value:e.value}),t._updateTargetValue()}return!0}for(let r=0;r<i.length;r++){const o=i[r],s=t.getItem(o);e!==s&&t.unselect(s)}return t.clearSelection(),t._select(e,i.indexOf(e.value)>=0),!0}}return!1}}_applyTemplate(e,t){const i=this;if(null===i.itemTemplate)return;if("function"==typeof i.itemTemplate)return void i.itemTemplate(e,{label:e.label,value:e.value,index:i._items.indexOf(e)});if(!i._bindingDetails||0===i._bindingDetails.length)return;const r=i._bindingDetails.length;let o,s,n=document.importNode(i._template.content,!0);for(let t=0;t<r;t++){o=n.childNodes[i._bindingDetails[t].childNodeIndex],s=i._bindingDetails[t].bindingString.length;for(let r=0;r<s;r++){const s=i._bindingDetails[t].bindingString[r],n=s.indexOf("label")>=0?e.label:e.value;o.innerHTML=o.innerHTML.replace(s,n)}}e.innerHTML="";for(let t=0;t<n.childNodes.length;t++)n.childNodes[t].outerHTML&&(e.innerHTML+=n.childNodes[t].outerHTML);!1!==t&&(i._scrollHeightTimer&&(clearInterval(i._scrollHeightTimer),i._scrollHeightCounter=0),i._scrollHeightTimer=setInterval((function(){i._lastScrollHeight===i.$.itemsInnerContainer.scrollHeight&&10!==i._scrollHeightCounter||(i._refreshLayout(),clearInterval(i._scrollHeightTimer)),i._lastScrollHeight=i.$.itemsInnerContainer.scrollHeight,i._scrollHeightCounter++}),50))}_filterItems(e,t,i){const r=this,o=r.$.filterInput.value;let s,n;const l=function(){if(0===n.length)return r._filteredItems=[],void(t&&t());s=r._queryItems(o,r.filterMode);for(let e=0;e<n.length;e++)n[e].hidden=!0,n[e].$&&n[e].$.addClass("smart-hidden");for(let e=0;e<s.length;e++){const t=s[e];t.hidden=!1,n[e].$&&t.$.removeClass("smart-hidden")}if(r.grouped&&r.isVirtualized)for(let e=0;e<r._groups.length;e++){const t=r._groups[e],i=t.items;let o=!0;for(let e=0;e<i.length;e++)i[e].hidden||(o=!1);o&&(t.hidden=!0)}if(r.grouped&&!r.isVirtualized)for(let e=0;e<r._groups.length;e++){const t=r._groups[e],i=[].concat(...t.querySelectorAll("smart-list-item"));let o=!0;for(let e=0;e<i.length;e++)i[e].$.hasClass("smart-hidden")||(o=!1);o?t.$.addClass("smart-hidden"):t.$.removeClass("smart-hidden")}r._filteredItems=s,r._refreshLayout(),t&&t(),e||r._refreshSelection()};if("function"==typeof r.dataSource)if(o||i){const e=function(e){(o||i)&&r.isAttached&&(r._updateListBoxAfterQuery=function(){s=n=r._items,l()},r.clearItems(),r.insert(0,e))},t=r.dataSource(o,e);if(t){if(!o&&!i)return;r._updateListBoxAfterQuery=function(){s=n=r._items,l()},r.clearItems(),r.insert(0,t)}}else r.clearItems(),s=n=r._items,l(),r.$.fireEvent("bindingComplete");else{if(n=r._items,0===n.length)return;l()}}_getNextItem(e){const t=this._items,i=this._items.length;let r=Math.max(e+1,0);for(;r<i;){const e=t[r];if(!(e.disabled||e.hidden||e.grouped||e.readonly))return e;r++}return t[e]}_getPreviousItem(e){const t=this._items;let i=Math.max(e-1,0);for(;i>-1;){const e=t[i];if(!(e.disabled||e.hidden||e.grouped||e.readonly))return e;i--}return t[e]}get _scrollWidth(){const e=this,t=e._items;return e.__scrollWidth||(e.__scrollWidth=(()=>{const e=this,i=e.virtualized,r=e.itemMeasureMode;let o=0,s="";function n(t){const i=e._createItem({label:t});i.style.position="absolute",e.$.itemsContainer.appendChild(i),i.label=t,i.style.width="auto",i.isCompleted&&(i.$.itemContainer.style.width="auto");const r=getComputedStyle(i),o=parseInt(r.paddingLeft)+parseInt(r.paddingRight),s=i.$.itemContainer||i,n=s.offsetWidth+s.offsetLeft+o;return i.parentNode.removeChild(i),n}for(let e=0;e<t.length;e++){const l=t[e];if(!l.hidden)if("auto"===r){const e=i?l.label:l.textContent.trim();e.length>s.length&&(s=e)}else o=Math.max(o,n(l.label))}return"auto"===r?n(s):o})()),e.__scrollWidth}update(e,t){const i=this,r=i._items[e];if(r){if("string"==typeof t)r.label=t,void 0===r.value&&(r.value=t);else for(let e in t)"selected"===e&&r[e]!==t[e]?i.select(r):r[e]=t[e],"group"===e&&i._refreshItems();(i.sorted||i.grouped||i.isVirtualized)&&(i._refreshItems(),i._refreshSelection())}else i.error(i.localize("indexOutOfBound",{elementType:i.nodeName.toLowerCase(),method:"update"}))}insert(e,t){const i=this;let r=[];if((!e||e<0)&&(e=0),Array.isArray(t)){i.isUpdating++;for(let o=0;o<t.length;o++){const s=t[o],n=i._createItem(s);r.push(n),e>=i._items.length||0===i._items.length?i.appendChild(n):i.insertBefore(n,i._items[e])}i.isUpdating--}else{const o=i._createItem(t);r.push(o),e>=i._items.length||0===i._items.length?i.appendChild(o):i.insertBefore(o,i._items[e])}r.length>0?(r.map((e=>i._applyTemplate(e))),i._ensureItemsReady(r,(function(){i._refreshItems(),0!==i._items.length&&(i._updateListBoxAfterQuery&&(i._updateListBoxAfterQuery(),delete i._updateListBoxAfterQuery),i._refreshSelection(),i.$.fireEvent("bindingComplete"))}))):i._updateListBoxAfterQuery&&(i._updateListBoxAfterQuery(),delete i._updateListBoxAfterQuery)}removeAt(e){const t=this,i=t._items[e];i?(i.selected&&t.unselect(i),t.isVirtualized?t._items.splice(e,1):i.parentNode.removeChild(i),t._refreshItems(),t._refreshSelection(),0===t.selectedIndexes.length&&t._items.length>0&&("oneOrMany"!==t.selectionMode&&"one"!==t.selectionMode&&"oneOrManyExtended"!==t.selectionMode||t.select(t._items[0]))):t.error(t.localize("indexOutOfBound",{elementType:t.nodeName.toLowerCase(),method:"remove"}))}_queryItems(e,t){const i=this,r=[],o=function(r,o){if(r.grouped)return r;switch(t){case"startsWith":if(0===r.label.indexOf(o))return r;break;case"startsWithIgnoreCase":if(0===r.label.toLowerCase().indexOf(o.toLowerCase()))return r;break;case"doesNotContain":if(r.label.indexOf(o)<0)return r;break;case"doesNotContainIgnoreCase":if(r.label.toLowerCase().indexOf(o.toLowerCase())<0)return r;break;case"contains":if(r.label.indexOf(o)>-1)return r;break;case"containsIgnoreCase":if(r.label.toLowerCase().indexOf(o.toLowerCase())>-1)return r;break;case"equals":if(0===r.label.localeCompare(o))return r;break;case"equalsIgnoreCase":if(0===r.label.toLowerCase().localeCompare(o.toLowerCase()))return r;break;case"endsWith":if(r.label.endsWith(o))return r;break;case"endsWithIgnoreCase":if(r.label.toLowerCase().endsWith(o.toLowerCase()))return r;break;case"custom":if(i.filterCallback(r,e))return r}return null};if(0===e.length)return i._items;for(let t=0;t<i._items.length;t++){const s=o(i._items[t],e);s&&r.push(s)}return r}_select(e,t){const i=this,r=i.selectedIndexes.indexOf(i._indexOf(e)),o=i.selectedIndexes.slice(0),s=i.selectedValues.slice(0);if(e.selected=!0,-1!==r)return i._recycle(),!1;if(o.push(i._indexOf(e)),s.push(e.value||e.label),i.selectedIndexes=o,i.selectedValues=s,i._recycle(),i.$.hiddenInput.value=s.toString(),!i.isCompleted||t||!i.isInitialized||i._propertyChanging)return;let n=[];if(i._previouslySelectedIndexes){for(let e=0;e<i._previouslySelectedIndexes.length;e++)i.selectedIndexes.indexOf(i._previouslySelectedIndexes[e])<0&&n.push(i._items[i._previouslySelectedIndexes[e]]);delete i._previouslySelectedIndexes}return i.$.fireEvent("change",{addedItems:[e],removedItems:n,selected:e.selected,disabled:e.disabled,index:i._indexOf(e),label:e.label,value:e.value}),i._updateTargetValue(),!0}_updateTargetValue(){const e=this;if(e.dataset.target){const t=document.querySelector(e.dataset.target);if(t){const i=e.dataset.property,r=e.value;i&&void 0!==t[i]&&(t[i]=r)}}}_setTopVisibleIndex(e){const t=this;if("number"==typeof e&&(t.topVisibleIndex=Math.max(0,e),e=t._items[t.topVisibleIndex]),!e)return!1;e.top!==t.scrollTop&&(t.scrollTop=e.top,t.isVirtualized||(t.$.itemsContainer.scrollTop=t.scrollTop),t.scrollHeight===t.scrollTop&&t._updateTopVisibleIndex())}_updateTopVisibleIndex(){const e=this,t=e.scrollTop+e._scrollView.verticalScrollBar.offsetHeight-e.offsetHeight;let i;if(e.scrollTop<e.scrollHeight/2){for(let r=0;r<e._items.length;r++)if(e._items[r].top>=t){i=e._items[r];break}}else for(let r=e._items.length-1;r>=0&&!(e._items[r].top<t);r--)i=e._items[r];if(i){const t=e.context;e.context=e,e.topVisibleIndex=i.dataIndex,e.context=t}}unselect(e){const t=this;if(!e)return;if("string"==typeof e&&!(e=t.getItem(e)))return;if("none"===t.selectionMode)return void t.clearSelection();const i=t.selectedIndexes.indexOf(t._indexOf(e)),r=t.selectedIndexes.slice(0),o=t.selectedValues.slice(0);return e.selected=!1,i>=0&&(r.splice(i,1),o.splice(i,1),t.selectedIndexes=r,t.selectedValues=o,t.$.hiddenInput.value=o.toString(),t.isCompleted&&!t._propertyChanging?(t.$.fireEvent("change",{addedItems:[],removedItems:[e],selected:e.selected,disabled:e.disabled,index:t._indexOf(e),label:e.label,value:e.value}),t._updateTargetValue(),t._recycle(),!0):void 0)}_handleItemTemplate(e){if(null===e||!e)return;if("function"==typeof e)return e;const t=this;if(!("content"in document.createElement("template")))return t.error(t.localize("htmlTemplateNotSuported",{elementType:t.nodeName.toLowerCase()})),void(t.itemTemplate=null);if(null===(e=document.getElementById(e))||!("content"in e))return t.error(t.localize("invalidTemplate",{elementType:t.nodeName.toLowerCase(),property:"itemTemplate"})),void(t.itemTemplate=null);const i=e.content,r=i.childNodes.length,o=/{{\w+}}/g;let s,n;t._bindingDetails=[],t._template=e;for(let e=0;e<r;e++){for(n=[];s=o.exec(i.childNodes[e].innerHTML);)n.push(s[0]);n.length>0&&t._bindingDetails.push({childNodeIndex:e,bindingString:n})}return!0}_handleKeyStrokes(e){const t=this,i="radioButton"===t.selectionMode||"checkBox"===t.selectionMode||"zeroOrMany"===t.selectionMode||"oneOrMany"===t.selectionMode||"zeroOrOne"===t.selectionMode;let r=t._items;if(t.filterable&&t.$.filterInput.value.length>0&&(r=t._filteredItems),!t.disabled&&!t.readonly&&r.length){switch(e){case"ArrowLeft":case"ArrowUp":t._handleArrowKeys(!0);break;case"ArrowRight":case"ArrowDown":t._handleArrowKeys(!1);break;case" ":{if(t.selectedIndexes.length<1&&!t._focusedItem)return;const e=t._focusedItem?t._focusedItem:t._items[t.selectedIndexes[t.selectedIndexes.length-1]],i=e=>{e.selected&&"radioButton"!==t.selectionMode?t.unselect(e):t.select(e)};if("oneOrMany"===t.selectionMode)return void(e.selected&&t.selectedIndexes.length>1?i(e):e.selected||i(e));i(e);break}case"Home":if(0===r.length)return;i||(t._keysPressed.Shift||t.clearSelection(),t.select(r[0])),t._focus(r[0]),t.scrollTop=0;break;case"End":if(0===r.length)return;i||(t._keysPressed.Shift||t.clearSelection(),t.select(r[r.length-1])),t._focus(r[r.length-1]),t.scrollTop=t.scrollHeight;break;case"PageUp":t._pageUpKeyHandler(r);break;case"PageDown":t._pageDownKeyHandler(r)}t._recycle()}}_horizontalScrollbarHandler(e){const t=this;e&&e.stopPropagation&&e.stopPropagation(),t.isVirtualized?t._recycle():t.$.itemsContainer.scrollLeft=t._getScrollLeft(e.detail.value)}_getScrollLeft(e,t){const i=this;if(!i.rightToLeft)return e;if(Smart.Utilities.Core.Browser.Chrome){if(!t){const e=2*(parseInt(getComputedStyle(i.$.itemsInnerContainer).getPropertyValue("--smart-list-item-horizontal-offset"))||0);t=i._scrollWidth-i.$.itemsContainer.offsetWidth-e}e=t-e}else e*=-1;return e}_unsort(){const e=this;e.isUpdating++;const t=function(e,t){let i=e.dataIndex,r=t.dataIndex;return i<r?-1:i>r?1:0};if(e.isVirtualized)if(e._groups.length>0){e._groups.sort(t);let i=[];for(let r=0;r<e._groups.length;r++){const o=e._groups[r],s=[].concat(...o.items);s.sort(t),i.push(o),i=i.concat(s)}e._items=i}else e._items.sort(t);else{if(e._groups.length>0){e._groups.sort(t);let i=[];for(let r=0;r<e._groups.length;r++){const o=e._groups[r],s=[].concat(...o.querySelectorAll("smart-list-item"));s.sort(t),i=i.concat(s)}e._items=i}else e._items.sort(t);e._applySortOrder()}e.isUpdating--}_applySortOrder(){const e=function(e){for(let t=0;t<e.length;t++){const i=e[t],r=i.parentNode;r&&r.appendChild(i)}};e(this._items),e(this._groups)}_sort(){const e=this;if(!e._canSort)return;e.isUpdating++;const t=function(t,i){let r=t.label,o=i.label;if("asc"===e.sortDirection){if(r<o)return-1;if(r>o)return 1}else{if(r<o)return 1;if(r>o)return-1}return 0};if(e._groups.sort(t),e.isVirtualized)if(e._groups.length>0){let i=[];for(let r=0;r<e._groups.length;r++){const o=e._groups[r],s=[].concat(...o.items);i.push(o),s.sort(t),i=i.concat(s)}e._items=i}else e._items.sort(t);else{if(e._groups.length>0){let i=[];for(let r=0;r<e._groups.length;r++){const o=e._groups[r],s=[].concat(...o.querySelectorAll("smart-list-item"));s.sort(t),i=i.concat(s)}e._items=i}else e._items.sort(t);e._applySortOrder()}e.isUpdating--}getItem(e){const t=this;for(let i=0;i<t._items.length;i++)if(t._items[i].value===e)return t._items[i];return null}_focus(e){const t=this;!e||"none"===t.selectionMode||t.disabled||t.readonly||(t._focusedItem&&(t._focusedItem._focused=!1),t._focusedItem=e,t._focusedItem._focused=!0)}_keyDownHandler(e){const t=this,i=(t.shadowRoot||t.getRootNode()).activeElement||document.activeElement;let r=e.key;if(e.metaKey&&(r="Control"),!t.disabled&&!t.readonly&&(!t.filterable||t.$.filterInput!==i)&&t._focused&&0!==t._items.length&&!t.disabled&&!t.displayLoadingIndicator){if(t.editable){if("F2"===r)return void t._dblclickEventHandler({target:t._focusedItem});if(t.$.editInput===i)return}if("none"!==t.selectionMode){switch(e.stopPropagation(),r){case"Down":case"Right":case"Left":case"Up":r="Arrow"+r}if(t.filterable)switch(r){case"ArrowLeft":case"ArrowRight":return;case"ArrowUp":case"ArrowDown":e.preventDefault()}if(t._applyIncrementalSearch(r),!(["Shift","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Control"," ","Home","End","PageUp","PageDown"].indexOf(r)<0))if(e.preventDefault(),!t._focusedItem&&t._items.length>0)"one"===t.selectionMode||"oneOrMany"===t.selectionMode||"oneOrManyExtended"===t.selectionMode?t.select(t._items[0]):t._focus(t._items[0]);else switch(t.selectionMode){case"one":case"zeroAndOne":if("Shift"===r||"Control"===r||" "===r)return;t._handleKeyStrokes(r);break;case"oneOrMany":case"zeroOrOne":case"zeroOrMany":case"radioButton":case"checkBox":if("Shift"===r||"Control"===r)return;t._handleKeyStrokes(r);break;case"oneOrManyExtended":if(" "===r)return;t._keysPressed[r]="keydown"===e.type,t._handleKeyStrokes(r)}}}}_keyUpHandler(e){const t=this,i=(t.shadowRoot||t.getRootNode()).activeElement||document.activeElement;if(!t.editable||t.$.editInput!==i){if(t.filterable&&t.$.filterInput===i)return t._filterTimer&&clearTimeout(t._filterTimer),void(t._filterTimer=setTimeout((function(){const e=t.context;t.context=t,t._filterItems(),t.scrollTop=t.$.itemsContainer.scrollTop=0,t.scrollLeft=t.$.itemsContainer.scrollLeft=t._getScrollLeft(0),t.context=e}),300));if(t._focused){if(t._focusedItem&&t._focusedItem.hidden&&t._filteredItems.length>0){let e=t._filteredItems[0];e.grouped&&t._filteredItems.length>1&&(e=t._filteredItems[1]),t._focus(e),t._recycle()}e.stopPropagation(),e.preventDefault(),t.disabled||("Escape"===e.key&&Smart.ListBox.DragDrop.Dragging&&t._cancelDrag(),["Shift","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Control"," ","PageUp","PageDown"].indexOf(e.key)<0||(t._keysPressed[e.key]=!1))}}}_cancelDrag(){if(!Smart.ListBox.DragDrop.Dragging)return;Smart.ListBox.DragDrop.Feedback.parentNode&&Smart.ListBox.DragDrop.Feedback.parentNode.removeChild(Smart.ListBox.DragDrop.Feedback);const e=Smart.ListBox.DragDrop.Item,t=e.ownerListBox;if(t.$.fireEvent("dragCancel",{item:e,data:Smart.ListBox.DragDrop,container:t,previousContainer:t}),Smart.ListBox.DragDrop.Feedback=null,Smart.ListBox.DragDrop.DropDetails){let e=Smart.ListBox.DragDrop.DropDetails.item;e&&(e.$.removeClass("smart-list-item-line-feedback"),e.$.removeClass("smart-list-item-bottom-line-feedback"))}document.body.classList.remove("smart-dragging"),delete Smart.ListBox.DragDrop.DraggedFrom,Smart.ListBox.DragDrop.Dragging=!1,Smart.ListBox.DragDrop.Item=null,Smart.ListBox.DragDrop.DropDetails=null}_mouseWheelHandler(e){const t=this;if((t.computedHorizontalScrollBarVisibility||t.computedVerticalScrollBarVisibility)&&!t.disabled&&t.computedVerticalScrollBarVisibility){const i=t.scrollTop;if(0===i&&e.deltaY<0||i===t.scrollHeight&&e.deltaY>0)return;e.stopPropagation(),e.preventDefault(),t.scrollTo(i+t._getScrollCoefficient(e,t.offsetHeight))}}_pageDownKeyHandler(e){const t=this;if(0===e.length)return;let i,r=t._items[t.selectedIndexes[t.selectedIndexes.length-1]];if("checkBox"!==t.selectionMode&&"radioButton"!==t.selectionMode&&"zeroOrMany"!==t.selectionMode&&"oneOrMany"!==t.selectionMode&&"zeroOrOne"!==t.selectionMode||t._focusedItem&&(r=t._focusedItem),!r)return;const o=t._indexOf(r);let s=r.top+t.$.itemsContainer.offsetHeight-r.height;for(let t=o;t<e.length;t++)if(e[t].top>=s){i=e[t];break}i||(i=e[e.length-1]),"checkBox"===t.selectionMode||"radioButton"===t.selectionMode||"zeroOrMany"===t.selectionMode||"oneOrMany"===t.selectionMode||"zeroOrOne"===t.selectionMode?t._focus(i):i.selected||(t._keysPressed.Shift||t.clearSelection(),t.select(i),t._focus(i)),(i.height+i.top>t.$.itemsContainer.scrollTop+t.$.itemsContainer.offsetHeight||i.top<t.$.itemsContainer.scrollTop)&&(t.scrollTop=i.top-t.$.itemsContainer.offsetHeight+i.height)}_pageUpKeyHandler(e){const t=this;if(0===e.length)return;let i=t._items[t.selectedIndexes[t.selectedIndexes.length-1]];if("checkBox"!==t.selectionMode&&"radioButton"!==t.selectionMode&&"zeroOrMany"!==t.selectionMode&&"oneOrMany"!==t.selectionMode&&"zeroOrOne"!==t.selectionMode||t._focusedItem&&(i=t._focusedItem),!i)return;const r=i.top-t.$.itemsContainer.offsetHeight;let o;for(let s=t._indexOf(i);s>0;s--)if(e[s].top<=r){o=e[s];break}o||(o=e[0]),"checkBox"===t.selectionMode||"radioButton"===t.selectionMode||"zeroOrMany"===t.selectionMode||"oneOrMany"===t.selectionMode||"zeroOrOne"===t.selectionMode?t._focus(o):o.selected||(t._keysPressed.Shift||t.clearSelection(),t.select(o),t._focus(o)),t.scrollTop=o.top,0===t._indexOf(o)&&(t.scrollTop=0)}clearItems(){const e=this;e.clearSelection(),e.$.itemsInnerContainer.innerHTML="",e._items=[],delete e._focusedItem,e.$placeholder.removeClass("smart-hidden"),e.refresh()}_resizeHandler(e){this.refresh(e)}refresh(e){const t=this;if(!e&&!t._isUpdatingScrollBars&&t.isInitialized)return t._isUpdatingScrollBars=!0,t._initializeRecyclingItems(),t._refreshLayout(),void(t._isUpdatingScrollBars=!1);e&&e.target===t&&!t._isUpdatingScrollBars&&(t._isUpdatingScrollBars=!0,t._initializeRecyclingItems(),t._refreshLayout(),t._isUpdatingScrollBars=!1)}_indexOf(e){const t=this;if(!e)return-1;let i=t._items.indexOf(e);return-1===i&&(i=t._items.indexOf(t.getItem(e.value))),i}_incrementalSearch(){const e=this,t="radioButton"!==e.selectionMode&&"checkBox"!==e.selectionMode&&"zeroOrMany"!==e.selectionMode&&"oneOrMany"!==e.selectionMode&&"zeroOrOne"!==e.selectionMode;let i,r=0;switch(e.incrementalSearchMode){case"containsIgnoreCase":case"equalsIgnoreCase":case"startsWithIgnoreCase":case"endsWithIgnoreCase":i=e._incrementalSearchQuery.toLowerCase();break;default:i=e._incrementalSearchQuery}const o=function(i){i.grouped||i.readonly||(t?(e.selectedIndexes.length>0&&e.clearSelection(),e._focus(i),e.select(i)):e._focus(i),(i.height+i.top>e.$.itemsContainer.scrollTop+e.$.itemsContainer.offsetHeight||i.top<e.scrollTop)&&(e.scrollTop=i.top),0===e._indexOf(i)&&(e.scrollTop=0),e._indexOf(i)===e._items.length-1&&(e.scrollTop=e.scrollHeight))};0!==e._previousEntry.localeCompare(i)&&(e._incrementalSearchItems=e._queryItems(e._incrementalSearchQuery,e.incrementalSearchMode),delete e._itemPosition),e._previousEntry=i;const s=e._incrementalSearchItems.length;if(0!==s)if(1!==s)for(void 0!==e._itemPosition?e._itemPosition<s-1?r=e._itemPosition:(r=0,t?(e._incrementalSearchItems[e._itemPosition].selected=!1,e.selectedIndexes=[],e.selectedValues=[]):e._incrementalSearchItems[e._itemPosition]._focused=!1):t&&e.clearSelection();r<s;r++)if(e._incrementalSearchItems[r].selected&&t)e._incrementalSearchItems[r].selected=!1,e.selectedIndexes=[],e.selectedValues=[];else{if(t||!e._incrementalSearchItems[r]._focused)return o(e._incrementalSearchItems[r]),void(e._itemPosition=r);e._incrementalSearchItems[r]._focused=!1}else o(e._incrementalSearchItems[0])}_selectStartHandler(e){const t=this,i=(t.shadowRoot||t.getRootNode()).activeElement;t.$.filterInput!==i&&t.$.editInput!==i&&e.preventDefault()}_handleArrowKeys(e){const t=this,i="radioButton"!==t.selectionMode&&"checkBox"!==t.selectionMode&&"zeroOrMany"!==t.selectionMode&&"oneOrMany"!==t.selectionMode&&"zeroOrOne"!==t.selectionMode;if(t.disabled||t.readonly)return;let r;if(t._focusedItem&&!t._keysPressed.Shift)r=t._indexOf(t._focusedItem),t._focusedItem._focused=!1;else{if(0===t.selectedIndexes.length)return;r=t.selectedIndexes[t.selectedIndexes.length-1]}const o=e?t._getPreviousItem(r):t._getNextItem(r);t._focus(o),i&&(t._keysPressed.Shift?t.select(o):t._items[r]!==o&&(t.clearSelection(),t.select(o))),t.ensureVisible(o)}_refreshFilter(){const e=this;if(e.filterable)return e.$.filterInput.disabled=!(!e.disabled&&!e.displayLoadingIndicator),e.$filterInputContainer.removeClass("smart-hidden"),void e.$itemsContainer.addClass("filter");e.$.filterInput.disabled=!0,e.$filterInputContainer.addClass("smart-hidden"),e.$itemsContainer.removeClass("filter")}_setFocusable(){const e=this;e.disabled||e.unfocusable?e.removeAttribute("tabindex"):e.tabIndex=e.tabIndex>0?e.tabIndex:0}_setLoadingIndicatorVisibility(){const e=this;e.displayLoadingIndicator?e.$loadingIndicatorContainer.hasClass("smart-visibility-hidden")?e.$loadingIndicatorContainer.removeClass("smart-visibility-hidden"):e.$loadingIndicatorContainer.removeClass("smart-hidden"):e._areCSSVarsSupported?e.$loadingIndicatorContainer.addClass("smart-hidden"):e.$loadingIndicatorContainer.addClass("smart-visibility-hidden")}_refreshLayout(){const e=this,t=e._filteredItems||e._items;if(e.__scrollHeight=null,e.__scrollWidth=null,e._height=null,e._scrollView||(e._scrollView=new Smart.Utilities.Scroll(e,e.$.horizontalScrollBar,e.$.verticalScrollBar)),e.$itemsContainer.removeClass("hscroll"),e.$itemsContainer.removeClass("vscroll"),!t||null===t||0===t.length)return e.scrollWidth=0,e.scrollHeight=0,e.$filterInputContainer.removeClass("vscroll"),e.$placeholder.removeClass("smart-hidden"),e.isVirtualized&&e._recycle(),void(e.$.itemsInnerContainer.style.width="");e.$placeholder.addClass("smart-hidden");const i=2*(parseInt(getComputedStyle(e.$.itemsContainer).getPropertyValue("--smart-list-item-horizontal-offset"))||0);let r=e._scrollWidth-e.$.itemsContainer.offsetWidth-i,o=e._scrollHeight;if(e._refreshHorizontalScrollBarVisibility(r),e._refreshVerticalScrollBarVisibility(o),e.$.itemsInnerContainer.style.width="","hidden"===e.horizontalScrollBarVisibility?e.$.itemsInnerContainer.style.width=e.$.itemsContainer.offsetWidth-i:e.$.itemsInnerContainer.style.width=Math.max(e.$.itemsContainer.offsetWidth-i,-i+e.__scrollWidth)+"px",e.computedVerticalScrollBarVisibility)return r=e._scrollWidth-e.$.itemsContainer.offsetWidth-i,e._refreshHorizontalScrollBarVisibility(r),"hidden"!==e.horizontalScrollBarVisibility&&(e.$.itemsInnerContainer.style.width="",e.$.itemsInnerContainer.style.width=Math.max(e.$.itemsContainer.offsetWidth-i,-i+e.__scrollWidth)+"px"),e.computedHorizontalScrollBarVisibility&&(("visible"!==e.horizontalScrollBarVisibility||0!==e.scrollWidth||"visible"===e.horizontalScrollBarVisibility)&&(e.__scrollHeight+=e._scrollView.hScrollBar.offsetHeight),e.scrollHeight=e.__scrollHeight,e._scrollView.hScrollBar.$.hasClass("bottom-corner")&&e._scrollView.hScrollBar.refresh()),void(e.isVirtualized&&e._recycle());r=e._scrollWidth-e.$.itemsContainer.offsetWidth-i,e._refreshHorizontalScrollBarVisibility(r),e.computedHorizontalScrollBarVisibility&&(e.scrollHeight=e._scrollHeight,e._refreshVerticalScrollBarVisibility(e.scrollHeight),e.computedVerticalScrollBarVisibility&&(r=e._scrollWidth-e.$.itemsContainer.offsetWidth-e._scrollView.vScrollBar.offsetWidth,e._refreshHorizontalScrollBarVisibility(r)),e._scrollView.vScrollBar.$.hasClass("bottom-corner")&&e._scrollView.vScrollBar.refresh(),e._scrollView.hScrollBar.$.hasClass("bottom-corner")&&e._scrollView.hScrollBar.refresh()),e.isVirtualized&&e._recycle();const s=/Trident|Edge/.test(navigator.userAgent);!e.isRefreshing&&s&&setTimeout((function(){e.isRefreshing=!0,e._refreshLayout(),e.isRefreshing=!1}),50)}_styleChangedHandler(){this._refreshLayout()}_swipeLeftHandler(){}_swipeRightHandler(){}_refreshHorizontalScrollBarVisibility(e){const t=this;t.scrollWidth=e,t.computedHorizontalScrollBarVisibility?(t.scrollLeft=t._getScrollLeft(t.$.itemsContainer.scrollLeft,e),t.$itemsContainer.addClass("hscroll")):t.$itemsContainer.removeClass("hscroll")}_refreshVerticalScrollBarVisibility(e){const t=this;t.scrollHeight=e,t.computedVerticalScrollBarVisibility?(t.$itemsContainer.addClass("vscroll"),t.$filterInputContainer.addClass("vscroll")):(t.$itemsContainer.removeClass("vscroll"),t.$filterInputContainer.removeClass("vscroll"))}_validateTemplate(e,t){if(null===t||!t)return;const i=this;return"content"in document.createElement("template")?null!==(t=document.getElementById(t))&&"content"in t?t:(i.error(i.localize("invalidTemplate",{elementType:i.nodeName.toLowerCase(),property:e})),void(i[e]=null)):(i.error(i.localize("htmlTemplateNotSuported",{elementType:i.nodeName.toLowerCase()})),void(i[e]=null))}_getItemIndexByPosition(e){const t=this;return(i=>{let r=0,o=i.length-1;if(e<=0)return 0;if(i[i.length-1].top<=e)return i.length-1;for(;;){const s=Math.floor((r+o)/2),n=i[s];if(t._isItemInPosition(n,e))return s;n.top<e?r=s+1:n.top>e&&(o=s-1)}})(t.filterable&&t.$.filterInput.value.length>0?t._filteredItems:t._items)}_isItemInPosition(e,t){const i=e.top,r=e.top+e.height;return i<=t&&r>t}get isVirtualized(){const e=this;return e.virtualized&&e.dataSource&&e.dataSource.length>0}_recycle(){const e=this;if(!e._recyclingItems)return;let t=e._height;e._height||(t=e._height=e.$.itemsContainer.offsetHeight);let i=0;const r=e.scrollTop,o=e._getItemIndexByPosition(r),s=e.filterable&&e.$.filterInput.value.length>0?e._filteredItems:e._items,n=s[o];let l=n?n.top:0;if(e.$.itemsInnerContainer.style.left=-e.scrollLeft+"px",e.$.itemsInnerContainer.style.top=-r+l+"px",e.isUpdating++,o>=0){const n=s.length;for(let a=o;a<n;a++){const o=s[a];if(0!==o.height){if(!(l+o.height>=r&&l<=r+t))break;{const t=e._recyclingItems[i++];if(!t)break;t.setAttribute("aria-setsize",n),t.setAttribute("aria-posinset",a),t.context=document,t.dataItem=o,t.label=o.label,t.value=o.value,t.selected=o.selected,t._focused=o._focused,t.hidden=o.hidden,t.grouped=o.grouped,t.readonly=o.readonly,t.style.height=o.height+"px",e._alternateItem(t),o.title?t.title=o.title:t.title="",o.grouped?t.displayMode="plain":t.displayMode=o.displayMode,e.scrollWidth>0&&(t.style.width=e.$.itemsInnerContainer.offsetWidth+e.scrollWidth+"px"),e.itemTemplate&&e._handleItemTemplate(e.itemTemplate)&&e._applyTemplate(t,!1)}l+=o.height}}}if(i<e._recyclingItems.length)for(let t=i;t<e._recyclingItems.length;t++){const t=e._recyclingItems[i++],r=t.context;t.context=document,t.hidden=!0,t.context=r}e.isUpdating--}_verticalScrollbarHandler(e){const t=this,i=e.detail.value;e&&e.stopPropagation&&e.stopPropagation(),t.isVirtualized?t._recycle():t.$.itemsContainer.scrollTop=i,t._updateTopVisibleIndex(),e.context.max!==e.context.value?e.context.min===e.context.value&&t.$.fireEvent("scrollTopReached"):t.$.fireEvent("scrollBottomReached")}_applyAriaSelected(){const e=this,t=e.isVirtualized?e._recyclingItems:e._items,i=e.selectionMode;for(let e=0;e<t.length;e++){const r=t[e];r.selected?r.setAttribute("aria-selected",!0):r.readonly||r.disabled||-1===["oneOrManyExtended","zeroOrMany","oneOrMany","checkBox"].indexOf(i)?r.removeAttribute("aria-selected"):r.setAttribute("aria-selected",!1)}}});
|
|
841
|
+
Smart("smart-list-item",class extends Smart.ContentElement{static get properties(){return{alternationIndex:{value:-1,type:"int"},color:{value:"",type:"string"},displayMode:{allowedValues:["plain","checkBox","radioButton"],value:"plain",type:"string"},grouped:{value:!1,type:"boolean"},selected:{value:!1,type:"boolean"},value:{value:"",type:"string"},label:{value:"",type:"string"},details:{value:"",type:"string"},group:{value:"",type:"string"},hidden:{value:!1,type:"boolean"},readonly:{value:!1,type:"boolean"}}}get hasStyleObserver(){return!1}get enableShadowDOM(){return!1}get _focused(){const e=this;return void 0===e.__focused&&(e.__focused=!1),e.__focused}set _focused(e){const t=this;t.__focused=e,e?(t.setAttribute("focus",""),t.ownerListBox&&t.ownerListBox.ownerElement&&Smart.ComboBox&&t.ownerListBox.ownerElement instanceof Smart.ComboBox&&t.ownerListBox.ownerElement.$.input.setAttribute("aria-activedescendant",t.id)):t.removeAttribute("focus")}template(){return'<div id="container">\n <span id=\'itemInput\' class=\'smart-input smart-hidden\'></span>\n <span class="smart-overlay" id="overlay"></span>\n <div id="itemContainer" class="smart-content smart-list-item-container"><span class="smart-content-label" inner-h-t-m-l=\'[[innerHTML]]\' role="presentation"><content></content></span><span inner-h-t-m-l=\'[[details]]\' id="details" class="smart-content-details"></span></div>\n </div>'}appendChild(e){const t=this;if(!t.isCompleted||e.classList&&e.classList.contains("smart-ripple")){const e=Array.prototype.slice.call(arguments,2);return HTMLElement.prototype.appendChild.apply(t,e.concat(Array.prototype.slice.call(arguments)))}window.smartBlazor?t.$.itemContainer.appendChild(e):(t.$.itemContainer.innerHTML="",e instanceof HTMLElement&&t.$.itemContainer.appendChild(e))}insertBefore(e,t){const i=this;if(!i.isCompleted){const e=Array.prototype.slice.call(arguments,2);return HTMLElement.prototype.insertBefore.apply(i,e.concat(Array.prototype.slice.call(arguments)))}t.parentNode.insertBefore(e,t)}removeChild(e){const t=this;if(!t.isCompleted||e.classList.contains("smart-ripple")){const e=Array.prototype.slice.call(arguments,2);return HTMLElement.prototype.removeChild.apply(t,e.concat(Array.prototype.slice.call(arguments)))}e instanceof HTMLElement&&t.$.itemContainer.removeChild(e)}attached(){super.attached(),this.ownerListBox=this.getListBox()}static get listeners(){return{mouseenter:"_itemOnMouseEnter",mouseleave:"_itemOnMouseLeave"}}ready(){super.ready();const e=this;if(e.setAttribute("role","option"),""!==e.label){let t=e.label;t&&"string"==typeof t&&(t=t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,""")),e.innerHTML=t}else""!==e.innerHTML&&(e.label=e.innerHTML);e._setDisplayMode(e.displayMode),e._setItemColor(),e.$.container.noRipple=!0;const t=e.closest("smart-list-box");if(t&&t.isRendered){if(cancelAnimationFrame(Smart.ListBox.processTimer),t._inLazyInit||t._isUpdating)return;Smart.ListBox.processTimer=requestAnimationFrame((()=>{t._lazyInitItems()}))}}propertyChangedHandler(e,t,i){const r=this;if(super.propertyChangedHandler(e,t,i),"hidden"===e)i?r.$.addClass("smart-hidden"):r.$.removeClass("smart-hidden");else if("color"===e)r._setItemColor();else if("displayMode"===e)r._setDisplayMode(i);else if("label"===e||"value"===e){const t=r.context;r.context=document,"label"===e&&(r.innerHTML=i);const o=r.getListBox();o&&(o._applyTemplate(r),o.onItemUpdated(r)),r.context=t}else if("details"===e){const e=r.context;r.context=document,r.$.details.innerHTML=i;const t=r.getListBox();t&&t.onItemUpdated(r),r.context=e}else if("innerHTML"===e){const e=r.getListBox();e&&e.onItemUpdated(r)}else if("selected"===e)if(i)r.setAttribute("aria-selected",!0);else{const e=r.getListBox();r.readonly||r.disabled||!e||-1===["oneOrManyExtended","zeroOrMany","oneOrMany","checkBox"].indexOf(e.selectionMode)?r.removeAttribute("aria-selected"):r.setAttribute("aria-selected",!1)}}getListBox(){const e=this;if(!Smart.ListBox)return e.getRootNode().host;let t=e.parentNode;for(;t instanceof Smart.ListBox==0&&null!==t;)t=t.parentNode;return!t&&Smart.EnableShadowDOM?e.getRootNode().host:t}_itemOnMouseEnter(){const e=this;!e.disabled&&e.ownerListBox&&(Smart.ListBox.DragDrop.Dragging&&e.ownerListBox.allowDrop&&(Smart.ListBox.DragDrop.DropDetails={item:e,position:"bottom"}),e.ownerListBox.$.verticalScrollBar.thumbCapture||e.ownerListBox.$.horizontalScrollBar.thumbCapture||e.setAttribute("hover",""))}_itemOnMouseMove(e){const t=this;if(t.ownerListBox&&Smart.ListBox.DragDrop.Dragging&&t.ownerListBox.allowDrop&&!Smart.Utilities.Core.isMobile){const i=[].slice.call(t.ownerListBox.getElementsByClassName("smart-list-item-bottom-line-feedback"));for(let e=0;e<i.length;e++)i[e].$.removeClass("smart-list-item-line-feedback"),i[e].$.removeClass("smart-list-item-bottom-line-feedback");if(Smart.ListBox.DragDrop.DropDetails={item:t,position:"top"},!t.ownerListBox._areCSSVarsSupported){if(t.ownerListBox._indexOf(t)===t.ownerListBox._items.length-1||t.parentNode.lastElementChild===t){const i=t.getBoundingClientRect();e.pageY-window.pageYOffset>i.top+i.height/2-1&&(Smart.ListBox.DragDrop.DropDetails={item:t,position:"bottom"})}return}if(t.$.removeClass("smart-list-item-line-feedback"),t.$.removeClass("smart-list-item-bottom-line-feedback"),t.ownerListBox.sorted&&t.ownerListBox.autoSort)return;const r=t.ownerListBox._items.filter((e=>!e.hidden));if(r.indexOf(t)===r.length-1||t.parentNode.lastElementChild===t){const i=t.getBoundingClientRect();e.pageY-window.pageYOffset>i.top+i.height/2-1?(t.$.addClass("smart-list-item-bottom-line-feedback"),Smart.ListBox.DragDrop.DropDetails={item:t,position:"bottom"}):arguments[1]||t.$.addClass("smart-list-item-line-feedback")}else arguments[1]||t.$.addClass("smart-list-item-line-feedback")}}_itemOnMouseLeave(){const e=this;e.ownerListBox&&(Smart.ListBox.DragDrop.Dragging&&(e.$.removeClass("smart-list-item-line-feedback"),e.$.removeClass("smart-list-item-bottom-line-feedback")),e.removeAttribute("hover"))}_setDisplayMode(e){const t=this,i=t.getListBox();if(i){const r="checkBox"===i.selectionMode||"radioButton"===i.selectionMode?i.selectionMode:"plain";t.displayMode=e=r}"plain"!==e?t.$itemInput.removeClass("smart-hidden"):t.$itemInput.addClass("smart-hidden")}_setItemColor(){const e=this,t=e.querySelector(".smart-content-label"),i=/(^#[0-9A-F]{3}$)|(^#[0-9A-F]{6}$)|(^#[0-9A-F]{8}$)/i.test(e.color)?e.color:"";t.style.backgroundColor=i,t.style.color=e._getContrastColor(i)}_getContrastColor(e){if(!e)return"";let t=(i=e.slice(1,3),r=e.slice(3,5),o=e.slice(5,7),[parseInt(i,16),parseInt(r,16),parseInt(o,16)]);var i,r,o;return parseFloat(((.299*t[0]+.61*t[1]+.114*t[2])/255).toFixed(2))>.65?"#000000":"#FFFFFF"}}),Smart("smart-list-items-group",class extends Smart.ContentElement{static get properties(){return{label:{value:"",type:"string"}}}get enableShadowDOM(){return!1}template(){return'<div id="container" role="presentation">\n <span id="itemsLabel" class="smart-list-items-group-label">[[label]]</span>\n <div id="listItemsGroupContainer" inner-h-t-m-l=\'[[innerHTML]]\' class="smart-list-items-group-container" role="presentation">\n <content></content>\n </div>\n </div>'}appendChild(e){const t=this;if(!t.isCompleted){const e=Array.prototype.slice.call(arguments,2);return HTMLElement.prototype.appendChild.apply(t,e.concat(Array.prototype.slice.call(arguments)))}e instanceof HTMLElement&&t.$.listItemsGroupContainer.appendChild(e)}removeChild(e){const t=this;if(!t.isCompleted){const e=Array.prototype.slice.call(arguments,2);return HTMLElement.prototype.removeChild.apply(t,e.concat(Array.prototype.slice.call(arguments)))}e instanceof HTMLElement&&t.$.listItemsGroupContainer.removeChild(e)}getListBox(){let e=this.parentNode;for(;e instanceof Smart.ListBox==0&&null!==e;)e=e.parentNode;return e}attached(){const e=this;super.attached(),e.ownerListBox||(e.ownerListBox=e.getListBox()),e.setAttribute("role","group"),e.$.itemsLabel.id||(e.$.itemsLabel.id=e.id+"Label"),e.setAttribute("aria-labelledby",e.$.itemsLabel.id)}}),Smart("smart-list-box",class extends Smart.ScrollViewer{static get properties(){return{allowDrag:{value:!1,type:"boolean"},allowDrop:{value:!1,type:"boolean"},alternationStart:{value:0,type:"int"},alternationEnd:{value:0,type:"int"},alternationCount:{value:0,type:"int"},autoSort:{value:!0,type:"boolean"},dataSource:{value:null,type:"any?",reflectToAttribute:!1},dragFeedbackFormatFunction:{value:null,type:"function?"},dragOffset:{value:[10,10],type:"array"},displayLoadingIndicator:{value:!1,type:"boolean"},displayMember:{value:"",type:"string"},shadowDomMode:{allowedValues:["light","shadow"],value:"shadow",type:"string"},dropAction:{value:"move",type:"string",allowedValues:["copy","move","none"]},editable:{value:!1,type:"boolean"},filterable:{value:!1,type:"boolean"},filterCallback:{value:null,type:"function?"},filterMode:{value:"containsIgnoreCase",allowedValues:["contains","containsIgnoreCase","doesNotContain","doesNotContainIgnoreCase","equals","equalsIgnoreCase","startsWith","startsWithIgnoreCase","endsWith","endsWithIgnoreCase","custom"],type:"string"},filterInputPlaceholder:{value:"",type:"string"},grouped:{value:!1,type:"boolean"},groupMember:{value:"",type:"string"},itemTemplate:{value:null,type:"any"},itemHeight:{value:null,type:"number?"},incrementalSearchDelay:{value:700,type:"number?"},incrementalSearchMode:{value:"startsWithIgnoreCase",allowedValues:["contains","containsIgnoreCase","doesNotContain","doesNotContainIgnoreCase","equals","equalsIgnoreCase","startsWith","startsWithIgnoreCase","endsWith","endsWithIgnoreCase"],type:"string"},itemMeasureMode:{value:"auto",allowedValues:["auto","precise"],type:"string"},loadingIndicatorPlaceholder:{value:"Loading...",type:"string"},loadingIndicatorPosition:{value:"center",allowedValues:["bottom","center","top"],type:"string"},messages:{extend:!0,value:{en:{overridingProperties:'{{elementType}}: Overriding properties {{property1}} and {{property2}} applied. The "{{property1}}" property is used by default.',invalidIndex:'{{elementType}}: "{{method}}" method accepts an index of type number or an Array of numbers.',indexOutOfBound:'{{elementType}}: Out of bound index/indexes in "{{method}}" method.',invalidItem:'{{elementType}}: "{{method}}" method accepts an object or an array of objects as it\'s second parameter.',invalidSettings:'{{elementType}}: "{{method}}" method accepts a string or an object as it\'s second parameter.'}},type:"object"},name:{value:"",type:"string"},placeholder:{value:"No Items",type:"string"},selectedIndexes:{value:[],type:"array"},selectedValues:{value:[],type:"array"},selectionMode:{value:"oneOrManyExtended",allowedValues:["none","oneOrManyExtended","zeroOrMany","oneOrMany","zeroOrOne","zeroAndOne","one","checkBox","radioButton"],type:"string"},selectionChangeAction:{value:"release",allowedValues:["press","release"],type:"string"},sorted:{value:!1,type:"boolean"},sortDirection:{value:"asc",type:"string"},topVisibleIndex:{value:-1,type:"int"},type:{value:"list",type:"string",defaultReflectToAttribute:!0,readonly:!0},valueMember:{value:"",type:"string"},virtualized:{value:!1,type:"boolean"}}}static get requires(){return{"Smart.ScrollBar":"smart.scrollbar.js"}}static get styleUrls(){return["smart.listbox.css","smart.dropdown.css","smart.scrollbar.css"]}static get listeners(){return{focus:"_focusHandler",blur:"_blurHandler","container.wheel":"_mouseWheelHandler","editInput.change":"_editInputEventHandler","editInput.blur":"_editInputEventHandler","editInput.keydown":"_editInputEventHandler","horizontalScrollBar.change":"_horizontalScrollbarHandler","itemsInnerContainer.down":"_downHandler","itemsInnerContainer.dblclick":"_dblclickEventHandler","itemsInnerContainer.move":"_itemsContainerMoveHandler","itemsContainer.mouseleave":"_mouseLeaveHandler","itemsInnerContainer.touchmove":"_touchmoveHandler","itemsInnerContainer.touchstart":"_touchstartHandler","document.move":"_moveHandler",keydown:"_keyDownHandler",keyup:"_keyUpHandler",resize:"_resizeHandler",selectstart:"_selectStartHandler",styleChanged:"_styleChangedHandler",swipeleft:"_swipeLeftHandler",swiperight:"_swipeRightHandler",touchmove:"_overriddenHandler",touchstart:"_overriddenHandler","verticalScrollBar.change":"_verticalScrollbarHandler"}}template(){return'<div id="container" class="smart-container" role="presentation">\n <div class="smart-list-box-filter-input-container smart-hidden" id="filterInputContainer" role="presentation"><input id="filterInput" disabled="[[disabled]]" placeholder=\'[[filterInputPlaceholder]]\' role="searchbox" aria-label="[[filterInputPlaceholder]]"></div>\n <div id="itemsContainer" class="smart-list-items-container" role="presentation">\n <div id="placeholder" class="smart-placeholder" role="presentation" aria-hidden="true">[[placeholder]]</div>\n <div id="itemsInnerContainer" inner-h-t-m-l=\'[[innerHTML]]\' class="smart-list-items-inner-container" role="presentation">\n <content></content>\n </div>\n <input type="text" id="editInput" class= "smart-hidden"/>\n </div>\n <smart-scroll-bar wait theme="[[theme]]" right-to-left="[[rightToLeft]]" id="verticalScrollBar" disabled="[[disabled]]" orientation="vertical"></smart-scroll-bar>\n <smart-scroll-bar wait theme="[[theme]]" right-to-left="[[rightToLeft]]" id="horizontalScrollBar" disabled="[[disabled]]"></smart-scroll-bar>\n <div id="loadingIndicatorContainer" class="smart-loader-container" role="presentation">\n <span id="loadingIndicator" class="smart-loader" role="img" aria-label="[[loadingIndicatorPlaceholder]]"></span>\n <span id="loadingIndicatorPlaceHolder" class="smart-loader-label smart-hidden">[[loadingIndicatorPlaceholder]]</span>\n </div>\n <input id="hiddenInput" type="hidden" name="[[name]]">\n </div>'}get value(){const e=this;return e.isRendered&&e._selectedItems.length>0?e._selectedItems.map((e=>({label:e.label,value:e.value}))):null}set value(e){const t=this;if(Array.isArray(e)){const i=t.context;t.context=t,t._isUpdating++,t.selectedValues=[],t.clearSelection();for(let i=0;i<e.length;i++){const r=e[i],o=t.getItem(r);o&&("oneOrManyExtended"===t.selectionMode?t._select(o):t.select(o))}return t.context=i,void t._isUpdating--}const i=t.getItem(e);i&&t.select(i)}get _selectedItems(){const e=this,t=[];if(e.isRendered)for(let i=0;i<e._items.length;i++){const r=e._items[i];r.selected&&t.push(r)}return t}_mouseLeaveHandler(){const e=[].slice.call(this.getElementsByClassName("smart-list-item-bottom-line-feedback"));for(let t=0;t<e.length;t++)e[t].$.removeClass("smart-list-item-line-feedback"),e[t].$.removeClass("smart-list-item-bottom-line-feedback")}_downHandler(e){const t=this;if(t.disabled||t.displayLoadingIndicator||t.readonly)return;let i=e.originalEvent.target,r=null;if(!(i instanceof Smart.ListItem)||i.disabled||i.hidden||i instanceof Smart.ListItemsGroup)for(;i.parentElement;){if(i instanceof Smart.ListItem&&!i.disabled&&!i.hidden&&!(i instanceof Smart.ListItemsGroup)){r=i.dataItem;break}i=i.parentElement}else r=i.dataItem;Smart.ListBox.DragDrop.StartTime=new Date,Smart.ListBox.DragDrop.StartPosition={left:e.pageX,top:e.pageY},r&&(e.stopPropagation(),t.hasRippleAnimation&&(r.readonly||r.disabled||Smart.Utilities.Animation.Ripple.animate(i.$.overlay,e.pageX,e.pageY)),Smart.Utilities.Core.isMobile||"press"!==t.selectionChangeAction||(t._focus(r),t.select(r)),!Smart.ListBox.DragDrop.Feedback&&t.allowDrag&&(Smart.ListBox.DragDrop.DraggedFrom=t,Smart.ListBox.DragDrop.Feedback=document.createElement("span"),t.rightToLeft?Smart.ListBox.DragDrop.Feedback.setAttribute("right-to-left",!0):Smart.ListBox.DragDrop.Feedback.removeAttribute("right-to-left"),t.dragFeedbackFormatFunction?Smart.ListBox.DragDrop.Feedback.innerHTML=t.dragFeedbackFormatFunction(r):Smart.ListBox.DragDrop.Feedback.appendChild(r.offsetHeight?r.cloneNode(!0):t._createItem(r)),Smart.ListBox.DragDrop.Item=r,Smart.Utilities.Extend(Smart.ListBox.DragDrop.Feedback).addClass("smart-popup smart-list-item smart-list-item-feedback")))}_dblclickEventHandler(e){const t=this;if(!t.editable)return;const i=e.target.closest("smart-list-item");i instanceof Smart.ListItem&&!i.disabled&&!i.readonly?(t.$.editInput.dir=t.rightToLeft?"rtl":"ltr",t.$.editInput.style.width=t.$.itemsInnerContainer.offsetWidth+"px",t.$.editInput.owner=i,t.$.editInput.value=i.label,t.$.editInput.style.height=i.offsetHeight+"px",t.$.editInput.style.top=i.offsetTop+t.$.itemsInnerContainer.offsetTop+"px",t.$.editInput.setAttribute("aria-label","Edit item "+i.label),t.$editInput.hasClass("smart-hidden")&&t.$editInput.removeClass("smart-hidden"),t.$.editInput.focus({preventScroll:!0})):t.$editInput.addClass("smart-hidden")}_editInputEventHandler(e){const t=this;if("blur"===e.type||"keydown"===e.type&&"Escape"===e.key)return t.$editInput.hasClass("smart-hidden")||t.$editInput.addClass("smart-hidden"),void t.focus();if("keydown"===e.type||t.$editInput.hasClass("smart-hidden"))return;const i=e.target;if(e.stopPropagation(),i.owner.label!==i.value&&(i.owner.label=i.value,t.itemTemplate&&t._applyTemplate(i.owner),t.dataSource)){const e=i.owner.dataIndex,r=t.dataSource[e];r&&(t.displayMember?r[t.displayMember]=i.value:r.label=i.value)}t.$editInput.addClass("smart-hidden"),t.$.fireEvent("itemLabelChange",{selected:i.owner.selected,disabled:i.owner.disabled,index:t._indexOf(i.owner),label:i.owner.label,value:i.owner.value})}_pointerUpHandler(e){const t=this;let i=e.originalEvent,r=i.target;(t.shadowRoot||t.isInShadowDOM)&&(r=i.originalEvent?i.originalEvent.composedPath()[0]:i.composedPath()[0]);const o=e=>{const i=e.ownerListBox;i.disabled||i!==t||i.displayLoadingIndicator||"none"===i.selectionMode||e.grouped||e.readonly||(i._focus(e),i.select(e),Smart.ListBox.DragDrop.StartPosition=null,t.$.fireEvent("itemClick",{selected:r.selected,disabled:r.disabled,index:t._indexOf(r),label:r.label,value:r.value}))};if(!(i.target instanceof Smart.ListItem)||i.target.disabled||i.target instanceof Smart.ListItemsGroup){for(;r.parentElement;){if(r instanceof Smart.ListItem&&!r.disabled&&!(r instanceof Smart.ListItemsGroup))return void o(r.dataItem);r=r.parentElement}if(this.shadowRoot&&"shadow"===this.shadowDomMode){const e=i.composedPath();for(let t=0;t<e.length;t++){const i=e[t];i instanceof Smart.ListItem&&!i.disabled&&o(i.dataItem)}}}else o(r.dataItem)}_upHandler(e){const t=this;if(super._upHandler(),!t.disabled&&!t.readonly&&Smart.ListBox.DragDrop.StartPosition){if(Smart.Utilities.Core.isMobile&&!Smart.ListBox.DragDrop.Dragging){const i=Math.abs(e.pageX-Smart.ListBox.DragDrop.StartPosition.left),r=Math.abs(e.pageY-Smart.ListBox.DragDrop.StartPosition.top);let o=i>=0&&i<=3&&r>=0&&r<=3;if(Smart.Utilities.Core.isMobile&&new Date-Smart.ListBox.DragDrop.StartTime>=300&&(o=!1,Smart.ListBox.DragDrop.StartTime=null),o){const i=e.originalEvent.target.closest("smart-list-box");i?i._pointerUpHandler(e):t._pointerUpHandler(e),Smart.ListBox.DragDrop.StartPosition=null}else{let t=e.originalEvent.target;if(!(e.target instanceof Smart.ListItem)||t.readonly||e.target.disabled||e.target instanceof Smart.ListItemsGroup)for(;t.parentElement;){if(t instanceof Smart.ListItem&&!t.readonly&&!t.disabled&&!(t instanceof Smart.ListItemsGroup)){e.stopPropagation();break}t=t.parentElement}else e.stopPropagation()}}else if(!Smart.Utilities.Core.isMobile&&!Smart.ListBox.DragDrop.Dragging&&"release"===t.selectionChangeAction){const i=(t.shadowRoot||t.isInShadowDOM?e.originalEvent.composedPath()[0]:e.originalEvent.target).closest("smart-list-box");i?i._pointerUpHandler(e):t._pointerUpHandler(e)}if(Smart.ListBox.DragDrop.Feedback){let i;if(Smart.ListBox.DragDrop.Feedback.parentNode&&Smart.ListBox.DragDrop.Feedback.parentNode.removeChild(Smart.ListBox.DragDrop.Feedback),Smart.ListBox.DragDrop.Feedback=null,Smart.Utilities.Core.isMobile&&Smart.ListBox.DragDrop.Dragging)for(let t=0;t<Smart.ListBox.DragDrop.ListBoxes.length;t++){const r=Smart.ListBox.DragDrop.ListBoxes[t],o=r.getBoundingClientRect();if(r.allowDrop&&!r.closest(".smart-visibility-hidden")&&o.left<=e.clientX&&e.clientX<=o.left+o.width&&o.top<=e.clientY&&e.clientY<=o.top+o.height){i=r;const t=r._items.filter((e=>!e.hidden));for(let i=0;i<t.length;i++){const s=t[i],n=s.getBoundingClientRect();if((t.indexOf(s)===t.length-1||s.parentNode.lastElementChild===s)&&e.clientY>=o.top+s.offsetTop-r.scrollTop+n.height/2&&e.clientY<=o.top-r.scrollTop+s.offsetTop+n.height){Smart.ListBox.DragDrop.DropDetails={item:s,position:"bottom"};break}if(e.clientY>=o.top+s.offsetTop-r.scrollTop&&e.clientY<=o.top+s.offsetTop+n.height-r.scrollTop){Smart.ListBox.DragDrop.DropDetails={item:s,position:"top"};break}}}}if(Smart.ListBox.DragDrop.Dragging){if(Smart.ListBox.DragDrop.DropDetails){let r=Smart.ListBox.DragDrop.DropDetails.item,o=Smart.ListBox.DragDrop.Item;const s=o.ownerListBox;let n=e.originalEvent.target;if(t.isInShadowDOM&&(n=e.originalEvent?e.originalEvent.composedPath()[0]:e.composedPath()[0]),i=!i&&n.closest?n.closest("smart-list-box"):i,document.body.classList.remove("smart-dragging"),r.$.removeClass("smart-list-item-line-feedback"),r.$.removeClass("smart-list-item-bottom-line-feedback"),i&&r.ownerListBox!==i&&i.items.length>0&&(r=i.items[i.items.length-1]),Smart.ListBox.DragDrop.Item===r||i!==r.ownerListBox&&!Smart.Utilities.Core.isMobile)i&&0===i._items.length&&"none"!==i.dropAction&&("move"===i.dropAction?Smart.ListBox.DragDrop.Item.ownerListBox.removeChild(Smart.ListBox.DragDrop.Item):"copy"===i.dropAction&&(o=o.cloneNode(!0)),i.appendChild(o));else if("none"!==o.ownerListBox.dropAction){r.ownerListBox!==o.ownerListBox&&"move"===o.ownerListBox.dropAction&&Smart.ListBox.DragDrop.Item.ownerListBox.removeChild(Smart.ListBox.DragDrop.Item),"copy"===o.ownerListBox.dropAction&&(o=o.cloneNode(!0)),Smart.ListBox.DragDrop.Item.group=r.group;const e=r.ownerListBox;"checkBox"!==e.selectionMode&&"radioButton"!==e.selectionMode&&e.clearSelection(),"top"===Smart.ListBox.DragDrop.DropDetails.position?e.insertBefore(o,r):r.parentNode.lastElementChild===r?e.appendChild(o):e.appendChild(o,r),e.ensureVisible(o),"checkBox"===e.selectionMode||"radioButton"===e.selectionMode?(e._focus(o),e._refreshSelection()):(e.clearSelection(),e.select(o))}o.selected&&i!==s&&s._refreshSelection();const l=Smart.ListBox.DragDrop.Item,a=l.ownerListBox;l.displayMode="checkBox"===a.selectionMode||"radioButton"===a.selectionMode?a.selectionMode:"plain",a.$.fireEvent("dragEnd",{item:l,target:r,data:Smart.ListBox.DragDrop,previousContainer:s,container:i,originalEvent:e}),a._focus(l)}else{const t=Smart.ListBox.DragDrop.Item,i=t.ownerListBox;t.displayMode="checkBox"===i.selectionMode||"radioButton"===i.selectionMode?i.selectionMode:"plain",document.body.classList.remove("smart-dragging"),i.$.fireEvent("dragEnd",{item:t,target:null,data:Smart.ListBox.DragDrop,previousContainer:i,container:i,originalEvent:e}),i._focus(t)}e.preventDefault()}delete Smart.ListBox.DragDrop.DraggedFrom,Smart.ListBox.DragDrop.Dragging=!1,Smart.ListBox.DragDrop.Item=null,Smart.ListBox.DragDrop.DropDetails=null}for(let e=0;e<Smart.ListBox.DragDrop.ListBoxes.length;e++){const t=Smart.ListBox.DragDrop.ListBoxes[e];t._dragInterval&&clearInterval(t._dragInterval)}}}_itemsContainerMoveHandler(e){const t=this;if(Smart.ListBox.DragDrop.Dragging)return t._applyItemFeedback(e),t._moveHandler(e),e.originalEvent.preventDefault(),e.originalEvent.stopPropagation(),!1}_touchmoveHandler(e){if(Smart.ListBox.DragDrop.Dragging&&e.cancelable)return e.preventDefault(),void e.stopPropagation();super._touchmoveHandler(e)}_applyItemFeedback(e){const t=this,i=e.originalEvent.target,r=i.closest?i.closest("smart-list-item"):i;Smart.Utilities.Core.isMobile?Smart.ListBox.DragDrop.DropDetails={item:Smart.ListBox.DragDrop.Item,position:"bottom"}:0!==t.items.length&&(r?r._itemOnMouseMove(e):t.items[t.items.length-1]._itemOnMouseMove(e,!0))}_moveHandler(e){const t=this;if(!Smart.ListBox.DragDrop.Feedback||Smart.ListBox.DragDrop.DraggedFrom!==t)return;const i=t.dragOffset;if(Smart.ListBox.DragDrop.Dragging){Smart.ListBox.DragDrop.Feedback.style.left=i[0]+e.pageX+"px",Smart.ListBox.DragDrop.Feedback.style.top=i[1]+e.pageY+"px",t.$.fireEvent("dragging",{item:Smart.ListBox.DragDrop.Item,data:Smart.ListBox.DragDrop,originalEvent:e.originalEvent});for(let t=0;t<Smart.ListBox.DragDrop.ListBoxes.length;t++){const i=Smart.ListBox.DragDrop.ListBoxes[t];i._dragInterval&&clearInterval(i._dragInterval),i._dragInterval=setInterval((function(){const t=i.getBoundingClientRect();t.left<=e.clientX&&t.left+t.width>=e.clientX&&(e.clientY>=t.top&&e.clientY<=t.top+20?i.scrollTop-=2:e.clientY>=t.top+t.height-20&&e.clientY<=t.top+t.height&&(i.scrollTop+=2))}),1)}return e.preventDefault(),e.stopPropagation(),e.originalEvent.preventDefault(),e.originalEvent.stopPropagation(),!1}{const r=Math.abs(e.pageX-Smart.ListBox.DragDrop.StartPosition.left),o=Math.abs(e.pageY-Smart.ListBox.DragDrop.StartPosition.top),s=new Date-Smart.ListBox.DragDrop.StartTime;let n=r>=5&&r<=15||o>=5&&o<=15;if(Smart.Utilities.Core.isMobile&&(s<300||s>1e3)&&(n=!1),n){Smart.ListBox.DragDrop.Dragging=!0,Smart.ListBox.DragDrop.Feedback.style.left=i[0]+e.pageX+"px",Smart.ListBox.DragDrop.Feedback.style.top=i[1]+e.pageY+"px",t.getShadowRootOrBody().appendChild(Smart.ListBox.DragDrop.Feedback),e.preventDefault(),e.stopPropagation(),e.originalEvent.preventDefault(),e.originalEvent.stopPropagation();const r=Smart.ListBox.DragDrop.Item,o=r.ownerListBox;o.$.fireEvent("dragStart",{item:r,data:Smart.ListBox.DragDrop,container:o,previousContainer:o,originalEvent:e.originalEvent}),document.body.classList.add("smart-dragging")}}}_focusHandler(){this._focused=!0,this.setAttribute("focus","")}_blurHandler(){this._focused=!1,this.removeAttribute("focus")}appendChild(e){const t=this;if(!t.isCompleted){const e=Array.prototype.slice.call(arguments,2);return HTMLElement.prototype.appendChild.apply(t,e.concat(Array.prototype.slice.call(arguments)))}t.isVirtualized?(t._items.indexOf(e)>-1&&t._items.splice(t._items.indexOf(e),1),t._items.push(e)):(e.dataItem=e,t.shadowRoot&&"light"===t.shadowDomMode?t.appendChild(e):t.$.itemsInnerContainer.appendChild(e),t._items.indexOf(e)>-1&&t._items.splice(t._items.indexOf(e),1),t._items.push(e)),t._refreshItems(),t._refreshSelection()}insertBefore(e,t){const i=this;if(!i.isCompleted){const e=Array.prototype.slice.call(arguments,2);return HTMLElement.prototype.insertBefore.apply(i,e.concat(Array.prototype.slice.call(arguments)))}i.isVirtualized?(i._items.indexOf(e)>-1&&i._items.splice(i._items.indexOf(e),1),i._items.splice(i._indexOf(t),0,e)):(e.dataItem=e,t.parentNode.insertBefore(e,t),i._items.indexOf(e)>-1&&i._items.splice(i._items.indexOf(e),1),i._items.splice(i._indexOf(t),0,e)),i._refreshItems(),i._refreshSelection()}removeChild(e){const t=this;if(!t.isCompleted){const e=Array.prototype.slice.call(arguments,2);return HTMLElement.prototype.removeChild.apply(t,e.concat(Array.prototype.slice.call(arguments)))}if(t.isVirtualized)t._items.splice(t._indexOf(e),1);else if(e.parentNode){const i=t.selectedIndexes.slice(0),r=t.selectedValues.slice(0),o=i.indexOf(e.dataIndex);e.parentNode.removeChild(e),o>-1&&(i.splice(o,1),r.splice(o,1),t.selectedIndexes=i,t.selectedValues=r)}t._refreshItems()}propertyChangedHandler(e,t,i){if("dataSource"===e&&(!i||i&&Array.isArray(i)&&0===i.length))return void this.clearItems();super.propertyChangedHandler(e,t,i);const r=this;switch(e){case"innerHTML":r.clearSelection(),r._dataBind(),r.innerHTML=r.content=Smart.Utilities.Core.html(r.$.content);break;case"dataSource":case"valueMember":case"groupMember":case"displayMember":r.clearSelection(),r._dataBind(),r._applyDefaultSelection();break;case"disabled":case"unfocusable":r._setFocusable();break;case"displayLoadingIndicator":r._setLoadingIndicatorVisibility();break;case"filterable":r._refreshFilter(),r._refreshLayout();break;case"grouped":if(i?r._group():r._ungroup(),"radioButton"===r.selectionMode){if(r.selectedValues.length>0){const e=r.selectedValues;r.clearSelection(),r.select(e[0])}}else r._refreshSelection();r._refreshLayout();break;case"itemTemplate":{if(null===i||""===i)return r._items.map((e=>e.innerHTML=e.label)),delete r._bindingDetails,void r._refreshLayout();const e=r.querySelectorAll("smart-list-item"),t=function(){r._handleItemTemplate(i)&&(r._items.map((e=>r._applyTemplate(e))),r._refreshLayout()),r.ownerElement&&r.ownerElement._setDropDownSize&&r.ownerElement._setDropDownSize(),r.$.fireEvent("bindingComplete")};0===e.length?t():r._ensureItemsReady(e,t);break}case"selectedIndexes":case"selectedValues":{let o=r.selectedIndexes.slice(0),s=r.selectedValues.slice(0);if(!r._items||0===r._items.length)return r.selectedIndexes=[],r.selectedValues=[],void(r.$.hiddenInput.value=r.selectedValues.toString());if(r._propertyChanging=!0,"selectedIndexes"===e){o=t.slice(0),r.clearSelection();for(let e=0;e<i.length;e++){const t=i[e],o=r._items[t];o&&("oneOrManyExtended"===r.selectionMode||"oneOrMany"===r.selectionMode?(r.selectedIndexes.length>0&&0===e&&r.clearSelection(),r._select(o)):r.select(o))}}else{s=t.slice(0),r.selectedValues=[],r.clearSelection();for(let e=0;e<i.length;e++){const t=i[e],o=r.getItem(t);o&&("oneOrManyExtended"===r.selectionMode?r._select(o):r.select(o))}}if(r.selectedIndexes.length>0&&r._focus(r._items[r.selectedIndexes[0]]),r._propertyChanging=!1,JSON.stringify(s)!==JSON.stringify(r.selectedValues.slice(0))){let e=[],t=[];for(let e=0;e<o.length;e++)r.selectedIndexes.indexOf(o[e])<0&&t.push(r._items[o[e]]);for(let t=0;t<r.selectedIndexes.length;t++)o.indexOf(r.selectedIndexes[t])<0&&e.push(r._items[r.selectedIndexes[t]]);let i={addedItems:e,removedItems:t};if(r.selectedIndexes.length>0){const e=r._items[r.selectedIndexes[r.selectedIndexes.length-1]];void 0!==e&&(i.selected=e.selected,i.disabled=e.disabled,i.index=r._indexOf(e),i.label=e.label,i.value=e.value)}else i.selected=!1,i.disabled=!1,i.index=-1,i.label="",i.value="";r.$.fireEvent("change",i),r._updateTargetValue()}break}case"selectionMode":{const e="checkBox"===r.selectionMode||"radioButton"===r.selectionMode?r.selectionMode:"plain",o=r.selectedIndexes.slice(0),s=r.selectedValues.slice(0);r._propertyChanging=!0;const n=r.selectedValues;r.setAttribute("aria-multiselectable",-1!==["oneOrManyExtended","zeroOrMany","oneOrMany","checkBox","radioButton"].indexOf(i)),r.selectedValues=[],r.clearSelection();for(let e=0;e<n.length;e++){const t=n[e],i=r.getItem(t);i&&("oneOrManyExtended"===r.selectionMode?r._select(i):r.select(i))}if(r._items.forEach((t=>t.displayMode=e)),r._recycle(),r._propertyChanging=!1,JSON.stringify(s)!==JSON.stringify(r.selectedValues.slice(0))){let e=[],t=[];for(let e=0;e<o.length;e++)r.selectedIndexes.indexOf(o[e])<0&&t.push(r._items[o[e]]);for(let t=0;t<r.selectedIndexes.length;t++)o.indexOf(r.selectedIndexes[t])<0&&e.push(r._items[r.selectedIndexes[t]]);let i={addedItems:e,removedItems:t};if(o.length>0){const e=r._items[o[o.length-1]];e&&(i.selected=e.selected,i.disabled=e.disabled,i.index=r._indexOf(e),i.label=e.label,i.value=e.value)}r.$.fireEvent("change",i),r._updateTargetValue()}r._applyAriaSelected(),"checkBox"!==i&&"radioButton"!==i&&"checkBox"!==t&&"radioButton"!==t||r._refreshLayout();break}case"topVisibleIndex":r._setTopVisibleIndex(i);break;case"autoSort":r._canSort=i;break;case"alternationStart":case"alternationEnd":case"alternationCount":r._refreshItems(),r._refreshLayout();break;case"sortDirection":case"sorted":{r._canSort=!0,i?r._sort():r._unsort();const e=r.selectedValues;r.selectedValues=[],r._refreshSelection();for(let t=0;t<e.length;t++){const i=e[t],o=r.getItem(i);o&&("oneOrManyExtended"===r.selectionMode?r._select(o):r.select(o))}r._refreshLayout(),r._canSort=r.autoSort;break}}}_refreshSelection(){const e=this;if(!e._items||0===e._items.length)return;const t=e.selectedValues;e.selectedIndexes=[],e.selectedValues=[];for(let i=0;i<e._items.length;i++){const r=e._items[i];r.selected=!1,t.indexOf(r.value)>-1&&e.select(r)}e._recycle()}clearSelection(){const e=this;if(!e._items||0===e._items.length)return;let t=[];for(let i=0;i<e._items.length;i++)e._items[i].selected&&t.push(e._items[i]);e._items.map((e=>e.selected=!1)),e.selectedValues.slice(0);const i=e.selectedIndexes.slice(0);if(e.selectedIndexes=[],e.selectedValues=[],e.$.hiddenInput.value=e.selectedValues.toString(),e._recycle(),e.context!==e){let r={addedItems:[],removedItems:t};if(i.length>0){const t=e._items[i[i.length-1]];t&&(r.selected=t.selected,r.disabled=t.disabled,r.index=e._indexOf(t),r.label=t.label,r.value=t.value)}e.$.fireEvent("change",r),e._updateTargetValue()}}ensureVisible(e){const t=this;if(e)return!("string"==typeof e&&!(e=t.getItem(e))||(t.isVirtualized||t.$.itemsContainer.scrollTop===t.scrollTop||(t.scrollTop=t.$.itemsContainer.scrollTop),e.top+e.height>=t.scrollTop+t.offsetHeight&&(t.scrollTop=t.scrollTop+e.height,t.isVirtualized||(t.$.itemsContainer.scrollTop=t.scrollTop)),(e.top<=t.scrollTop||e.top>=t.scrollTop+t.$.itemsContainer.offsetHeight)&&(t.scrollTop=e.top,t.isVirtualized||(t.$.itemsContainer.scrollTop=t.scrollTop)),0===t._indexOf(e)||1===t._indexOf(e)&&t._items.length>1&&t._items[0].grouped?(t.scrollTop=0,t.isVirtualized||(t.$.itemsContainer.scrollTop=t.scrollTop)):t._indexOf(e)===t._items.length-1&&(t.scrollTop=t.scrollHeight,t.isVirtualized||(t.$.itemsContainer.scrollTop=t.scrollTop)),0))}get items(){const e=this;if(!window.__karma__&&!window.karma&&e instanceof Element&&e.isRendered&&e.hasAttribute&&e.hasAttribute("smart-blazor")){let t=[];for(let i=0;i<e._items.length;i++){const r=e._items[i];t.push({label:r.label,value:r.value})}return t}return e._filteredItems?e._filteredItems:e._items}getItems(){const e=this,t=e._filteredItems?e._filteredItems:e._items;let i=[];if(t&&t.length>0)for(let e=0;e<t.length;e++){const r=t[e];i.push({label:r.label,value:r.value})}return i}ready(){super.ready();const e=this;if(e.shadowRoot&&"light"===e.shadowDomMode){const t=document.createDocumentFragment();[].slice.call(e.$.itemsInnerContainer.children).map((e=>t.appendChild(e))),e.appendChild(t),e.$.itemsInnerContainer.appendChild(document.createElement("slot"))}e._areCSSVarsSupported=Smart.Utilities.Core.CSSVariablesSupport(),e.isUpdating=0,e._scrollView&&(e._scrollView=new Smart.Utilities.Scroll(e,e.$.horizontalScrollBar,e.$.verticalScrollBar),e._scrollView.hScrollBar.$.addClass("smart-hidden"),e._scrollView.vScrollBar.$.addClass("smart-hidden"));const t=e._scrollView.vScrollBar,i=e._scrollView.hScrollBar;t.hasStyleObserver=!1,i.hasStyleObserver=!1,t.hasResizeObserver=!1,i.hasResizeObserver=!1,t.wait=!1,i.wait=!1,e._setFocusable()}render(){const e=this;e.setAttribute("role","listbox"),e.setAttribute("aria-orientation","vertical"),e.$.verticalScrollBar.setAttribute("aria-controls",e.id),e.$.horizontalScrollBar.setAttribute("aria-controls",e.id),e._keysPressed={},e._incrementalSearchQuery="",e._incrementalSearchItems=[],e._canSort=!0,e._previousEntry="",e._setLoadingIndicatorVisibility(),e._refreshFilter(),e._initializeInnerHTML(),e._dataBind(),e._applyDefaultSelection(),e.enableShadowDOM&&HTMLElement.prototype.appendChild.apply(e,[e.$.hiddenInput]),e.setAttribute("aria-multiselectable",-1!==["oneOrManyExtended","zeroOrMany","oneOrMany","checkBox","radioButton"].indexOf(e.selectionMode)),super.render()}_lazyInitItems(){const e=this;if(e._inLazyInit)return cancelAnimationFrame(Smart.ListBox.processTimer),void delete Smart.ListBox.processTimer;e._inLazyInit=!0,e.dataSource||(e.clearSelection(),e._dataBind(),e._applyDefaultSelection()),cancelAnimationFrame(Smart.ListBox.processTimer),delete Smart.ListBox.processTimer,e._inLazyInit=!1}_applyDefaultSelection(){const e=this;!e._focusedItem&&e._items&&e._items.length>0&&0===e.selectedIndexes.length&&("one"!==e.selectionMode&&"oneOrMany"!==e.selectionMode&&"oneOrManyExtended"!==e.selectionMode||e.select(e._items[0]))}attached(){const e=this;super.attached(),Smart.ListBox.DragDrop||(Smart.ListBox.DragDrop={ListBoxes:[]}),Smart.ListBox.DragDrop.ListBoxes.push(e),e._scrollView||(e._scrollView=new Smart.Utilities.Scroll(e,e.$.horizontalScrollBar,e.$.verticalScrollBar)),e.selectedIndexes.length>0&&e._items&&e.ensureVisible(e._items[e.selectedIndexes[0]])}detached(){const e=this;if(super.detached(),e._scrollView&&(e._scrollView.unlisten(),delete e._scrollView),Smart.ListBox.DragDrop&&Smart.ListBox.DragDrop.ListBoxes){const t=Smart.ListBox.DragDrop.ListBoxes.indexOf(e);Smart.ListBox.DragDrop.ListBoxes.splice(t,1)}}_createItem(e,t,i){const r=this,o="checkBox"===r.selectionMode||"radioButton"===r.selectionMode?r.selectionMode:"plain",s=i?{}:document.createElement("smart-list-item");s.ownerListBox=r,"number"==typeof e&&(e=""+e);const n=function(t,i){return void 0!==e[t]?""+e[t]:e[i]};let l="string"==typeof e?e:n(r.displayMember,"label"),a="string"==typeof e?e:n(r.valueMember,"value"),d=n(r.groupMember,"group");return void 0===l&&(l=void 0!==t?""+t:""),s.label=s.innerHTML=""+l,void 0===a&&(a=void 0!==t?""+t:l),e.color&&(s.color=e.color),s.value=""+a,s.displayMode=o,s.selected=!!e.selected&&e.selected,s.disabled=!!e.disabled&&e.disabled,s.dataItem=s,void 0!==t&&(s.dataIndex=t),r._alternateItem(s),e.title&&(s.title=e.title),d&&(s.group=""+d),s}_alternateItem(e){const t=this,i=t.alternationStart,r=t.alternationEnd>0?t.alternationEnd:1/0;t.alternationCount<=0||(void 0===t._alternationIndexCounter&&(t._alternationIndexCounter=0),e.dataIndex>=i&&e.dataIndex<=r&&(e.alternationIndex=t._alternationIndexCounter++,t._alternationIndexCounter===t.alternationCount&&(t._alternationIndexCounter=0)))}_beginUpdate(){this.isUpdating++}_isUpdating(){return this.isUpdating>0}_endUpdate(){this.isUpdating--}get _scrollHeight(){const e=this;if(0===e._items.length||e._items.filter((e=>!e.hidden)).length<1)return 0;let t=0;if(e.isVirtualized){if(e.__scrollHeight)return e.__scrollHeight;if(0===e._items.length)return 0;e.isUpdating++;const i=e._createItem(e.dataSource[0]);e.$.itemsInnerContainer.appendChild(i);for(let r=0;r<e._items.length;r++){const o=e._items[r];o.hidden?(o.height=0,o.top=t):(e.itemHeight?(e.itemHeight<32&&(e.itemHeight=32),o.height=e.itemHeight):(i.$&&i.$.itemContainer?i.$.itemContainer.firstElementChild.innerHTML=o.label:i.label=o.label,o.height=i.offsetHeight),o.top=t,t+=o.height)}e.$.itemsInnerContainer.removeChild(i),e.__scrollHeight=t-e.$.itemsInnerContainer.offsetHeight,e.filterable&&(e.__scrollHeight+=e.$.filterInput.offsetHeight),t=e.__scrollHeight,e.isUpdating--}else{for(let i=0;i<e._items.length;i++){const r=e._items[i];r.hidden?(r.height=0,r.top=t):(e.itemHeight?"auto"!==e.itemHeight&&(r.height=e.itemHeight,r.style.height=r.height+"px"):r.height=r.offsetHeight,r.top=r.offsetTop,t+=r.height)}t=e.$.itemsInnerContainer.scrollHeight-e.$.itemsInnerContainer.offsetHeight,e.filterable&&t>0&&(t+=e.$.filterInput.offsetHeight),e.__scrollHeight=t}return t}_initializeRecyclingItems(){const e=this;if(!e.dataSource||e.dataSource&&0===e.dataSource.length||!e.isVirtualized)return;let t=0,i=e.offsetHeight||400;e.$.itemsInnerContainer.innerHTML="",e._recyclingItems=[];const r=function(){for(let r=0;r<e.dataSource.length;r++){const o=e.dataSource[r],s=e._createItem(o);if(e.itemHeight&&"auto"!==e.itemHeight&&(s.style.height=e.itemHeight+"px"),e.$.itemsInnerContainer.appendChild(s),t+=s.offsetHeight,s.dataItem=e._items[r],e._recyclingItems.push(s),t>1.5*i)break}};r();let o=0;for(;t<1.5*i&&++o<5;)r()}_dataBind(){const e=this;if(e._scrollView||(e._scrollView=new Smart.Utilities.Scroll(e,e.$.horizontalScrollBar,e.$.verticalScrollBar)),"function"==typeof e.dataSource&&(e._items=[],delete e._filteredItems),"string"==typeof e.dataSource&&(e.dataSource=JSON.parse(e.dataSource)),null!==e.dataSource&&Array.isArray(e.dataSource)){e.isUpdating++;const t=t=>{e._items=[],e._groups=[],delete e._filteredItems;const i=e.dataSource;for(let r=0;r<i.length;r++){const o=i[r],s=e._createItem(o,r,!t);e._items[r]=s,t&&t.appendChild(s)}};if(e.isVirtualized)t(),e._initializeRecyclingItems();else{const i=document.createDocumentFragment();e.$.itemsInnerContainer.innerHTML="",t(i),e.$.itemsInnerContainer.appendChild(i)}e.isUpdating--}const t=e.shadowRoot?e.shadowRoot.querySelectorAll("smart-list-item"):e.querySelectorAll("smart-list-item"),i=function(){e.isUpdating++,e.dataSource||(e._initializeHtmlListItems(),e._initializeHtmlListGroups()),e.grouped&&e._group(),e.sorted&&e._sort(),e._refreshLayout(),e._initializeSelection(),e.isInitialized=!0,e._canSort=e.autoSort,e.isUpdating--,e.itemTemplate&&e._handleItemTemplate(e.itemTemplate)&&(e._items.map((t=>e._applyTemplate(t))),e._refreshLayout()),e.__onCompleted&&(e._onCompleted=e.__onCompleted,e.__onCompleted=null,e._onCompleted()),e.topVisibleIndex>-1&&e._setTopVisibleIndex(e.topVisibleIndex),e.$.fireEvent("bindingComplete"),e._updateTopVisibleIndex(),0===e._items.length&&e.clearItems(),e._applyAriaSelected()};0===t.length?i():(e._onCompleted&&(e.__onCompleted=e._onCompleted,e._onCompleted=null),e._ensureItemsReady(t,i))}_ensureItemsReady(e,t){const i=this,r=function(){const i=function(t){for(let i=0;i<e.length;i++)e[i].context="node"===t?e[i]:document};i("node"),t(),i()};if(0===e.length)r();else{i._nodesReadyListeners=0;for(let t=0;t<e.length;t++){const o=e[t],s=function(){i._nodesReadyListeners--,0===i._nodesReadyListeners&&(r(),delete i._nodesReadyListeners)}.bind(i);o.isCompleted||(i._nodesReadyListeners++,o._onCompleted=s)}0===i._nodesReadyListeners&&r()}}_initializeInnerHTML(){const e=this;e.$.itemsInnerContainer.innerHTML.indexOf("<option")>=0?e.$.itemsInnerContainer.innerHTML=e.$.itemsInnerContainer.innerHTML.replace(/<optgroup/gi,"<smart-list-items-group").replace(/<\/optgroup/gi,"</smart-list-items-group").replace(/<option/gi,"<smart-list-item").replace(/<\/option/gi,"</smart-list-item"):e.$.itemsInnerContainer.innerHTML.indexOf("<ul")>=0&&(e.$.itemsInnerContainer.innerHTML=e.$.itemsInnerContainer.innerHTML.replace(/<ul/gi,"<smart-list-items-group").replace(/<\/ul/gi,"</smart-list-items-group").replace(/<li/gi,"<smart-list-item").replace(/<\/li/gi,"</smart-list-item"))}_initializeHtmlListItems(){const e=this,t=e.shadowRoot&&"shadow"===e.shadowDomMode?e.shadowRoot.querySelectorAll("smart-list-item"):e.querySelectorAll("smart-list-item"),i="checkBox"===e.selectionMode||"radioButton"===e.selectionMode?e.selectionMode:"plain",r=function(e,t,i){return void 0!==e[t]?""+e[t]:e[i]};e._items=[];let o=0;for(let s=0;s<t.length;s++){const n=t[s];n.dataIndex=s,n.label=n.innerHTML,n.dataItem=n,n.top||(n.top=o),n.height||(n.height=n.offsetHeight),o+=n.height,n.value||(n.value=""+s);const l=r(n,e.displayMember,"label"),a=r(n,e.valueMember,"value"),d=r(n,e.groupMember,"group");n.label!==l&&(n.label=l),n.value!==a&&(n.value=a),n.group!==d&&(n.group=d);const c=n.context;n.context=document,n.displayMode=i,n.context=c,e._alternateItem(n),n.selected&&(e.selectedIndexes.push(s),e.selectedValues.push(n.value)),e._items.push(n)}e.itemTemplate&&e._handleItemTemplate(e.itemTemplate)&&e._items.map((t=>e._applyTemplate(t)))}_group(){const e=this;e.isUpdating++;let t=[],i=[];e._canSort&&e._unsort();for(let i=0;i<e._items.length;i++){const r=e._items[i];let o=r.group?r.group.trim():r.innerHTML.charAt(0)||r.label.charAt(0);o+=" ",t[o]?t[o].items.push(r):t[t.length++]=t[o]={items:[r],label:o}}if(e.isVirtualized){e._groups=[];for(let e=0;e<t.length;e++){const r=t[e];r.dataIndex=e,r.grouped=!0,r.hidden=!1,r.displayMode="plain",i.push(r);for(let o=0;o<t[e].items.length;o++){const e=r.items[o];e.group=r,i.push(e)}}e._groups=t,e._items=i}else{for(;e.$.itemsInnerContainer.firstChild;)e.$.itemsInnerContainer.removeChild(e.$.itemsInnerContainer.firstChild);const r=document.createDocumentFragment();e._groups=[];for(let o=0;o<t.length;o++){const s=t[o],n=document.createElement("smart-list-items-group");n.label=s.label,n.dataIndex=o;for(let e=0;e<t[o].items.length;e++){const t=s.items[e];i.push(t),t.group=s.label,n.appendChild(t)}e._groups.push(n),r.appendChild(n)}e._items=i,/Trident|Edge/.test(navigator.userAgent)?setTimeout((function(){e.$.itemsInnerContainer.appendChild(r)}),50):e.$.itemsInnerContainer.appendChild(r)}e.sorted&&e._sort(),e.isUpdating--}_ungroup(){const e=this;e.isUpdating++,e._groups=[],e._canSort&&e._unsort();let t=[];if(e.isVirtualized)for(let i=0;i<e._items.length;i++){const r=e._items[i];r.grouped||t.push(r)}else{const i=document.createDocumentFragment();for(let r=0;r<e._items.length;r++){const o=e._items[r];i.appendChild(o),t.push(o)}t.length>0&&(e.$.itemsInnerContainer.innerHTML="",e.$.itemsInnerContainer.appendChild(i))}e._items=t,e.sorted&&e._sort(),e.isUpdating--}_initializeHtmlListGroups(){const e=this,t=e.$.itemsInnerContainer.querySelectorAll("smart-list-items-group");e._groups=[];for(let i=0;i<t.length;i++){const r=t[i];r.dataIndex=i,e._groups.push(r)}}_initializeSelection(){const e=this,t=e.selectedIndexes.slice(0),i=e.selectedValues.slice(0);e.clearSelection(),"oneOrManyExtended"===e.selectionMode&&(e._keysPressed.Control=!0);for(let r=0;r<e._items.length;r++){const o=e._items[r];(t.indexOf(r)>=0||i.indexOf(o.value||o.label)>=0)&&(e._focusedItem&&(e._focusedItem._focused=!1),e._focusedItem=null,e.select(o))}"oneOrManyExtended"===e.selectionMode&&(e._keysPressed.Control=!1)}onItemUpdated(){const e=this;e.isInitialized&&!e._isUpdating()&&(e.isUpdating++,e._refreshLayout(),e.isUpdating--)}_refreshItems(){const e=this;if(e.isInitialized&&!e._isUpdating()){if(e.isUpdating++,e.grouped?e._ungroup():e.sorted&&e._canSort&&e._unsort(),!e.isVirtualized){e._items=[];const t=e.shadowRoot?e.shadowRoot.querySelectorAll("smart-list-item"):e.querySelectorAll("smart-list-item");for(let i=0;i<t.length;i++)t[i].dataIndex=i,e._alternateItem(t[i]),e._items.push(t[i])}e.grouped?e._group():e.sorted&&e._sort(),e._refreshLayout(),e.isUpdating--}}_applyIncrementalSearch(e){const t=this;null===t.incrementalSearchDelay||isNaN(t.incrementalSearchDelay)||["Shift","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Control","Home","End","PageUp","PageDown"].indexOf(e)>-1||(0!==t._incrementalSearchQuery.indexOf(e)&&(t._incrementalSearchQuery+=e),t._incrementalSearchTimer&&clearTimeout(t._incrementalSearchTimer),t._incrementalSearch(),t._incrementalSearchTimer=setTimeout((function(){t._incrementalSearchQuery=""}),t.incrementalSearchDelay))}select(e){const t=this;if(("string"!=typeof e||(e=t.getItem(e)))&&("number"!=typeof e||(e=t.getItem(e)))&&!(e.grouped||e.readonly||!t._items.length||e instanceof HTMLElement&&!t.contains(e))){if("none"===t.selectionMode)return t.selectedIndexes=[],void(t.selectedValues=[]);switch(!t._focusedItem!==e&&"none"!==t.selectionMode&&(t._focusedItem&&(t._focusedItem._focused=!1),t._focusedItem=e,e._focused=!0),t.selectionMode){case"one":case"zeroAndOne":return(1!==t.selectedIndexes.length||t.selectedIndexes[0]!==t._indexOf(e))&&(t._previouslySelectedIndexes=t.selectedIndexes,t.selectedIndexes.length>=1&&t.clearSelection(),t._select(e),delete t._previouslySelectedIndexes,!0);case"zeroOrOne":return 1===t.selectedIndexes.length&&t.selectedIndexes[0]===t._indexOf(e)?(t.unselect(e),!0):(t._previouslySelectedIndexes=t.selectedIndexes,t.selectedIndexes.length>=1&&t.clearSelection(),t._select(e),delete t._previouslySelectedIndexes,!0);case"radioButton":if(t._previouslySelectedIndexes=t.selectedIndexes,t.$.itemsInnerContainer.querySelectorAll("smart-list-items-group").length>0){const i=e.parentNode;if(!e.selected){for(let e in i.children){const r=i.children[e];r.selected&&t.unselect(r)}t._select(e)}return delete t._previouslySelectedIndexes,!0}if(t.isVirtualized&&t._groups.length>0){const i=e.group;if(!e.selected){for(let e in i.items){const r=i.items[e];r.selected&&t.unselect(r)}t._select(e)}return delete t._previouslySelectedIndexes,!0}return e.selected||(t.selectedIndexes.length>=1&&t.clearSelection(),t._select(e)),delete t._previouslySelectedIndexes,!0;case"oneOrMany":return e.selected?t.selectedIndexes.length>1&&t.unselect(e):t._select(e),!0;case"zeroOrMany":case"checkBox":return e.selected?t.unselect(e):t._select(e),!0;case"oneOrManyExtended":{const i=t.selectedValues;if(t._keysPressed.Control)return t.selectedIndexes.length>1&&e.selected?(t.unselect(e),t._focus(t._items[t.selectedIndexes[0]])):t._select(e),!0;if(t._keysPressed.Shift){const r=t._items[t.selectedIndexes[0]];let o;t.clearSelection();const s=i.indexOf(r.value)>=0||r.selected;if(t._select(r,s),t._indexOf(r)>t._indexOf(e))for(o=t._indexOf(r)-1;o>=t._indexOf(e);){const e=t._items[o],r=i.indexOf(e.value)>=0||e.selected;t._select(e,r),o--}else for(o=t._indexOf(r)+1;o<=t._indexOf(e);){const e=t._items[o],r=i.indexOf(e.value)>=0||e.selected;t._select(e,r),o++}const n=[];for(let e=0;e<i.length;e++)n.push(t.getItem(i[e]));if(n.length>0&&!t._propertyChanging){let r=[];for(let e=0;e<t.selectedValues.length;e++){const o=t.selectedValues[e];i.indexOf(o)<0&&r.push(t.getItem(o))}t.$.fireEvent("change",{addedItems:r,removedItems:n,selected:e.selected,disabled:e.disabled,index:t._indexOf(e),label:e.label,value:e.value}),t._updateTargetValue()}return!0}for(let r=0;r<i.length;r++){const o=i[r],s=t.getItem(o);e!==s&&t.unselect(s)}return t.clearSelection(),t._select(e,i.indexOf(e.value)>=0),!0}}return!1}}_applyTemplate(e,t){const i=this;if(null===i.itemTemplate)return;if("function"==typeof i.itemTemplate)return void i.itemTemplate(e,{label:e.label,value:e.value,index:i._items.indexOf(e)});if(!i._bindingDetails||0===i._bindingDetails.length)return;const r=i._bindingDetails.length;let o,s,n=document.importNode(i._template.content,!0);for(let t=0;t<r;t++){o=n.childNodes[i._bindingDetails[t].childNodeIndex],s=i._bindingDetails[t].bindingString.length;for(let r=0;r<s;r++){const s=i._bindingDetails[t].bindingString[r],n=s.indexOf("label")>=0?e.label:e.value;o.innerHTML=o.innerHTML.replace(s,n)}}e.innerHTML="";for(let t=0;t<n.childNodes.length;t++)n.childNodes[t].outerHTML&&(e.innerHTML+=n.childNodes[t].outerHTML);!1!==t&&(i._scrollHeightTimer&&(clearInterval(i._scrollHeightTimer),i._scrollHeightCounter=0),i._scrollHeightTimer=setInterval((function(){i._lastScrollHeight===i.$.itemsInnerContainer.scrollHeight&&10!==i._scrollHeightCounter||(i._refreshLayout(),clearInterval(i._scrollHeightTimer)),i._lastScrollHeight=i.$.itemsInnerContainer.scrollHeight,i._scrollHeightCounter++}),50))}_filterItems(e,t,i){const r=this,o=r.$.filterInput.value;let s,n;const l=function(){if(0===n.length)return r._filteredItems=[],void(t&&t());s=r._queryItems(o,r.filterMode);for(let e=0;e<n.length;e++)n[e].hidden=!0,n[e].$&&n[e].$.addClass("smart-hidden");for(let e=0;e<s.length;e++){const t=s[e];t.hidden=!1,n[e].$&&t.$.removeClass("smart-hidden")}if(r.grouped&&r.isVirtualized)for(let e=0;e<r._groups.length;e++){const t=r._groups[e],i=t.items;let o=!0;for(let e=0;e<i.length;e++)i[e].hidden||(o=!1);o&&(t.hidden=!0)}if(r.grouped&&!r.isVirtualized)for(let e=0;e<r._groups.length;e++){const t=r._groups[e],i=[].concat(...t.querySelectorAll("smart-list-item"));let o=!0;for(let e=0;e<i.length;e++)i[e].$.hasClass("smart-hidden")||(o=!1);o?t.$.addClass("smart-hidden"):t.$.removeClass("smart-hidden")}if(r._filteredItems=s,r._refreshLayout(),t&&t(),e)return;const i=r._propertyChanging;r._propertyChanging=!0,r._refreshSelection(),r._propertyChanging=i};if("function"==typeof r.dataSource)if(o||i){const e=function(e){(o||i)&&r.isAttached&&(r._updateListBoxAfterQuery=function(){s=n=r._items,l()},r.clearItems(),r.insert(0,e))},t=r.dataSource(o,e);if(t){if(!o&&!i)return;r._updateListBoxAfterQuery=function(){s=n=r._items,l()},r.clearItems(),r.insert(0,t)}}else r.clearItems(),s=n=r._items,l(),r.$.fireEvent("bindingComplete");else{if(n=r._items,0===n.length)return;l()}}_getNextItem(e){const t=this._items,i=this._items.length;let r=Math.max(e+1,0);for(;r<i;){const e=t[r];if(!(e.disabled||e.hidden||e.grouped||e.readonly))return e;r++}return t[e]}_getPreviousItem(e){const t=this._items;let i=Math.max(e-1,0);for(;i>-1;){const e=t[i];if(!(e.disabled||e.hidden||e.grouped||e.readonly))return e;i--}return t[e]}get _scrollWidth(){const e=this,t=e._items;return e.__scrollWidth||(e.__scrollWidth=(()=>{const e=this,i=e.virtualized,r=e.itemMeasureMode;let o=0,s="";function n(t){const i=e._createItem({label:t});i.style.position="absolute",e.$.itemsContainer.appendChild(i),i.label=t,i.style.width="auto",i.isCompleted&&(i.$.itemContainer.style.width="auto");const r=getComputedStyle(i),o=parseInt(r.paddingLeft)+parseInt(r.paddingRight),s=i.$.itemContainer||i,n=s.offsetWidth+s.offsetLeft+o;return i.parentNode.removeChild(i),n}for(let e=0;e<t.length;e++){const l=t[e];if(!l.hidden)if("auto"===r){const e=i?l.label:l.textContent.trim();e.length>s.length&&(s=e)}else o=Math.max(o,n(l.label))}return"auto"===r?n(s):o})()),e.__scrollWidth}update(e,t){const i=this,r=i._items[e];if(r){if("string"==typeof t)r.label=t,void 0===r.value&&(r.value=t);else for(let e in t)"selected"===e&&r[e]!==t[e]?i.select(r):r[e]=t[e],"group"===e&&i._refreshItems();(i.sorted||i.grouped||i.isVirtualized)&&(i._refreshItems(),i._refreshSelection())}else i.error(i.localize("indexOutOfBound",{elementType:i.nodeName.toLowerCase(),method:"update"}))}insert(e,t){const i=this;let r=[];if((!e||e<0)&&(e=0),Array.isArray(t)){i.isUpdating++;for(let o=0;o<t.length;o++){const s=t[o],n=i._createItem(s);r.push(n),e>=i._items.length||0===i._items.length?i.appendChild(n):i.insertBefore(n,i._items[e])}i.isUpdating--}else{const o=i._createItem(t);r.push(o),e>=i._items.length||0===i._items.length?i.appendChild(o):i.insertBefore(o,i._items[e])}r.length>0?(r.map((e=>i._applyTemplate(e))),i._ensureItemsReady(r,(function(){i._refreshItems(),0!==i._items.length&&(i._updateListBoxAfterQuery&&(i._updateListBoxAfterQuery(),delete i._updateListBoxAfterQuery),i._refreshSelection(),i.$.fireEvent("bindingComplete"))}))):i._updateListBoxAfterQuery&&(i._updateListBoxAfterQuery(),delete i._updateListBoxAfterQuery)}removeAt(e){const t=this,i=t._items[e];i?(i.selected&&t.unselect(i),t.isVirtualized?t._items.splice(e,1):i.parentNode.removeChild(i),t._refreshItems(),t._refreshSelection(),0===t.selectedIndexes.length&&t._items.length>0&&("oneOrMany"!==t.selectionMode&&"one"!==t.selectionMode&&"oneOrManyExtended"!==t.selectionMode||t.select(t._items[0]))):t.error(t.localize("indexOutOfBound",{elementType:t.nodeName.toLowerCase(),method:"remove"}))}_queryItems(e,t){const i=this,r=[],o=function(r,o){if(r.grouped)return r;switch(t){case"startsWith":if(0===r.label.indexOf(o))return r;break;case"startsWithIgnoreCase":if(0===r.label.toLowerCase().indexOf(o.toLowerCase()))return r;break;case"doesNotContain":if(r.label.indexOf(o)<0)return r;break;case"doesNotContainIgnoreCase":if(r.label.toLowerCase().indexOf(o.toLowerCase())<0)return r;break;case"contains":if(r.label.indexOf(o)>-1)return r;break;case"containsIgnoreCase":if(r.label.toLowerCase().indexOf(o.toLowerCase())>-1)return r;break;case"equals":if(0===r.label.localeCompare(o))return r;break;case"equalsIgnoreCase":if(0===r.label.toLowerCase().localeCompare(o.toLowerCase()))return r;break;case"endsWith":if(r.label.endsWith(o))return r;break;case"endsWithIgnoreCase":if(r.label.toLowerCase().endsWith(o.toLowerCase()))return r;break;case"custom":if(i.filterCallback(r,e))return r}return null};if(0===e.length)return i._items;for(let t=0;t<i._items.length;t++){const s=o(i._items[t],e);s&&r.push(s)}return r}_select(e,t){const i=this,r=i.selectedIndexes.indexOf(i._indexOf(e)),o=i.selectedIndexes.slice(0),s=i.selectedValues.slice(0);if(e.selected=!0,-1!==r)return i._recycle(),!1;if(o.push(i._indexOf(e)),s.push(e.value||e.label),i.selectedIndexes=o,i.selectedValues=s,i._recycle(),i.$.hiddenInput.value=s.toString(),!i.isCompleted||t||!i.isInitialized||i._propertyChanging)return;let n=[];if(i._previouslySelectedIndexes){for(let e=0;e<i._previouslySelectedIndexes.length;e++)i.selectedIndexes.indexOf(i._previouslySelectedIndexes[e])<0&&n.push(i._items[i._previouslySelectedIndexes[e]]);delete i._previouslySelectedIndexes}return i.$.fireEvent("change",{addedItems:[e],removedItems:n,selected:e.selected,disabled:e.disabled,index:i._indexOf(e),label:e.label,value:e.value}),i._updateTargetValue(),!0}_updateTargetValue(){const e=this;if(e.dataset.target){const t=document.querySelector(e.dataset.target);if(t){const i=e.dataset.property,r=e.value;i&&void 0!==t[i]&&(t[i]=r)}}}_setTopVisibleIndex(e){const t=this;if("number"==typeof e&&(t.topVisibleIndex=Math.max(0,e),e=t._items[t.topVisibleIndex]),!e)return!1;e.top!==t.scrollTop&&(t.scrollTop=e.top,t.isVirtualized||(t.$.itemsContainer.scrollTop=t.scrollTop),t.scrollHeight===t.scrollTop&&t._updateTopVisibleIndex())}_updateTopVisibleIndex(){const e=this,t=e.scrollTop+e._scrollView.verticalScrollBar.offsetHeight-e.offsetHeight;let i;if(e.scrollTop<e.scrollHeight/2){for(let r=0;r<e._items.length;r++)if(e._items[r].top>=t){i=e._items[r];break}}else for(let r=e._items.length-1;r>=0&&!(e._items[r].top<t);r--)i=e._items[r];if(i){const t=e.context;e.context=e,e.topVisibleIndex=i.dataIndex,e.context=t}}unselect(e){const t=this;if(!e)return;if("string"==typeof e&&!(e=t.getItem(e)))return;if("none"===t.selectionMode)return void t.clearSelection();const i=t.selectedIndexes.indexOf(t._indexOf(e)),r=t.selectedIndexes.slice(0),o=t.selectedValues.slice(0);return e.selected=!1,i>=0&&(r.splice(i,1),o.splice(i,1),t.selectedIndexes=r,t.selectedValues=o,t.$.hiddenInput.value=o.toString(),t.isCompleted&&!t._propertyChanging?(t.$.fireEvent("change",{addedItems:[],removedItems:[e],selected:e.selected,disabled:e.disabled,index:t._indexOf(e),label:e.label,value:e.value}),t._updateTargetValue(),t._recycle(),!0):void 0)}_handleItemTemplate(e){if(null===e||!e)return;if("function"==typeof e)return e;const t=this;if(!("content"in document.createElement("template")))return t.error(t.localize("htmlTemplateNotSuported",{elementType:t.nodeName.toLowerCase()})),void(t.itemTemplate=null);if(null===(e=document.getElementById(e))||!("content"in e))return t.error(t.localize("invalidTemplate",{elementType:t.nodeName.toLowerCase(),property:"itemTemplate"})),void(t.itemTemplate=null);const i=e.content,r=i.childNodes.length,o=/{{\w+}}/g;let s,n;t._bindingDetails=[],t._template=e;for(let e=0;e<r;e++){for(n=[];s=o.exec(i.childNodes[e].innerHTML);)n.push(s[0]);n.length>0&&t._bindingDetails.push({childNodeIndex:e,bindingString:n})}return!0}_handleKeyStrokes(e){const t=this,i="radioButton"===t.selectionMode||"checkBox"===t.selectionMode||"zeroOrMany"===t.selectionMode||"oneOrMany"===t.selectionMode||"zeroOrOne"===t.selectionMode;let r=t._items;if(t.filterable&&t.$.filterInput.value.length>0&&(r=t._filteredItems),!t.disabled&&!t.readonly&&r.length){switch(e){case"ArrowLeft":case"ArrowUp":t._handleArrowKeys(!0);break;case"ArrowRight":case"ArrowDown":t._handleArrowKeys(!1);break;case" ":{if(t.selectedIndexes.length<1&&!t._focusedItem)return;const e=t._focusedItem?t._focusedItem:t._items[t.selectedIndexes[t.selectedIndexes.length-1]],i=e=>{e.selected&&"radioButton"!==t.selectionMode?t.unselect(e):t.select(e)};if("oneOrMany"===t.selectionMode)return void(e.selected&&t.selectedIndexes.length>1?i(e):e.selected||i(e));i(e);break}case"Home":if(0===r.length)return;i||(t._keysPressed.Shift||t.clearSelection(),t.select(r[0])),t._focus(r[0]),t.scrollTop=0;break;case"End":if(0===r.length)return;i||(t._keysPressed.Shift||t.clearSelection(),t.select(r[r.length-1])),t._focus(r[r.length-1]),t.scrollTop=t.scrollHeight;break;case"PageUp":t._pageUpKeyHandler(r);break;case"PageDown":t._pageDownKeyHandler(r)}t._recycle()}}_horizontalScrollbarHandler(e){const t=this;e&&e.stopPropagation&&e.stopPropagation(),t.isVirtualized?t._recycle():t.$.itemsContainer.scrollLeft=t._getScrollLeft(e.detail.value)}_getScrollLeft(e,t){const i=this;if(!i.rightToLeft)return e;if(Smart.Utilities.Core.Browser.Chrome){if(!t){const e=2*(parseInt(getComputedStyle(i.$.itemsInnerContainer).getPropertyValue("--smart-list-item-horizontal-offset"))||0);t=i._scrollWidth-i.$.itemsContainer.offsetWidth-e}e=t-e}else e*=-1;return e}_unsort(){const e=this;e.isUpdating++;const t=function(e,t){let i=e.dataIndex,r=t.dataIndex;return i<r?-1:i>r?1:0};if(e.isVirtualized)if(e._groups.length>0){e._groups.sort(t);let i=[];for(let r=0;r<e._groups.length;r++){const o=e._groups[r],s=[].concat(...o.items);s.sort(t),i.push(o),i=i.concat(s)}e._items=i}else e._items.sort(t);else{if(e._groups.length>0){e._groups.sort(t);let i=[];for(let r=0;r<e._groups.length;r++){const o=e._groups[r],s=[].concat(...o.querySelectorAll("smart-list-item"));s.sort(t),i=i.concat(s)}e._items=i}else e._items.sort(t);e._applySortOrder()}e.isUpdating--}_applySortOrder(){const e=function(e){for(let t=0;t<e.length;t++){const i=e[t],r=i.parentNode;r&&r.appendChild(i)}};e(this._items),e(this._groups)}_sort(){const e=this;if(!e._canSort)return;e.isUpdating++;const t=function(t,i){let r=t.label,o=i.label;if("asc"===e.sortDirection){if(r<o)return-1;if(r>o)return 1}else{if(r<o)return 1;if(r>o)return-1}return 0};if(e._groups.sort(t),e.isVirtualized)if(e._groups.length>0){let i=[];for(let r=0;r<e._groups.length;r++){const o=e._groups[r],s=[].concat(...o.items);i.push(o),s.sort(t),i=i.concat(s)}e._items=i}else e._items.sort(t);else{if(e._groups.length>0){let i=[];for(let r=0;r<e._groups.length;r++){const o=e._groups[r],s=[].concat(...o.querySelectorAll("smart-list-item"));s.sort(t),i=i.concat(s)}e._items=i}else e._items.sort(t);e._applySortOrder()}e.isUpdating--}getItem(e){const t=this;for(let i=0;i<t._items.length;i++)if(t._items[i].value===e)return t._items[i];return null}_focus(e){const t=this;!e||"none"===t.selectionMode||t.disabled||t.readonly||(t._focusedItem&&(t._focusedItem._focused=!1),t._focusedItem=e,t._focusedItem._focused=!0)}_keyDownHandler(e){const t=this,i=(t.shadowRoot||t.getRootNode()).activeElement||document.activeElement;let r=e.key;if(e.metaKey&&(r="Control"),!t.disabled&&!t.readonly&&(!t.filterable||t.$.filterInput!==i)&&t._focused&&0!==t._items.length&&!t.disabled&&!t.displayLoadingIndicator){if(t.editable){if("F2"===r)return void t._dblclickEventHandler({target:t._focusedItem});if(t.$.editInput===i)return}if("none"!==t.selectionMode){switch(e.stopPropagation(),r){case"Down":case"Right":case"Left":case"Up":r="Arrow"+r}if(t.filterable)switch(r){case"ArrowLeft":case"ArrowRight":return;case"ArrowUp":case"ArrowDown":e.preventDefault()}if(t._applyIncrementalSearch(r),!(["Shift","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Control"," ","Home","End","PageUp","PageDown"].indexOf(r)<0))if(e.preventDefault(),!t._focusedItem&&t._items.length>0)"one"===t.selectionMode||"oneOrMany"===t.selectionMode||"oneOrManyExtended"===t.selectionMode?t.select(t._items[0]):t._focus(t._items[0]);else switch(t.selectionMode){case"one":case"zeroAndOne":if("Shift"===r||"Control"===r||" "===r)return;t._handleKeyStrokes(r);break;case"oneOrMany":case"zeroOrOne":case"zeroOrMany":case"radioButton":case"checkBox":if("Shift"===r||"Control"===r)return;t._handleKeyStrokes(r);break;case"oneOrManyExtended":if(" "===r)return;t._keysPressed[r]="keydown"===e.type,t._handleKeyStrokes(r)}}}}_keyUpHandler(e){const t=this,i=(t.shadowRoot||t.getRootNode()).activeElement||document.activeElement;if(!t.editable||t.$.editInput!==i){if(t.filterable&&t.$.filterInput===i)return t._filterTimer&&clearTimeout(t._filterTimer),void(t._filterTimer=setTimeout((function(){const e=t.context;t.context=t,t._filterItems(),t.scrollTop=t.$.itemsContainer.scrollTop=0,t.scrollLeft=t.$.itemsContainer.scrollLeft=t._getScrollLeft(0),t.context=e}),300));if(t._focused){if(t._focusedItem&&t._focusedItem.hidden&&t._filteredItems.length>0){let e=t._filteredItems[0];e.grouped&&t._filteredItems.length>1&&(e=t._filteredItems[1]),t._focus(e),t._recycle()}e.stopPropagation(),e.preventDefault(),t.disabled||("Escape"===e.key&&Smart.ListBox.DragDrop.Dragging&&t._cancelDrag(),["Shift","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Control"," ","PageUp","PageDown"].indexOf(e.key)<0||(t._keysPressed[e.key]=!1))}}}_cancelDrag(){if(!Smart.ListBox.DragDrop.Dragging)return;Smart.ListBox.DragDrop.Feedback.parentNode&&Smart.ListBox.DragDrop.Feedback.parentNode.removeChild(Smart.ListBox.DragDrop.Feedback);const e=Smart.ListBox.DragDrop.Item,t=e.ownerListBox;if(t.$.fireEvent("dragCancel",{item:e,data:Smart.ListBox.DragDrop,container:t,previousContainer:t}),Smart.ListBox.DragDrop.Feedback=null,Smart.ListBox.DragDrop.DropDetails){let e=Smart.ListBox.DragDrop.DropDetails.item;e&&(e.$.removeClass("smart-list-item-line-feedback"),e.$.removeClass("smart-list-item-bottom-line-feedback"))}document.body.classList.remove("smart-dragging"),delete Smart.ListBox.DragDrop.DraggedFrom,Smart.ListBox.DragDrop.Dragging=!1,Smart.ListBox.DragDrop.Item=null,Smart.ListBox.DragDrop.DropDetails=null}_mouseWheelHandler(e){const t=this;if((t.computedHorizontalScrollBarVisibility||t.computedVerticalScrollBarVisibility)&&!t.disabled&&t.computedVerticalScrollBarVisibility){const i=t.scrollTop;if(0===i&&e.deltaY<0||i===t.scrollHeight&&e.deltaY>0)return;e.stopPropagation(),e.preventDefault(),t.scrollTo(i+t._getScrollCoefficient(e,t.offsetHeight))}}_pageDownKeyHandler(e){const t=this;if(0===e.length)return;let i,r=t._items[t.selectedIndexes[t.selectedIndexes.length-1]];if("checkBox"!==t.selectionMode&&"radioButton"!==t.selectionMode&&"zeroOrMany"!==t.selectionMode&&"oneOrMany"!==t.selectionMode&&"zeroOrOne"!==t.selectionMode||t._focusedItem&&(r=t._focusedItem),!r)return;const o=t._indexOf(r);let s=r.top+t.$.itemsContainer.offsetHeight-r.height;for(let t=o;t<e.length;t++)if(e[t].top>=s){i=e[t];break}i||(i=e[e.length-1]),"checkBox"===t.selectionMode||"radioButton"===t.selectionMode||"zeroOrMany"===t.selectionMode||"oneOrMany"===t.selectionMode||"zeroOrOne"===t.selectionMode?t._focus(i):i.selected||(t._keysPressed.Shift||t.clearSelection(),t.select(i),t._focus(i)),(i.height+i.top>t.$.itemsContainer.scrollTop+t.$.itemsContainer.offsetHeight||i.top<t.$.itemsContainer.scrollTop)&&(t.scrollTop=i.top-t.$.itemsContainer.offsetHeight+i.height)}_pageUpKeyHandler(e){const t=this;if(0===e.length)return;let i=t._items[t.selectedIndexes[t.selectedIndexes.length-1]];if("checkBox"!==t.selectionMode&&"radioButton"!==t.selectionMode&&"zeroOrMany"!==t.selectionMode&&"oneOrMany"!==t.selectionMode&&"zeroOrOne"!==t.selectionMode||t._focusedItem&&(i=t._focusedItem),!i)return;const r=i.top-t.$.itemsContainer.offsetHeight;let o;for(let s=t._indexOf(i);s>0;s--)if(e[s].top<=r){o=e[s];break}o||(o=e[0]),"checkBox"===t.selectionMode||"radioButton"===t.selectionMode||"zeroOrMany"===t.selectionMode||"oneOrMany"===t.selectionMode||"zeroOrOne"===t.selectionMode?t._focus(o):o.selected||(t._keysPressed.Shift||t.clearSelection(),t.select(o),t._focus(o)),t.scrollTop=o.top,0===t._indexOf(o)&&(t.scrollTop=0)}clearItems(){const e=this;e.clearSelection(),e.$.itemsInnerContainer.innerHTML="",e._items=[],delete e._focusedItem,e.$placeholder.removeClass("smart-hidden"),e.refresh()}_resizeHandler(e){this.refresh(e)}refresh(e){const t=this;if(!e&&!t._isUpdatingScrollBars&&t.isInitialized)return t._isUpdatingScrollBars=!0,t._initializeRecyclingItems(),t._refreshLayout(),void(t._isUpdatingScrollBars=!1);e&&e.target===t&&!t._isUpdatingScrollBars&&(t._isUpdatingScrollBars=!0,t._initializeRecyclingItems(),t._refreshLayout(),t._isUpdatingScrollBars=!1)}_indexOf(e){const t=this;if(!e)return-1;let i=t._items.indexOf(e);return-1===i&&(i=t._items.indexOf(t.getItem(e.value))),i}_incrementalSearch(){const e=this,t="radioButton"!==e.selectionMode&&"checkBox"!==e.selectionMode&&"zeroOrMany"!==e.selectionMode&&"oneOrMany"!==e.selectionMode&&"zeroOrOne"!==e.selectionMode;let i,r=0;switch(e.incrementalSearchMode){case"containsIgnoreCase":case"equalsIgnoreCase":case"startsWithIgnoreCase":case"endsWithIgnoreCase":i=e._incrementalSearchQuery.toLowerCase();break;default:i=e._incrementalSearchQuery}const o=function(i){i.grouped||i.readonly||(t?(e.selectedIndexes.length>0&&e.clearSelection(),e._focus(i),e.select(i)):e._focus(i),(i.height+i.top>e.$.itemsContainer.scrollTop+e.$.itemsContainer.offsetHeight||i.top<e.scrollTop)&&(e.scrollTop=i.top),0===e._indexOf(i)&&(e.scrollTop=0),e._indexOf(i)===e._items.length-1&&(e.scrollTop=e.scrollHeight))};0!==e._previousEntry.localeCompare(i)&&(e._incrementalSearchItems=e._queryItems(e._incrementalSearchQuery,e.incrementalSearchMode),delete e._itemPosition),e._previousEntry=i;const s=e._incrementalSearchItems.length;if(0!==s)if(1!==s)for(void 0!==e._itemPosition?e._itemPosition<s-1?r=e._itemPosition:(r=0,t?(e._incrementalSearchItems[e._itemPosition].selected=!1,e.selectedIndexes=[],e.selectedValues=[]):e._incrementalSearchItems[e._itemPosition]._focused=!1):t&&e.clearSelection();r<s;r++)if(e._incrementalSearchItems[r].selected&&t)e._incrementalSearchItems[r].selected=!1,e.selectedIndexes=[],e.selectedValues=[];else{if(t||!e._incrementalSearchItems[r]._focused)return o(e._incrementalSearchItems[r]),void(e._itemPosition=r);e._incrementalSearchItems[r]._focused=!1}else o(e._incrementalSearchItems[0])}_selectStartHandler(e){const t=this,i=(t.shadowRoot||t.getRootNode()).activeElement;t.$.filterInput!==i&&t.$.editInput!==i&&e.preventDefault()}_handleArrowKeys(e){const t=this,i="radioButton"!==t.selectionMode&&"checkBox"!==t.selectionMode&&"zeroOrMany"!==t.selectionMode&&"oneOrMany"!==t.selectionMode&&"zeroOrOne"!==t.selectionMode;if(t.disabled||t.readonly)return;let r;if(t._focusedItem&&!t._keysPressed.Shift)r=t._indexOf(t._focusedItem),t._focusedItem._focused=!1;else{if(0===t.selectedIndexes.length)return;r=t.selectedIndexes[t.selectedIndexes.length-1]}const o=e?t._getPreviousItem(r):t._getNextItem(r);t._focus(o),i&&(t._keysPressed.Shift?t.select(o):t._items[r]!==o&&(t.clearSelection(),t.select(o))),t.ensureVisible(o)}_refreshFilter(){const e=this;if(e.filterable)return e.$.filterInput.disabled=!(!e.disabled&&!e.displayLoadingIndicator),e.$filterInputContainer.removeClass("smart-hidden"),void e.$itemsContainer.addClass("filter");e.$.filterInput.disabled=!0,e.$filterInputContainer.addClass("smart-hidden"),e.$itemsContainer.removeClass("filter")}_setFocusable(){const e=this;e.disabled||e.unfocusable?e.removeAttribute("tabindex"):e.tabIndex=e.tabIndex>0?e.tabIndex:0}_setLoadingIndicatorVisibility(){const e=this;e.displayLoadingIndicator?e.$loadingIndicatorContainer.hasClass("smart-visibility-hidden")?e.$loadingIndicatorContainer.removeClass("smart-visibility-hidden"):e.$loadingIndicatorContainer.removeClass("smart-hidden"):e._areCSSVarsSupported?e.$loadingIndicatorContainer.addClass("smart-hidden"):e.$loadingIndicatorContainer.addClass("smart-visibility-hidden")}_refreshLayout(){const e=this,t=e._filteredItems||e._items;if(e.__scrollHeight=null,e.__scrollWidth=null,e._height=null,e._scrollView||(e._scrollView=new Smart.Utilities.Scroll(e,e.$.horizontalScrollBar,e.$.verticalScrollBar)),e.$itemsContainer.removeClass("hscroll"),e.$itemsContainer.removeClass("vscroll"),!t||null===t||0===t.length)return e.scrollWidth=0,e.scrollHeight=0,e.$filterInputContainer.removeClass("vscroll"),e.$placeholder.removeClass("smart-hidden"),e.isVirtualized&&e._recycle(),void(e.$.itemsInnerContainer.style.width="");e.$placeholder.addClass("smart-hidden");const i=2*(parseInt(getComputedStyle(e.$.itemsContainer).getPropertyValue("--smart-list-item-horizontal-offset"))||0);let r=e._scrollWidth-e.$.itemsContainer.offsetWidth-i,o=e._scrollHeight;if(e._refreshHorizontalScrollBarVisibility(r),e._refreshVerticalScrollBarVisibility(o),e.$.itemsInnerContainer.style.width="","hidden"===e.horizontalScrollBarVisibility?e.$.itemsInnerContainer.style.width=e.$.itemsContainer.offsetWidth-i:e.$.itemsInnerContainer.style.width=Math.max(e.$.itemsContainer.offsetWidth-i,-i+e.__scrollWidth)+"px",e.computedVerticalScrollBarVisibility)return r=e._scrollWidth-e.$.itemsContainer.offsetWidth-i,e._refreshHorizontalScrollBarVisibility(r),"hidden"!==e.horizontalScrollBarVisibility&&(e.$.itemsInnerContainer.style.width="",e.$.itemsInnerContainer.style.width=Math.max(e.$.itemsContainer.offsetWidth-i,-i+e.__scrollWidth)+"px"),e.computedHorizontalScrollBarVisibility&&(("visible"!==e.horizontalScrollBarVisibility||0!==e.scrollWidth||"visible"===e.horizontalScrollBarVisibility)&&(e.__scrollHeight+=e._scrollView.hScrollBar.offsetHeight),e.scrollHeight=e.__scrollHeight,e._scrollView.hScrollBar.$.hasClass("bottom-corner")&&e._scrollView.hScrollBar.refresh()),void(e.isVirtualized&&e._recycle());r=e._scrollWidth-e.$.itemsContainer.offsetWidth-i,e._refreshHorizontalScrollBarVisibility(r),e.computedHorizontalScrollBarVisibility&&(e.scrollHeight=e._scrollHeight,e._refreshVerticalScrollBarVisibility(e.scrollHeight),e.computedVerticalScrollBarVisibility&&(r=e._scrollWidth-e.$.itemsContainer.offsetWidth-e._scrollView.vScrollBar.offsetWidth,e._refreshHorizontalScrollBarVisibility(r)),e._scrollView.vScrollBar.$.hasClass("bottom-corner")&&e._scrollView.vScrollBar.refresh(),e._scrollView.hScrollBar.$.hasClass("bottom-corner")&&e._scrollView.hScrollBar.refresh()),e.isVirtualized&&e._recycle();const s=/Trident|Edge/.test(navigator.userAgent);!e.isRefreshing&&s&&setTimeout((function(){e.isRefreshing=!0,e._refreshLayout(),e.isRefreshing=!1}),50)}_styleChangedHandler(){this._refreshLayout()}_swipeLeftHandler(){}_swipeRightHandler(){}_refreshHorizontalScrollBarVisibility(e){const t=this;t.scrollWidth=e,t.computedHorizontalScrollBarVisibility?(t.scrollLeft=t._getScrollLeft(t.$.itemsContainer.scrollLeft,e),t.$itemsContainer.addClass("hscroll")):t.$itemsContainer.removeClass("hscroll")}_refreshVerticalScrollBarVisibility(e){const t=this;t.scrollHeight=e,t.computedVerticalScrollBarVisibility?(t.$itemsContainer.addClass("vscroll"),t.$filterInputContainer.addClass("vscroll")):(t.$itemsContainer.removeClass("vscroll"),t.$filterInputContainer.removeClass("vscroll"))}_validateTemplate(e,t){if(null===t||!t)return;const i=this;return"content"in document.createElement("template")?null!==(t=document.getElementById(t))&&"content"in t?t:(i.error(i.localize("invalidTemplate",{elementType:i.nodeName.toLowerCase(),property:e})),void(i[e]=null)):(i.error(i.localize("htmlTemplateNotSuported",{elementType:i.nodeName.toLowerCase()})),void(i[e]=null))}_getItemIndexByPosition(e){const t=this;return(i=>{let r=0,o=i.length-1;if(e<=0)return 0;if(i[i.length-1].top<=e)return i.length-1;for(;;){const s=Math.floor((r+o)/2),n=i[s];if(t._isItemInPosition(n,e))return s;n.top<e?r=s+1:n.top>e&&(o=s-1)}})(t.filterable&&t.$.filterInput.value.length>0?t._filteredItems:t._items)}_isItemInPosition(e,t){const i=e.top,r=e.top+e.height;return i<=t&&r>t}get isVirtualized(){const e=this;return e.virtualized&&e.dataSource&&e.dataSource.length>0}_recycle(){const e=this;if(!e._recyclingItems)return;let t=e._height;e._height||(t=e._height=e.$.itemsContainer.offsetHeight);let i=0;const r=e.scrollTop,o=e._getItemIndexByPosition(r),s=e.filterable&&e.$.filterInput.value.length>0?e._filteredItems:e._items,n=s[o];let l=n?n.top:0;if(e.$.itemsInnerContainer.style.left=-e.scrollLeft+"px",e.$.itemsInnerContainer.style.top=-r+l+"px",e.isUpdating++,o>=0){const n=s.length;for(let a=o;a<n;a++){const o=s[a];if(0!==o.height){if(!(l+o.height>=r&&l<=r+t))break;{const t=e._recyclingItems[i++];if(!t)break;t.setAttribute("aria-setsize",n),t.setAttribute("aria-posinset",a),t.context=document,t.dataItem=o,t.label=o.label,t.value=o.value,t.selected=o.selected,t._focused=o._focused,t.hidden=o.hidden,t.grouped=o.grouped,t.readonly=o.readonly,t.style.height=o.height+"px",e._alternateItem(t),o.title?t.title=o.title:t.title="",o.grouped?t.displayMode="plain":t.displayMode=o.displayMode,e.scrollWidth>0&&(t.style.width=e.$.itemsInnerContainer.offsetWidth+e.scrollWidth+"px"),e.itemTemplate&&e._handleItemTemplate(e.itemTemplate)&&e._applyTemplate(t,!1)}l+=o.height}}}if(i<e._recyclingItems.length)for(let t=i;t<e._recyclingItems.length;t++){const t=e._recyclingItems[i++],r=t.context;t.context=document,t.hidden=!0,t.context=r}e.isUpdating--}_verticalScrollbarHandler(e){const t=this,i=e.detail.value;e&&e.stopPropagation&&e.stopPropagation(),t.isVirtualized?t._recycle():t.$.itemsContainer.scrollTop=i,t._updateTopVisibleIndex(),e.context.max!==e.context.value?e.context.min===e.context.value&&t.$.fireEvent("scrollTopReached"):t.$.fireEvent("scrollBottomReached")}_applyAriaSelected(){const e=this,t=e.isVirtualized?e._recyclingItems:e._items,i=e.selectionMode;for(let e=0;e<t.length;e++){const r=t[e];r.selected?r.setAttribute("aria-selected",!0):r.readonly||r.disabled||-1===["oneOrManyExtended","zeroOrMany","oneOrMany","checkBox"].indexOf(i)?r.removeAttribute("aria-selected"):r.setAttribute("aria-selected",!1)}}});
|
|
842
842
|
|
|
843
843
|
/***/ }),
|
|
844
844
|
|
|
@@ -990,7 +990,7 @@ var __webpack_exports__ = {};
|
|
|
990
990
|
/* harmony import */ var _smart_editor_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(7855);
|
|
991
991
|
/* harmony import */ var _smart_editor_js__WEBPACK_IMPORTED_MODULE_17___default = /*#__PURE__*/__webpack_require__.n(_smart_editor_js__WEBPACK_IMPORTED_MODULE_17__);
|
|
992
992
|
|
|
993
|
-
/* Smart UI v14.
|
|
993
|
+
/* Smart UI v14.3.0 (2022-09-27)
|
|
994
994
|
Copyright (c) 2011-2022 jQWidgets.
|
|
995
995
|
License: https://htmlelements.com/license/ */ //
|
|
996
996
|
|