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