import { ref as v, computed as V, resolveComponent as k, openBlock as t, createElementBlock as l, createElementVNode as s, toDisplayString as _, unref as o, createCommentVNode as i, createBlock as y, createVNode as g, Transition as w, withCtx as x, renderSlot as C, TransitionGroup as q, Fragment as A, renderList as E, withDirectives as L, normalizeStyle as T, vShow as j } from "vue";
import { useUser as F, usePosts as G, countRating as b } from "./composables-5f691338.js";
const H = { class: "flex flex-col z-10 items-start justify-items-stretch" }, R = {
  key: 0,
  class: "flex flex-wrap items-center p-2 text-xl sticky z-100 top-0 shadow-lg bg-light-700 w-full"
}, I = /* @__PURE__ */ s("div", { class: "flex-1" }, null, -1), J = { class: "p-2 font-bold mx-2" }, K = { class: "flex flex-col items-center bg-dark-50 bg-opacity-20 backdrop-filter backdrop-blur-md flex-1 p-2 w-full gap-8" }, M = {
  key: 0,
  class: "p-2 flex flex-wrap z-300 text-sm bg-light-300 bg-opacity-40 dark-bg-dark-500 rounded-2xl m-2 flex-1",
  style: { order: "-2147483647", flex: "1000 100%" }
}, O = {
  key: 1,
  class: "flex flex-wrap gap-2"
}, Q = {
  key: 0,
  class: "i-la-plus"
}, W = {
  key: 1,
  class: "i-la-times"
}, X = /* @__PURE__ */ s("div", { class: "ml-2 mr-1" }, "Add", -1), Y = /* @__PURE__ */ s("label", {
  class: "button",
  title: "Upload feed",
  for: "import-feed"
}, [
  /* @__PURE__ */ s("div", { class: "i-la-file-upload" }),
  /* @__PURE__ */ s("div", { class: "ml-2 mr-1" }, "Upload")
], -1), Z = {
  key: 0,
  class: "i-la-eye"
}, ee = {
  key: 1,
  class: "i-la-eye-slash"
}, te = /* @__PURE__ */ s("div", { class: "ml-2" }, "Show hidden", -1), se = {
  key: 0,
  class: "i-la-file-download"
}, le = {
  key: 1,
  class: "i-la-redo-alt animate-spin"
}, oe = /* @__PURE__ */ s("div", { class: "ml-2 mr-1" }, "Download", -1), ne = {
  key: 1,
  class: "p-2 flex items-center gap-2",
  style: { order: "-2147483647", flex: "1000 100%" }
}, ue = {
  __name: "PostList",
  props: {
    tag: {
      type: String,
      default: ""
    },
    header: {
      type: Boolean,
      default: !0
    }
  },
  emits: ["close", "browse", "user"],
  setup(a, { emit: $ }) {
    const z = a, {
      user: c
    } = F(), {
      posts: m,
      backlinks: ae,
      countPosts: h,
      countBacklinks: ie,
      downloadPosts: P,
      downloading: S,
      uploadPosts: B
    } = G(z.tag), r = v();
    v(!1);
    const u = v(!1), D = V(() => {
      const d = {};
      for (let e in m) {
        const p = b(m[e]);
        (u.value || p > 0) && (d[e] = m[e]);
      }
      return d;
    });
    return (d, e) => {
      const p = k("qr-share"), N = k("post-form"), U = k("post-card");
      return t(), l("div", H, [
        a.header ? (t(), l("div", R, [
          s("div", {
            class: "text-xl ml-2 font-bold cursor-pointer",
            style: { flex: "1 100px" },
            onClick: e[0] || (e[0] = (n) => d.$emit("close"))
          }, "# " + _(a.tag), 1),
          I,
          s("div", J, _(o(h)), 1)
        ])) : i("", !0),
        s("div", K, [
          o(c).pub ? (t(), l("div", M, [
            a.header ? (t(), y(p, { key: 0 })) : i("", !0),
            o(c).pub ? (t(), l("div", O, [
              s("button", {
                class: "button",
                onClick: e[1] || (e[1] = (n) => r.value = !r.value)
              }, [
                g(w, {
                  name: "fade",
                  mode: "out-in"
                }, {
                  default: x(() => [
                    r.value ? (t(), l("div", W)) : (t(), l("div", Q))
                  ]),
                  _: 1
                }),
                X
              ]),
              Y,
              s("button", {
                class: "button",
                onClick: e[2] || (e[2] = (n) => u.value = !u.value)
              }, [
                u.value ? (t(), l("div", Z)) : (t(), l("div", ee)),
                te
              ]),
              0 < o(h) ? (t(), l("button", {
                key: 0,
                class: "button",
                title: "Download feed",
                onClick: e[3] || (e[3] = (n) => o(P)())
              }, [
                o(S) ? (t(), l("div", le)) : (t(), l("div", se)),
                oe
              ])) : i("", !0),
              C(d.$slots, "default")
            ])) : i("", !0),
            s("input", {
              class: "hidden",
              id: "import-feed",
              ref: "file",
              tabindex: "-1",
              type: "file",
              accept: ".zip",
              multiple: "",
              onChange: e[4] || (e[4] = (n) => o(B)(n.target.files))
            }, null, 544),
            g(w, { name: "fade" }, {
              default: x(() => [
                r.value ? (t(), y(N, {
                  key: 0,
                  tag: a.tag,
                  onClose: e[5] || (e[5] = (n) => r.value = !1)
                }, null, 8, ["tag"])) : i("", !0)
              ]),
              _: 1
            })
          ])) : i("", !0),
          o(c).pub ? i("", !0) : (t(), l("div", ne, [
            s("button", {
              class: "button",
              onClick: e[6] || (e[6] = (n) => o(c).auth = !0)
            }, "Authorize to post here"),
            C(d.$slots, "default")
          ])),
          g(q, { name: "list" }, {
            default: x(() => [
              (t(!0), l(A, null, E(o(D), (n, f) => L((t(), y(U, {
                class: "max-w-3xl w-full shadow-xl",
                key: f,
                style: T({ order: -o(b)(n), opacity: o(b)(n) > 0 ? 1 : 0.3 }),
                hash: f,
                tag: a.tag,
                authors: n,
                onClick: (de) => $("browse", f)
              }, null, 8, ["style", "hash", "tag", "authors", "onClick"])), [
                [j, a.tag != f]
              ])), 128))
            ]),
            _: 1
          })
        ])
      ]);
    };
  }
};
export {
  ue as default
};
//# sourceMappingURL=PostList-9807f8ad.js.map
