var o = Object.defineProperty;
var p = (s, i, e) => i in s ? o(s, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[i] = e;
var l = (s, i, e) => p(s, typeof i != "symbol" ? i + "" : i, e);
import { ContentType as d } from "./index-Document.types.js";
import { MediaItemValidator as n } from "./index-MediaItemValidator.js";
class T extends n {
  constructor(e) {
    super();
    l(this, "applicableFileTypes", [d.FILE_ANY]);
    l(this, "fileTypeConfig");
    l(this, "resolveValidatePromise");
    l(this, "validate", (e) => new Promise((a) => {
      this.resolveValidatePromise = a, this.validateMediaItems(e);
    }));
    l(this, "validateMediaItems", (e) => {
      var t;
      const a = [];
      for (const r of e)
        a.push(this.validateMediaItem(r));
      (t = this.resolveValidatePromise) == null || t.call(this, a), this.resolveValidatePromise = void 0;
    });
    l(this, "validateMediaItem", (e) => {
      var t;
      const {
        file: a
      } = e;
      return e.isInvalid = e.isInvalid ?? !1, e.validationErrors = e.validationErrors ?? [], (!a || e.fileType && !((t = this.fileTypeConfig) != null && t.acceptedTypes.includes(e.fileType))) && (e.isInvalid = !0, e.validationErrors.push({
        text: "File format is not supported."
      })), e;
    });
    this.fileTypeConfig = e, e.applicableFileTypes && (this.applicableFileTypes = e.applicableFileTypes);
  }
}
export {
  T as FileTypeValidator
};
