import { defineComponent as O, useId as h, computed as p, useTemplateRef as w, createElementBlock as a, createCommentVNode as C, openBlock as i, createVNode as r, unref as t, withCtx as m, createElementVNode as I, Fragment as g, normalizeClass as E, renderList as N, createBlock as P, createTextVNode as _, toDisplayString as k } from "vue";
import { TabGroup as B, TabList as F, TabPanels as V, TabPanel as A } from "@headlessui/vue";
import { ScalarMarkdown as S, ScalarCodeBlock as D } from "@scalar/components";
import { DEFAULT_CLIENT as M } from "../../../v2/blocks/scalar-request-example-block/helpers/find-client.js";
import { emitCustomEvent as R } from "../../../v2/events/definitions.js";
import z from "./ClientSelector.vue.js";
import { getFeaturedClients as G, isFeaturedClient as K } from "./featured-clients.js";
const U = {
  key: 0,
  ref: "wrapper"
}, j = ["id"], q = {
  key: 1,
  class: "selected-client card-footer border-t-0 p-0",
  role: "tabpanel",
  tabindex: "1"
}, H = ["id"], ee = /* @__PURE__ */ O({
  __name: "ClientLibraries",
  props: {
    document: {},
    clientOptions: {},
    selectedClient: { default: () => M }
  },
  setup(o) {
    const v = h(), b = h(), x = p(
      () => o.clientOptions.flatMap(
        (e) => e.options.find((n) => n.id === o.selectedClient) ?? []
      )[0]
    ), d = p(() => G(o.clientOptions)), T = p(
      () => d.value.findIndex(
        (e) => o.selectedClient === e.id
      )
    ), y = w("wrapper"), L = (e) => {
      const n = d.value[e];
      !n || !y.value || R(y.value, "scalar-update-selected-client", n.id);
    }, l = p(() => {
      const e = o.document.info["x-scalar-sdk-installation"];
      if (!Array.isArray(e) || !(e != null && e.length))
        return;
      const n = e.find((u) => {
        var s, c;
        const f = (c = (s = o.selectedClient) == null ? void 0 : s.split("/")[0]) == null ? void 0 : c.toLowerCase();
        return u.lang.toLowerCase() === f;
      });
      if (n)
        return n;
    });
    return (e, n) => e.clientOptions.length ? (i(), a("div", U, [
      r(t(B), {
        manual: "",
        selectedIndex: T.value,
        onChange: L
      }, {
        default: m(() => [
          I("div", {
            id: t(v),
            class: "client-libraries-heading"
          }, " Client Libraries ", 8, j),
          r(t(F), {
            "aria-labelledby": t(v),
            class: "client-libraries-list"
          }, {
            default: m(() => [
              r(z, {
                clientOptions: e.clientOptions,
                featuredClients: d.value,
                selectedClient: e.selectedClient,
                morePanel: t(b)
              }, null, 8, ["clientOptions", "featuredClients", "selectedClient", "morePanel"])
            ]),
            _: 1
          }, 8, ["aria-labelledby"]),
          r(t(V), null, {
            default: m(() => {
              var u, f, s;
              return [
                (u = l.value) != null && u.source || (f = l.value) != null && f.description ? (i(), a(g, { key: 0 }, [
                  l.value.description ? (i(), a("div", {
                    key: 0,
                    class: E(["selected-client card-footer -outline-offset-2", l.value.source && "rounded-b-none"]),
                    role: "tabpanel",
                    tabindex: "0"
                  }, [
                    r(t(S), {
                      value: l.value.description
                    }, null, 8, ["value"])
                  ], 2)) : C("", !0),
                  l.value.source ? (i(), a("div", q, [
                    r(t(D), {
                      lang: "shell",
                      content: l.value.source,
                      copy: !0,
                      class: "rounded-t-none rounded-b-lg px-3 py-2 -outline-offset-1 has-focus:outline"
                    }, null, 8, ["content"])
                  ])) : C("", !0)
                ], 64)) : t(K)(e.selectedClient) ? (i(!0), a(g, { key: 1 }, N(d.value, (c) => (i(), P(t(A), {
                  key: c.id,
                  class: "selected-client card-footer -outline-offset-2"
                }, {
                  default: m(() => [
                    _(k(c.title), 1)
                  ]),
                  _: 2
                }, 1024))), 128)) : (i(), a("div", {
                  key: 2,
                  id: t(b),
                  class: "selected-client card-footer -outline-offset-2",
                  role: "tabpanel",
                  tabindex: "0"
                }, k((s = x.value) == null ? void 0 : s.title), 9, H))
              ];
            }),
            _: 1
          })
        ]),
        _: 1
      }, 8, ["selectedIndex"])
    ], 512)) : C("", !0);
  }
});
export {
  ee as default
};
