@dialpad/dialtone 9.174.0 → 9.175.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.
@@ -1 +1 @@
1
- {"version":3,"file":"combobox-multi-select.js","sources":["../../../components/combobox_multi_select/combobox_multi_select.vue"],"sourcesContent":["<!-- eslint-disable vue/no-static-inline-styles -->\n<template>\n <dt-combobox-with-popover\n ref=\"comboboxWithPopover\"\n :label=\"label\"\n :show-list=\"showList\"\n :max-height=\"listMaxHeight\"\n :max-width=\"listMaxWidth\"\n :popover-offset=\"popoverOffset\"\n :has-suggestion-list=\"hasSuggestionList\"\n content-width=\"anchor\"\n :append-to=\"appendTo\"\n :transition=\"transition\"\n v-bind=\"extractNonListeners($attrs)\"\n @select=\"onComboboxSelect\"\n @highlight=\"comboboxHighlight\"\n >\n <template #input=\"{ onInput }\">\n <span\n ref=\"inputSlotWrapper\"\n class=\"d-recipe-combobox-multi-select__input-wrapper\"\n @focusin=\"handleInputFocusIn\"\n @focusout=\"handleInputFocusOut\"\n >\n <span\n ref=\"chipsWrapper\"\n :class=\"['d-recipe-combobox-multi-select__chip-wrapper', chipWrapperClass]\"\n >\n <dt-chip\n v-for=\"item in selectedItems\"\n ref=\"chips\"\n :key=\"item\"\n :label-class=\"['d-chip__label']\"\n :class=\"[\n 'd-recipe-combobox-multi-select__chip',\n { 'd-recipe-combobox-multi-select__chip--truncate': !!chipMaxWidth },\n ]\"\n :style=\"{ maxWidth: chipMaxWidth }\"\n :size=\"CHIP_SIZES[size]\"\n :disabled=\"disabled\"\n v-on=\"chipListeners\"\n @keydown.backspace=\"onChipRemove(item)\"\n @close=\"onChipRemove(item)\"\n >\n {{ item }}\n </dt-chip>\n </span>\n\n <dt-input\n ref=\"input\"\n v-model=\"value\"\n class=\"d-recipe-combobox-multi-select__input\"\n :input-class=\"[\n inputClass, {\n 'd-recipe-combobox-multi-select__input--hidden': hideInputText,\n }]\"\n :input-wrapper-class=\"inputWrapperClass\"\n :disabled=\"disabled\"\n :aria-label=\"label\"\n :label=\"labelVisible ? label : ''\"\n :description=\"description\"\n :placeholder=\"inputPlaceHolder\"\n :show-messages=\"showInputMessages\"\n :messages=\"inputMessages\"\n :size=\"size\"\n v-bind=\"inputListeners\"\n @input=\"onInput\"\n />\n\n <dt-validation-messages\n :validation-messages=\"maxSelectedMessage\"\n :show-messages=\"showValidationMessages\"\n />\n </span>\n </template>\n\n <!-- @slot slot for popover header -->\n <template\n v-if=\"hasSlotContent($slots.header)\"\n #header\n >\n <div ref=\"header\">\n <slot name=\"header\" />\n </div>\n </template>\n\n <!-- @slot slot for popover list -->\n <template #list>\n <div\n ref=\"list\"\n class=\"d-recipe-combobox-multi-select__list\"\n @mousedown.prevent\n >\n <slot\n v-if=\"!loading\"\n name=\"list\"\n />\n <div\n v-else\n class=\"d-recipe-combobox-multi-select__list--loading\"\n >\n {{ loadingMessage }}\n </div>\n </div>\n </template>\n\n <!-- @slot slot for popover footer -->\n <template\n v-if=\"hasSlotContent($slots.footer)\"\n #footer\n >\n <div ref=\"footer\">\n <slot name=\"footer\" />\n </div>\n </template>\n </dt-combobox-with-popover>\n</template>\n\n<script>\n/* eslint-disable max-lines */\nimport DtComboboxWithPopover from '@/components/combobox_with_popover/combobox_with_popover.vue';\nimport DtInput from '@/components/input/input.vue';\nimport DtChip from '@/components/chip/chip.vue';\nimport DtValidationMessages from '@/components/validation_messages/validation_messages.vue';\nimport { validationMessageValidator } from '@/common/validators';\nimport { extractVueListeners, extractNonListeners, hasSlotContent, returnFirstEl } from '@/common/utils';\nimport {\n POPOVER_APPEND_TO_VALUES,\n} from '@/components/popover/popover_constants';\nimport {\n MULTI_SELECT_SIZES,\n CHIP_SIZES,\n CHIP_TOP_POSITION,\n} from './combobox_multi_select_constants';\n\nexport default {\n compatConfig: { MODE: 3 },\n name: 'DtComboboxMultiSelect',\n\n components: {\n DtComboboxWithPopover,\n DtInput,\n DtChip,\n DtValidationMessages,\n },\n\n inheritAttrs: false,\n\n props: {\n /**\n * String to use for the input label.\n */\n label: {\n type: String,\n required: true,\n },\n\n /**\n * Determines visibility of input label.\n * @values true, false\n */\n labelVisible: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Description for the input\n */\n description: {\n type: String,\n default: '',\n },\n\n /**\n * Input placeholder\n */\n placeholder: {\n type: String,\n default: 'Select one or start typing',\n },\n\n /**\n * Input validation messages\n */\n inputMessages: {\n type: Array,\n default: () => [],\n validator: inputMessages => {\n return validationMessageValidator(inputMessages);\n },\n },\n\n /**\n * Show input validation message\n */\n showInputMessages: {\n type: Boolean,\n default: true,\n },\n\n // @TODO: https://dialpad.atlassian.net/browse/DP-52324\n // type: {\n // type: String,\n // values: ['input', 'select'],\n // default: 'select',\n // },\n\n /**\n * Determines if the list is loading\n */\n loading: {\n type: Boolean,\n default: false,\n },\n\n /**\n * The message when the list is loading\n */\n loadingMessage: {\n type: String,\n default: 'loading...',\n },\n\n /**\n * Determines when to show the list element and also controls the aria-expanded attribute.\n * Leaving this null will have the combobox trigger on input focus by default.\n * If you set this value, the default trigger behavior will be disabled and you can\n * control it as you need.\n */\n showList: {\n type: Boolean,\n default: null,\n },\n\n /**\n * Determines maximum height for the popover before overflow.\n * Possible units rem|px|em\n */\n listMaxHeight: {\n type: String,\n default: '300px',\n },\n\n /**\n * The selected items\n */\n selectedItems: {\n type: Array,\n default: function () { return []; },\n },\n\n /**\n * Would be the maximum number of selections you can make. 0 is unlimited\n */\n maxSelected: {\n type: Number,\n default: 0,\n },\n\n /**\n * Max select message when the max selections is exceeded with the structure:\n * `[{\"message\": string, \"type\": VALIDATION_MESSAGE_TYPES }]`\n */\n maxSelectedMessage: {\n type: Array,\n default: function () { return []; },\n },\n\n /**\n * Displays the list when the combobox is focused, before the user has typed anything.\n * When this is enabled the list will not close after selection.\n */\n hasSuggestionList: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Size of the chip, one of `xs`, `sm`, `md`\n */\n size: {\n type: String,\n default: 'md',\n validator: (t) => Object.values(MULTI_SELECT_SIZES).includes(t),\n },\n\n /**\n * Sets the element to which the popover is going to append to.\n * 'body' will append to the nearest body (supports shadow DOM).\n * @values 'body', 'parent', HTMLElement,\n */\n appendTo: {\n type: [HTMLElement, String],\n default: 'body',\n validator: appendTo => {\n return POPOVER_APPEND_TO_VALUES.includes(appendTo) ||\n (appendTo instanceof HTMLElement);\n },\n },\n\n /**\n * Named transition when the content display is toggled.\n * @see DtLazyShow\n */\n transition: {\n type: String,\n default: 'fade',\n },\n\n /**\n * Determines whether the combobox should collapse to a single when losing focus.\n * @type {boolean}\n */\n collapseOnFocusOut: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Determines maximum width for the popover before overflow.\n * Possible units rem|px|em\n */\n listMaxWidth: {\n type: String,\n default: '',\n },\n\n /**\n * Amount of reserved space (in px) on the right side of the input\n * before the chips and the input caret jump to the next line.\n * default is 64\n */\n reservedRightSpace: {\n type: Number,\n default: 64,\n },\n\n /**\n * Determines the maximum width of a single chip. If the text within this chip exceeds the value\n * it will be truncated with ellipses.\n * Possible units rem|px|em\n */\n chipMaxWidth: {\n type: String,\n default: '',\n },\n\n /**\n * Additional class name for the input element.\n * Can accept String, Object, and Array, i.e. has the\n * same API as Vue's built-in handling of the class attribute.\n */\n inputClass: {\n type: [String, Object, Array],\n default: '',\n },\n\n /**\n * Additional class name for the input wrapper element.\n * Can accept all of String, Object, and Array, i.e. has the\n * same api as Vue's built-in handling of the class attribute.\n */\n inputWrapperClass: {\n type: [String, Object, Array],\n default: '',\n },\n\n /**\n * When true, disables the underlying input.\n */\n disabled: {\n type: Boolean,\n default: false,\n },\n },\n\n emits: [\n /**\n * Native input event\n *\n * @event input\n * @type {String }\n */\n 'input',\n\n /**\n * Event fired when item selected\n *\n * @event select\n * @type {Number}\n */\n 'select',\n\n /**\n * Event fired when item removed\n *\n * @event remove\n * @type {String}\n */\n 'remove',\n\n /**\n * Event fired when max selected items limit is reached\n *\n * @event max-selected\n * @type {Object}\n */\n 'max-selected',\n\n /**\n * Native keyup event\n *\n * @event keyup\n * @type {KeyboardEvent}\n */\n 'keyup',\n\n /**\n * Native keydown event\n *\n * @event keydown\n * @type {KeyboardEvent}\n */\n 'keydown',\n\n /**\n * Event fired when combobox item is highlighted\n *\n * @event combobox-highlight\n * @type {Object}\n */\n 'combobox-highlight',\n ],\n\n data () {\n return {\n value: '',\n popoverOffset: [0, 4],\n showValidationMessages: false,\n resizeWindowObserver: null,\n initialInputHeight: null,\n CHIP_SIZES,\n hasSlotContent,\n inputFocused: false,\n hideInputText: false,\n };\n },\n\n computed: {\n inputPlaceHolder () {\n return this.selectedItems?.length > 0 ? '' : this.placeholder;\n },\n\n chipListeners () {\n return {\n keydown: event => {\n this.onChipKeyDown(event);\n this.$emit('keydown', event);\n },\n };\n },\n\n inputListeners () {\n return {\n ...extractVueListeners(this.$attrs),\n onInput: event => {\n this.$emit('input', event);\n if (this.hasSuggestionList) {\n this.showComboboxList();\n }\n },\n\n onKeydown: event => {\n this.onInputKeyDown(event);\n },\n\n onKeyup: event => {\n this.$emit('keyup', event);\n },\n\n onClick: () => {\n if (this.hasSuggestionList) {\n this.showComboboxList();\n }\n },\n };\n },\n\n chipWrapperClass () {\n return {\n [`d-recipe-combobox-multi-select__chip-wrapper-${this.size}--collapsed`]: !this.inputFocused && this.collapseOnFocusOut,\n };\n },\n },\n\n watch: {\n selectedItems: {\n deep: true,\n handler: async function () {\n await this.initSelectedItems();\n },\n },\n\n chipMaxWidth: {\n async handler () {\n await this.initSelectedItems();\n },\n },\n\n async label () {\n await this.$nextTick();\n // Adjust the chips position if label changed\n this.setChipsTopPosition();\n },\n\n async description () {\n await this.$nextTick();\n // Adjust the chips position if description changed\n this.setChipsTopPosition();\n },\n\n size: {\n async handler () {\n await this.$nextTick();\n const input = this.getInput();\n this.revertInputPadding(input);\n this.initialInputHeight = input.getBoundingClientRect().height;\n this.setInputPadding();\n this.setChipsTopPosition();\n },\n },\n },\n\n async mounted () {\n this.setInitialInputHeight();\n // Recalculate chip position and input padding when resizing window\n this.resizeWindowObserver = new ResizeObserver(async () => {\n this.setChipsTopPosition();\n this.setInputPadding();\n });\n this.resizeWindowObserver.observe(document.body);\n\n await this.initSelectedItems();\n },\n\n beforeUnmount () {\n this.resizeWindowObserver?.unobserve(document.body);\n },\n\n methods: {\n extractNonListeners,\n comboboxHighlight (highlightIndex) {\n this.$emit('combobox-highlight', highlightIndex);\n },\n\n async initSelectedItems () {\n await this.$nextTick();\n this.setInputPadding();\n this.setChipsTopPosition();\n this.setInputMinWidth();\n this.checkMaxSelected();\n },\n\n onChipRemove (item) {\n this.$emit('remove', item);\n this.$refs.input?.focus();\n },\n\n onComboboxSelect (i) {\n if (this.loading) return;\n this.value = '';\n this.$emit('select', i);\n },\n\n showComboboxList () {\n if (this.showList != null) { return; }\n this.$refs.comboboxWithPopover?.showComboboxList();\n },\n\n closeComboboxList () {\n if (this.showList != null) { return; }\n this.$refs.comboboxWithPopover?.closeComboboxList();\n },\n\n getChips () {\n if (!this.selectedItems.length || !this.$refs.chips) return null;\n\n // use the order from selectedItems to not rely on DOM order which may be stale\n const chips = this.selectedItems.map(item => {\n return this.$refs.chips.find(chip => {\n const chipLabel = returnFirstEl(chip.$el)?.querySelector('.d-chip__label')?.textContent?.trim();\n return chipLabel === item;\n });\n });\n return chips.filter(Boolean).map(chip => returnFirstEl(chip.$el));\n },\n\n getChipButtons () {\n const chips = this.getChips();\n return chips && chips.map(chip => returnFirstEl(chip).querySelector('button'));\n },\n\n getLastChipButton () {\n const chipButtons = this.getChipButtons();\n return chipButtons && chipButtons[chipButtons.length - 1];\n },\n\n getLastChip () {\n const chips = this.getChips();\n return chips && chips[chips.length - 1];\n },\n\n getFirstChip () {\n const chips = this.getChips();\n return chips && chips[0];\n },\n\n getInput () {\n return this.$refs.input?.$refs.input;\n },\n\n onChipKeyDown (event) {\n const key = event.code?.toLowerCase();\n if (key === 'arrowleft') {\n // Move to the previous chip\n this.navigateBetweenChips(event.target, true);\n } else if (key === 'arrowright') {\n if (event.target.id === this.getLastChipButton().id) {\n // Move to the input if it's the last chip\n this.moveFromChipToInput();\n } else {\n // Move to the next chip\n this.navigateBetweenChips(event.target, false);\n }\n }\n },\n\n onInputKeyDown (event) {\n const key = event.code?.toLowerCase();\n // If the cursor is at the start of the text,\n // press 'backspace' or 'left' focuses the last chip\n if (this.selectedItems.length > 0 && event.target.selectionStart === 0) {\n // if there is selected text, do not focus the last chip\n if (event.target.selectionEnd !== event.target.selectionStart) {\n return;\n }\n if (key === 'backspace' || key === 'arrowleft') {\n this.moveFromInputToChip();\n }\n }\n },\n\n moveFromInputToChip () {\n this.getLastChipButton().focus();\n this.$refs.input?.blur();\n this.closeComboboxList();\n },\n\n moveFromChipToInput () {\n this.getLastChipButton().blur();\n this.$refs.input?.focus();\n this.showComboboxList();\n },\n\n navigateBetweenChips (target, toLeft) {\n const from = this.getChipButtons().indexOf(target);\n const to = toLeft ? from - 1 : from + 1;\n if (to < 0 || to >= this.$refs.chips?.length) {\n return;\n }\n this.getChipButtons()[from].blur();\n this.getChipButtons()[to].focus();\n this.closeComboboxList();\n },\n\n setChipsTopPosition () {\n // To place the chips in the input box\n // The chip \"top\" position should be the same line as the input box\n const input = this.getInput();\n if (!input) return;\n const inputSlotWrapper = this.$refs.inputSlotWrapper;\n const top = input.getBoundingClientRect().top -\n inputSlotWrapper.getBoundingClientRect().top;\n const chipsWrapper = this.$refs.chipsWrapper;\n chipsWrapper.style.top = (top - CHIP_TOP_POSITION[this.size]) + 'px';\n },\n\n setInputPadding () {\n const lastChip = this.getLastChip();\n const input = this.getInput();\n const chipsWrapper = this.$refs.chipsWrapper;\n if (!input) return;\n this.revertInputPadding(input);\n this.popoverOffset = [0, 4];\n if (!lastChip) return;\n // Avoid adding extra padding when the input is not focused if collapseOnFocusOut is true\n // This ensures the input returns to its original state when resizing\n if (this.collapseOnFocusOut && !this.inputFocused) return;\n\n // Get the position of the last chip\n // The input cursor should be the same \"top\" as that chip and next besides it\n const left = lastChip.offsetLeft + this.getFullWidth(lastChip);\n const spaceLeft = input.getBoundingClientRect().width - left;\n // input.style.paddingLeft = left + 'px';\n\n if (spaceLeft > this.reservedRightSpace) {\n input.style.paddingLeft = left + 'px';\n } else {\n input.style.paddingLeft = '4px';\n }\n\n // Get the chip wrapper height minus the 4px padding\n const chipsWrapperHeight = chipsWrapper.getBoundingClientRect().height - 4;\n const lastChipHeight = lastChip.getBoundingClientRect().height - 4;\n\n // Get lastChip offsetTop plus 2px of the input padding.\n const top = spaceLeft > this.reservedRightSpace\n ? lastChip.offsetTop + 2\n : (chipsWrapperHeight + lastChipHeight - 9);\n\n input.style.paddingTop = `${top}px`;\n },\n\n revertInputPadding (input) {\n input.style.paddingLeft = '';\n input.style.paddingTop = '';\n input.style.paddingBottom = '';\n },\n\n getFullWidth (el) {\n const styles = window.getComputedStyle(el);\n return el.offsetWidth + parseInt(styles.marginLeft) + parseInt(styles.marginRight);\n },\n\n setInputMinWidth () {\n // Ensure the width of the input is \"slightly bigger\" than the width of a single chip\n const firstChip = this.getFirstChip();\n const input = this.getInput();\n if (!input) return;\n if (firstChip) {\n // Add 4px buffer for typing room\n input.style.minWidth = (this.getFullWidth(firstChip) + 4) + 'px';\n } else {\n input.style.minWidth = '';\n }\n },\n\n checkMaxSelected () {\n if (this.maxSelected === 0) return;\n if (this.selectedItems.length > this.maxSelected) {\n this.showValidationMessages = true;\n this.$emit('max-selected');\n } else {\n this.showValidationMessages = false;\n }\n },\n\n setInitialInputHeight () {\n const input = this.getInput();\n if (!input) return;\n this.initialInputHeight = input.getBoundingClientRect().height;\n },\n\n async handleInputFocusIn () {\n this.inputFocused = true;\n if (this.collapseOnFocusOut) {\n this.hideInputText = false;\n await this.$nextTick();\n this.setInputPadding();\n }\n },\n\n async handleInputFocusOut () {\n this.inputFocused = false;\n if (this.collapseOnFocusOut) {\n this.hideInputText = true;\n const input = this.getInput();\n if (!input) return;\n // Hide the input text when is not on first line\n if (!input.style.paddingTop) {\n return;\n }\n this.revertInputPadding(input);\n }\n },\n },\n};\n</script>\n"],"names":["_sfc_main","DtComboboxWithPopover","DtInput","DtChip","DtValidationMessages","inputMessages","validationMessageValidator","MULTI_SELECT_SIZES","appendTo","POPOVER_APPEND_TO_VALUES","CHIP_SIZES","hasSlotContent","_a","event","extractVueListeners","input","extractNonListeners","highlightIndex","item","i","chip","_c","_b","returnFirstEl","chips","chipButtons","key","target","toLeft","from","to","inputSlotWrapper","top","chipsWrapper","CHIP_TOP_POSITION","lastChip","left","spaceLeft","chipsWrapperHeight","lastChipHeight","el","styles","firstChip","_hoisted_1","_hoisted_3","_openBlock","_createBlock","_component_dt_combobox_with_popover","_mergeProps","$props","$data","$options","_ctx","_withCtx","onInput","_createElementVNode","args","_createElementBlock","_Fragment","_renderList","_component_dt_chip","_toHandlers","_withKeys","$event","_createVNode","_component_dt_input","_component_dt_validation_messages","_hoisted_2","_toDisplayString","_renderSlot"],"mappings":";;;;;;;;;;AAuIA,MAAKA,IAAU;AAAA,EACb,cAAc,EAAE,MAAM;EACtB,MAAM;AAAA,EAEN,YAAY;AAAA,IACV,uBAAAC;AAAA,IACA,SAAAC;AAAA,IACA,QAAAC;AAAA,IACA,sBAAAC;AAAA;EAGF,cAAc;AAAA,EAEd,OAAO;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AAAA,MACL,MAAM;AAAA,MACN,UAAU;AAAA;;;;;IAOZ,cAAc;AAAA,MACZ,MAAM;AAAA,MACN,SAAS;AAAA;;;;IAMX,aAAa;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA;;;;IAMX,aAAa;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA;;;;IAMX,eAAe;AAAA,MACb,MAAM;AAAA,MACN,SAAS,MAAM,CAAA;AAAA,MACf,WAAW,CAAAC,MACFC,EAA2BD,CAAa;AAAA;;;;IAOnD,mBAAmB;AAAA,MACjB,MAAM;AAAA,MACN,SAAS;AAAA;;;;;;;;;;IAaX,SAAS;AAAA,MACP,MAAM;AA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;;;;;;"}
1
+ {"version":3,"file":"combobox-multi-select.js","sources":["../../../components/combobox_multi_select/combobox_multi_select.vue"],"sourcesContent":["<!-- eslint-disable vue/no-static-inline-styles -->\n<template>\n <dt-combobox-with-popover\n ref=\"comboboxWithPopover\"\n :label=\"label\"\n :show-list=\"showList\"\n :max-height=\"listMaxHeight\"\n :max-width=\"listMaxWidth\"\n :popover-offset=\"popoverOffset\"\n :has-suggestion-list=\"hasSuggestionList\"\n content-width=\"anchor\"\n :append-to=\"appendTo\"\n :transition=\"transition\"\n v-bind=\"extractNonListeners($attrs)\"\n @select=\"onComboboxSelect\"\n @highlight=\"comboboxHighlight\"\n >\n <template #input=\"{ onInput }\">\n <span\n ref=\"inputSlotWrapper\"\n class=\"d-recipe-combobox-multi-select__input-wrapper\"\n @focusin=\"handleInputFocusIn\"\n @focusout=\"handleInputFocusOut\"\n >\n <span\n ref=\"chipsWrapper\"\n :class=\"['d-recipe-combobox-multi-select__chip-wrapper', chipWrapperClass]\"\n >\n <dt-chip\n v-for=\"(item, index) in selectedItems\"\n ref=\"chips\"\n :key=\"`${index}-${item}`\"\n :label-class=\"['d-chip__label']\"\n :class=\"[\n 'd-recipe-combobox-multi-select__chip',\n { 'd-recipe-combobox-multi-select__chip--truncate': !!chipMaxWidth },\n ]\"\n :style=\"{ maxWidth: chipMaxWidth }\"\n :size=\"CHIP_SIZES[size]\"\n :disabled=\"disabled\"\n v-on=\"chipListeners\"\n @keydown.backspace=\"onChipRemove(item)\"\n @close=\"onChipRemove(item)\"\n >\n {{ item }}\n </dt-chip>\n </span>\n\n <dt-input\n ref=\"input\"\n v-model=\"value\"\n class=\"d-recipe-combobox-multi-select__input\"\n :input-class=\"[\n inputClass, {\n 'd-recipe-combobox-multi-select__input--hidden': hideInputText,\n }]\"\n :input-wrapper-class=\"inputWrapperClass\"\n :disabled=\"disabled\"\n :aria-label=\"label\"\n :label=\"labelVisible ? label : ''\"\n :description=\"description\"\n :placeholder=\"inputPlaceHolder\"\n :show-messages=\"showInputMessages\"\n :messages=\"inputMessages\"\n :size=\"size\"\n v-bind=\"inputListeners\"\n @input=\"onInput\"\n />\n\n <dt-validation-messages\n :validation-messages=\"maxSelectedMessage\"\n :show-messages=\"showValidationMessages\"\n />\n </span>\n </template>\n\n <!-- @slot slot for popover header -->\n <template\n v-if=\"hasSlotContent($slots.header)\"\n #header\n >\n <div ref=\"header\">\n <slot name=\"header\" />\n </div>\n </template>\n\n <!-- @slot slot for popover list -->\n <template #list>\n <div\n ref=\"list\"\n class=\"d-recipe-combobox-multi-select__list\"\n @mousedown.prevent\n >\n <slot\n v-if=\"!loading\"\n name=\"list\"\n />\n <div\n v-else\n class=\"d-recipe-combobox-multi-select__list--loading\"\n >\n {{ loadingMessage }}\n </div>\n </div>\n </template>\n\n <!-- @slot slot for popover footer -->\n <template\n v-if=\"hasSlotContent($slots.footer)\"\n #footer\n >\n <div ref=\"footer\">\n <slot name=\"footer\" />\n </div>\n </template>\n </dt-combobox-with-popover>\n</template>\n\n<script>\n/* eslint-disable max-lines */\nimport DtComboboxWithPopover from '@/components/combobox_with_popover/combobox_with_popover.vue';\nimport DtInput from '@/components/input/input.vue';\nimport DtChip from '@/components/chip/chip.vue';\nimport DtValidationMessages from '@/components/validation_messages/validation_messages.vue';\nimport { validationMessageValidator } from '@/common/validators';\nimport { extractVueListeners, extractNonListeners, hasSlotContent, returnFirstEl } from '@/common/utils';\nimport {\n POPOVER_APPEND_TO_VALUES,\n} from '@/components/popover/popover_constants';\nimport {\n MULTI_SELECT_SIZES,\n CHIP_SIZES,\n CHIP_TOP_POSITION,\n} from './combobox_multi_select_constants';\n\nexport default {\n compatConfig: { MODE: 3 },\n name: 'DtComboboxMultiSelect',\n\n components: {\n DtComboboxWithPopover,\n DtInput,\n DtChip,\n DtValidationMessages,\n },\n\n inheritAttrs: false,\n\n props: {\n /**\n * String to use for the input label.\n */\n label: {\n type: String,\n required: true,\n },\n\n /**\n * Determines visibility of input label.\n * @values true, false\n */\n labelVisible: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Description for the input\n */\n description: {\n type: String,\n default: '',\n },\n\n /**\n * Input placeholder\n */\n placeholder: {\n type: String,\n default: 'Select one or start typing',\n },\n\n /**\n * Input validation messages\n */\n inputMessages: {\n type: Array,\n default: () => [],\n validator: inputMessages => {\n return validationMessageValidator(inputMessages);\n },\n },\n\n /**\n * Show input validation message\n */\n showInputMessages: {\n type: Boolean,\n default: true,\n },\n\n // @TODO: https://dialpad.atlassian.net/browse/DP-52324\n // type: {\n // type: String,\n // values: ['input', 'select'],\n // default: 'select',\n // },\n\n /**\n * Determines if the list is loading\n */\n loading: {\n type: Boolean,\n default: false,\n },\n\n /**\n * The message when the list is loading\n */\n loadingMessage: {\n type: String,\n default: 'loading...',\n },\n\n /**\n * Determines when to show the list element and also controls the aria-expanded attribute.\n * Leaving this null will have the combobox trigger on input focus by default.\n * If you set this value, the default trigger behavior will be disabled and you can\n * control it as you need.\n */\n showList: {\n type: Boolean,\n default: null,\n },\n\n /**\n * Determines maximum height for the popover before overflow.\n * Possible units rem|px|em\n */\n listMaxHeight: {\n type: String,\n default: '300px',\n },\n\n /**\n * The selected items\n */\n selectedItems: {\n type: Array,\n default: function () { return []; },\n },\n\n /**\n * Would be the maximum number of selections you can make. 0 is unlimited\n */\n maxSelected: {\n type: Number,\n default: 0,\n },\n\n /**\n * Max select message when the max selections is exceeded with the structure:\n * `[{\"message\": string, \"type\": VALIDATION_MESSAGE_TYPES }]`\n */\n maxSelectedMessage: {\n type: Array,\n default: function () { return []; },\n },\n\n /**\n * Displays the list when the combobox is focused, before the user has typed anything.\n * When this is enabled the list will not close after selection.\n */\n hasSuggestionList: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Size of the chip, one of `xs`, `sm`, `md`\n */\n size: {\n type: String,\n default: 'md',\n validator: (t) => Object.values(MULTI_SELECT_SIZES).includes(t),\n },\n\n /**\n * Sets the element to which the popover is going to append to.\n * 'body' will append to the nearest body (supports shadow DOM).\n * @values 'body', 'parent', HTMLElement,\n */\n appendTo: {\n type: [HTMLElement, String],\n default: 'body',\n validator: appendTo => {\n return POPOVER_APPEND_TO_VALUES.includes(appendTo) ||\n (appendTo instanceof HTMLElement);\n },\n },\n\n /**\n * Named transition when the content display is toggled.\n * @see DtLazyShow\n */\n transition: {\n type: String,\n default: 'fade',\n },\n\n /**\n * Determines whether the combobox should collapse to a single when losing focus.\n * @type {boolean}\n */\n collapseOnFocusOut: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Determines maximum width for the popover before overflow.\n * Possible units rem|px|em\n */\n listMaxWidth: {\n type: String,\n default: '',\n },\n\n /**\n * Amount of reserved space (in px) on the right side of the input\n * before the chips and the input caret jump to the next line.\n * default is 64\n */\n reservedRightSpace: {\n type: Number,\n default: 64,\n },\n\n /**\n * Determines the maximum width of a single chip. If the text within this chip exceeds the value\n * it will be truncated with ellipses.\n * Possible units rem|px|em\n */\n chipMaxWidth: {\n type: String,\n default: '',\n },\n\n /**\n * Additional class name for the input element.\n * Can accept String, Object, and Array, i.e. has the\n * same API as Vue's built-in handling of the class attribute.\n */\n inputClass: {\n type: [String, Object, Array],\n default: '',\n },\n\n /**\n * Additional class name for the input wrapper element.\n * Can accept all of String, Object, and Array, i.e. has the\n * same api as Vue's built-in handling of the class attribute.\n */\n inputWrapperClass: {\n type: [String, Object, Array],\n default: '',\n },\n\n /**\n * When true, disables the underlying input.\n */\n disabled: {\n type: Boolean,\n default: false,\n },\n },\n\n emits: [\n /**\n * Native input event\n *\n * @event input\n * @type {String }\n */\n 'input',\n\n /**\n * Event fired when item selected\n *\n * @event select\n * @type {Number}\n */\n 'select',\n\n /**\n * Event fired when item removed\n *\n * @event remove\n * @type {String}\n */\n 'remove',\n\n /**\n * Event fired when max selected items limit is reached\n *\n * @event max-selected\n * @type {Object}\n */\n 'max-selected',\n\n /**\n * Native keyup event\n *\n * @event keyup\n * @type {KeyboardEvent}\n */\n 'keyup',\n\n /**\n * Native keydown event\n *\n * @event keydown\n * @type {KeyboardEvent}\n */\n 'keydown',\n\n /**\n * Event fired when combobox item is highlighted\n *\n * @event combobox-highlight\n * @type {Object}\n */\n 'combobox-highlight',\n ],\n\n data () {\n return {\n value: '',\n popoverOffset: [0, 4],\n showValidationMessages: false,\n resizeWindowObserver: null,\n initialInputHeight: null,\n CHIP_SIZES,\n hasSlotContent,\n inputFocused: false,\n hideInputText: false,\n };\n },\n\n computed: {\n inputPlaceHolder () {\n return this.selectedItems?.length > 0 ? '' : this.placeholder;\n },\n\n chipListeners () {\n return {\n keydown: event => {\n this.onChipKeyDown(event);\n this.$emit('keydown', event);\n },\n };\n },\n\n inputListeners () {\n return {\n ...extractVueListeners(this.$attrs),\n onInput: event => {\n this.$emit('input', event);\n if (this.hasSuggestionList) {\n this.showComboboxList();\n }\n },\n\n onKeydown: event => {\n this.onInputKeyDown(event);\n },\n\n onKeyup: event => {\n this.$emit('keyup', event);\n },\n\n onClick: () => {\n if (this.hasSuggestionList) {\n this.showComboboxList();\n }\n },\n };\n },\n\n chipWrapperClass () {\n return {\n [`d-recipe-combobox-multi-select__chip-wrapper-${this.size}--collapsed`]: !this.inputFocused && this.collapseOnFocusOut,\n };\n },\n },\n\n watch: {\n selectedItems: {\n deep: true,\n handler: async function () {\n await this.initSelectedItems();\n },\n },\n\n chipMaxWidth: {\n async handler () {\n await this.initSelectedItems();\n },\n },\n\n async label () {\n await this.$nextTick();\n // Adjust the chips position if label changed\n this.setChipsTopPosition();\n },\n\n async description () {\n await this.$nextTick();\n // Adjust the chips position if description changed\n this.setChipsTopPosition();\n },\n\n size: {\n async handler () {\n await this.$nextTick();\n const input = this.getInput();\n this.revertInputPadding(input);\n this.initialInputHeight = input.getBoundingClientRect().height;\n this.setInputPadding();\n this.setChipsTopPosition();\n },\n },\n },\n\n async mounted () {\n this.setInitialInputHeight();\n // Recalculate chip position and input padding when resizing window\n this.resizeWindowObserver = new ResizeObserver(async () => {\n this.setChipsTopPosition();\n this.setInputPadding();\n });\n this.resizeWindowObserver.observe(document.body);\n\n await this.initSelectedItems();\n },\n\n beforeUnmount () {\n this.resizeWindowObserver?.unobserve(document.body);\n },\n\n methods: {\n extractNonListeners,\n comboboxHighlight (highlightIndex) {\n this.$emit('combobox-highlight', highlightIndex);\n },\n\n async initSelectedItems () {\n await this.$nextTick();\n this.setInputPadding();\n this.setChipsTopPosition();\n this.setInputMinWidth();\n this.checkMaxSelected();\n },\n\n onChipRemove (item) {\n this.$emit('remove', item);\n this.$refs.input?.focus();\n },\n\n onComboboxSelect (i) {\n if (this.loading) return;\n this.value = '';\n this.$emit('select', i);\n },\n\n showComboboxList () {\n if (this.showList != null) { return; }\n this.$refs.comboboxWithPopover?.showComboboxList();\n },\n\n closeComboboxList () {\n if (this.showList != null) { return; }\n this.$refs.comboboxWithPopover?.closeComboboxList();\n },\n\n getChips () {\n if (!this.selectedItems.length || !this.$refs.chips) return null;\n\n // Use the order from selectedItems to not rely on DOM order which may be stale.\n // Track matched indices to handle duplicate item names correctly.\n const matched = new Set();\n const chips = this.selectedItems.map(item => {\n return this.$refs.chips.find((chip, index) => {\n if (matched.has(index)) return false;\n const chipLabel = returnFirstEl(chip.$el)?.querySelector('.d-chip__label')?.textContent?.trim();\n if (chipLabel === item) {\n matched.add(index);\n return true;\n }\n return false;\n });\n });\n return chips.filter(Boolean).map(chip => returnFirstEl(chip.$el));\n },\n\n getChipButtons () {\n const chips = this.getChips();\n return chips && chips.map(chip => returnFirstEl(chip).querySelector('button'));\n },\n\n getLastChipButton () {\n const chipButtons = this.getChipButtons();\n return chipButtons && chipButtons[chipButtons.length - 1];\n },\n\n getLastChip () {\n const chips = this.getChips();\n return chips && chips[chips.length - 1];\n },\n\n getFirstChip () {\n const chips = this.getChips();\n return chips && chips[0];\n },\n\n getInput () {\n return this.$refs.input?.$refs.input;\n },\n\n onChipKeyDown (event) {\n const key = event.code?.toLowerCase();\n if (key === 'arrowleft') {\n // Move to the previous chip\n this.navigateBetweenChips(event.target, true);\n } else if (key === 'arrowright') {\n if (event.target.id === this.getLastChipButton().id) {\n // Move to the input if it's the last chip\n this.moveFromChipToInput();\n } else {\n // Move to the next chip\n this.navigateBetweenChips(event.target, false);\n }\n }\n },\n\n onInputKeyDown (event) {\n const key = event.code?.toLowerCase();\n // If the cursor is at the start of the text,\n // press 'backspace' or 'left' focuses the last chip\n if (this.selectedItems.length > 0 && event.target.selectionStart === 0) {\n // if there is selected text, do not focus the last chip\n if (event.target.selectionEnd !== event.target.selectionStart) {\n return;\n }\n if (key === 'backspace' || key === 'arrowleft') {\n this.moveFromInputToChip();\n }\n }\n },\n\n moveFromInputToChip () {\n this.getLastChipButton().focus();\n this.$refs.input?.blur();\n this.closeComboboxList();\n },\n\n moveFromChipToInput () {\n this.getLastChipButton().blur();\n this.$refs.input?.focus();\n this.showComboboxList();\n },\n\n navigateBetweenChips (target, toLeft) {\n const from = this.getChipButtons().indexOf(target);\n const to = toLeft ? from - 1 : from + 1;\n if (to < 0 || to >= this.$refs.chips?.length) {\n return;\n }\n this.getChipButtons()[from].blur();\n this.getChipButtons()[to].focus();\n this.closeComboboxList();\n },\n\n setChipsTopPosition () {\n // To place the chips in the input box\n // The chip \"top\" position should be the same line as the input box\n const input = this.getInput();\n if (!input) return;\n const inputSlotWrapper = this.$refs.inputSlotWrapper;\n const top = input.getBoundingClientRect().top -\n inputSlotWrapper.getBoundingClientRect().top;\n const chipsWrapper = this.$refs.chipsWrapper;\n chipsWrapper.style.top = (top - CHIP_TOP_POSITION[this.size]) + 'px';\n },\n\n setInputPadding () {\n const lastChip = this.getLastChip();\n const input = this.getInput();\n const chipsWrapper = this.$refs.chipsWrapper;\n if (!input) return;\n this.revertInputPadding(input);\n this.popoverOffset = [0, 4];\n if (!lastChip) return;\n // Avoid adding extra padding when the input is not focused if collapseOnFocusOut is true\n // This ensures the input returns to its original state when resizing\n if (this.collapseOnFocusOut && !this.inputFocused) return;\n\n // Get the position of the last chip\n // The input cursor should be the same \"top\" as that chip and next besides it\n const left = lastChip.offsetLeft + this.getFullWidth(lastChip);\n const spaceLeft = input.getBoundingClientRect().width - left;\n // input.style.paddingLeft = left + 'px';\n\n if (spaceLeft > this.reservedRightSpace) {\n input.style.paddingLeft = left + 'px';\n } else {\n input.style.paddingLeft = '4px';\n }\n\n // Get the chip wrapper height minus the 4px padding\n const chipsWrapperHeight = chipsWrapper.getBoundingClientRect().height - 4;\n const lastChipHeight = lastChip.getBoundingClientRect().height - 4;\n\n // Get lastChip offsetTop plus 2px of the input padding.\n const top = spaceLeft > this.reservedRightSpace\n ? lastChip.offsetTop + 2\n : (chipsWrapperHeight + lastChipHeight - 9);\n\n input.style.paddingTop = `${top}px`;\n },\n\n revertInputPadding (input) {\n input.style.paddingLeft = '';\n input.style.paddingTop = '';\n input.style.paddingBottom = '';\n },\n\n getFullWidth (el) {\n const styles = window.getComputedStyle(el);\n return el.offsetWidth + parseInt(styles.marginLeft) + parseInt(styles.marginRight);\n },\n\n setInputMinWidth () {\n // Ensure the width of the input is \"slightly bigger\" than the width of a single chip\n const firstChip = this.getFirstChip();\n const input = this.getInput();\n if (!input) return;\n if (firstChip) {\n // Add 4px buffer for typing room\n input.style.minWidth = (this.getFullWidth(firstChip) + 4) + 'px';\n } else {\n input.style.minWidth = '';\n }\n },\n\n checkMaxSelected () {\n if (this.maxSelected === 0) return;\n if (this.selectedItems.length > this.maxSelected) {\n this.showValidationMessages = true;\n this.$emit('max-selected');\n } else {\n this.showValidationMessages = false;\n }\n },\n\n setInitialInputHeight () {\n const input = this.getInput();\n if (!input) return;\n this.initialInputHeight = input.getBoundingClientRect().height;\n },\n\n async handleInputFocusIn () {\n this.inputFocused = true;\n if (this.collapseOnFocusOut) {\n this.hideInputText = false;\n await this.$nextTick();\n this.setInputPadding();\n }\n },\n\n async handleInputFocusOut () {\n this.inputFocused = false;\n if (this.collapseOnFocusOut) {\n this.hideInputText = true;\n const input = this.getInput();\n if (!input) return;\n // Hide the input text when is not on first line\n if (!input.style.paddingTop) {\n return;\n }\n this.revertInputPadding(input);\n }\n },\n },\n};\n</script>\n"],"names":["_sfc_main","DtComboboxWithPopover","DtInput","DtChip","DtValidationMessages","inputMessages","validationMessageValidator","MULTI_SELECT_SIZES","appendTo","POPOVER_APPEND_TO_VALUES","CHIP_SIZES","hasSlotContent","_a","event","extractVueListeners","input","extractNonListeners","highlightIndex","item","i","matched","chip","index","_c","_b","returnFirstEl","chips","chipButtons","key","target","toLeft","from","to","inputSlotWrapper","top","chipsWrapper","CHIP_TOP_POSITION","lastChip","left","spaceLeft","chipsWrapperHeight","lastChipHeight","el","styles","firstChip","_hoisted_1","_hoisted_3","_openBlock","_createBlock","_component_dt_combobox_with_popover","_mergeProps","$props","$data","$options","_ctx","_withCtx","onInput","_createElementVNode","args","_createElementBlock","_Fragment","_renderList","_component_dt_chip","_toHandlers","_withKeys","$event","_createVNode","_component_dt_input","_component_dt_validation_messages","_hoisted_2","_toDisplayString","_renderSlot"],"mappings":";;;;;;;;;;AAuIA,MAAKA,IAAU;AAAA,EACb,cAAc,EAAE,MAAM;EACtB,MAAM;AAAA,EAEN,YAAY;AAAA,IACV,uBAAAC;AAAA,IACA,SAAAC;AAAA,IACA,QAAAC;AAAA,IACA,sBAAAC;AAAA;EAGF,cAAc;AAAA,EAEd,OAAO;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO;AAAA,MACL,MAAM;AAAA,MACN,UAAU;AAAA;;;;;IAOZ,cAAc;AAAA,MACZ,MAAM;AAAA,MACN,SAAS;AAAA;;;;IAMX,aAAa;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA;;;;IAMX,aAAa;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA;;;;IAMX,eAAe;AAAA,MACb,MAAM;AAAA,MACN,SAAS,MAAM,CAAA;AAAA,MACf,WAAW,CAAAC,MACFC,EAA2BD,CAAa;AAAA;;;;IAOnD,mBAAmB;AAAA,MACjB,MAAM;AAAA,MACN,SAAS;AAAA;;;;;;;;;;IAaX,SAAS;AAAA,MACP,MAAM;AAAA,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EAAsBjB,EAAA,QAAA,QAAA;AAAA;;;;IA0BlBF,EAAA,eAAeE,EAAA,OAAO,MAAM;YACjC;AAAA,YAED,MAEM;AAAA,QAFNG,EAEM,OAFNX,GAEM;AAAA,UADJyB,EAAsBjB,EAAA,QAAA,QAAA;AAAA;;;;;;;"}
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const S=require("../../node_modules/@tiptap/vue-3.cjs"),T=require("@tiptap/core"),j=require("@tiptap/pm/state"),kt=require("@tiptap/pm/tables"),a=require("vue"),Et=require("@tiptap/extension-blockquote"),Ot=require("@tiptap/extension-code-block"),St=require("@tiptap/extension-code"),Lt=require("@tiptap/extension-document"),ve=require("@tiptap/extensions"),Dt=require("@tiptap/extension-hard-break"),Ge=require("@tiptap/extension-paragraph"),At=require("@tiptap/extension-bold"),xe=require("@tiptap/extension-list"),It=require("@tiptap/extension-italic"),Bt=require("@tiptap/extension-link"),Rt=require("@tiptap/extension-strike"),Mt=require("@tiptap/extension-underline"),Nt=require("@tiptap/extension-text"),Ht=require("@tiptap/extension-text-align"),pe=require("@tiptap/extension-table"),Je=require("@tiptap/extension-text-style"),Vt=require("@tiptap/suggestion"),Ze=require("regex-combined-emojis"),F=require("../../_plugin-vue_export-helper-BRilXfQE.cjs"),Qe=require("../emoji/emoji.cjs"),te=require("../../common/emoji/index.cjs"),$t=require("../list-item/list-item.cjs"),le=require("../stack/stack.cjs"),re=require("../../common/utils/index.cjs"),Pt=require("@tiptap/extension-image"),ke=require("@tiptap/extension-mention"),et=require("../link/link.cjs"),Ut=require("@dialpad/dialtone-icons/vue3"),tt=require("../../localization/index.cjs"),jt=require("../input/input.cjs"),zt=require("../popover/popover.cjs"),nt=require("../button/button.cjs"),qt=require("../badge/badge.cjs"),de=require("./rich-text-editor-constants.cjs"),Ft=require("../avatar/avatar.cjs"),Kt=require("@dialpad/dialtone-icons/vue3/hash"),Wt=require("@dialpad/dialtone-icons/vue3/lock"),Xt=require("deep-equal"),ot=["top","right","bottom","left"],Me=["start","end"],Ne=ot.reduce((e,t)=>e.concat(t,t+"-"+Me[0],t+"-"+Me[1]),[]),X=Math.min,I=Math.max,ue=Math.round,W=e=>({x:e,y:e}),Yt={left:"right",right:"left",bottom:"top",top:"bottom"},Gt={start:"end",end:"start"};function Te(e,t,o){return I(e,X(t,o))}function G(e,t){return typeof e=="function"?e(t):e}function $(e){return e.split("-")[0]}function U(e){return e.split("-")[1]}function it(e){return e==="x"?"y":"x"}function Ee(e){return e==="y"?"height":"width"}const Jt=new Set(["top","bottom"]);function K(e){return Jt.has($(e))?"y":"x"}function Oe(e){return it(K(e))}function st(e,t,o){o===void 0&&(o=!1);const n=U(e),i=Oe(e),s=Ee(i);let r=i==="x"?n===(o?"end":"start")?"right":"left":n==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(r=fe(r)),[r,fe(r)]}function Zt(e){const t=fe(e);return[he(e),t,he(t)]}function he(e){return e.replace(/start|end/g,t=>Gt[t])}const He=["left","right"],Ve=["right","left"],Qt=["top","bottom"],en=["bottom","top"];function tn(e,t,o){switch(e){case"top":case"bottom":return o?t?Ve:He:t?He:Ve;case"left":case"right":return t?Qt:en;default:return[]}}function nn(e,t,o,n){const i=U(e);let s=tn($(e),o==="start",n);return i&&(s=s.map(r=>r+"-"+i),t&&(s=s.concat(s.map(he)))),s}function fe(e){return e.replace(/left|right|bottom|top/g,t=>Yt[t])}function on(e){return{top:0,right:0,bottom:0,left:0,...e}}function Se(e){return typeof e!="number"?on(e):{top:e,right:e,bottom:e,left:e}}function oe(e){const{x:t,y:o,width:n,height:i}=e;return{width:n,height:i,top:o,left:t,right:t+n,bottom:o+i,x:t,y:o}}function $e(e,t,o){let{reference:n,floating:i}=e;const s=K(t),r=Oe(t),l=Ee(r),c=$(t),h=s==="y",u=n.x+n.width/2-i.width/2,d=n.y+n.height/2-i.height/2,f=n[l]/2-i[l]/2;let p;switch(c){case"top":p={x:u,y:n.y-i.height};break;case"bottom":p={x:u,y:n.y+n.height};break;case"right":p={x:n.x+n.width,y:d};break;case"left":p={x:n.x-i.width,y:d};break;default:p={x:n.x,y:n.y}}switch(U(t)){case"start":p[r]-=f*(o&&h?-1:1);break;case"end":p[r]+=f*(o&&h?-1:1);break}return p}async function sn(e,t){var o;t===void 0&&(t={});const{x:n,y:i,platform:s,rects:r,elements:l,strategy:c}=e,{boundary:h="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:p=0}=G(t,e),m=Se(p),w=l[f?d==="floating"?"reference":"floating":d],y=oe(await s.getClippingRect({element:(o=await(s.isElement==null?void 0:s.isElement(w)))==null||o?w:w.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:h,rootBoundary:u,strategy:c})),v=d==="floating"?{x:n,y:i,width:r.floating.width,height:r.floating.height}:r.reference,x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),_=await(s.isElement==null?void 0:s.isElement(x))?await(s.getScale==null?void 0:s.getScale(x))||{x:1,y:1}:{x:1,y:1},k=oe(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:v,offsetParent:x,strategy:c}):v);return{top:(y.top-k.top+m.top)/_.y,bottom:(k.bottom-y.bottom+m.bottom)/_.y,left:(y.left-k.left+m.left)/_.x,right:(k.right-y.right+m.right)/_.x}}const rn=async(e,t,o)=>{const{placement:n="bottom",strategy:i="absolute",middleware:s=[],platform:r}=o,l=s.filter(Boolean),c=await(r.isRTL==null?void 0:r.isRTL(t));let h=await r.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=$e(h,n,c),f=n,p={},m=0;for(let w=0;w<l.length;w++){var g;const{name:y,fn:v}=l[w],{x,y:_,data:k,reset:C}=await v({x:u,y:d,initialPlacement:n,placement:f,strategy:i,middlewareData:p,rects:h,platform:{...r,detectOverflow:(g=r.detectOverflow)!=null?g:sn},elements:{reference:e,floating:t}});u=x??u,d=_??d,p={...p,[y]:{...p[y],...k}},C&&m<=50&&(m++,typeof C=="object"&&(C.placement&&(f=C.placement),C.rects&&(h=C.rects===!0?await r.getElementRects({reference:e,floating:t,strategy:i}):C.rects),{x:u,y:d}=$e(h,f,c)),w=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:p}},an=e=>({name:"arrow",options:e,async fn(t){const{x:o,y:n,placement:i,rects:s,platform:r,elements:l,middlewareData:c}=t,{element:h,padding:u=0}=G(e,t)||{};if(h==null)return{};const d=Se(u),f={x:o,y:n},p=Oe(i),m=Ee(p),g=await r.getDimensions(h),w=p==="y",y=w?"top":"left",v=w?"bottom":"right",x=w?"clientHeight":"clientWidth",_=s.reference[m]+s.reference[p]-f[p]-s.floating[m],k=f[p]-s.reference[p],C=await(r.getOffsetParent==null?void 0:r.getOffsetParent(h));let L=C?C[x]:0;(!L||!await(r.isElement==null?void 0:r.isElement(C)))&&(L=l.floating[x]||s.floating[m]);const H=_/2-k/2,D=L/2-g[m]/2-1,b=X(d[y],D),E=X(d[v],D),A=b,B=L-g[m]-E,O=L/2-g[m]/2+H,P=Te(A,O,B),V=!c.arrow&&U(i)!=null&&O!==P&&s.reference[m]/2-(O<A?b:E)-g[m]/2<0,R=V?O<A?O-A:O-B:0;return{[p]:f[p]+R,data:{[p]:P,centerOffset:O-P-R,...V&&{alignmentOffset:R}},reset:V}}});function ln(e,t,o){return(e?[...o.filter(i=>U(i)===e),...o.filter(i=>U(i)!==e)]:o.filter(i=>$(i)===i)).filter(i=>e?U(i)===e||(t?he(i)!==i:!1):!0)}const cn=function(e){return e===void 0&&(e={}),{name:"autoPlacement",options:e,async fn(t){var o,n,i;const{rects:s,middlewareData:r,placement:l,platform:c,elements:h}=t,{crossAxis:u=!1,alignment:d,allowedPlacements:f=Ne,autoAlignment:p=!0,...m}=G(e,t),g=d!==void 0||f===Ne?ln(d||null,p,f):f,w=await c.detectOverflow(t,m),y=((o=r.autoPlacement)==null?void 0:o.index)||0,v=g[y];if(v==null)return{};const x=st(v,s,await(c.isRTL==null?void 0:c.isRTL(h.floating)));if(l!==v)return{reset:{placement:g[0]}};const _=[w[$(v)],w[x[0]],w[x[1]]],k=[...((n=r.autoPlacement)==null?void 0:n.overflows)||[],{placement:v,overflows:_}],C=g[y+1];if(C)return{data:{index:y+1,overflows:k},reset:{placement:C}};const L=k.map(b=>{const E=U(b.placement);return[b.placement,E&&u?b.overflows.slice(0,2).reduce((A,B)=>A+B,0):b.overflows[0],b.overflows]}).sort((b,E)=>b[1]-E[1]),D=((i=L.filter(b=>b[2].slice(0,U(b[0])?2:3).every(E=>E<=0))[0])==null?void 0:i[0])||L[0][0];return D!==l?{data:{index:y+1,overflows:k},reset:{placement:D}}:{}}}},dn=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var o,n;const{placement:i,middlewareData:s,rects:r,initialPlacement:l,platform:c,elements:h}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:g=!0,...w}=G(e,t);if((o=s.arrow)!=null&&o.alignmentOffset)return{};const y=$(i),v=K(l),x=$(l)===l,_=await(c.isRTL==null?void 0:c.isRTL(h.floating)),k=f||(x||!g?[fe(l)]:Zt(l)),C=m!=="none";!f&&C&&k.push(...nn(l,g,m,_));const L=[l,...k],H=await c.detectOverflow(t,w),D=[];let b=((n=s.flip)==null?void 0:n.overflows)||[];if(u&&D.push(H[y]),d){const O=st(i,r,_);D.push(H[O[0]],H[O[1]])}if(b=[...b,{placement:i,overflows:D}],!D.every(O=>O<=0)){var E,A;const O=(((E=s.flip)==null?void 0:E.index)||0)+1,P=L[O];if(P&&(!(d==="alignment"?v!==K(P):!1)||b.every(M=>K(M.placement)===v?M.overflows[0]>0:!0)))return{data:{index:O,overflows:b},reset:{placement:P}};let V=(A=b.filter(R=>R.overflows[0]<=0).sort((R,M)=>R.overflows[1]-M.overflows[1])[0])==null?void 0:A.placement;if(!V)switch(p){case"bestFit":{var B;const R=(B=b.filter(M=>{if(C){const Z=K(M.placement);return Z===v||Z==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(Z=>Z>0).reduce((Z,Ct)=>Z+Ct,0)]).sort((M,Z)=>M[1]-Z[1])[0])==null?void 0:B[0];R&&(V=R);break}case"initialPlacement":V=l;break}if(i!==V)return{reset:{placement:V}}}return{}}}};function Pe(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Ue(e){return ot.some(t=>e[t]>=0)}const un=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:o,platform:n}=t,{strategy:i="referenceHidden",...s}=G(e,t);switch(i){case"referenceHidden":{const r=await n.detectOverflow(t,{...s,elementContext:"reference"}),l=Pe(r,o.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:Ue(l)}}}case"escaped":{const r=await n.detectOverflow(t,{...s,altBoundary:!0}),l=Pe(r,o.floating);return{data:{escapedOffsets:l,escaped:Ue(l)}}}default:return{}}}}};function rt(e){const t=X(...e.map(s=>s.left)),o=X(...e.map(s=>s.top)),n=I(...e.map(s=>s.right)),i=I(...e.map(s=>s.bottom));return{x:t,y:o,width:n-t,height:i-o}}function hn(e){const t=e.slice().sort((i,s)=>i.y-s.y),o=[];let n=null;for(let i=0;i<t.length;i++){const s=t[i];!n||s.y-n.y>n.height/2?o.push([s]):o[o.length-1].push(s),n=s}return o.map(i=>oe(rt(i)))}const fn=function(e){return e===void 0&&(e={}),{name:"inline",options:e,async fn(t){const{placement:o,elements:n,rects:i,platform:s,strategy:r}=t,{padding:l=2,x:c,y:h}=G(e,t),u=Array.from(await(s.getClientRects==null?void 0:s.getClientRects(n.reference))||[]),d=hn(u),f=oe(rt(u)),p=Se(l);function m(){if(d.length===2&&d[0].left>d[1].right&&c!=null&&h!=null)return d.find(w=>c>w.left-p.left&&c<w.right+p.right&&h>w.top-p.top&&h<w.bottom+p.bottom)||f;if(d.length>=2){if(K(o)==="y"){const b=d[0],E=d[d.length-1],A=$(o)==="top",B=b.top,O=E.bottom,P=A?b.left:E.left,V=A?b.right:E.right,R=V-P,M=O-B;return{top:B,bottom:O,left:P,right:V,width:R,height:M,x:P,y:B}}const w=$(o)==="left",y=I(...d.map(b=>b.right)),v=X(...d.map(b=>b.left)),x=d.filter(b=>w?b.left===v:b.right===y),_=x[0].top,k=x[x.length-1].bottom,C=v,L=y,H=L-C,D=k-_;return{top:_,bottom:k,left:C,right:L,width:H,height:D,x:C,y:_}}return f}const g=await s.getElementRects({reference:{getBoundingClientRect:m},floating:n.floating,strategy:r});return i.reference.x!==g.reference.x||i.reference.y!==g.reference.y||i.reference.width!==g.reference.width||i.reference.height!==g.reference.height?{reset:{rects:g}}:{}}}},pn=new Set(["left","top"]);async function mn(e,t){const{placement:o,platform:n,elements:i}=e,s=await(n.isRTL==null?void 0:n.isRTL(i.floating)),r=$(o),l=U(o),c=K(o)==="y",h=pn.has(r)?-1:1,u=s&&c?-1:1,d=G(t,e);let{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return l&&typeof m=="number"&&(p=l==="end"?m*-1:m),c?{x:p*u,y:f*h}:{x:f*h,y:p*u}}const gn=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var o,n;const{x:i,y:s,placement:r,middlewareData:l}=t,c=await mn(t,e);return r===((o=l.offset)==null?void 0:o.placement)&&(n=l.arrow)!=null&&n.alignmentOffset?{}:{x:i+c.x,y:s+c.y,data:{...c,placement:r}}}}},wn=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:o,y:n,placement:i,platform:s}=t,{mainAxis:r=!0,crossAxis:l=!1,limiter:c={fn:y=>{let{x:v,y:x}=y;return{x:v,y:x}}},...h}=G(e,t),u={x:o,y:n},d=await s.detectOverflow(t,h),f=K($(i)),p=it(f);let m=u[p],g=u[f];if(r){const y=p==="y"?"top":"left",v=p==="y"?"bottom":"right",x=m+d[y],_=m-d[v];m=Te(x,m,_)}if(l){const y=f==="y"?"top":"left",v=f==="y"?"bottom":"right",x=g+d[y],_=g-d[v];g=Te(x,g,_)}const w=c.fn({...t,[p]:m,[f]:g});return{...w,data:{x:w.x-o,y:w.y-n,enabled:{[p]:r,[f]:l}}}}}},yn=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var o,n;const{placement:i,rects:s,platform:r,elements:l}=t,{apply:c=()=>{},...h}=G(e,t),u=await r.detectOverflow(t,h),d=$(i),f=U(i),p=K(i)==="y",{width:m,height:g}=s.floating;let w,y;d==="top"||d==="bottom"?(w=d,y=f===(await(r.isRTL==null?void 0:r.isRTL(l.floating))?"start":"end")?"left":"right"):(y=d,w=f==="end"?"top":"bottom");const v=g-u.top-u.bottom,x=m-u.left-u.right,_=X(g-u[w],v),k=X(m-u[y],x),C=!t.middlewareData.shift;let L=_,H=k;if((o=t.middlewareData.shift)!=null&&o.enabled.x&&(H=x),(n=t.middlewareData.shift)!=null&&n.enabled.y&&(L=v),C&&!f){const b=I(u.left,0),E=I(u.right,0),A=I(u.top,0),B=I(u.bottom,0);p?H=m-2*(b!==0||E!==0?b+E:I(u.left,u.right)):L=g-2*(A!==0||B!==0?A+B:I(u.top,u.bottom))}await c({...t,availableWidth:H,availableHeight:L});const D=await r.getDimensions(l.floating);return m!==D.width||g!==D.height?{reset:{rects:!0}}:{}}}};function me(){return typeof window<"u"}function se(e){return at(e)?(e.nodeName||"").toLowerCase():"#document"}function N(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function J(e){var t;return(t=(at(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function at(e){return me()?e instanceof Node||e instanceof N(e).Node:!1}function z(e){return me()?e instanceof Element||e instanceof N(e).Element:!1}function Y(e){return me()?e instanceof HTMLElement||e instanceof N(e).HTMLElement:!1}function je(e){return!me()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof N(e).ShadowRoot}const bn=new Set(["inline","contents"]);function ce(e){const{overflow:t,overflowX:o,overflowY:n,display:i}=q(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+o)&&!bn.has(i)}const vn=new Set(["table","td","th"]);function xn(e){return vn.has(se(e))}const _n=[":popover-open",":modal"];function ge(e){return _n.some(t=>{try{return e.matches(t)}catch{return!1}})}const Tn=["transform","translate","scale","rotate","perspective"],Cn=["transform","translate","scale","rotate","perspective","filter"],kn=["paint","layout","strict","content"];function Le(e){const t=De(),o=z(e)?q(e):e;return Tn.some(n=>o[n]?o[n]!=="none":!1)||(o.containerType?o.containerType!=="normal":!1)||!t&&(o.backdropFilter?o.backdropFilter!=="none":!1)||!t&&(o.filter?o.filter!=="none":!1)||Cn.some(n=>(o.willChange||"").includes(n))||kn.some(n=>(o.contain||"").includes(n))}function En(e){let t=ee(e);for(;Y(t)&&!ie(t);){if(Le(t))return t;if(ge(t))return null;t=ee(t)}return null}function De(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const On=new Set(["html","body","#document"]);function ie(e){return On.has(se(e))}function q(e){return N(e).getComputedStyle(e)}function we(e){return z(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ee(e){if(se(e)==="html")return e;const t=e.assignedSlot||e.parentNode||je(e)&&e.host||J(e);return je(t)?t.host:t}function lt(e){const t=ee(e);return ie(t)?e.ownerDocument?e.ownerDocument.body:e.body:Y(t)&&ce(t)?t:lt(t)}function ct(e,t,o){var n;t===void 0&&(t=[]);const i=lt(e),s=i===((n=e.ownerDocument)==null?void 0:n.body),r=N(i);return s?t.concat(r,r.visualViewport||[],ce(i)?i:[],[]):t.concat(i,ct(i,[]))}function ze(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function dt(e){const t=q(e);let o=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const i=Y(e),s=i?e.offsetWidth:o,r=i?e.offsetHeight:n,l=ue(o)!==s||ue(n)!==r;return l&&(o=s,n=r),{width:o,height:n,$:l}}function ut(e){return z(e)?e:e.contextElement}function ne(e){const t=ut(e);if(!Y(t))return W(1);const o=t.getBoundingClientRect(),{width:n,height:i,$:s}=dt(t);let r=(s?ue(o.width):o.width)/n,l=(s?ue(o.height):o.height)/i;return(!r||!Number.isFinite(r))&&(r=1),(!l||!Number.isFinite(l))&&(l=1),{x:r,y:l}}const Sn=W(0);function ht(e){const t=N(e);return!De()||!t.visualViewport?Sn:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ln(e,t,o){return t===void 0&&(t=!1),!o||t&&o!==N(e)?!1:t}function ae(e,t,o,n){t===void 0&&(t=!1),o===void 0&&(o=!1);const i=e.getBoundingClientRect(),s=ut(e);let r=W(1);t&&(n?z(n)&&(r=ne(n)):r=ne(e));const l=Ln(s,o,n)?ht(s):W(0);let c=(i.left+l.x)/r.x,h=(i.top+l.y)/r.y,u=i.width/r.x,d=i.height/r.y;if(s){const f=N(s),p=n&&z(n)?N(n):n;let m=f,g=ze(m);for(;g&&n&&p!==m;){const w=ne(g),y=g.getBoundingClientRect(),v=q(g),x=y.left+(g.clientLeft+parseFloat(v.paddingLeft))*w.x,_=y.top+(g.clientTop+parseFloat(v.paddingTop))*w.y;c*=w.x,h*=w.y,u*=w.x,d*=w.y,c+=x,h+=_,m=N(g),g=ze(m)}}return oe({width:u,height:d,x:c,y:h})}function ye(e,t){const o=we(e).scrollLeft;return t?t.left+o:ae(J(e)).left+o}function ft(e,t){const o=e.getBoundingClientRect(),n=o.left+t.scrollLeft-ye(e,o),i=o.top+t.scrollTop;return{x:n,y:i}}function Dn(e){let{elements:t,rect:o,offsetParent:n,strategy:i}=e;const s=i==="fixed",r=J(n),l=t?ge(t.floating):!1;if(n===r||l&&s)return o;let c={scrollLeft:0,scrollTop:0},h=W(1);const u=W(0),d=Y(n);if((d||!d&&!s)&&((se(n)!=="body"||ce(r))&&(c=we(n)),Y(n))){const p=ae(n);h=ne(n),u.x=p.x+n.clientLeft,u.y=p.y+n.clientTop}const f=r&&!d&&!s?ft(r,c):W(0);return{width:o.width*h.x,height:o.height*h.y,x:o.x*h.x-c.scrollLeft*h.x+u.x+f.x,y:o.y*h.y-c.scrollTop*h.y+u.y+f.y}}function An(e){return Array.from(e.getClientRects())}function In(e){const t=J(e),o=we(e),n=e.ownerDocument.body,i=I(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),s=I(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let r=-o.scrollLeft+ye(e);const l=-o.scrollTop;return q(n).direction==="rtl"&&(r+=I(t.clientWidth,n.clientWidth)-i),{width:i,height:s,x:r,y:l}}const qe=25;function Bn(e,t){const o=N(e),n=J(e),i=o.visualViewport;let s=n.clientWidth,r=n.clientHeight,l=0,c=0;if(i){s=i.width,r=i.height;const u=De();(!u||u&&t==="fixed")&&(l=i.offsetLeft,c=i.offsetTop)}const h=ye(n);if(h<=0){const u=n.ownerDocument,d=u.body,f=getComputedStyle(d),p=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,m=Math.abs(n.clientWidth-d.clientWidth-p);m<=qe&&(s-=m)}else h<=qe&&(s+=h);return{width:s,height:r,x:l,y:c}}const Rn=new Set(["absolute","fixed"]);function Mn(e,t){const o=ae(e,!0,t==="fixed"),n=o.top+e.clientTop,i=o.left+e.clientLeft,s=Y(e)?ne(e):W(1),r=e.clientWidth*s.x,l=e.clientHeight*s.y,c=i*s.x,h=n*s.y;return{width:r,height:l,x:c,y:h}}function Fe(e,t,o){let n;if(t==="viewport")n=Bn(e,o);else if(t==="document")n=In(J(e));else if(z(t))n=Mn(t,o);else{const i=ht(e);n={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return oe(n)}function pt(e,t){const o=ee(e);return o===t||!z(o)||ie(o)?!1:q(o).position==="fixed"||pt(o,t)}function Nn(e,t){const o=t.get(e);if(o)return o;let n=ct(e,[]).filter(l=>z(l)&&se(l)!=="body"),i=null;const s=q(e).position==="fixed";let r=s?ee(e):e;for(;z(r)&&!ie(r);){const l=q(r),c=Le(r);!c&&l.position==="fixed"&&(i=null),(s?!c&&!i:!c&&l.position==="static"&&!!i&&Rn.has(i.position)||ce(r)&&!c&&pt(e,r))?n=n.filter(u=>u!==r):i=l,r=ee(r)}return t.set(e,n),n}function Hn(e){let{element:t,boundary:o,rootBoundary:n,strategy:i}=e;const r=[...o==="clippingAncestors"?ge(t)?[]:Nn(t,this._c):[].concat(o),n],l=r[0],c=r.reduce((h,u)=>{const d=Fe(t,u,i);return h.top=I(d.top,h.top),h.right=X(d.right,h.right),h.bottom=X(d.bottom,h.bottom),h.left=I(d.left,h.left),h},Fe(t,l,i));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Vn(e){const{width:t,height:o}=dt(e);return{width:t,height:o}}function $n(e,t,o){const n=Y(t),i=J(t),s=o==="fixed",r=ae(e,!0,s,t);let l={scrollLeft:0,scrollTop:0};const c=W(0);function h(){c.x=ye(i)}if(n||!n&&!s)if((se(t)!=="body"||ce(i))&&(l=we(t)),n){const p=ae(t,!0,s,t);c.x=p.x+t.clientLeft,c.y=p.y+t.clientTop}else i&&h();s&&!n&&i&&h();const u=i&&!n&&!s?ft(i,l):W(0),d=r.left+l.scrollLeft-c.x-u.x,f=r.top+l.scrollTop-c.y-u.y;return{x:d,y:f,width:r.width,height:r.height}}function _e(e){return q(e).position==="static"}function Ke(e,t){if(!Y(e)||q(e).position==="fixed")return null;if(t)return t(e);let o=e.offsetParent;return J(e)===o&&(o=o.ownerDocument.body),o}function mt(e,t){const o=N(e);if(ge(e))return o;if(!Y(e)){let i=ee(e);for(;i&&!ie(i);){if(z(i)&&!_e(i))return i;i=ee(i)}return o}let n=Ke(e,t);for(;n&&xn(n)&&_e(n);)n=Ke(n,t);return n&&ie(n)&&_e(n)&&!Le(n)?o:n||En(e)||o}const Pn=async function(e){const t=this.getOffsetParent||mt,o=this.getDimensions,n=await o(e.floating);return{reference:$n(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function Un(e){return q(e).direction==="rtl"}const jn={convertOffsetParentRelativeRectToViewportRelativeRect:Dn,getDocumentElement:J,getClippingRect:Hn,getOffsetParent:mt,getElementRects:Pn,getClientRects:An,getDimensions:Vn,getScale:ne,isElement:z,isRTL:Un},Ae=gn,gt=cn,Ie=wn,Be=dn,wt=yn,yt=un,bt=an,vt=fn,Re=(e,t,o)=>{const n=new Map,i={platform:jn,...o},s={...i.platform,_c:n};return rn(e,t,{...i,platform:s})};function zn(e,t){const o=Math.min(e.top,t.top),n=Math.max(e.bottom,t.bottom),i=Math.min(e.left,t.left),r=Math.max(e.right,t.right)-i,l=n-o,c=i,h=o;return new DOMRect(c,h,r,l)}var qn=class{constructor({editor:e,element:t,view:o,updateDelay:n=250,resizeDelay:i=60,shouldShow:s,appendTo:r,getReferencedVirtualElement:l,options:c}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:u,state:d,from:f,to:p})=>{const{doc:m,selection:g}=d,{empty:w}=g,y=!m.textBetween(f,p).length&&T.isTextSelection(d.selection),v=this.element.contains(document.activeElement);return!(!(u.hasFocus()||v)||w||y||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:u})=>{var d;if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}u!=null&&u.relatedTarget&&((d=this.element.parentNode)!=null&&d.contains(u.relatedTarget))||(u==null?void 0:u.relatedTarget)!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(u,d)=>{const f=!(d!=null&&d.selection.eq(u.state.selection)),p=!(d!=null&&d.doc.eq(u.state.doc));!f&&!p||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(u,f,p,d)},this.updateDelay))},this.updateHandler=(u,d,f,p)=>{const{composing:m}=u;if(m||!d&&!f)return;if(!this.getShouldShow(p)){this.hide();return}this.updatePosition(),this.show()},this.transactionHandler=({transaction:u})=>{const d=u.getMeta("bubbleMenu");d==="updatePosition"?this.updatePosition():d&&typeof d=="object"&&d.type==="updateOptions"&&this.updateOptions(d.options)};var h;this.editor=e,this.element=t,this.view=o,this.updateDelay=n,this.resizeDelay=i,this.appendTo=r,this.scrollTarget=(h=c==null?void 0:c.scrollTarget)!=null?h:window,this.getReferencedVirtualElement=l,this.floatingUIOptions={...this.floatingUIOptions,...c},this.element.tabIndex=0,s&&(this.shouldShow=s),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(o,o.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){const e=[];return this.floatingUIOptions.flip&&e.push(Be(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&e.push(Ie(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&e.push(Ae(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&e.push(bt(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(wt(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&e.push(gt(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&e.push(yt(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&e.push(vt(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),e}get virtualElement(){var e,t,o;const{selection:n}=this.editor.state,i=(e=this.getReferencedVirtualElement)==null?void 0:e.call(this);if(i)return i;if(!((o=(t=this.view)==null?void 0:t.dom)!=null&&o.parentNode))return;const s=T.posToDOMRect(this.view,n.from,n.to);let r={getBoundingClientRect:()=>s,getClientRects:()=>[s]};if(n instanceof j.NodeSelection){let l=this.view.nodeDOM(n.from);const c=l.dataset.nodeViewWrapper?l:l.querySelector("[data-node-view-wrapper]");c&&(l=c),l&&(r={getBoundingClientRect:()=>l.getBoundingClientRect(),getClientRects:()=>[l.getBoundingClientRect()]})}if(n instanceof kt.CellSelection){const{$anchorCell:l,$headCell:c}=n,h=l?l.pos:c.pos,u=c?c.pos:l.pos,d=this.view.nodeDOM(h),f=this.view.nodeDOM(u);if(!d||!f)return;const p=d===f?d.getBoundingClientRect():zn(d.getBoundingClientRect(),f.getBoundingClientRect());r={getBoundingClientRect:()=>p,getClientRects:()=>[p]}}return r}updatePosition(){const e=this.virtualElement;e&&Re(e,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:t,y:o,strategy:n,middlewareData:i})=>{var s,r;if((s=i.hide)!=null&&s.referenceHidden||(r=i.hide)!=null&&r.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=n,this.element.style.left=`${t}px`,this.element.style.top=`${o}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){const{state:o}=e,n=o.selection.from!==o.selection.to;if(this.updateDelay>0&&n){this.handleDebouncedUpdate(e,t);return}const i=!(t!=null&&t.selection.eq(e.state.selection)),s=!(t!=null&&t.doc.eq(e.state.doc));this.updateHandler(e,i,s,t)}getShouldShow(e){var t;const{state:o}=this.view,{selection:n}=o,{ranges:i}=n,s=Math.min(...i.map(c=>c.$from.pos)),r=Math.max(...i.map(c=>c.$to.pos));return((t=this.shouldShow)==null?void 0:t.call(this,{editor:this.editor,element:this.element,view:this.view,state:o,oldState:e,from:s,to:r}))||!1}show(){var e;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const t=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(e=t??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}updateOptions(e){var t;if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=e.getReferencedVirtualElement),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){const o=(t=e.options.scrollTarget)!=null?t:window;o!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=o,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},Fn=e=>new j.Plugin({key:typeof e.pluginKey=="string"?new j.PluginKey(e.pluginKey):e.pluginKey,view:t=>new qn({view:t,...e})}),Kn=a.defineComponent({name:"BubbleMenu",inheritAttrs:!1,props:{pluginKey:{type:[String,Object],default:"bubbleMenu"},editor:{type:Object,required:!0},updateDelay:{type:Number,default:void 0},resizeDelay:{type:Number,default:void 0},options:{type:Object,default:()=>({})},appendTo:{type:[Object,Function],default:void 0},shouldShow:{type:Function,default:null},getReferencedVirtualElement:{type:Function,default:void 0}},setup(e,{slots:t,attrs:o}){const n=a.ref(null);return a.onMounted(()=>{const{editor:i,options:s,pluginKey:r,resizeDelay:l,appendTo:c,shouldShow:h,getReferencedVirtualElement:u,updateDelay:d}=e,f=n.value;f&&(f.style.visibility="hidden",f.style.position="absolute",f.remove(),a.nextTick(()=>{i.registerPlugin(Fn({editor:i,element:f,options:s,pluginKey:r,resizeDelay:l,appendTo:c,shouldShow:h,getReferencedVirtualElement:u,updateDelay:d}))}))}),a.onBeforeUnmount(()=>{const{pluginKey:i,editor:s}=e;s.unregisterPlugin(i)}),()=>{var i;return a.h("div",{ref:n,...o},(i=t.default)==null?void 0:i.call(t))}}}),Wn=class{constructor({editor:e,element:t,view:o,updateDelay:n=250,resizeDelay:i=60,options:s,appendTo:r,shouldShow:l}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:h,state:u})=>{const{selection:d}=u,{$anchor:f,empty:p}=d,m=f.depth===1,g=f.parent.isTextblock&&!f.parent.type.spec.code&&!f.parent.textContent&&f.parent.childCount===0&&!this.getTextContent(f.parent);return!(!h.hasFocus()||!p||!m||!g||!this.editor.isEditable)},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(h,u,d,f)=>{const{composing:p}=h;if(p||!u&&!d)return;if(!this.getShouldShow(f)){this.hide();return}this.updatePosition(),this.show()},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:h})=>{var u;if(this.preventHide){this.preventHide=!1;return}h!=null&&h.relatedTarget&&((u=this.element.parentNode)!=null&&u.contains(h.relatedTarget))||(h==null?void 0:h.relatedTarget)!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:h})=>{const u=h.getMeta("floatingMenu");u==="updatePosition"?this.updatePosition():u&&typeof u=="object"&&u.type==="updateOptions"&&this.updateOptions(u.options)},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)};var c;this.editor=e,this.element=t,this.view=o,this.updateDelay=n,this.resizeDelay=i,this.appendTo=r,this.scrollTarget=(c=s==null?void 0:s.scrollTarget)!=null?c:window,this.floatingUIOptions={...this.floatingUIOptions,...s},this.element.tabIndex=0,l&&(this.shouldShow=l),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(o,o.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(e){return T.getText(e,{textSerializers:T.getTextSerializersFromSchema(this.editor.schema)})}get middlewares(){const e=[];return this.floatingUIOptions.flip&&e.push(Be(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&e.push(Ie(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&e.push(Ae(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&e.push(bt(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(wt(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&e.push(gt(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&e.push(yt(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&e.push(vt(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),e}getShouldShow(e){var t;const{state:o}=this.view,{selection:n}=o,{ranges:i}=n,s=Math.min(...i.map(c=>c.$from.pos)),r=Math.max(...i.map(c=>c.$to.pos));return(t=this.shouldShow)==null?void 0:t.call(this,{editor:this.editor,view:this.view,state:o,oldState:e,from:s,to:r})}updateOptions(e){var t;if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){const o=(t=e.options.scrollTarget)!=null?t:window;o!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=o,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}updatePosition(){const{selection:e}=this.editor.state,t=T.posToDOMRect(this.view,e.from,e.to);Re({getBoundingClientRect:()=>t,getClientRects:()=>[t]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:n,y:i,strategy:s,middlewareData:r})=>{var l,c;if((l=r.hide)!=null&&l.referenceHidden||(c=r.hide)!=null&&c.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=s,this.element.style.left=`${n}px`,this.element.style.top=`${i}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){const o=!(t!=null&&t.selection.eq(e.state.selection)),n=!(t!=null&&t.doc.eq(e.state.doc));this.updateHandler(e,o,n,t)}show(){var e;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const t=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(e=t??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},Xn=e=>new j.Plugin({key:typeof e.pluginKey=="string"?new j.PluginKey(e.pluginKey):e.pluginKey,view:t=>new Wn({view:t,...e})});a.defineComponent({name:"FloatingMenu",inheritAttrs:!1,props:{pluginKey:{type:null,default:"floatingMenu"},editor:{type:Object,required:!0},updateDelay:{type:Number,default:void 0},resizeDelay:{type:Number,default:void 0},options:{type:Object,default:()=>({})},appendTo:{type:[Object,Function],default:void 0},shouldShow:{type:Function,default:null}},setup(e,{slots:t,attrs:o}){const n=a.ref(null);return a.onMounted(()=>{const{pluginKey:i,editor:s,updateDelay:r,resizeDelay:l,options:c,appendTo:h,shouldShow:u}=e,d=n.value;d&&(d.style.visibility="hidden",d.style.position="absolute",d.remove(),s.registerPlugin(Xn({pluginKey:i,editor:s,element:d,updateDelay:r,resizeDelay:l,options:c,appendTo:h,shouldShow:u})))}),a.onBeforeUnmount(()=>{const{pluginKey:i,editor:s}=e;s.unregisterPlugin(i)}),()=>{var i;return a.h("div",{ref:n,...o},(i=t.default)==null?void 0:i.call(t))}}});const Q=e=>({default:null,parseHTML:t=>t.getAttribute(e),renderHTML:t=>t[e]?{[e]:t[e]}:{}}),Yn=pe.Table.extend({addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),border:Q("border"),cellpadding:Q("cellpadding"),cellspacing:Q("cellspacing"),style:Q("style")}},renderHTML({HTMLAttributes:e}){return["table",T.mergeAttributes(this.options.HTMLAttributes,e),["tbody",0]]}}),Gn=pe.TableRow.extend({addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),style:Q("style")}}}),xt={style:Q("style"),valign:Q("valign"),width:Q("width")},Jn=pe.TableCell.extend({addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),...xt}}}),Zn=pe.TableHeader.extend({addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),...xt}}}),Qn=Je.TextStyle.extend({parseHTML(){var e;return[...((e=this.parent)==null?void 0:e.call(this))||[],{tag:"div",consuming:!1,getAttrs:t=>t.hasAttribute("style")?{}:!1},{tag:"a",consuming:!1,getAttrs:t=>t.hasAttribute("style")?{}:!1}]}}),eo={compatConfig:{MODE:3},name:"EmojiComponent",components:{NodeViewWrapper:S.NodeViewWrapper,DtEmoji:Qe.default},props:S.nodeViewProps};function to(e,t,o,n,i,s){const r=a.resolveComponent("dt-emoji"),l=a.resolveComponent("node-view-wrapper");return a.openBlock(),a.createBlock(l,{class:"d-d-inline-block d-va-bottom d-lh0"},{default:a.withCtx(()=>[a.createVNode(r,{size:"500",code:e.node.attrs.code},null,8,["code"])]),_:1})}const no=F._(eo,[["render",to]]),oo={compatConfig:{MODE:3},name:"SuggestionList",components:{DtListItem:$t.default},props:{items:{type:Array,required:!0},command:{type:Function,required:!0},itemComponent:{type:Object,required:!0},itemType:{type:String,required:!0}},data(){return{selectedIndex:0}},watch:{items(){this.selectedIndex=0}},methods:{onKeyDown({event:e}){return e.key==="ArrowUp"?(this.upHandler(),!0):e.key==="ArrowDown"?(this.downHandler(),!0):e.key==="Enter"||e.key==="Tab"?(this.selectHandler(),!0):!1},upHandler(){this.selectedIndex=(this.selectedIndex+this.items.length-1)%this.items.length,this.scrollActiveElementIntoView()},downHandler(){this.selectedIndex=(this.selectedIndex+1)%this.items.length,this.scrollActiveElementIntoView()},async scrollActiveElementIntoView(){await this.$nextTick();const e=this.$refs.suggestionList.querySelector(".d-list-item--highlighted");e&&e.scrollIntoView({behaviour:"smooth",block:"center"})},selectHandler(){this.selectItem(this.selectedIndex)},selectItem(e){const t=this.items[e];switch(this.itemType){case"emoji":this.command(t);return;case"mention":this.command({name:t.name,id:t.id,avatarSrc:t.avatarSrc,contactKey:t.contactKey});break;case"channel":this.command({name:t.name,id:t.id,locked:t.locked,channelKey:t.channelKey});break;case"slash-command":this.command({command:t.command});break}}}},io={class:"d-popover__dialog d-suggestion-list__container"},so={ref:"suggestionList",class:"d-suggestion-list"};function ro(e,t,o,n,i,s){const r=a.resolveComponent("dt-list-item");return a.openBlock(),a.createElementBlock("div",io,[a.withDirectives(a.createElementVNode("ul",so,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(o.items,(l,c)=>(a.openBlock(),a.createBlock(r,{key:l.id,class:a.normalizeClass(["d-suggestion-list__item",{"d-list-item--highlighted":c===i.selectedIndex}]),"navigation-type":"arrow-keys",onClick:h=>s.selectItem(c),onKeydown:a.withModifiers(s.onKeyDown,["prevent"])},{default:a.withCtx(()=>[(a.openBlock(),a.createBlock(a.resolveDynamicComponent(o.itemComponent),{item:l},null,8,["item"]))]),_:2},1032,["class","onClick","onKeydown"]))),128))],512),[[a.vShow,o.items.length]])])}const ao=F._(oo,[["render",ro]]),_t="top-start",Tt="650";function lo(){return{getBoundingClientRect:()=>({width:0,height:0,x:0,y:0,top:0,left:0,right:0,bottom:0})}}function We(e){return{getBoundingClientRect:e}}async function co(e,t,o={}){if(!e||!(t!=null&&t.getBoundingClientRect))return;const{placement:n=_t,middleware:i=[Ae(0),Be(),Ie({padding:8})]}=o,{x:s,y:r}=await Re(t,e,{placement:n,middleware:i});Object.assign(e.style,{left:`${s}px`,top:`${r}px`})}function uo(e,t={}){const{zIndex:o=Tt}=t;e.style.position="absolute",e.style.zIndex=o,e.style.display="none"}function ho(e){e&&(e.style.display="block")}function fo(e){e&&(e.style.display="none")}function po(e,t){return o=>{o.key==="Escape"&&t()&&e()}}function mo(e){document.addEventListener("keydown",e)}function go(e){document.removeEventListener("keydown",e)}function wo(e,t,o,n){return new S.VueRenderer(e,{props:{itemComponent:a.markRaw(t),itemType:o,...n},editor:n.editor})}function yo(e){var t,o;e.escHandler&&go(e.escHandler),(t=e.floatingEl)==null||t.remove(),(o=e.component)==null||o.destroy()}function be(e,t,o={}){const{listComponent:n=ao,placement:i=_t,zIndex:s=Tt}=o;return()=>{let r=null,l=null,c=!1,h=lo(),u=null;function d(){co(l,h,{placement:i})}function f(){l&&(ho(l),c=!0,d())}function p(){l&&(fo(l),c=!1)}return{onStart:m=>{r=wo(n,e,t,m),m.clientRect&&(l=r.element,uo(l,{zIndex:s}),document.body.appendChild(l),h=We(m.clientRect),u=po(p,()=>c),mo(u),m.items.length>0&&f())},onUpdate(m){r==null||r.updateProps(m),m.items.length>0?f():p(),m.clientRect&&(h=We(m.clientRect),d())},onKeyDown(m){var g;if(c)return(g=r==null?void 0:r.ref)==null?void 0:g.onKeyDown(m)},onExit(){yo({escHandler:u,floatingEl:l,component:r}),u=null,l=null,r=null}}}}const bo={compatConfig:{MODE:3},name:"EmojiSuggestion",components:{DtEmoji:Qe.default,DtStack:le.default},props:{item:{type:Object,required:!0}}};function vo(e,t,o,n,i,s){const r=a.resolveComponent("dt-emoji"),l=a.resolveComponent("dt-stack");return a.openBlock(),a.createBlock(l,{direction:"row",gap:"400"},{default:a.withCtx(()=>[a.createVNode(r,{size:"200",code:o.item.code},null,8,["code"]),a.createTextVNode(" "+a.toDisplayString(o.item.code),1)]),_:1})}const xo=F._(bo,[["render",vo]]),_o=20,To=(e,t,o)=>{var l,c;const n=(l=e.shortname)==null?void 0:l.replaceAll(":",""),i=(c=t.shortname)==null?void 0:c.replaceAll(":",""),s=n.startsWith(o),r=i.startsWith(o);return s&&!r?-1:!s&&r?1:n.localeCompare(i)},Co={items:({query:e})=>{if(e.length<2)return[];const t=Object.values(te.getEmojiData());return e=e.toLowerCase(),t.filter(n=>{var i;return[n.name,(i=n.shortname)==null?void 0:i.replaceAll(":",""),...n.keywords||[]].some(s=>s&&s.startsWith(e))}).splice(0,_o).sort((n,i)=>To(n,i,e)).map(n=>({code:n.shortname}))},command:({editor:e,range:t,props:o})=>{var s,r;const n=e.view.state.selection.$to.nodeAfter;((s=n==null?void 0:n.text)==null?void 0:s.startsWith(" "))&&(t.to+=1),e.chain().focus().insertContentAt(t,[{type:"emoji",attrs:o}]).run(),(r=window.getSelection())==null||r.collapseToEnd()},render:be(xo,"emoji")},ko=/(:\w+:)$/,Eo=new RegExp(Ze.emojiPattern+"$"),Oo=e=>{if(e&&te.codeToEmojiData(e[0]))return{text:e[2]||e[0]}},So=e=>[...e.matchAll(te.emojiShortCodeRegex)].filter(o=>te.codeToEmojiData(o[0])).map(o=>({index:o.index,text:o[0],match:o})),Lo=T.Node.create({name:"emoji",addOptions(){return{HTMLAttributes:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addNodeView(){return S.VueNodeViewRenderer(no)},addAttributes(){return{code:{default:null}}},parseHTML(){return[{tag:"emoji-component"}]},renderText({node:e}){return te.stringToUnicode(te.codeToEmojiData(e.attrs.code).unicode_output)},renderHTML({HTMLAttributes:e}){return["emoji-component",T.mergeAttributes(this.options.HTMLAttributes,e)]},addInputRules(){return[new T.InputRule({find:e=>{const t=e.match(ko)||e.match(Eo);if(t)return Oo(t)},handler:({state:e,range:t,match:o})=>{const{tr:n}=e,i=t.from,s=t.to;n.replaceWith(i,s,this.type.create({code:o[0]}))}})]},addPasteRules(){return[T.nodePasteRule({find:So,type:this.type,getAttributes(e){return{code:e[0]}}}),T.nodePasteRule({find:te.emojiRegex,type:this.type,getAttributes(e){return{code:e[0]}}})]},addProseMirrorPlugins(){return[Vt({char:":",pluginKey:new j.PluginKey("emoji"),editor:this.editor,...this.options.suggestion,...Co})]},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:e,state:t})=>{let o=!1;const{selection:n}=t,{empty:i,anchor:s}=n;return i?(t.doc.nodesBetween(s-1,s,(r,l)=>{if(r.type.name===this.name)return o=!0,e.insertText("",l,l+r.nodeSize),!1}),o):!1})}}});function Do(e,t,o=()=>!0){const n=[];t.lastIndex=0;let i;for(;i=t.exec(e);)o(e,i)&&n.push(i);return n}function Ao(e,t){return!["#","@"].includes(e.charAt(t.index))&&!["#","@"].includes(e.charAt(t.index-1))}function Io(e){const t=new RegExp("(?:"+[`[!?.,:;'"]`,"(?:&|&amp;)(?:lt|gt|quot|apos|raquo|laquo|rsaquo|lsaquo);)+$"].join("|"),"g");return e.replace(t,"")}function Bo(e,t){const o=e.slice(0,t+1).search(/\S+\s*$/),n=e.slice(t).search(/\s/);if(n<0){const i=e.slice(o);return{text:i,from:o,to:o+i.length}}return{text:e.slice(o,n+t),from:o,to:n+t}}function Ce(e,t,o,n){const i=Bo(e,t);if(n.lastIndex=0,!n.test(i.text))return i;const s=o==="left"?i.from-1:i.to+1;return s<=0||s>=e.length||s===t?i:Ce(e,s,o,n)}function Ro(e,t,o,n){const i=Math.max(e.from-1,0),s=Math.min(e.to+1,t.content.size),r=T.getMarksBetween(i,s,t);for(const l of r)l.mark.type===n&&o.removeMark(l.from,l.to,n)}const Xe=re.getPhoneNumberRegex(1,15);function Ye(e,t,o,n,i,s){if(!e)return;let r=o-t-1;r=r<0?0:r;const l=n-t,c=Ce(e,r,"left",Xe),h=Ce(e,l,"right",Xe),u=e.slice(c.from,h.to);Do(u,re.linkRegex,Ao).forEach(f=>{const p=Io(f[0]),m=t+c.from+f.index+1,g=m+p.length;i.addMark(m,g,s.create())})}function Mo(e){let t=!1;return new j.Plugin({key:new j.PluginKey("autolink"),appendTransaction:(o,n,i)=>{const s=o.some(u=>u.docChanged)&&!n.doc.eq(i.doc);if(t&&!s)return;const{tr:r}=i,{textContent:l}=i.doc;t||Ye(l,0,0,l.length,r,e.type),t=!0;const c=T.combineTransactionSteps(n.doc,[...o]);return T.getChangedRanges(c).forEach(({oldRange:u,newRange:d})=>{Ro(d,i.doc,r,e.type),T.findChildrenInRange(i.doc,d,p=>p.isTextblock).forEach(({node:p,pos:m})=>{Ye(p.textContent,m,u.from,d.to,r,e.type)})}),r}})}const No={class:"d-link d-c-text d-d-inline-block d-wb-break-all",rel:"noopener noreferrer nofollow"},Ho=T.Mark.create({name:"CustomLink",renderHTML({HTMLAttributes:e}){return["a",T.mergeAttributes(this.options.HTMLAttributes,e,No)]},renderText({node:e}){return e.attrs.text},addProseMirrorPlugins(){return[Mo({type:this.type})]}}),Vo=Pt.extend({name:"ConfigurableImage",addAttributes(){return{src:{default:""},alt:{default:void 0},title:{default:void 0},width:{default:void 0},height:{default:void 0},style:{default:void 0}}}}).configure({inline:!0,allowBase64:!0}),$o=new Set(["address","article","aside","blockquote","dd","details","dialog","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","li","main","nav","ol","p","pre","section","table","ul"]),Po=Ge.extend({parseHTML(){return[{tag:"div",getAttrs:e=>{for(const t of e.children)if($o.has(t.tagName.toLowerCase()))return!1;return null}}]},renderHTML({HTMLAttributes:e}){return["div",T.mergeAttributes(this.options.HTMLAttributes,e),0]}}),Uo={compatConfig:{MODE:3},name:"MentionComponent",components:{NodeViewWrapper:S.NodeViewWrapper,DtLink:et.default},props:S.nodeViewProps,computed:{text(){return"@"+this.$props.node.attrs.name}},methods:{getMentionData(){return{name:this.$props.node.attrs.name,id:this.$props.node.attrs.id,avatarSrc:this.$props.node.attrs.avatarSrc,contactKey:this.$props.node.attrs.contactKey}},handleClick(){this.$props.editor.emit("mention-click",this.getMentionData())},handleMouseEnter(e){this.$props.editor.emit("mention-hover",{...this.getMentionData(),event:e})},handleMouseLeave(e){this.$props.editor.emit("mention-leave",{...this.getMentionData(),event:e})}}};function jo(e,t,o,n,i,s){const r=a.resolveComponent("dt-link"),l=a.resolveComponent("node-view-wrapper");return a.openBlock(),a.createBlock(l,{class:"d-d-inline-block"},{default:a.withCtx(()=>[a.createVNode(r,{kind:"mention",onClick:a.withModifiers(s.handleClick,["prevent"]),onMouseenter:s.handleMouseEnter,onMouseleave:s.handleMouseLeave,onFocusin:s.handleMouseEnter,onFocusout:s.handleMouseLeave},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(s.text),1)]),_:1},8,["onClick","onMouseenter","onMouseleave","onFocusin","onFocusout"])]),_:1})}const zo=F._(Uo,[["render",jo]]),qo=ke.extend({addNodeView(){return S.VueNodeViewRenderer(zo)},parseHTML(){return[{tag:"mention-component"}]},addAttributes(){return{name:{default:""},avatarSrc:{default:""},id:{default:""},contactKey:{default:""}}},renderText({node:e}){return`@${e.attrs.id}`},renderHTML({HTMLAttributes:e}){return["mention-component",T.mergeAttributes(this.options.HTMLAttributes,e)]}}).configure({suggestion:{char:"@",pluginKey:new j.PluginKey("mentionSuggestion")}}),Fo={compatConfig:{MODE:3},name:"ChannelComponent",components:{NodeViewWrapper:S.NodeViewWrapper,DtLink:et.default,DtIconLock:Ut.DtIconLock,DtStack:le.default},props:S.nodeViewProps,computed:{text(){return this.$props.node.attrs.locked?this.$props.node.attrs.name:"#"+this.$props.node.attrs.name}},methods:{handleClick(){const e={name:this.$props.node.attrs.name,id:this.$props.node.attrs.id,locked:this.$props.node.attrs.locked,channelKey:this.$props.node.attrs.channelKey};this.$props.editor.emit("channel-click",e)}}};function Ko(e,t,o,n,i,s){const r=a.resolveComponent("dt-icon-lock"),l=a.resolveComponent("dt-stack"),c=a.resolveComponent("dt-link"),h=a.resolveComponent("node-view-wrapper");return a.openBlock(),a.createBlock(h,{class:"d-d-inline-block"},{default:a.withCtx(()=>[a.createVNode(c,{kind:"mention",onClick:a.withModifiers(s.handleClick,["prevent"])},{default:a.withCtx(()=>[a.createVNode(l,{direction:"row",gap:"0"},{default:a.withCtx(()=>[e.$props.node.attrs.locked?(a.openBlock(),a.createBlock(r,{key:0,size:"200"})):a.createCommentVNode("",!0),a.createElementVNode("span",null,a.toDisplayString(s.text),1)]),_:1})]),_:1},8,["onClick"])]),_:1})}const Wo=F._(Fo,[["render",Ko]]),Xo=ke.extend({name:"channel",addNodeView(){return S.VueNodeViewRenderer(Wo)},parseHTML(){return[{tag:"channel-component"}]},addAttributes(){return{name:{default:""},id:{default:""},locked:{default:!1},channelKey:{default:""}}},renderText({node:e}){return`#${e.attrs.id}`},renderHTML({HTMLAttributes:e}){return["channel-component",T.mergeAttributes(this.options.HTMLAttributes,e)]}}).configure({suggestion:{char:"#",pluginKey:new j.PluginKey("channelSuggestion")}}),Yo={compatConfig:{MODE:3},name:"SlashCommandsComponent",components:{NodeViewWrapper:S.NodeViewWrapper},props:{...S.nodeViewProps},emits:["selected-command"],computed:{text(){return"/"+this.$props.node.attrs.command}},created(){var o,n,i;const e=this.$props.node.attrs.command;this.$emit("selected-command",e);const t=(i=(n=(o=this.editor)==null?void 0:o.storage)==null?void 0:n["slash-commands"])==null?void 0:i.onSelectedCommand;t&&typeof t=="function"&&t(e)}};function Go(e,t,o,n,i,s){const r=a.resolveComponent("node-view-wrapper");return a.openBlock(),a.createBlock(r,{class:"d-d-inline-block"},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(s.text),1)]),_:1})}const Jo=F._(Yo,[["render",Go]]),Zo=(e,t)=>[...e.matchAll(t)].map(n=>{let i=n[2];return i.endsWith(" ")||(i+=" "),{index:n.index,text:i,match:n}}),Qo=ke.extend({name:"slash-commands",group:"inline",inline:!0,addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),onSelectedCommand:null}},addStorage(){return{onSelectedCommand:this.options.onSelectedCommand}},addNodeView(){return S.VueNodeViewRenderer(Jo)},parseHTML(){return[{tag:"command-component"}]},addAttributes(){return{command:{default:""},parametersExample:{default:""},description:{default:""}}},renderText({node:e}){return`/${e.attrs.command}`},renderHTML({HTMLAttributes:e}){return["command-component",T.mergeAttributes(this.options.HTMLAttributes,e)]},addInputRules(){var o;const e=(o=this.options.suggestion)==null?void 0:o.items({query:""}).map(n=>n.command),t=new RegExp(`^((?:\\/)(${e.join("|")})) $`);return[T.nodeInputRule({find:t,type:this.type,getAttributes(n){return{command:n[2]}}})]},addPasteRules(){var o;const e=(o=this.options.suggestion)==null?void 0:o.items({query:""}).map(n=>n.command),t=new RegExp(`^((?:\\/)(${e.join("|")})) ?$`,"g");return[T.nodePasteRule({find:n=>Zo(n,t),type:this.type,getAttributes(n){return{command:n[0].trim()}}})]}}).configure({suggestion:{char:"/",pluginKey:new j.PluginKey("slashCommandSuggestion")}}),ei=100,ti={name:"VariableComponent",components:{DtBadge:qt.default,DtButton:nt.default,DtPopover:zt.default,DtInput:jt.default,NodeViewWrapper:S.NodeViewWrapper},props:S.nodeViewProps,data(){return{i18n:new tt.DialtoneLocalization,MAX_VARIABLE_ALT_LENGTH:ei}},computed:{altText:{get(){var e,t;return((t=(e=this.node)==null?void 0:e.attrs)==null?void 0:t.altText)||""},set(e){this.updateAttributes({altText:e})}},variableId(){var e,t;return(t=(e=this.node)==null?void 0:e.attrs)==null?void 0:t.id},placeholder(){var e;return((e=this.variableData)==null?void 0:e.placeholder)||""},variableItems(){var e,t;return((t=(e=this.extension)==null?void 0:e.options)==null?void 0:t.variableItems)||[]},variableData(){return this.variableItems.find(e=>e.id===this.variableId)},enableAltText(){var e,t;return(t=(e=this.node)==null?void 0:e.attrs)==null?void 0:t.enableAltText},badgeLabel(){return`{} ${this.placeholder}`},placeholderText(){return`Replaces ${this.placeholder}`}}};function ni(e,t,o,n,i,s){const r=a.resolveComponent("dt-badge"),l=a.resolveComponent("dt-button"),c=a.resolveComponent("dt-input"),h=a.resolveComponent("dt-popover"),u=a.resolveComponent("node-view-wrapper");return a.openBlock(),a.createBlock(u,{class:"d-d-inline-block"},{default:a.withCtx(()=>[s.enableAltText?(a.openBlock(),a.createBlock(h,{key:0,padding:"small","navigation-type":"arrow-keys",placement:"top-start",modal:!1},{anchor:a.withCtx(({attrs:d})=>[a.createVNode(l,a.mergeProps(d,{kind:"unstyled"}),{default:a.withCtx(()=>[a.createVNode(r,{text:s.badgeLabel,contenteditable:"false"},null,8,["text"])]),_:1},16)]),content:a.withCtx(({close:d})=>[a.createVNode(c,{modelValue:s.altText,"onUpdate:modelValue":t[0]||(t[0]=f=>s.altText=f),"root-class":"d-p8 d-w332",label:i.i18n.$t("DIALTONE_EDITOR_VARIABLE_LABEL"),placeholder:s.placeholderText,validate:{length:{description:i.i18n.$t("DIALTONE_EDITOR_VARIABLE_VALIDATE_DESCRIPTION"),message:i.i18n.$t("DIALTONE_EDITOR_VARIABLE_VALIDATE_MESSAGE"),max:i.MAX_VARIABLE_ALT_LENGTH,warn:i.MAX_VARIABLE_ALT_LENGTH,limitMaxLength:!0}},onKeyup:a.withKeys(f=>d(),["enter"])},null,8,["modelValue","label","placeholder","validate","onKeyup"])]),_:1})):(a.openBlock(),a.createBlock(r,{key:1,text:s.badgeLabel,contenteditable:"false"},null,8,["text"]))]),_:1})}const oi=F._(ti,[["render",ni]]),ii=T.Node.create({name:"variable",group:"inline",inline:!0,selectable:!0,atom:!0,addOptions(){return{HTMLAttributes:{},variableItems:[]}},addNodeView(){return S.VueNodeViewRenderer(oi)},addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute("data-variable-id"),renderHTML:e=>e.id?{"data-variable-id":e.id}:{}},altText:{default:"",parseHTML:e=>e.getAttribute("data-alt-text"),renderHTML:e=>e.altText?{"data-alt-text":e.altText}:{}},enableAltText:{default:!0,parseHTML:e=>e.getAttribute("data-enable-alt-text")==="true",renderHTML:e=>({"data-enable-alt-text":String(e.enableAltText)})}}},parseHTML(){return[{tag:"variable"}]},renderText({node:e}){return e.attrs.altText},renderHTML({node:e,HTMLAttributes:t}){return["variable",T.mergeAttributes(this.options.HTMLAttributes,t,{"data-variable-id":e.attrs.id,"data-alt-text":e.attrs.altText,"data-enable-alt-text":String(e.attrs.enableAltText)})]},addCommands(){return{insertVariable:(e={})=>({commands:t})=>t.insertContent({type:this.name,attrs:{id:e.id||null,altText:e.altText||"",enableAltText:e.enableAltText}})}}}),si={compatConfig:{MODE:3},name:"MentionSuggestion",components:{DtAvatar:Ft.default,DtStack:le.default},props:{item:{type:Object,required:!0}},computed:{name(){return this.item.name},avatarSrc(){return this.item.avatarSrc},presence(){return this.item.presence},status(){return this.item.status},presenceText(){return this.item.presenceText},presenceFontColorClass(){return{active:"d-recipe-contact-row--active",busy:"d-recipe-contact-row--busy",away:"d-recipe-contact-row--away",offline:"d-recipe-contact-row--busy"}[this.presence]},showDetails(){return this.item.showDetails}}},ri={class:"d-mention-suggestion__name"},ai={key:1,class:"d-mention-suggestion__divider"},li={key:2,class:"d-mention-suggestion__status"};function ci(e,t,o,n,i,s){const r=a.resolveComponent("dt-avatar"),l=a.resolveComponent("dt-stack");return a.openBlock(),a.createBlock(l,{direction:"row",class:"d-mention-suggestion__container",gap:"400"},{default:a.withCtx(()=>[a.createVNode(r,{"full-name":s.name,"image-src":s.avatarSrc,"image-alt":s.name,"show-presence":s.showDetails,presence:s.presence,size:"sm"},null,8,["full-name","image-src","image-alt","show-presence","presence"]),a.createVNode(l,{class:"d-mention-suggestion__details-container",gap:"100"},{default:a.withCtx(()=>[a.createElementVNode("span",ri,a.toDisplayString(s.name),1),s.showDetails?(a.openBlock(),a.createBlock(l,{key:0,direction:"row",gap:"300",class:"d-label--sm-plain"},{default:a.withCtx(()=>[s.presenceText?(a.openBlock(),a.createElementBlock("span",{key:0,class:a.normalizeClass(["d-mention-suggestion__presence",[s.presenceFontColorClass]])},a.toDisplayString(s.presenceText),3)):a.createCommentVNode("",!0),s.status&&s.presenceText?(a.openBlock(),a.createElementBlock("div",ai," • ")):a.createCommentVNode("",!0),s.status?(a.openBlock(),a.createElementBlock("div",li,a.toDisplayString(s.status),1)):a.createCommentVNode("",!0)]),_:1})):a.createCommentVNode("",!0)]),_:1})]),_:1})}const di=F._(si,[["render",ci]]),ui={allowSpaces:!0,render:be(di,"mention")},hi={compatConfig:{MODE:3},name:"ChannelSuggestion",components:{DtStack:le.default,DtIconHash:Kt,DtIconLock:Wt},props:{item:{type:Object,required:!0}},computed:{name(){return this.item.name}}};function fi(e,t,o,n,i,s){const r=a.resolveComponent("dt-icon-hash"),l=a.resolveComponent("dt-icon-lock"),c=a.resolveComponent("dt-stack");return a.openBlock(),a.createBlock(c,{direction:"row",gap:"400"},{default:a.withCtx(()=>[o.item.locked?(a.openBlock(),a.createBlock(l,{key:1,size:"300"})):(a.openBlock(),a.createBlock(r,{key:0,size:"300"})),a.createElementVNode("span",null,a.toDisplayString(s.name),1)]),_:1})}const pi=F._(hi,[["render",fi]]),mi={allowSpaces:!0,render:be(pi,"channel")},gi={compatConfig:{MODE:3},name:"SlashCommandSuggestion",props:{item:{type:Object,required:!0}},computed:{command(){return this.item.command},description(){return this.item.description},parametersExample(){return this.item.parametersExample}}},wi={class:"d-body--md-compact"},yi={key:0},bi={class:"d-body--sm d-fc-tertiary"};function vi(e,t,o,n,i,s){return a.openBlock(),a.createElementBlock("div",null,[a.createElementVNode("div",wi,[a.createElementVNode("span",null,"/"+a.toDisplayString(s.command),1),s.parametersExample?(a.openBlock(),a.createElementBlock("span",yi,a.toDisplayString(s.parametersExample),1)):a.createCommentVNode("",!0)]),a.createElementVNode("div",bi,a.toDisplayString(s.description),1)])}const xi=F._(gi,[["render",vi]]),_i={allowSpaces:!0,startOfLine:!0,render:be(xi,"slash-command")},Ti={compatConfig:{MODE:3},name:"DtRichTextEditor",components:{EditorContent:S.EditorContent,BubbleMenu:Kn,DtButton:nt.default,DtStack:le.default},props:{modelValue:{type:[Object,String],default:""},editable:{type:Boolean,default:!0},preventTyping:{type:Boolean,default:!1},pasteRichText:{type:Boolean,default:!0},allowLineBreaks:{type:Boolean,default:!1},inputAriaLabel:{type:String,required:!0},inputClass:{type:String,default:""},autoFocus:{type:[Boolean,String,Number],default:!1,validator(e){return typeof e=="string"?de.RICH_TEXT_EDITOR_AUTOFOCUS_TYPES.includes(e):!0}},outputFormat:{type:String,default:"html",validator(e){return de.RICH_TEXT_EDITOR_OUTPUT_FORMATS.includes(e)}},placeholder:{type:String,default:""},link:{type:[Boolean,Object],default:!1},customLink:{type:[Boolean,Object],default:!1},mentionSuggestion:{type:Object,default:null},channelSuggestion:{type:Object,default:null},slashCommandSuggestion:{type:Object,default:null},allowBlockquote:{type:Boolean,default:!0},allowBold:{type:Boolean,default:!0},allowBulletList:{type:Boolean,default:!0},allowItalic:{type:Boolean,default:!0},allowStrike:{type:Boolean,default:!0},allowUnderline:{type:Boolean,default:!0},allowCode:{type:Boolean,default:!0},allowCodeblock:{type:Boolean,default:!0},allowInlineImages:{type:Boolean,default:!1},allowFontColor:{type:Boolean,default:!1},allowBackgroundColor:{type:Boolean,default:!1},allowFontSize:{type:Boolean,default:!1},allowFontFamily:{type:Boolean,default:!1},allowLineHeight:{type:Boolean,default:!1},allowVariable:{type:Boolean,default:!1},variableItems:{type:Array,default:()=>[]},additionalExtensions:{type:Array,default:()=>[]},hideLinkBubbleMenu:{type:Boolean,default:!1},preserveWhitespace:{type:[Boolean,String],default:"full"},useDivTags:{type:Boolean,default:!1},allowTables:{type:Boolean,default:!1},allowImageResize:{type:Boolean,default:!1}},emits:["input","json-input","html-input","text-input","markdown-input","update:modelValue","blur","focus","enter","edit-link","selected","selected-command","mention-click","mention-hover","mention-leave","channel-click"],data(){return{editor:null,appendTo:()=>{var e;return(e=re.returnFirstEl(this.$refs.editor.$el).getRootNode())==null?void 0:e.querySelector("body")},floatingOptions:{placement:"top-start"},i18n:new tt.DialtoneLocalization,jsonToMarkdownConverter:{convertToMarkdown(e){return this.processNode(e)},processNodeContent(e){return e.content?e.content.map(t=>this.processNode(t)).join(""):""},processNode(e){if(!e)return"";const o={doc:n=>this.processDocNode(n),paragraph:n=>this.processParagraphNode(n),text:n=>this.processTextNode(n),hardBreak:()=>this.processHardBreakNode(),blockquote:n=>this.processBlockquoteNode(n),bulletList:n=>this.processBulletListNode(n),orderedList:n=>this.processOrderedListNode(n),listItem:n=>this.processListItemNode(n),codeBlock:n=>this.processCodeBlockNode(n),mention:n=>this.processMentionNode(n),channel:n=>this.processChannelNode(n),"slash-commands":n=>this.processSlashCommandsNode(n),emoji:n=>this.processEmojiNode(n),variable:n=>this.processVariableNode(n)}[e.type];return o?o(e):this.processUnknownNode(e)},processDocNode(e){return this.processNodeContent(e)},processParagraphNode(e){const t=this.processNodeContent(e);return t?t+`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const S=require("../../node_modules/@tiptap/vue-3.cjs"),T=require("@tiptap/core"),j=require("@tiptap/pm/state"),kt=require("@tiptap/pm/tables"),a=require("vue"),Et=require("@tiptap/extension-blockquote"),Ot=require("@tiptap/extension-code-block"),St=require("@tiptap/extension-code"),Lt=require("@tiptap/extension-document"),ve=require("@tiptap/extensions"),At=require("@tiptap/extension-hard-break"),Ge=require("@tiptap/extension-paragraph"),Dt=require("@tiptap/extension-bold"),xe=require("@tiptap/extension-list"),It=require("@tiptap/extension-italic"),Bt=require("@tiptap/extension-link"),Rt=require("@tiptap/extension-strike"),Mt=require("@tiptap/extension-underline"),Nt=require("@tiptap/extension-text"),Ht=require("@tiptap/extension-text-align"),pe=require("@tiptap/extension-table"),Je=require("@tiptap/extension-text-style"),Vt=require("@tiptap/suggestion"),Ze=require("regex-combined-emojis"),F=require("../../_plugin-vue_export-helper-BRilXfQE.cjs"),Qe=require("../emoji/emoji.cjs"),te=require("../../common/emoji/index.cjs"),$t=require("../list-item/list-item.cjs"),le=require("../stack/stack.cjs"),re=require("../../common/utils/index.cjs"),Pt=require("@tiptap/extension-image"),ke=require("@tiptap/extension-mention"),et=require("../link/link.cjs"),Ut=require("@dialpad/dialtone-icons/vue3"),tt=require("../../localization/index.cjs"),jt=require("../input/input.cjs"),zt=require("../popover/popover.cjs"),nt=require("../button/button.cjs"),qt=require("../badge/badge.cjs"),de=require("./rich-text-editor-constants.cjs"),Ft=require("../avatar/avatar.cjs"),Kt=require("@dialpad/dialtone-icons/vue3/hash"),Wt=require("@dialpad/dialtone-icons/vue3/lock"),Xt=require("deep-equal"),ot=["top","right","bottom","left"],Me=["start","end"],Ne=ot.reduce((e,t)=>e.concat(t,t+"-"+Me[0],t+"-"+Me[1]),[]),X=Math.min,I=Math.max,ue=Math.round,W=e=>({x:e,y:e}),Yt={left:"right",right:"left",bottom:"top",top:"bottom"},Gt={start:"end",end:"start"};function Te(e,t,o){return I(e,X(t,o))}function G(e,t){return typeof e=="function"?e(t):e}function $(e){return e.split("-")[0]}function U(e){return e.split("-")[1]}function it(e){return e==="x"?"y":"x"}function Ee(e){return e==="y"?"height":"width"}const Jt=new Set(["top","bottom"]);function K(e){return Jt.has($(e))?"y":"x"}function Oe(e){return it(K(e))}function st(e,t,o){o===void 0&&(o=!1);const n=U(e),i=Oe(e),s=Ee(i);let r=i==="x"?n===(o?"end":"start")?"right":"left":n==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(r=fe(r)),[r,fe(r)]}function Zt(e){const t=fe(e);return[he(e),t,he(t)]}function he(e){return e.replace(/start|end/g,t=>Gt[t])}const He=["left","right"],Ve=["right","left"],Qt=["top","bottom"],en=["bottom","top"];function tn(e,t,o){switch(e){case"top":case"bottom":return o?t?Ve:He:t?He:Ve;case"left":case"right":return t?Qt:en;default:return[]}}function nn(e,t,o,n){const i=U(e);let s=tn($(e),o==="start",n);return i&&(s=s.map(r=>r+"-"+i),t&&(s=s.concat(s.map(he)))),s}function fe(e){return e.replace(/left|right|bottom|top/g,t=>Yt[t])}function on(e){return{top:0,right:0,bottom:0,left:0,...e}}function Se(e){return typeof e!="number"?on(e):{top:e,right:e,bottom:e,left:e}}function oe(e){const{x:t,y:o,width:n,height:i}=e;return{width:n,height:i,top:o,left:t,right:t+n,bottom:o+i,x:t,y:o}}function $e(e,t,o){let{reference:n,floating:i}=e;const s=K(t),r=Oe(t),l=Ee(r),c=$(t),h=s==="y",u=n.x+n.width/2-i.width/2,d=n.y+n.height/2-i.height/2,f=n[l]/2-i[l]/2;let p;switch(c){case"top":p={x:u,y:n.y-i.height};break;case"bottom":p={x:u,y:n.y+n.height};break;case"right":p={x:n.x+n.width,y:d};break;case"left":p={x:n.x-i.width,y:d};break;default:p={x:n.x,y:n.y}}switch(U(t)){case"start":p[r]-=f*(o&&h?-1:1);break;case"end":p[r]+=f*(o&&h?-1:1);break}return p}async function sn(e,t){var o;t===void 0&&(t={});const{x:n,y:i,platform:s,rects:r,elements:l,strategy:c}=e,{boundary:h="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:p=0}=G(t,e),m=Se(p),w=l[f?d==="floating"?"reference":"floating":d],y=oe(await s.getClippingRect({element:(o=await(s.isElement==null?void 0:s.isElement(w)))==null||o?w:w.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:h,rootBoundary:u,strategy:c})),v=d==="floating"?{x:n,y:i,width:r.floating.width,height:r.floating.height}:r.reference,x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),_=await(s.isElement==null?void 0:s.isElement(x))?await(s.getScale==null?void 0:s.getScale(x))||{x:1,y:1}:{x:1,y:1},k=oe(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:v,offsetParent:x,strategy:c}):v);return{top:(y.top-k.top+m.top)/_.y,bottom:(k.bottom-y.bottom+m.bottom)/_.y,left:(y.left-k.left+m.left)/_.x,right:(k.right-y.right+m.right)/_.x}}const rn=async(e,t,o)=>{const{placement:n="bottom",strategy:i="absolute",middleware:s=[],platform:r}=o,l=s.filter(Boolean),c=await(r.isRTL==null?void 0:r.isRTL(t));let h=await r.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=$e(h,n,c),f=n,p={},m=0;for(let w=0;w<l.length;w++){var g;const{name:y,fn:v}=l[w],{x,y:_,data:k,reset:C}=await v({x:u,y:d,initialPlacement:n,placement:f,strategy:i,middlewareData:p,rects:h,platform:{...r,detectOverflow:(g=r.detectOverflow)!=null?g:sn},elements:{reference:e,floating:t}});u=x??u,d=_??d,p={...p,[y]:{...p[y],...k}},C&&m<=50&&(m++,typeof C=="object"&&(C.placement&&(f=C.placement),C.rects&&(h=C.rects===!0?await r.getElementRects({reference:e,floating:t,strategy:i}):C.rects),{x:u,y:d}=$e(h,f,c)),w=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:p}},an=e=>({name:"arrow",options:e,async fn(t){const{x:o,y:n,placement:i,rects:s,platform:r,elements:l,middlewareData:c}=t,{element:h,padding:u=0}=G(e,t)||{};if(h==null)return{};const d=Se(u),f={x:o,y:n},p=Oe(i),m=Ee(p),g=await r.getDimensions(h),w=p==="y",y=w?"top":"left",v=w?"bottom":"right",x=w?"clientHeight":"clientWidth",_=s.reference[m]+s.reference[p]-f[p]-s.floating[m],k=f[p]-s.reference[p],C=await(r.getOffsetParent==null?void 0:r.getOffsetParent(h));let L=C?C[x]:0;(!L||!await(r.isElement==null?void 0:r.isElement(C)))&&(L=l.floating[x]||s.floating[m]);const H=_/2-k/2,A=L/2-g[m]/2-1,b=X(d[y],A),E=X(d[v],A),D=b,B=L-g[m]-E,O=L/2-g[m]/2+H,P=Te(D,O,B),V=!c.arrow&&U(i)!=null&&O!==P&&s.reference[m]/2-(O<D?b:E)-g[m]/2<0,R=V?O<D?O-D:O-B:0;return{[p]:f[p]+R,data:{[p]:P,centerOffset:O-P-R,...V&&{alignmentOffset:R}},reset:V}}});function ln(e,t,o){return(e?[...o.filter(i=>U(i)===e),...o.filter(i=>U(i)!==e)]:o.filter(i=>$(i)===i)).filter(i=>e?U(i)===e||(t?he(i)!==i:!1):!0)}const cn=function(e){return e===void 0&&(e={}),{name:"autoPlacement",options:e,async fn(t){var o,n,i;const{rects:s,middlewareData:r,placement:l,platform:c,elements:h}=t,{crossAxis:u=!1,alignment:d,allowedPlacements:f=Ne,autoAlignment:p=!0,...m}=G(e,t),g=d!==void 0||f===Ne?ln(d||null,p,f):f,w=await c.detectOverflow(t,m),y=((o=r.autoPlacement)==null?void 0:o.index)||0,v=g[y];if(v==null)return{};const x=st(v,s,await(c.isRTL==null?void 0:c.isRTL(h.floating)));if(l!==v)return{reset:{placement:g[0]}};const _=[w[$(v)],w[x[0]],w[x[1]]],k=[...((n=r.autoPlacement)==null?void 0:n.overflows)||[],{placement:v,overflows:_}],C=g[y+1];if(C)return{data:{index:y+1,overflows:k},reset:{placement:C}};const L=k.map(b=>{const E=U(b.placement);return[b.placement,E&&u?b.overflows.slice(0,2).reduce((D,B)=>D+B,0):b.overflows[0],b.overflows]}).sort((b,E)=>b[1]-E[1]),A=((i=L.filter(b=>b[2].slice(0,U(b[0])?2:3).every(E=>E<=0))[0])==null?void 0:i[0])||L[0][0];return A!==l?{data:{index:y+1,overflows:k},reset:{placement:A}}:{}}}},dn=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var o,n;const{placement:i,middlewareData:s,rects:r,initialPlacement:l,platform:c,elements:h}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:g=!0,...w}=G(e,t);if((o=s.arrow)!=null&&o.alignmentOffset)return{};const y=$(i),v=K(l),x=$(l)===l,_=await(c.isRTL==null?void 0:c.isRTL(h.floating)),k=f||(x||!g?[fe(l)]:Zt(l)),C=m!=="none";!f&&C&&k.push(...nn(l,g,m,_));const L=[l,...k],H=await c.detectOverflow(t,w),A=[];let b=((n=s.flip)==null?void 0:n.overflows)||[];if(u&&A.push(H[y]),d){const O=st(i,r,_);A.push(H[O[0]],H[O[1]])}if(b=[...b,{placement:i,overflows:A}],!A.every(O=>O<=0)){var E,D;const O=(((E=s.flip)==null?void 0:E.index)||0)+1,P=L[O];if(P&&(!(d==="alignment"?v!==K(P):!1)||b.every(M=>K(M.placement)===v?M.overflows[0]>0:!0)))return{data:{index:O,overflows:b},reset:{placement:P}};let V=(D=b.filter(R=>R.overflows[0]<=0).sort((R,M)=>R.overflows[1]-M.overflows[1])[0])==null?void 0:D.placement;if(!V)switch(p){case"bestFit":{var B;const R=(B=b.filter(M=>{if(C){const Z=K(M.placement);return Z===v||Z==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(Z=>Z>0).reduce((Z,Ct)=>Z+Ct,0)]).sort((M,Z)=>M[1]-Z[1])[0])==null?void 0:B[0];R&&(V=R);break}case"initialPlacement":V=l;break}if(i!==V)return{reset:{placement:V}}}return{}}}};function Pe(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Ue(e){return ot.some(t=>e[t]>=0)}const un=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:o,platform:n}=t,{strategy:i="referenceHidden",...s}=G(e,t);switch(i){case"referenceHidden":{const r=await n.detectOverflow(t,{...s,elementContext:"reference"}),l=Pe(r,o.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:Ue(l)}}}case"escaped":{const r=await n.detectOverflow(t,{...s,altBoundary:!0}),l=Pe(r,o.floating);return{data:{escapedOffsets:l,escaped:Ue(l)}}}default:return{}}}}};function rt(e){const t=X(...e.map(s=>s.left)),o=X(...e.map(s=>s.top)),n=I(...e.map(s=>s.right)),i=I(...e.map(s=>s.bottom));return{x:t,y:o,width:n-t,height:i-o}}function hn(e){const t=e.slice().sort((i,s)=>i.y-s.y),o=[];let n=null;for(let i=0;i<t.length;i++){const s=t[i];!n||s.y-n.y>n.height/2?o.push([s]):o[o.length-1].push(s),n=s}return o.map(i=>oe(rt(i)))}const fn=function(e){return e===void 0&&(e={}),{name:"inline",options:e,async fn(t){const{placement:o,elements:n,rects:i,platform:s,strategy:r}=t,{padding:l=2,x:c,y:h}=G(e,t),u=Array.from(await(s.getClientRects==null?void 0:s.getClientRects(n.reference))||[]),d=hn(u),f=oe(rt(u)),p=Se(l);function m(){if(d.length===2&&d[0].left>d[1].right&&c!=null&&h!=null)return d.find(w=>c>w.left-p.left&&c<w.right+p.right&&h>w.top-p.top&&h<w.bottom+p.bottom)||f;if(d.length>=2){if(K(o)==="y"){const b=d[0],E=d[d.length-1],D=$(o)==="top",B=b.top,O=E.bottom,P=D?b.left:E.left,V=D?b.right:E.right,R=V-P,M=O-B;return{top:B,bottom:O,left:P,right:V,width:R,height:M,x:P,y:B}}const w=$(o)==="left",y=I(...d.map(b=>b.right)),v=X(...d.map(b=>b.left)),x=d.filter(b=>w?b.left===v:b.right===y),_=x[0].top,k=x[x.length-1].bottom,C=v,L=y,H=L-C,A=k-_;return{top:_,bottom:k,left:C,right:L,width:H,height:A,x:C,y:_}}return f}const g=await s.getElementRects({reference:{getBoundingClientRect:m},floating:n.floating,strategy:r});return i.reference.x!==g.reference.x||i.reference.y!==g.reference.y||i.reference.width!==g.reference.width||i.reference.height!==g.reference.height?{reset:{rects:g}}:{}}}},pn=new Set(["left","top"]);async function mn(e,t){const{placement:o,platform:n,elements:i}=e,s=await(n.isRTL==null?void 0:n.isRTL(i.floating)),r=$(o),l=U(o),c=K(o)==="y",h=pn.has(r)?-1:1,u=s&&c?-1:1,d=G(t,e);let{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return l&&typeof m=="number"&&(p=l==="end"?m*-1:m),c?{x:p*u,y:f*h}:{x:f*h,y:p*u}}const gn=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var o,n;const{x:i,y:s,placement:r,middlewareData:l}=t,c=await mn(t,e);return r===((o=l.offset)==null?void 0:o.placement)&&(n=l.arrow)!=null&&n.alignmentOffset?{}:{x:i+c.x,y:s+c.y,data:{...c,placement:r}}}}},wn=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:o,y:n,placement:i,platform:s}=t,{mainAxis:r=!0,crossAxis:l=!1,limiter:c={fn:y=>{let{x:v,y:x}=y;return{x:v,y:x}}},...h}=G(e,t),u={x:o,y:n},d=await s.detectOverflow(t,h),f=K($(i)),p=it(f);let m=u[p],g=u[f];if(r){const y=p==="y"?"top":"left",v=p==="y"?"bottom":"right",x=m+d[y],_=m-d[v];m=Te(x,m,_)}if(l){const y=f==="y"?"top":"left",v=f==="y"?"bottom":"right",x=g+d[y],_=g-d[v];g=Te(x,g,_)}const w=c.fn({...t,[p]:m,[f]:g});return{...w,data:{x:w.x-o,y:w.y-n,enabled:{[p]:r,[f]:l}}}}}},yn=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var o,n;const{placement:i,rects:s,platform:r,elements:l}=t,{apply:c=()=>{},...h}=G(e,t),u=await r.detectOverflow(t,h),d=$(i),f=U(i),p=K(i)==="y",{width:m,height:g}=s.floating;let w,y;d==="top"||d==="bottom"?(w=d,y=f===(await(r.isRTL==null?void 0:r.isRTL(l.floating))?"start":"end")?"left":"right"):(y=d,w=f==="end"?"top":"bottom");const v=g-u.top-u.bottom,x=m-u.left-u.right,_=X(g-u[w],v),k=X(m-u[y],x),C=!t.middlewareData.shift;let L=_,H=k;if((o=t.middlewareData.shift)!=null&&o.enabled.x&&(H=x),(n=t.middlewareData.shift)!=null&&n.enabled.y&&(L=v),C&&!f){const b=I(u.left,0),E=I(u.right,0),D=I(u.top,0),B=I(u.bottom,0);p?H=m-2*(b!==0||E!==0?b+E:I(u.left,u.right)):L=g-2*(D!==0||B!==0?D+B:I(u.top,u.bottom))}await c({...t,availableWidth:H,availableHeight:L});const A=await r.getDimensions(l.floating);return m!==A.width||g!==A.height?{reset:{rects:!0}}:{}}}};function me(){return typeof window<"u"}function se(e){return at(e)?(e.nodeName||"").toLowerCase():"#document"}function N(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function J(e){var t;return(t=(at(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function at(e){return me()?e instanceof Node||e instanceof N(e).Node:!1}function z(e){return me()?e instanceof Element||e instanceof N(e).Element:!1}function Y(e){return me()?e instanceof HTMLElement||e instanceof N(e).HTMLElement:!1}function je(e){return!me()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof N(e).ShadowRoot}const bn=new Set(["inline","contents"]);function ce(e){const{overflow:t,overflowX:o,overflowY:n,display:i}=q(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+o)&&!bn.has(i)}const vn=new Set(["table","td","th"]);function xn(e){return vn.has(se(e))}const _n=[":popover-open",":modal"];function ge(e){return _n.some(t=>{try{return e.matches(t)}catch{return!1}})}const Tn=["transform","translate","scale","rotate","perspective"],Cn=["transform","translate","scale","rotate","perspective","filter"],kn=["paint","layout","strict","content"];function Le(e){const t=Ae(),o=z(e)?q(e):e;return Tn.some(n=>o[n]?o[n]!=="none":!1)||(o.containerType?o.containerType!=="normal":!1)||!t&&(o.backdropFilter?o.backdropFilter!=="none":!1)||!t&&(o.filter?o.filter!=="none":!1)||Cn.some(n=>(o.willChange||"").includes(n))||kn.some(n=>(o.contain||"").includes(n))}function En(e){let t=ee(e);for(;Y(t)&&!ie(t);){if(Le(t))return t;if(ge(t))return null;t=ee(t)}return null}function Ae(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const On=new Set(["html","body","#document"]);function ie(e){return On.has(se(e))}function q(e){return N(e).getComputedStyle(e)}function we(e){return z(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ee(e){if(se(e)==="html")return e;const t=e.assignedSlot||e.parentNode||je(e)&&e.host||J(e);return je(t)?t.host:t}function lt(e){const t=ee(e);return ie(t)?e.ownerDocument?e.ownerDocument.body:e.body:Y(t)&&ce(t)?t:lt(t)}function ct(e,t,o){var n;t===void 0&&(t=[]);const i=lt(e),s=i===((n=e.ownerDocument)==null?void 0:n.body),r=N(i);return s?t.concat(r,r.visualViewport||[],ce(i)?i:[],[]):t.concat(i,ct(i,[]))}function ze(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function dt(e){const t=q(e);let o=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const i=Y(e),s=i?e.offsetWidth:o,r=i?e.offsetHeight:n,l=ue(o)!==s||ue(n)!==r;return l&&(o=s,n=r),{width:o,height:n,$:l}}function ut(e){return z(e)?e:e.contextElement}function ne(e){const t=ut(e);if(!Y(t))return W(1);const o=t.getBoundingClientRect(),{width:n,height:i,$:s}=dt(t);let r=(s?ue(o.width):o.width)/n,l=(s?ue(o.height):o.height)/i;return(!r||!Number.isFinite(r))&&(r=1),(!l||!Number.isFinite(l))&&(l=1),{x:r,y:l}}const Sn=W(0);function ht(e){const t=N(e);return!Ae()||!t.visualViewport?Sn:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ln(e,t,o){return t===void 0&&(t=!1),!o||t&&o!==N(e)?!1:t}function ae(e,t,o,n){t===void 0&&(t=!1),o===void 0&&(o=!1);const i=e.getBoundingClientRect(),s=ut(e);let r=W(1);t&&(n?z(n)&&(r=ne(n)):r=ne(e));const l=Ln(s,o,n)?ht(s):W(0);let c=(i.left+l.x)/r.x,h=(i.top+l.y)/r.y,u=i.width/r.x,d=i.height/r.y;if(s){const f=N(s),p=n&&z(n)?N(n):n;let m=f,g=ze(m);for(;g&&n&&p!==m;){const w=ne(g),y=g.getBoundingClientRect(),v=q(g),x=y.left+(g.clientLeft+parseFloat(v.paddingLeft))*w.x,_=y.top+(g.clientTop+parseFloat(v.paddingTop))*w.y;c*=w.x,h*=w.y,u*=w.x,d*=w.y,c+=x,h+=_,m=N(g),g=ze(m)}}return oe({width:u,height:d,x:c,y:h})}function ye(e,t){const o=we(e).scrollLeft;return t?t.left+o:ae(J(e)).left+o}function ft(e,t){const o=e.getBoundingClientRect(),n=o.left+t.scrollLeft-ye(e,o),i=o.top+t.scrollTop;return{x:n,y:i}}function An(e){let{elements:t,rect:o,offsetParent:n,strategy:i}=e;const s=i==="fixed",r=J(n),l=t?ge(t.floating):!1;if(n===r||l&&s)return o;let c={scrollLeft:0,scrollTop:0},h=W(1);const u=W(0),d=Y(n);if((d||!d&&!s)&&((se(n)!=="body"||ce(r))&&(c=we(n)),Y(n))){const p=ae(n);h=ne(n),u.x=p.x+n.clientLeft,u.y=p.y+n.clientTop}const f=r&&!d&&!s?ft(r,c):W(0);return{width:o.width*h.x,height:o.height*h.y,x:o.x*h.x-c.scrollLeft*h.x+u.x+f.x,y:o.y*h.y-c.scrollTop*h.y+u.y+f.y}}function Dn(e){return Array.from(e.getClientRects())}function In(e){const t=J(e),o=we(e),n=e.ownerDocument.body,i=I(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),s=I(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let r=-o.scrollLeft+ye(e);const l=-o.scrollTop;return q(n).direction==="rtl"&&(r+=I(t.clientWidth,n.clientWidth)-i),{width:i,height:s,x:r,y:l}}const qe=25;function Bn(e,t){const o=N(e),n=J(e),i=o.visualViewport;let s=n.clientWidth,r=n.clientHeight,l=0,c=0;if(i){s=i.width,r=i.height;const u=Ae();(!u||u&&t==="fixed")&&(l=i.offsetLeft,c=i.offsetTop)}const h=ye(n);if(h<=0){const u=n.ownerDocument,d=u.body,f=getComputedStyle(d),p=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,m=Math.abs(n.clientWidth-d.clientWidth-p);m<=qe&&(s-=m)}else h<=qe&&(s+=h);return{width:s,height:r,x:l,y:c}}const Rn=new Set(["absolute","fixed"]);function Mn(e,t){const o=ae(e,!0,t==="fixed"),n=o.top+e.clientTop,i=o.left+e.clientLeft,s=Y(e)?ne(e):W(1),r=e.clientWidth*s.x,l=e.clientHeight*s.y,c=i*s.x,h=n*s.y;return{width:r,height:l,x:c,y:h}}function Fe(e,t,o){let n;if(t==="viewport")n=Bn(e,o);else if(t==="document")n=In(J(e));else if(z(t))n=Mn(t,o);else{const i=ht(e);n={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return oe(n)}function pt(e,t){const o=ee(e);return o===t||!z(o)||ie(o)?!1:q(o).position==="fixed"||pt(o,t)}function Nn(e,t){const o=t.get(e);if(o)return o;let n=ct(e,[]).filter(l=>z(l)&&se(l)!=="body"),i=null;const s=q(e).position==="fixed";let r=s?ee(e):e;for(;z(r)&&!ie(r);){const l=q(r),c=Le(r);!c&&l.position==="fixed"&&(i=null),(s?!c&&!i:!c&&l.position==="static"&&!!i&&Rn.has(i.position)||ce(r)&&!c&&pt(e,r))?n=n.filter(u=>u!==r):i=l,r=ee(r)}return t.set(e,n),n}function Hn(e){let{element:t,boundary:o,rootBoundary:n,strategy:i}=e;const r=[...o==="clippingAncestors"?ge(t)?[]:Nn(t,this._c):[].concat(o),n],l=r[0],c=r.reduce((h,u)=>{const d=Fe(t,u,i);return h.top=I(d.top,h.top),h.right=X(d.right,h.right),h.bottom=X(d.bottom,h.bottom),h.left=I(d.left,h.left),h},Fe(t,l,i));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Vn(e){const{width:t,height:o}=dt(e);return{width:t,height:o}}function $n(e,t,o){const n=Y(t),i=J(t),s=o==="fixed",r=ae(e,!0,s,t);let l={scrollLeft:0,scrollTop:0};const c=W(0);function h(){c.x=ye(i)}if(n||!n&&!s)if((se(t)!=="body"||ce(i))&&(l=we(t)),n){const p=ae(t,!0,s,t);c.x=p.x+t.clientLeft,c.y=p.y+t.clientTop}else i&&h();s&&!n&&i&&h();const u=i&&!n&&!s?ft(i,l):W(0),d=r.left+l.scrollLeft-c.x-u.x,f=r.top+l.scrollTop-c.y-u.y;return{x:d,y:f,width:r.width,height:r.height}}function _e(e){return q(e).position==="static"}function Ke(e,t){if(!Y(e)||q(e).position==="fixed")return null;if(t)return t(e);let o=e.offsetParent;return J(e)===o&&(o=o.ownerDocument.body),o}function mt(e,t){const o=N(e);if(ge(e))return o;if(!Y(e)){let i=ee(e);for(;i&&!ie(i);){if(z(i)&&!_e(i))return i;i=ee(i)}return o}let n=Ke(e,t);for(;n&&xn(n)&&_e(n);)n=Ke(n,t);return n&&ie(n)&&_e(n)&&!Le(n)?o:n||En(e)||o}const Pn=async function(e){const t=this.getOffsetParent||mt,o=this.getDimensions,n=await o(e.floating);return{reference:$n(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function Un(e){return q(e).direction==="rtl"}const jn={convertOffsetParentRelativeRectToViewportRelativeRect:An,getDocumentElement:J,getClippingRect:Hn,getOffsetParent:mt,getElementRects:Pn,getClientRects:Dn,getDimensions:Vn,getScale:ne,isElement:z,isRTL:Un},De=gn,gt=cn,Ie=wn,Be=dn,wt=yn,yt=un,bt=an,vt=fn,Re=(e,t,o)=>{const n=new Map,i={platform:jn,...o},s={...i.platform,_c:n};return rn(e,t,{...i,platform:s})};function zn(e,t){const o=Math.min(e.top,t.top),n=Math.max(e.bottom,t.bottom),i=Math.min(e.left,t.left),r=Math.max(e.right,t.right)-i,l=n-o,c=i,h=o;return new DOMRect(c,h,r,l)}var qn=class{constructor({editor:e,element:t,view:o,updateDelay:n=250,resizeDelay:i=60,shouldShow:s,appendTo:r,getReferencedVirtualElement:l,options:c}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:u,state:d,from:f,to:p})=>{const{doc:m,selection:g}=d,{empty:w}=g,y=!m.textBetween(f,p).length&&T.isTextSelection(d.selection),v=this.element.contains(document.activeElement);return!(!(u.hasFocus()||v)||w||y||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:u})=>{var d;if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}u!=null&&u.relatedTarget&&((d=this.element.parentNode)!=null&&d.contains(u.relatedTarget))||(u==null?void 0:u.relatedTarget)!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(u,d)=>{const f=!(d!=null&&d.selection.eq(u.state.selection)),p=!(d!=null&&d.doc.eq(u.state.doc));!f&&!p||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(u,f,p,d)},this.updateDelay))},this.updateHandler=(u,d,f,p)=>{const{composing:m}=u;if(m||!d&&!f)return;if(!this.getShouldShow(p)){this.hide();return}this.updatePosition(),this.show()},this.transactionHandler=({transaction:u})=>{const d=u.getMeta("bubbleMenu");d==="updatePosition"?this.updatePosition():d&&typeof d=="object"&&d.type==="updateOptions"&&this.updateOptions(d.options)};var h;this.editor=e,this.element=t,this.view=o,this.updateDelay=n,this.resizeDelay=i,this.appendTo=r,this.scrollTarget=(h=c==null?void 0:c.scrollTarget)!=null?h:window,this.getReferencedVirtualElement=l,this.floatingUIOptions={...this.floatingUIOptions,...c},this.element.tabIndex=0,s&&(this.shouldShow=s),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(o,o.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){const e=[];return this.floatingUIOptions.flip&&e.push(Be(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&e.push(Ie(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&e.push(De(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&e.push(bt(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(wt(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&e.push(gt(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&e.push(yt(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&e.push(vt(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),e}get virtualElement(){var e,t,o;const{selection:n}=this.editor.state,i=(e=this.getReferencedVirtualElement)==null?void 0:e.call(this);if(i)return i;if(!((o=(t=this.view)==null?void 0:t.dom)!=null&&o.parentNode))return;const s=T.posToDOMRect(this.view,n.from,n.to);let r={getBoundingClientRect:()=>s,getClientRects:()=>[s]};if(n instanceof j.NodeSelection){let l=this.view.nodeDOM(n.from);const c=l.dataset.nodeViewWrapper?l:l.querySelector("[data-node-view-wrapper]");c&&(l=c),l&&(r={getBoundingClientRect:()=>l.getBoundingClientRect(),getClientRects:()=>[l.getBoundingClientRect()]})}if(n instanceof kt.CellSelection){const{$anchorCell:l,$headCell:c}=n,h=l?l.pos:c.pos,u=c?c.pos:l.pos,d=this.view.nodeDOM(h),f=this.view.nodeDOM(u);if(!d||!f)return;const p=d===f?d.getBoundingClientRect():zn(d.getBoundingClientRect(),f.getBoundingClientRect());r={getBoundingClientRect:()=>p,getClientRects:()=>[p]}}return r}updatePosition(){const e=this.virtualElement;e&&Re(e,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:t,y:o,strategy:n,middlewareData:i})=>{var s,r;if((s=i.hide)!=null&&s.referenceHidden||(r=i.hide)!=null&&r.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=n,this.element.style.left=`${t}px`,this.element.style.top=`${o}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){const{state:o}=e,n=o.selection.from!==o.selection.to;if(this.updateDelay>0&&n){this.handleDebouncedUpdate(e,t);return}const i=!(t!=null&&t.selection.eq(e.state.selection)),s=!(t!=null&&t.doc.eq(e.state.doc));this.updateHandler(e,i,s,t)}getShouldShow(e){var t;const{state:o}=this.view,{selection:n}=o,{ranges:i}=n,s=Math.min(...i.map(c=>c.$from.pos)),r=Math.max(...i.map(c=>c.$to.pos));return((t=this.shouldShow)==null?void 0:t.call(this,{editor:this.editor,element:this.element,view:this.view,state:o,oldState:e,from:s,to:r}))||!1}show(){var e;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const t=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(e=t??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}updateOptions(e){var t;if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=e.getReferencedVirtualElement),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){const o=(t=e.options.scrollTarget)!=null?t:window;o!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=o,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},Fn=e=>new j.Plugin({key:typeof e.pluginKey=="string"?new j.PluginKey(e.pluginKey):e.pluginKey,view:t=>new qn({view:t,...e})}),Kn=a.defineComponent({name:"BubbleMenu",inheritAttrs:!1,props:{pluginKey:{type:[String,Object],default:"bubbleMenu"},editor:{type:Object,required:!0},updateDelay:{type:Number,default:void 0},resizeDelay:{type:Number,default:void 0},options:{type:Object,default:()=>({})},appendTo:{type:[Object,Function],default:void 0},shouldShow:{type:Function,default:null},getReferencedVirtualElement:{type:Function,default:void 0}},setup(e,{slots:t,attrs:o}){const n=a.ref(null);return a.onMounted(()=>{const{editor:i,options:s,pluginKey:r,resizeDelay:l,appendTo:c,shouldShow:h,getReferencedVirtualElement:u,updateDelay:d}=e,f=n.value;f&&(f.style.visibility="hidden",f.style.position="absolute",f.remove(),a.nextTick(()=>{i.registerPlugin(Fn({editor:i,element:f,options:s,pluginKey:r,resizeDelay:l,appendTo:c,shouldShow:h,getReferencedVirtualElement:u,updateDelay:d}))}))}),a.onBeforeUnmount(()=>{const{pluginKey:i,editor:s}=e;s.unregisterPlugin(i)}),()=>{var i;return a.h("div",{ref:n,...o},(i=t.default)==null?void 0:i.call(t))}}}),Wn=class{constructor({editor:e,element:t,view:o,updateDelay:n=250,resizeDelay:i=60,options:s,appendTo:r,shouldShow:l}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:h,state:u})=>{const{selection:d}=u,{$anchor:f,empty:p}=d,m=f.depth===1,g=f.parent.isTextblock&&!f.parent.type.spec.code&&!f.parent.textContent&&f.parent.childCount===0&&!this.getTextContent(f.parent);return!(!h.hasFocus()||!p||!m||!g||!this.editor.isEditable)},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(h,u,d,f)=>{const{composing:p}=h;if(p||!u&&!d)return;if(!this.getShouldShow(f)){this.hide();return}this.updatePosition(),this.show()},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:h})=>{var u;if(this.preventHide){this.preventHide=!1;return}h!=null&&h.relatedTarget&&((u=this.element.parentNode)!=null&&u.contains(h.relatedTarget))||(h==null?void 0:h.relatedTarget)!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:h})=>{const u=h.getMeta("floatingMenu");u==="updatePosition"?this.updatePosition():u&&typeof u=="object"&&u.type==="updateOptions"&&this.updateOptions(u.options)},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)};var c;this.editor=e,this.element=t,this.view=o,this.updateDelay=n,this.resizeDelay=i,this.appendTo=r,this.scrollTarget=(c=s==null?void 0:s.scrollTarget)!=null?c:window,this.floatingUIOptions={...this.floatingUIOptions,...s},this.element.tabIndex=0,l&&(this.shouldShow=l),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(o,o.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(e){return T.getText(e,{textSerializers:T.getTextSerializersFromSchema(this.editor.schema)})}get middlewares(){const e=[];return this.floatingUIOptions.flip&&e.push(Be(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&e.push(Ie(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&e.push(De(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&e.push(bt(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(wt(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&e.push(gt(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&e.push(yt(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&e.push(vt(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),e}getShouldShow(e){var t;const{state:o}=this.view,{selection:n}=o,{ranges:i}=n,s=Math.min(...i.map(c=>c.$from.pos)),r=Math.max(...i.map(c=>c.$to.pos));return(t=this.shouldShow)==null?void 0:t.call(this,{editor:this.editor,view:this.view,state:o,oldState:e,from:s,to:r})}updateOptions(e){var t;if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){const o=(t=e.options.scrollTarget)!=null?t:window;o!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=o,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}updatePosition(){const{selection:e}=this.editor.state,t=T.posToDOMRect(this.view,e.from,e.to);Re({getBoundingClientRect:()=>t,getClientRects:()=>[t]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:n,y:i,strategy:s,middlewareData:r})=>{var l,c;if((l=r.hide)!=null&&l.referenceHidden||(c=r.hide)!=null&&c.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=s,this.element.style.left=`${n}px`,this.element.style.top=`${i}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){const o=!(t!=null&&t.selection.eq(e.state.selection)),n=!(t!=null&&t.doc.eq(e.state.doc));this.updateHandler(e,o,n,t)}show(){var e;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const t=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(e=t??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},Xn=e=>new j.Plugin({key:typeof e.pluginKey=="string"?new j.PluginKey(e.pluginKey):e.pluginKey,view:t=>new Wn({view:t,...e})});a.defineComponent({name:"FloatingMenu",inheritAttrs:!1,props:{pluginKey:{type:null,default:"floatingMenu"},editor:{type:Object,required:!0},updateDelay:{type:Number,default:void 0},resizeDelay:{type:Number,default:void 0},options:{type:Object,default:()=>({})},appendTo:{type:[Object,Function],default:void 0},shouldShow:{type:Function,default:null}},setup(e,{slots:t,attrs:o}){const n=a.ref(null);return a.onMounted(()=>{const{pluginKey:i,editor:s,updateDelay:r,resizeDelay:l,options:c,appendTo:h,shouldShow:u}=e,d=n.value;d&&(d.style.visibility="hidden",d.style.position="absolute",d.remove(),s.registerPlugin(Xn({pluginKey:i,editor:s,element:d,updateDelay:r,resizeDelay:l,options:c,appendTo:h,shouldShow:u})))}),a.onBeforeUnmount(()=>{const{pluginKey:i,editor:s}=e;s.unregisterPlugin(i)}),()=>{var i;return a.h("div",{ref:n,...o},(i=t.default)==null?void 0:i.call(t))}}});const Q=e=>({default:null,parseHTML:t=>t.getAttribute(e),renderHTML:t=>t[e]?{[e]:t[e]}:{}}),Yn=()=>{let e=Q("style");return e.renderHTML=t=>t.style?{style:Gn(t.style)}:{},e};function Gn(e){return e.replace(new RegExp("(?<![a-z-])width\\s*:\\s*([^;]+);?","gi"),(t,o)=>/^\s*0\s*[a-z%]*\s*(!important)?\s*$/i.test(o)?"width: 100%;":t)}const Jn=pe.Table.extend({addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),border:Q("border"),cellpadding:Q("cellpadding"),cellspacing:Q("cellspacing"),style:Yn()}},renderHTML({HTMLAttributes:e}){return["table",T.mergeAttributes(this.options.HTMLAttributes,e),["tbody",0]]}}),Zn=pe.TableRow.extend({addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),style:Q("style")}}}),xt={style:Q("style"),valign:Q("valign"),width:Q("width")},Qn=pe.TableCell.extend({addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),...xt}}}),eo=pe.TableHeader.extend({addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),...xt}}}),to=Je.TextStyle.extend({parseHTML(){var e;return[...((e=this.parent)==null?void 0:e.call(this))||[],{tag:"div",consuming:!1,getAttrs:t=>t.hasAttribute("style")?{}:!1},{tag:"a",consuming:!1,getAttrs:t=>t.hasAttribute("style")?{}:!1}]}}),no={compatConfig:{MODE:3},name:"EmojiComponent",components:{NodeViewWrapper:S.NodeViewWrapper,DtEmoji:Qe.default},props:S.nodeViewProps};function oo(e,t,o,n,i,s){const r=a.resolveComponent("dt-emoji"),l=a.resolveComponent("node-view-wrapper");return a.openBlock(),a.createBlock(l,{class:"d-d-inline-block d-va-bottom d-lh0"},{default:a.withCtx(()=>[a.createVNode(r,{size:"500",code:e.node.attrs.code},null,8,["code"])]),_:1})}const io=F._(no,[["render",oo]]),so={compatConfig:{MODE:3},name:"SuggestionList",components:{DtListItem:$t.default},props:{items:{type:Array,required:!0},command:{type:Function,required:!0},itemComponent:{type:Object,required:!0},itemType:{type:String,required:!0}},data(){return{selectedIndex:0}},watch:{items(){this.selectedIndex=0}},methods:{onKeyDown({event:e}){return e.key==="ArrowUp"?(this.upHandler(),!0):e.key==="ArrowDown"?(this.downHandler(),!0):e.key==="Enter"||e.key==="Tab"?(this.selectHandler(),!0):!1},upHandler(){this.selectedIndex=(this.selectedIndex+this.items.length-1)%this.items.length,this.scrollActiveElementIntoView()},downHandler(){this.selectedIndex=(this.selectedIndex+1)%this.items.length,this.scrollActiveElementIntoView()},async scrollActiveElementIntoView(){await this.$nextTick();const e=this.$refs.suggestionList.querySelector(".d-list-item--highlighted");e&&e.scrollIntoView({behaviour:"smooth",block:"center"})},selectHandler(){this.selectItem(this.selectedIndex)},selectItem(e){const t=this.items[e];switch(this.itemType){case"emoji":this.command(t);return;case"mention":this.command({name:t.name,id:t.id,avatarSrc:t.avatarSrc,contactKey:t.contactKey});break;case"channel":this.command({name:t.name,id:t.id,locked:t.locked,channelKey:t.channelKey});break;case"slash-command":this.command({command:t.command});break}}}},ro={class:"d-popover__dialog d-suggestion-list__container"},ao={ref:"suggestionList",class:"d-suggestion-list"};function lo(e,t,o,n,i,s){const r=a.resolveComponent("dt-list-item");return a.openBlock(),a.createElementBlock("div",ro,[a.withDirectives(a.createElementVNode("ul",ao,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(o.items,(l,c)=>(a.openBlock(),a.createBlock(r,{key:l.id,class:a.normalizeClass(["d-suggestion-list__item",{"d-list-item--highlighted":c===i.selectedIndex}]),"navigation-type":"arrow-keys",onClick:h=>s.selectItem(c),onKeydown:a.withModifiers(s.onKeyDown,["prevent"])},{default:a.withCtx(()=>[(a.openBlock(),a.createBlock(a.resolveDynamicComponent(o.itemComponent),{item:l},null,8,["item"]))]),_:2},1032,["class","onClick","onKeydown"]))),128))],512),[[a.vShow,o.items.length]])])}const co=F._(so,[["render",lo]]),_t="top-start",Tt="650";function uo(){return{getBoundingClientRect:()=>({width:0,height:0,x:0,y:0,top:0,left:0,right:0,bottom:0})}}function We(e){return{getBoundingClientRect:e}}async function ho(e,t,o={}){if(!e||!(t!=null&&t.getBoundingClientRect))return;const{placement:n=_t,middleware:i=[De(0),Be(),Ie({padding:8})]}=o,{x:s,y:r}=await Re(t,e,{placement:n,middleware:i});Object.assign(e.style,{left:`${s}px`,top:`${r}px`})}function fo(e,t={}){const{zIndex:o=Tt}=t;e.style.position="absolute",e.style.zIndex=o,e.style.display="none"}function po(e){e&&(e.style.display="block")}function mo(e){e&&(e.style.display="none")}function go(e,t){return o=>{o.key==="Escape"&&t()&&e()}}function wo(e){document.addEventListener("keydown",e)}function yo(e){document.removeEventListener("keydown",e)}function bo(e,t,o,n){return new S.VueRenderer(e,{props:{itemComponent:a.markRaw(t),itemType:o,...n},editor:n.editor})}function vo(e){var t,o;e.escHandler&&yo(e.escHandler),(t=e.floatingEl)==null||t.remove(),(o=e.component)==null||o.destroy()}function be(e,t,o={}){const{listComponent:n=co,placement:i=_t,zIndex:s=Tt}=o;return()=>{let r=null,l=null,c=!1,h=uo(),u=null;function d(){ho(l,h,{placement:i})}function f(){l&&(po(l),c=!0,d())}function p(){l&&(mo(l),c=!1)}return{onStart:m=>{r=bo(n,e,t,m),m.clientRect&&(l=r.element,fo(l,{zIndex:s}),document.body.appendChild(l),h=We(m.clientRect),u=go(p,()=>c),wo(u),m.items.length>0&&f())},onUpdate(m){r==null||r.updateProps(m),m.items.length>0?f():p(),m.clientRect&&(h=We(m.clientRect),d())},onKeyDown(m){var g;if(c)return(g=r==null?void 0:r.ref)==null?void 0:g.onKeyDown(m)},onExit(){vo({escHandler:u,floatingEl:l,component:r}),u=null,l=null,r=null}}}}const xo={compatConfig:{MODE:3},name:"EmojiSuggestion",components:{DtEmoji:Qe.default,DtStack:le.default},props:{item:{type:Object,required:!0}}};function _o(e,t,o,n,i,s){const r=a.resolveComponent("dt-emoji"),l=a.resolveComponent("dt-stack");return a.openBlock(),a.createBlock(l,{direction:"row",gap:"400"},{default:a.withCtx(()=>[a.createVNode(r,{size:"200",code:o.item.code},null,8,["code"]),a.createTextVNode(" "+a.toDisplayString(o.item.code),1)]),_:1})}const To=F._(xo,[["render",_o]]),Co=20,ko=(e,t,o)=>{var l,c;const n=(l=e.shortname)==null?void 0:l.replaceAll(":",""),i=(c=t.shortname)==null?void 0:c.replaceAll(":",""),s=n.startsWith(o),r=i.startsWith(o);return s&&!r?-1:!s&&r?1:n.localeCompare(i)},Eo={items:({query:e})=>{if(e.length<2)return[];const t=Object.values(te.getEmojiData());return e=e.toLowerCase(),t.filter(n=>{var i;return[n.name,(i=n.shortname)==null?void 0:i.replaceAll(":",""),...n.keywords||[]].some(s=>s&&s.startsWith(e))}).splice(0,Co).sort((n,i)=>ko(n,i,e)).map(n=>({code:n.shortname}))},command:({editor:e,range:t,props:o})=>{var s,r;const n=e.view.state.selection.$to.nodeAfter;((s=n==null?void 0:n.text)==null?void 0:s.startsWith(" "))&&(t.to+=1),e.chain().focus().insertContentAt(t,[{type:"emoji",attrs:o}]).run(),(r=window.getSelection())==null||r.collapseToEnd()},render:be(To,"emoji")},Oo=/(:\w+:)$/,So=new RegExp(Ze.emojiPattern+"$"),Lo=e=>{if(e&&te.codeToEmojiData(e[0]))return{text:e[2]||e[0]}},Ao=e=>[...e.matchAll(te.emojiShortCodeRegex)].filter(o=>te.codeToEmojiData(o[0])).map(o=>({index:o.index,text:o[0],match:o})),Do=T.Node.create({name:"emoji",addOptions(){return{HTMLAttributes:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addNodeView(){return S.VueNodeViewRenderer(io)},addAttributes(){return{code:{default:null}}},parseHTML(){return[{tag:"emoji-component"}]},renderText({node:e}){return te.stringToUnicode(te.codeToEmojiData(e.attrs.code).unicode_output)},renderHTML({HTMLAttributes:e}){return["emoji-component",T.mergeAttributes(this.options.HTMLAttributes,e)]},addInputRules(){return[new T.InputRule({find:e=>{const t=e.match(Oo)||e.match(So);if(t)return Lo(t)},handler:({state:e,range:t,match:o})=>{const{tr:n}=e,i=t.from,s=t.to;n.replaceWith(i,s,this.type.create({code:o[0]}))}})]},addPasteRules(){return[T.nodePasteRule({find:Ao,type:this.type,getAttributes(e){return{code:e[0]}}}),T.nodePasteRule({find:te.emojiRegex,type:this.type,getAttributes(e){return{code:e[0]}}})]},addProseMirrorPlugins(){return[Vt({char:":",pluginKey:new j.PluginKey("emoji"),editor:this.editor,...this.options.suggestion,...Eo})]},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:e,state:t})=>{let o=!1;const{selection:n}=t,{empty:i,anchor:s}=n;return i?(t.doc.nodesBetween(s-1,s,(r,l)=>{if(r.type.name===this.name)return o=!0,e.insertText("",l,l+r.nodeSize),!1}),o):!1})}}});function Io(e,t,o=()=>!0){const n=[];t.lastIndex=0;let i;for(;i=t.exec(e);)o(e,i)&&n.push(i);return n}function Bo(e,t){return!["#","@"].includes(e.charAt(t.index))&&!["#","@"].includes(e.charAt(t.index-1))}function Ro(e){const t=new RegExp("(?:"+[`[!?.,:;'"]`,"(?:&|&amp;)(?:lt|gt|quot|apos|raquo|laquo|rsaquo|lsaquo);)+$"].join("|"),"g");return e.replace(t,"")}function Mo(e,t){const o=e.slice(0,t+1).search(/\S+\s*$/),n=e.slice(t).search(/\s/);if(n<0){const i=e.slice(o);return{text:i,from:o,to:o+i.length}}return{text:e.slice(o,n+t),from:o,to:n+t}}function Ce(e,t,o,n){const i=Mo(e,t);if(n.lastIndex=0,!n.test(i.text))return i;const s=o==="left"?i.from-1:i.to+1;return s<=0||s>=e.length||s===t?i:Ce(e,s,o,n)}function No(e,t,o,n){const i=Math.max(e.from-1,0),s=Math.min(e.to+1,t.content.size),r=T.getMarksBetween(i,s,t);for(const l of r)l.mark.type===n&&o.removeMark(l.from,l.to,n)}const Xe=re.getPhoneNumberRegex(1,15);function Ye(e,t,o,n,i,s){if(!e)return;let r=o-t-1;r=r<0?0:r;const l=n-t,c=Ce(e,r,"left",Xe),h=Ce(e,l,"right",Xe),u=e.slice(c.from,h.to);Io(u,re.linkRegex,Bo).forEach(f=>{const p=Ro(f[0]),m=t+c.from+f.index+1,g=m+p.length;i.addMark(m,g,s.create())})}function Ho(e){let t=!1;return new j.Plugin({key:new j.PluginKey("autolink"),appendTransaction:(o,n,i)=>{const s=o.some(u=>u.docChanged)&&!n.doc.eq(i.doc);if(t&&!s)return;const{tr:r}=i,{textContent:l}=i.doc;t||Ye(l,0,0,l.length,r,e.type),t=!0;const c=T.combineTransactionSteps(n.doc,[...o]);return T.getChangedRanges(c).forEach(({oldRange:u,newRange:d})=>{No(d,i.doc,r,e.type),T.findChildrenInRange(i.doc,d,p=>p.isTextblock).forEach(({node:p,pos:m})=>{Ye(p.textContent,m,u.from,d.to,r,e.type)})}),r}})}const Vo={class:"d-link d-c-text d-d-inline-block d-wb-break-all",rel:"noopener noreferrer nofollow"},$o=T.Mark.create({name:"CustomLink",renderHTML({HTMLAttributes:e}){return["a",T.mergeAttributes(this.options.HTMLAttributes,e,Vo)]},renderText({node:e}){return e.attrs.text},addProseMirrorPlugins(){return[Ho({type:this.type})]}}),Po=Pt.extend({name:"ConfigurableImage",addAttributes(){return{src:{default:""},alt:{default:void 0},title:{default:void 0},width:{default:void 0},height:{default:void 0},style:{default:void 0}}}}).configure({inline:!0,allowBase64:!0}),Uo=new Set(["address","article","aside","blockquote","dd","details","dialog","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","li","main","nav","ol","p","pre","section","table","ul"]),jo=Ge.extend({parseHTML(){return[{tag:"div",getAttrs:e=>{for(const t of e.children)if(Uo.has(t.tagName.toLowerCase()))return!1;return null}}]},renderHTML({HTMLAttributes:e}){return["div",T.mergeAttributes(this.options.HTMLAttributes,e),0]}}),zo={compatConfig:{MODE:3},name:"MentionComponent",components:{NodeViewWrapper:S.NodeViewWrapper,DtLink:et.default},props:S.nodeViewProps,computed:{text(){return"@"+this.$props.node.attrs.name}},methods:{getMentionData(){return{name:this.$props.node.attrs.name,id:this.$props.node.attrs.id,avatarSrc:this.$props.node.attrs.avatarSrc,contactKey:this.$props.node.attrs.contactKey}},handleClick(){this.$props.editor.emit("mention-click",this.getMentionData())},handleMouseEnter(e){this.$props.editor.emit("mention-hover",{...this.getMentionData(),event:e})},handleMouseLeave(e){this.$props.editor.emit("mention-leave",{...this.getMentionData(),event:e})}}};function qo(e,t,o,n,i,s){const r=a.resolveComponent("dt-link"),l=a.resolveComponent("node-view-wrapper");return a.openBlock(),a.createBlock(l,{class:"d-d-inline-block"},{default:a.withCtx(()=>[a.createVNode(r,{kind:"mention",onClick:a.withModifiers(s.handleClick,["prevent"]),onMouseenter:s.handleMouseEnter,onMouseleave:s.handleMouseLeave,onFocusin:s.handleMouseEnter,onFocusout:s.handleMouseLeave},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(s.text),1)]),_:1},8,["onClick","onMouseenter","onMouseleave","onFocusin","onFocusout"])]),_:1})}const Fo=F._(zo,[["render",qo]]),Ko=ke.extend({addNodeView(){return S.VueNodeViewRenderer(Fo)},parseHTML(){return[{tag:"mention-component"}]},addAttributes(){return{name:{default:""},avatarSrc:{default:""},id:{default:""},contactKey:{default:""}}},renderText({node:e}){return`@${e.attrs.id}`},renderHTML({HTMLAttributes:e}){return["mention-component",T.mergeAttributes(this.options.HTMLAttributes,e)]}}).configure({suggestion:{char:"@",pluginKey:new j.PluginKey("mentionSuggestion")}}),Wo={compatConfig:{MODE:3},name:"ChannelComponent",components:{NodeViewWrapper:S.NodeViewWrapper,DtLink:et.default,DtIconLock:Ut.DtIconLock,DtStack:le.default},props:S.nodeViewProps,computed:{text(){return this.$props.node.attrs.locked?this.$props.node.attrs.name:"#"+this.$props.node.attrs.name}},methods:{handleClick(){const e={name:this.$props.node.attrs.name,id:this.$props.node.attrs.id,locked:this.$props.node.attrs.locked,channelKey:this.$props.node.attrs.channelKey};this.$props.editor.emit("channel-click",e)}}};function Xo(e,t,o,n,i,s){const r=a.resolveComponent("dt-icon-lock"),l=a.resolveComponent("dt-stack"),c=a.resolveComponent("dt-link"),h=a.resolveComponent("node-view-wrapper");return a.openBlock(),a.createBlock(h,{class:"d-d-inline-block"},{default:a.withCtx(()=>[a.createVNode(c,{kind:"mention",onClick:a.withModifiers(s.handleClick,["prevent"])},{default:a.withCtx(()=>[a.createVNode(l,{direction:"row",gap:"0"},{default:a.withCtx(()=>[e.$props.node.attrs.locked?(a.openBlock(),a.createBlock(r,{key:0,size:"200"})):a.createCommentVNode("",!0),a.createElementVNode("span",null,a.toDisplayString(s.text),1)]),_:1})]),_:1},8,["onClick"])]),_:1})}const Yo=F._(Wo,[["render",Xo]]),Go=ke.extend({name:"channel",addNodeView(){return S.VueNodeViewRenderer(Yo)},parseHTML(){return[{tag:"channel-component"}]},addAttributes(){return{name:{default:""},id:{default:""},locked:{default:!1},channelKey:{default:""}}},renderText({node:e}){return`#${e.attrs.id}`},renderHTML({HTMLAttributes:e}){return["channel-component",T.mergeAttributes(this.options.HTMLAttributes,e)]}}).configure({suggestion:{char:"#",pluginKey:new j.PluginKey("channelSuggestion")}}),Jo={compatConfig:{MODE:3},name:"SlashCommandsComponent",components:{NodeViewWrapper:S.NodeViewWrapper},props:{...S.nodeViewProps},emits:["selected-command"],computed:{text(){return"/"+this.$props.node.attrs.command}},created(){var o,n,i;const e=this.$props.node.attrs.command;this.$emit("selected-command",e);const t=(i=(n=(o=this.editor)==null?void 0:o.storage)==null?void 0:n["slash-commands"])==null?void 0:i.onSelectedCommand;t&&typeof t=="function"&&t(e)}};function Zo(e,t,o,n,i,s){const r=a.resolveComponent("node-view-wrapper");return a.openBlock(),a.createBlock(r,{class:"d-d-inline-block"},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(s.text),1)]),_:1})}const Qo=F._(Jo,[["render",Zo]]),ei=(e,t)=>[...e.matchAll(t)].map(n=>{let i=n[2];return i.endsWith(" ")||(i+=" "),{index:n.index,text:i,match:n}}),ti=ke.extend({name:"slash-commands",group:"inline",inline:!0,addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),onSelectedCommand:null}},addStorage(){return{onSelectedCommand:this.options.onSelectedCommand}},addNodeView(){return S.VueNodeViewRenderer(Qo)},parseHTML(){return[{tag:"command-component"}]},addAttributes(){return{command:{default:""},parametersExample:{default:""},description:{default:""}}},renderText({node:e}){return`/${e.attrs.command}`},renderHTML({HTMLAttributes:e}){return["command-component",T.mergeAttributes(this.options.HTMLAttributes,e)]},addInputRules(){var o;const e=(o=this.options.suggestion)==null?void 0:o.items({query:""}).map(n=>n.command),t=new RegExp(`^((?:\\/)(${e.join("|")})) $`);return[T.nodeInputRule({find:t,type:this.type,getAttributes(n){return{command:n[2]}}})]},addPasteRules(){var o;const e=(o=this.options.suggestion)==null?void 0:o.items({query:""}).map(n=>n.command),t=new RegExp(`^((?:\\/)(${e.join("|")})) ?$`,"g");return[T.nodePasteRule({find:n=>ei(n,t),type:this.type,getAttributes(n){return{command:n[0].trim()}}})]}}).configure({suggestion:{char:"/",pluginKey:new j.PluginKey("slashCommandSuggestion")}}),ni=100,oi={name:"VariableComponent",components:{DtBadge:qt.default,DtButton:nt.default,DtPopover:zt.default,DtInput:jt.default,NodeViewWrapper:S.NodeViewWrapper},props:S.nodeViewProps,data(){return{i18n:new tt.DialtoneLocalization,MAX_VARIABLE_ALT_LENGTH:ni}},computed:{altText:{get(){var e,t;return((t=(e=this.node)==null?void 0:e.attrs)==null?void 0:t.altText)||""},set(e){this.updateAttributes({altText:e})}},variableId(){var e,t;return(t=(e=this.node)==null?void 0:e.attrs)==null?void 0:t.id},placeholder(){var e;return((e=this.variableData)==null?void 0:e.placeholder)||""},variableItems(){var e,t;return((t=(e=this.extension)==null?void 0:e.options)==null?void 0:t.variableItems)||[]},variableData(){return this.variableItems.find(e=>e.id===this.variableId)},enableAltText(){var e,t;return(t=(e=this.node)==null?void 0:e.attrs)==null?void 0:t.enableAltText},badgeLabel(){return`{} ${this.placeholder}`},placeholderText(){return`Replaces ${this.placeholder}`}}};function ii(e,t,o,n,i,s){const r=a.resolveComponent("dt-badge"),l=a.resolveComponent("dt-button"),c=a.resolveComponent("dt-input"),h=a.resolveComponent("dt-popover"),u=a.resolveComponent("node-view-wrapper");return a.openBlock(),a.createBlock(u,{class:"d-d-inline-block"},{default:a.withCtx(()=>[s.enableAltText?(a.openBlock(),a.createBlock(h,{key:0,padding:"small","navigation-type":"arrow-keys",placement:"top-start",modal:!1},{anchor:a.withCtx(({attrs:d})=>[a.createVNode(l,a.mergeProps(d,{kind:"unstyled"}),{default:a.withCtx(()=>[a.createVNode(r,{text:s.badgeLabel,contenteditable:"false"},null,8,["text"])]),_:1},16)]),content:a.withCtx(({close:d})=>[a.createVNode(c,{modelValue:s.altText,"onUpdate:modelValue":t[0]||(t[0]=f=>s.altText=f),"root-class":"d-p8 d-w332",label:i.i18n.$t("DIALTONE_EDITOR_VARIABLE_LABEL"),placeholder:s.placeholderText,validate:{length:{description:i.i18n.$t("DIALTONE_EDITOR_VARIABLE_VALIDATE_DESCRIPTION"),message:i.i18n.$t("DIALTONE_EDITOR_VARIABLE_VALIDATE_MESSAGE"),max:i.MAX_VARIABLE_ALT_LENGTH,warn:i.MAX_VARIABLE_ALT_LENGTH,limitMaxLength:!0}},onKeyup:a.withKeys(f=>d(),["enter"])},null,8,["modelValue","label","placeholder","validate","onKeyup"])]),_:1})):(a.openBlock(),a.createBlock(r,{key:1,text:s.badgeLabel,contenteditable:"false"},null,8,["text"]))]),_:1})}const si=F._(oi,[["render",ii]]),ri=T.Node.create({name:"variable",group:"inline",inline:!0,selectable:!0,atom:!0,addOptions(){return{HTMLAttributes:{},variableItems:[]}},addNodeView(){return S.VueNodeViewRenderer(si)},addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute("data-variable-id"),renderHTML:e=>e.id?{"data-variable-id":e.id}:{}},altText:{default:"",parseHTML:e=>e.getAttribute("data-alt-text"),renderHTML:e=>e.altText?{"data-alt-text":e.altText}:{}},enableAltText:{default:!0,parseHTML:e=>e.getAttribute("data-enable-alt-text")==="true",renderHTML:e=>({"data-enable-alt-text":String(e.enableAltText)})}}},parseHTML(){return[{tag:"variable"}]},renderText({node:e}){return e.attrs.altText},renderHTML({node:e,HTMLAttributes:t}){return["variable",T.mergeAttributes(this.options.HTMLAttributes,t,{"data-variable-id":e.attrs.id,"data-alt-text":e.attrs.altText,"data-enable-alt-text":String(e.attrs.enableAltText)})]},addCommands(){return{insertVariable:(e={})=>({commands:t})=>t.insertContent({type:this.name,attrs:{id:e.id||null,altText:e.altText||"",enableAltText:e.enableAltText}})}}}),ai={compatConfig:{MODE:3},name:"MentionSuggestion",components:{DtAvatar:Ft.default,DtStack:le.default},props:{item:{type:Object,required:!0}},computed:{name(){return this.item.name},avatarSrc(){return this.item.avatarSrc},presence(){return this.item.presence},status(){return this.item.status},presenceText(){return this.item.presenceText},presenceFontColorClass(){return{active:"d-recipe-contact-row--active",busy:"d-recipe-contact-row--busy",away:"d-recipe-contact-row--away",offline:"d-recipe-contact-row--busy"}[this.presence]},showDetails(){return this.item.showDetails}}},li={class:"d-mention-suggestion__name"},ci={key:1,class:"d-mention-suggestion__divider"},di={key:2,class:"d-mention-suggestion__status"};function ui(e,t,o,n,i,s){const r=a.resolveComponent("dt-avatar"),l=a.resolveComponent("dt-stack");return a.openBlock(),a.createBlock(l,{direction:"row",class:"d-mention-suggestion__container",gap:"400"},{default:a.withCtx(()=>[a.createVNode(r,{"full-name":s.name,"image-src":s.avatarSrc,"image-alt":s.name,"show-presence":s.showDetails,presence:s.presence,size:"sm"},null,8,["full-name","image-src","image-alt","show-presence","presence"]),a.createVNode(l,{class:"d-mention-suggestion__details-container",gap:"100"},{default:a.withCtx(()=>[a.createElementVNode("span",li,a.toDisplayString(s.name),1),s.showDetails?(a.openBlock(),a.createBlock(l,{key:0,direction:"row",gap:"300",class:"d-label--sm-plain"},{default:a.withCtx(()=>[s.presenceText?(a.openBlock(),a.createElementBlock("span",{key:0,class:a.normalizeClass(["d-mention-suggestion__presence",[s.presenceFontColorClass]])},a.toDisplayString(s.presenceText),3)):a.createCommentVNode("",!0),s.status&&s.presenceText?(a.openBlock(),a.createElementBlock("div",ci," • ")):a.createCommentVNode("",!0),s.status?(a.openBlock(),a.createElementBlock("div",di,a.toDisplayString(s.status),1)):a.createCommentVNode("",!0)]),_:1})):a.createCommentVNode("",!0)]),_:1})]),_:1})}const hi=F._(ai,[["render",ui]]),fi={allowSpaces:!0,render:be(hi,"mention")},pi={compatConfig:{MODE:3},name:"ChannelSuggestion",components:{DtStack:le.default,DtIconHash:Kt,DtIconLock:Wt},props:{item:{type:Object,required:!0}},computed:{name(){return this.item.name}}};function mi(e,t,o,n,i,s){const r=a.resolveComponent("dt-icon-hash"),l=a.resolveComponent("dt-icon-lock"),c=a.resolveComponent("dt-stack");return a.openBlock(),a.createBlock(c,{direction:"row",gap:"400"},{default:a.withCtx(()=>[o.item.locked?(a.openBlock(),a.createBlock(l,{key:1,size:"300"})):(a.openBlock(),a.createBlock(r,{key:0,size:"300"})),a.createElementVNode("span",null,a.toDisplayString(s.name),1)]),_:1})}const gi=F._(pi,[["render",mi]]),wi={allowSpaces:!0,render:be(gi,"channel")},yi={compatConfig:{MODE:3},name:"SlashCommandSuggestion",props:{item:{type:Object,required:!0}},computed:{command(){return this.item.command},description(){return this.item.description},parametersExample(){return this.item.parametersExample}}},bi={class:"d-body--md-compact"},vi={key:0},xi={class:"d-body--sm d-fc-tertiary"};function _i(e,t,o,n,i,s){return a.openBlock(),a.createElementBlock("div",null,[a.createElementVNode("div",bi,[a.createElementVNode("span",null,"/"+a.toDisplayString(s.command),1),s.parametersExample?(a.openBlock(),a.createElementBlock("span",vi,a.toDisplayString(s.parametersExample),1)):a.createCommentVNode("",!0)]),a.createElementVNode("div",xi,a.toDisplayString(s.description),1)])}const Ti=F._(yi,[["render",_i]]),Ci={allowSpaces:!0,startOfLine:!0,render:be(Ti,"slash-command")},ki={compatConfig:{MODE:3},name:"DtRichTextEditor",components:{EditorContent:S.EditorContent,BubbleMenu:Kn,DtButton:nt.default,DtStack:le.default},props:{modelValue:{type:[Object,String],default:""},editable:{type:Boolean,default:!0},preventTyping:{type:Boolean,default:!1},pasteRichText:{type:Boolean,default:!0},allowLineBreaks:{type:Boolean,default:!1},inputAriaLabel:{type:String,required:!0},inputClass:{type:String,default:""},autoFocus:{type:[Boolean,String,Number],default:!1,validator(e){return typeof e=="string"?de.RICH_TEXT_EDITOR_AUTOFOCUS_TYPES.includes(e):!0}},outputFormat:{type:String,default:"html",validator(e){return de.RICH_TEXT_EDITOR_OUTPUT_FORMATS.includes(e)}},placeholder:{type:String,default:""},link:{type:[Boolean,Object],default:!1},customLink:{type:[Boolean,Object],default:!1},mentionSuggestion:{type:Object,default:null},channelSuggestion:{type:Object,default:null},slashCommandSuggestion:{type:Object,default:null},allowBlockquote:{type:Boolean,default:!0},allowBold:{type:Boolean,default:!0},allowBulletList:{type:Boolean,default:!0},allowItalic:{type:Boolean,default:!0},allowStrike:{type:Boolean,default:!0},allowUnderline:{type:Boolean,default:!0},allowCode:{type:Boolean,default:!0},allowCodeblock:{type:Boolean,default:!0},allowInlineImages:{type:Boolean,default:!1},allowFontColor:{type:Boolean,default:!1},allowBackgroundColor:{type:Boolean,default:!1},allowFontSize:{type:Boolean,default:!1},allowFontFamily:{type:Boolean,default:!1},allowLineHeight:{type:Boolean,default:!1},allowVariable:{type:Boolean,default:!1},variableItems:{type:Array,default:()=>[]},additionalExtensions:{type:Array,default:()=>[]},hideLinkBubbleMenu:{type:Boolean,default:!1},preserveWhitespace:{type:[Boolean,String],default:"full"},useDivTags:{type:Boolean,default:!1},allowTables:{type:Boolean,default:!1},allowImageResize:{type:Boolean,default:!1}},emits:["input","json-input","html-input","text-input","markdown-input","update:modelValue","blur","focus","enter","edit-link","selected","selected-command","mention-click","mention-hover","mention-leave","channel-click"],data(){return{editor:null,appendTo:()=>{var e;return(e=re.returnFirstEl(this.$refs.editor.$el).getRootNode())==null?void 0:e.querySelector("body")},floatingOptions:{placement:"top-start"},i18n:new tt.DialtoneLocalization,jsonToMarkdownConverter:{convertToMarkdown(e){return this.processNode(e)},processNodeContent(e){return e.content?e.content.map(t=>this.processNode(t)).join(""):""},processNode(e){if(!e)return"";const o={doc:n=>this.processDocNode(n),paragraph:n=>this.processParagraphNode(n),text:n=>this.processTextNode(n),hardBreak:()=>this.processHardBreakNode(),blockquote:n=>this.processBlockquoteNode(n),bulletList:n=>this.processBulletListNode(n),orderedList:n=>this.processOrderedListNode(n),listItem:n=>this.processListItemNode(n),codeBlock:n=>this.processCodeBlockNode(n),mention:n=>this.processMentionNode(n),channel:n=>this.processChannelNode(n),"slash-commands":n=>this.processSlashCommandsNode(n),emoji:n=>this.processEmojiNode(n),variable:n=>this.processVariableNode(n)}[e.type];return o?o(e):this.processUnknownNode(e)},processDocNode(e){return this.processNodeContent(e)},processParagraphNode(e){const t=this.processNodeContent(e);return t?t+`
2
2
  `:`
3
3
  `},processTextNode(e){let t=e.text||"";return e.marks&&(t=this.applyMarks(t,e.marks)),t},processHardBreakNode(){return`
4
4
  `},processBlockquoteNode(e){return this.processNodeContent(e).split(`
@@ -7,9 +7,9 @@
7
7
  `},processBulletListNode(e){return this.processNodeContent(e)},processOrderedListNode(e){return e.content?e.content.map((t,o)=>this.processNode(t).replace(/^- /,`${o+1}. `)).join(""):""},processListItemNode(e){const t=this.processNodeContent(e);return t?`- ${t.replace(/\n$/,"")}
8
8
  `:""},processCodeBlockNode(e){return`\`\`\`
9
9
  ${this.processNodeContent(e)}
10
- \`\`\``},processMentionNode(e){var i,s,r;const t=((i=e.attrs)==null?void 0:i.name)||"",o=((s=e.attrs)==null?void 0:s.id)||"",n=((r=e.attrs)==null?void 0:r.contactKey)||"";return`<!-- @mention: {"id": "${o}", "contactKey": "${n}", "name": "${t}"} -->`},processChannelNode(e){var s,r,l,c;const t=((s=e.attrs)==null?void 0:s.name)||"",o=((r=e.attrs)==null?void 0:r.id)||"",n=((l=e.attrs)==null?void 0:l.locked.toString())||"",i=((c=e.attrs)==null?void 0:c.channelKey)||"";return`<!-- @channel: {"id": "${o}", "channelKey": "${i}", "name": "${t}", "locked": "${n}"} -->`},processSlashCommandsNode(e){var n,i;const t=((n=e.attrs)==null?void 0:n.command)||"",o=((i=e.attrs)==null?void 0:i.parameters)||"";return`/${t}${o?` ${o}`:""}`},processEmojiNode(e){var t;return((t=e.attrs)==null?void 0:t.code)||""},processVariableNode(e){var n,i;const t=((n=e.attrs)==null?void 0:n.id)||"",o=((i=e.attrs)==null?void 0:i.altText)||"";return`{{${t}=${o}}}`},processUnknownNode(e){return this.processNodeContent(e)},applyMarks(e,t){let o=e;return[...t].sort((i,s)=>{const r={link:0,bold:1,italic:2,strike:3,code:4};return(r[i.type]||5)-(r[s.type]||5)}).forEach(i=>{var s;switch(i.type){case"bold":o=`**${o}**`;break;case"italic":o=`*${o}*`;break;case"strike":o=`~~${o}~~`;break;case"code":o=`\`${o}\``;break;case"link":{const r=((s=i.attrs)==null?void 0:s.href)||"";o=`[${o}](${r})`;break}}}),o}}}},computed:{attrs(){return{...this.$attrs,onInput:()=>{},onFocus:()=>{},onBlur:()=>{}}},extensions(){const e=[Lt,Nt,ve.UndoRedo,Dt];e.push(this.useDivTags?Po:Ge),this.allowBold&&e.push(At),this.allowBlockquote&&e.push(Et),this.allowBulletList&&(e.push(xe.BulletList),e.push(xe.ListItem.extend({renderText({node:n}){return n.textContent}})),e.push(xe.OrderedList)),this.allowItalic&&e.push(It),this.allowStrike&&e.push(Rt),this.allowUnderline&&e.push(Mt),this.placeholder&&e.push(ve.Placeholder.configure({placeholder:this.placeholder}));const t=this,o=T.Extension.create({addKeyboardShortcuts(){return{"Shift-Enter":({editor:n})=>t.allowLineBreaks?!1:(n.commands.first(({commands:i})=>[()=>i.newlineInCode(),()=>t.allowBulletList&&i.splitListItem("listItem"),()=>i.createParagraphNear(),()=>i.liftEmptyBlock(),()=>i.splitBlock()]),!0),Enter:()=>t.allowLineBreaks?!1:(t.$emit("enter"),!0)}}});if(e.push(o),this.link&&e.push(Bt.extend({inclusive:!1,addKeyboardShortcuts(){return{"Mod-k":()=>(t.$emit("edit-link"),!0)}}}).configure({HTMLAttributes:{class:"d-link d-wb-break-all"},openOnClick:!1,autolink:!0,protocols:de.RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS})),this.customLink&&e.push(this.getExtension(Ho,this.customLink)),this.mentionSuggestion){const n={...this.mentionSuggestion,...ui};e.push(qo.configure({suggestion:n}))}if(this.channelSuggestion){const n={...this.channelSuggestion,...mi};e.push(Xo.configure({suggestion:n}))}if(this.slashCommandSuggestion){const n={...this.slashCommandSuggestion,..._i};e.push(Qo.configure({suggestion:n,onSelectedCommand:i=>{this.$emit("selected-command",i)}}))}return this.allowVariable&&e.push(ii.configure({variableItems:this.variableItems})),e.push(Lo),e.push(Ht.configure({types:["paragraph"]})),this.allowCode&&e.push(St),this.allowCodeblock&&e.push(Ot.extend({renderText({node:n}){return`\`\`\`
10
+ \`\`\``},processMentionNode(e){var i,s,r;const t=((i=e.attrs)==null?void 0:i.name)||"",o=((s=e.attrs)==null?void 0:s.id)||"",n=((r=e.attrs)==null?void 0:r.contactKey)||"";return`<!-- @mention: {"id": "${o}", "contactKey": "${n}", "name": "${t}"} -->`},processChannelNode(e){var s,r,l,c;const t=((s=e.attrs)==null?void 0:s.name)||"",o=((r=e.attrs)==null?void 0:r.id)||"",n=((l=e.attrs)==null?void 0:l.locked.toString())||"",i=((c=e.attrs)==null?void 0:c.channelKey)||"";return`<!-- @channel: {"id": "${o}", "channelKey": "${i}", "name": "${t}", "locked": "${n}"} -->`},processSlashCommandsNode(e){var n,i;const t=((n=e.attrs)==null?void 0:n.command)||"",o=((i=e.attrs)==null?void 0:i.parameters)||"";return`/${t}${o?` ${o}`:""}`},processEmojiNode(e){var t;return((t=e.attrs)==null?void 0:t.code)||""},processVariableNode(e){var n,i;const t=((n=e.attrs)==null?void 0:n.id)||"",o=((i=e.attrs)==null?void 0:i.altText)||"";return`{{${t}=${o}}}`},processUnknownNode(e){return this.processNodeContent(e)},applyMarks(e,t){let o=e;return[...t].sort((i,s)=>{const r={link:0,bold:1,italic:2,strike:3,code:4};return(r[i.type]||5)-(r[s.type]||5)}).forEach(i=>{var s;switch(i.type){case"bold":o=`**${o}**`;break;case"italic":o=`*${o}*`;break;case"strike":o=`~~${o}~~`;break;case"code":o=`\`${o}\``;break;case"link":{const r=((s=i.attrs)==null?void 0:s.href)||"";o=`[${o}](${r})`;break}}}),o}}}},computed:{attrs(){return{...this.$attrs,onInput:()=>{},onFocus:()=>{},onBlur:()=>{}}},extensions(){const e=[Lt,Nt,ve.UndoRedo,At];e.push(this.useDivTags?jo:Ge),this.allowBold&&e.push(Dt),this.allowBlockquote&&e.push(Et),this.allowBulletList&&(e.push(xe.BulletList),e.push(xe.ListItem.extend({renderText({node:n}){return n.textContent}})),e.push(xe.OrderedList)),this.allowItalic&&e.push(It),this.allowStrike&&e.push(Rt),this.allowUnderline&&e.push(Mt),this.placeholder&&e.push(ve.Placeholder.configure({placeholder:this.placeholder}));const t=this,o=T.Extension.create({addKeyboardShortcuts(){return{"Shift-Enter":({editor:n})=>t.allowLineBreaks?!1:(n.commands.first(({commands:i})=>[()=>i.newlineInCode(),()=>t.allowBulletList&&i.splitListItem("listItem"),()=>i.createParagraphNear(),()=>i.liftEmptyBlock(),()=>i.splitBlock()]),!0),Enter:()=>t.allowLineBreaks?!1:(t.$emit("enter"),!0)}}});if(e.push(o),this.link&&e.push(Bt.extend({inclusive:!1,addKeyboardShortcuts(){return{"Mod-k":()=>(t.$emit("edit-link"),!0)}}}).configure({HTMLAttributes:{class:"d-link d-wb-break-all"},openOnClick:!1,autolink:!0,protocols:de.RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS})),this.customLink&&e.push(this.getExtension($o,this.customLink)),this.mentionSuggestion){const n={...this.mentionSuggestion,...fi};e.push(Ko.configure({suggestion:n}))}if(this.channelSuggestion){const n={...this.channelSuggestion,...wi};e.push(Go.configure({suggestion:n}))}if(this.slashCommandSuggestion){const n={...this.slashCommandSuggestion,...Ci};e.push(ti.configure({suggestion:n,onSelectedCommand:i=>{this.$emit("selected-command",i)}}))}return this.allowVariable&&e.push(ri.configure({variableItems:this.variableItems})),e.push(Do),e.push(Ht.configure({types:["paragraph"]})),this.allowCode&&e.push(St),this.allowCodeblock&&e.push(Ot.extend({renderText({node:n}){return`\`\`\`
11
11
  ${n.textContent}
12
- \`\`\``}}).configure({HTMLAttributes:{class:"d-rich-text-editor__code-block"}})),this.allowInlineImages&&e.push(Vo.configure({resize:{enabled:this.allowImageResize,alwaysPreserveAspectRatio:!0}})),(this.allowFontFamily||this.allowFontColor||this.allowFontSize||this.allowBackgroundColor||this.allowLineHeight)&&(e.push(Je.TextStyleKit.configure({color:this.allowFontColor,backgroundColor:this.allowBackgroundColor,fontFamily:this.allowFontFamily,fontSize:this.allowFontSize,lineHeight:this.allowLineHeight})),e.push(Qn)),this.additionalExtensions.length&&e.push(...this.additionalExtensions),this.allowTables&&e.push(Yn.configure({resizable:!0}),Gn,Zn,Jn,ve.Gapcursor),e},inputAttrs(){const e={"aria-label":this.inputAriaLabel,"aria-multiline":!0,role:"textbox"};return this.editable||(e["aria-readonly"]=!0),e}},watch:{editable(e){this.editor.setEditable(e),this.updateEditorAttributes({"aria-readonly":!e})},inputClass(e){this.updateEditorAttributes({class:e})},inputAriaLabel(e){this.updateEditorAttributes({"aria-label":e})},extensions(){this.destroyEditor(),this.createEditor()},modelValue(e){this.processValue(e)}},created(){this.createEditor()},beforeUnmount(){this.destroyEditor()},mounted(){re.warnIfUnmounted(re.returnFirstEl(this.$el),this.$options.name),this.processValue(this.modelValue,!1)},methods:{createEditor(){this.editor=new S.Editor({autofocus:this.autoFocus,content:this.modelValue,editable:this.editable,extensions:this.extensions,shouldRerenderOnTransaction:!1,parseOptions:{preserveWhitespace:this.preserveWhitespace},editorProps:{attributes:{...this.inputAttrs,class:this.inputClass},handleKeyDown:(e,t)=>{if(!this.preventTyping)return!1;const o=["Backspace"];return!this.allowLineBreaks&&!t.shiftKey&&o.push("Enter"),!o.includes(t.key)},handlePaste:(e,t)=>{const o=t.clipboardData||window.clipboardData,n=o.getData("text/plain"),i=o.getData("text/html");return this.processPasteData(e,n,i)},transformPastedHTML(e){return e.replace(/(<\/\w+>)((<br \/>)+)/g,"$2$3$1")}}}),this.addEditorListeners()},bubbleMenuShouldShow({editor:e}){return e.isActive("link")},getSelectedLinkText(e){var l,c,h;const{view:t,state:o}=e,{from:n,to:i}=t.state.selection,s=o.doc.textBetween(n,i,""),r=this.editor.state.doc.nodeAt(n);return r&&((h=(c=(l=r.marks)==null?void 0:l.at(0))==null?void 0:c.type)==null?void 0:h.name)==="link"?r.textContent:s},editLink(){const e=this.getSelectedLinkText(this.editor),t={href:this.editor.getAttributes("link").href,text:e};this.$emit("edit-link",t)},removeLink(){var e,t,o,n;(n=(o=(t=(e=this.editor)==null?void 0:e.chain())==null?void 0:t.focus())==null?void 0:o.unsetLink())==null||n.run()},openLink(){var t,o;(o=(t=this.editor)==null?void 0:t.chain())==null||o.focus();const e=this.editor.getAttributes("link").href;window.open(e,"_blank")},setLink(e,t,o,n=de.RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS,i){var l,c,h;if(!e){this.removeLink();return}n.find(u=>u.test(e))||(e=`${i}${e}`),this.editor.chain().focus().extendMarkRange("link").run();const r=(h=(c=(l=this.editor)==null?void 0:l.view)==null?void 0:c.state)==null?void 0:h.selection;this.editor.chain().focus().insertContent(t).setTextSelection({from:r.from,to:r.from+t.length}).setLink({href:e,class:o.class}).run()},processValue(e,t=!0){if(!this.editor)return;const o=this.getOutput();if(!(t&&Xt(e,o))){if(typeof e=="string"&&this.outputFormat==="text"){const n=new RegExp(`(${Ze.emojiPattern})`,"g");e=e==null?void 0:e.replace(n,'<emoji-component code="$1"></emoji-component>')}this.editor.commands.setContent(e,{emitUpdate:!1,parseOptions:{preserveWhitespace:this.preserveWhitespace}})}},destroyEditor(){this.editor.destroy()},insertPlainTextWithHardBreaks(e,t){const i=(this.pasteRichText?t:t.replace(/\r\n/g,`
12
+ \`\`\``}}).configure({HTMLAttributes:{class:"d-rich-text-editor__code-block"}})),this.allowInlineImages&&e.push(Po.configure({resize:{enabled:this.allowImageResize,alwaysPreserveAspectRatio:!0}})),(this.allowFontFamily||this.allowFontColor||this.allowFontSize||this.allowBackgroundColor||this.allowLineHeight)&&(e.push(Je.TextStyleKit.configure({color:this.allowFontColor,backgroundColor:this.allowBackgroundColor,fontFamily:this.allowFontFamily,fontSize:this.allowFontSize,lineHeight:this.allowLineHeight})),e.push(to)),this.additionalExtensions.length&&e.push(...this.additionalExtensions),this.allowTables&&e.push(Jn.configure({resizable:!0}),Zn,eo,Qn,ve.Gapcursor),e},inputAttrs(){const e={"aria-label":this.inputAriaLabel,"aria-multiline":!0,role:"textbox"};return this.editable||(e["aria-readonly"]=!0),e}},watch:{editable(e){this.editor.setEditable(e),this.updateEditorAttributes({"aria-readonly":!e})},inputClass(e){this.updateEditorAttributes({class:e})},inputAriaLabel(e){this.updateEditorAttributes({"aria-label":e})},extensions(){this.destroyEditor(),this.createEditor()},modelValue(e){this.processValue(e)}},created(){this.createEditor()},beforeUnmount(){this.destroyEditor()},mounted(){re.warnIfUnmounted(re.returnFirstEl(this.$el),this.$options.name),this.processValue(this.modelValue,!1)},methods:{createEditor(){this.editor=new S.Editor({autofocus:this.autoFocus,content:this.modelValue,editable:this.editable,extensions:this.extensions,shouldRerenderOnTransaction:!1,parseOptions:{preserveWhitespace:this.preserveWhitespace},editorProps:{attributes:{...this.inputAttrs,class:this.inputClass},handleKeyDown:(e,t)=>{if(!this.preventTyping)return!1;const o=["Backspace"];return!this.allowLineBreaks&&!t.shiftKey&&o.push("Enter"),!o.includes(t.key)},handlePaste:(e,t)=>{const o=t.clipboardData||window.clipboardData,n=o.getData("text/plain"),i=o.getData("text/html");return this.processPasteData(e,n,i)},transformPastedHTML(e){return e.replace(/(<\/\w+>)((<br \/>)+)/g,"$2$3$1")}}}),this.addEditorListeners()},bubbleMenuShouldShow({editor:e}){return e.isActive("link")},getSelectedLinkText(e){var l,c,h;const{view:t,state:o}=e,{from:n,to:i}=t.state.selection,s=o.doc.textBetween(n,i,""),r=this.editor.state.doc.nodeAt(n);return r&&((h=(c=(l=r.marks)==null?void 0:l.at(0))==null?void 0:c.type)==null?void 0:h.name)==="link"?r.textContent:s},editLink(){const e=this.getSelectedLinkText(this.editor),t={href:this.editor.getAttributes("link").href,text:e};this.$emit("edit-link",t)},removeLink(){var e,t,o,n;(n=(o=(t=(e=this.editor)==null?void 0:e.chain())==null?void 0:t.focus())==null?void 0:o.unsetLink())==null||n.run()},openLink(){var t,o;(o=(t=this.editor)==null?void 0:t.chain())==null||o.focus();const e=this.editor.getAttributes("link").href;window.open(e,"_blank")},setLink(e,t,o,n=de.RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS,i){var l,c,h;if(!e){this.removeLink();return}n.find(u=>u.test(e))||(e=`${i}${e}`),this.editor.chain().focus().extendMarkRange("link").run();const r=(h=(c=(l=this.editor)==null?void 0:l.view)==null?void 0:c.state)==null?void 0:h.selection;this.editor.chain().focus().insertContent(t).setTextSelection({from:r.from,to:r.from+t.length}).setLink({href:e,class:o.class}).run()},processValue(e,t=!0){if(!this.editor)return;const o=this.getOutput();if(!(t&&Xt(e,o))){if(typeof e=="string"&&this.outputFormat==="text"){const n=new RegExp(`(${Ze.emojiPattern})`,"g");e=e==null?void 0:e.replace(n,'<emoji-component code="$1"></emoji-component>')}this.editor.commands.setContent(e,{emitUpdate:!1,parseOptions:{preserveWhitespace:this.preserveWhitespace}})}},destroyEditor(){this.editor.destroy()},insertPlainTextWithHardBreaks(e,t){const i=(this.pasteRichText?t:t.replace(/\r\n/g,`
13
13
  `).replace(/\n\n/g,`
14
14
  `)).replace(/[\r\n]+$/,"").split(/\r?\n/),s=[];for(let r=0;r<i.length;r++)r>0&&s.push({type:"hardBreak"}),i[r]&&s.push({type:"text",text:i[r]});this.editor.chain().focus().insertContent(s).run()},shouldPreserveLineBreaks(e,t){return this.pasteRichText?!t&&e&&this.hasBlankLines(e):!!e},processPasteData(e,t,o){if(this.shouldPreserveLineBreaks(t,o))return this.insertPlainTextWithHardBreaks(e,t),!0;if(this.shouldHandlePreformattedHTML(o)){const n=this.extractPreformattedText(o);if(n&&n.includes(`
15
15
  `))return this.insertPlainTextWithHardBreaks(e,n),!0}return!1},shouldHandlePreformattedHTML(e){return this.pasteRichText&&e&&this.containsPreformattedContent(e)},containsPreformattedContent(e){const t=document.createElement("div");t.innerHTML=e;const o=t.querySelectorAll("*");for(const n of o)if(this.hasPreWhitespace(n)&&this.hasLineBreaks(n))return!0;return!1},hasPreWhitespace(e){const t=e.getAttribute("style")||"",o=e.style.whiteSpace||"",n=o==="pre"||o==="pre-wrap",i=t.includes("white-space: pre");return n||i},hasLineBreaks(e){return e.textContent&&e.textContent.includes(`
@@ -17,5 +17,5 @@ ${n.textContent}
17
17
 
18
18
  `)||/\n\s*\n/.test(e)},extractPreformattedText(e){const t=document.createElement("div");return t.innerHTML=e,this.walkAndExtractText(t)},walkAndExtractText(e){let t="";if(e.nodeType===Node.TEXT_NODE)t+=e.textContent;else if(e.nodeType===Node.ELEMENT_NODE)if(this.hasPreWhitespace(e))t+=e.textContent;else for(const o of e.childNodes)t+=this.walkAndExtractText(o);return t},triggerInputChangeEvents(){const e=this.getOutput();this.$emit("input",e),this.$emit("update:modelValue",e);const t=this.editor.getJSON();this.$emit("json-input",t);const o=this.editor.getHTML();this.$emit("html-input",o);const n=this.editor.getText({blockSeparator:`
19
19
  `});this.$emit("text-input",n);const i=this.jsonToMarkdownConverter.convertToMarkdown(t);this.$emit("markdown-input",i)},addEditorListeners(){this.editor.on("create",()=>{this.triggerInputChangeEvents()}),this.editor.on("update",()=>{this.triggerInputChangeEvents()}),this.editor.on("selectionUpdate",({editor:e})=>{this.$emit("selected",this.getSelectedLinkText(e))}),this.editor.on("focus",({event:e})=>{this.$emit("focus",e)}),this.editor.on("blur",({event:e})=>{this.$emit("blur",e)}),this.editor.on("mention-click",e=>{this.$emit("mention-click",e)}),this.editor.on("mention-hover",e=>{this.$emit("mention-hover",e)}),this.editor.on("mention-leave",e=>{this.$emit("mention-leave",e)}),this.editor.on("channel-click",e=>{this.$emit("channel-click",e)})},getOutput(){switch(this.outputFormat){case"json":return this.editor.getJSON();case"html":return this.editor.getHTML();case"markdown":return this.jsonToMarkdownConverter.convertToMarkdown(this.editor.getJSON());case"text":default:return this.editor.getText({blockSeparator:`
20
- `})}},getExtension(e,t){var o;return typeof t=="boolean"?e:(o=e.configure)==null?void 0:o.call(e,t)},updateEditorAttributes(e){this.editor.setOptions({editorProps:{attributes:{...this.inputAttrs,class:this.inputClass,...e}}})},focusEditor(){this.editor.commands.focus()}}},Ci={class:"d-popover__dialog"};function ki(e,t,o,n,i,s){const r=a.resolveComponent("dt-button"),l=a.resolveComponent("dt-stack"),c=a.resolveComponent("bubble-menu"),h=a.resolveComponent("editor-content");return a.openBlock(),a.createElementBlock("div",null,[i.editor&&o.link&&!o.hideLinkBubbleMenu?(a.openBlock(),a.createBlock(c,{key:0,editor:i.editor,"should-show":s.bubbleMenuShouldShow,options:i.floatingOptions,"append-to":i.appendTo,style:{visibility:"visible"}},{default:a.withCtx(()=>[a.createElementVNode("div",Ci,[a.createVNode(l,{direction:"row",class:"d-rich-text-editor-bubble-menu__button-stack",gap:"0"},{default:a.withCtx(()=>[a.createVNode(r,{kind:"muted",importance:"clear",onClick:s.editLink},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(i.i18n.$t("DIALTONE_RICH_TEXT_EDITOR_EDIT_BUTTON_LABEL")),1)]),_:1},8,["onClick"]),a.createVNode(r,{kind:"muted",importance:"clear",onClick:s.openLink},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(i.i18n.$t("DIALTONE_RICH_TEXT_EDITOR_OPEN_LINK_BUTTON_LABEL")),1)]),_:1},8,["onClick"]),a.createVNode(r,{kind:"danger",importance:"clear",onClick:s.removeLink},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(i.i18n.$t("DIALTONE_RICH_TEXT_EDITOR_REMOVE_BUTTON_LABEL")),1)]),_:1},8,["onClick"])]),_:1})])]),_:1},8,["editor","should-show","options","append-to"])):a.createCommentVNode("",!0),a.createVNode(h,a.mergeProps({ref:"editor",editor:i.editor,class:"d-rich-text-editor","data-qa":"dt-rich-text-editor"},s.attrs),null,16,["editor"])])}const Ei=F._(Ti,[["render",ki]]);exports.default=Ei;
20
+ `})}},getExtension(e,t){var o;return typeof t=="boolean"?e:(o=e.configure)==null?void 0:o.call(e,t)},updateEditorAttributes(e){this.editor.setOptions({editorProps:{attributes:{...this.inputAttrs,class:this.inputClass,...e}}})},focusEditor(){this.editor.commands.focus()}}},Ei={class:"d-popover__dialog"};function Oi(e,t,o,n,i,s){const r=a.resolveComponent("dt-button"),l=a.resolveComponent("dt-stack"),c=a.resolveComponent("bubble-menu"),h=a.resolveComponent("editor-content");return a.openBlock(),a.createElementBlock("div",null,[i.editor&&o.link&&!o.hideLinkBubbleMenu?(a.openBlock(),a.createBlock(c,{key:0,editor:i.editor,"should-show":s.bubbleMenuShouldShow,options:i.floatingOptions,"append-to":i.appendTo,style:{visibility:"visible"}},{default:a.withCtx(()=>[a.createElementVNode("div",Ei,[a.createVNode(l,{direction:"row",class:"d-rich-text-editor-bubble-menu__button-stack",gap:"0"},{default:a.withCtx(()=>[a.createVNode(r,{kind:"muted",importance:"clear",onClick:s.editLink},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(i.i18n.$t("DIALTONE_RICH_TEXT_EDITOR_EDIT_BUTTON_LABEL")),1)]),_:1},8,["onClick"]),a.createVNode(r,{kind:"muted",importance:"clear",onClick:s.openLink},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(i.i18n.$t("DIALTONE_RICH_TEXT_EDITOR_OPEN_LINK_BUTTON_LABEL")),1)]),_:1},8,["onClick"]),a.createVNode(r,{kind:"danger",importance:"clear",onClick:s.removeLink},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(i.i18n.$t("DIALTONE_RICH_TEXT_EDITOR_REMOVE_BUTTON_LABEL")),1)]),_:1},8,["onClick"])]),_:1})])]),_:1},8,["editor","should-show","options","append-to"])):a.createCommentVNode("",!0),a.createVNode(h,a.mergeProps({ref:"editor",editor:i.editor,class:"d-rich-text-editor","data-qa":"dt-rich-text-editor"},s.attrs),null,16,["editor"])])}const Si=F._(ki,[["render",Oi]]);exports.default=Si;
21
21
  //# sourceMappingURL=rich-text-editor.cjs.map