import { defineComponent as h, openBlock as u, createElementBlock as m, createBaseVNode as i, toDisplayString as F, unref as t, prettyBytes as w, Fragment as v, renderList as y, createBlock as B, reactive as S } from "./composables-Ci32s3jE.js";
import { FileCard as T } from "./components.js";
const b = { class: "flex flex-col gap-2" }, C = { class: "p-2 text-sm flex flex-wrap gap-2" }, D = /* @__PURE__ */ i("div", { class: "p-1" }, "Torrent: ", -1), j = { class: "p-1" }, z = { class: "p-1" }, N = /* @__PURE__ */ h({
  __name: "TorrentDownload",
  props: {
    id: {
      type: String,
      default: ""
    }
  },
  setup(g) {
    const A = g;
    function x(_) {
      const e = S({
        files: [],
        task: null,
        status: {
          done: !1,
          progress: 0,
          downloadSpeed: 0,
          downloaded: 0
        }
      });
      return import("./webtorrent.min-d4NLa47Z.js").then((n) => {
        const a = n.default, s = new a();
        e.task = s.add(_, (r) => {
          e.files = r.files;
        }), s.on("download", () => {
          const { progress: r, downloaded: d, done: c, downloadSpeed: l } = e.task;
          e.status = { done: c, progress: r, downloaded: d, downloadSpeed: l };
        });
      }), e;
    }
    const o = x(`magnet:?xt=urn:btih:${A.id}&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com`);
    return (_, e) => {
      var n, a, s, r, d, c, l, f, k;
      return u(), m("div", b, [
        i("div", C, [
          D,
          i("div", j, F((a = (n = t(o)) == null ? void 0 : n.status) != null && a.done ? (r = (s = t(o)) == null ? void 0 : s.status) == null ? void 0 : r.progress : "done"), 1),
          i("div", z, "Total " + F(t(w)((c = (d = t(o)) == null ? void 0 : d.status) == null ? void 0 : c.downloaded)) + " at " + F(t(w)((f = (l = t(o)) == null ? void 0 : l.status) == null ? void 0 : f.downloadSpeed)) + "/s", 1)
        ]),
        (u(!0), m(v, null, y((k = t(o)) == null ? void 0 : k.files, (p) => (u(), B(t(T), {
          key: p == null ? void 0 : p.name,
          file: p
        }, null, 8, ["file"]))), 128))
      ]);
    };
  }
});
export {
  N as default
};
//# sourceMappingURL=TorrentDownload-iKJQAEit.js.map
