var T = (c, r, e) => new Promise((t, o) => {
  var n = (s) => {
    try {
      a(e.next(s));
    } catch (h) {
      o(h);
    }
  }, i = (s) => {
    try {
      a(e.throw(s));
    } catch (h) {
      o(h);
    }
  }, a = (s) => s.done ? t(s.value) : Promise.resolve(s.value).then(n, i);
  a((e = e.apply(c, r)).next());
});
import { jsx as y, jsxs as A } from "react/jsx-runtime";
import * as x from "react";
import { useState as P, useCallback as k } from "react";
import { br as te, f_ as oe, f$ as w, e as re, S as ie, cs as ne, bh as ae } from "./main-CxoAwMiG.js";
var I, U;
function se() {
  if (U) return I;
  U = 1;
  var c = !1, r, e, t, o, n, i, a, s, h, p, d, u, f, v, g;
  function l() {
    if (!c) {
      c = !0;
      var C = navigator.userAgent, m = /(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(C), S = /(Mac OS X)|(Windows)|(Linux)/.exec(C);
      if (u = /\b(iPhone|iP[ao]d)/.exec(C), f = /\b(iP[ao]d)/.exec(C), p = /Android/i.exec(C), v = /FBAN\/\w+;/i.exec(C), g = /Mobile/i.exec(C), d = !!/Win64/.exec(C), m) {
        r = m[1] ? parseFloat(m[1]) : m[5] ? parseFloat(m[5]) : NaN, r && document && document.documentMode && (r = document.documentMode);
        var D = /(?:Trident\/(\d+.\d+))/.exec(C);
        i = D ? parseFloat(D[1]) + 4 : r, e = m[2] ? parseFloat(m[2]) : NaN, t = m[3] ? parseFloat(m[3]) : NaN, o = m[4] ? parseFloat(m[4]) : NaN, o ? (m = /(?:Chrome\/(\d+\.\d+))/.exec(C), n = m && m[1] ? parseFloat(m[1]) : NaN) : n = NaN;
      } else
        r = e = t = n = o = NaN;
      if (S) {
        if (S[1]) {
          var b = /(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(C);
          a = b ? parseFloat(b[1].replace("_", ".")) : !0;
        } else
          a = !1;
        s = !!S[2], h = !!S[3];
      } else
        a = s = h = !1;
    }
  }
  var R = {
    /**
     *  Check if the UA is Internet Explorer.
     *
     *
     *  @return float|NaN Version number (if match) or NaN.
     */
    ie: function() {
      return l() || r;
    },
    /**
     * Check if we're in Internet Explorer compatibility mode.
     *
     * @return bool true if in compatibility mode, false if
     * not compatibility mode or not ie
     */
    ieCompatibilityMode: function() {
      return l() || i > r;
    },
    /**
     * Whether the browser is 64-bit IE.  Really, this is kind of weak sauce;  we
     * only need this because Skype can't handle 64-bit IE yet.  We need to remove
     * this when we don't need it -- tracked by #601957.
     */
    ie64: function() {
      return R.ie() && d;
    },
    /**
     *  Check if the UA is Firefox.
     *
     *
     *  @return float|NaN Version number (if match) or NaN.
     */
    firefox: function() {
      return l() || e;
    },
    /**
     *  Check if the UA is Opera.
     *
     *
     *  @return float|NaN Version number (if match) or NaN.
     */
    opera: function() {
      return l() || t;
    },
    /**
     *  Check if the UA is WebKit.
     *
     *
     *  @return float|NaN Version number (if match) or NaN.
     */
    webkit: function() {
      return l() || o;
    },
    /**
     *  For Push
     *  WILL BE REMOVED VERY SOON. Use UserAgent_DEPRECATED.webkit
     */
    safari: function() {
      return R.webkit();
    },
    /**
     *  Check if the UA is a Chrome browser.
     *
     *
     *  @return float|NaN Version number (if match) or NaN.
     */
    chrome: function() {
      return l() || n;
    },
    /**
     *  Check if the user is running Windows.
     *
     *  @return bool `true' if the user's OS is Windows.
     */
    windows: function() {
      return l() || s;
    },
    /**
     *  Check if the user is running Mac OS X.
     *
     *  @return float|bool   Returns a float if a version number is detected,
     *                       otherwise true/false.
     */
    osx: function() {
      return l() || a;
    },
    /**
     * Check if the user is running Linux.
     *
     * @return bool `true' if the user's OS is some flavor of Linux.
     */
    linux: function() {
      return l() || h;
    },
    /**
     * Check if the user is running on an iPhone or iPod platform.
     *
     * @return bool `true' if the user is running some flavor of the
     *    iPhone OS.
     */
    iphone: function() {
      return l() || u;
    },
    mobile: function() {
      return l() || u || f || p || g;
    },
    nativeApp: function() {
      return l() || v;
    },
    android: function() {
      return l() || p;
    },
    ipad: function() {
      return l() || f;
    }
  };
  return I = R, I;
}
var F, H;
function ce() {
  if (H) return F;
  H = 1;
  var c = !!(typeof window != "undefined" && window.document && window.document.createElement), r = {
    canUseDOM: c,
    canUseWorkers: typeof Worker != "undefined",
    canUseEventListeners: c && !!(window.addEventListener || window.attachEvent),
    canUseViewport: c && !!window.screen,
    isInWorker: !c
    // For now, this is true - might change in the future.
  };
  return F = r, F;
}
var O, G;
function he() {
  if (G) return O;
  G = 1;
  var c = ce(), r;
  c.canUseDOM && (r = document.implementation && document.implementation.hasFeature && // always returns true in newer browsers as per the standard.
  // @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature
  document.implementation.hasFeature("", "") !== !0);
  function e(t, o) {
    if (!c.canUseDOM || o && !("addEventListener" in document))
      return !1;
    var n = "on" + t, i = n in document;
    if (!i) {
      var a = document.createElement("div");
      a.setAttribute(n, "return;"), i = typeof a[n] == "function";
    }
    return !i && r && t === "wheel" && (i = document.implementation.hasFeature("Events.wheel", "3.0")), i;
  }
  return O = e, O;
}
var L, q;
function pe() {
  if (q) return L;
  q = 1;
  var c = se(), r = he(), e = 10, t = 40, o = 800;
  function n(i) {
    var a = 0, s = 0, h = 0, p = 0;
    return "detail" in i && (s = i.detail), "wheelDelta" in i && (s = -i.wheelDelta / 120), "wheelDeltaY" in i && (s = -i.wheelDeltaY / 120), "wheelDeltaX" in i && (a = -i.wheelDeltaX / 120), "axis" in i && i.axis === i.HORIZONTAL_AXIS && (a = s, s = 0), h = a * e, p = s * e, "deltaY" in i && (p = i.deltaY), "deltaX" in i && (h = i.deltaX), (h || p) && i.deltaMode && (i.deltaMode == 1 ? (h *= t, p *= t) : (h *= o, p *= o)), h && !a && (a = h < 1 ? -1 : 1), p && !s && (s = p < 1 ? -1 : 1), {
      spinX: a,
      spinY: s,
      pixelX: h,
      pixelY: p
    };
  }
  return n.getEventType = function() {
    return c.firefox() ? "DOMMouseScroll" : r("wheel") ? "wheel" : "mousewheel";
  }, L = n, L;
}
var Z, B;
function ue() {
  return B || (B = 1, Z = pe()), Z;
}
var de = ue();
const le = /* @__PURE__ */ te(de);
function fe(c, r, e, t, o, n) {
  n === void 0 && (n = 0);
  var i = _(c, r, n), a = i.width, s = i.height, h = Math.min(a, e), p = Math.min(s, t);
  return h > p * o ? {
    width: p * o,
    height: p
  } : {
    width: h,
    height: h / o
  };
}
function ve(c) {
  return c.width > c.height ? c.width / c.naturalWidth : c.height / c.naturalHeight;
}
function z(c, r, e, t, o) {
  o === void 0 && (o = 0);
  var n = _(r.width, r.height, o), i = n.width, a = n.height;
  return {
    x: X(c.x, i, e.width, t),
    y: X(c.y, a, e.height, t)
  };
}
function X(c, r, e, t) {
  var o = Math.abs(r * t / 2 - e / 2);
  return W(c, -o, o);
}
function Y(c, r) {
  return Math.sqrt(Math.pow(c.y - r.y, 2) + Math.pow(c.x - r.x, 2));
}
function V(c, r) {
  return Math.atan2(r.y - c.y, r.x - c.x) * 180 / Math.PI;
}
function me(c, r, e, t, o, n, i) {
  n === void 0 && (n = 0), i === void 0 && (i = !0);
  var a = i ? ge : we, s = _(r.width, r.height, n), h = _(r.naturalWidth, r.naturalHeight, n), p = {
    x: a(100, ((s.width - e.width / o) / 2 - c.x / o) / s.width * 100),
    y: a(100, ((s.height - e.height / o) / 2 - c.y / o) / s.height * 100),
    width: a(100, e.width / s.width * 100 / o),
    height: a(100, e.height / s.height * 100 / o)
  }, d = Math.round(a(h.width, p.width * h.width / 100)), u = Math.round(a(h.height, p.height * h.height / 100)), f = h.width >= h.height * t, v = f ? {
    width: Math.round(u * t),
    height: u
  } : {
    width: d,
    height: Math.round(d / t)
  }, g = w(w({}, v), {
    x: Math.round(a(h.width - v.width, p.x * h.width / 100)),
    y: Math.round(a(h.height - v.height, p.y * h.height / 100))
  });
  return {
    croppedAreaPercentages: p,
    croppedAreaPixels: g
  };
}
function ge(c, r) {
  return Math.min(c, Math.max(0, r));
}
function we(c, r) {
  return r;
}
function Ce(c, r, e, t, o, n) {
  var i = _(r.width, r.height, e), a = W(t.width / i.width * (100 / c.width), o, n), s = {
    x: a * i.width / 2 - t.width / 2 - i.width * a * (c.x / 100),
    y: a * i.height / 2 - t.height / 2 - i.height * a * (c.y / 100)
  };
  return {
    crop: s,
    zoom: a
  };
}
function ye(c, r, e) {
  var t = ve(r);
  return e.height > e.width ? e.height / (c.height * t) : e.width / (c.width * t);
}
function xe(c, r, e, t, o, n) {
  e === void 0 && (e = 0);
  var i = _(r.naturalWidth, r.naturalHeight, e), a = W(ye(c, r, t), o, n), s = t.height > t.width ? t.height / c.height : t.width / c.width, h = {
    x: ((i.width - c.width) / 2 - c.x) * s,
    y: ((i.height - c.height) / 2 - c.y) * s
  };
  return {
    crop: h,
    zoom: a
  };
}
function K(c, r) {
  return {
    x: (r.x + c.x) / 2,
    y: (r.y + c.y) / 2
  };
}
function Re(c) {
  return c * Math.PI / 180;
}
function _(c, r, e) {
  var t = Re(e);
  return {
    width: Math.abs(Math.cos(t) * c) + Math.abs(Math.sin(t) * r),
    height: Math.abs(Math.sin(t) * c) + Math.abs(Math.cos(t) * r)
  };
}
function W(c, r, e) {
  return Math.min(Math.max(c, r), e);
}
function M() {
  for (var c = [], r = 0; r < arguments.length; r++)
    c[r] = arguments[r];
  return c.filter(function(e) {
    return typeof e == "string" && e.length > 0;
  }).join(" ").trim();
}
var Se = `.reactEasyCrop_Container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  user-select: none;
  touch-action: none;
  cursor: move;
  display: flex;
  justify-content: center;
  align-items: center;
}

.reactEasyCrop_Image,
.reactEasyCrop_Video {
  will-change: transform; /* this improves performances and prevent painting issues on iOS Chrome */
}

.reactEasyCrop_Contain {
  max-width: 100%;
  max-height: 100%;
  margin: auto;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
}
.reactEasyCrop_Cover_Horizontal {
  width: 100%;
  height: auto;
}
.reactEasyCrop_Cover_Vertical {
  width: auto;
  height: 100%;
}

.reactEasyCrop_CropArea {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-sizing: border-box;
  box-shadow: 0 0 0 9999em;
  color: rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.reactEasyCrop_CropAreaRound {
  border-radius: 50%;
}

.reactEasyCrop_CropAreaGrid::before {
  content: ' ';
  box-sizing: border-box;
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.5);
  top: 0;
  bottom: 0;
  left: 33.33%;
  right: 33.33%;
  border-top: 0;
  border-bottom: 0;
}

.reactEasyCrop_CropAreaGrid::after {
  content: ' ';
  box-sizing: border-box;
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.5);
  top: 33.33%;
  bottom: 33.33%;
  left: 0;
  right: 0;
  border-left: 0;
  border-right: 0;
}
`, be = 1, Ee = 3, _e = 1, De = (
  /** @class */
  (function(c) {
    oe(r, c);
    function r() {
      var e = c !== null && c.apply(this, arguments) || this;
      return e.cropperRef = x.createRef(), e.imageRef = x.createRef(), e.videoRef = x.createRef(), e.containerPosition = {
        x: 0,
        y: 0
      }, e.containerRef = null, e.styleRef = null, e.containerRect = null, e.mediaSize = {
        width: 0,
        height: 0,
        naturalWidth: 0,
        naturalHeight: 0
      }, e.dragStartPosition = {
        x: 0,
        y: 0
      }, e.dragStartCrop = {
        x: 0,
        y: 0
      }, e.gestureZoomStart = 0, e.gestureRotationStart = 0, e.isTouching = !1, e.lastPinchDistance = 0, e.lastPinchRotation = 0, e.rafDragTimeout = null, e.rafPinchTimeout = null, e.wheelTimer = null, e.currentDoc = typeof document != "undefined" ? document : null, e.currentWindow = typeof window != "undefined" ? window : null, e.resizeObserver = null, e.previousCropSize = null, e.isInitialized = !1, e.state = {
        cropSize: null,
        hasWheelJustStarted: !1,
        mediaObjectFit: void 0
      }, e.initResizeObserver = function() {
        if (!(typeof window.ResizeObserver == "undefined" || !e.containerRef)) {
          var t = !0;
          e.resizeObserver = new window.ResizeObserver(function(o) {
            if (t) {
              t = !1;
              return;
            }
            e.computeSizes();
          }), e.resizeObserver.observe(e.containerRef);
        }
      }, e.preventZoomSafari = function(t) {
        return t.preventDefault();
      }, e.cleanEvents = function() {
        e.currentDoc && (e.currentDoc.removeEventListener("mousemove", e.onMouseMove), e.currentDoc.removeEventListener("mouseup", e.onDragStopped), e.currentDoc.removeEventListener("touchmove", e.onTouchMove), e.currentDoc.removeEventListener("touchend", e.onDragStopped), e.currentDoc.removeEventListener("gesturechange", e.onGestureChange), e.currentDoc.removeEventListener("gestureend", e.onGestureEnd), e.currentDoc.removeEventListener("scroll", e.onScroll));
      }, e.clearScrollEvent = function() {
        e.containerRef && e.containerRef.removeEventListener("wheel", e.onWheel), e.wheelTimer && clearTimeout(e.wheelTimer);
      }, e.onMediaLoad = function() {
        var t = e.computeSizes();
        t && (e.previousCropSize = t, e.emitCropData(), e.setInitialCrop(t), e.isInitialized = !0), e.props.onMediaLoaded && e.props.onMediaLoaded(e.mediaSize);
      }, e.setInitialCrop = function(t) {
        if (e.props.initialCroppedAreaPercentages) {
          var o = Ce(e.props.initialCroppedAreaPercentages, e.mediaSize, e.props.rotation, t, e.props.minZoom, e.props.maxZoom), n = o.crop, i = o.zoom;
          e.props.onCropChange(n), e.props.onZoomChange && e.props.onZoomChange(i);
        } else if (e.props.initialCroppedAreaPixels) {
          var a = xe(e.props.initialCroppedAreaPixels, e.mediaSize, e.props.rotation, t, e.props.minZoom, e.props.maxZoom), n = a.crop, i = a.zoom;
          e.props.onCropChange(n), e.props.onZoomChange && e.props.onZoomChange(i);
        }
      }, e.computeSizes = function() {
        var t, o, n, i, a, s, h = e.imageRef.current || e.videoRef.current;
        if (h && e.containerRef) {
          e.containerRect = e.containerRef.getBoundingClientRect(), e.saveContainerPosition();
          var p = e.containerRect.width / e.containerRect.height, d = ((t = e.imageRef.current) === null || t === void 0 ? void 0 : t.naturalWidth) || ((o = e.videoRef.current) === null || o === void 0 ? void 0 : o.videoWidth) || 0, u = ((n = e.imageRef.current) === null || n === void 0 ? void 0 : n.naturalHeight) || ((i = e.videoRef.current) === null || i === void 0 ? void 0 : i.videoHeight) || 0, f = h.offsetWidth < d || h.offsetHeight < u, v = d / u, g = void 0;
          if (f)
            switch (e.state.mediaObjectFit) {
              default:
              case "contain":
                g = p > v ? {
                  width: e.containerRect.height * v,
                  height: e.containerRect.height
                } : {
                  width: e.containerRect.width,
                  height: e.containerRect.width / v
                };
                break;
              case "horizontal-cover":
                g = {
                  width: e.containerRect.width,
                  height: e.containerRect.width / v
                };
                break;
              case "vertical-cover":
                g = {
                  width: e.containerRect.height * v,
                  height: e.containerRect.height
                };
                break;
            }
          else
            g = {
              width: h.offsetWidth,
              height: h.offsetHeight
            };
          e.mediaSize = w(w({}, g), {
            naturalWidth: d,
            naturalHeight: u
          }), e.props.setMediaSize && e.props.setMediaSize(e.mediaSize);
          var l = e.props.cropSize ? e.props.cropSize : fe(e.mediaSize.width, e.mediaSize.height, e.containerRect.width, e.containerRect.height, e.props.aspect, e.props.rotation);
          return (((a = e.state.cropSize) === null || a === void 0 ? void 0 : a.height) !== l.height || ((s = e.state.cropSize) === null || s === void 0 ? void 0 : s.width) !== l.width) && e.props.onCropSizeChange && e.props.onCropSizeChange(l), e.setState({
            cropSize: l
          }, e.recomputeCropPosition), e.props.setCropSize && e.props.setCropSize(l), l;
        }
      }, e.saveContainerPosition = function() {
        if (e.containerRef) {
          var t = e.containerRef.getBoundingClientRect();
          e.containerPosition = {
            x: t.left,
            y: t.top
          };
        }
      }, e.onMouseDown = function(t) {
        e.currentDoc && (t.preventDefault(), e.currentDoc.addEventListener("mousemove", e.onMouseMove), e.currentDoc.addEventListener("mouseup", e.onDragStopped), e.saveContainerPosition(), e.onDragStart(r.getMousePoint(t)));
      }, e.onMouseMove = function(t) {
        return e.onDrag(r.getMousePoint(t));
      }, e.onScroll = function(t) {
        e.currentDoc && (t.preventDefault(), e.saveContainerPosition());
      }, e.onTouchStart = function(t) {
        e.currentDoc && (e.isTouching = !0, !(e.props.onTouchRequest && !e.props.onTouchRequest(t)) && (e.currentDoc.addEventListener("touchmove", e.onTouchMove, {
          passive: !1
        }), e.currentDoc.addEventListener("touchend", e.onDragStopped), e.saveContainerPosition(), t.touches.length === 2 ? e.onPinchStart(t) : t.touches.length === 1 && e.onDragStart(r.getTouchPoint(t.touches[0]))));
      }, e.onTouchMove = function(t) {
        t.preventDefault(), t.touches.length === 2 ? e.onPinchMove(t) : t.touches.length === 1 && e.onDrag(r.getTouchPoint(t.touches[0]));
      }, e.onGestureStart = function(t) {
        e.currentDoc && (t.preventDefault(), e.currentDoc.addEventListener("gesturechange", e.onGestureChange), e.currentDoc.addEventListener("gestureend", e.onGestureEnd), e.gestureZoomStart = e.props.zoom, e.gestureRotationStart = e.props.rotation);
      }, e.onGestureChange = function(t) {
        if (t.preventDefault(), !e.isTouching) {
          var o = r.getMousePoint(t), n = e.gestureZoomStart - 1 + t.scale;
          if (e.setNewZoom(n, o, {
            shouldUpdatePosition: !0
          }), e.props.onRotationChange) {
            var i = e.gestureRotationStart + t.rotation;
            e.props.onRotationChange(i);
          }
        }
      }, e.onGestureEnd = function(t) {
        e.cleanEvents();
      }, e.onDragStart = function(t) {
        var o, n, i = t.x, a = t.y;
        e.dragStartPosition = {
          x: i,
          y: a
        }, e.dragStartCrop = w({}, e.props.crop), (n = (o = e.props).onInteractionStart) === null || n === void 0 || n.call(o);
      }, e.onDrag = function(t) {
        var o = t.x, n = t.y;
        e.currentWindow && (e.rafDragTimeout && e.currentWindow.cancelAnimationFrame(e.rafDragTimeout), e.rafDragTimeout = e.currentWindow.requestAnimationFrame(function() {
          if (e.state.cropSize && !(o === void 0 || n === void 0)) {
            var i = o - e.dragStartPosition.x, a = n - e.dragStartPosition.y, s = {
              x: e.dragStartCrop.x + i,
              y: e.dragStartCrop.y + a
            }, h = e.props.restrictPosition ? z(s, e.mediaSize, e.state.cropSize, e.props.zoom, e.props.rotation) : s;
            e.props.onCropChange(h);
          }
        }));
      }, e.onDragStopped = function() {
        var t, o;
        e.isTouching = !1, e.cleanEvents(), e.emitCropData(), (o = (t = e.props).onInteractionEnd) === null || o === void 0 || o.call(t);
      }, e.onWheel = function(t) {
        if (e.currentWindow && !(e.props.onWheelRequest && !e.props.onWheelRequest(t))) {
          t.preventDefault();
          var o = r.getMousePoint(t), n = le(t).pixelY, i = e.props.zoom - n * e.props.zoomSpeed / 200;
          e.setNewZoom(i, o, {
            shouldUpdatePosition: !0
          }), e.state.hasWheelJustStarted || e.setState({
            hasWheelJustStarted: !0
          }, function() {
            var a, s;
            return (s = (a = e.props).onInteractionStart) === null || s === void 0 ? void 0 : s.call(a);
          }), e.wheelTimer && clearTimeout(e.wheelTimer), e.wheelTimer = e.currentWindow.setTimeout(function() {
            return e.setState({
              hasWheelJustStarted: !1
            }, function() {
              var a, s;
              return (s = (a = e.props).onInteractionEnd) === null || s === void 0 ? void 0 : s.call(a);
            });
          }, 250);
        }
      }, e.getPointOnContainer = function(t, o) {
        var n = t.x, i = t.y;
        if (!e.containerRect)
          throw new Error("The Cropper is not mounted");
        return {
          x: e.containerRect.width / 2 - (n - o.x),
          y: e.containerRect.height / 2 - (i - o.y)
        };
      }, e.getPointOnMedia = function(t) {
        var o = t.x, n = t.y, i = e.props, a = i.crop, s = i.zoom;
        return {
          x: (o + a.x) / s,
          y: (n + a.y) / s
        };
      }, e.setNewZoom = function(t, o, n) {
        var i = n === void 0 ? {} : n, a = i.shouldUpdatePosition, s = a === void 0 ? !0 : a;
        if (!(!e.state.cropSize || !e.props.onZoomChange)) {
          var h = W(t, e.props.minZoom, e.props.maxZoom);
          if (s) {
            var p = e.getPointOnContainer(o, e.containerPosition), d = e.getPointOnMedia(p), u = {
              x: d.x * h - p.x,
              y: d.y * h - p.y
            }, f = e.props.restrictPosition ? z(u, e.mediaSize, e.state.cropSize, h, e.props.rotation) : u;
            e.props.onCropChange(f);
          }
          e.props.onZoomChange(h);
        }
      }, e.getCropData = function() {
        if (!e.state.cropSize)
          return null;
        var t = e.props.restrictPosition ? z(e.props.crop, e.mediaSize, e.state.cropSize, e.props.zoom, e.props.rotation) : e.props.crop;
        return me(t, e.mediaSize, e.state.cropSize, e.getAspect(), e.props.zoom, e.props.rotation, e.props.restrictPosition);
      }, e.emitCropData = function() {
        var t = e.getCropData();
        if (t) {
          var o = t.croppedAreaPercentages, n = t.croppedAreaPixels;
          e.props.onCropComplete && e.props.onCropComplete(o, n), e.props.onCropAreaChange && e.props.onCropAreaChange(o, n);
        }
      }, e.emitCropAreaChange = function() {
        var t = e.getCropData();
        if (t) {
          var o = t.croppedAreaPercentages, n = t.croppedAreaPixels;
          e.props.onCropAreaChange && e.props.onCropAreaChange(o, n);
        }
      }, e.recomputeCropPosition = function() {
        var t, o;
        if (e.state.cropSize) {
          var n = e.props.crop;
          if (e.isInitialized && (!((t = e.previousCropSize) === null || t === void 0) && t.width) && (!((o = e.previousCropSize) === null || o === void 0) && o.height)) {
            var i = Math.abs(e.previousCropSize.width - e.state.cropSize.width) > 1e-6 || Math.abs(e.previousCropSize.height - e.state.cropSize.height) > 1e-6;
            if (i) {
              var a = e.state.cropSize.width / e.previousCropSize.width, s = e.state.cropSize.height / e.previousCropSize.height;
              n = {
                x: e.props.crop.x * a,
                y: e.props.crop.y * s
              };
            }
          }
          var h = e.props.restrictPosition ? z(n, e.mediaSize, e.state.cropSize, e.props.zoom, e.props.rotation) : n;
          e.previousCropSize = e.state.cropSize, e.props.onCropChange(h), e.emitCropData();
        }
      }, e.onKeyDown = function(t) {
        var o, n, i = e.props, a = i.crop, s = i.onCropChange, h = i.keyboardStep, p = i.zoom, d = i.rotation, u = h;
        if (e.state.cropSize) {
          t.shiftKey && (u *= 0.2);
          var f = w({}, a);
          switch (t.key) {
            case "ArrowUp":
              f.y -= u, t.preventDefault();
              break;
            case "ArrowDown":
              f.y += u, t.preventDefault();
              break;
            case "ArrowLeft":
              f.x -= u, t.preventDefault();
              break;
            case "ArrowRight":
              f.x += u, t.preventDefault();
              break;
            default:
              return;
          }
          e.props.restrictPosition && (f = z(f, e.mediaSize, e.state.cropSize, p, d)), t.repeat || (n = (o = e.props).onInteractionStart) === null || n === void 0 || n.call(o), s(f);
        }
      }, e.onKeyUp = function(t) {
        var o, n;
        switch (t.key) {
          case "ArrowUp":
          case "ArrowDown":
          case "ArrowLeft":
          case "ArrowRight":
            t.preventDefault();
            break;
          default:
            return;
        }
        e.emitCropData(), (n = (o = e.props).onInteractionEnd) === null || n === void 0 || n.call(o);
      }, e;
    }
    return r.prototype.componentDidMount = function() {
      !this.currentDoc || !this.currentWindow || (this.containerRef && (this.containerRef.ownerDocument && (this.currentDoc = this.containerRef.ownerDocument), this.currentDoc.defaultView && (this.currentWindow = this.currentDoc.defaultView), this.initResizeObserver(), typeof window.ResizeObserver == "undefined" && this.currentWindow.addEventListener("resize", this.computeSizes), this.props.zoomWithScroll && this.containerRef.addEventListener("wheel", this.onWheel, {
        passive: !1
      }), this.containerRef.addEventListener("gesturestart", this.onGestureStart)), this.currentDoc.addEventListener("scroll", this.onScroll), this.props.disableAutomaticStylesInjection || (this.styleRef = this.currentDoc.createElement("style"), this.styleRef.setAttribute("type", "text/css"), this.props.nonce && this.styleRef.setAttribute("nonce", this.props.nonce), this.styleRef.innerHTML = Se, this.currentDoc.head.appendChild(this.styleRef)), this.imageRef.current && this.imageRef.current.complete && this.onMediaLoad(), this.props.setImageRef && this.props.setImageRef(this.imageRef), this.props.setVideoRef && this.props.setVideoRef(this.videoRef), this.props.setCropperRef && this.props.setCropperRef(this.cropperRef));
    }, r.prototype.componentWillUnmount = function() {
      var e, t;
      !this.currentDoc || !this.currentWindow || (typeof window.ResizeObserver == "undefined" && this.currentWindow.removeEventListener("resize", this.computeSizes), (e = this.resizeObserver) === null || e === void 0 || e.disconnect(), this.containerRef && this.containerRef.removeEventListener("gesturestart", this.preventZoomSafari), this.styleRef && ((t = this.styleRef.parentNode) === null || t === void 0 || t.removeChild(this.styleRef)), this.cleanEvents(), this.props.zoomWithScroll && this.clearScrollEvent());
    }, r.prototype.componentDidUpdate = function(e) {
      var t, o, n, i, a, s, h, p, d;
      e.rotation !== this.props.rotation ? (this.computeSizes(), this.recomputeCropPosition()) : e.aspect !== this.props.aspect ? this.computeSizes() : e.objectFit !== this.props.objectFit ? this.computeSizes() : e.zoom !== this.props.zoom ? this.recomputeCropPosition() : ((t = e.cropSize) === null || t === void 0 ? void 0 : t.height) !== ((o = this.props.cropSize) === null || o === void 0 ? void 0 : o.height) || ((n = e.cropSize) === null || n === void 0 ? void 0 : n.width) !== ((i = this.props.cropSize) === null || i === void 0 ? void 0 : i.width) ? this.computeSizes() : (((a = e.crop) === null || a === void 0 ? void 0 : a.x) !== ((s = this.props.crop) === null || s === void 0 ? void 0 : s.x) || ((h = e.crop) === null || h === void 0 ? void 0 : h.y) !== ((p = this.props.crop) === null || p === void 0 ? void 0 : p.y)) && this.emitCropAreaChange(), e.zoomWithScroll !== this.props.zoomWithScroll && this.containerRef && (this.props.zoomWithScroll ? this.containerRef.addEventListener("wheel", this.onWheel, {
        passive: !1
      }) : this.clearScrollEvent()), e.video !== this.props.video && ((d = this.videoRef.current) === null || d === void 0 || d.load());
      var u = this.getObjectFit();
      u !== this.state.mediaObjectFit && this.setState({
        mediaObjectFit: u
      }, this.computeSizes);
    }, r.prototype.getAspect = function() {
      var e = this.props, t = e.cropSize, o = e.aspect;
      return t ? t.width / t.height : o;
    }, r.prototype.getObjectFit = function() {
      var e, t, o, n;
      if (this.props.objectFit === "cover") {
        var i = this.imageRef.current || this.videoRef.current;
        if (i && this.containerRef) {
          this.containerRect = this.containerRef.getBoundingClientRect();
          var a = this.containerRect.width / this.containerRect.height, s = ((e = this.imageRef.current) === null || e === void 0 ? void 0 : e.naturalWidth) || ((t = this.videoRef.current) === null || t === void 0 ? void 0 : t.videoWidth) || 0, h = ((o = this.imageRef.current) === null || o === void 0 ? void 0 : o.naturalHeight) || ((n = this.videoRef.current) === null || n === void 0 ? void 0 : n.videoHeight) || 0, p = s / h;
          return p < a ? "horizontal-cover" : "vertical-cover";
        }
        return "horizontal-cover";
      }
      return this.props.objectFit;
    }, r.prototype.onPinchStart = function(e) {
      var t = r.getTouchPoint(e.touches[0]), o = r.getTouchPoint(e.touches[1]);
      this.lastPinchDistance = Y(t, o), this.lastPinchRotation = V(t, o), this.onDragStart(K(t, o));
    }, r.prototype.onPinchMove = function(e) {
      var t = this;
      if (!(!this.currentDoc || !this.currentWindow)) {
        var o = r.getTouchPoint(e.touches[0]), n = r.getTouchPoint(e.touches[1]), i = K(o, n);
        this.onDrag(i), this.rafPinchTimeout && this.currentWindow.cancelAnimationFrame(this.rafPinchTimeout), this.rafPinchTimeout = this.currentWindow.requestAnimationFrame(function() {
          var a = Y(o, n), s = t.props.zoom * (a / t.lastPinchDistance);
          t.setNewZoom(s, i, {
            shouldUpdatePosition: !1
          }), t.lastPinchDistance = a;
          var h = V(o, n), p = t.props.rotation + (h - t.lastPinchRotation);
          t.props.onRotationChange && t.props.onRotationChange(p), t.lastPinchRotation = h;
        });
      }
    }, r.prototype.render = function() {
      var e = this, t, o = this.props, n = o.image, i = o.video, a = o.mediaProps, s = o.cropperProps, h = o.transform, p = o.crop, d = p.x, u = p.y, f = o.rotation, v = o.zoom, g = o.cropShape, l = o.showGrid, R = o.roundCropAreaPixels, C = o.style, m = C.containerStyle, S = C.cropAreaStyle, D = C.mediaStyle, b = o.classes, J = b.containerClassName, Q = b.cropAreaClassName, j = b.mediaClassName, E = (t = this.state.mediaObjectFit) !== null && t !== void 0 ? t : this.getObjectFit();
      return x.createElement("div", {
        onMouseDown: this.onMouseDown,
        onTouchStart: this.onTouchStart,
        ref: function(ee) {
          return e.containerRef = ee;
        },
        "data-testid": "container",
        style: m,
        className: M("reactEasyCrop_Container", J)
      }, n ? x.createElement("img", w({
        alt: "",
        className: M("reactEasyCrop_Image", E === "contain" && "reactEasyCrop_Contain", E === "horizontal-cover" && "reactEasyCrop_Cover_Horizontal", E === "vertical-cover" && "reactEasyCrop_Cover_Vertical", j)
      }, a, {
        src: n,
        ref: this.imageRef,
        style: w(w({}, D), {
          transform: h || "translate(".concat(d, "px, ").concat(u, "px) rotate(").concat(f, "deg) scale(").concat(v, ")")
        }),
        onLoad: this.onMediaLoad
      })) : i && x.createElement("video", w({
        autoPlay: !0,
        playsInline: !0,
        loop: !0,
        muted: !0,
        className: M("reactEasyCrop_Video", E === "contain" && "reactEasyCrop_Contain", E === "horizontal-cover" && "reactEasyCrop_Cover_Horizontal", E === "vertical-cover" && "reactEasyCrop_Cover_Vertical", j)
      }, a, {
        ref: this.videoRef,
        onLoadedMetadata: this.onMediaLoad,
        style: w(w({}, D), {
          transform: h || "translate(".concat(d, "px, ").concat(u, "px) rotate(").concat(f, "deg) scale(").concat(v, ")")
        }),
        controls: !1
      }), (Array.isArray(i) ? i : [{
        src: i
      }]).map(function(N) {
        return x.createElement("source", w({
          key: N.src
        }, N));
      })), this.state.cropSize && x.createElement("div", w({
        ref: this.cropperRef,
        style: w(w({}, S), {
          width: R ? Math.round(this.state.cropSize.width) : this.state.cropSize.width,
          height: R ? Math.round(this.state.cropSize.height) : this.state.cropSize.height
        }),
        tabIndex: 0,
        onKeyDown: this.onKeyDown,
        onKeyUp: this.onKeyUp,
        "data-testid": "cropper",
        className: M("reactEasyCrop_CropArea", g === "round" && "reactEasyCrop_CropAreaRound", l && "reactEasyCrop_CropAreaGrid", Q)
      }, s)));
    }, r.defaultProps = {
      zoom: 1,
      rotation: 0,
      aspect: 4 / 3,
      maxZoom: Ee,
      minZoom: be,
      cropShape: "rect",
      objectFit: "contain",
      showGrid: !0,
      style: {},
      classes: {},
      mediaProps: {},
      cropperProps: {},
      zoomSpeed: 1,
      restrictPosition: !0,
      zoomWithScroll: !0,
      keyboardStep: _e
    }, r.getMousePoint = function(e) {
      return {
        x: Number(e.clientX),
        y: Number(e.clientY)
      };
    }, r.getTouchPoint = function(e) {
      return {
        x: Number(e.clientX),
        y: Number(e.clientY)
      };
    }, r;
  })(x.Component)
);
function ze(c, r, e = 0) {
  return T(this, null, function* () {
    const t = yield new Promise((i, a) => {
      const s = new Image();
      s.src = c, s.crossOrigin = "anonymous", s.onload = () => i(s), s.onerror = a;
    }), o = document.createElement("canvas"), n = o.getContext("2d");
    return o.width = r.width, o.height = r.height, n.translate(o.width / 2, o.height / 2), n.rotate(e * Math.PI / 180), n.translate(-o.width / 2, -o.height / 2), n.drawImage(
      t,
      r.x,
      r.y,
      r.width,
      r.height,
      0,
      0,
      r.width,
      r.height
    ), new Promise((i) => {
      o.toBlob((a) => {
        if (!a)
          throw new Error("Canvas to blob failed");
        i(a);
      }, "image/jpeg");
    });
  });
}
const $ = ({ min: c, max: r, step: e, value: t, onChange: o, icon: n, className: i }) => /* @__PURE__ */ A("div", { className: `gap-1 flex justify-between items-center ${i}`, children: [
  /* @__PURE__ */ y("span", { className: "mb-1", children: n }),
  /* @__PURE__ */ y(
    "input",
    {
      type: "range",
      min: c,
      max: r,
      step: e,
      value: t,
      onChange: (a) => o(parseFloat(a.target.value)),
      className: "w-full accent-accent"
    }
  )
] }), Ne = ({
  open: c,
  onClose: r,
  imageUrl: e,
  onSave: t
}) => {
  const [o, n] = P({ x: 0, y: 0 }), [i, a] = P(1), [s, h] = P(0), [p, d] = P(null), u = k((v, g) => {
    d(g);
  }, []), f = k(() => T(null, null, function* () {
    if (p)
      try {
        const v = yield ze(
          e,
          p,
          s
        ), g = new File([v], "edited-image.jpg", {
          type: "image/jpeg",
          lastModified: Date.now()
        });
        t(g), r();
      } catch (v) {
        console.error(v);
      }
  }), [p, s, e, t, r]);
  return /* @__PURE__ */ y(
    re,
    {
      open: c,
      onOpenChange: r,
      size: "full",
      hasNotPadding: !0,
      children: /* @__PURE__ */ A("div", { className: "dark h-full bg-divider flex flex-col", children: [
        /* @__PURE__ */ A("div", { className: "flex justify-between items-center bg-bgPinMessage p-1", children: [
          /* @__PURE__ */ y(
            "button",
            {
              onClick: f,
              className: "px-6 py-1 rounded focus-visible:!outline-none bg-accent text-white font-bold text-sm flex items-center",
              children: "ثبت"
            }
          ),
          /* @__PURE__ */ A("div", { className: "flex justify-center items-center gap-3", children: [
            /* @__PURE__ */ y(
              $,
              {
                min: 0.5,
                max: 4,
                step: 0.01,
                value: i,
                onChange: a,
                icon: /* @__PURE__ */ y(ie, { className: "text-accent" })
              }
            ),
            /* @__PURE__ */ y(
              $,
              {
                min: 0,
                max: 360,
                step: 1,
                value: s,
                onChange: h,
                icon: /* @__PURE__ */ y(ne, { fill: "var(--color-accent)" })
              }
            )
          ] }),
          /* @__PURE__ */ y("button", { className: "text-white", onClick: r, children: /* @__PURE__ */ y(ae, { width: "17", height: "17" }) })
        ] }),
        /* @__PURE__ */ y("div", { className: "flex-1 flex items-center justify-center p-2 sm:p-4 md:p-6 overflow-hidden", children: /* @__PURE__ */ y("div", { className: "relative w-full h-full md:w-[80%] md:h-[80%]", children: /* @__PURE__ */ y(
          De,
          {
            image: e,
            crop: o,
            zoom: i,
            rotation: s,
            aspect: 1,
            cropShape: "round",
            showGrid: !1,
            onCropChange: n,
            onZoomChange: a,
            onRotationChange: h,
            onCropComplete: u
          }
        ) }) })
      ] })
    }
  );
};
export {
  Ne as I
};
