import { createElementBlock as s, openBlock as n, createElementVNode as i, createVNode as p, Transition as $, withCtx as k, createBlock as a, createCommentVNode as x, unref as e, withDirectives as D, isRef as g, vModelText as b, TransitionGroup as W, Fragment as c, renderList as h, normalizeStyle as V } from "vue";
import { useUser as B, useWords as E, dictRecord as u } from "./composables-BAZQlC3e.js";
import { DictDefCard as N, DictWordCard as v } from "./components.js";
const T = { class: "flex flex-col gap-2" }, L = { class: "flex gap-2" }, R = { class: "flex flex-wrap gap-2" }, G = {
  __name: "DictWordList",
  emits: ["word", "root", "def"],
  setup(U) {
    const { user: m } = B(), { input: l, found: C, linked: w, addWord: y } = E();
    return (d, t) => (n(), s("div", T, [
      i("div", {
        class: "font-bold text-xl mb-2 cursor-pointer",
        onClick: t[0] || (t[0] = (o) => d.$emit("root", "words"))
      }, "Words"),
      p($, {
        name: "fade",
        mode: "out-in"
      }, {
        default: k(() => [
          e(u).def ? (n(), a(e(N), {
            key: e(u).def,
            hash: e(u).def
          }, null, 8, ["hash"])) : x("", !0)
        ]),
        _: 1
      }),
      i("div", L, [
        D(i("input", {
          class: "p-2 rounded-lg flex-1 dark-bg-dark-400",
          "onUpdate:modelValue": t[1] || (t[1] = (o) => g(l) ? l.value = o : null),
          placeholder: "Enter a word"
        }, null, 512), [
          [b, e(l)]
        ]),
        i("button", {
          class: "button",
          onClick: t[2] || (t[2] = (o) => e(m).is ? e(y)() : e(m).auth = !0)
        }, "Add")
      ]),
      i("div", R, [
        p(W, { name: "list" }, {
          default: k(() => [
            e(l) ? (n(!0), s(c, { key: 1 }, h(e(C), (o) => (n(), a(e(v), {
              key: o.item.hash,
              style: V({ opacity: 1 - o.score }),
              hash: o.item.hash,
              onDef: t[4] || (t[4] = (r) => d.$emit("def", r)),
              onClick: (r) => d.$emit("word", o.item.hash)
            }, null, 8, ["style", "hash", "onClick"]))), 128)) : (n(!0), s(c, { key: 0 }, h(e(w), (o, r) => (n(), a(e(v), {
              key: r,
              hash: r,
              onDef: t[3] || (t[3] = (f) => d.$emit("def", f)),
              onClick: (f) => d.$emit("word", r)
            }, null, 8, ["hash", "onClick"]))), 128))
          ]),
          _: 1
        })
      ])
    ]));
  }
};
export {
  G as default
};
//# sourceMappingURL=DictWordList-D_9uozWN.js.map
