import { LayoutGallery } from "@wix/wix-ui-icons-common";
import React, { useContext, useState } from "react";
import { RicosContext } from "./../../../ricos-context/index.js";
import { getIsModalOpen, useModalState } from "./../../../ricos-modals/modal-service-provider.js";
import { GalleryOptions_Layout_Type } from "./../../../ricos-schema/next-schema/index.js";
import { DropdownButton } from "./../../../_shared/dropdown-button.js";
import { GALLERY_LAYOUT_DROPDOWN, GALLERY_LAYOUT_SETTINGS_MODAL } from "../../consts.js";
import { LAYOUT_DROPDOWN_OPTIONS } from "../layout-dropdown.js";
const GalleryLayoutButton = ({ dataHook, toolbarItem }) => {
  const { t, isMobile } = useContext(RicosContext) || {};
  const isModalOpen = useModalState(getIsModalOpen(GALLERY_LAYOUT_SETTINGS_MODAL));
  const isDropdownOpen = useModalState(getIsModalOpen(GALLERY_LAYOUT_DROPDOWN));
  const [referenceElement, setReferenceElement] = useState(null);
  const selectedLayout = LAYOUT_DROPDOWN_OPTIONS[toolbarItem?.attributes.layout] || LAYOUT_DROPDOWN_OPTIONS[GalleryOptions_Layout_Type.GRID];
  return /* @__PURE__ */ React.createElement(
    DropdownButton,
    {
      dataHook,
      active: isDropdownOpen || isModalOpen,
      onClick: () => toolbarItem.commands?.click({ referenceElement, isMobile }),
      ref: setReferenceElement,
      icon: selectedLayout.icon || LayoutGallery,
      tooltip: t("GalleryPlugin_Layout_Select_Tooltip"),
      tabIndex: toolbarItem.presentation.tabIndex
    }
  );
};
export {
  GalleryLayoutButton
};
//# sourceMappingURL=gallery-layout-button.js.map
