var b = Object.defineProperty;
var y = (e, t, i) => t in e ? b(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
var o = (e, t, i) => y(e, typeof t != "symbol" ? t + "" : t, i);
import { getAspectRatioFormatted as S } from "./index-format-aspect-ratio.js";
import { ContentType as l } from "./index-Document.types.js";
import { VIDEO_VALIDATION_ERRORS as a } from "./index-media-items-validations.js";
import { MediaItemValidator as F } from "./index-MediaItemValidator.js";
class B extends F {
  constructor(i) {
    super();
    o(this, "applicableFileTypes", [l.VIDEO_ANY, l.VIDEO_MP4, l.VIDEO_MOV]);
    o(this, "videoResolutionConfig");
    o(this, "resolveValidatePromise");
    o(this, "validate", (i) => new Promise((s) => {
      this.resolveValidatePromise = s, this.validateVideoFiles(i);
    }));
    o(this, "validateVideoFiles", (i) => {
      var n;
      const s = [];
      for (const r of i)
        s.push(this.validateVideo(r));
      (n = this.resolveValidatePromise) == null || n.call(this, s), this.resolveValidatePromise = void 0;
    });
    o(this, "validateVideo", (i) => {
      var r, d, h, v, u, p, f, R, A, c, g, E, _, O, T, V, x, C, M, H, L, P, W, D;
      const {
        file: s
      } = i;
      if (i.isInvalid = i.isInvalid ?? !1, i.validationErrors = i.validationErrors ?? [], !s || i.fileType && !this.applicableFileTypes.includes(i.fileType))
        return i;
      (((d = (r = i.metadata) == null ? void 0 : r.videoMetadata) == null ? void 0 : d.width) ?? 0) > (((h = this.videoResolutionConfig) == null ? void 0 : h.maxWidth) ?? Number.MAX_VALUE) && (i.isInvalid = !0, i.validationErrors.push({
        text: a.WIDTH_TOO_LARGE,
        replacements: {
          maxWidth: (v = this.videoResolutionConfig) == null ? void 0 : v.maxWidth
        }
      })), (((p = (u = i.metadata) == null ? void 0 : u.videoMetadata) == null ? void 0 : p.width) ?? 0) < (((f = this.videoResolutionConfig) == null ? void 0 : f.minWidth) ?? 0) && (i.isInvalid = !0, i.validationErrors.push({
        text: a.WIDTH_TOO_SMALL,
        replacements: {
          minWidth: (R = this.videoResolutionConfig) == null ? void 0 : R.minWidth
        }
      })), (((c = (A = i.metadata) == null ? void 0 : A.videoMetadata) == null ? void 0 : c.height) ?? 0) > (((g = this.videoResolutionConfig) == null ? void 0 : g.maxHeight) ?? Number.MAX_VALUE) && (i.isInvalid = !0, i.validationErrors.push({
        text: a.HEIGHT_TOO_LARGE,
        replacements: {
          maxHeight: (E = this.videoResolutionConfig) == null ? void 0 : E.maxHeight
        }
      })), (((O = (_ = i.metadata) == null ? void 0 : _.videoMetadata) == null ? void 0 : O.height) ?? 0) < (((T = this.videoResolutionConfig) == null ? void 0 : T.minHeight) ?? 0) && (i.isInvalid = !0, i.validationErrors.push({
        text: a.HEIGHT_TOO_SMALL,
        replacements: {
          minHeight: (V = this.videoResolutionConfig) == null ? void 0 : V.minHeight
        }
      }));
      const n = (((C = (x = i.metadata) == null ? void 0 : x.videoMetadata) == null ? void 0 : C.width) ?? 0) / (((H = (M = i.metadata) == null ? void 0 : M.videoMetadata) == null ? void 0 : H.height) ?? 1);
      return n > (((L = this.videoResolutionConfig) == null ? void 0 : L.maxAspectRatio) ?? Number.MAX_VALUE) && (i.isInvalid = !0, i.validationErrors.push({
        text: a.ASPECT_RATIO_TOO_BIG,
        replacements: {
          maxAspectRatio: S(((P = this.videoResolutionConfig) == null ? void 0 : P.maxAspectRatio) ?? 1)
        }
      })), n < (((W = this.videoResolutionConfig) == null ? void 0 : W.minAspectRatio) ?? 0) && (i.isInvalid = !0, i.validationErrors.push({
        text: a.ASPECT_RATIO_TOO_SMALL,
        replacements: {
          minAspectRatio: S(((D = this.videoResolutionConfig) == null ? void 0 : D.minAspectRatio) ?? 1)
        }
      })), i;
    });
    this.videoResolutionConfig = i;
  }
}
export {
  B as VideoResolutionValidator
};
