import { defineComponent as k, useId as C, createElementBlock as V, openBlock as a, Fragment as y, createElementVNode as u, createVNode as B, createBlock as m, createCommentVNode as b, normalizeClass as h, unref as t } from "vue";
import { ServerSelector as N, ServerVariablesForm as U } from "@scalar/api-client/components/Server";
import { useWorkspace as E } from "@scalar/api-client/store";
import { ScalarMarkdown as F } from "@scalar/components";
import { useConfig as M } from "../../hooks/useConfig.js";
const w = ["id"], A = /* @__PURE__ */ k({
  __name: "BaseUrl",
  props: {
    collection: {},
    server: {}
  },
  setup(l) {
    const { serverMutators: p } = E(), s = C(), f = M(), g = (e, o) => {
      if (!l.server)
        return;
      const r = l.server.variables || {};
      r[e] = { ...r[e], default: o }, p.edit(l.server.uid, "variables", r);
    }, S = (e) => {
      var o, r;
      (r = (o = f.value).onServerChange) == null || r.call(o, e);
    };
    return (e, o) => {
      var r, n, i, d, v, c;
      return a(), V(y, null, [
        o[0] || (o[0] = u("label", { class: "bg-b-2 flex h-8 items-center rounded-t-lg border border-b-0 px-3 py-2.5 font-medium" }, " Server ", -1)),
        u("div", {
          id: t(s),
          class: h(["border", {
            "rounded-b-lg": !((r = e.server) != null && r.description) && !((n = e.server) != null && n.variables)
          }])
        }, [
          (d = (i = e.collection) == null ? void 0 : i.servers) != null && d.length ? (a(), m(t(N), {
            key: 0,
            collection: e.collection,
            server: e.server,
            target: t(s),
            onUpdateServer: S
          }, null, 8, ["collection", "server", "target"])) : b("", !0)
        ], 10, w),
        B(t(U), {
          variables: (v = e.server) == null ? void 0 : v.variables,
          layout: "reference",
          "onUpdate:variable": g
        }, null, 8, ["variables"]),
        (c = e.server) != null && c.description ? (a(), m(t(F), {
          key: 0,
          class: "text-c-3 rounded-b-lg border border-t-0 px-3 py-1.5",
          value: e.server.description
        }, null, 8, ["value"])) : b("", !0)
      ], 64);
    };
  }
});
export {
  A as default
};
