import { Catalog } from "@wix/wix-ui-icons-common";
import React, { useContext, useEffect, useState } from "react";
import { RicosContext } from "./../../ricos-context/index.js";
import { useModalService } from "./../../ricos-modals/modal-service-provider.js";
import { ToolbarButton } from "./../../_shared/toolbar-button/toolbar-button.js";
const PresetsButton = ({ toolbarItem, dataHook }) => {
  const { t, isMobile } = useContext(RicosContext) || {};
  const [referenceElement, setReferenceElement] = useState(null);
  const [isActive, setIsActive] = useState(toolbarItem.attributes.active);
  const modalService = useModalService();
  useEffect(() => {
    modalService.onModalOpened(() => {
      setIsActive(Boolean(toolbarItem.attributes.active));
    });
    modalService.onModalClosed(() => {
      setIsActive(Boolean(toolbarItem.attributes.active));
    });
  }, [modalService]);
  return /* @__PURE__ */ React.createElement(
    ToolbarButton,
    {
      prefix: Catalog,
      onClick: () => toolbarItem.commands?.click({ isMobile, referenceElement }),
      dataHook,
      tooltip: t("Embed_Vertical_Presets_Tooltip"),
      ariaLabel: t("Embed_Vertical_Presets_Tooltip"),
      label: t("Embed_Vertical_Presets_Tooltip"),
      ref: setReferenceElement,
      active: isActive
    }
  );
};
export {
  PresetsButton
};
//# sourceMappingURL=presets-button.js.map
