import { RicosPluginToolbarNames } from "./../ricos-types/index.js";
import { PLUGIN_TOOLBAR_DELETE_BUTTON } from "./../_shared/data-hooks.js";
import { dataHook } from "./../wix-rich-content-common/index.js";
import {
  INSERT_DIVIDER_BUTTON,
  PLUGIN_TOOLBAR_DIVIDER_STYLE_BUTTON,
  ROOT,
  STYLE_DROPDOWN_OPTION_DASHED,
  STYLE_DROPDOWN_OPTION_DOTTED,
  STYLE_DROPDOWN_OPTION_DOUBLE,
  STYLE_DROPDOWN_OPTION_SINGLE
} from "./data-hooks.js";
import { toolbarsToAddIn } from "./get-add-buttons.js";
const createDividerTestkit = (getBase) => {
  const getDivider = async (index, options) => {
    const divider = await getBase().getAll(dataHook(ROOT), options);
    return divider.at(index);
  };
  const getDividerByType = async (type = "SINGLE", index) => {
    const dividers = await getBase().getAll(dataHook(`${ROOT}-${type.toLowerCase()}`));
    return dividers.at(index);
  };
  return {
    content: {
      atIndex: (index) => {
        return {
          exists: async (options) => {
            try {
              const divider = await getDivider(index, options);
              return divider.exists();
            } catch {
              return false;
            }
          },
          click: async () => {
            const divider = await getDivider(index);
            await divider.click();
          },
          hover: async () => {
            const divider = await getDivider(index);
            await divider.hover();
          },
          getNativeElement: async () => {
            const divider = await getDivider(index);
            return divider.getNative();
          }
        };
      },
      byType: (type, index = 0) => {
        return {
          exists: async () => {
            try {
              return (await getDividerByType(type, index)).exists();
            } catch {
              return false;
            }
          },
          click: async () => {
            const divider = await getDividerByType(type, index);
            await divider.click();
          }
        };
      }
    },
    toolbars: {
      createAddButtonToolbars: (getAddButtonToolbarBase) => ({
        click: async () => {
          const button = await getAddButtonToolbarBase().get(dataHook(INSERT_DIVIDER_BUTTON));
          await button.click();
        },
        toolbarsToAddIn
      }),
      createPluginToolbar: (getPluginToolbarBase) => {
        const getPluginToolbar = () => getPluginToolbarBase(RicosPluginToolbarNames.DIVIDER);
        return {
          clickDelete: async () => {
            const button = await getPluginToolbar().get(dataHook(PLUGIN_TOOLBAR_DELETE_BUTTON));
            await button.click();
          },
          clickStyleDropdown: async () => {
            const dropdown = await getPluginToolbar().get(
              dataHook(PLUGIN_TOOLBAR_DIVIDER_STYLE_BUTTON)
            );
            await dropdown.click();
          },
          style: {
            clickStyle: async (type) => {
              const dataHookMap = {
                SINGLE: STYLE_DROPDOWN_OPTION_SINGLE,
                DOUBLE: STYLE_DROPDOWN_OPTION_DOUBLE,
                DASHED: STYLE_DROPDOWN_OPTION_DASHED,
                DOTTED: STYLE_DROPDOWN_OPTION_DOTTED
              };
              const style = await getBase().get(dataHook(dataHookMap[type]));
              await style.click();
            }
          },
          exists: async () => {
            try {
              return getPluginToolbar().exists();
            } catch {
              return false;
            }
          }
        };
      }
    }
  };
};
export {
  createDividerTestkit
};
//# sourceMappingURL=testkit.js.map
