"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const designSystem = require("@choiceform/design-system");
const iconsReact = require("@choiceform/icons-react");
const react = require("../../../../_vendor/@legendapp/state/react.cjs");
const React = require("react");
const index = require("../../../../_vendor/usehooks-ts/dist-index.cjs");
const index$1 = require("../../../../i18n/index.cjs");
const pasteFileUrlDialog = require("./paste-file-url-dialog.cjs");
const promptInputContext = require("../../context/prompt-input-context.cjs");
const PromptContextMenu = react.observer(function PromptContextMenu2() {
  const {
    attachmentEnabled,
    handleFileButtonClick,
    allowUploadByUrl,
    allowUploadLocalFiles,
    attachmentMaxCount,
    dragCtx
  } = promptInputContext.usePromptInputContext();
  const [isDialogOpen, setIsDialogOpen] = React.useState(false);
  const handlePasteFileUrl = index.useEventCallback(() => {
    setIsDialogOpen(true);
  });
  const addContext = index$1.t("prompt-input", "add-context");
  const attachFiles = index$1.t("prompt-input", "attach-files");
  const pasteFileUrl = index$1.t("prompt-input", "paste-file-url");
  const isAttachmentLimitReached = attachmentMaxCount !== void 0 && dragCtx?.attachments.length !== void 0 && dragCtx.attachments.length >= attachmentMaxCount;
  const isUploadEnabled = allowUploadLocalFiles && !isAttachmentLimitReached;
  const isPasteUrlEnabled = allowUploadByUrl && !isAttachmentLimitReached;
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
    /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dropdown, { children: [
      /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dropdown.Trigger, { asChild: true, children: (active) => /* @__PURE__ */ jsxRuntime.jsx(
        designSystem.IconButton,
        {
          tooltip: {
            disabled: active,
            content: addContext
          },
          children: /* @__PURE__ */ jsxRuntime.jsx(iconsReact.PromptToolbarAdd, {})
        }
      ) }),
      /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dropdown.Content, { children: [
        /* @__PURE__ */ jsxRuntime.jsx(
          designSystem.Dropdown.Item,
          {
            prefixElement: /* @__PURE__ */ jsxRuntime.jsx(iconsReact.PromptToolbarAttach, {}),
            onClick: handleFileButtonClick,
            disabled: !isUploadEnabled,
            children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dropdown.Value, { children: attachFiles })
          }
        ),
        allowUploadByUrl !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(
          designSystem.Dropdown.Item,
          {
            prefixElement: /* @__PURE__ */ jsxRuntime.jsx(iconsReact.CloudUpload, {}),
            onClick: handlePasteFileUrl,
            disabled: !isPasteUrlEnabled,
            children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dropdown.Value, { children: pasteFileUrl })
          }
        )
      ] })
    ] }),
    allowUploadByUrl !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(
      pasteFileUrlDialog.PasteFileUrlDialog,
      {
        isOpen: isDialogOpen,
        onClose: () => setIsDialogOpen(false)
      }
    )
  ] });
});
exports.PromptContextMenu = PromptContextMenu;
//# sourceMappingURL=prompt-context-menu.cjs.map
