var p = Object.defineProperty;
var n = (o, e, r) => e in o ? p(o, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[e] = r;
var s = (o, e, r) => n(o, typeof e != "symbol" ? e + "" : e, r);
import { jsx as t } from "react/jsx-runtime";
import { RcCropper as a } from "./index-Cropper.js";
import { ContentType as m } from "./index-Document.types.js";
import { ModalService as f } from "./index-ModalService.js";
import "react";
import { MediaItemTransformer as l } from "./index-MediaItemTransformer.js";
class c extends l {
  /**
   * Constructor for the ImageCropperTransformer.
   * @param config - Configuration options for the transformer, including cropper options.
   */
  constructor(r) {
    super();
    /**
     * Specifies the file types this transformer can handle.
     * Includes generic image types and specific formats like JPEG, JPG, and PNG.
     */
    s(this, "applicableFileTypes", [m.IMAGE_ANY, m.IMAGE_JPEG, m.IMAGE_JPG, m.IMAGE_PNG]);
    /**
     * Optional configuration options for the image cropper.
     */
    s(this, "imageCropperOptions");
    /**
     * Determines whether the file dialog should close after cropping is completed.
     */
    // closeFileDialogAfterCrop?: boolean;
    /**
     * Internal property to store the resolve function of the transform promise.
     * Used to resolve the promise when the crop operation is completed.
     */
    s(this, "resolveTransformPromise");
    /**
     * Asynchronous method to transform an array of files using the image cropper modal.
     * Displays the cropper for the first file in the list and resolves with the transformed file(s) or null.
     *
     * @param files - An array of files to be transformed.
     * @returns A promise that resolves to the transformed files or null.
     */
    s(this, "transform", (r) => new Promise((i) => {
      this.resolveTransformPromise = i, this.openImageCropper(r[0].file);
    }));
    /**
     * Function: Open Cropper
     */
    s(this, "openImageCropper", (r) => f.open(t(a, {
      imageFile: r,
      // closeAfterCrop={this.closeFileDialogAfterCrop}
      close: (i) => {
        this.resolveTransformPromise && (this.resolveTransformPromise(null), this.resolveTransformPromise = void 0);
      },
      save: (i) => {
        this.resolveTransformPromise && (this.resolveTransformPromise(i ?? null), this.resolveTransformPromise = void 0);
      },
      ...this.imageCropperOptions
    })));
    this.imageCropperOptions = r.options;
  }
}
export {
  c as ImageCropperTransformer
};
