import DesktopTab_default from "./DesktopTab.vue.js";
import { Fragment, computed, createBlock, createElementBlock, createElementVNode, createVNode, defineComponent, openBlock, renderList, unref } from "vue";
import { ScalarIcon } from "@scalar/components";
//#region src/v2/features/app/components/DesktopTabs.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1 = { class: "t-app__top-nav" };
var _hoisted_2 = { class: "mac:app-drag-region" };
var _hoisted_3 = { class: "z-1 flex h-10 items-center gap-2 px-2" };
var DesktopTabs_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
	__name: "DesktopTabs",
	props: {
		tabs: {},
		activeTabIndex: {},
		eventBus: {}
	},
	setup(__props) {
		/** Whether there is only a single tab open */
		const isSingleTab = computed(() => __props.tabs.length === 1);
		/** Adds a new tab */
		const handleAddTab = () => {
			__props.eventBus.emit("tabs:add:tab", void 0);
		};
		/** Switches to the tab at the specified index */
		const switchTab = (index) => {
			__props.eventBus.emit("tabs:focus:tab", { index });
		};
		/** Closes the tab at the specified index */
		const handleCloseTab = (index) => {
			__props.eventBus.emit("tabs:close:tab", { index });
		};
		/** Closes all tabs except the one at the specified index */
		const handleCloseOtherTabs = (index) => {
			__props.eventBus.emit("tabs:close:other-tabs", { index });
		};
		const handleCopyTabUrl = (index) => {
			__props.eventBus.emit("tabs:copy:url", { index });
		};
		return (_ctx, _cache) => {
			return openBlock(), createElementBlock("nav", _hoisted_1, [createElementVNode("div", _hoisted_2, [createElementVNode("div", _hoisted_3, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.tabs, (tab, index) => {
				return openBlock(), createBlock(DesktopTab_default, {
					key: index,
					active: index === __props.activeTabIndex,
					hotkey: !isSingleTab.value && index < 9 ? String(index + 1) : void 0,
					isSingleTab: isSingleTab.value,
					tab,
					onClick: ($event) => switchTab(index),
					onClose: ($event) => handleCloseTab(index),
					onCloseOtherTabs: ($event) => handleCloseOtherTabs(index),
					onCopyUrl: () => handleCopyTabUrl(index),
					onNewTab: handleAddTab
				}, null, 8, [
					"active",
					"hotkey",
					"isSingleTab",
					"tab",
					"onClick",
					"onClose",
					"onCloseOtherTabs",
					"onCopyUrl"
				]);
			}), 128)), createElementVNode("button", {
				class: "text-c-3 hover:bg-b-3 app-no-drag-region rounded p-1.5",
				type: "button",
				onClick: handleAddTab
			}, [createVNode(unref(ScalarIcon), {
				icon: "Add",
				size: "sm",
				thickness: "2.5"
			})])])])]);
		};
	}
});
//#endregion
export { DesktopTabs_vue_vue_type_script_setup_true_lang_default as default };

//# sourceMappingURL=DesktopTabs.vue.script.js.map