import { inject as y, ref as i, resolveComponent as r, openBlock as j, createElementBlock as w, Fragment as x, renderSlot as F, createElementVNode as _, normalizeProps as M, guardReactiveProps as O, createVNode as l, withCtx as s, createTextVNode as m } from "vue";
import { _ as z } from "./DashboardPlugin-2e4f6b9c.js";
import { A as B } from "./index-bd6a25c1.js";
class h {
  constructor(e = {}) {
    this.id = e.id || "";
  }
  clone() {
    const e = new h();
    return e.id = this.id, e;
  }
}
class E {
  constructor(e) {
    this.id = e.image_id, this.name = e.image_id, this.size = (Math.random() * 10).toFixed(2) + "mb", this.path = e.share_link;
  }
}
class P {
  constructor(e = {}) {
    this.SparcImageArray = [], e.forEach((t) => this.SparcImageArray.push(new E(t))), this.MBFImageObject = [], e.forEach((t) => this.MBFImageObject.push(new h(t)));
  }
  buildTableMBF() {
    let e = [];
    return this.MBFImageObject.forEach((t) => {
      let c = {
        name: t.id,
        size: (Math.random() * 10).toFixed(2) + "mb",
        path: ""
      };
      e.push(c);
    }), e;
  }
  buildTableSPARC() {
    let e = [];
    return this.SparcImageArray.forEach((t) => {
      let c = {
        name: t.id,
        size: (Math.random() * 10).toFixed(2) + "mb",
        path: t.path
      };
      e.push(c);
    }), e;
  }
}
const k = { class: "fill" }, C = ["src"], N = { class: "tw-p-1" }, T = /* @__PURE__ */ Object.assign({
  inheritAttrs: !1
}, {
  __name: "ImageSelector",
  setup(g) {
    const e = y("emitter"), t = i(null), c = i(null);
    i("");
    const u = i(), b = i("MUSE Image Selector");
    function f(a) {
      let n = u.value[a].path;
      e.emit("ImageSelector-mbfImageSelected", n);
    }
    e.on("locationSelect-MBFImageArrayUpdate", (a) => {
      v();
    });
    const v = async (a) => {
      a = 353, u.value = [];
      let n = {}, o = {};
      try {
        await B.biolucida.searchDataset(a).then((d) => {
          o = d;
        }), o.status === 200 && (n = o, c.value = new P(n.data.dataset_images), u.value = c.value.buildTableSPARC());
      } catch {
        console.error("couldn't fetch images from dataset");
      }
    };
    return e.on("selectSubject", (a) => {
      t.value = a, imgPath2.value = "./imgs/imgSel.png", imgPath3.value = "./imgs/imgSel2.png";
    }), (a, n) => {
      const o = r("el-option"), d = r("el-select"), p = r("el-table-column"), S = r("el-button"), I = r("el-table");
      return j(), w(x, null, [
        F(a.$slots, "default", { widgetName: b.value }, void 0, !0),
        _("div", M(O(a.$attrs)), [
          _("div", k, [
            _("img", { src: t.value }, null, 8, C)
          ]),
          _("div", N, [
            l(d, { placeholder: "Select Subject" }, {
              default: s(() => [
                l(o, { value: 0 }, {
                  default: s(() => [
                    m("sub 1 ")
                  ]),
                  _: 1
                }),
                m(),
                l(o, { value: 1 }, {
                  default: s(() => [
                    m("sub 2")
                  ]),
                  _: 1
                }),
                l(o, { value: 2 }, {
                  default: s(() => [
                    m("sub 3")
                  ]),
                  _: 1
                })
              ]),
              _: 1
            })
          ]),
          l(I, {
            data: u.value,
            class: "table-of-images tw-text-sm"
          }, {
            default: s(() => [
              l(p, {
                prop: "name",
                label: "Name"
              }),
              l(p, {
                prop: "size",
                label: "Size"
              }),
              l(p, {
                fixed: "right",
                label: "Img"
              }, {
                default: s((A) => [
                  l(S, {
                    link: "",
                    type: "primary",
                    size: "small",
                    onClick: (D) => f(A.$index)
                  }, {
                    default: s(() => [
                      m("Open")
                    ]),
                    _: 2
                  }, 1032, ["onClick"])
                ]),
                _: 1
              })
            ]),
            _: 1
          }, 8, ["data"])
        ], 16)
      ], 64);
    };
  }
}), U = /* @__PURE__ */ z(T, [["__scopeId", "data-v-622f48dc"]]);
export {
  U as default
};
