import { jsx as n, jsxs as u } from "react/jsx-runtime";
import { FileUploadDefaultIcon as f } from "../../icons/FileUploadDefaultIcon.js";
import { useToolbarComponentContext as F } from "../../../contexts/ToolbarComponentContext.js";
import { useIconContext as T } from "../../../contexts/IconContext.js";
import { UIButton as d } from "../../ui/Button.js";
import { MenuItem as C } from "./MenuItem.js";
import { useViewportContext as x } from "../../../contexts/ViewportContext.js";
import { useOpenFileContext as h } from "../../../contexts/FileInputContext.js";
import p from "../../ui/RPTooltip.js";
import { useLocalizationContext as I } from "../../../contexts/LocalizationContext.js";
import { useIconToolContext as L } from "../../../contexts/IconToolContext.js";
import { useToolComponentContext as U } from "../../../contexts/ToolComponentContext.js";
const l = () => {
  const { openFileIcon: t } = T(), { openFileIcon: o } = L();
  return t || o || /* @__PURE__ */ n(f, {});
}, m = ({ children: t, className: o, localeMessages: i }) => /* @__PURE__ */ n(p, { className: o, content: i == null ? void 0 : i.openLocalFileTooltip, children: t }), b = ({ onFileChange: t, localeMessages: o }) => /* @__PURE__ */ n(C, { onClick: t, children: /* @__PURE__ */ u(m, { className: "rp-menu-item", localeMessages: o, children: [
  /* @__PURE__ */ n("div", { className: "rp-menu-item-left", children: /* @__PURE__ */ n(l, {}) }),
  o == null ? void 0 : o.openLocalFileLabel
] }) }), O = ({ onFileChange: t, localeMessages: o }) => /* @__PURE__ */ n(m, { localeMessages: o, children: /* @__PURE__ */ n(d, { onClick: t, "aria-label": o == null ? void 0 : o.openLocalFileTooltip, children: /* @__PURE__ */ n(l, {}) }) }), V = () => {
  const { openFileTool: t = !0 } = F(), { openFileTool: o = !0 } = U(), { openFile: i } = h(), { isSmallScreen: c } = x(), { localeMessages: r } = I(), e = r == null ? void 0 : r.openLocalFileTooltip;
  return !t || !o ? null : c ? /* @__PURE__ */ n(b, { onFileChange: i, localeMessages: r }) : typeof t == "function" ? /* @__PURE__ */ n(p, { content: e, children: /* @__PURE__ */ n(t, { openFile: i }) }) : typeof o == "function" ? /* @__PURE__ */ n(p, { content: e, children: /* @__PURE__ */ n(o, { openFile: i }) }) : /* @__PURE__ */ n(O, { onFileChange: i, localeMessages: r });
};
export {
  V as FileUploadTool
};
