var z = Object.defineProperty;
var h = (a, l, i) => l in a ? z(a, l, { enumerable: !0, configurable: !0, writable: !0, value: i }) : a[l] = i;
var t = (a, l, i) => h(a, typeof l != "symbol" ? l + "" : l, i);
import { convertBytesToSizeString as v } from "./index-file-utils.js";
import { ContentType as e } from "./index-Document.types.js";
import { MediaItemValidator as S } from "./index-MediaItemValidator.js";
class E extends S {
  constructor(i) {
    super();
    t(this, "applicableFileTypes", [e.IMAGE_ANY, e.IMAGE_JPEG, e.IMAGE_JPG, e.IMAGE_PNG, e.VIDEO_ANY, e.VIDEO_MP4, e.VIDEO_MOV, e.APPLICATION_PDF, e.UNKNOWN]);
    t(this, "fileSizeConfig");
    t(this, "resolveValidatePromise");
    t(this, "validate", (i) => new Promise((s) => {
      this.resolveValidatePromise = s, this.validateMediaItems(i);
    }));
    t(this, "validateMediaItems", (i) => {
      var r;
      const s = [];
      for (const o of i)
        s.push(this.validateMediaItem(o));
      (r = this.resolveValidatePromise) == null || r.call(this, s), this.resolveValidatePromise = void 0;
    });
    t(this, "validateMediaItem", (i) => {
      var n, f, p, 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;
      const r = i.fileType.split("/")[0], o = ["image", "video"].includes(r) ? r : "file";
      return s.size > (((n = this.fileSizeConfig) == null ? void 0 : n.maxSize) ?? Number.MAX_VALUE) && (i.isInvalid = !0, i.validationErrors.push({
        text: `The ${o} size must be <b>smaller than %fileSize%</b>.`,
        replacements: {
          fileSize: v(((f = this.fileSizeConfig) == null ? void 0 : f.maxSize) ?? 0)
        }
      })), s.size < (((p = this.fileSizeConfig) == null ? void 0 : p.minSize) ?? 0) && (i.isInvalid = !0, i.validationErrors.push({
        text: `The ${o} size must be <b>bigger than %fileSize%</b>.`,
        replacements: {
          fileSize: v(((d = this.fileSizeConfig) == null ? void 0 : d.minSize) ?? 0)
        }
      })), i;
    });
    this.fileSizeConfig = i, i.applicableFileTypes && (this.applicableFileTypes = i.applicableFileTypes);
  }
}
export {
  E as FileSizeValidator
};
