import { defineComponent as O, computed as d, ref as C, watch as U, resolveComponent as $, openBlock as a, createElementBlock as l, normalizeClass as u, unref as i, createBlock as L, mergeProps as R, isRef as M, createCommentVNode as V, createElementVNode as s, Fragment as z, renderList as D, createTextVNode as x, toDisplayString as b, createVNode as H } from "vue";
import { isArray as h, isString as E, isEqual as K, isPlainObject as N } from "lodash-es";
import { a6 as T, a7 as Y, a9 as q, ad as G, P as J, ak as Q } from "./index-9ceb1eb9.js";
import { m as W } from "./mediaFilter-3fdbc89b.js";
import "axios";
import "@vueuse/core";
import "vue-i18n";
const X = `.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;align-items:center;justify-content:center}.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%;height:52px;padding:10px 20px 10px 10px;margin-bottom:10px}.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}
`, Z = {
  key: 0,
  class: "document-item"
}, _ = {
  key: 0,
  class: "document-item"
}, f = "i-fa-regular-file", se = /* @__PURE__ */ O({
  __name: "KapixDocumentInput",
  props: T([Array, String]),
  emits: ["update:modelValue"],
  setup(P, { emit: A }) {
    Y("KapixDocumentInput", X);
    const p = P, S = A, n = d({
      get() {
        return q(p);
      },
      set(e) {
        var t;
        S("update:modelValue", e), (t = p.onValueChanged) == null || t.call(p, e);
      }
    }), v = C(!1), g = C(!1), r = C(void 0), I = d(() => h(r.value) ? r.value : G), m = d(() => h(r.value) ? void 0 : r.value), c = d(() => h(n.value) || !!p.options.multiple), j = d(() => p.options.showStringInput !== !1 && !c.value && (n.value == null || E(n.value)));
    let k = null;
    const B = d(() => c.value ? n && n.value && n.value.length > 0 : n.value != null);
    function F(e) {
      if (e)
        if (c.value) {
          const { files: t, previews: w } = e;
          r.value = w, k = t;
        } else
          r.value = e.preview, k = e.file;
    }
    return typeof document < "u" && U(() => n.value, (e) => {
      K(e, k) || (k = void 0, r.value = void 0, e instanceof File || N(e) && e.name ? r.value = e.name : E(e) ? r.value = e : h(e) && (r.value = e.map((t) => E(t) ? t : t instanceof File || N(t) && t.name ? t.name : null).filter((t) => t)));
    }, { immediate: !0 }), (e, t) => {
      const w = $("kapix-uploadcare");
      return e.editable ? (a(), l("div", {
        key: 0,
        class: u([e.templateClass, "kapix-document-input"])
      }, [
        i(j) ? (a(), L(J, R({
          key: 0,
          modelValue: i(n),
          "onUpdate:modelValue": t[0] || (t[0] = (o) => M(n) ? n.value = o : null)
        }, p, { "template-class": "" }), null, 16, ["modelValue"])) : V("", !0),
        s("div", {
          class: "kapix-document-container",
          onMouseenter: t[1] || (t[1] = (o) => v.value = !0),
          onMouseout: t[2] || (t[2] = (o) => v.value = !1),
          onDragenter: t[3] || (t[3] = (o) => g.value = !0),
          onMouseleave: t[4] || (t[4] = (o) => g.value = !1)
        }, [
          i(c) ? (a(!0), l(z, { key: 0 }, D(i(I), (o, y) => (a(), l("div", {
            key: y,
            class: "document-item"
          }, [
            s("div", { class: "file-icon" }, [
              s("div", {
                class: u(f)
              })
            ]),
            x(" " + b(o), 1)
          ]))), 128)) : (a(), l(z, { key: 1 }, [
            i(m) ? (a(), l("div", Z, [
              s("div", { class: "file-icon" }, [
                s("div", {
                  class: u(f)
                })
              ]),
              x(" " + b(i(m)), 1)
            ])) : V("", !0)
          ], 64))
        ], 32),
        s("div", {
          class: u([
            i(B) ? "kapix-upload-actions-container" : "kapix-upload-actions-container-no-item",
            i(g),
            i(v)
          ])
        }, [
          H(w, {
            modelValue: i(n),
            "onUpdate:modelValue": t[5] || (t[5] = (o) => M(n) ? n.value = o : null),
            options: e.options,
            "is-multiple-files": i(c),
            pubkey: e.options.pubkey || i(Q).UPLOADCARE_PUBLIC_KEY,
            "return-type": e.options.returnType,
            "media-filter": i(W).DOCUMENT,
            accept: e.options.accept,
            "on-change": F
          }, null, 8, ["modelValue", "options", "is-multiple-files", "pubkey", "return-type", "media-filter", "accept"])
        ], 2)
      ], 2)) : i(c) ? (a(), l("div", {
        key: 1,
        class: u(["kapix-document-container", e.templateClass])
      }, [
        (a(!0), l(z, null, D(i(I), (o, y) => (a(), l("div", {
          key: y,
          class: "document-item"
        }, [
          s("div", { class: "file-icon" }, [
            s("div", {
              class: u(f)
            })
          ]),
          x(" " + b(o), 1)
        ]))), 128))
      ], 2)) : (a(), l("div", {
        key: 2,
        class: u(["kapix-document-container", e.templateClass])
      }, [
        i(m) ? (a(), l("div", _, [
          s("div", { class: "file-icon" }, [
            s("div", {
              class: u(f)
            })
          ]),
          x(" " + b(i(m)), 1)
        ])) : V("", !0)
      ], 2));
    };
  }
});
export {
  se as default
};
