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