import { defineComponent as k, openBlock as o, createElementBlock as r, createElementVNode as n, createVNode as F, ref as x, reactive as L, computed as B, onMounted as J, nextTick as K, watch as Q, normalizeClass as E, unref as X, mergeProps as Y, Fragment as I, createCommentVNode as g, createBlock as b, withModifiers as p, normalizeStyle as R, withCtx as Z } from "vue";
import { VueCropper as _ } from "vue-cropper";
import { _ as ee } from "./Index.vue_vue_type_script_setup_true_lang-Cuv5NgcY.js";
import { _ as ie } from "./_plugin-vue_export-helper-CHgC5LLL.js";
import { C as f } from "./base-PQGakkrl.js";
import { _ as ne } from "./Index.vue_vue_type_script_setup_true_lang-Da4Z8GsB.js";
const te = { class: "panel-load-fullCenter loading-wrapper" }, le = { class: "loading-content" }, oe = /* @__PURE__ */ k({
  name: "ClLoadFullCenter",
  __name: "FullCenter",
  props: {
    theme: {},
    size: {}
  },
  setup(i) {
    return (y, v) => (o(), r("div", te, [
      v[0] || (v[0] = n("div", { class: "load-fullCenter-bg" }, null, -1)),
      n("div", le, [
        F(ee, {
          theme: i.theme,
          size: i.size
        }, null, 8, ["theme", "size"])
      ])
    ]));
  }
}), se = /* @__PURE__ */ ie(oe, [["__scopeId", "data-v-bfbb2c59"]]), ae = { class: "imgCropper-container" }, re = { class: "imgCropper-main" }, ue = { class: "frame-alignline" }, de = { class: "imgCropper-btns" }, ge = {
  key: 0,
  class: "imgCropper-upload"
}, ce = ["id", "name"], me = ["for"], pe = { class: "imgCropper-btns-opt" }, fe = ["src"], ve = {
  key: 0,
  class: "frame-alignline"
}, M = /* @__PURE__ */ k({
  name: "ClCropperBase",
  __name: "Base",
  props: {
    className: String,
    src: {
      type: String,
      required: !0
    },
    width: {
      type: Number,
      required: !0
    },
    height: {
      type: Number,
      required: !0
    },
    isFixedAspectRatio: {
      type: Boolean,
      default: !0
    },
    isPreview: {
      type: Boolean,
      default: !0
    },
    previewShape: {
      type: String,
      default: "square"
      // square | round
    },
    enlarge: {
      type: Number,
      default: 2
    },
    isShowUpload: {
      type: Boolean,
      default: !0
    },
    isShowSave: {
      type: Boolean,
      default: !1
    },
    isCenterBox: {
      type: Boolean,
      default: !0
    },
    fillColor: {
      type: String,
      default: "transparent"
      // #FFFFFF
    },
    alignLine: {
      type: String,
      default: "center"
      // center | nineGrid
    },
    isPreviewAlignLine: {
      type: Boolean,
      default: !1
    }
  },
  emits: ["onImgLoad", "onImgSave"],
  setup(i, { expose: y, emit: v }) {
    const l = i, h = v, s = x(null), w = x(null), S = f.getRandom(8), u = L({
      uploadAgainId: `btnImgCropper_uploadAgain_${S}`,
      isInitImageLoading: !1
    }), m = L({
      img: "",
      outputSize: 1,
      outputType: "png",
      info: !0,
      canScale: !0,
      autoCrop: !0,
      autoCropWidth: l.width,
      autoCropHeight: l.height,
      fixed: l.isFixedAspectRatio,
      fixedNumber: [1, 1],
      full: !1,
      fixedBox: !1,
      canMove: !0,
      canMoveBox: !0,
      original: !1,
      centerBox: l.isCenterBox,
      high: !0,
      infoTrue: !0,
      maxImgSize: 2e3,
      enlarge: l.enlarge,
      mode: "contain",
      limitMinSize: 50,
      fillColor: l.fillColor
    }), c = L({
      src: "",
      style: {},
      pStyle: {}
    }), C = B(() => {
      const { alignLine: t } = l;
      return t && !f.isEmpty(t) ? t.split(",") : [];
    }), A = B(() => {
      const { className: t } = l, e = {
        "panel-imgCropper": !0
      };
      return t && !f.isEmpty(t) && t.split(" ").forEach((d) => {
        f.isEmpty(d) || (e[d] = !0);
      }), e;
    }), a = B(() => {
      const { previewShape: t } = l, e = {
        "imgCropper-preview": !0
      };
      return e[`imgCropper-preview-${t}`] = !0, e;
    }), N = () => {
      const { width: t, height: e } = l;
      let d = [];
      t > e ? d = [1, e / t] : t < e ? d = [t / e, 1] : d = [1, 1], m.fixedNumber = d;
    }, P = () => {
      const { src: t } = l;
      let e = "";
      if (t && !f.isEmpty(t)) {
        if (t.substring(0, 5) !== "data:") {
          if (/^(http|https):\/\/[^\s]+$/.test(t)) {
            const d = `_t=${(/* @__PURE__ */ new Date()).getTime()}`, D = t.indexOf("?") === -1 ? "?" : "&";
            e = t + D + d;
          }
        } else
          e = t;
        u.isInitImageLoading = !0;
      }
      m.img = e;
    }, G = () => {
      N(), P();
    };
    J(() => {
      u.isInitImageLoading = !0, K(() => {
        G();
      });
    }), Q(
      () => l.src,
      (t) => {
        f.isEmpty(t) || P();
      }
    );
    const O = (t) => {
      c.src = t.url, c.style = t.img, c.pStyle = t.div;
    }, $ = (t) => {
      const e = t === "success";
      u.isInitImageLoading = !1, h("onImgLoad", e);
    }, z = (t) => {
      f.getBase64ByFile(t.currentTarget.files).then((e) => {
        m.img = e;
      });
    }, U = () => {
    }, q = () => {
      s.value.changeScale(1);
    }, T = () => {
      s.value.changeScale(-1);
    }, j = () => {
      s.value.rotateLeft();
    }, V = () => {
      s.value.rotateRight();
    }, H = () => {
      s.value.refresh();
    }, W = () => {
      h("onImgSave");
    };
    return y({
      getImageBase64: () => new Promise((t) => {
        s.value.getCropData((e) => {
          t(e);
        });
      })
    }), (t, e) => (o(), r("div", {
      class: E(A.value)
    }, [
      n("div", ae, [
        n("div", null, [
          n("div", re, [
            F(X(_), Y({
              ref_key: "refElCropper",
              ref: s
            }, m, {
              onRealTime: O,
              onImgLoad: $
            }), null, 16),
            n("div", ue, [
              C.value.indexOf("center") > -1 ? (o(), r(I, { key: 0 }, [
                e[0] || (e[0] = n("div", { class: "alignline-h alignline-center-h" }, null, -1)),
                e[1] || (e[1] = n("div", { class: "alignline-v alignline-center-v" }, null, -1))
              ], 64)) : g("", !0),
              C.value.indexOf("nineGrid") > -1 ? (o(), r(I, { key: 1 }, [
                e[2] || (e[2] = n("div", { class: "alignline-h alignline-nineGrid-h1" }, null, -1)),
                e[3] || (e[3] = n("div", { class: "alignline-h alignline-nineGrid-h2" }, null, -1)),
                e[4] || (e[4] = n("div", { class: "alignline-v alignline-nineGrid-v1" }, null, -1)),
                e[5] || (e[5] = n("div", { class: "alignline-v alignline-nineGrid-v2" }, null, -1))
              ], 64)) : g("", !0)
            ]),
            u.isInitImageLoading ? (o(), b(se, {
              key: 0,
              theme: "rotaryLine"
            })) : g("", !0)
          ]),
          n("div", de, [
            n("div", null, [
              i.isShowUpload ? (o(), r("div", ge, [
                n("input", {
                  type: "file",
                  id: u.uploadAgainId,
                  name: u.uploadAgainId,
                  accept: "image/jpg,image/jpeg,image/pjpeg,image/png,image/x-png",
                  onChange: z
                }, null, 40, ce),
                n("label", {
                  ref_key: "refElFileLabel",
                  ref: w,
                  for: u.uploadAgainId
                }, [
                  n("span", {
                    title: "重新上传",
                    onClick: p(U, ["stop"])
                  }, [...e[6] || (e[6] = [
                    n("i", { class: "clIconFont clIcon-upload" }, null, -1)
                  ])])
                ], 8, me)
              ])) : g("", !0)
            ]),
            n("div", pe, [
              n("span", {
                title: "放大",
                onClick: p(q, ["stop"])
              }, [...e[7] || (e[7] = [
                n("i", { class: "clIconFont clIcon-search-plus" }, null, -1)
              ])]),
              n("span", {
                title: "缩小",
                onClick: p(T, ["stop"])
              }, [...e[8] || (e[8] = [
                n("i", { class: "clIconFont clIcon-search-minus" }, null, -1)
              ])]),
              n("span", {
                title: "左转90°",
                onClick: p(j, ["stop"])
              }, [...e[9] || (e[9] = [
                n("i", { class: "clIconFont clIcon-rotate-left" }, null, -1)
              ])]),
              n("span", {
                title: "右转90°",
                onClick: p(V, ["stop"])
              }, [...e[10] || (e[10] = [
                n("i", { class: "clIconFont clIcon-rotate-right" }, null, -1)
              ])]),
              n("span", {
                title: "重置",
                onClick: p(H, ["stop"])
              }, [...e[11] || (e[11] = [
                n("i", { class: "clIconFont clIcon-restore" }, null, -1)
              ])]),
              i.isShowSave ? (o(), r("span", {
                key: 0,
                title: "保存",
                onClick: p(W, ["stop"])
              }, [...e[12] || (e[12] = [
                n("i", { class: "clIconFont clIcon-save" }, null, -1)
              ])])) : g("", !0)
            ])
          ])
        ]),
        i.isPreview ? (o(), r("div", {
          key: 0,
          class: E(a.value)
        }, [
          n("div", {
            style: R(c.pStyle)
          }, [
            n("img", {
              src: c.src,
              style: R(c.style),
              alt: ""
            }, null, 12, fe)
          ], 4),
          i.isPreviewAlignLine ? (o(), r("div", ve, [
            C.value.indexOf("center") > -1 ? (o(), r(I, { key: 0 }, [
              e[13] || (e[13] = n("div", { class: "alignline-h alignline-center-h" }, null, -1)),
              e[14] || (e[14] = n("div", { class: "alignline-v alignline-center-v" }, null, -1))
            ], 64)) : g("", !0),
            C.value.indexOf("nineGrid") > -1 ? (o(), r(I, { key: 1 }, [
              e[15] || (e[15] = n("div", { class: "alignline-h alignline-nineGrid-h1" }, null, -1)),
              e[16] || (e[16] = n("div", { class: "alignline-h alignline-nineGrid-h2" }, null, -1)),
              e[17] || (e[17] = n("div", { class: "alignline-v alignline-nineGrid-v1" }, null, -1)),
              e[18] || (e[18] = n("div", { class: "alignline-v alignline-nineGrid-v2" }, null, -1))
            ], 64)) : g("", !0)
          ])) : g("", !0)
        ], 2)) : g("", !0)
      ])
    ], 2));
  }
}), Le = /* @__PURE__ */ k({
  name: "ClCropper",
  __name: "Index",
  props: {
    className: String,
    src: {
      type: String,
      required: !0
    },
    width: {
      type: Number,
      required: !0
    },
    height: {
      type: Number,
      required: !0
    },
    isFixedAspectRatio: {
      type: Boolean,
      default: !0
    },
    isCenterBox: {
      type: Boolean,
      default: !0
    },
    isPreview: {
      type: Boolean,
      default: !0
    },
    previewShape: {
      type: String,
      default: "square"
      // square | round
    },
    enlarge: {
      type: Number,
      default: 2
    },
    isModal: {
      type: Boolean,
      default: !0
    },
    isShowUpload: {
      type: Boolean,
      default: !0
    },
    isShowSave: {
      type: Boolean,
      default: !1
    },
    fillColor: {
      type: String,
      default: "transparent"
      // #FFFFFF
    },
    alignLine: {
      type: String,
      default: "center"
      // center | nineGrid
    },
    isPreviewAlignLine: {
      type: Boolean,
      default: !1
    }
  },
  emits: ["onSubmit", "onImgLoad"],
  setup(i, { expose: y, emit: v }) {
    const l = i, h = v, s = x(null), w = x(null), S = () => w.value.getImageBase64().then((a) => a), u = () => S().then((a) => {
      h("onSubmit", a), s.value.hide();
    }), m = (a) => {
      h("onImgLoad", a);
    }, c = () => S().then((a) => {
      h("onSubmit", a);
    });
    return y({
      getImageBase64: () => S(),
      show: () => {
        s.value && l.isModal && s.value.show();
      }
    }), (a, N) => i.isModal ? (o(), b(ne, {
      key: 0,
      ref_key: "refElModal",
      ref: s,
      width: "850px",
      titleName: "图片裁切",
      isShowSubmitLoad: !1,
      closeLabel: "取消",
      submitLabel: "确定",
      onOnSubmit: u
    }, {
      default: Z(() => [
        F(M, {
          ref_key: "refElCropper",
          ref: w,
          className: i.className,
          src: i.src,
          width: i.width,
          height: i.height,
          isFixedAspectRatio: i.isFixedAspectRatio,
          isPreview: i.isPreview,
          previewShape: i.previewShape,
          enlarge: i.enlarge,
          isCenterBox: i.isCenterBox,
          isShowUpload: i.isShowUpload,
          isShowSave: !1,
          alignLine: i.alignLine,
          isPreviewAlignLine: i.isPreviewAlignLine,
          fillColor: i.fillColor,
          onOnImgLoad: m
        }, null, 8, ["className", "src", "width", "height", "isFixedAspectRatio", "isPreview", "previewShape", "enlarge", "isCenterBox", "isShowUpload", "alignLine", "isPreviewAlignLine", "fillColor"])
      ]),
      _: 1
    }, 512)) : (o(), b(M, {
      key: 1,
      ref_key: "refElCropper",
      ref: w,
      className: i.className,
      src: i.src,
      width: i.width,
      height: i.height,
      isFixedAspectRatio: i.isFixedAspectRatio,
      isPreview: i.isPreview,
      previewShape: i.previewShape,
      enlarge: i.enlarge,
      isCenterBox: i.isCenterBox,
      isShowUpload: i.isShowUpload,
      isShowSave: i.isShowSave,
      alignLine: i.alignLine,
      isPreviewAlignLine: i.isPreviewAlignLine,
      fillColor: i.fillColor,
      onOnImgLoad: m,
      onOnImgSave: c
    }, null, 8, ["className", "src", "width", "height", "isFixedAspectRatio", "isPreview", "previewShape", "enlarge", "isCenterBox", "isShowUpload", "isShowSave", "alignLine", "isPreviewAlignLine", "fillColor"]));
  }
});
export {
  Le as _
};
//# sourceMappingURL=Index.vue_vue_type_script_setup_true_lang-DpxHzkjC.js.map
