import { defineComponent as B, ref as S, computed as b, useTemplateRef as F, createBlock as n, openBlock as u, unref as t, withModifiers as p, normalizeClass as O, createSlots as R, withCtx as i, createElementVNode as w, createCommentVNode as v, createVNode as d, mergeProps as y, createTextVNode as f, toDisplayString as x } from "vue";
import I from "./pl-file-dialog.module.scss.js";
import { notEmpty as N } from "@milaboratories/helpers";
import T from "../PlDialogModal/PlDialogModal.vue.js";
import M from "../PlBtnPrimary/PlBtnPrimary.vue.js";
import D from "../PlBtnGhost/PlBtnGhost.vue.js";
import E from "../PlBtnGroup/PlBtnGroup.vue.js";
import P from "./Remote.vue.js";
import U from "./Local.vue.js";
const j = { style: { margin: "0 24px" } }, Q = /* @__PURE__ */ B({
  __name: "PlFileDialog",
  props: {
    modelValue: { type: Boolean },
    extensions: { default: void 0 },
    multi: { type: Boolean },
    title: { default: void 0 },
    autoSelectStorage: { type: Boolean, default: !0 },
    closeOnOutsideClick: { type: Boolean, default: !0 }
  },
  emits: ["update:modelValue", "import:files"],
  setup(k, { emit: V }) {
    const a = V, C = k, l = S("local"), _ = b(() => C.multi ? "Select Files to Import" : "Select File to Import"), g = [
      {
        label: "My Computer",
        value: "local"
      },
      {
        label: "Remote",
        value: "remote"
      }
    ], m = () => a("update:modelValue", !1), r = F("remote"), c = () => {
      var o, e;
      (o = r.value) != null && o.isReady && (a("import:files", N((e = r.value) == null ? void 0 : e.getFilesToImport())), m());
    }, $ = (o) => {
      a("import:files", o), m();
    };
    return (o, e) => (u(), n(t(T), {
      "no-content-gutters": !0,
      "close-on-outside-click": o.closeOnOutsideClick,
      class: O(["pl-dialog-modal", t(I).component]),
      "model-value": o.modelValue,
      width: "688px",
      height: "720px",
      "onUpdate:modelValue": m,
      onClick: e[1] || (e[1] = p(() => {
      }, ["stop"]))
    }, R({
      title: i(() => [
        f(x(o.title ?? _.value), 1)
      ]),
      default: i(() => [
        w("div", j, [
          d(t(E), {
            modelValue: l.value,
            "onUpdate:modelValue": e[0] || (e[0] = (s) => l.value = s),
            options: g
          }, null, 8, ["modelValue"])
        ]),
        l.value === "remote" ? (u(), n(P, y({
          key: 0,
          ref: "remote"
        }, o.$props, { submit: c }), null, 16)) : v("", !0),
        l.value === "local" ? (u(), n(U, y({
          key: 1,
          "import-files": $
        }, o.$props), null, 16)) : v("", !0)
      ]),
      _: 2
    }, [
      l.value === "remote" ? {
        name: "actions",
        fn: i(() => {
          var s;
          return [
            d(t(M), {
              style: { "min-width": "160px" },
              disabled: !((s = t(r)) != null && s.isReady),
              onClick: p(c, ["stop"])
            }, {
              default: i(() => e[2] || (e[2] = [
                f("Import")
              ])),
              _: 1
            }, 8, ["disabled"]),
            d(t(D), {
              "justify-center": !1,
              onClick: p(m, ["stop"])
            }, {
              default: i(() => e[3] || (e[3] = [
                f("Cancel")
              ])),
              _: 1
            })
          ];
        }),
        key: "0"
      } : void 0
    ]), 1032, ["close-on-outside-click", "class", "model-value"]));
  }
});
export {
  Q as default
};
//# sourceMappingURL=PlFileDialog.vue.js.map
