"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, {
  createFileUploadTestkit: () => createFileUploadTestkit
});
module.exports = __toCommonJS(testkit_exports);
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 createFileUploadTestkit = (getBase) => {
  const getUploadedFile = async (index, options) => {
    const fileUpload = await getBase().getAll((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.ROOT), options);
    return fileUpload.at(index);
  };
  return {
    content: {
      atIndex: (index) => {
        return {
          exists: async (options) => {
            try {
              const file = await getUploadedFile(index, options);
              return file.exists();
            } catch {
              return false;
            }
          },
          click: async () => {
            const file = await getUploadedFile(index);
            await file.click();
          },
          getFileName: async () => {
            const file = await getUploadedFile(index);
            const fileName = await file.get((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.FILE_UPLOAD_NAME));
            return fileName.text();
          },
          getFileUrl: async () => {
            const file = await getUploadedFile(index);
            const fileLink = await file.get((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.FILE_UPLOAD_LINK));
            return fileLink.attr("href");
          },
          getNativeElement: async () => {
            const file = await getUploadedFile(index);
            return file.getNative();
          }
        };
      }
    },
    toolbars: {
      createAddButtonToolbars: (getAddButtonToolbarBase) => ({
        click: async () => {
          const button = await getAddButtonToolbarBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.INSERT_FILE_BUTTON));
          await button.click();
        },
        toolbarsToAddIn: import_get_add_buttons.toolbarsToAddIn
      }),
      createPluginToolbar: (getPluginToolbarBase) => {
        return {
          clickReplace: async () => {
            const button = await getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.FILE).get(
              (0, import_wix_rich_content_common.dataHook)(import_data_hooks.PLUGIN_TOOLBAR_REPLACE_BUTTON)
            );
            await button.click();
          },
          clickDelete: async () => {
            const button = await getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.FILE).get(
              (0, import_wix_rich_content_common.dataHook)(import_data_hooks.PLUGIN_TOOLBAR_DELETE_BUTTON)
            );
            await button.click();
          },
          exists: async () => {
            try {
              return getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.FILE).exists();
            } catch {
              return false;
            }
          }
        };
      }
    }
  };
};
//# sourceMappingURL=testkit.js.map
