import R from "./last-active-nodes.js";
import { addClassStyleAttrs as U, removeClassStyleAttrs as z, returnFirstEl as q } from "../../common/utils/index.js";
import { Node as H, mergeAttributes as G } from "@tiptap/core";
import { nodeViewProps as K, NodeViewWrapper as W, VueNodeViewRenderer as X } from "../../node_modules/@tiptap/vue-3.js";
import { DtIconVideo as Q, DtIconClose as J, DtIconSend as Y, DtIconSatisfied as Z, DtIconVerySatisfied as $, DtIconImage as ee } from "@dialpad/dialtone-icons/vue3";
import { DialtoneLocalization as v } from "../../localization/index.js";
import { resolveComponent as l, createBlock as u, openBlock as r, withCtx as a, createVNode as c, createTextVNode as te, toDisplayString as T, createElementVNode as m, resolveDirective as w, createElementBlock as y, mergeProps as _, withModifiers as E, renderSlot as p, createCommentVNode as g, withDirectives as k, normalizeStyle as ie, vShow as ne, normalizeClass as oe, createSlots as se } from "vue";
import { _ as C } from "../../_plugin-vue_export-helper-CHgC5LLL.js";
import P from "../button/button.js";
import le from "../item-layout/item-layout.js";
import ae from "./message-input-topbar.js";
import re from "./message-input-link.js";
import { EDITOR_SUPPORTED_LINK_PROTOCOLS as ce, EDITOR_DEFAULT_LINK_PREFIX as de } from "../editor/editor-constants.js";
import ue from "../stack/stack.js";
import me from "../tooltip/tooltip.js";
import pe from "../rich-text-editor/rich-text-editor.js";
import he from "../popover/popover.js";
import ge from "../input/input.js";
import be from "../emoji-picker/emoji-picker.js";
import { RICH_TEXT_EDITOR_OUTPUT_FORMATS as ke, RICH_TEXT_EDITOR_AUTOFOCUS_TYPES as fe } from "../rich-text-editor/rich-text-editor-constants.js";
const _e = {
  name: "MeetingPill",
  components: {
    NodeViewWrapper: W,
    DtItemLayout: le,
    DtIconClose: J,
    DtButton: P,
    DtIconVideo: Q
  },
  props: K,
  emits: ["meeting-pill-close"],
  data() {
    return {
      i18n: new v()
    };
  },
  computed: {
    closeButtonTitle() {
      return this.i18n.$t("DIALTONE_CLOSE_BUTTON");
    }
  },
  methods: {
    close(t) {
      var i, d, o;
      const e = (o = (d = (i = this.editor) == null ? void 0 : i.storage) == null ? void 0 : d.meetingPill) == null ? void 0 : o.onClose;
      e && typeof e == "function" && e(t);
    }
  }
}, Te = { class: "d-recipe-message-input-meeting-pill__icon" }, Se = { class: "d-recipe-message-input-meeting-pill__close" };
function Le(t, e, i, d, o, n) {
  const S = l("dt-icon-video"), L = l("dt-icon-close"), I = l("dt-button"), O = l("dt-item-layout"), b = l("node-view-wrapper");
  return r(), u(b, { class: "d-recipe-message-input-meeting-pill" }, {
    default: a(() => [
      c(O, {
        class: "d-recipe-message-input-meeting-pill__layout",
        unstyled: ""
      }, {
        left: a(() => [
          m("div", Te, [
            c(S, { size: "400" })
          ])
        ]),
        right: a(() => [
          m("div", Se, [
            c(I, {
              circle: "",
              importance: "clear",
              size: "xs",
              "aria-label": n.closeButtonTitle,
              title: n.closeButtonTitle,
              onClick: n.close
            }, {
              icon: a(() => [
                c(L, { size: "300" })
              ]),
              _: 1
            }, 8, ["aria-label", "title", "onClick"])
          ])
        ]),
        default: a(() => [
          te(" " + T(t.node.attrs.text) + " ", 1)
        ]),
        _: 1
      })
    ]),
    _: 1
  });
}
const Ie = /* @__PURE__ */ C(_e, [["render", Le]]), Oe = H.create({
  name: "meetingPill",
  atom: !0,
  group: "inline",
  inline: !0,
  addOptions() {
    return {
      onClose: () => {
      }
    };
  },
  addStorage() {
    return {
      onClose: this.options.onClose
    };
  },
  addNodeView() {
    return X(Ie);
  },
  addAttributes() {
    return {
      text: {
        default: 'Please pass in "text" attribute'
      }
    };
  },
  parseHTML() {
    return [
      {
        tag: "meeting-pill"
      }
    ];
  },
  renderText() {
    return "/dpm";
  },
  renderHTML({ HTMLAttributes: t }) {
    return ["meeting-pill", G(t)];
  }
}), ye = {
  compatConfig: { MODE: 3 },
  name: "DtRecipeMessageInput",
  components: {
    DtButton: P,
    DtEmojiPicker: be,
    DtInput: ge,
    DtPopover: he,
    DtRecipeMessageInputTopbar: ae,
    DtRecipeMessageInputLink: re,
    DtRichTextEditor: pe,
    DtTooltip: me,
    DtStack: ue,
    DtIconImage: ee,
    DtIconVerySatisfied: $,
    DtIconSatisfied: Z,
    DtIconSend: Y
  },
  inheritAttrs: !1,
  props: {
    /**
     * Displays all the buttons for rich text formatting above the message input, and enables it within the editor.
     * Rich text formatting for the purposes of this component is defined as:
     *
     * bold, italic, strikethrough, lists, blockquotes, inline code tags, and code blocks.
     *
     * If you are sending a message to a phone rather than a Dialpad to Dialpad message, you should have this as false.
     */
    richText: {
      type: Boolean,
      default: !0
    },
    /**
     * Value of the input. The object format should match TipTap's JSON
     * document structure: https://tiptap.dev/guide/output#option-1-json
     */
    modelValue: {
      type: [Object, String],
      default: ""
    },
    /**
     * Whether the input is editable
     */
    editable: {
      type: Boolean,
      default: !0
    },
    /**
     * Descriptive label for the input element
     */
    inputAriaLabel: {
      type: String,
      required: !0,
      default: ""
    },
    /**
     * Prevents the user from typing any further. Deleting text will still work.
     */
    preventTyping: {
      type: Boolean,
      default: !1
    },
    /**
     * Additional class name for the input element. Only accepts a String value
     * because this is passed to the editor via options. For multiple classes,
     * join them into one string, e.g. "d-p8 d-hmx96"
     */
    inputClass: {
      type: String,
      default: ""
    },
    /**
     * Whether the input should receive focus after the component has been
     * mounted. Either one of `start`, `end`, `all` or a Boolean or a Number.
     * - `start`  Sets the focus to the beginning of the input
     * - `end`    Sets the focus to the end of the input
     * - `all`    Selects the whole contents of the input
     * - `Number` Sets the focus to a specific position in the input
     * - `true`   Defaults to `start`
     * - `false`  Disables autofocus
     * @values true, false, start, end, all, number
     */
    autoFocus: {
      type: [Boolean, String, Number],
      default: !1,
      validator(t) {
        return typeof t == "string" ? fe.includes(t) : !0;
      }
    },
    /**
     * The output format that the editor uses when emitting the "@input" event.
     * One of `text`, `json`, `html`, `markdown`. See https://tiptap.dev/guide/output for
     * examples.
     * @values text, json, html, markdown
     */
    outputFormat: {
      type: String,
      default: "json",
      validator(t) {
        return ke.includes(t);
      }
    },
    /**
     * Placeholder text
     */
    placeholder: {
      type: String,
      default: ""
    },
    /**
     * Disable Send Button
     */
    disableSend: {
      type: Boolean,
      default: !1
    },
    /**
     * Content area needs to dynamically adjust height based on the conversation area height.
     * can be vh|px|rem|em|%
     */
    maxHeight: {
      type: String,
      default: "unset"
    },
    // Emoji picker props
    showEmojiPicker: {
      type: Boolean,
      default: !0
    },
    /**
     * Props to pass into the emoji picker.
     */
    emojiPickerProps: {
      type: Object,
      default: () => ({})
    },
    /**
     * Enable character Limit warning
     */
    showCharacterLimit: {
      type: [Boolean, Object],
      default: () => ({ count: 1500, warning: 500, message: "" })
    },
    showImagePicker: {
      type: [Boolean, Object],
      default: () => ({})
    },
    /**
     * Send button defaults.
     * TODO (Dialtone 10):
     * - Change to `showSendButton`, boolean only.
     */
    showSend: {
      type: [Boolean, Object],
      default: () => ({})
    },
    /**
     * TODO (Dialtone 10):
     * - Add a prop `iconOnly` default: true to control if localized send button text should be shown
     */
    /**
     * Cancel button defaults.
     * TODO (Dialtone 10): Change to `showCancelButton`, boolean only.
     */
    showCancel: {
      type: [Boolean, Object],
      default: () => ({})
    },
    /**
     * suggestion object containing the items query function.
     * The valid keys passed into this object can be found here: https://tiptap.dev/api/utilities/suggestion
     *
     * The only required key is the items function which is used to query the contacts for suggestion.
     * items({ query }) => { return [ContactObject]; }
     * ContactObject format:
     * { name: string, avatarSrc: string, id: string }
     *
     * When null, it does not add the plugin.
     */
    mentionSuggestion: {
      type: Object,
      default: null
    },
    /**
     * suggestion object containing the items query function.
     * The valid keys passed into this object can be found here: https://tiptap.dev/api/utilities/suggestion
     *
     * The only required key is the items function which is used to query the channels for suggestion.
     * items({ query }) => { return [ChannelObject]; }
     * ChannelObject format:
     * { name: string, id: string, locked: boolean }
     *
     * When null, it does not add the plugin. Setting locked to true will display a lock rather than hash.
     */
    channelSuggestion: {
      type: Object,
      default: null
    },
    /**
     * suggestion object containing the items query function.
     * The valid keys passed into this object can be found here: https://tiptap.dev/api/utilities/suggestion
     *
     * The only required key is the items function which is used to query the slash commands for suggestion.
     * items({ query }) => { return [SlashCommandObject]; }
     * SlashCommandObject format:
     * { command: string, description: string, parametersExample?: string }
     * The "parametersExample" parameter is optional, and describes an example
     * of the parameters that command can take.
     *
     * When null, it does not add the plugin.
     */
    slashCommandSuggestion: {
      type: Object,
      default: null
    },
    /**
     * descriptive text fields for the bold button
     *
     * object format:
     * { keyboardShortcutText: string }
     */
    boldButtonOptions: {
      type: Object,
      default: () => ({
        keyboardShortcutText: "Mod + B"
      })
    },
    /**
     * descriptive text fields for the italic button
     *
     * object format:
     * { keyboardShortcutText: string }
     */
    italicButtonOptions: {
      type: Object,
      default: () => ({
        keyboardShortcutText: "Mod + I"
      })
    },
    /**
     * descriptive text fields for the strikethrough button
     *
     * object format:
     * { keyboardShortcutText: string }
     */
    strikeButtonOptions: {
      type: Object,
      default: () => ({
        keyboardShortcutText: "Mod + Shift + S"
      })
    },
    /**
     * descriptive text fields for the link button
     *
     * object format:
     * { keyboardShortcutText: string }
     */
    linkButtonOptions: {
      type: Object,
      default: () => ({
        // TODO: implement mod k
        keyboardShortcutText: "Mod + K",
        linkPlaceholder: "e.g. https://www.dialpad.com"
      })
    },
    /**
     * descriptive text fields for the bullet list button
     *
     * object format:
     * { keyboardShortcutText: string }
     */
    bulletListButtonOptions: {
      type: Object,
      default: () => ({
        keyboardShortcutText: "Mod + Shift + 8"
      })
    },
    /**
     * descriptive text fields for the ordered list button
     *
     * object format:
     * { keyboardShortcutText: string }
     */
    orderedListButtonOptions: {
      type: Object,
      default: () => ({
        keyboardShortcutText: "Mod + Shift + 7"
      })
    },
    /**
     * descriptive text fields for the italic button
     *
     * object format:
     * { keyboardShortcutText: string }
     */
    blockQuoteButtonOptions: {
      type: Object,
      default: () => ({
        keyboardShortcutText: "Mod + Shift + B"
      })
    },
    /**
     * descriptive text fields for the code button
     *
     * object format:
     * { keyboardShortcutText: string }
     */
    codeButtonOptions: {
      type: Object,
      default: () => ({
        keyboardShortcutText: "Mod + E"
      })
    },
    /**
     * descriptive text fields for the code block button
     *
     * object format:
     * { keyboardShortcutText: string }
     */
    codeBlockButtonOptions: {
      type: Object,
      default: () => ({
        keyboardShortcutText: "Mod + Alt + C"
      })
    }
  },
  emits: [
    /**
     * Fires when send button is clicked
     *
     * @event submit
     * @type {String}
     */
    "submit",
    /**
     * Fires when media is selected from image button
     *
     * @event select-media
     * @type {Array}
     */
    "select-media",
    /**
     * Fires when media is dropped into the message input
     *
     * @event add-media
     * @type {Array}
     */
    "add-media",
    /**
     * Fires when media is pasted into the message input
     *
     * @event paste-media
     * @type {Array}
     */
    "paste-media",
    /**
     * Fires when cancel button is pressed (only on edit mode)
     *
     * @event cancel
     * @type {Boolean}
     */
    "cancel",
    /**
     * Fires when skin tone is selected from the emoji picker
     *
     * @event skin-tone
     * @type {String}
     */
    "skin-tone",
    /**
     * Fires when emoji is selected from the emoji picker
     *
     * @event selected-emoji
     * @type {String}
     */
    "selected-emoji",
    /**
     * Fires when a slash command is selected
     *
     * @event selected-command
     * @type {String}
     */
    "selected-command",
    /**
     * Fires when meeting pill is closed
     *
     * @event meeting-pill-close
     * @type {String}
     */
    "meeting-pill-close",
    /**
     * Event to sync the value with the parent
     * @event update:modelValue
     * @type {String|JSON}
     */
    "update:modelValue",
    /**
     * Emitted when input changes, returns text content only
     * @event text-input
     * @type {String}
     */
    "text-input",
    /**
     * Emitted when input changes, returns markdown content only
     * @event markdown-input
     * @type {String}
     */
    "markdown-input",
    /**
     * Emitted when the 'Add emoji' button is clicked
     * @event add-emoji
     * @type {Boolean}
     */
    "add-emoji",
    /**
     * Emitted when the emoji picker scroll reaches the bottom
     * @event emoji-scroll-bottom-reached
     */
    "emoji-scroll-bottom-reached"
  ],
  data() {
    return {
      // If an ordered list is nested within an unordered list, we only want to show the currently selected list as
      // active. This function performs the logic to determine the farthest active node from the root.
      lastActiveNodes: R,
      additionalExtensions: [
        Oe.configure({
          onClose: (t) => {
            this.$emit("meeting-pill-close", t);
          }
        })
      ],
      internalInputValue: this.modelValue,
      // internal input content
      imagePickerFocus: !1,
      emojiPickerFocus: !1,
      emojiPickerOpened: !1,
      isFocused: !1,
      linkOptions: {
        class: "d-link d-c-text d-d-inline-block"
      },
      linkDialogOpen: !1,
      selectedText: "",
      text: "",
      hideLinkBubbleMenu: !1,
      i18n: new v()
    };
  },
  computed: {
    showSendIcon() {
      return !this.showSend.text;
    },
    inputLength() {
      return this.text.length;
    },
    displayCharacterLimitWarning() {
      return !!this.showCharacterLimit && this.showCharacterLimit.count - this.inputLength <= this.showCharacterLimit.warning;
    },
    characterLimitTooltipEnabled() {
      return this.showCharacterLimit.message && this.showCharacterLimit.count - this.inputLength < 0;
    },
    isSendDisabled() {
      return this.disableSend || this.showCharacterLimit && this.inputLength > this.showCharacterLimit.count;
    },
    emojiPickerHovered() {
      return this.emojiPickerFocus || this.emojiPickerOpened;
    },
    sendIconSize() {
      return "300";
    },
    sendButtonLabel() {
      return this.i18n.$t("DIALTONE_MESSAGE_INPUT_SEND_BUTTON_ARIA_LABEL");
    },
    imagePickerButtonLabel() {
      return this.i18n.$t("DIALTONE_MESSAGE_INPUT_IMAGE_PICKER_BUTTON_ARIA_LABEL");
    },
    emojiPickerButtonLabel() {
      return this.i18n.$t("DIALTONE_MESSAGE_INPUT_EMOJI_PICKER_BUTTON_ARIA_LABEL");
    },
    cancelButtonLabel() {
      return this.i18n.$t("DIALTONE_MESSAGE_INPUT_CANCEL_BUTTON_ARIA_LABEL");
    }
  },
  watch: {
    modelValue(t) {
      this.internalInputValue = t;
    },
    emojiPickerOpened(t) {
      var e;
      t || (e = this.$refs.richTextEditor) == null || e.focusEditor();
    }
  },
  created() {
    this.modelValue && this.outputFormat === "text" ? this.internalInputValue = this.modelValue.replace(/\n/g, "<br>") : this.internalInputValue = this.modelValue;
  },
  methods: {
    removeClassStyleAttrs: z,
    addClassStyleAttrs: U,
    linkDialogOpened(t) {
      var e;
      this.linkDialogOpen = t, t === !0 ? this.initLinkDialog() : (this.hideLinkBubbleMenu = !1, (e = this.$refs.richTextEditor) == null || e.focusEditor());
    },
    handleTopbarClick(t) {
      var d;
      const e = (d = this.$refs.richTextEditor) == null ? void 0 : d.editor, i = {
        bold: () => e == null ? void 0 : e.chain().focus().toggleBold().run(),
        italic: () => e == null ? void 0 : e.chain().focus().toggleItalic().run(),
        strike: () => e == null ? void 0 : e.chain().focus().toggleStrike().run(),
        bulletList: () => e == null ? void 0 : e.chain().focus().toggleBulletList().run(),
        orderedList: () => e == null ? void 0 : e.chain().focus().toggleOrderedList().run(),
        blockquote: () => e == null ? void 0 : e.chain().focus().toggleBlockquote().run(),
        code: () => e == null ? void 0 : e.chain().focus().toggleCode().run(),
        codeBlock: () => e == null ? void 0 : e.chain().focus().toggleCodeBlock().run()
      };
      e && i[t] && i[t]();
    },
    // Checks if the node currently selected is active ex/ the bold button is active if the selected text is bold
    isSelectionActive(t) {
      var e, i, d, o;
      return ["bulletList", "orderedList"].includes(t) ? this.lastActiveNodes((i = (e = this.$refs.richTextEditor) == null ? void 0 : e.editor) == null ? void 0 : i.state, [{ type: "bulletList" }, { type: "orderedList" }]).includes(t) && this.isFocused : ((o = (d = this.$refs.richTextEditor) == null ? void 0 : d.editor) == null ? void 0 : o.isActive(t)) && this.isFocused;
    },
    initLinkDialog() {
      var t, e, i;
      this.$refs.link.setInitialValues(this.selectedText, (i = (e = (t = this.$refs.richTextEditor) == null ? void 0 : t.editor) == null ? void 0 : e.getAttributes("link")) == null ? void 0 : i.href), this.hideLinkBubbleMenu = !0, this.linkDialogOpen = !0;
    },
    removeLink() {
      var t;
      (t = this.$refs.richTextEditor) == null || t.removeLink(), this.linkDialogOpen = !1;
    },
    setLink(t, e) {
      this.$refs.richTextEditor.setLink(
        e,
        t,
        this.linkOptions,
        ce,
        de
      ), this.linkDialogOpen = !1;
    },
    // Mousedown instead of click because it fires before the blur event.
    onMousedown(t) {
      q(this.$refs.richTextEditor.$el).querySelector(".tiptap").contains(t.target) || (t.preventDefault(), this.$refs.richTextEditor.focusEditor());
    },
    onDrop(t) {
      const e = t.dataTransfer, i = Array.from(e.files);
      this.$emit("add-media", i);
    },
    onPaste(t) {
      if (t.clipboardData.files.length) {
        t.stopPropagation(), t.preventDefault();
        const e = [...t.clipboardData.files];
        this.$emit("paste-media", e);
      }
    },
    onSkinTone(t) {
      this.$emit("skin-tone", t);
    },
    onSelectEmoji(t, e) {
      t && (t.shift_key || e(), this.$refs.richTextEditor.editor.commands.insertContent({
        type: "emoji",
        attrs: {
          code: t.shortname,
          image: t.image,
          name: t.name
        }
      }), this.$emit("selected-emoji", t));
    },
    onSelectImage() {
      this.$refs.messageInputImageUpload.$refs.input.click();
    },
    onImageUpload() {
      this.$emit(
        "select-media",
        this.$refs.messageInputImageUpload.$refs.input.files
      );
    },
    toggleEmojiPicker() {
      this.emojiPickerOpened = !this.emojiPickerOpened;
    },
    onSend() {
      this.isSendDisabled || this.$emit("submit", this.internalInputValue);
    },
    onCancel() {
      this.$emit("cancel");
    },
    onInput(t) {
      this.$emit("update:modelValue", t);
    },
    onTextInput(t) {
      this.text = t, this.$emit("text-input", t);
    },
    onMarkdownInput(t) {
      this.$emit("markdown-input", t);
    }
  }
}, Be = { class: "d-recipe-message-input__bottom-section" }, we = { class: "d-recipe-message-input__bottom-section-left" }, Ee = { class: "d-recipe-message-input__bottom-section-right" }, ve = { class: "d-recipe-message-input__schedule-message" }, Ce = { class: "d-recipe-message-input__sms-count" }, Pe = { key: 0 };
function xe(t, e, i, d, o, n) {
  const S = l("dt-recipe-message-input-link"), L = l("dt-recipe-message-input-topbar"), I = l("dt-rich-text-editor"), O = l("dt-icon-image"), b = l("dt-button"), x = l("dt-input"), D = l("dt-icon-very-satisfied"), j = l("dt-icon-satisfied"), A = l("dt-emoji-picker"), M = l("dt-popover"), B = l("dt-stack"), V = l("dt-tooltip"), N = l("dt-icon-send"), F = w("dt-scrollbar"), f = w("dt-tooltip");
  return r(), y("div", _({
    "data-qa": "dt-recipe-message-input",
    role: "presentation",
    class: "d-recipe-message-input"
  }, n.addClassStyleAttrs(t.$attrs), {
    onDragover: e[15] || (e[15] = E(() => {
    }, ["prevent"])),
    onDrop: e[16] || (e[16] = E((...s) => n.onDrop && n.onDrop(...s), ["prevent"])),
    onPaste: e[17] || (e[17] = (...s) => n.onPaste && n.onPaste(...s)),
    onMousedown: e[18] || (e[18] = (...s) => n.onMousedown && n.onMousedown(...s))
  }), [
    p(t.$slots, "top"),
    i.richText ? (r(), u(L, {
      key: o.selectedText,
      "bold-button-options": i.boldButtonOptions,
      "italic-button-options": i.italicButtonOptions,
      "strike-button-options": i.strikeButtonOptions,
      "bullet-list-button-options": i.bulletListButtonOptions,
      "ordered-list-button-options": i.orderedListButtonOptions,
      "block-quote-button-options": i.blockQuoteButtonOptions,
      "code-button-options": i.codeButtonOptions,
      "code-block-button-options": i.codeBlockButtonOptions,
      "is-selection-active": n.isSelectionActive,
      onClick: n.handleTopbarClick
    }, {
      link: a(() => [
        c(S, {
          ref: "link",
          open: o.linkDialogOpen,
          "link-button-options": i.linkButtonOptions,
          "is-selection-active": n.isSelectionActive,
          onOpened: n.linkDialogOpened,
          onSetLink: n.setLink,
          onRemoveLink: n.removeLink
        }, null, 8, ["open", "link-button-options", "is-selection-active", "onOpened", "onSetLink", "onRemoveLink"])
      ]),
      _: 1
    }, 8, ["bold-button-options", "italic-button-options", "strike-button-options", "bullet-list-button-options", "ordered-list-button-options", "block-quote-button-options", "code-button-options", "code-block-button-options", "is-selection-active", "onClick"])) : g("", !0),
    k((r(), y("div", {
      class: "d-recipe-message-input__editor-wrapper",
      style: ie({ "max-height": i.maxHeight })
    }, [
      c(I, _({
        ref: "richTextEditor",
        modelValue: o.internalInputValue,
        "onUpdate:modelValue": e[0] || (e[0] = (s) => o.internalInputValue = s),
        "allow-blockquote": i.richText,
        "allow-bold": i.richText,
        "allow-bullet-list": i.richText,
        "allow-code": i.richText,
        "allow-codeblock": i.richText,
        "allow-italic": i.richText,
        "allow-strike": i.richText,
        "allow-underline": i.richText,
        "paste-rich-text": i.richText,
        editable: i.editable,
        "input-aria-label": i.inputAriaLabel,
        "input-class": i.inputClass,
        "output-format": i.outputFormat,
        "auto-focus": i.autoFocus,
        link: i.richText,
        placeholder: i.placeholder,
        "prevent-typing": i.preventTyping,
        "mention-suggestion": i.mentionSuggestion,
        "channel-suggestion": i.channelSuggestion,
        "slash-command-suggestion": i.slashCommandSuggestion,
        "additional-extensions": o.additionalExtensions,
        "hide-link-bubble-menu": o.hideLinkBubbleMenu
      }, n.removeClassStyleAttrs(t.$attrs), {
        onInput: n.onInput,
        onTextInput: n.onTextInput,
        onMarkdownInput: n.onMarkdownInput,
        onEnter: n.onSend,
        onSelected: e[1] || (e[1] = (s) => o.selectedText = s),
        onSelectedCommand: e[2] || (e[2] = (s) => t.$emit("selected-command", s)),
        onEditLink: n.initLinkDialog,
        onFocus: e[3] || (e[3] = (s) => o.isFocused = !0),
        onBlur: e[4] || (e[4] = (s) => o.isFocused = !1)
      }), null, 16, ["modelValue", "allow-blockquote", "allow-bold", "allow-bullet-list", "allow-code", "allow-codeblock", "allow-italic", "allow-strike", "allow-underline", "paste-rich-text", "editable", "input-aria-label", "input-class", "output-format", "auto-focus", "link", "placeholder", "prevent-typing", "mention-suggestion", "channel-suggestion", "slash-command-suggestion", "additional-extensions", "hide-link-bubble-menu", "onInput", "onTextInput", "onMarkdownInput", "onEnter", "onEditLink"])
    ], 4)), [
      [F]
    ]),
    p(t.$slots, "middle"),
    m("section", Be, [
      m("div", we, [
        c(B, {
          gap: "200",
          direction: "row"
        }, {
          default: a(() => [
            i.showImagePicker ? k((r(), u(b, {
              key: 0,
              "data-qa": "dt-recipe-message-input-image-btn",
              size: "sm",
              class: "d-recipe-message-input__button",
              kind: "muted",
              importance: "clear",
              "aria-label": n.imagePickerButtonLabel,
              onClick: n.onSelectImage,
              onMouseenter: e[5] || (e[5] = (s) => o.imagePickerFocus = !0),
              onMouseleave: e[6] || (e[6] = (s) => o.imagePickerFocus = !1),
              onFocus: e[7] || (e[7] = (s) => o.imagePickerFocus = !0),
              onBlur: e[8] || (e[8] = (s) => o.imagePickerFocus = !1)
            }, {
              icon: a(() => [
                c(O, { size: "300" })
              ]),
              _: 1
            }, 8, ["aria-label", "onClick"])), [
              [f, n.imagePickerButtonLabel, "top-start"]
            ]) : g("", !0),
            c(x, {
              ref: "messageInputImageUpload",
              "data-qa": "dt-recipe-message-input-image-input",
              accept: "image/*, video/*",
              type: "file",
              class: "d-recipe-message-input__image-input",
              multiple: "",
              hidden: "",
              onInput: n.onImageUpload
            }, null, 8, ["onInput"]),
            i.showEmojiPicker ? (r(), u(M, {
              key: 1,
              "open.sync": "emojiPickerOpened",
              "data-qa": "dt-recipe-message-input-emoji-picker-popover",
              "initial-focus-element": "#searchInput",
              padding: "none"
            }, {
              anchor: a(({ attrs: s }) => [
                k((r(), u(b, _(s, {
                  "data-qa": "dt-recipe-message-input-emoji-picker-btn",
                  size: "sm",
                  class: "d-recipe-message-input__button",
                  kind: "muted",
                  importance: "clear",
                  "aria-label": n.emojiPickerButtonLabel,
                  onClick: n.toggleEmojiPicker,
                  onMouseenter: e[9] || (e[9] = (h) => o.emojiPickerFocus = !0),
                  onMouseleave: e[10] || (e[10] = (h) => o.emojiPickerFocus = !1),
                  onFocus: e[11] || (e[11] = (h) => o.emojiPickerFocus = !0),
                  onBlur: e[12] || (e[12] = (h) => o.emojiPickerFocus = !1)
                }), {
                  icon: a(() => [
                    n.emojiPickerHovered ? (r(), u(D, {
                      key: 0,
                      size: "300"
                    })) : (r(), u(j, {
                      key: 1,
                      size: "300"
                    }))
                  ]),
                  _: 1
                }, 16, ["aria-label", "onClick"])), [
                  [f, n.emojiPickerButtonLabel]
                ])
              ]),
              content: a(({ close: s }) => [
                c(A, _(i.emojiPickerProps, {
                  onAddEmoji: e[13] || (e[13] = (h) => t.$emit("add-emoji")),
                  onSkinTone: n.onSkinTone,
                  onSelectedEmoji: (h) => n.onSelectEmoji(h, s),
                  onScrollBottomReached: e[14] || (e[14] = (h) => t.$emit("emoji-scroll-bottom-reached"))
                }), null, 16, ["onSkinTone", "onSelectedEmoji"])
              ]),
              _: 1
            })) : g("", !0),
            p(t.$slots, "emojiGiphyPicker"),
            p(t.$slots, "customActionIcons")
          ]),
          _: 3
        })
      ]),
      m("div", Ee, [
        c(B, {
          direction: "row",
          gap: "300"
        }, {
          default: a(() => [
            m("div", ve, [
              p(t.$slots, "scheduleMessage")
            ]),
            m("div", Ce, [
              p(t.$slots, "smsCount")
            ]),
            i.showCharacterLimit ? (r(), u(V, {
              key: 0,
              class: "d-recipe-message-input__remaining-char-tooltip",
              placement: "top-end",
              enabled: n.characterLimitTooltipEnabled,
              message: i.showCharacterLimit.message,
              offset: [10, 8]
            }, {
              anchor: a(() => [
                k(m("p", {
                  class: "d-recipe-message-input__remaining-char",
                  "data-qa": "dt-recipe-message-input-character-limit"
                }, T(i.showCharacterLimit.count - n.inputLength), 513), [
                  [ne, n.displayCharacterLimitWarning]
                ])
              ]),
              _: 1
            }, 8, ["enabled", "message"])) : g("", !0),
            i.showCancel ? k((r(), u(b, {
              key: 1,
              "data-qa": "dt-recipe-message-input-cancel-button",
              class: "d-recipe-message-input__button d-recipe-message-input__cancel-button",
              size: "sm",
              kind: "muted",
              importance: "clear",
              "aria-label": n.cancelButtonLabel,
              onClick: n.onCancel
            }, {
              default: a(() => [
                m("p", null, T(n.cancelButtonLabel), 1)
              ]),
              _: 1
            }, 8, ["aria-label", "onClick"])), [
              [f, n.cancelButtonLabel]
            ]) : g("", !0),
            p(t.$slots, "sendButton", {}, () => [
              i.showSend ? k((r(), u(b, {
                key: 0,
                "data-qa": "dt-recipe-message-input-send-btn",
                size: "sm",
                kind: "default",
                importance: "primary",
                class: oe([
                  "d-recipe-message-input__button d-recipe-message-input__send-button",
                  {
                    "d-recipe-message-input__send-button--disabled": n.isSendDisabled,
                    "d-btn--icon-only": n.showSendIcon
                  }
                ]),
                "aria-label": n.sendButtonLabel,
                "aria-disabled": n.isSendDisabled,
                onClick: n.onSend
              }, se({
                default: a(() => [
                  i.showSend.text ? (r(), y("p", Pe, T(i.showSend.text), 1)) : g("", !0)
                ]),
                _: 2
              }, [
                n.showSendIcon ? {
                  name: "icon",
                  fn: a(() => [
                    p(t.$slots, "sendIcon", { iconSize: n.sendIconSize }, () => [
                      c(N, { size: n.sendIconSize }, null, 8, ["size"])
                    ])
                  ]),
                  key: "0"
                } : void 0
              ]), 1032, ["class", "aria-label", "aria-disabled", "onClick"])), [
                [f, n.sendButtonLabel, "top-end"]
              ]) : g("", !0)
            ])
          ]),
          _: 3
        })
      ])
    ])
  ], 16);
}
const $e = /* @__PURE__ */ C(ye, [["render", xe]]);
export {
  $e as default
};
//# sourceMappingURL=message-input.js.map
