import { dataHook } from "./../../../../wix-rich-content-common/index.js";
import { TOOLBAR_VISIBLE } from "../../../components/Toolbar/index.js";
import { convertToSpecificAddButtonToolbar } from "../../testkit/covert-to-specific-add-button-toolbar.js";
import { FOOTER_TOOLBAR } from "../index.js";
const createFooterToolbarTestkit = (getBase, createAddButtonToolbarPluginTestkits) => {
  const getFooter = () => getBase().$(`${dataHook(FOOTER_TOOLBAR)} ${dataHook(TOOLBAR_VISIBLE)}`);
  const createFooterToolbarPluginTestkits = convertToSpecificAddButtonToolbar(
    createAddButtonToolbarPluginTestkits
  );
  return {
    exists: async () => {
      return getFooter().exists();
    },
    waitForElement: async () => {
      const footer = getFooter();
      await footer.wait();
      return footer;
    },
    getButtonsAmount: async () => {
      const buttons = getFooter().$$("button");
      return await buttons.count();
    },
    scrollToElementByIndex: async (index) => {
      const button = getFooter().$$("button").get(index);
      if (!button) {
        throw new Error(`Footer toolbar doesn't have a button at index ${index}`);
      }
      await button.scrollIntoView?.();
    },
    getButtonAtIndex: async (index) => {
      const button = getFooter().$$("button").get(index);
      if (!button) {
        throw new Error(`Footer toolbar doesn't have a button at index ${index}`);
      }
      return button;
    },
    clickMoreButton: async () => {
      const footer = await getFooter();
      const moreButton = footer.$(dataHook("more-button"));
      await moreButton.click();
    },
    waitForOverflownButtonsToolbar: async () => {
      const overflownButtonsToolbar = getBase().$(dataHook("overflown-buttons-toolbar"));
      await overflownButtonsToolbar.wait();
    },
    plugins: createFooterToolbarPluginTestkits(getFooter)
  };
};
export {
  createFooterToolbarTestkit
};
//# sourceMappingURL=footer.testkit.js.map
