"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 get_upload_error_exports = {};
__export(get_upload_error_exports, {
  getUploadError: () => getUploadError
});
module.exports = __toCommonJS(get_upload_error_exports);
var import_ricos_content = require("./../ricos-content/index.js");
var import_upload_types = require("./request-service-provider/upload-types.js");
const getUploadError = (error, metaSiteId, isOwner) => {
  const upgradeUrl = `https://www.wix.com/store/plans?siteGuid=${metaSiteId}`;
  const { key, args } = error.error_info || {};
  const errorMessages = {
    [import_upload_types.MediaManagerUploadErrorTypes.SizeLimitExceeded]: {
      key: import_ricos_content.MediaUploadErrorKey.SIZE_LIMIT,
      args: { maxLimit: parseInt(args?.[1], 10) }
    },
    [import_upload_types.MediaManagerUploadErrorTypes.SiteQuotaExceeded]: {
      key: isOwner ? import_ricos_content.MediaUploadErrorKey.QUOTA_STORAGE_OWNER : import_ricos_content.MediaUploadErrorKey.QUOTA_STORAGE_VISITOR,
      args: { upgradeUrl, usage: args?.[0], limit: args?.[1] }
    },
    [import_upload_types.MediaManagerUploadErrorTypes.SiteVideoDurationQuotaExceeded]: {
      key: isOwner ? import_ricos_content.MediaUploadErrorKey.QUOTA_VIDEO_OWNER : import_ricos_content.MediaUploadErrorKey.QUOTA_VIDEO_VISITOR,
      args: { upgradeUrl, usage: args?.[0], limit: args?.[1] }
    },
    [import_upload_types.MediaManagerUploadErrorTypes.SiteSingleVideoDurationQuotaExceeded]: {
      key: isOwner ? import_ricos_content.MediaUploadErrorKey.QUOTA_SINGLE_VIDEO_OWNER : import_ricos_content.MediaUploadErrorKey.QUOTA_SINGLE_VIDEO_VISITOR,
      args: { upgradeUrl, usage: args?.[0], limit: args?.[1] }
    },
    [import_upload_types.MediaManagerUploadErrorTypes.General]: {
      key: import_ricos_content.MediaUploadErrorKey.GENERIC
    },
    [import_upload_types.MediaManagerUploadErrorTypes.MimeTypeMismatch]: {
      key: import_ricos_content.MediaUploadErrorKey.MIME_TYPE_MISMATCH
    },
    [import_upload_types.MediaManagerUploadErrorTypes.InvalidSession]: {
      key: import_ricos_content.MediaUploadErrorKey.INVALID_SESSION
    },
    [import_upload_types.MediaManagerUploadErrorTypes.SessionExpired]: {
      key: import_ricos_content.MediaUploadErrorKey.SESSION_EXPIRED
    },
    [import_upload_types.MediaManagerUploadErrorTypes.MissingWixSession]: {
      key: import_ricos_content.MediaUploadErrorKey.MISSING_WIX_SESSION
    },
    [import_upload_types.MediaManagerUploadErrorTypes.IncorrectFileInfo]: {
      key: import_ricos_content.MediaUploadErrorKey.INCORRECT_FILE_INFO
    },
    [import_upload_types.MediaManagerUploadErrorTypes.InvalidFile]: {
      key: import_ricos_content.MediaUploadErrorKey.CORRUPT_FILE
    },
    [import_upload_types.MediaManagerUploadErrorTypes.UnsupportedFileExtension]: {
      key: import_ricos_content.MediaUploadErrorKey.UNSUPPORTED_EXTENSION,
      args: { extension: args?.[0] }
    },
    [import_upload_types.MediaManagerUploadErrorTypes.WavInvalidMissingHeader]: {
      key: import_ricos_content.MediaUploadErrorKey.MISSING_HEADER
    },
    [import_upload_types.MediaManagerUploadErrorTypes.WavInvalidFormatChunkMissing]: {
      key: import_ricos_content.MediaUploadErrorKey.FORMAT_CHUNK_MISSING
    },
    [import_upload_types.MediaManagerUploadErrorTypes.ExternalFileAuthorization]: {
      key: import_ricos_content.MediaUploadErrorKey.EXT_FILE_AUTHORIZATION
    },
    [import_upload_types.MediaManagerUploadErrorTypes.ExternalFileForbidden]: {
      key: import_ricos_content.MediaUploadErrorKey.EXT_FILE_FORBBIDEN
    },
    [import_upload_types.MediaManagerUploadErrorTypes.UnsupportedImageFormat]: {
      key: import_ricos_content.MediaUploadErrorKey.IMAGE_FORMAT
    },
    [import_upload_types.MediaManagerUploadErrorTypes.CorruptedImage]: {
      key: import_ricos_content.MediaUploadErrorKey.CORRUPT_IMAGE
    },
    [import_upload_types.MediaManagerUploadErrorTypes.ImageDimentionsExceededLimit]: {
      key: import_ricos_content.MediaUploadErrorKey.IMAGE_DIMENSIONS_EXCEEDED
    },
    [import_upload_types.MediaManagerUploadErrorTypes.Mp4UnsupportedStereoOnly]: {
      key: import_ricos_content.MediaUploadErrorKey.MP4_STEREO_FORMAT
    },
    [import_upload_types.MediaManagerUploadErrorTypes.WavUnsupportedStereoOnly]: {
      key: import_ricos_content.MediaUploadErrorKey.WAV_STEREO_FORMAT
    },
    [import_upload_types.MediaManagerUploadErrorTypes.WmaUnsupportedBitrate]: {
      key: import_ricos_content.MediaUploadErrorKey.WMA_BITRATE
    },
    [import_upload_types.MediaManagerUploadErrorTypes.WmaUnsupportedBitrateLossy]: {
      key: import_ricos_content.MediaUploadErrorKey.WMA_BITRATE_LOSSY
    },
    [import_upload_types.MediaManagerUploadErrorTypes.Mp4UnsupportedBitrate]: {
      key: import_ricos_content.MediaUploadErrorKey.MP4_BITRATE
    },
    [import_upload_types.MediaManagerUploadErrorTypes.Mp3UnsupportedStereoOnly]: {
      key: import_ricos_content.MediaUploadErrorKey.MP3_UNSUPPORTED_STEREO
    },
    [import_upload_types.MediaManagerUploadErrorTypes.Mp3UnsupportedFormat]: {
      key: import_ricos_content.MediaUploadErrorKey.MP3_UNSUPPORTED_FORMAT
    },
    [import_upload_types.MediaManagerUploadErrorTypes.WavUnsupportedSampleRate]: {
      key: import_ricos_content.MediaUploadErrorKey.WAV_SAMPLE_RATE
    },
    [import_upload_types.MediaManagerUploadErrorTypes.AacUnsupportedFormat]: {
      key: import_ricos_content.MediaUploadErrorKey.AAC_UNSUPPORTED_FORMAT
    },
    [import_upload_types.MediaManagerUploadErrorTypes.WavUnsupportedFormat]: {
      key: import_ricos_content.MediaUploadErrorKey.WAV_UNSUPPORTED_FORMAT
    },
    [import_upload_types.MediaManagerUploadErrorTypes.WavUnsupportedSampleSize]: {
      key: import_ricos_content.MediaUploadErrorKey.WAV_SAMPLE_SIZE
    },
    [import_upload_types.MediaManagerUploadErrorTypes.WavUnsupportedFormatChunkSize]: {
      key: import_ricos_content.MediaUploadErrorKey.WAV_CHUNK_SIZE
    },
    [import_upload_types.MediaManagerUploadErrorTypes.UnsupportedAudioCodec]: {
      key: import_ricos_content.MediaUploadErrorKey.AUDIO_CODEC,
      args: { codec: args?.[0] }
    },
    [import_upload_types.MediaManagerUploadErrorTypes.ZeroSizeFile]: {
      key: import_ricos_content.MediaUploadErrorKey.EMPTY_FILE
    },
    [import_upload_types.MediaManagerUploadErrorTypes.Mp4UnsupportedFormat]: {
      key: import_ricos_content.MediaUploadErrorKey.MP4_UNSUPPORTED_FORMAT
    },
    [import_upload_types.MediaManagerUploadErrorTypes.Mp4UnsupportedSampleRate]: {
      key: import_ricos_content.MediaUploadErrorKey.MP4_SAMPLE_RATE
    },
    [import_upload_types.MediaManagerUploadErrorTypes.MaxVideoBitrateIsExceeded]: {
      key: import_ricos_content.MediaUploadErrorKey.VIDEO_BITRATE,
      args: { fps: args?.[0] }
    },
    [import_upload_types.MediaManagerUploadErrorTypes.VideoDurationMismatch]: {
      key: import_ricos_content.MediaUploadErrorKey.VIDEO_DURATION_MISMATCH,
      args: { videoDuration: args?.[0], audioDuration: args?.[1] }
    },
    [import_upload_types.MediaManagerUploadErrorTypes.UnsupportedVideoCodec]: {
      key: import_ricos_content.MediaUploadErrorKey.VIDEO_CODEC,
      args: { codec: args?.[0] }
    }
  };
  const uploadError = errorMessages[key];
  return { msg: error.error_description, ...uploadError };
};
//# sourceMappingURL=get-upload-error.js.map
