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