import { defineComponent as D, onMounted as R, createElementBlock as S, openBlock as o, Fragment as I, createVNode as d, createBlock as i, unref as e, withCtx as p, createTextVNode as O, renderList as B, withDirectives as V, toDisplayString as g, ref as N, computed as _, createCommentVNode as C } from "vue";
import { y as x, z as M, p as v, B as w, l as H, D as $, _ as L, G as a, K, M as U, R as q, N as P, L as W, b as A, c as G, Z, I as z, v as F, w as Q } from "./index-CVEvAPNs.js";
import { u as j } from "./index-BFe8XjpO.js";
const J = /* @__PURE__ */ D({
  __name: "_itlab-search",
  props: {
    index: {},
    disabled: { type: Boolean }
  },
  emits: ["id", "label"],
  setup(f) {
    const r = x({ resource: f.index, limit: 10, allowEmptyQuery: !0 });
    return R(() => r.fetch()), (n, u) => (o(), S(I, null, [
      d(e(M), {
        modelValue: e(r).query,
        "onUpdate:modelValue": u[0] || (u[0] = (s) => e(r).query = s),
        placeholder: "Ein Element suchen"
      }, null, 8, ["modelValue"]),
      e(r).results.length > 0 ? (o(), i(e(v), {
        key: 0,
        primary: "Gefundene Elemente"
      })) : e(r).query.length === 0 ? (o(), i(e(v), {
        key: 1,
        primary: "Die Suche beginnt automatisch"
      })) : e(r).searching ? (o(), i(e(v), { key: 2 }, {
        description: p(() => [
          u[1] || (u[1] = O("Suche läuft")),
          d(e(w))
        ]),
        _: 1
      })) : (o(), i(e(v), {
        key: 3,
        primary: "Es wurde nichts gefunden"
      })),
      (o(!0), S(I, null, B(e(r).results, ({ label: s, id: m }) => (o(), i(e(H), {
        onClick: (b) => {
          n.$emit("id", m), n.$emit("label", s);
        }
      }, {
        default: p(() => [
          V((o(), S("em", null, [
            O(g(s), 1)
          ])), [
            [e($), 1]
          ])
        ]),
        _: 2
      }, 1032, ["onClick"]))), 256))
    ], 64));
  }
}), X = /* @__PURE__ */ L(J, [["__scopeId", "data-v-192f2c4f"]]), Y = /* @__PURE__ */ D({
  __name: "itlab",
  props: {
    content: {},
    disabled: { type: Boolean }
  },
  setup(f) {
    const E = [
      a.NEWSROOM_NEWS,
      a.EVENTS_EVENT,
      a.DEMO_HIVE_DEMO,
      a.TECH_RADAR_BLIP,
      a.PODCASTS_PODCAST,
      a.BOOKS_BOOK,
      a.HACKSCHOOL_COURSE,
      a.HACKSCHOOL_DOC,
      a.TEAM_MEMBER,
      a.NEWSLETTER_ISSUE
    ], r = E.map((t) => K(t, "app")), n = f, u = U();
    j(n.content, "itlab", { resource: "", resourceId: "" }), R(() => {
      const { itlab: t } = n.content;
      if (!t) return;
      const { resource: l, resourceId: c } = t;
      E.includes(l) && u.get(`https://services.svi-itlab.com/search/${l}/${c}`).then(({ data: h }) => {
        h.url !== "404" && (s.value = h.label);
      }).catch(() => {
      });
    });
    const s = N(), m = _(() => n.disabled || !n.content.itlab || !n.content.itlab.resource), b = _(() => {
      const t = n.content.itlab && n.content.itlab.resource, l = E.includes(t);
      return t && l ? t : void 0;
    }), T = _(() => b.value && s.value ? q[b.value] : P);
    function y(t) {
      n.content.itlab && (n.content.itlab.resourceId = t);
    }
    function k() {
      s.value = void 0, y("");
    }
    return (t, l) => t.content.itlab ? (o(), i(e(W), { key: 0 }, {
      default: p(() => [
        d(e(A), null, {
          default: p(() => [
            d(e(G), {
              modelValue: t.content.itlab.resource,
              "onUpdate:modelValue": [
                l[0] || (l[0] = (c) => t.content.itlab.resource = c),
                l[1] || (l[1] = (c) => k())
              ],
              placeholder: "Ressouce auswählen",
              icon: e(Z),
              disabled: t.disabled,
              selectable: e(r)
            }, null, 8, ["modelValue", "icon", "disabled", "selectable"])
          ]),
          _: 1
        }),
        V((o(), i(e(A), {
          cursor: "",
          disabled: m.value
        }, {
          default: p(() => [
            d(e(z), {
              "input-props": { readonly: "", style: m.value ? "" : "cursor:pointer" },
              icon: T.value,
              "model-value": s.value,
              placeholder: "Ein Element suchen",
              disabled: m.value
            }, null, 8, ["input-props", "icon", "model-value", "disabled"])
          ]),
          _: 1
        }, 8, ["disabled"])), [
          [e(F)]
        ]),
        d(e(Q), { arrow: "" }, {
          default: p(() => [
            b.value ? (o(), i(X, {
              key: 0,
              index: b.value,
              onId: y,
              onLabel: l[2] || (l[2] = (c) => s.value = c)
            }, null, 8, ["index"])) : C("", !0)
          ]),
          _: 1
        })
      ]),
      _: 1
    })) : C("", !0);
  }
}), le = /* @__PURE__ */ L(Y, [["__scopeId", "data-v-99bd0960"]]);
export {
  le as default
};
