import { defineComponent as $, computed as d, ref as y, watch as L, resolveComponent as R, openBlock as r, createElementBlock as s, normalizeClass as p, unref as i, createBlock as H, mergeProps as K, isRef as F, createCommentVNode as C, createElementVNode as u, Fragment as V, renderList as I, createTextVNode as x, toDisplayString as h, createVNode as T } from "vue";
import { isArray as b, isString as z, isEqual as Y, isPlainObject as M, isFunction as P } from "lodash-es";
import { a6 as q, a7 as G, a9 as J, ae as Q, P as W, ak as X } from "./index-5a333c35.js";
import { m as Z } from "./mediaFilter-3fdbc89b.js";
import "axios";
import "@vueuse/core";
import "vue-i18n";
const _ = `.kapix-document-input{width:100%;height:100%;min-width:0;min-height:0;display:flex;flex-direction:row;overflow:auto}.kapix-document-input::-webkit-scrollbar-thumb{background-color:currentColor;border-radius:9px;border:solid 6px transparent;background-clip:content-box}.kapix-document-input::-webkit-scrollbar-thumb:hover{border-width:5px}.kapix-document-input::-webkit-scrollbar{height:18px;width:18px}@media (max-width: 599.98px){.kapix-document-input::-webkit-scrollbar{height:0;width:0}}.kapix-document-input::-webkit-scrollbar:disabled{display:none}.kapix-document-input::-webkit-scrollbar-button,.kapix-document-input ::-webkit-scrollbar-corner{cursor:pointer;background:transparent}.kapix-document-input::-webkit-scrollbar-button:horizontal:decrement,.kapix-document-input::-webkit-scrollbar-button:horizontal:increment,.kapix-document-input::-webkit-scrollbar-button:vertical:decrement,.kapix-document-input::-webkit-scrollbar-button:vertical:increment{display:none}.kapix-document-input::-webkit-scrollbar-button:vertical:start:increment,.kapix-document-input::-webkit-scrollbar-button:vertical:end:decrement,.kapix-document-input::-webkit-scrollbar-button:horizontal:start:increment,.kapix-document-input::-webkit-scrollbar-button:horizontal:end:decrement{display:none}.kapix-document-input::-webkit-scrollbar-track{background:transparent}.kapix-document-input::-webkit-scrollbar-thumb:vertical{min-height:50px}.kapix-document-input::-webkit-scrollbar-thumb:horizontal{min-width:50px}.kapix-document-input .kapix-field-input{height:auto}.kapix-document-container{width:100%;height:100%;min-width:0;min-height:0;flex-direction:column;display:flex;flex-wrap:wrap;justify-content:flex-start;align-items:flex-start;flex-direction:row;grid-gap:.5rem;gap:.5rem}.kapix-document-container .document-item{background-color:#f7f7f8;border-radius:8px;white-space:nowrap;overflow:hidden;display:flex;align-items:center;width:auto;max-width:100%;padding:3px}.kapix-document-container .file-icon{display:flex;align-items:center;justify-content:center;color:#aaadb0;background-color:#ebebec;border-radius:8px;margin-right:10px;font-size:16px;width:32px;height:32px;min-width:32px;min-height:32px}.kapix-document-container .file-icon .i-fa-regular-file{--un-icon: url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 384 512' width='1.2em' height='1.2em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='currentColor' d='M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48z'/%3E%3C/svg%3E");-webkit-mask:var(--un-icon) no-repeat;mask:var(--un-icon) no-repeat;-webkit-mask-size:100% 100%;mask-size:100% 100%;background-color:currentColor;color:inherit;font-size:16px;width:16px;height:16px;min-width:16px;min-height:16px}.kapix-upload-actions-container{width:100%;height:100%;min-width:0;min-height:0;opacity:0;background:rgba(128,128,128,.3);border:2px dashed white;border-radius:8px;display:flex;position:absolute;justify-content:center;align-items:center;transition:opacity .2s ease-in;top:0;left:0}.kapix-upload-actions-container *{pointer-events:auto}.kapix-upload-actions-container:hover,.kapix-upload-actions-container.dragging,.kapix-upload-actions-container.hover{opacity:1}.kapix-upload-actions-container-no-item{width:100%;height:100%;min-width:0;min-height:0;border-radius:8px;display:flex;position:absolute;justify-content:center;align-items:center;transition:opacity .2s ease-in;top:0;left:0}
`, ee = {
  key: 0,
  class: "document-item"
}, te = {
  key: 0,
  class: "document-item"
}, f = "i-fa-regular-file", pe = /* @__PURE__ */ $({
  __name: "KapixDocumentInput",
  props: q([Array, String]),
  emits: ["update:modelValue"],
  setup(D, { emit: N }) {
    G("KapixDocumentInput", _);
    const o = D, A = N, n = d({
      get() {
        return J(o);
      },
      set(e) {
        var t;
        A("update:modelValue", e), (t = o.onValueChanged) == null || t.call(o, e);
      }
    }), v = y(!1), g = y(!1), l = y(void 0), E = d(() => b(l.value) ? l.value : Q), m = d(() => b(l.value) ? void 0 : l.value), c = d(() => b(n.value) || !!o.options.multiple), S = d(() => o.options.showStringInput !== !1 && !c.value && (n.value == null || z(n.value)));
    let k = null;
    const j = d(() => c.value ? n && n.value && n.value.length > 0 : n.value != null);
    function B(e) {
      return c.value;
    }
    function O(e) {
      e && (B() ? (l.value = e.map((t) => t.preview ?? "empty"), k = e.map((t) => t.file), P(o.options.onFilesChange) && o.options.onFilesChange(e)) : (l.value = e.preview, k = e.file, P(o.options.onFilesChange) && o.options.onFilesChange(e)));
    }
    return typeof document < "u" && L(() => n.value, (e) => {
      Y(e, k) || (k = void 0, l.value = void 0, e instanceof File || M(e) && e.name ? l.value = e.name : z(e) ? l.value = e : b(e) && (l.value = e.map((t) => z(t) ? t : t instanceof File || M(t) && t.name ? t.name : null).filter((t) => t)));
    }, { immediate: !0 }), (e, t) => {
      const U = R("kapix-uploadcare");
      return e.editable ? (r(), s("div", {
        key: 0,
        class: p([e.templateClass, "kapix-document-input"])
      }, [
        i(S) ? (r(), H(W, K({
          key: 0,
          modelValue: i(n),
          "onUpdate:modelValue": t[0] || (t[0] = (a) => F(n) ? n.value = a : null)
        }, o, { "template-class": "" }), null, 16, ["modelValue"])) : C("", !0),
        u("div", {
          class: "kapix-document-container",
          onMouseenter: t[1] || (t[1] = (a) => v.value = !0),
          onMouseout: t[2] || (t[2] = (a) => v.value = !1),
          onDragenter: t[3] || (t[3] = (a) => g.value = !0),
          onMouseleave: t[4] || (t[4] = (a) => g.value = !1)
        }, [
          i(c) ? (r(!0), s(V, { key: 0 }, I(i(E), (a, w) => (r(), s("div", {
            key: w,
            class: "document-item"
          }, [
            u("div", { class: "file-icon" }, [
              u("div", {
                class: p(f)
              })
            ]),
            x(" " + h(a), 1)
          ]))), 128)) : (r(), s(V, { key: 1 }, [
            i(m) ? (r(), s("div", ee, [
              u("div", { class: "file-icon" }, [
                u("div", {
                  class: p(f)
                })
              ]),
              x(" " + h(i(m)), 1)
            ])) : C("", !0)
          ], 64))
        ], 32),
        u("div", {
          class: p([
            i(j) ? "kapix-upload-actions-container" : "kapix-upload-actions-container-no-item",
            i(g) ? "dragging" : void 0,
            i(v) ? "hover" : void 0
          ])
        }, [
          T(U, {
            modelValue: i(n),
            "onUpdate:modelValue": t[5] || (t[5] = (a) => F(n) ? n.value = a : null),
            options: e.options,
            "is-multiple-files": i(c),
            pubkey: e.options.pubkey || i(X).UPLOADCARE_PUBLIC_KEY,
            "return-type": e.options.returnType,
            "media-filter": i(Z).DOCUMENT,
            accept: e.options.accept,
            "on-change": O
          }, null, 8, ["modelValue", "options", "is-multiple-files", "pubkey", "return-type", "media-filter", "accept"])
        ], 2)
      ], 2)) : i(c) ? (r(), s("div", {
        key: 1,
        class: p(["kapix-document-container", e.templateClass])
      }, [
        (r(!0), s(V, null, I(i(E), (a, w) => (r(), s("div", {
          key: w,
          class: "document-item"
        }, [
          u("div", { class: "file-icon" }, [
            u("div", {
              class: p(f)
            })
          ]),
          x(" " + h(a), 1)
        ]))), 128))
      ], 2)) : (r(), s("div", {
        key: 2,
        class: p(["kapix-document-container", e.templateClass])
      }, [
        i(m) ? (r(), s("div", te, [
          u("div", { class: "file-icon" }, [
            u("div", {
              class: p(f)
            })
          ]),
          x(" " + h(i(m)), 1)
        ])) : C("", !0)
      ], 2));
    };
  }
});
export {
  pe as default
};
