import { jsx } from "react/jsx-runtime";
import { ContextInput, mergeRefs } from "@choiceform/design-system";
import { memo, forwardRef } from "react";
import { t } from "../../../../i18n/index.js";
import { promptTextAreaTv } from "./tv.js";
import { usePromptInputContext } from "../../context/prompt-input-context.js";
const PromptTextArea = memo(
  forwardRef(function PromptTextArea2(props, ref) {
    const { className, children, ...rest } = props;
    const {
      contextInputRef,
      inputValue,
      placeholder,
      mentionTriggers,
      mentionPrefix,
      minHeight,
      variant,
      size,
      handleInputChange,
      handleKeyDown,
      handleCompositionStart,
      handleCompositionEnd,
      onMentionSelect,
      setIsInputFocused
    } = usePromptInputContext();
    const inputPlaceholder = t("prompt-input", "input-placeholder");
    const tv = promptTextAreaTv({ size });
    return /* @__PURE__ */ jsx(
      ContextInput,
      {
        className: tv.input({ className }),
        ref: mergeRefs(contextInputRef, ref),
        value: inputValue,
        placeholder: placeholder ?? inputPlaceholder,
        mentionPrefix,
        triggers: mentionTriggers,
        minHeight,
        variant,
        size,
        onChange: handleInputChange,
        onKeyDown: handleKeyDown,
        onCompositionStart: handleCompositionStart,
        onCompositionEnd: handleCompositionEnd,
        onMentionSelect,
        onFocus: () => setIsInputFocused(true),
        onBlur: () => setIsInputFocused(false),
        ...rest,
        children: children && /* @__PURE__ */ jsx(ContextInput.Footer, { className: tv.footer(), children })
      }
    );
  })
);
export {
  PromptTextArea
};
//# sourceMappingURL=prompt-text-area.js.map
