import { defineComponent as O, computed as u, ref as P, createElementBlock as o, createCommentVNode as p, openBlock as s, Fragment as v, renderList as y, createBlock as f, createElementVNode as $, createVNode as A, unref as k, withCtx as j, createTextVNode as w, normalizeClass as F, toDisplayString as U } from "vue";
import { ScalarButton as R } from "@scalar/components";
import { ScalarIconPlus as z } from "@scalar/icons";
import E from "./SchemaEnumPropertyItem.vue.js";
const M = {
  key: 0,
  class: "property-enum"
}, W = {
  key: 0,
  class: "property-enum-values"
}, Y = {
  key: 1,
  class: "property-enum-values"
}, N = 9, q = 5, S = " ", X = /* @__PURE__ */ O({
  __name: "SchemaEnumValues",
  props: {
    value: {},
    isDiscriminator: { type: Boolean }
  },
  setup(l) {
    const I = (t) => {
      var n;
      return t ? t.enum || ((n = t.items) == null ? void 0 : n.enum) || [] : [];
    }, g = (t, n) => {
      var r, a, b, x;
      const e = ((a = (r = l.value) == null ? void 0 : r["x-enum-varnames"]) == null ? void 0 : a[n]) ?? ((x = (b = l.value) == null ? void 0 : b["x-enumNames"]) == null ? void 0 : x[n]);
      return e ? `${t}${S}=${S}${e}` : String(t);
    }, d = (t) => {
      var r, a;
      const n = (r = l.value) == null ? void 0 : r["x-enum-descriptions"];
      if (Array.isArray(n))
        return n[t];
      const e = (a = l.value) == null ? void 0 : a["x-enumDescriptions"];
      if (Array.isArray(e))
        return e[t];
    }, C = (t) => {
      var r, a;
      const n = (r = l.value) == null ? void 0 : r["x-enumDescriptions"];
      if (n && !Array.isArray(n))
        return n[t];
      const e = (a = l.value) == null ? void 0 : a["x-enum-descriptions"];
      if (e && !Array.isArray(e))
        return e[t];
    }, i = u(() => I(l.value)), L = u(() => i.value.length > 0), h = u(
      () => i.value.length > N
    ), m = u(
      () => h.value ? q : N
    ), V = u(
      () => i.value.slice(0, m.value)
    ), B = u(
      () => i.value.slice(m.value)
    ), D = u(() => {
      var n, e;
      const t = ((n = l.value) == null ? void 0 : n["x-enumDescriptions"]) ?? ((e = l.value) == null ? void 0 : e["x-enum-descriptions"]);
      return t && typeof t == "object" && !Array.isArray(t);
    }), T = u(() => L.value && !l.isDiscriminator), c = P(!1), H = () => {
      c.value = !c.value;
    };
    return (t, n) => T.value ? (s(), o("div", M, [
      D.value ? (s(), o("ul", W, [
        (s(!0), o(v, null, y(i.value, (e, r) => (s(), f(E, {
          key: e,
          label: e,
          description: D.value ? C(e) : d(r)
        }, null, 8, ["label", "description"]))), 128))
      ])) : (s(), o("ul", Y, [
        (s(!0), o(v, null, y(V.value, (e, r) => (s(), f(E, {
          key: e,
          label: g(e, r),
          description: d(r)
        }, null, 8, ["label", "description"]))), 128)),
        h.value ? (s(), o(v, { key: 0 }, [
          c.value ? (s(!0), o(v, { key: 0 }, y(B.value, (e, r) => (s(), f(E, {
            key: e,
            label: g(e, m.value + r),
            description: d(m.value + r)
          }, null, 8, ["label", "description"]))), 128)) : p("", !0),
          $("li", null, [
            A(k(R), {
              class: "enum-toggle-button my-2 flex h-fit gap-1 rounded-full border py-1.5 pr-2.5 pl-2 leading-none",
              variant: "ghost",
              onClick: H
            }, {
              default: j(() => [
                A(k(z), {
                  weight: "bold",
                  class: F({
                    "rotate-45": c.value
                  })
                }, null, 8, ["class"]),
                w(" " + U(c.value ? "Hide values" : "Show all values"), 1)
              ]),
              _: 1
            })
          ])
        ], 64)) : p("", !0)
      ]))
    ])) : p("", !0);
  }
});
export {
  X as default
};
