import { T as PathId, r as useWorkspace, w as useActiveEntities } from "./store-DpSUVhjp.js";
import { t as _plugin_vue_export_helper_default } from "./_plugin-vue_export-helper-BmmBcIzD.js";
import { t as IconSelector_default } from "./IconSelector-BDC_GQXv.js";
import { t as ViewLayout_default } from "./ViewLayout-BOXN0IYo.js";
import { t as ViewLayoutSection_default } from "./ViewLayoutSection-mUqKbQry.js";
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, guardReactiveProps, mergeProps, normalizeClass, normalizeProps, openBlock, ref, renderList, toDisplayString, unref, watch, withCtx } from "vue";
import { ScalarButton, useBindCx } from "@scalar/components";
import { RouterLink, RouterView, useRouter } from "vue-router";
import { LibraryIcon } from "@scalar/icons/library";
import { useScroll } from "@vueuse/core";
//#region src/components/Form/LabelInput.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$3 = ["for"];
var _hoisted_2$2 = [
	"id",
	"placeholder",
	"value"
];
//#endregion
//#region src/components/Form/LabelInput.vue
var LabelInput_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
	__name: "LabelInput",
	props: {
		inputId: {},
		placeholder: {},
		value: {},
		layout: {}
	},
	emits: ["updateValue"],
	setup(__props, { emit: __emit }) {
		const emit = __emit;
		const { cx } = useBindCx();
		const onInput = (event) => {
			const target = event.target;
			emit("updateValue", target.value);
		};
		return (_ctx, _cache) => {
			return openBlock(), createElementBlock("div", normalizeProps(guardReactiveProps(unref(cx)("flex-1 flex gap-1 items-center pointer-events-none group"))), [__props.layout !== "modal" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createElementVNode("label", mergeProps(unref(cx)("absolute w-full h-full top-0 left-0 pointer-events-auto opacity-0 cursor-text"), { for: __props.inputId }), null, 16, _hoisted_1$3), createElementVNode("input", mergeProps(unref(cx)("flex-1 text-c-1 rounded pointer-events-auto relative w-full pl-1.25 -ml-0.5 md:-ml-1.25 h-8 group-hover-input has-[:focus-visible]:outline z-10"), {
				id: __props.inputId,
				placeholder: __props.placeholder,
				value: __props.value,
				onInput
			}), null, 16, _hoisted_2$2)], 64)) : (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 1 }, unref(cx)("flex items-center text-c-1 h-8"))), toDisplayString(__props.value), 17))], 16);
		};
	}
}), [["__scopeId", "data-v-fced736a"]]);
//#endregion
//#region src/views/Collection/CollectionInfoForm.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$2 = ["aria-label"];
var _hoisted_2$1 = { class: "group relative ml-1.25" };
//#endregion
//#region src/views/Collection/CollectionInfoForm.vue
var CollectionInfoForm_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
	__name: "CollectionInfoForm",
	setup(__props) {
		const { activeCollection } = useActiveEntities();
		const { collectionMutators } = useWorkspace();
		const icon = computed(() => activeCollection?.value?.["x-scalar-icon"] || "interface-content-folder");
		const updateCollectionIcon = (value) => {
			if (!activeCollection?.value?.uid) return;
			collectionMutators.edit(activeCollection?.value?.uid, "x-scalar-icon", value);
		};
		/**
		* Update info.title
		*/
		const updateCollectionTitle = (value) => {
			if (!activeCollection.value) return;
			collectionMutators.edit(activeCollection.value.uid, "info.title", value);
		};
		/**
		* Alias for the data that we'd like to display.
		*/
		const data = computed(() => {
			return {
				icon: activeCollection?.value?.["x-scalar-icon"],
				title: activeCollection?.value?.info?.title,
				description: activeCollection?.value?.info?.description,
				version: activeCollection?.value?.info?.version
			};
		});
		return (_ctx, _cache) => {
			return openBlock(), createElementBlock("div", {
				"aria-label": `Collection: ${data.value.title}`,
				class: "mx-auto flex h-fit w-full flex-col gap-2 pt-6 pb-3 md:mx-auto md:max-w-[720px]"
			}, [createVNode(IconSelector_default, {
				modelValue: icon.value,
				placement: "bottom-start",
				"onUpdate:modelValue": _cache[0] || (_cache[0] = (value) => updateCollectionIcon(value))
			}, {
				default: withCtx(() => [createVNode(unref(ScalarButton), {
					class: "hover:bg-b-2 aspect-square h-7 w-7 cursor-pointer rounded border border-transparent p-0 hover:border-inherit",
					variant: "ghost"
				}, {
					default: withCtx(() => [createVNode(unref(LibraryIcon), {
						class: "text-c-2 size-5",
						src: icon.value,
						"stroke-width": "2"
					}, null, 8, ["src"])]),
					_: 1
				})]),
				_: 1
			}, 8, ["modelValue"]), createElementVNode("div", _hoisted_2$1, [createVNode(LabelInput_default, {
				class: "text-xl font-bold",
				inputId: "collectionName",
				placeholder: "Untitled Collection",
				value: data.value.title,
				onUpdateValue: updateCollectionTitle
			}, null, 8, ["value"])])], 8, _hoisted_1$2);
		};
	}
}), [["__scopeId", "data-v-68d5218e"]]);
//#endregion
//#region src/views/Collection/CollectionNavigation.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$1 = { class: "bg-b-1 sticky -top-[104px] z-10 mx-auto w-full" };
var _hoisted_2 = {
	key: 0,
	class: "flex max-w-40 items-center"
};
var _hoisted_3 = { class: "text-c-1 mr-[6.25px] hidden overflow-hidden px-2 font-medium text-ellipsis whitespace-nowrap md:block" };
//#endregion
//#region src/views/Collection/CollectionNavigation.vue
var CollectionNavigation_default = /* @__PURE__ */ defineComponent({
	__name: "CollectionNavigation",
	props: { isSticky: { type: Boolean } },
	setup(__props) {
		const { currentRoute } = useRouter();
		const { activeCollection } = useActiveEntities();
		const routes = computed(() => [
			{
				displayName: "Overview",
				to: {
					name: "collection.overview",
					params: { [PathId.Collection]: activeCollection.value?.uid }
				}
			},
			{
				displayName: "Servers",
				to: {
					name: "collection.servers",
					params: { [PathId.Collection]: activeCollection.value?.uid }
				}
			},
			{
				displayName: "Authentication",
				to: {
					name: "collection.authentication",
					params: { [PathId.Collection]: activeCollection.value?.uid }
				}
			},
			{
				displayName: "Environment",
				to: {
					name: "collection.environment",
					params: { [PathId.Collection]: activeCollection.value?.uid }
				}
			},
			{
				displayName: "Settings",
				to: { name: "collection.settings" }
			}
		]);
		return (_ctx, _cache) => {
			return openBlock(), createElementBlock("div", _hoisted_1$1, [createVNode(CollectionInfoForm_default), createElementVNode("div", { class: normalizeClass(["items-center text-sm font-medium", __props.isSticky ? "h-fit border-b md:grid md:grid-cols-[1fr_720px_1fr] md:px-4" : "flex md:mx-auto md:max-w-[720px]"]) }, [__props.isSticky ? (openBlock(), createElementBlock("div", _hoisted_2, [createVNode(unref(LibraryIcon), {
				class: "text-c-2 hidden size-3.5 md:block",
				src: unref(activeCollection)?.["x-scalar-icon"] || "interface-content-folder",
				"stroke-width": "2"
			}, null, 8, ["src"]), createElementVNode("span", _hoisted_3, toDisplayString(unref(activeCollection)?.info?.title), 1)])) : createCommentVNode("", true), createElementVNode("div", { class: normalizeClass(["flex w-full max-w-[720px] gap-2 pl-1.5 md:ml-1.5 md:pl-0", !__props.isSticky && "border-b"]) }, [(openBlock(true), createElementBlock(Fragment, null, renderList(routes.value, ({ to, displayName }, i) => {
				return openBlock(), createBlock(unref(RouterLink), {
					key: i,
					class: "-ml-2 flex h-10 cursor-pointer items-center px-2 text-center text-sm font-medium whitespace-nowrap no-underline -outline-offset-1 has-[:focus-visible]:outline",
					to
				}, {
					default: withCtx(() => [createElementVNode("span", { class: normalizeClass(["flex-center h-full w-full border-b", typeof to.name === "string" && typeof unref(currentRoute).name === "string" && unref(currentRoute).name?.startsWith(to.name) ? "text-c-1 border-c-1" : "text-c-2 hover:text-c-1 border-transparent"]) }, toDisplayString(displayName), 3)]),
					_: 2
				}, 1032, ["to"]);
			}), 128))], 2)], 2)]);
		};
	}
});
//#endregion
//#region src/views/Collection/Collection.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1 = { class: "w-full md:mx-auto md:max-w-[720px]" };
//#endregion
//#region src/views/Collection/Collection.vue
var Collection_default = /* @__PURE__ */ defineComponent({
	__name: "Collection",
	setup(__props) {
		const { activeCollection } = useActiveEntities();
		const router = useRouter();
		const el = ref(null);
		const { y } = useScroll(el);
		const isSticky = computed(() => y.value > 104);
		watch(activeCollection, (collection) => {
			if (collection?.info?.title === "Drafts") {
				const firstRequest = collection.requests[0];
				router.push({
					name: "request",
					params: { [PathId.Request]: firstRequest }
				});
			}
		}, { immediate: true });
		return (_ctx, _cache) => {
			return openBlock(), createBlock(ViewLayout_default, {
				ref_key: "el",
				ref: el,
				class: "h-fit overflow-auto pb-6 xl:overflow-auto"
			}, {
				default: withCtx(() => [createVNode(ViewLayoutSection_default, { class: "xl:h-fit" }, {
					default: withCtx(() => [createVNode(CollectionNavigation_default, { isSticky: isSticky.value }, null, 8, ["isSticky"]), createElementVNode("div", _hoisted_1, [createVNode(unref(RouterView))])]),
					_: 1
				})]),
				_: 1
			}, 512);
		};
	}
});
//#endregion
export { Collection_default as default };

//# sourceMappingURL=Collection-4MT9WmDD.js.map