import '@das-fed/upf-ui/packages/components/image-viewer/style.css';
import { withInstall as xt } from "@das-fed/upf-utils/with-install/index";
import { ref as be, computed as D, watch as Ft, createApp as Nt, defineComponent as Mt, openBlock as m, createElementBlock as E, Fragment as le, createCommentVNode as f, createElementVNode as F, normalizeStyle as ue, withDirectives as B, createVNode as G, unref as r, normalizeClass as ce, withCtx as Y, createBlock as I, vShow as O, isRef as xe, createTextVNode as Fe, toDisplayString as Ne, renderList as Me } from "vue";
import { ElImageViewer as Lt, ElImage as Le } from "element-plus";
import { Upload as Je } from "ant-design-vue";
import { vDasTooltip as Ve } from "@das-fed/upf-ui/packages/components/text-tooltip/index";
import { DasImageUpload as Ke } from "@das-fed/upf-ui/packages/components/image-upload/index";
import { DasSpin as ze } from "@das-fed/upf-ui/packages/components/spin/index";
import { DasAudioVideo as de } from "@das-fed/upf-ui/packages/components/audio-video/index";
import { DasIconDownload as He } from "@das-fed/upf-ui/packages/icons/download/index";
import { DasIconChange as fe } from "@das-fed/upf-ui/packages/icons/change/index";
import { DasIconDelete as qe } from "@das-fed/upf-ui/packages/icons/delete/index";
import { useModelValue as Ge } from "@das-fed/upf-utils/vue";
import { DasMessage as Ye } from "@das-fed/upf-ui/packages/components/message/index";
import { extractFilename as ut, getFileExtension as Jt } from "@das-fed/upf-utils/common-tools";
import { getConfig as De } from "@das-fed/upf-utils/config";
import { currentLang as Ze, i18n as Xe } from "@das-fed/upf-web/packages/i18n/index";
import { iotMinio as ct } from "@das-fed/upf-utils/api-services/modules/iot";
import { useFile as Vt } from "@das-fed/upf-utils/api-services/modules/file";
import { getUserInfo as Kt } from "@das-fed/upf-utils/common-info";
import { pureImageSrc as Pe } from "@das-fed/upf-utils/pure-image-src";
import "ant-design-vue/es/upload/style/css";
import "element-plus/es/components/image/style/css";
import "element-plus/es/components/image-viewer/style/css";
const Se = "data:image/png;base64, ", zt = (e, t) => {
  const n = new Image();
  n.setAttribute("crossOrigin", "Anonymous"), n.onload = function() {
    let a = document.createElement("canvas");
    const o = a.getContext("2d");
    a.width = n.width, a.height = n.height, o.drawImage(n, 0, 0, n.width, n.height), a.toBlob((l) => {
      let u = URL.createObjectURL(l), s = document.createElement("a"), d = new MouseEvent("click");
      const v = e.substring(e.lastIndexOf(".")).toLowerCase();
      s.download = t || `default${v}`, s.href = u, s.dispatchEvent(d), URL.revokeObjectURL(u);
    });
  }, n.src = e + "?v=" + Date.now();
}, Ht = (e, t) => {
  e && fetch(e).then((n) => n.blob()).then((n) => {
    const a = document.createElement("a");
    document.body.appendChild(a), a.style.display = "none";
    const o = window.URL.createObjectURL(n);
    a.href = o, a.download = t, a.click(), document.body.removeChild(a), window.URL.revokeObjectURL(o);
  });
};
function qt() {
  this.__data__ = [], this.size = 0;
}
function pe(e, t) {
  return e === t || e !== e && t !== t;
}
function he(e, t) {
  for (var n = e.length; n--; )
    if (pe(e[n][0], t))
      return n;
  return -1;
}
var Gt = Array.prototype, Yt = Gt.splice;
function Zt(e) {
  var t = this.__data__, n = he(t, e);
  if (n < 0)
    return !1;
  var a = t.length - 1;
  return n == a ? t.pop() : Yt.call(t, n, 1), --this.size, !0;
}
function Xt(e) {
  var t = this.__data__, n = he(t, e);
  return n < 0 ? void 0 : t[n][1];
}
function Wt(e) {
  return he(this.__data__, e) > -1;
}
function $t(e, t) {
  var n = this.__data__, a = he(n, e);
  return a < 0 ? (++this.size, n.push([e, t])) : n[a][1] = t, this;
}
function j(e) {
  var t = -1, n = e == null ? 0 : e.length;
  for (this.clear(); ++t < n; ) {
    var a = e[t];
    this.set(a[0], a[1]);
  }
}
j.prototype.clear = qt;
j.prototype.delete = Zt;
j.prototype.get = Xt;
j.prototype.has = Wt;
j.prototype.set = $t;
function _t() {
  this.__data__ = new j(), this.size = 0;
}
function en(e) {
  var t = this.__data__, n = t.delete(e);
  return this.size = t.size, n;
}
function tn(e) {
  return this.__data__.get(e);
}
function nn(e) {
  return this.__data__.has(e);
}
var dt = typeof global == "object" && global && global.Object === Object && global, rn = typeof self == "object" && self && self.Object === Object && self, Z = dt || rn || Function("return this")(), me = Z.Symbol, ft = Object.prototype, an = ft.hasOwnProperty, on = ft.toString, re = me ? me.toStringTag : void 0;
function sn(e) {
  var t = an.call(e, re), n = e[re];
  try {
    e[re] = void 0;
    var a = !0;
  } catch {
  }
  var o = on.call(e);
  return a && (t ? e[re] = n : delete e[re]), o;
}
var ln = Object.prototype, un = ln.toString;
function cn(e) {
  return un.call(e);
}
var dn = "[object Null]", fn = "[object Undefined]", We = me ? me.toStringTag : void 0;
function Ae(e) {
  return e == null ? e === void 0 ? fn : dn : We && We in Object(e) ? sn(e) : cn(e);
}
function V(e) {
  var t = typeof e;
  return e != null && (t == "object" || t == "function");
}
var gn = "[object AsyncFunction]", mn = "[object Function]", vn = "[object GeneratorFunction]", pn = "[object Proxy]";
function Qe(e) {
  if (!V(e))
    return !1;
  var t = Ae(e);
  return t == mn || t == vn || t == gn || t == pn;
}
var Ee = Z["__core-js_shared__"], $e = function() {
  var e = /[^.]+$/.exec(Ee && Ee.keys && Ee.keys.IE_PROTO || "");
  return e ? "Symbol(src)_1." + e : "";
}();
function hn(e) {
  return !!$e && $e in e;
}
var An = Function.prototype, wn = An.toString;
function yn(e) {
  if (e != null) {
    try {
      return wn.call(e);
    } catch {
    }
    try {
      return e + "";
    } catch {
    }
  }
  return "";
}
var Cn = /[\\^$.*+?()[\]{}|]/g, bn = /^\[object .+?Constructor\]$/, En = Function.prototype, In = Object.prototype, Sn = En.toString, Bn = In.hasOwnProperty, On = RegExp(
  "^" + Sn.call(Bn).replace(Cn, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
);
function Tn(e) {
  if (!V(e) || hn(e))
    return !1;
  var t = Qe(e) ? On : bn;
  return t.test(yn(e));
}
function kn(e, t) {
  return e == null ? void 0 : e[t];
}
function Re(e, t) {
  var n = kn(e, t);
  return Tn(n) ? n : void 0;
}
var gt = Re(Z, "Map"), ie = Re(Object, "create");
function Dn() {
  this.__data__ = ie ? ie(null) : {}, this.size = 0;
}
function Pn(e) {
  var t = this.has(e) && delete this.__data__[e];
  return this.size -= t ? 1 : 0, t;
}
var Qn = "__lodash_hash_undefined__", Rn = Object.prototype, jn = Rn.hasOwnProperty;
function Un(e) {
  var t = this.__data__;
  if (ie) {
    var n = t[e];
    return n === Qn ? void 0 : n;
  }
  return jn.call(t, e) ? t[e] : void 0;
}
var xn = Object.prototype, Fn = xn.hasOwnProperty;
function Nn(e) {
  var t = this.__data__;
  return ie ? t[e] !== void 0 : Fn.call(t, e);
}
var Mn = "__lodash_hash_undefined__";
function Ln(e, t) {
  var n = this.__data__;
  return this.size += this.has(e) ? 0 : 1, n[e] = ie && t === void 0 ? Mn : t, this;
}
function J(e) {
  var t = -1, n = e == null ? 0 : e.length;
  for (this.clear(); ++t < n; ) {
    var a = e[t];
    this.set(a[0], a[1]);
  }
}
J.prototype.clear = Dn;
J.prototype.delete = Pn;
J.prototype.get = Un;
J.prototype.has = Nn;
J.prototype.set = Ln;
function Jn() {
  this.size = 0, this.__data__ = {
    hash: new J(),
    map: new (gt || j)(),
    string: new J()
  };
}
function Vn(e) {
  var t = typeof e;
  return t == "string" || t == "number" || t == "symbol" || t == "boolean" ? e !== "__proto__" : e === null;
}
function we(e, t) {
  var n = e.__data__;
  return Vn(t) ? n[typeof t == "string" ? "string" : "hash"] : n.map;
}
function Kn(e) {
  var t = we(this, e).delete(e);
  return this.size -= t ? 1 : 0, t;
}
function zn(e) {
  return we(this, e).get(e);
}
function Hn(e) {
  return we(this, e).has(e);
}
function qn(e, t) {
  var n = we(this, e), a = n.size;
  return n.set(e, t), this.size += n.size == a ? 0 : 1, this;
}
function X(e) {
  var t = -1, n = e == null ? 0 : e.length;
  for (this.clear(); ++t < n; ) {
    var a = e[t];
    this.set(a[0], a[1]);
  }
}
X.prototype.clear = Jn;
X.prototype.delete = Kn;
X.prototype.get = zn;
X.prototype.has = Hn;
X.prototype.set = qn;
var Gn = 200;
function Yn(e, t) {
  var n = this.__data__;
  if (n instanceof j) {
    var a = n.__data__;
    if (!gt || a.length < Gn - 1)
      return a.push([e, t]), this.size = ++n.size, this;
    n = this.__data__ = new X(a);
  }
  return n.set(e, t), this.size = n.size, this;
}
function W(e) {
  var t = this.__data__ = new j(e);
  this.size = t.size;
}
W.prototype.clear = _t;
W.prototype.delete = en;
W.prototype.get = tn;
W.prototype.has = nn;
W.prototype.set = Yn;
var ve = function() {
  try {
    var e = Re(Object, "defineProperty");
    return e({}, "", {}), e;
  } catch {
  }
}();
function je(e, t, n) {
  t == "__proto__" && ve ? ve(e, t, {
    configurable: !0,
    enumerable: !0,
    value: n,
    writable: !0
  }) : e[t] = n;
}
function Be(e, t, n) {
  (n !== void 0 && !pe(e[t], n) || n === void 0 && !(t in e)) && je(e, t, n);
}
function Zn(e) {
  return function(t, n, a) {
    for (var o = -1, l = Object(t), u = a(t), s = u.length; s--; ) {
      var d = u[++o];
      if (n(l[d], d, l) === !1)
        break;
    }
    return t;
  };
}
var Xn = Zn(), mt = typeof exports == "object" && exports && !exports.nodeType && exports, _e = mt && typeof module == "object" && module && !module.nodeType && module, Wn = _e && _e.exports === mt, et = Wn ? Z.Buffer : void 0;
et && et.allocUnsafe;
function $n(e, t) {
  return e.slice();
}
var tt = Z.Uint8Array;
function _n(e) {
  var t = new e.constructor(e.byteLength);
  return new tt(t).set(new tt(e)), t;
}
function er(e, t) {
  var n = _n(e.buffer);
  return new e.constructor(n, e.byteOffset, e.length);
}
function tr(e, t) {
  var n = -1, a = e.length;
  for (t || (t = Array(a)); ++n < a; )
    t[n] = e[n];
  return t;
}
var nt = Object.create, nr = /* @__PURE__ */ function() {
  function e() {
  }
  return function(t) {
    if (!V(t))
      return {};
    if (nt)
      return nt(t);
    e.prototype = t;
    var n = new e();
    return e.prototype = void 0, n;
  };
}();
function rr(e, t) {
  return function(n) {
    return e(t(n));
  };
}
var vt = rr(Object.getPrototypeOf, Object), ar = Object.prototype;
function pt(e) {
  var t = e && e.constructor, n = typeof t == "function" && t.prototype || ar;
  return e === n;
}
function ir(e) {
  return typeof e.constructor == "function" && !pt(e) ? nr(vt(e)) : {};
}
function oe(e) {
  return e != null && typeof e == "object";
}
var or = "[object Arguments]";
function rt(e) {
  return oe(e) && Ae(e) == or;
}
var ht = Object.prototype, sr = ht.hasOwnProperty, lr = ht.propertyIsEnumerable, Oe = rt(/* @__PURE__ */ function() {
  return arguments;
}()) ? rt : function(e) {
  return oe(e) && sr.call(e, "callee") && !lr.call(e, "callee");
}, Te = Array.isArray, ur = 9007199254740991;
function At(e) {
  return typeof e == "number" && e > -1 && e % 1 == 0 && e <= ur;
}
function Ue(e) {
  return e != null && At(e.length) && !Qe(e);
}
function cr(e) {
  return oe(e) && Ue(e);
}
function dr() {
  return !1;
}
var wt = typeof exports == "object" && exports && !exports.nodeType && exports, at = wt && typeof module == "object" && module && !module.nodeType && module, fr = at && at.exports === wt, it = fr ? Z.Buffer : void 0, gr = it ? it.isBuffer : void 0, yt = gr || dr, mr = "[object Object]", vr = Function.prototype, pr = Object.prototype, Ct = vr.toString, hr = pr.hasOwnProperty, Ar = Ct.call(Object);
function wr(e) {
  if (!oe(e) || Ae(e) != mr)
    return !1;
  var t = vt(e);
  if (t === null)
    return !0;
  var n = hr.call(t, "constructor") && t.constructor;
  return typeof n == "function" && n instanceof n && Ct.call(n) == Ar;
}
var yr = "[object Arguments]", Cr = "[object Array]", br = "[object Boolean]", Er = "[object Date]", Ir = "[object Error]", Sr = "[object Function]", Br = "[object Map]", Or = "[object Number]", Tr = "[object Object]", kr = "[object RegExp]", Dr = "[object Set]", Pr = "[object String]", Qr = "[object WeakMap]", Rr = "[object ArrayBuffer]", jr = "[object DataView]", Ur = "[object Float32Array]", xr = "[object Float64Array]", Fr = "[object Int8Array]", Nr = "[object Int16Array]", Mr = "[object Int32Array]", Lr = "[object Uint8Array]", Jr = "[object Uint8ClampedArray]", Vr = "[object Uint16Array]", Kr = "[object Uint32Array]", w = {};
w[Ur] = w[xr] = w[Fr] = w[Nr] = w[Mr] = w[Lr] = w[Jr] = w[Vr] = w[Kr] = !0;
w[yr] = w[Cr] = w[Rr] = w[br] = w[jr] = w[Er] = w[Ir] = w[Sr] = w[Br] = w[Or] = w[Tr] = w[kr] = w[Dr] = w[Pr] = w[Qr] = !1;
function zr(e) {
  return oe(e) && At(e.length) && !!w[Ae(e)];
}
function Hr(e) {
  return function(t) {
    return e(t);
  };
}
var bt = typeof exports == "object" && exports && !exports.nodeType && exports, ae = bt && typeof module == "object" && module && !module.nodeType && module, qr = ae && ae.exports === bt, Ie = qr && dt.process, ot = function() {
  try {
    var e = ae && ae.require && ae.require("util").types;
    return e || Ie && Ie.binding && Ie.binding("util");
  } catch {
  }
}(), st = ot && ot.isTypedArray, Et = st ? Hr(st) : zr;
function ke(e, t) {
  if (!(t === "constructor" && typeof e[t] == "function") && t != "__proto__")
    return e[t];
}
var Gr = Object.prototype, Yr = Gr.hasOwnProperty;
function Zr(e, t, n) {
  var a = e[t];
  (!(Yr.call(e, t) && pe(a, n)) || n === void 0 && !(t in e)) && je(e, t, n);
}
function Xr(e, t, n, a) {
  var o = !n;
  n || (n = {});
  for (var l = -1, u = t.length; ++l < u; ) {
    var s = t[l], d = void 0;
    d === void 0 && (d = e[s]), o ? je(n, s, d) : Zr(n, s, d);
  }
  return n;
}
function Wr(e, t) {
  for (var n = -1, a = Array(e); ++n < e; )
    a[n] = t(n);
  return a;
}
var $r = 9007199254740991, _r = /^(?:0|[1-9]\d*)$/;
function It(e, t) {
  var n = typeof e;
  return t = t ?? $r, !!t && (n == "number" || n != "symbol" && _r.test(e)) && e > -1 && e % 1 == 0 && e < t;
}
function ea(e, t) {
  var n = Te(e), a = !n && Oe(e), o = !n && !a && yt(e), l = !n && !a && !o && Et(e), u = n || a || o || l, s = u ? Wr(e.length, String) : [], d = s.length;
  for (var v in e)
    u && // Safari 9 has enumerable `arguments.length` in strict mode.
    (v == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
    o && (v == "offset" || v == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
    l && (v == "buffer" || v == "byteLength" || v == "byteOffset") || // Skip index properties.
    It(v, d)) || s.push(v);
  return s;
}
function ta(e) {
  var t = [];
  if (e != null)
    for (var n in Object(e))
      t.push(n);
  return t;
}
var na = Object.prototype, ra = na.hasOwnProperty;
function aa(e) {
  if (!V(e))
    return ta(e);
  var t = pt(e), n = [];
  for (var a in e)
    a == "constructor" && (t || !ra.call(e, a)) || n.push(a);
  return n;
}
function St(e) {
  return Ue(e) ? ea(e) : aa(e);
}
function ia(e) {
  return Xr(e, St(e));
}
function oa(e, t, n, a, o, l, u) {
  var s = ke(e, n), d = ke(t, n), v = u.get(d);
  if (v) {
    Be(e, n, v);
    return;
  }
  var h = l ? l(s, d, n + "", e, t, u) : void 0, c = h === void 0;
  if (c) {
    var C = Te(d), b = !C && yt(d), T = !C && !b && Et(d);
    h = d, C || b || T ? Te(s) ? h = s : cr(s) ? h = tr(s) : b ? (c = !1, h = $n(d)) : T ? (c = !1, h = er(d)) : h = [] : wr(d) || Oe(d) ? (h = s, Oe(s) ? h = ia(s) : (!V(s) || Qe(s)) && (h = ir(d))) : c = !1;
  }
  c && (u.set(d, h), o(h, d, a, l, u), u.delete(d)), Be(e, n, h);
}
function Bt(e, t, n, a, o) {
  e !== t && Xn(t, function(l, u) {
    if (o || (o = new W()), V(l))
      oa(e, t, u, n, Bt, a, o);
    else {
      var s = a ? a(ke(e, u), l, u + "", e, t, o) : void 0;
      s === void 0 && (s = l), Be(e, u, s);
    }
  }, St);
}
function Ot(e) {
  return e;
}
function sa(e, t, n) {
  switch (n.length) {
    case 0:
      return e.call(t);
    case 1:
      return e.call(t, n[0]);
    case 2:
      return e.call(t, n[0], n[1]);
    case 3:
      return e.call(t, n[0], n[1], n[2]);
  }
  return e.apply(t, n);
}
var lt = Math.max;
function la(e, t, n) {
  return t = lt(t === void 0 ? e.length - 1 : t, 0), function() {
    for (var a = arguments, o = -1, l = lt(a.length - t, 0), u = Array(l); ++o < l; )
      u[o] = a[t + o];
    o = -1;
    for (var s = Array(t + 1); ++o < t; )
      s[o] = a[o];
    return s[t] = n(u), sa(e, this, s);
  };
}
function ua(e) {
  return function() {
    return e;
  };
}
var ca = ve ? function(e, t) {
  return ve(e, "toString", {
    configurable: !0,
    enumerable: !1,
    value: ua(t),
    writable: !0
  });
} : Ot, da = 800, fa = 16, ga = Date.now;
function ma(e) {
  var t = 0, n = 0;
  return function() {
    var a = ga(), o = fa - (a - n);
    if (n = a, o > 0) {
      if (++t >= da)
        return arguments[0];
    } else
      t = 0;
    return e.apply(void 0, arguments);
  };
}
var va = ma(ca);
function pa(e, t) {
  return va(la(e, t, Ot), e + "");
}
function ha(e, t, n) {
  if (!V(n))
    return !1;
  var a = typeof t;
  return (a == "number" ? Ue(n) && It(t, n.length) : a == "string" && t in n) ? pe(n[t], e) : !1;
}
function Aa(e) {
  return pa(function(t, n) {
    var a = -1, o = n.length, l = o > 1 ? n[o - 1] : void 0, u = o > 2 ? n[2] : void 0;
    for (l = e.length > 3 && typeof l == "function" ? (o--, l) : void 0, u && ha(n[0], n[1], u) && (l = o < 3 ? void 0 : l, o = 1), t = Object(t); ++a < o; ) {
      var s = n[a];
      s && e(t, s, a, l);
    }
    return t;
  });
}
var Tt = Aa(function(e, t, n) {
  Bt(e, t, n);
});
const kt = (e, t) => {
  let n = {};
  return typeof (e == null ? void 0 : e.requestConfig) == "function" ? n = e == null ? void 0 : e.requestConfig(t) : n = (e == null ? void 0 : e.requestConfig) || {}, n;
}, wa = (e) => {
  const t = (e == null ? void 0 : e.minioTokenApi) ?? "token";
  return ct.get(t, (n) => {
    let a = kt(e, n);
    return n.headers || (n.headers = {}), e != null && e.baseUrl && (n.baseURL = e.baseUrl), Tt(n, a);
  });
}, ya = (e) => ct.post("put-object", (t) => {
  let n = kt(e, t);
  return t.headers || (t.headers = {}), e != null && e.baseUrl && (t.baseURL = e.baseUrl), t.headers["Content-Type"] = "multipart/form-data", Tt(t, n);
}), Ca = () => {
  const e = Kt();
  return e ? e.tenantId : "";
}, ba = (e) => {
  const { baseUrl: t, serviceName: n, pathPrefix: a, bucketName: o, minioTokenApi: l, autoContentType: u, requestConfig: s } = e, d = async () => {
    const [c, C] = await wa({ baseUrl: t, minioTokenApi: l, requestConfig: s })().run();
    return c ? { stauts: !1 } : { status: !0, data: C };
  }, { generateUniqueName: v } = Vt();
  return { upload: async (c, C = {}) => {
    const b = await d();
    if (!b.status) return;
    const T = c.name, Q = b.data, K = a || Ca(), $ = T.substring(T.lastIndexOf(".")).toLowerCase(), N = e.randomName ? `${v("")}${$}` : T, z = n ? `${K}/${n}/${N}` : `${K}/${N}`, H = {
      accessKeyId: Q.accessKeyId,
      secretAccessKey: Q.secretAccessKey,
      sessionToken: Q.sessionToken,
      file: c,
      bucketName: o || "business",
      filePath: z,
      isThumbnail: !0,
      autoContentType: u === !0 ? !0 : void 0,
      ...C
    }, [M, q] = await ya({ baseUrl: t, requestConfig: s })(H).run();
    return M ? "error" : q.value;
  } };
}, Ea = () => ({ size2B: (t) => {
  isNaN(Number(t)) ? t = t.toString() : t = t + "M";
  const n = Number(t.slice(0, -1)), a = t[t.length - 1].toUpperCase(), o = 1024, l = {
    M: o * o,
    K: o,
    B: 1
  };
  return { finalSize: n * l[a], sizeText: t };
} }), Ia = (e) => ({ handlerImageSrc: (n, a) => {
  if (a.startsWith("http")) return a;
  const o = e.useOriginUrl ? a : Pe(a);
  return n + o;
} }), Sa = async (e) => {
  const n = De().baseURL + Pe(e);
  return await ut(n);
}, Ba = async (e) => {
  const t = De();
  let n = [];
  for (const a of e) {
    const o = t.baseURL + Pe(a), l = await ut(o);
    n.push(l);
  }
  return n;
}, Oa = (e, t) => {
  De();
  const n = Ge(e, "modelValue"), a = Ge(e, "status"), { upload: o } = ba(e), { size2B: l } = Ea(), { handlerImageSrc: u } = Ia(e), s = be(""), d = be([]), v = [".mp4", ".avi", ".mkv", ".mov", ".wmv", ".flv", ".mpeg", ".webm"], h = [".mp3", ".wav", ".aac", ".flac", ".ogg", ".alff", ".wma", ".m4a"], c = D(() => e.baseUrl ? e.baseUrl : ""), C = (i) => {
    if (i) {
      const g = i.substring(i.lastIndexOf(".")).toLowerCase();
      if (v.includes(g)) return "isVideo";
      if (h.includes(g)) return "isAudio";
    }
    return "isImg";
  }, b = D(() => {
    var g;
    let i = e.accept ? (g = e.accept) == null ? void 0 : g.split(",") : [];
    return i.includes("image/jpg") && !i.includes("image/jpeg") && i.push("image/jpeg"), i.includes(".jpg") && !i.includes(".jpeg") && i.push(".jpeg"), e.acceptVideo && (i = [...i, ...v]), e.acceptAudio && (i = [...i, ...h]), i.join(",");
  }), T = D(() => a.value === "uploading"), Q = be(0), K = (i) => T.value ? Q.value === i : !1, $ = D(() => n.value ? [u(c.value, n.value)] : []), N = D(() => n.value ? n.value.map((i) => [u(c.value, i)]) : []), z = D(() => e.status !== "info" && (e.needDeleteBtn || e.needChangeBtn) || e.needDownloadBtn), H = D(() => e.status !== "info" && e.needDeleteBtn || e.needDownloadBtn), M = D(() => {
    const i = [], g = e.previewBtnConfig;
    if (typeof g == "boolean")
      return g ? ["zoom_in", "zoom_out", "turn_left", "turn_right", "full_screen"] : [];
    for (const k in g)
      g[k] && i.push(k);
    return i;
  }), q = () => {
    setTimeout(() => {
      const i = document.querySelector(".el-image-viewer__wrapper");
      i == null || i.classList.add("das-image-viewer-preview-btn-groups"), i == null || i.classList.add(...M.value);
    }, 0);
  }, ye = (i) => {
    t("clickChangeIcon", i);
  }, U = (i, g) => {
    e.limitNum === 1 ? (n.value = "", t("update:modelValue", ""), t("deleteImage", i)) : (n.value.splice(g, 1), t("update:modelValue", n.value), t("deleteImage", i));
  }, x = (i, g = 0) => {
    var te;
    t("downloadImage", i);
    let k = "";
    e.limitNum === 1 ? k = e.imageName || s.value : k = ((te = e.imageName) == null ? void 0 : te[g]) || d.value[g], C(i) === "isImg" ? zt(u(c.value, i), k) : Ht(u(c.value, i), k);
  }, _ = (i, g) => {
    var te;
    if (e.maxSize) {
      const { finalSize: P, sizeText: S } = l(e.maxSize);
      if (i.size > P) {
        const ne = Ze.value === "zh-CN" ? "、" : ", ", L = Xe(
          "das-ui-import-upload-key3",
          S,
          ((te = b.value) == null ? void 0 : te.toUpperCase().replace(/\./g, "").replace(/,/g, ne)) ?? ""
        ).value, Ce = e.errorMessage || L;
        return Ye.warning(Ce), !1;
      }
    }
    const k = async (P) => {
      Q.value = P, t("update:status", "uploading"), t("image-upload", i);
      const S = await o(i);
      return S === "error" ? (t("update:status", "error"), !1) : (t("upload-success", i, S), e.limitNum === 1 ? n.value = S : n.value[P] = S, t("update:modelValue", n.value), t("update:status", "normal"), !1);
    };
    if (e.customCheck) {
      const P = e.customCheck(i);
      if (P instanceof Promise)
        return new Promise(async (S, ne) => {
          let L;
          try {
            L = await P.then();
          } catch {
            L = !1;
          }
          L ? k(g) : ne(!1);
        });
      if (!P) return !1;
    } else if (b.value) {
      const P = b.value.split(",").filter((R) => R.trim().startsWith(".")).map((R) => R.trim()), S = b.value.split(",").filter((R) => !R.trim().startsWith(".")).map((R) => R.trim()), ne = Jt(i.name), L = P.includes(ne);
      let Ce = S.includes("image/*") && i.type.split("/")[0].trim() === "image", Pt = S.includes("video/*") && i.type.split("/")[0].trim() === "video", Qt = S.includes("audio/*") && i.type.split("/")[0].trim() === "audio", Rt = S.includes(i.type) || Ce || Pt || Qt;
      if (!L && !Rt) {
        const R = e.acceptAudio || e.acceptVideo ? "das-ui-import-upload-key2" : "das-ui-import-upload-key1", jt = Ze.value === "zh-CN" ? "、" : ", ", Ut = e.errorMessage || Xe(R, b.value.toUpperCase().replace(/\./g, "").replace(/,/g, jt)).value;
        return Ye.warning(Ut), !1;
      }
    }
    return k(g);
  }, se = (i) => (g) => _(g, i), ee = async (i) => {
    e.limitNum !== 1 && (Q.value = n.length), t("update:status", "uploading"), t("image-upload", i);
    const g = await o(i);
    t("upload-success", i, g), e.limitNum === 1 ? p(g) : y(g);
  }, p = (i) => {
    if (i === "error") {
      t("update:status", "error");
      return;
    }
    n.value = i, t("update:modelValue", n.value), t("update:status", "normal");
  }, y = (i) => {
    if (i === "error") {
      t("update:status", "error");
      return;
    }
    n.value.push(i), t("update:modelValue", n.value), t("update:status", "normal");
  };
  return Ft(n, async () => {
    const i = e.limitNum ?? 1;
    i === 1 && n.value ? s.value = await Sa(n.value) : i > 1 && n.value.length > 0 && (d.value = await Ba(n.value));
  }, {
    deep: !0,
    immediate: !0
  }), {
    url: n,
    singlePreviewList: $,
    multiPreviewList: N,
    isAccept: b,
    loading: T,
    uploadStatus: a,
    previewBtns: M,
    operateShow: z,
    operateShow_Multi: H,
    singlePreviewName: s,
    multiPreviewName: d,
    getFileType: C,
    changeImg: ye,
    delImg: U,
    beforeupload: _,
    getBeforeUpload: se,
    uploadImg: ee,
    onDownload: x,
    handleImageClick: q,
    isLoadingMulti: K
  };
}, Ta = (e, t) => {
  var l;
  const { __IN_DAS_MICRO_APP: n, __DAS_MAIN_APP_HREF: a } = window;
  if (!n || !a) return;
  const { origin: o } = new URL(a);
  (l = window.top) == null || l.postMessage({ type: e, data: t }, o);
}, Dt = "proxy-image-viewer", ge = {
  sendMessageToMainApp: Ta,
  // @ts-ignore
  isMicroApp: () => window.__IN_DAS_MICRO_APP && window.top !== window.self,
  addEventFromMicroApp: () => {
    window.addEventListener("message", (e) => {
      const { type: t, data: n } = e.data;
      if (t !== Dt) return;
      const a = document.createElement("div");
      a.classList.add("das-image-viewer-preview-btn-groups");
      const { previewList: o, previewBtns: l } = n, u = Nt(Lt, {
        urlList: o,
        onClose: () => {
          u.unmount(), document.body.removeChild(a);
        }
      });
      document.body.appendChild(a), u.mount(a), setTimeout(() => {
        const s = document.querySelector(".el-image-viewer__wrapper");
        s == null || s.classList.add("das-image-viewer-preview-btn-groups"), s == null || s.classList.add(...l);
      }, 0);
    });
  }
};
ge.addEventFromMicroApp();
const ka = (e) => {
  const { handleImageClickProxy: t, previewBtns: n } = e;
  return { needPreviewImage: D(() => !e.needPreview || ge.isMicroApp() ? !1 : e.needPreview), handleImageClick: (l) => {
    if (!e.needPreview) return;
    if (!ge.isMicroApp()) {
      t();
      return;
    }
    let u = [];
    Array.isArray(l) && u.push(...l), typeof l == "string" && u.push(l), ge.sendMessageToMainApp(Dt, {
      previewList: u,
      previewBtns: n.value
    });
  } };
}, Da = {
  key: 0,
  class: "das-ui-image-viewer-container"
}, Pa = {
  class: "no-data-img",
  src: Se,
  alt: ""
}, Qa = { class: "image-name" }, Ra = { class: "das-ui-image-viewer-groups" }, ja = { class: "image-name" }, Ua = { class: "das-ui-image-viewer-container" }, xa = {
  key: 1,
  class: "das-ui-image-viewer-container"
}, Fa = { class: "das-ui-image-viewer" }, Na = {
  key: 2,
  class: "das-ui-image-viewer"
}, Ma = /* @__PURE__ */ Mt({
  __name: "Index",
  props: {
    style: { default: "" },
    modelValue: {},
    status: { default: "normal" },
    imageName: {},
    accept: { default: ".png, .jpg, .jpeg, .gif, .svg" },
    acceptVideo: { type: Boolean },
    acceptAudio: { type: Boolean },
    showImageName: { type: Boolean },
    baseUrl: {},
    serviceName: {},
    pathPrefix: {},
    bucketName: {},
    minioTokenApi: { default: "token" },
    maxSize: {},
    limitNum: { default: 1 },
    errorMessage: {},
    customCheck: {},
    needPreview: { type: Boolean, default: !0 },
    needDownloadBtn: { type: Boolean, default: !0 },
    needDeleteBtn: { type: Boolean, default: !0 },
    needChangeBtn: { type: Boolean, default: !0 },
    mode: { default: "upload" },
    previewBtnConfig: { type: [Boolean, Object], default: !0 },
    imageFit: { default: "cover" },
    autoContentType: { type: Boolean },
    message: {},
    videoWidth: {},
    videoHeight: {},
    randomName: { type: Boolean, default: !1 },
    useOriginUrl: { type: Boolean, default: !1 },
    openFileDialogOnClick: { type: Boolean, default: !0 },
    requestConfig: { default: null }
  },
  emits: ["update:modelValue", "update:status", "downloadImage", "image-upload", "upload-success", "clickChangeIcon", "deleteImage"],
  setup(e, { emit: t }) {
    const n = e, a = t, o = D(() => {
      const p = [
        n.needDownloadBtn,
        n.limitNum === 1 && c.value !== "info" && n.needChangeBtn,
        c.value !== "info" && n.needDeleteBtn
      ].filter((A) => A).length;
      let y = "center";
      return p === 2 && (y = "space-around"), p === 3 && (y = "space-between"), {
        "justify-content": y
      };
    }), l = D(() => n.mode === "view" ? !1 : s.value ? c.value === "error" : c.value !== "info"), u = (ee) => {
      ee.stopPropagation();
    }, {
      url: s,
      isAccept: d,
      singlePreviewList: v,
      multiPreviewList: h,
      uploadStatus: c,
      loading: C,
      previewBtns: b,
      operateShow: T,
      operateShow_Multi: Q,
      singlePreviewName: K,
      multiPreviewName: $,
      changeImg: N,
      delImg: z,
      getBeforeUpload: H,
      uploadImg: M,
      onDownload: q,
      handleImageClick: ye,
      getFileType: U,
      isLoadingMulti: x
    } = Oa(n, a), { needPreviewImage: _, handleImageClick: se } = ka({
      needPreview: n.needPreview,
      handleImageClickProxy: ye,
      previewBtns: b
    });
    return (ee, p) => (m(), E(
      le,
      null,
      [
        f(" 单文件 "),
        e.limitNum === 1 ? (m(), E("div", Da, [
          F(
            "div",
            {
              class: "das-ui-image-viewer",
              style: ue(e.style)
            },
            [
              f(" 状态不为 error 时显示 "),
              B(G(r(ze), {
                class: ce([{ "loading-border": r(C) }]),
                type: "component",
                spinning: r(C)
              }, {
                default: Y(() => [
                  f(" 图片 "),
                  r(U)(r(v)[0]) === "isImg" ? B((m(), I(r(Le), {
                    key: 0,
                    class: ce(["image-context", [r(b)]]),
                    "preview-teleported": !0,
                    src: r(v)[0],
                    "preview-src-list": r(_) ? r(v) : void 0,
                    "initial-index": 0,
                    fit: e.imageFit,
                    onClick: p[0] || (p[0] = (y) => r(se)(r(v)))
                  }, null, 8, ["class", "src", "preview-src-list", "fit"])), [
                    [O, !r(C)]
                  ]) : f("v-if", !0),
                  f(" 视频 "),
                  r(U)(r(v)[0]) === "isVideo" ? B((m(), I(r(de), {
                    key: 1,
                    mode: r(c) === "info" || e.mode === "view" ? "view" : "normal",
                    src: r(v)[0],
                    needPreview: e.needPreview,
                    width: "100%",
                    height: "100%",
                    "player-props": { videoWidth: e.videoWidth, videoHeight: e.videoHeight },
                    fullPath: ""
                  }, null, 8, ["mode", "src", "needPreview", "player-props"])), [
                    [O, !r(C)]
                  ]) : f("v-if", !0),
                  f(" 音频 "),
                  r(U)(r(v)[0]) === "isAudio" ? B((m(), I(r(de), {
                    key: 2,
                    mode: r(c) === "info" || e.mode === "view" ? "view" : "normal",
                    src: r(v)[0],
                    needPreview: e.needPreview,
                    width: "100%",
                    height: "100%",
                    type: "audio",
                    fullPath: ""
                  }, null, 8, ["mode", "src", "needPreview"])), [
                    [O, !r(C)]
                  ]) : f("v-if", !0),
                  !r(C) && r(T) ? (m(), E(
                    "div",
                    {
                      key: 3,
                      class: "operate-container",
                      style: ue(o.value),
                      onClick: u
                    },
                    [
                      e.needDownloadBtn ? (m(), I(r(He), {
                        key: 0,
                        class: "operate-btn",
                        size: "medium",
                        "icon-color": "#fff",
                        onClick: p[1] || (p[1] = (y) => r(q)(r(s)))
                      })) : f("v-if", !0),
                      r(c) !== "info" && e.needChangeBtn ? (m(), E("div", {
                        key: 1,
                        class: "change-icon-box",
                        onClick: p[2] || (p[2] = (y) => r(N)(r(s)))
                      }, [
                        e.openFileDialogOnClick ? (m(), I(r(Je), {
                          key: 0,
                          "before-upload": r(H)(0),
                          accept: r(d),
                          openFileDialogOnClick: e.openFileDialogOnClick
                        }, {
                          itemRender: Y(({ file: y, actions: A }) => [...p[7] || (p[7] = [])]),
                          default: Y(() => [
                            G(r(fe), {
                              class: "operate-btn m-t-6",
                              "icon-color": "#fff",
                              size: "medium"
                            })
                          ]),
                          _: 1
                          /* STABLE */
                        }, 8, ["before-upload", "accept", "openFileDialogOnClick"])) : f("v-if", !0),
                        e.openFileDialogOnClick ? f("v-if", !0) : (m(), I(r(fe), {
                          key: 1,
                          class: "operate-btn m-t-6",
                          "icon-color": "#fff",
                          size: "medium"
                        }))
                      ])) : f("v-if", !0),
                      r(c) !== "info" && e.needDeleteBtn ? (m(), I(r(qe), {
                        key: 2,
                        class: "operate-btn",
                        "icon-color": "#fff",
                        size: "medium",
                        onClick: p[3] || (p[3] = (y) => r(z)(r(s)))
                      })) : f("v-if", !0)
                    ],
                    4
                    /* STYLE */
                  )) : f("v-if", !0)
                ]),
                _: 1
                /* STABLE */
              }, 8, ["class", "spinning"]), [
                [O, r(s) && e.status !== "error"]
              ]),
              f(" 上传模式，当 url 为空或者 uploading 和 error 时显示 "),
              B(G(r(Ke), {
                status: r(c),
                "onUpdate:status": p[4] || (p[4] = (y) => xe(c) ? c.value = y : null),
                "max-size": e.maxSize,
                accept: e.accept,
                acceptVideo: e.acceptVideo,
                message: e.message,
                acceptAudio: e.acceptAudio,
                autoContentType: e.autoContentType,
                "custom-check": e.customCheck,
                "error-message": e.errorMessage,
                openFileDialogOnClick: e.openFileDialogOnClick,
                onImageUpload: r(M)
              }, null, 8, ["status", "max-size", "accept", "acceptVideo", "message", "acceptAudio", "autoContentType", "custom-check", "error-message", "openFileDialogOnClick", "onImageUpload"]), [
                [O, l.value]
              ]),
              f(" 查看模式 "),
              B(F(
                "img",
                Pa,
                null,
                512
                /* NEED_PATCH */
              ), [
                [O, !r(s) && (r(c) === "info" || e.mode === "view")]
              ])
            ],
            4
            /* STYLE */
          ),
          B((m(), E("div", Qa, [
            Fe(
              Ne(n.imageName || r(K)),
              1
              /* TEXT */
            )
          ])), [
            [O, r(s) && e.showImageName && (r(c) === "normal" || r(c) === "info")],
            [r(Ve)]
          ])
        ])) : (m(), E(
          le,
          { key: 1 },
          [
            f(" 多文件 "),
            F("div", Ra, [
              f(" 已上传的图片集合 "),
              (m(!0), E(
                le,
                null,
                Me(r(s), (y, A) => {
                  var i;
                  return m(), E("div", {
                    key: A,
                    class: "das-ui-image-viewer-container"
                  }, [
                    F(
                      "div",
                      {
                        class: "das-ui-image-viewer",
                        style: ue(e.style)
                      },
                      [
                        B(G(r(ze), {
                          class: ce([{ "loading-border": r(x)(A) }]),
                          type: "component",
                          spinning: r(x)(A)
                        }, {
                          default: Y(() => [
                            r(U)(r(h)[A][0]) === "isImg" ? B((m(), I(r(Le), {
                              key: 0,
                              class: ce(["image-context", [r(b)]]),
                              src: r(h)[A][0],
                              "preview-teleported": !0,
                              "preview-src-list": r(_) ? r(h)[A] : void 0,
                              "initial-index": A,
                              onClick: (g) => r(se)(r(h)[A]),
                              fit: "cover"
                            }, null, 8, ["class", "src", "preview-src-list", "initial-index", "onClick"])), [
                              [O, !r(x)(A)]
                            ]) : f("v-if", !0),
                            f(" 视频 "),
                            r(U)(r(h)[A][0]) === "isVideo" ? B((m(), I(r(de), {
                              key: 1,
                              mode: r(c) === "info" || e.mode === "view" ? "view" : "normal",
                              src: r(h)[A][0],
                              needPreview: e.needPreview,
                              width: "100%",
                              height: "100%",
                              fullPath: "",
                              "player-props": { videoWidth: e.videoWidth, videoHeight: e.videoHeight }
                            }, null, 8, ["mode", "src", "needPreview", "player-props"])), [
                              [O, !r(x)(A)]
                            ]) : f("v-if", !0),
                            f(" 音频 "),
                            r(U)(r(h)[A][0]) === "isAudio" ? B((m(), I(r(de), {
                              key: 2,
                              mode: r(c) === "info" || e.mode === "view" ? "view" : "normal",
                              src: r(h)[A][0],
                              needPreview: e.needPreview,
                              width: "100%",
                              height: "100%",
                              type: "audio",
                              fullPath: ""
                            }, null, 8, ["mode", "src", "needPreview"])), [
                              [O, !r(x)(A)]
                            ]) : f("v-if", !0),
                            !r(C) && r(Q) ? (m(), E(
                              "div",
                              {
                                key: 3,
                                class: "operate-container",
                                style: ue(o.value)
                              },
                              [
                                e.needDownloadBtn ? (m(), I(r(He), {
                                  key: 0,
                                  class: "operate-btn",
                                  size: "medium",
                                  "icon-color": "#fff",
                                  onClick: (g) => r(q)(y, A)
                                }, null, 8, ["onClick"])) : f("v-if", !0),
                                r(c) !== "info" && e.needChangeBtn ? (m(), E("div", {
                                  key: 1,
                                  class: "change-icon-box",
                                  onClick: p[5] || (p[5] = (g) => r(N)(r(s)))
                                }, [
                                  e.openFileDialogOnClick ? (m(), I(r(Je), {
                                    key: 0,
                                    "before-upload": r(H)(A),
                                    accept: r(d),
                                    openFileDialogOnClick: e.openFileDialogOnClick
                                  }, {
                                    itemRender: Y(({ file: g, actions: k }) => [...p[8] || (p[8] = [])]),
                                    default: Y(() => [
                                      G(r(fe), {
                                        class: "operate-btn m-t-6",
                                        "icon-color": "#fff",
                                        size: "medium"
                                      })
                                    ]),
                                    _: 1
                                    /* STABLE */
                                  }, 8, ["before-upload", "accept", "openFileDialogOnClick"])) : f("v-if", !0),
                                  e.openFileDialogOnClick ? f("v-if", !0) : (m(), I(r(fe), {
                                    key: 1,
                                    class: "operate-btn m-t-6",
                                    "icon-color": "#fff",
                                    size: "medium"
                                  }))
                                ])) : f("v-if", !0),
                                r(c) !== "info" && e.needDeleteBtn ? (m(), I(r(qe), {
                                  key: 2,
                                  class: "operate-btn",
                                  "icon-color": "#fff",
                                  size: "medium",
                                  onClick: (g) => r(z)(y, A)
                                }, null, 8, ["onClick"])) : f("v-if", !0)
                              ],
                              4
                              /* STYLE */
                            )) : f("v-if", !0)
                          ]),
                          _: 2
                          /* DYNAMIC */
                        }, 1032, ["class", "spinning"]), [
                          [O, y]
                        ])
                      ],
                      4
                      /* STYLE */
                    ),
                    B((m(), E("div", ja, [
                      Fe(
                        Ne(((i = n.imageName) == null ? void 0 : i[A]) || r($)[A]),
                        1
                        /* TEXT */
                      )
                    ])), [
                      [O, y && e.showImageName && !r(x)(A)],
                      [r(Ve)]
                    ])
                  ]);
                }),
                128
                /* KEYED_FRAGMENT */
              )),
              f(" 查看模式下，默认占位符 "),
              e.mode === "view" ? (m(!0), E(
                le,
                { key: 0 },
                Me(e.limitNum - r(s).length, (y) => (m(), E("div", Ua, [...p[9] || (p[9] = [
                  F(
                    "div",
                    { class: "das-ui-image-viewer" },
                    [
                      F("img", {
                        class: "no-data-img",
                        src: Se,
                        alt: ""
                      })
                    ],
                    -1
                    /* CACHED */
                  )
                ])]))),
                256
                /* UNKEYED_FRAGMENT */
              )) : f("v-if", !0),
              f(" 图片数量未到达最大数量限制时，显示上传组件 "),
              e.mode === "upload" && r(c) !== "info" && r(s).length < e.limitNum ? (m(), E("div", xa, [
                F("div", Fa, [
                  G(r(Ke), {
                    status: r(c),
                    "onUpdate:status": p[6] || (p[6] = (y) => xe(c) ? c.value = y : null),
                    "max-size": e.maxSize,
                    accept: e.accept,
                    acceptVideo: e.acceptVideo,
                    acceptAudio: e.acceptAudio,
                    message: e.message,
                    "custom-check": e.customCheck,
                    "error-message": e.errorMessage,
                    openFileDialogOnClick: e.openFileDialogOnClick,
                    onImageUpload: r(M)
                  }, null, 8, ["status", "max-size", "accept", "acceptVideo", "acceptAudio", "message", "custom-check", "error-message", "openFileDialogOnClick", "onImageUpload"])
                ])
              ])) : f("v-if", !0),
              f(" 当图片状态为查看态且无数据时，显示无数据图片 "),
              r(c) === "info" && r(s).length === 0 ? (m(), E("div", Na, [...p[10] || (p[10] = [
                F(
                  "img",
                  {
                    class: "no-data-img",
                    src: Se,
                    alt: ""
                  },
                  null,
                  -1
                  /* CACHED */
                )
              ])])) : f("v-if", !0)
            ])
          ],
          2112
          /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
        ))
      ],
      2112
      /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
    ));
  }
}), La = (e, t) => {
  const n = e.__vccOpts || e;
  for (const [a, o] of t)
    n[a] = o;
  return n;
}, Ja = /* @__PURE__ */ La(Ma, [["__scopeId", "data-v-616ed0e1"]]), di = xt(Ja);
export {
  di as DasImageViewer,
  di as default,
  ba as minioUpload,
  Ea as useCalculateSize
};
