import { ChevronDownSmall } from "@wix/wix-ui-icons-common";
import React, { useContext, useState } from "react";
import { EditorContext, RicosContext } from "./../../../../ricos-context/index.js";
import { getIsModalOpen, useModalState } from "./../../../../ricos-modals/modal-service-provider.js";
import { ToolbarButton } from "./../../../../_shared/toolbar-button/toolbar-button.js";
const AlignmentButton = ({
  toolbarItem,
  dataHook
}) => {
  const { t } = useContext(RicosContext);
  const { getPublicCommands } = useContext(EditorContext);
  const [referenceElement, setReferenceElement] = useState(null);
  const publicCommands = getPublicCommands?.();
  const Icon = toolbarItem.presentation.getIcon({ publicCommands, t });
  const tooltip = t(toolbarItem.presentation?.tooltip);
  const isModalOpen = useModalState(getIsModalOpen("TextAlignment.modal"));
  return /* @__PURE__ */ React.createElement(
    ToolbarButton,
    {
      ref: setReferenceElement,
      disabled: toolbarItem.attributes.disabled,
      active: isModalOpen,
      tooltip,
      onClick: () => {
        toolbarItem.commands?.click({ referenceElement });
      },
      prefix: Icon,
      suffix: ChevronDownSmall,
      dataHook,
      tabIndex: toolbarItem.presentation.tabIndex
    }
  );
};
export {
  AlignmentButton
};
//# sourceMappingURL=alignment-button.js.map
