var D = Object.defineProperty;
var V = (t, o, i) => o in t ? D(t, o, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[o] = i;
var a = (t, o, i) => V(t, typeof o != "symbol" ? o + "" : o, i);
import { ContentType as s } from "./index-Document.types.js";
import { MediaItemValidator as h } from "./index-MediaItemValidator.js";
class C extends h {
  constructor(i) {
    super();
    a(this, "applicableFileTypes", [s.VIDEO_ANY, s.VIDEO_MP4, s.VIDEO_MOV]);
    a(this, "videoDurationConfig");
    a(this, "resolveValidatePromise");
    a(this, "validate", (i) => new Promise((e) => {
      this.resolveValidatePromise = e, this.validateVideoFiles(i);
    }));
    a(this, "validateVideoFiles", (i) => {
      var r;
      const e = [];
      for (const n of i)
        e.push(this.validateVideo(n));
      (r = this.resolveValidatePromise) == null || r.call(this, e), this.resolveValidatePromise = void 0;
    });
    a(this, "validateVideo", (i) => {
      var r, n, d, l, u, v, f, p;
      const {
        file: e
      } = i;
      return i.isInvalid = i.isInvalid ?? !1, i.validationErrors = i.validationErrors ?? [], !e || i.fileType && !this.applicableFileTypes.includes(i.fileType) || ((((n = (r = i.metadata) == null ? void 0 : r.videoMetadata) == null ? void 0 : n.duration) ?? 0) > (((d = this.videoDurationConfig) == null ? void 0 : d.maxDuration) ?? Number.MAX_VALUE) && (i.isInvalid = !0, i.validationErrors.push({
        text: "Video duration exceeds maximum duration of %maxDuration% seconds.",
        replacements: {
          maxDuration: (l = this.videoDurationConfig) == null ? void 0 : l.maxDuration
        }
      })), (((v = (u = i.metadata) == null ? void 0 : u.videoMetadata) == null ? void 0 : v.duration) ?? 0) < (((f = this.videoDurationConfig) == null ? void 0 : f.minDuration) ?? 0) && (i.isInvalid = !0, i.validationErrors.push({
        text: "Video duration is less than minimum duration of %minDuration% seconds.",
        replacements: {
          minDuration: (p = this.videoDurationConfig) == null ? void 0 : p.minDuration
        }
      }))), i;
    });
    this.videoDurationConfig = i;
  }
}
export {
  C as VideoDurationValidator
};
