"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var testkit_exports = {};
__export(testkit_exports, {
  createVideoTestkit: () => createVideoTestkit
});
module.exports = __toCommonJS(testkit_exports);
var import_unidriver = require("@wix/design-system/dist/testkit/unidriver.js");
var import_testkit = require("./../plugin-figure/testkit.js");
var import_ricos_types = require("./../ricos-types/index.js");
var import_data_hooks = require("./../_shared/data-hooks.js");
var import_wix_rich_content_common = require("./../wix-rich-content-common/index.js");
var import_data_hooks2 = require("./data-hooks.js");
var import_get_add_buttons = require("./get-add-buttons.js");
const createVideoTestkit = (getBase) => {
  const getVideo = async (index, options) => {
    const video = await getBase().getAll((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.VIDEO_ROOT), options);
    return video.at(index);
  };
  const getVideoModalBase = async () => {
    const modal = await getBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.INSERT_VIDEO_MODAL));
    return modal;
  };
  const getPreview = async (index) => {
    const video = await getVideo(index);
    return video.get(".react-player__preview");
  };
  const hasPreview = async (index) => {
    try {
      await getPreview(index);
      return true;
    } catch {
      return false;
    }
  };
  return {
    content: {
      atIndex: (index) => {
        return {
          exists: async (options) => {
            try {
              const video = await getVideo(index, options);
              return video.exists();
            } catch {
              return false;
            }
          },
          click: async () => {
            if (await hasPreview(index)) {
              const preview = await getPreview(index);
              await preview.click();
              return;
            }
            const video = await getVideo(index);
            await video.click();
          },
          hasSpoiler: async () => {
            try {
              const spoiler = await getBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks.SPOILER_CONTAINER));
              return spoiler.exists();
            } catch {
              return false;
            }
          },
          waitForPlayer: async () => {
            const player = await getVideo(index);
            return player.wait();
          },
          hasVideo: async () => {
            try {
              const player = await getVideo(index);
              await player.get("video");
              return true;
            } catch {
              return false;
            }
          },
          hasPreview: () => hasPreview(index),
          getNativeElement: async () => {
            const video = await getVideo(index);
            return video.getNative();
          },
          ...(0, import_testkit.createFigureTestkit)(getBase, index)
        };
      }
    },
    toolbars: {
      createAddButtonToolbars: (getAddButtonToolbarBase) => ({
        click: async () => {
          const button = await getAddButtonToolbarBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.INSERT_VIDEO_BUTTON));
          await button.click();
        },
        toolbarsToAddIn: import_get_add_buttons.toolbarsToAddIn
      }),
      createPluginToolbar: (getPluginToolbarBase) => ({
        openReplaceModal: async () => {
          await (await getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.VIDEO).get(
            (0, import_wix_rich_content_common.dataHook)(import_data_hooks.PLUGIN_TOOLBAR_REPLACE_BUTTON)
          )).click();
        },
        openSettingsModal: async () => {
          await (await getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.VIDEO).get(
            (0, import_wix_rich_content_common.dataHook)(import_data_hooks.PLUGIN_TOOLBAR_SETTINGS_BUTTON)
          )).click();
        },
        settingsButtonExists: async () => {
          return getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.VIDEO).$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.PLUGIN_TOOLBAR_SETTINGS_BUTTON)).exists();
        },
        clickDelete: async () => {
          await (await getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.VIDEO).get(
            (0, import_wix_rich_content_common.dataHook)(import_data_hooks.PLUGIN_TOOLBAR_DELETE_BUTTON)
          )).click();
        },
        exists: async () => {
          try {
            return getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.VIDEO).exists();
          } catch {
            return false;
          }
        }
      })
    },
    insertModal: {
      sourceSegmentedToggle: (0, import_unidriver.SegmentedToggleUniDriver)(
        getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.INSERT_VIDEO_MODAL_SOURCE_TOGGLE)),
        getBase()
      ),
      embedSection: {
        urlInput: (0, import_unidriver.InputUniDriver)(getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.EMBED_TAB_URL_INPUT)), getBase()),
        submitButton: (0, import_unidriver.ButtonUniDriver)(getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.EMBED_TAB_SUBMIT_BUTTON)), getBase())
      },
      uploadSection: {
        uploadButton: (0, import_unidriver.ButtonUniDriver)(getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.UPLOAD_TAB_UPLOAD_BUTTON)), getBase())
      },
      waitForElement: async () => {
        const element = await getVideoModalBase();
        await element.wait();
      }
    },
    settings: {
      disableDownloadToggle: (0, import_unidriver.ToggleSwitchUniDriver)(
        getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SETTINGS_DISABLE_DOWNLOAD_TOGGLE)),
        getBase()
      ),
      spoilerToggle: (0, import_unidriver.ToggleSwitchUniDriver)(
        getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SETTINGS_SPOILER_TOGGLE)),
        getBase()
      )
    }
  };
};
//# sourceMappingURL=testkit.js.map
