import { t as _plugin_vue_export_helper_default } from "./_plugin-vue_export-helper-BmmBcIzD.js";
import { n as CommandActionForm_default, t as CommandActionInput_default } from "./CommandActionInput-TkcAx6E8.js";
import { t as mergeSecurity } from "./scalar-auth-selector-block-DI3DLag9.js";
import { t as ScalarAsciiArt_default } from "./ScalarAsciiArt-BjuSnj8e.js";
import { n as Sidebar_default, t as SidebarToggle_default } from "./sidebar-ceSbYmnt.js";
import { t as getActiveEnvironment } from "./get-active-environment-CkxyQ1dM.js";
import { n as slugify, t as TheCommandPalette_default } from "./TheCommandPalette-Dl9TAeke.js";
import { n as initializeWorkspaceEventHandlers, t as useGlobalHotKeys } from "./use-global-hot-keys-D8Ai8Qbm.js";
import { o as useMonacoEditorConfiguration } from "./editor-BZ_J0eze.js";
import { n as rabbit_default, t as rabbitjump_default } from "./rabbitjump-CMZXAR6d.js";
import { t as DeleteSidebarListElement_default } from "./DeleteSidebarListElement-C-p87d03.js";
import { Fragment, capitalize, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, guardReactiveProps, mergeModels, nextTick, normalizeClass, normalizeProps, onBeforeUnmount, onMounted, onUnmounted, openBlock, readonly, ref, renderList, renderSlot, resolveDynamicComponent, shallowRef, toDisplayString, toValue, unref, useModel, watch, withCtx, withKeys, withModifiers } from "vue";
import { ScalarButton, ScalarContextMenu, ScalarDropdown, ScalarDropdownButton, ScalarDropdownDivider, ScalarDropdownItem, ScalarDropdownMenu, ScalarFloating, ScalarHotkey, ScalarIcon, ScalarIconButton, ScalarModal, ScalarSidebarItem, ScalarTeleportRoot, ScalarTooltip, useModal } from "@scalar/components";
import { defaultFonts, themePresets } from "@scalar/themes";
import { ScalarToasts } from "@scalar/use-toasts";
import { NavigationFailureType, RouterView } from "vue-router";
import { LibraryIcon } from "@scalar/icons/library";
import { safeLocalStorage } from "@scalar/helpers/object/local-storage";
import { migrateLocalStorageToIndexDb } from "@scalar/oas-utils/migrations";
import { isMacOS } from "@scalar/helpers/general/is-mac-os";
import { isDefined } from "@scalar/helpers/array/is-defined";
import { createWorkspaceEventBus } from "@scalar/workspace-store/events";
import { ScalarIconArrowUpRight, ScalarIconDotsThree, ScalarIconDownloadSimple, ScalarIconFolderSimple, ScalarIconGearSix, ScalarIconLinkSimple, ScalarIconPencil, ScalarIconPlus, ScalarIconPlusSquare, ScalarIconTabs, ScalarIconX, ScalarIconXSquare } from "@scalar/icons";
import { dereference, escapeJsonPointer } from "@scalar/openapi-parser";
import { unpackProxyObject } from "@scalar/workspace-store/helpers/unpack-proxy";
import { createSidebarState, generateReverseIndex } from "@scalar/sidebar";
import { sortByOrder } from "@scalar/helpers/array/sort-by-order";
import { createWorkspaceStore } from "@scalar/workspace-store/client";
import { generateUniqueValue } from "@scalar/workspace-store/helpers/generate-unique-value";
import { getOpenapiObject, getParentEntry } from "@scalar/workspace-store/navigation";
import { createWorkspaceStorePersistence, getWorkspaceId } from "@scalar/workspace-store/persistence";
import { persistencePlugin } from "@scalar/workspace-store/plugins/client";
import { extensions } from "@scalar/workspace-store/schemas/extensions";
import { isHttpMethod } from "@scalar/helpers/http/is-http-method";
import { toJsonCompatible } from "@scalar/helpers/object/to-json-compatible";
//#region src/v2/features/app/helpers/get-route-param.ts
function getRouteParam(paramName, route) {
	const param = route?.params[paramName];
	if (typeof param !== "string") return;
	if (paramName === "method") return param && isHttpMethod(param) ? param : void 0;
	return decodeURIComponent(param);
}
//#endregion
//#region src/v2/features/app/helpers/group-workspaces.ts
/**
* Groups workspaces into team and local categories.
* Team workspaces are listed first (if not viewing local workspaces),
* followed by local workspaces.
*
* @param workspaces - Array of workspaces to group
* @param currentTeamUid - Current team identifier ('local' for local team)
* @returns Array of workspace groups with labels and options
*/
function groupWorkspacesByTeam(workspaces, currentTeamUid) {
	const workspacesByTeam = workspaces.reduce((acc, workspace) => {
		const teamUid = workspace.teamUid;
		if (!acc[teamUid]) acc[teamUid] = [];
		acc[teamUid].push({
			id: workspace.id,
			label: workspace.label
		});
		return acc;
	}, {});
	const result = [];
	if (currentTeamUid !== "local") {
		const teamWorkspaces = workspacesByTeam[currentTeamUid] ?? [];
		if (teamWorkspaces.length > 0) result.push({
			label: "Team Workspaces",
			options: teamWorkspaces
		});
	}
	result.push({
		label: "Local Workspaces",
		options: workspacesByTeam["local"] ?? []
	});
	return result;
}
//#endregion
//#region src/v2/features/app/hooks/use-theme.ts
var themePresentsMap = new Map(themePresets.map((theme) => [theme.slug, theme]));
/**
* Wraps theme CSS styles in a style tag for injection into the DOM.
*/
var wrapThemeInStyleTag = (themeStyles, dataTestId = "scalar-theme") => {
	return `<style id="scalar-theme" data-testid="${dataTestId}">${themeStyles}</style>`;
};
/**
* Resolves theme styles by slug from built-in presets or custom themes.
* Returns undefined if the theme is not found.
*/
var resolveThemeStyles = (themeSlug, customThemes) => {
	const addFonts = (themeStyles) => {
		return `${themeStyles}\n${defaultFonts}`;
	};
	if (themePresentsMap.has(themeSlug)) return addFonts(themePresentsMap.get(themeSlug)?.theme ?? "");
	const customTheme = customThemes.find((theme) => theme.slug === themeSlug);
	if (customTheme) return addFonts(customTheme.theme);
};
/**
* useTheme
*
* Reactive Vue.js hook to resolve and generate a <style> tag string based on the current theme.
* Automatically selects the appropriate theme styles in the following priority order:
*    1. Workspace theme (from the provided store, e.g. store.workspace['x-scalar-theme'])
*    2. Fallback theme (from the fallbackThemeSlug prop)
*    3. Default built-in theme (with slug "default")
*
* The returned `themeStyleTag` can be injected into your page to dynamically apply theming.
*
* @example
* ```ts
* // In a Vue component setup() function
* import { ref } from 'vue'
* import { useTheme } from './use-theme'
*
* const myThemes = ref([...])
* const workspaceStore = ref(...)
* const fallbackThemeSlug = ref('dark')
*
* const { themeStyleTag } = useTheme({
*   customThemes: myThemes,
*   fallbackThemeSlug,
*   store: workspaceStore
* })
*
* // To inject in template:
* // <div v-html="themeStyleTag"></div>
* ```
*/
var useTheme = ({ fallbackThemeSlug, store, customThemes }) => {
	const themeStyles = computed(() => {
		const defaultThemeStyles = {
			themeStyles: resolveThemeStyles("default", []),
			themeSlug: "default"
		};
		const storeValue = toValue(store);
		const fallbackThemeSlugValue = toValue(fallbackThemeSlug);
		if (storeValue === null) return defaultThemeStyles;
		const workspaceTheme = storeValue.workspace["x-scalar-theme"];
		const themeSlug = workspaceTheme === "none" ? fallbackThemeSlugValue : workspaceTheme;
		if (!themeSlug) {
			const fallbackStyles = resolveThemeStyles(fallbackThemeSlugValue, toValue(customThemes));
			return fallbackStyles ? {
				themeStyles: fallbackStyles,
				themeSlug: fallbackThemeSlugValue
			} : defaultThemeStyles;
		}
		const themeStyles = resolveThemeStyles(themeSlug, toValue(customThemes));
		if (themeStyles) return {
			themeStyles,
			themeSlug
		};
		const fallbackStyles = resolveThemeStyles(fallbackThemeSlugValue, toValue(customThemes));
		if (fallbackStyles) return {
			themeStyles: fallbackStyles,
			themeSlug: fallbackThemeSlugValue
		};
		return defaultThemeStyles;
	});
	return {
		themeStyles,
		themeStyleTag: computed(() => {
			return wrapThemeInStyleTag(themeStyles.value.themeStyles, themeStyles.value.themeSlug);
		})
	};
};
//#endregion
//#region src/v2/helpers/get-tab-details.ts
/**
* Returns display details for a tab in the API client UI.
* Determines the title and icon to use based on workspace, document, path, and method.
*
* - If no workspace is provided, returns { title: 'Untitled Tab' }.
* - If document is present, attempts to fetch an entry using getEntryByLocation, and returns:
*    - { title: entry.title, icon: 'document' } for document entry types,
*    - { title: entry.title, icon: 'request' } for all other types,
*    - If no entry found, returns { title: 'Untitled Tab' }.
* - If neither document nor entry is available, returns { title: 'Workspace' }.
*
* Example:
* ```
* const result = getTabDetails({
*   workspace: "main",
*   document: "doc1",
*   path: "/users",
*   method: "get",
*   getEntryByLocation: ({ document, path, method }) => {
*     // Mock lookup:
*     if (document === "doc1" && path === "/users") {
*       return { type: "document", title: "Users" }
*     }
*     return null
*   }
* })
* // result: { title: "Users", icon: "document" }
* ```
*/
var getTabDetails = ({ workspace, document, path, method, getEntryByLocation }) => {
	if (!workspace) return { title: "Untitled Tab" };
	if (document) {
		const entry = getEntryByLocation({
			document,
			path,
			method
		});
		if (!entry) return { title: "Untitled Tab" };
		if (entry.type === "document") return {
			title: entry.title,
			icon: "document"
		};
		return {
			title: entry.title,
			icon: "request"
		};
	}
	return { title: "Workspace" };
};
//#endregion
//#region src/v2/helpers/storage.ts
var CURRENT_PATH_KEY = "scalar.currentPath";
/**
* Handles persistence of the active workspace ID in localStorage.
*
* Usage example:
* ```ts
* // Set the active workspace id
* workspaceStorage.setActiveWorkspaceId('workspace-1');
*
* // Get the currently active workspace id
* const id = workspaceStorage.getActiveWorkspaceId();
* ```
*/
var workspaceStorage = {
	setCurrentPath: (path) => {
		if (path === "/") return;
		safeLocalStorage().setItem(CURRENT_PATH_KEY, path);
	},
	getLastPath: () => {
		return safeLocalStorage().getItem(CURRENT_PATH_KEY);
	}
};
//#endregion
//#region src/v2/features/app/app-events.ts
function initializeAppEventHandlers({ eventBus, store, router, rebuildSidebar, navigateToCurrentTab, onSelectSidebarItem, onAfterExampleCreation, onCopyTabUrl, onToggleSidebar, closeSidebar, renameWorkspace }) {
	const currentRoute = computed(() => router.currentRoute?.value);
	/**
	* Checks if the current route params match the specified operation meta.
	* Useful for determining if the sidebar or UI needs to be updated after changes to operations/examples.
	*
	* NOTE: It may be beneficial to compare to the active state instead of the router
	*/
	const isRouteParamsMatch = ({ documentName, path, method, exampleName }) => {
		if (documentName !== void 0 && documentName !== currentRoute.value?.params.documentSlug) return false;
		if (path !== void 0 && encodeURIComponent(path) !== currentRoute.value?.params.pathEncoded) return false;
		if (method !== void 0 && method !== currentRoute.value?.params.method) return false;
		if (exampleName !== void 0 && exampleName !== currentRoute.value?.params.exampleName) return false;
		return true;
	};
	initializeWorkspaceEventHandlers({
		eventBus,
		store,
		hooks: {
			"document:delete:document": { onAfterExecute: async (payload) => {
				if (currentRoute?.value?.params.documentSlug === payload.name) await router.push({ name: "workspace.environment" });
			} },
			"operation:update:pathMethod": { onBeforeExecute: (payload) => ({
				...payload,
				callback: async (status) => {
					if (status === "success") {
						rebuildSidebar(store.value?.workspace.activeDocument?.["x-scalar-navigation"]?.name);
						await router.replace({
							name: "example",
							params: {
								method: payload.payload.method,
								pathEncoded: encodeURIComponent(payload.payload.path),
								exampleName: currentRoute.value?.params.exampleName
							}
						});
					}
					payload.callback(status);
				}
			}) },
			"operation:upsert:parameter": { onAfterExecute: (payload) => onAfterExampleCreation(payload.meta) },
			"operation:update:extra-parameters": { onAfterExecute: (payload) => onAfterExampleCreation(payload.meta) },
			"operation:reload:history": { onAfterExecute: (payload) => onAfterExampleCreation({
				...payload.meta,
				exampleKey: "draft"
			}) },
			"operation:delete:operation": { onAfterExecute: async (payload) => {
				rebuildSidebar(payload.documentName);
				const { documentName, meta: { path, method } } = payload;
				if (isRouteParamsMatch({
					documentName,
					path,
					method
				})) await router.replace({
					name: "document.overview",
					params: { documentSlug: documentName }
				});
			} },
			"operation:create:draft-example": { onAfterExecute: async (payload) => {
				onAfterExampleCreation({
					...payload.meta,
					exampleKey: payload.exampleName
				});
				await router.push({
					name: "example",
					params: {
						documentSlug: payload.documentName,
						pathEncoded: encodeURIComponent(payload.meta.path),
						method: payload.meta.method,
						exampleName: payload.exampleName
					}
				});
			} },
			"operation:delete:example": { onAfterExecute: async (payload) => {
				rebuildSidebar(payload.documentName);
				const { documentName, meta: { path, method, exampleKey } } = payload;
				if (isRouteParamsMatch({
					documentName,
					path,
					method,
					exampleName: exampleKey
				})) await router.replace({
					name: "example",
					params: {
						pathEncoded: encodeURIComponent(path),
						method,
						documentSlug: documentName,
						exampleName: "default"
					}
				});
			} },
			"operation:rename:example": { onAfterExecute: async ({ meta, payload, documentName }) => {
				onAfterExampleCreation({
					...meta,
					exampleKey: payload.name,
					documentName
				});
				if (isRouteParamsMatch({
					documentName,
					path: meta.path,
					method: meta.method,
					exampleName: meta.exampleKey
				})) await router.replace({
					name: "example",
					params: {
						documentSlug: documentName,
						pathEncoded: encodeURIComponent(meta.path),
						method: meta.method,
						exampleName: payload.name
					}
				});
			} },
			"operation:update:requestBody:value": { onAfterExecute: (payload) => onAfterExampleCreation(payload.meta) },
			"operation:update:requestBody:formValue": { onAfterExecute: (payload) => onAfterExampleCreation(payload.meta) },
			"tag:create:tag": { onAfterExecute: (payload) => rebuildSidebar(payload.documentName) },
			"tag:edit:tag": { onAfterExecute: async (payload) => {
				rebuildSidebar(payload.documentName);
				if (payload.tag.children?.some((child) => child.type === "operation" && isRouteParamsMatch({
					documentName: payload.documentName,
					path: child.path,
					method: child.method
				}))) await router.replace({ ...currentRoute.value });
			} },
			"tag:delete:tag": { onAfterExecute: (payload) => rebuildSidebar(payload.documentName) },
			"tabs:add:tab": { onAfterExecute: navigateToCurrentTab },
			"tabs:close:tab": { onAfterExecute: navigateToCurrentTab },
			"tabs:focus:tab": { onAfterExecute: navigateToCurrentTab },
			"tabs:focus:tab-last": { onAfterExecute: navigateToCurrentTab },
			"tabs:navigate:previous": { onAfterExecute: navigateToCurrentTab },
			"tabs:navigate:next": { onAfterExecute: navigateToCurrentTab },
			"tabs:update:tabs": { onAfterExecute: navigateToCurrentTab }
		}
	});
	eventBus.on("workspace:update:name", (payload) => renameWorkspace(payload));
	eventBus.on("scroll-to:nav-item", ({ id }) => onSelectSidebarItem(id));
	eventBus.on("ui:toggle:sidebar", onToggleSidebar);
	/**
	* Bind the inernal navigation to a public api
	*/
	eventBus.on("ui:navigate", async (payload) => {
		const { replace = false } = payload;
		const fn = replace ? router.replace : router.push;
		const execCallback = (result) => {
			if (!result) {
				closeSidebar();
				return payload.callback?.("success");
			}
			const navigationFailure = NavigationFailureType.duplicated;
			if (result.type !== navigationFailure) return payload.callback?.("error");
			return payload.callback?.("success");
		};
		if (payload.page === "document") {
			const params = {
				documentSlug: payload.documentSlug,
				workspaceSlug: payload.workspaceSlug,
				namespace: payload.namespace
			};
			if (payload.path === "overview") return execCallback(await fn({
				name: "document.overview",
				params
			}));
			if (payload.path === "servers") return execCallback(await fn({
				name: "document.servers",
				params
			}));
			if (payload.path === "environment") return execCallback(await fn({
				name: "document.environment",
				params
			}));
			if (payload.path === "authentication") return execCallback(await fn({
				name: "document.authentication",
				params
			}));
			if (payload.path === "cookies") return execCallback(await fn({
				name: "document.cookies",
				params
			}));
			if (payload.path === "settings") return execCallback(await fn({
				name: "document.settings",
				params
			}));
		}
		if (payload.page === "workspace") {
			const params = {
				workspaceSlug: payload.workspaceSlug,
				namespace: payload.namespace
			};
			if (payload.path === "environment") return execCallback(await fn({
				name: "workspace.environment",
				params
			}));
			if (payload.path === "cookies") return execCallback(await fn({
				name: "workspace.cookies",
				params
			}));
			if (payload.path === "settings") return execCallback(await fn({
				name: "workspace.settings",
				params
			}));
		}
		if (payload.page === "example") return execCallback(await fn({
			name: "example",
			params: {
				namespace: payload.namespace,
				workspaceSlug: payload.workspaceSlug,
				documentSlug: payload.documentSlug,
				pathEncoded: encodeURIComponent(payload.path),
				method: payload.method,
				exampleName: payload.exampleName
			}
		}));
		if (payload.page === "operation") {
			const params = {
				namespace: payload.namespace,
				workspaceSlug: payload.workspaceSlug,
				documentSlug: payload.documentSlug,
				pathEncoded: encodeURIComponent(payload.operationPath),
				method: payload.method
			};
			if (payload.path === "overview") return execCallback(await fn({
				name: "operation.overview",
				params
			}));
			if (payload.path === "servers") return execCallback(await fn({
				name: "operation.servers",
				params
			}));
			if (payload.path === "authentication") return execCallback(await fn({
				name: "operation.authentication",
				params
			}));
		}
	});
	eventBus.on("tabs:copy:url", (payload) => onCopyTabUrl(payload.index));
}
//#endregion
//#region src/v2/features/app/helpers/filter-workspaces.ts
/**
* Filters workspaces to show only those accessible to the current team.
*
* A workspace is accessible if:
* - Its teamUid matches the current team, OR
* - Its teamUid is 'local' (local workspaces are always accessible)
*
* @param workspaces - Array of workspaces to filter
* @param currentTeamUid - The currently active team identifier
* @returns Filtered array of workspaces accessible to the current team
*
* @example
* ```ts
* const workspaces = [
*   { id: '1', teamUid: 'local', name: 'Local' },
*   { id: '2', teamUid: 'team-a', name: 'Team A' },
*   { id: '3', teamUid: 'team-b', name: 'Team B' },
* ]
*
* filterWorkspacesByTeam(workspaces, 'team-a')
* // => [{ id: '1', teamUid: 'local' }, { id: '2', teamUid: 'team-a' }]
* ```
*/
var filterWorkspacesByTeam = (workspaces, currentTeamUid) => {
	return workspaces.filter((workspace) => canLoadWorkspace(workspace.teamUid, currentTeamUid));
};
/**
* Checks if a workspace can be loaded by the current team.
*
* A workspace can be loaded if:
* - Its teamUid matches the current team, OR
* - Its teamUid is 'local' (local workspaces are always accessible)
*
* This is used during route changes to prevent users from accessing
* workspaces that do not belong to their active team.
*
* @param workspaceTeamUid - The team identifier of the workspace to check
* @param currentTeamUid - The currently active team identifier
* @returns true if the workspace can be loaded, false otherwise
*
* @example
* ```ts
* canLoadWorkspace('team-a', 'team-a') // => true
* canLoadWorkspace('local', 'team-a')  // => true
* canLoadWorkspace('team-b', 'team-a') // => false
* ```
*/
var canLoadWorkspace = (workspaceTeamUid, currentTeamUid) => {
	return workspaceTeamUid === currentTeamUid || workspaceTeamUid === "local";
};
//#endregion
//#region src/v2/features/app/app-state.ts
/** Default debounce delay in milliseconds for workspace store persistence. */
var DEFAULT_DEBOUNCE_DELAY = 1e3;
/** Default sidebar width in pixels. */
var DEFAULT_SIDEBAR_WIDTH = 288;
var createAppState = async ({ router, fileLoader, fallbackThemeSlug = () => "default", customThemes = () => [] }) => {
	/** Workspace event bus for handling workspace-level events. */
	const eventBus = createWorkspaceEventBus({ debug: false });
	const { workspace: persistence } = await createWorkspaceStorePersistence();
	/**
	* Run migration from localStorage to IndexedDB if needed
	* This happens once per user and transforms old data structure to new workspace format
	*/
	await migrateLocalStorageToIndexDb();
	const teamUid = ref("local");
	const namespace = ref(void 0);
	const workspaceSlug = ref(void 0);
	const documentSlug = ref(void 0);
	const method = ref(void 0);
	const path = ref(void 0);
	const exampleName = ref(void 0);
	const isSyncingWorkspace = ref(false);
	router.afterEach((to) => handleRouteChange(to));
	const currentRoute = computed(() => router.currentRoute.value ?? null);
	const activeWorkspace = shallowRef(null);
	const workspaces = ref([]);
	const filteredWorkspaces = computed(() => filterWorkspacesByTeam(workspaces.value, teamUid.value));
	const workspaceGroups = computed(() => groupWorkspacesByTeam(filteredWorkspaces.value, teamUid.value));
	const store = shallowRef(null);
	const activeDocument = computed(() => {
		return store.value?.workspace.documents[documentSlug.value ?? ""] || null;
	});
	/**
	* Merged environment variables from workspace and document levels.
	* Variables from both sources are combined, with document variables
	* taking precedence in case of naming conflicts.
	*/
	const environment = computed(() => getActiveEnvironment(store.value, activeDocument.value));
	/** Update the workspace list when the component is mounted */
	workspaces.value = await persistence.getAll().then((w) => w.map(({ teamUid, namespace, slug, name }) => ({
		id: getWorkspaceId(namespace, slug),
		teamUid,
		namespace,
		slug,
		label: name
	})));
	/**
	* Renames the currently active workspace.
	* Updates the workspace name in persistence and updates activeWorkspace if successful.
	* Returns early if namespace or workspaceSlug is not set, or if update fails.
	*/
	const renameWorkspace = async (name) => {
		const namespaceValue = namespace.value;
		const slugValue = workspaceSlug.value;
		if (!namespaceValue || !slugValue) return;
		const workspaceId = getWorkspaceId(namespaceValue, slugValue);
		if (await persistence.updateName({
			namespace: namespaceValue,
			slug: slugValue
		}, name) === void 0) return;
		workspaces.value = workspaces.value.map((workspace) => {
			if (workspace.id === workspaceId) return {
				...workspace,
				label: name
			};
			return workspace;
		});
		activeWorkspace.value = {
			id: workspaceId,
			label: name
		};
	};
	/**
	* Creates a client-side workspace store with persistence enabled for the given workspace id.
	*/
	const createClientStore = async ({ namespace, slug }) => {
		return createWorkspaceStore({
			plugins: [await persistencePlugin({
				workspaceId: getWorkspaceId(namespace, slug),
				debounceDelay: DEFAULT_DEBOUNCE_DELAY
			})],
			fileLoader
		});
	};
	/**
	* Attempts to load and activate a workspace by id.
	* Returns true when the workspace was found and activated.
	*/
	const loadWorkspace = async (namespace, slug) => {
		const workspace = await persistence.getItem({
			namespace,
			slug
		});
		if (!workspace) return { success: false };
		const client = await createClientStore({
			namespace,
			slug
		});
		client.loadWorkspace(workspace.workspace);
		activeWorkspace.value = {
			id: getWorkspaceId(workspace.namespace, workspace.slug),
			label: workspace.name
		};
		store.value = client;
		return {
			success: true,
			workspace: client.workspace
		};
	};
	/**
	* Creates and persists the default workspace with a blank draft document.
	* Used when no workspaces exist yet.
	*/
	const createAndPersistWorkspace = async ({ name, teamUid, namespace, slug }) => {
		const draftStore = createWorkspaceStore();
		await draftStore.addDocument({
			name: "drafts",
			document: {
				openapi: "3.1.0",
				info: {
					title: "Drafts",
					version: "1.0.0"
				},
				paths: { "/": { get: {} } },
				"x-scalar-original-document-hash": "drafts",
				"x-scalar-icon": "interface-edit-tool-pencil"
			}
		});
		const workspace = await persistence.setItem({
			namespace,
			slug
		}, {
			name,
			teamUid,
			workspace: draftStore.exportWorkspace()
		});
		workspaces.value.push({
			id: getWorkspaceId(workspace.namespace, workspace.slug),
			teamUid: workspace.teamUid,
			namespace: workspace.namespace,
			slug: workspace.slug,
			label: workspace.name
		});
		return workspace;
	};
	/**
	* Navigates to the overview page of the specified workspace.
	*
	* @param namespace - The workspace namespace.
	* @param slug - The unique workspace slug (identifier).
	*/
	const navigateToWorkspace = async (namespace, slug) => {
		if (!namespace || !slug) {
			await router.push("/");
			return;
		}
		await router.push({
			name: "example",
			params: {
				namespace,
				workspaceSlug: slug,
				documentSlug: "drafts",
				pathEncoded: encodeURIComponent("/"),
				method: "get",
				exampleName: "default"
			}
		});
	};
	/**
	* Creates a new workspace with the provided name.
	* - Generates a unique slug for the workspace (uses the provided slug if it is unique, otherwise generates a unique slug).
	* - Adds a default blank document ("drafts") to the workspace.
	* - Persists the workspace and navigates to it.
	*
	* Example usage:
	*   await createWorkspace({ name: 'My Awesome API' })
	*   // -> Navigates to /workspace/my-awesome-api (if available)
	*/
	const createWorkspace = async ({ teamUid, namespace, slug, name }) => {
		store.value = null;
		const newWorkspaceSlug = await generateUniqueValue({
			defaultValue: slug ?? name,
			validation: async (value) => !await persistence.has({
				namespace: namespace ?? "local",
				slug: value
			}),
			maxRetries: 100,
			transformation: slugify
		});
		if (!newWorkspaceSlug) return;
		const createdWorkspace = await createAndPersistWorkspace({
			teamUid,
			namespace,
			slug: newWorkspaceSlug,
			name
		});
		await navigateToWorkspace(createdWorkspace.namespace, createdWorkspace.slug);
		return createdWorkspace;
	};
	/**
	* Handles changing the active workspace when the workspace slug changes in the route.
	* This function:
	*  - Clears the current workspace store and sets loading state.
	*  - Attempts to load the workspace by slug.
	*    - If found, navigates to the active tab path (if available).
	*    - If not found, creates the default workspace and navigates to it.
	*/
	const changeWorkspace = async (namespace, slug) => {
		store.value = null;
		isSyncingWorkspace.value = true;
		const result = await loadWorkspace(namespace, slug);
		if (result.success) {
			const index = result.workspace["x-scalar-active-tab"] ?? 0;
			const tabs = result.workspace["x-scalar-tabs"];
			const tab = tabs?.[index];
			if (tab) await router.replace({
				path: tab.path,
				query: currentRoute.value?.query ?? {}
			});
			if (tabs && index >= tabs.length) eventBus.emit("tabs:update:tabs", { "x-scalar-active-tab": 0 });
			if (!tabs) eventBus.emit("tabs:update:tabs", {
				"x-scalar-tabs": [createTabFromRoute(currentRoute.value)],
				"x-scalar-active-tab": 0
			});
			isSyncingWorkspace.value = false;
			return;
		}
		const targetWorkspace = filteredWorkspaces.value.find((workspace) => workspace.teamUid === "local" && workspace.slug === "default") ?? filteredWorkspaces.value[0];
		if (targetWorkspace) return navigateToWorkspace(targetWorkspace.namespace, targetWorkspace.slug);
		const createResult = await createWorkspace({
			name: "Default Workspace",
			slug: "default"
		});
		isSyncingWorkspace.value = false;
		if (!createResult) return console.error("Failed to create the default workspace, something went wrong, can not load the workspace");
		sidebarState.reset();
	};
	/**
	* Sets the current team context. If the active workspace is not accessible
	* with the new team, navigates to the default workspace for that team.
	*/
	const setTeamUid = (value) => {
		teamUid.value = value;
		const workspace = filteredWorkspaces.value.find((w) => w.namespace === namespace.value && w.slug === workspaceSlug.value);
		if (workspace && canLoadWorkspace(workspace.teamUid, value)) return;
		return navigateToWorkspace("local", "default");
	};
	const entries = computed(() => {
		const activeStore = store.value;
		if (!activeStore) return [];
		const order = activeStore.workspace["x-scalar-order"] ?? Object.keys(activeStore.workspace.documents);
		return sortByOrder(Object.keys(activeStore.workspace.documents), order, (item) => item).map((doc) => activeStore.workspace.documents[doc]?.["x-scalar-navigation"]).filter(isDefined);
	});
	const sidebarState = createSidebarState(entries);
	/**
	* Generates a unique string ID for an API location, based on the document, path, method, and example.
	* Filters out undefined values and serializes the composite array into a stable string.
	*
	* @param params - An object containing document, path, method, and optional example name.
	* @returns A stringified array representing the unique location identifier.
	*
	* Example:
	*   generateId({ document: 'mydoc', path: '/users', method: 'get', example: 'default' })
	*   // => '["mydoc","/users","get","default"]'
	*/
	const generateId = ({ document, path, method, example }) => {
		return JSON.stringify([
			document,
			path,
			method,
			example
		].filter(isDefined));
	};
	/**
	* Computed index for fast lookup of sidebar nodes by their unique API location.
	*
	* - Only indexes nodes of type 'document', 'operation', or 'example'.
	* - The lookup key is a serialized array of: [documentName, operationPath, operationMethod, exampleName?].
	* - Supports precise resolution of sidebar entries given an API "location".
	*/
	const locationIndex = computed(() => generateReverseIndex({
		items: entries.value,
		nestedKey: "children",
		filter: (node) => node.type === "document" || node.type === "operation" || node.type === "example",
		getId: (node) => {
			const document = getParentEntry("document", node);
			const operation = getParentEntry("operation", node);
			return generateId({
				document: document?.name ?? "",
				path: operation?.path,
				method: operation?.method,
				example: node.type === "example" ? node.name : void 0
			});
		}
	}));
	/**
	* Looks up a sidebar entry by its unique API location.
	* - First tries to find an entry matching all provided properties (including example).
	* - If not found, falls back to matching only the operation (ignores example field).
	* This allows resolving either examples, operations, or documents as appropriate.
	*
	* @param location - Object specifying the document name, path, method, and optional example name.
	* @returns The matching sidebar entry, or undefined if none found.
	*
	* Example:
	*   const entry = getEntryByLocation({
	*     document: 'pets',
	*     path: '/pets',
	*     method: 'get',
	*     example: 'default',
	*   })
	*/
	const getEntryByLocation = (location) => {
		const entryWithExample = locationIndex.value.get(generateId(location));
		if (entryWithExample) return entryWithExample;
		return locationIndex.value.get(generateId({
			document: location.document,
			path: location.path,
			method: location.method
		}));
	};
	/**
	* Handles item selection from the sidebar and routes navigation accordingly.
	*
	* Example:
	*   handleSelectItem('id-of-entry')
	*/
	const handleSelectItem = (id) => {
		const entry = sidebarState.getEntryById(id);
		if (!entry) {
			console.warn(`Could not find sidebar entry with id ${id} to select`);
			return;
		}
		/** Close sidebar and navigate. Used for every branch that performs navigation. */
		const navigate = (route) => {
			isSidebarOpen.value = false;
			return router.push(route);
		};
		if (entry.type === "document") {
			if (sidebarState.selectedItem.value === id) {
				sidebarState.setExpanded(id, !sidebarState.isExpanded(id));
				return;
			}
			sidebarState.setSelected(id);
			sidebarState.setExpanded(id, true);
			return navigate({
				name: "document.overview",
				params: { documentSlug: entry.name }
			});
		}
		if (entry.type === "operation") {
			if (sidebarState.isSelected(id) && sidebarState.selectedItem.value !== id) {
				sidebarState.setExpanded(id, !sidebarState.isExpanded(id));
				return;
			}
			const firstExample = entry.children?.find((child) => child.type === "example");
			if (firstExample) {
				sidebarState.setSelected(firstExample.id);
				sidebarState.setExpanded(firstExample.id, true);
			} else sidebarState.setSelected(id);
			return navigate({
				name: "example",
				params: {
					documentSlug: getParentEntry("document", entry)?.name,
					pathEncoded: encodeURIComponent(entry.path),
					method: entry.method,
					exampleName: firstExample?.name ?? "default"
				}
			});
		}
		if (entry.type === "example") {
			sidebarState.setSelected(id);
			const operation = getParentEntry("operation", entry);
			return navigate({
				name: "example",
				params: {
					documentSlug: getParentEntry("document", entry)?.name,
					pathEncoded: encodeURIComponent(operation?.path ?? ""),
					method: operation?.method,
					exampleName: entry.name
				}
			});
		}
		if (entry.type === "text") return navigate({
			name: "document.overview",
			params: { documentSlug: getParentEntry("document", entry)?.name }
		});
		sidebarState.setExpanded(id, !sidebarState.isExpanded(id));
	};
	/**
	* Navigates to the currently active tab's path using the router.
	* Returns early if the workspace store or active tab is unavailable.
	*/
	const navigateToCurrentTab = async () => {
		if (!store.value) return;
		const activeTabIndex = store.value.workspace["x-scalar-active-tab"] ?? 0;
		const activeTab = store.value.workspace["x-scalar-tabs"]?.[activeTabIndex];
		if (!activeTab) return;
		await router.replace(activeTab.path);
	};
	/**
	* Rebuilds the sidebar for the given document.
	* This is used to refresh the sidebar state after structural changes (e.g. after adding or removing items).
	*
	* @param documentName - The name (id) of the document for which to rebuild the sidebar
	*/
	const rebuildSidebar = (documentName) => {
		if (documentName) store.value?.buildSidebar(documentName);
	};
	/**
	* Ensures the sidebar is refreshed after a new example is created.
	*
	* If the sidebar entry for the new example does not exist or is of a different type,
	* this will rebuild the sidebar for the current document. This helps keep the sidebar state
	* consistent (e.g., after adding a new example via the UI).
	*/
	const refreshSidebarAfterExampleCreation = (payload) => {
		const documentName = payload.documentName ?? activeDocument.value?.["x-scalar-navigation"]?.name;
		if (!documentName) return;
		const entry = getEntryByLocation({
			document: documentName,
			path: payload.path,
			method: payload.method,
			example: payload.exampleKey
		});
		if (!entry || entry.type !== "example") {
			rebuildSidebar(documentName);
			if (currentRoute.value) syncSidebar(currentRoute.value);
		}
	};
	/** Width of the sidebar, with fallback to default. */
	const sidebarWidth = computed(() => store.value?.workspace?.["x-scalar-sidebar-width"] ?? DEFAULT_SIDEBAR_WIDTH);
	/** Handler for sidebar width changes. */
	const handleSidebarWidthUpdate = (width) => store.value?.update("x-scalar-sidebar-width", width);
	/** Controls the visibility of the sidebar. */
	const isSidebarOpen = ref(false);
	/** Constants for workspace store keys */
	const TABS_KEY = "x-scalar-tabs";
	const ACTIVE_TAB_KEY = "x-scalar-active-tab";
	/**
	* Creates a tab object based on the current route and workspace state.
	* Used as a fallback when no tabs exist or when creating new tabs.
	*/
	const createTabFromRoute = (to) => {
		const method = getRouteParam("method", to);
		const path = getRouteParam("pathEncoded", to);
		const document = getRouteParam("documentSlug", to);
		return {
			...getTabDetails({
				workspace: getRouteParam("workspaceSlug", to),
				document,
				path,
				method,
				getEntryByLocation
			}),
			path: currentRoute.value?.path ?? ""
		};
	};
	const tabs = computed(() => {
		return store.value?.workspace[TABS_KEY] ?? [createTabFromRoute(currentRoute.value)];
	});
	const activeTabIndex = computed(() => {
		return store.value?.workspace[ACTIVE_TAB_KEY] ?? 0;
	});
	/**
	* Copies the URL of the tab at the given index to the clipboard.
	* Constructs the full URL using the current origin and the tab path.
	*
	* Note: Will silently fail if clipboard API is unavailable or the tab does not exist.
	*/
	const copyTabUrl = async (index) => {
		const tab = tabs.value[index];
		if (!tab) {
			console.warn(`Cannot copy URL: tab at index ${index} does not exist`);
			return;
		}
		const url = `${window.location.origin}${tab.path}`;
		try {
			await navigator.clipboard.writeText(url);
		} catch (error) {
			console.error("Failed to copy URL to clipboard:", error);
		}
	};
	/** When the route changes we need to update the active entities in the store */
	const handleRouteChange = (to) => {
		const slug = getRouteParam("workspaceSlug", to);
		const document = getRouteParam("documentSlug", to);
		const namespaceValue = getRouteParam("namespace", to);
		if (!namespaceValue || !slug) return;
		const workspace = workspaces.value.find((workspace) => workspace.slug === slug && workspace.namespace === namespaceValue);
		if (workspace && !canLoadWorkspace(workspace.teamUid, teamUid.value)) return navigateToWorkspace("local", "default");
		namespace.value = namespaceValue;
		workspaceSlug.value = slug;
		documentSlug.value = document;
		method.value = getRouteParam("method", to);
		path.value = getRouteParam("pathEncoded", to);
		exampleName.value = getRouteParam("exampleName", to);
		if (to.path !== "") workspaceStorage.setCurrentPath(to.path);
		if (getWorkspaceId(namespace.value, slug) !== activeWorkspace.value?.id) return changeWorkspace(namespace.value, slug);
		if (document && document !== store.value?.workspace[extensions.workspace.activeDocument]) store?.value?.update("x-scalar-active-document", document);
		syncTabs(to);
		syncSidebar(to);
	};
	/** Aligns the tabs with any potential slug changes */
	const syncTabs = (to) => {
		const tabs = store.value?.workspace["x-scalar-tabs"] ?? [];
		const index = store.value?.workspace["x-scalar-active-tab"] ?? 0;
		const tab = tabs[index];
		if (!tab || tab.path === to.path) return;
		tabs[index] = createTabFromRoute(to);
	};
	/** Aligns the sidebar state with any potential slug changes */
	const syncSidebar = (to) => {
		const document = getRouteParam("documentSlug", to);
		if (!document) {
			sidebarState.setSelected(null);
			return;
		}
		const entry = getEntryByLocation({
			document,
			path: getRouteParam("pathEncoded", to),
			method: getRouteParam("method", to),
			example: getRouteParam("exampleName", to)
		});
		if (entry) {
			sidebarState.setSelected(entry.id);
			sidebarState.setExpanded(entry.id, true);
		}
	};
	initializeAppEventHandlers({
		eventBus,
		router,
		store,
		navigateToCurrentTab,
		rebuildSidebar,
		onAfterExampleCreation: refreshSidebarAfterExampleCreation,
		onSelectSidebarItem: handleSelectItem,
		onCopyTabUrl: (index) => copyTabUrl(index),
		onToggleSidebar: () => isSidebarOpen.value = !isSidebarOpen.value,
		closeSidebar: () => isSidebarOpen.value = false,
		renameWorkspace
	});
	const theme = useTheme({
		fallbackThemeSlug,
		customThemes,
		store
	});
	const isDarkMode = computed(() => {
		const colorMode = store.value?.workspace["x-scalar-color-mode"] ?? "system";
		if (colorMode === "system") return window.matchMedia?.("(prefers-color-scheme: dark)")?.matches ?? false;
		return colorMode === "dark";
	});
	return {
		store,
		sidebar: {
			state: sidebarState,
			width: sidebarWidth,
			isOpen: isSidebarOpen,
			handleSelectItem,
			handleSidebarWidthUpdate,
			getEntryByLocation
		},
		tabs: {
			state: tabs,
			activeTabIndex,
			copyTabUrl
		},
		workspace: {
			create: createWorkspace,
			workspaceList: workspaces,
			filteredWorkspaceList: filteredWorkspaces,
			workspaceGroups,
			activeWorkspace,
			navigateToWorkspace,
			isOpen: computed(() => Boolean(workspaceSlug.value && !documentSlug.value))
		},
		eventBus,
		router,
		currentRoute,
		loading: isSyncingWorkspace,
		activeEntities: {
			namespace,
			workspaceSlug,
			documentSlug,
			path,
			method,
			exampleName,
			teamUid: readonly(teamUid),
			setTeamUid
		},
		environment,
		document: activeDocument,
		isDarkMode,
		theme: {
			styles: theme.themeStyles,
			themeStyleTag: theme.themeStyleTag,
			customThemes
		}
	};
};
//#endregion
//#region src/v2/features/app/components/CreateWorkspaceModal.vue
var CreateWorkspaceModal_default = /* @__PURE__ */ defineComponent({
	__name: "CreateWorkspaceModal",
	props: { state: {} },
	emits: ["create:workspace"],
	setup(__props, { emit: __emit }) {
		const emit = __emit;
		/** Name input for the new workspace. Resets whenever the modal opens. */
		const name = ref("");
		/** Trimmed version of the name to avoid repeating .trim() in multiple places. */
		const trimmedName = computed(() => name.value.trim());
		/** Disable submit when the name is empty after trimming. */
		const isDisabled = computed(() => trimmedName.value.length === 0);
		/**
		* Ensure the form is reset whenever the modal opens.
		* Avoids stale state if the modal is reopened.
		*/
		watch(() => __props.state.open, (isOpen) => {
			if (isOpen) name.value = "";
		});
		/** Emits an event to create the workspace with the provided name */
		const handleSubmit = () => {
			if (!trimmedName.value) return;
			emit("create:workspace", { name: trimmedName.value });
			__props.state.hide();
		};
		return (_ctx, _cache) => {
			return openBlock(), createBlock(unref(ScalarModal), {
				bodyClass: "border-t-0 rounded-t-lg",
				size: "xs",
				state: __props.state
			}, {
				default: withCtx(() => [createVNode(CommandActionForm_default, {
					disabled: isDisabled.value,
					onSubmit: handleSubmit
				}, {
					submit: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode("Add Workspace", -1)])]),
					default: withCtx(() => [createVNode(CommandActionInput_default, {
						modelValue: name.value,
						"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => name.value = $event),
						class: "-mt-[.5px] !p-0",
						placeholder: "Workspace name"
					}, null, 8, ["modelValue"])]),
					_: 1
				}, 8, ["disabled"])]),
				_: 1
			}, 8, ["state"]);
		};
	}
});
//#endregion
//#region src/v2/features/app/components/SplashScreen.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$5 = { class: "splash-screen bg-b-1 fixed inset-0 z-50 flex items-center justify-center" };
var _hoisted_2$4 = { class: "flex flex-col items-center gap-4" };
//#endregion
//#region src/v2/features/app/components/SplashScreen.vue
var SplashScreen_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
	__name: "SplashScreen",
	setup(__props) {
		return (_ctx, _cache) => {
			return openBlock(), createElementBlock("div", _hoisted_1$5, [createElementVNode("div", _hoisted_2$4, [createVNode(unref(ScalarIcon), {
				class: "logo-icon text-c-1 h-16 w-16",
				icon: "Logo"
			})])]);
		};
	}
}), [["__scopeId", "data-v-af32615f"]]);
//#endregion
//#region src/v2/features/app/hooks/use-document-watcher.ts
/**
* Default timeout before the first poll attempt (in milliseconds).
*/
var DEFAULT_INITIAL_TIMEOUT = 5 * 1e3;
/**
* Maximum timeout cap for exponential backoff (in milliseconds).
*/
var MAX_TIMEOUT = 60 * 1e3;
/**
* Creates a timer manager for handling polling timeouts.
*
* @returns Object with methods to manage the polling timer.
*/
var createTimerManager = () => {
	let timer = null;
	/**
	* Clears the current timer if it exists.
	*/
	const clear = () => {
		if (timer) {
			clearTimeout(timer);
			timer = null;
		}
	};
	/**
	* Schedules the next poll after the specified timeout.
	*
	* @param callback - The function to call when the timeout expires.
	* @param timeout - The delay in milliseconds before calling the callback.
	*/
	const schedule = (callback, timeout) => {
		clear();
		timer = setTimeout(callback, timeout);
	};
	return {
		clear,
		schedule
	};
};
/**
* Creates a timeout manager that handles exponential backoff on failures.
*
* @param initialTimeout - The initial timeout value in milliseconds.
* @returns Object with methods to manage timeout values.
*/
var createTimeoutManager = (initialTimeout) => {
	let currentTimeout = initialTimeout;
	/**
	* Resets the timeout to its initial value.
	*/
	const reset = () => {
		currentTimeout = initialTimeout;
	};
	/**
	* Doubles the timeout with exponential backoff, capped at MAX_TIMEOUT.
	*/
	const backoff = () => {
		currentTimeout = Math.min(currentTimeout * 2, MAX_TIMEOUT);
	};
	/**
	* Gets the current timeout value.
	*/
	const get = () => currentTimeout;
	return {
		reset,
		backoff,
		get
	};
};
/**
* Resolves conflicts by preferring remote changes.
*
* @param conflicts - Array of conflict tuples from the rebase result.
* Each tuple contains two arrays: [remote changes, local changes].
* @returns Array of remote changes to apply.
*/
var resolveConflicts = (conflicts) => {
	return conflicts.flatMap(([remote]) => remote);
};
/**
* Watches the specified document in the workspace store and periodically rebases it with its remote source.
*
* This utility sets up a watcher on the given document. If the document specifies an 'x-scalar-original-source-url'
* and watch mode is enabled, this hook polls the remote source and calls `store.rebaseDocument`.
* If rebase conflicts are detected, it applies automatic conflict resolution by preferring remote changes.
* Uses exponential backoff on failures to avoid overwhelming the server.
*
* @param params - Configuration object for the document watcher.
* @param params.documentName - The name/key of the document to watch and rebase.
* @param params.store - The WorkspaceStore instance.
* @param params.initialTimeout - Initial delay before the first poll attempt (default: 5000ms).
*
* @example
* ```ts
* import { useDocumentWatcher } from '@/hooks/use-document-watcher'
* import { useScalarWorkspaceStore } from '@scalar/workspace-store'
*
* const store = useScalarWorkspaceStore()
* useDocumentWatcher({ documentName: 'myApi', store })
* ```
*/
var useDocumentWatcher = ({ documentName, store, initialTimeout = DEFAULT_INITIAL_TIMEOUT }) => {
	const document = computed(() => {
		const storeValue = toValue(store);
		const documentNameValue = toValue(documentName);
		if (!storeValue || !documentNameValue) return null;
		return storeValue.workspace.documents[documentNameValue];
	});
	const timerManager = createTimerManager();
	const timeoutManager = createTimeoutManager(initialTimeout);
	/**
	* Handles a successful poll result (with or without changes).
	*/
	const handleSuccess = () => {
		timeoutManager.reset();
		timerManager.schedule(poll, timeoutManager.get());
	};
	/**
	* Handles a failed poll result with exponential backoff.
	*/
	const handleFailure = () => {
		timeoutManager.backoff();
		timerManager.schedule(poll, timeoutManager.get());
	};
	/**
	* Polls the remote document source and attempts to rebase.
	*/
	const poll = async () => {
		const storeValue = toValue(store);
		const documentNameValue = toValue(documentName);
		const sourceUrl = document.value?.["x-scalar-original-source-url"];
		if (!storeValue || !documentNameValue || !sourceUrl) return;
		const result = await storeValue.rebaseDocument({
			name: documentNameValue,
			url: sourceUrl
		});
		if (result?.ok) {
			await result.applyChanges({ resolvedConflicts: resolveConflicts(result.conflicts) });
			handleSuccess();
		} else if (result?.ok === false && result.type === "NO_CHANGES_DETECTED") handleSuccess();
		else handleFailure();
	};
	/**
	* Watches for changes to the document's source URL and watch mode.
	* Starts or stops polling based on these values.
	*/
	watch([() => document.value?.["x-scalar-original-source-url"], () => document.value?.["x-scalar-watch-mode"]], ([sourceUrl, watchMode = false]) => {
		if (!toValue(store)) {
			timerManager.clear();
			return;
		}
		timerManager.clear();
		if (!sourceUrl || !watchMode) {
			timeoutManager.reset();
			return;
		}
		timerManager.schedule(poll, timeoutManager.get());
	}, { immediate: true });
	onBeforeUnmount(() => {
		timerManager.clear();
	});
};
//#endregion
//#region src/v2/hooks/use-color-mode.ts
/**
* Gets the system color mode preference from the browser.
* Falls back to 'light' if running in a non-browser environment.
*
* @returns The system preference for dark or light mode.
*/
var getSystemModePreference = () => {
	if (typeof window === "undefined" || typeof window?.matchMedia !== "function") return "light";
	return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
};
/**
* Converts a ColorMode to a DarkLightMode by resolving 'system' to the actual system preference.
*
* @param mode - The color mode to convert.
* @returns The resolved dark or light mode.
*/
var getDarkLightMode = (mode) => {
	return mode === "system" ? getSystemModePreference() : mode;
};
/**
* Applies the color mode by adding/removing the appropriate CSS classes on the document body.
* This function is safe to call in non-browser environments (no-op).
*
* @param mode - The dark or light mode to apply.
*/
var applyColorMode = (mode) => {
	if (typeof document === "undefined") return;
	const isDark = mode === "dark";
	document.body.classList.toggle("dark-mode", isDark);
	document.body.classList.toggle("light-mode", !isDark);
};
/**
* Composable hook that manages color mode (dark/light/system) based on workspace store configuration.
* Automatically listens to system preference changes when mode is set to 'system'.
*
* @param options - Configuration options for the color mode hook.
* @param options.workspaceStore - The workspace store instance that contains the color mode preference.
* @returns Reactive color mode state and computed properties.
*/
var useColorMode = ({ workspaceStore }) => {
	const colorMode = computed(() => toValue(workspaceStore)?.workspace["x-scalar-color-mode"] ?? "system");
	const darkLightMode = computed(() => getDarkLightMode(colorMode.value));
	const isDarkMode = computed(() => darkLightMode.value === "dark");
	const mediaQuery = ref(null);
	/**
	* Handles system preference changes.
	* Only updates the color mode if the current mode is set to 'system'.
	*/
	const handleSystemPreferenceChange = () => {
		if (colorMode.value === "system") applyColorMode(getSystemModePreference());
	};
	watch(colorMode, (mode) => applyColorMode(getDarkLightMode(mode)), { immediate: true });
	onMounted(() => {
		if (typeof window !== "undefined" && typeof window?.matchMedia === "function") {
			mediaQuery.value = window.matchMedia("(prefers-color-scheme: dark)");
			mediaQuery.value.addEventListener("change", handleSystemPreferenceChange);
		}
	});
	onUnmounted(() => {
		mediaQuery.value?.removeEventListener("change", handleSystemPreferenceChange);
	});
	return {
		colorMode,
		isDarkMode
	};
};
//#endregion
//#region src/v2/features/app/components/DownloadAppButton.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$4 = {
	class: "download-app-button flex w-full flex-row items-center justify-center gap-2 rounded px-3.5 py-2 text-sm leading-4 font-medium",
	href: "https://scalar.com/download?utm_source=web_client&utm_medium=download_button&utm_campaign=topnav",
	target: "_blank",
	type: "button"
};
//#endregion
//#region src/v2/features/app/components/DownloadAppButton.vue
var DownloadAppButton_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
	__name: "DownloadAppButton",
	setup(__props) {
		return (_ctx, _cache) => {
			return openBlock(), createElementBlock("a", _hoisted_1$4, [createVNode(unref(ScalarIconDownloadSimple), { size: "sm" }), _cache[0] || (_cache[0] = createElementVNode("span", { class: "sr-only text-sm font-medium sm:not-sr-only" }, " Download App ", -1))]);
		};
	}
}), [["__scopeId", "data-v-9b609275"]]);
//#endregion
//#region src/v2/features/app/components/SidebarItemMenu.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$3 = { class: "flex items-center gap-2" };
var _hoisted_2$3 = { class: "flex items-center gap-2" };
var _hoisted_3$3 = { class: "flex items-center gap-2" };
var _hoisted_4$2 = { class: "flex items-center gap-2" };
var _hoisted_5$2 = { class: "flex items-center gap-2" };
var _hoisted_6$2 = { class: "text-red flex items-center gap-2" };
//#endregion
//#region src/v2/features/app/components/SidebarItemMenu.vue
var SidebarItemMenu_default = /* @__PURE__ */ defineComponent({
	__name: "SidebarItemMenu",
	props: {
		item: {},
		eventBus: {},
		sidebarState: {},
		target: {}
	},
	emits: ["closeMenu", "showDeleteModal"],
	setup(__props, { emit: __emit }) {
		const emit = __emit;
		const open = ref(false);
		watch(open, async (newValue, oldValue) => {
			if (!newValue && oldValue) {
				await nextTick();
				emit("closeMenu");
			}
		});
		/** Returns whether the item supports adding operations */
		const canAddOperation = () => __props.item.type === "document" || __props.item.type === "tag";
		/** Returns whether the item supports adding tags */
		const canAddTag = () => __props.item.type === "document";
		/** Returns whether the item supports editing tags */
		const canEditTag = () => __props.item.type === "tag";
		/** Returns whether the item supports editing examples */
		const canEditExample = () => __props.item.type === "example";
		/** Returns whether the item supports adding examples */
		const canAddExample = () => __props.item.type === "operation";
		/** Returns whether the item supports deletion */
		const canDelete = () => __props.item.type === "document" && __props.item.id !== "drafts" || __props.item.type === "tag" || __props.item.type === "operation" || __props.item.type === "example";
		const handleAddOperation = () => {
			if (__props.item.type === "document") __props.eventBus.emit("ui:open:command-palette", {
				action: "create-request",
				payload: { documentName: __props.item.name }
			});
			if (__props.item.type === "tag") {
				const itemWithParent = __props.sidebarState.getEntryById(__props.item.id);
				__props.eventBus.emit("ui:open:command-palette", {
					action: "create-request",
					payload: {
						documentName: getParentEntry("document", itemWithParent)?.name,
						tagId: __props.item.name
					}
				});
			}
		};
		const handleAddTag = () => {
			if (__props.item.type === "document") __props.eventBus.emit("ui:open:command-palette", {
				action: "add-tag",
				payload: { documentName: __props.item.name }
			});
		};
		const handleEditTag = () => {
			if (__props.item.type === "tag") {
				const itemWithParent = __props.sidebarState.getEntryById(__props.item.id);
				__props.eventBus.emit("ui:open:command-palette", {
					action: "edit-tag",
					payload: {
						tag: __props.item,
						documentName: getParentEntry("document", itemWithParent)?.name ?? ""
					}
				}, { skipUnpackProxy: true });
			}
		};
		const handleAddExample = () => {
			if (__props.item.type === "operation") {
				const itemWithParent = __props.sidebarState.getEntryById(__props.item.id);
				__props.eventBus.emit("ui:open:command-palette", {
					action: "add-example",
					payload: {
						documentName: getParentEntry("document", itemWithParent)?.name,
						operationId: __props.item.id
					}
				});
			}
		};
		const handleEditExample = () => {
			if (__props.item.type === "example") {
				const itemWithParent = __props.sidebarState.getEntryById(__props.item.id);
				const parentOperation = getParentEntry("operation", itemWithParent);
				__props.eventBus.emit("ui:open:command-palette", {
					action: "edit-example",
					payload: {
						example: __props.item,
						documentName: getParentEntry("document", itemWithParent)?.name ?? "",
						operationId: parentOperation?.id ?? ""
					}
				}, { skipUnpackProxy: true });
			}
		};
		return (_ctx, _cache) => {
			return openBlock(), createBlock(unref(ScalarDropdown), {
				open: open.value,
				"onUpdate:open": _cache[6] || (_cache[6] = ($event) => open.value = $event),
				placement: "bottom-end",
				target: __props.target,
				teleport: ""
			}, {
				items: withCtx(() => [
					canAddOperation() ? (openBlock(), createBlock(unref(ScalarDropdownItem), {
						key: 0,
						onClick: _cache[0] || (_cache[0] = ($event) => handleAddOperation())
					}, {
						default: withCtx(() => [createElementVNode("div", _hoisted_1$3, [createVNode(unref(ScalarIcon), {
							icon: "Add",
							size: "sm"
						}), _cache[7] || (_cache[7] = createTextVNode(" Add Operation ", -1))])]),
						_: 1
					})) : createCommentVNode("", true),
					canAddTag() ? (openBlock(), createBlock(unref(ScalarDropdownItem), {
						key: 1,
						onClick: _cache[1] || (_cache[1] = ($event) => handleAddTag())
					}, {
						default: withCtx(() => [createElementVNode("div", _hoisted_2$3, [createVNode(unref(ScalarIcon), {
							icon: "Add",
							size: "sm"
						}), _cache[8] || (_cache[8] = createTextVNode(" Add Tag ", -1))])]),
						_: 1
					})) : createCommentVNode("", true),
					canEditTag() ? (openBlock(), createBlock(unref(ScalarDropdownItem), {
						key: 2,
						onClick: _cache[2] || (_cache[2] = ($event) => handleEditTag())
					}, {
						default: withCtx(() => [createElementVNode("div", _hoisted_3$3, [createVNode(unref(ScalarIconPencil), { size: "sm" }), _cache[9] || (_cache[9] = createTextVNode(" Rename Tag ", -1))])]),
						_: 1
					})) : createCommentVNode("", true),
					canEditExample() ? (openBlock(), createBlock(unref(ScalarDropdownItem), {
						key: 3,
						onClick: _cache[3] || (_cache[3] = ($event) => handleEditExample())
					}, {
						default: withCtx(() => [createElementVNode("div", _hoisted_4$2, [createVNode(unref(ScalarIconPencil), { size: "sm" }), _cache[10] || (_cache[10] = createTextVNode(" Rename Example ", -1))])]),
						_: 1
					})) : createCommentVNode("", true),
					canAddExample() ? (openBlock(), createBlock(unref(ScalarDropdownItem), {
						key: 4,
						onClick: _cache[4] || (_cache[4] = ($event) => handleAddExample())
					}, {
						default: withCtx(() => [createElementVNode("div", _hoisted_5$2, [createVNode(unref(ScalarIcon), {
							icon: "Add",
							size: "sm"
						}), _cache[11] || (_cache[11] = createTextVNode(" Add Example ", -1))])]),
						_: 1
					})) : createCommentVNode("", true),
					(canAddExample() || canAddOperation() || canAddTag() || canEditExample()) && canDelete() ? (openBlock(), createBlock(unref(ScalarDropdownDivider), { key: 5 })) : createCommentVNode("", true),
					canDelete() ? (openBlock(), createBlock(unref(ScalarDropdownItem), {
						key: 6,
						onClick: _cache[5] || (_cache[5] = ($event) => emit("showDeleteModal"))
					}, {
						default: withCtx(() => [createElementVNode("div", _hoisted_6$2, [createVNode(unref(ScalarIcon), {
							icon: "Delete",
							size: "sm"
						}), _cache[12] || (_cache[12] = createTextVNode(" Delete ", -1))])]),
						_: 1
					})) : createCommentVNode("", true)
				]),
				_: 1
			}, 8, ["open", "target"]);
		};
	}
});
//#endregion
//#region src/v2/helpers/drag-handle-factory.ts
/**
* Reorders items in an array by moving an item from one index to another,
* adjusting insertion point based on offset.
* Returns the new order array, or null if indices are invalid.
*/
var reorderArray = (array, fromIndex, toIndex, offset) => {
	if (fromIndex === -1 || toIndex === -1 || fromIndex === toIndex) return null;
	const newArray = [...array];
	const [removed] = newArray.splice(fromIndex, 1);
	if (removed === void 0) return null;
	const insertIndex = calculateInsertIndex(fromIndex, toIndex, offset, newArray.length);
	newArray.splice(insertIndex, 0, removed);
	return unpackProxyObject(newArray, { depth: 1 });
};
/**
* Calculates the insertion index based on drag offset and direction.
*/
var calculateInsertIndex = (fromIndex, toIndex, offset, arrayLength) => {
	const isMovingDown = fromIndex < toIndex;
	if (offset === "after") return isMovingDown ? toIndex : toIndex + 1;
	if (offset === "before") return isMovingDown ? toIndex - 1 : toIndex;
	if (offset === "into") return arrayLength;
	return toIndex;
};
/**
* Type guard to check if an entry's type matches any of the provided types.
*
* @template Entry - The traversed entry type (must extend TraversedEntry).
* @template Type - An array of allowed entry types to check against.
* @param entry - The sidebar entry to check.
* @param type - Array of entry types to match (e.g., ['document', 'tag']).
* @returns {boolean} True if entry.type is included in the provided type array; otherwise, false.
*
* @example
* isEntryType(someEntry, ['document', 'tag']) // true if someEntry.type === 'document' or 'tag'
*/
var isEntryType = (entry, type) => {
	return type.includes(entry.type);
};
/**
* Determines if the hovered item qualifies as a "reorder" operation.
* Reorder means moving before or after another item, not dropping
* into a parent container.
*/
var isReorder = (hoveredItem) => {
	return hoveredItem.offset === "before" || hoveredItem.offset === "after";
};
/**
* Determines if the hovered item represents a "drop into parent" operation.
*/
var isDropIntoParent = (hoveredItem) => {
	return hoveredItem.offset === "into";
};
/**
* Checks if two sidebar entries (dragging and hovered) share the same parent.
*
* This is useful for determining if items can be reordered within the same context,
* such as reordering tags or operations under the same tag or document, during drag-and-drop operations.
*
* @param draggingItem - The entry currently being dragged (must have a parent to compare).
* @param hoveredItem - The entry currently hovered over (must have a parent to compare).
* @returns {boolean} True if both entries have the same parent (by id), false otherwise.
*
* @example
* const parent = { id: 'doc-1', type: 'document' };
* const tagA = { id: 'tag-1', type: 'tag', parent };
* const tagB = { id: 'tag-2', type: 'tag', parent };
* itemsShareParent(tagA, tagB); // true
*
* const otherParent = { id: 'doc-2', type: 'document' };
* const tagC = { id: 'tag-3', type: 'tag', parent: otherParent };
* itemsShareParent(tagA, tagC); // false
*/
var itemsShareParent = (draggingItem, hoveredItem) => {
	if (!draggingItem.parent || !hoveredItem.parent) return false;
	return draggingItem.parent.id === hoveredItem.parent.id;
};
/**
* Triggers rebuilding of the sidebar for a specific document entry.
* This is called after operations that alter the sidebar structure.
*/
var rebuildSidebar = ({ store, entry }) => {
	const documentEntry = getParentEntry("document", entry);
	if (documentEntry) store.buildSidebar(documentEntry.name);
};
/**
* Gets the current order array for a parent entry.
* Falls back to children IDs if no explicit order exists.
*/
var getCurrentOrder = (parent, parentEntry) => {
	return parent["x-scalar-order"] ?? parentEntry.children?.map((child) => child.id) ?? [];
};
/**
* Handles reordering of entries (tags or operations) within the same parent.
*/
var handleReorderWithinParent = (store, draggingItem, hoveredItem, offset) => {
	const parentEntry = draggingItem.parent;
	if (!parentEntry || !isEntryType(parentEntry, ["tag", "document"])) return false;
	const parent = getOpenapiObject({
		store,
		entry: parentEntry
	});
	if (!parent) return false;
	const currentOrder = getCurrentOrder(parent, parentEntry);
	const newOrder = reorderArray(currentOrder, currentOrder.findIndex((id) => id === draggingItem.id), currentOrder.findIndex((id) => id === hoveredItem.id), offset);
	if (!newOrder) return false;
	parent["x-scalar-order"] = newOrder;
	rebuildSidebar({
		store,
		entry: parentEntry
	});
	return true;
};
/**
* Updates operation tags when moving between different parents.
*/
var updateOperationTags = (operation, draggedTag, hoveredTag) => {
	const tags = new Set(operation.tags ?? []);
	if (hoveredTag) tags.add(hoveredTag.name);
	if (draggedTag) tags.delete(draggedTag.name);
	operation.tags = Array.from(tags);
};
/**
* Moves an operation from one document to another.
*/
var moveOperationBetweenDocuments = (draggingDocument, hoveredDocument, draggingItem, operationCopy) => {
	if (draggingDocument.paths?.[draggingItem.path]?.[draggingItem.method]) delete draggingDocument.paths[draggingItem.path][draggingItem.method];
	if (!hoveredDocument.paths) hoveredDocument.paths = { [draggingItem.path]: { [draggingItem.method]: operationCopy } };
	else {
		if (!hoveredDocument.paths[draggingItem.path]) hoveredDocument.paths[draggingItem.path] = {};
		hoveredDocument.paths[draggingItem.path][draggingItem.method] = operationCopy;
	}
};
/**
* Retrieves the dereferenced operation object for a given path and method.
* This resolves all $ref references so you always get the full, dereferenced operation.
*/
var getDereferencedOperation = (document, path, method) => {
	const operation = dereference(document).schema.paths?.[path]?.[method];
	return toJsonCompatible(operation, { prefix: `#/paths/${escapeJsonPointer(path)}/${method}` });
};
/**
* Handles moving an operation between different documents/tags.
*/
var handleMoveOperation = (store, draggingItem, hoveredItem) => {
	const draggingDocumentEntry = getParentEntry("document", draggingItem);
	const hoveredDocumentEntry = getParentEntry("document", hoveredItem);
	if (!draggingDocumentEntry || !hoveredDocumentEntry) return false;
	const draggingDocument = getOpenapiObject({
		store,
		entry: draggingDocumentEntry
	});
	const hoveredDocument = getOpenapiObject({
		store,
		entry: hoveredDocumentEntry
	});
	if (!draggingDocument || !hoveredDocument) return false;
	const currentOperation = getDereferencedOperation(unpackProxyObject(draggingDocument), draggingItem.path, draggingItem.method);
	if (!currentOperation) return false;
	updateOperationTags(currentOperation, getParentEntry("tag", draggingItem) ?? null, getParentEntry("tag", hoveredItem) ?? null);
	moveOperationBetweenDocuments(draggingDocument, hoveredDocument, draggingItem, currentOperation);
	rebuildSidebar({
		store,
		entry: draggingItem
	});
	rebuildSidebar({
		store,
		entry: hoveredItem
	});
	return true;
};
/**
* Handles document reordering.
*/
var handleDocumentReorder = (store, draggingItem, hoveredItem, offset) => {
	const order = store.workspace["x-scalar-order"] ?? [];
	const currentOrder = sortByOrder(Object.keys(store.workspace.documents), order, (item) => item);
	const newOrder = reorderArray(currentOrder, currentOrder.findIndex((id) => id === draggingItem.id), currentOrder.findIndex((id) => id === hoveredItem.id), offset);
	if (!newOrder) return false;
	store.update("x-scalar-order", newOrder);
	return true;
};
/**
* Factory function that creates drag and drop handlers for sidebar items.
* Handles reordering and moving of documents, tags, and operations.
*/
var dragHandleFactory = ({ store: _store, sidebarState }) => {
	/**
	* Handles the end of a drag operation.
	* Returns true if the drag and drop was successful, false otherwise.
	*/
	const handleDragEnd = (_draggingItem, _hoveredItem) => {
		const store = toValue(_store);
		if (!store) return false;
		const draggingItem = sidebarState.getEntryById(_draggingItem.id);
		const hoveredItem = sidebarState.getEntryById(_hoveredItem.id);
		if (!draggingItem || !hoveredItem) return false;
		if (draggingItem.type === "document") {
			if (hoveredItem.type !== "document" || !isReorder(_hoveredItem)) return false;
			return handleDocumentReorder(store, draggingItem, hoveredItem, _hoveredItem.offset);
		}
		if (draggingItem.type === "tag") {
			if (hoveredItem.type !== "tag" || !isReorder(_hoveredItem) || !itemsShareParent(draggingItem, hoveredItem)) return false;
			return handleReorderWithinParent(store, draggingItem, hoveredItem, _hoveredItem.offset);
		}
		if (draggingItem.type === "operation") {
			if (isReorder(_hoveredItem) && itemsShareParent(draggingItem, hoveredItem)) return handleReorderWithinParent(store, draggingItem, hoveredItem, _hoveredItem.offset);
			if (isEntryType(hoveredItem, ["tag", "document"]) && isDropIntoParent(_hoveredItem)) return handleMoveOperation(store, draggingItem, hoveredItem);
		}
		return false;
	};
	/**
	* Determines if an item can be dropped on another item.
	* Returns true if the drop operation is allowed, false otherwise.
	*/
	const isDroppable = (_draggingItem, _hoveredItem) => {
		const store = toValue(_store);
		if (!store) return false;
		const draggingItem = sidebarState.getEntryById(_draggingItem.id);
		const hoveredItem = sidebarState.getEntryById(_hoveredItem.id);
		if (!draggingItem || !hoveredItem) return false;
		if (draggingItem.type === "example") return false;
		if (draggingItem.type === "document") return hoveredItem.type === "document" && isReorder(_hoveredItem);
		if (draggingItem.type === "tag") return isReorder(_hoveredItem) && itemsShareParent(draggingItem, hoveredItem);
		if (draggingItem.type === "operation") {
			const hoveredDocumentEntry = getParentEntry("document", hoveredItem);
			const draggingDocumentEntry = getParentEntry("document", draggingItem);
			if (!hoveredDocumentEntry || !draggingDocumentEntry) return false;
			const hoveredDocument = getOpenapiObject({
				store,
				entry: hoveredDocumentEntry
			});
			if (!hoveredDocument) return false;
			const sameParent = itemsShareParent(draggingItem, hoveredItem);
			if (isReorder(_hoveredItem) && !sameParent) return false;
			if (sameParent) return isReorder(_hoveredItem) || isDropIntoParent(_hoveredItem) && isEntryType(hoveredItem, ["tag", "document"]);
			return isDropIntoParent(_hoveredItem) && isEntryType(hoveredItem, ["tag", "document"]) && (draggingDocumentEntry.id === hoveredDocumentEntry.id || hoveredDocument.paths?.[draggingItem.path]?.[draggingItem.method] === void 0);
		}
		return false;
	};
	return {
		handleDragEnd,
		isDroppable
	};
};
//#endregion
//#region src/v2/features/app/components/AppSidebar.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$2 = { class: "flex" };
var _hoisted_2$2 = { class: "flex items-center gap-0.5" };
var _hoisted_3$2 = {
	key: 0,
	class: "relative flex items-center"
};
var _hoisted_4$1 = {
	key: 0,
	class: "empty-sidebar-item-content overflow-hidden px-2.5 py-2.5"
};
var _hoisted_5$1 = { class: "rabbit-ascii relative m-auto mt-2 h-[68px] w-[60px]" };
var _hoisted_6$1 = { class: "flex flex-col gap-1.5 p-2" };
var _hoisted_7$1 = { class: "text-sidebar-c-2 rounded border px-1.25 py-1 text-xs leading-none font-medium uppercase" };
//#endregion
//#region src/v2/features/app/components/AppSidebar.vue
var AppSidebar_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
	__name: "AppSidebar",
	props: /* @__PURE__ */ mergeModels({
		layout: {},
		sidebarState: {},
		isWorkspaceOpen: { type: Boolean },
		activeWorkspace: {},
		workspaces: {},
		eventBus: {},
		store: {}
	}, {
		"isSidebarOpen": {
			type: Boolean,
			required: true
		},
		"isSidebarOpenModifiers": {},
		"sidebarWidth": {
			required: true,
			default: 288
		},
		"sidebarWidthModifiers": {}
	}),
	emits: /* @__PURE__ */ mergeModels([
		"click:workspace",
		"selectItem",
		"select:workspace",
		"create:workspace"
	], ["update:isSidebarOpen", "update:sidebarWidth"]),
	setup(__props, { emit: __emit }) {
		const emit = __emit;
		/** The label for the workspace button in the sidebar */
		const workspaceLabel = computed(() => capitalize(__props.activeWorkspace.label));
		/** Controls the visibility of the sidebar */
		const isSidebarOpen = useModel(__props, "isSidebarOpen");
		/** Controls the width of the sidebar */
		const sidebarWidth = useModel(__props, "sidebarWidth");
		/** Calculate if we should show the getting started section */
		const showGettingStarted = computed(() => __props.sidebarState.items.value.length <= 1);
		const dragHandlers = computed(() => dragHandleFactory({
			store: __props.store,
			sidebarState: __props.sidebarState
		}));
		const handleDragEnd = (draggingItem, hoveredItem) => {
			return dragHandlers.value.handleDragEnd(draggingItem, hoveredItem);
		};
		const isDroppable = (draggingItem, hoveredItem) => {
			return dragHandlers.value.isDroppable(draggingItem, hoveredItem);
		};
		/** The current target for the dropdown menu */
		const menuTarget = ref(null);
		const deleteModalState = useModal();
		/** Computes the message for the delete modal */
		const deleteMessage = computed(() => {
			const item = menuTarget.value?.item;
			if (item?.type === "document") return "This cannot be undone. You're about to delete the document and all tags and operations inside it.";
			return `Are you sure you want to delete this ${item?.type ?? "item"}? This action cannot be undone.`;
		});
		/** Deletes an item from the sidebar by emitting the appropriate event */
		const handleDelete = () => {
			const item = menuTarget.value?.item;
			if (!item) return;
			const result = __props.sidebarState.getEntryById(item.id);
			const document = getParentEntry("document", result);
			const operation = getParentEntry("operation", result);
			if (!document) return;
			if (item.type === "document") __props.eventBus.emit("document:delete:document", { name: document.name });
			else if (item.type === "tag") __props.eventBus.emit("tag:delete:tag", {
				documentName: document.name,
				name: item.name
			});
			else if (item.type === "operation") {
				if (!operation) return;
				__props.eventBus.emit("operation:delete:operation", {
					meta: {
						method: operation.method,
						path: operation.path
					},
					documentName: document.name
				});
			} else if (item.type === "example") {
				if (!operation) return;
				__props.eventBus.emit("operation:delete:example", {
					meta: {
						method: operation.method,
						path: operation.path,
						exampleKey: item.name
					},
					documentName: document.name
				});
			}
			/** Clean up after deletion */
			deleteModalState.hide();
			menuTarget.value = null;
		};
		/** Opens the dropdown menu for the given item */
		const openMenu = async (event, item) => {
			if (menuTarget.value?.showMenu) return;
			menuTarget.value = {
				item,
				el: event.currentTarget,
				showMenu: true
			};
			await nextTick();
			const cloned = event instanceof MouseEvent ? new MouseEvent(event.type, event) : new KeyboardEvent(event.type, event);
			menuTarget.value?.el.dispatchEvent(cloned);
		};
		/** Closes the dropdown menu */
		const closeMenu = () => {
			if (menuTarget.value) menuTarget.value.showMenu = false;
		};
		/** Opens the command palette with the payload needed to create a request */
		const handleAddEmptyFolder = (item) => {
			const itemWithParent = __props.sidebarState.getEntryById(item.id);
			const documentEntry = getParentEntry("document", itemWithParent);
			const tag = getParentEntry("tag", itemWithParent);
			__props.eventBus.emit("ui:open:command-palette", {
				action: "create-request",
				payload: {
					documentName: documentEntry?.name,
					tagId: tag?.name
				}
			});
		};
		/**
		* Navigates to the operations page for the provided operation item.
		* Emits a navigation event for the operation overview page.
		*/
		const navigateToOperationsPage = (item) => {
			const documentSlug = getParentEntry("document", __props.sidebarState.getEntryById(item.id))?.name;
			__props.eventBus.emit("ui:navigate", {
				page: "operation",
				path: "overview",
				operationPath: item.path,
				method: item.method,
				documentSlug
			});
		};
		return (_ctx, _cache) => {
			return openBlock(), createElementBlock("div", _hoisted_1$2, [
				createVNode(unref(Sidebar_default), {
					sidebarWidth: sidebarWidth.value,
					"onUpdate:sidebarWidth": _cache[3] || (_cache[3] = ($event) => sidebarWidth.value = $event),
					activeWorkspace: __props.activeWorkspace,
					class: normalizeClass(["max-md:inset-y-0 max-md:z-2 max-md:w-full!", isSidebarOpen.value ? "max-md:fixed! max-md:flex!" : "max-md:hidden!"]),
					documents: Object.values(__props.store.workspace.documents),
					isDroppable,
					layout: __props.layout,
					sidebarState: __props.sidebarState,
					workspaces: __props.workspaces,
					"onCreate:workspace": _cache[4] || (_cache[4] = ($event) => emit("create:workspace")),
					"onNavigate:to:settings": _cache[5] || (_cache[5] = ($event) => __props.eventBus.emit("ui:navigate", {
						page: "workspace",
						path: "settings"
					})),
					onReorder: _cache[6] || (_cache[6] = (draggingItem, hoveredItem) => handleDragEnd(draggingItem, hoveredItem)),
					"onSelect:workspace": _cache[7] || (_cache[7] = (id) => emit("select:workspace", id)),
					onSelectItem: _cache[8] || (_cache[8] = (id) => emit("selectItem", id))
				}, createSlots({
					sidebarMenuActions: withCtx(() => [renderSlot(_ctx.$slots, "sidebarMenuActions", {}, void 0, true)]),
					workspaceButton: withCtx(() => [createVNode(unref(ScalarSidebarItem), {
						is: "button",
						active: __props.isWorkspaceOpen,
						onClick: _cache[0] || (_cache[0] = ($event) => emit("click:workspace"))
					}, {
						default: withCtx(() => [createTextVNode(toDisplayString(workspaceLabel.value), 1)]),
						_: 1
					}, 8, ["active"])]),
					decorator: withCtx(({ item }) => [createElementVNode("div", _hoisted_2$2, [item.type === "operation" ? (openBlock(), createBlock(unref(ScalarIconButton), {
						key: 0,
						icon: unref(ScalarIconGearSix),
						label: "Operation settings",
						size: "sm",
						weight: "bold",
						onClick: withModifiers(($event) => navigateToOperationsPage(item), ["stop"]),
						onKeydown: [withKeys(withModifiers(($event) => navigateToOperationsPage(item), ["stop"]), ["enter"]), withKeys(withModifiers(($event) => navigateToOperationsPage(item), ["stop"]), ["space"])]
					}, null, 8, [
						"icon",
						"onClick",
						"onKeydown"
					])) : createCommentVNode("", true), createVNode(unref(ScalarIconButton), {
						"aria-expanded": "false",
						"aria-haspopup": "menu",
						icon: unref(ScalarIconDotsThree),
						label: "More options",
						size: "sm",
						weight: "bold",
						onClick: withModifiers((e) => openMenu(e, item), ["stop"]),
						onKeydown: [
							withKeys(withModifiers((e) => openMenu(e, item), ["stop"]), ["down"]),
							withKeys(withModifiers((e) => openMenu(e, item), ["stop"]), ["enter"]),
							withKeys(withModifiers((e) => openMenu(e, item), ["stop"]), ["space"]),
							withKeys(withModifiers((e) => openMenu(e, item), ["stop"]), ["up"])
						]
					}, null, 8, [
						"icon",
						"onClick",
						"onKeydown"
					])])]),
					icon: withCtx(({ item }) => [item.type === "document" && __props.store.workspace.documents[item.name]?.["x-scalar-is-dirty"] === true ? (openBlock(), createElementBlock("div", _hoisted_3$2, [createVNode(unref(LibraryIcon), {
						class: "block",
						src: "icon" in item && item.icon || "interface-content-folder"
					}, null, 8, ["src"]), _cache[11] || (_cache[11] = createElementVNode("div", { class: "bg-orange absolute -top-1.25 -right-1.25 flex h-2.5 w-2.5 items-center justify-center rounded-full text-[9px] font-bold text-white" }, " ! ", -1))])) : createCommentVNode("", true)]),
					empty: withCtx(({ item }) => [createVNode(unref(ScalarSidebarItem), {
						is: "button",
						onClick: ($event) => handleAddEmptyFolder(item)
					}, {
						icon: withCtx(() => [createVNode(unref(ScalarIconPlus))]),
						default: withCtx(() => [..._cache[12] || (_cache[12] = [createTextVNode("Add operation", -1)])]),
						_: 1
					}, 8, ["onClick"])]),
					_: 2
				}, [__props.layout !== "modal" ? {
					name: "footer",
					fn: withCtx(() => [createElementVNode("div", { class: normalizeClass({ "empty-sidebar-item border-t": showGettingStarted.value }) }, [showGettingStarted.value ? (openBlock(), createElementBlock("div", _hoisted_4$1, [createElementVNode("div", _hoisted_5$1, [createVNode(ScalarAsciiArt_default, {
						art: unref(rabbit_default),
						class: "rabbitsit font-bold"
					}, null, 8, ["art"]), createVNode(ScalarAsciiArt_default, {
						art: unref(rabbitjump_default),
						class: "rabbitjump absolute top-0 left-0 font-bold"
					}, null, 8, ["art"])]), _cache[13] || (_cache[13] = createElementVNode("div", { class: "mt-2 mb-2 text-center text-sm text-balance" }, [createElementVNode("b", { class: "font-medium" }, "Let's Get Started"), createElementVNode("p", { class: "mt-2 leading-5" }, " Create request, folder, collection or import from OpenAPI/Postman ")], -1))])) : createCommentVNode("", true), createElementVNode("div", _hoisted_6$1, [
						showGettingStarted.value ? (openBlock(), createBlock(unref(ScalarButton), {
							key: 0,
							class: "w-full",
							size: "sm",
							onClick: _cache[1] || (_cache[1] = ($event) => __props.eventBus.emit("ui:open:command-palette", {
								action: "import-from-openapi-swagger-postman-curl",
								payload: void 0
							}))
						}, {
							default: withCtx(() => [..._cache[14] || (_cache[14] = [createTextVNode(" Import Collection ", -1)])]),
							_: 1
						})) : createCommentVNode("", true),
						createVNode(unref(ScalarButton), {
							class: "w-full",
							hotkey: "K",
							size: "sm",
							variant: "outlined",
							onClick: _cache[2] || (_cache[2] = ($event) => __props.eventBus.emit("ui:open:command-palette"))
						}, {
							default: withCtx(() => [_cache[20] || (_cache[20] = createTextVNode(" Add Item \xA0 ", -1)), createElementVNode("span", _hoisted_7$1, [unref(isMacOS)() ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [_cache[15] || (_cache[15] = createElementVNode("span", { class: "sr-only" }, "Command", -1)), _cache[16] || (_cache[16] = createElementVNode("span", { "aria-hidden": "true" }, "⌘", -1))], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [_cache[17] || (_cache[17] = createElementVNode("span", { class: "sr-only" }, "CTRL", -1)), _cache[18] || (_cache[18] = createElementVNode("span", { "aria-hidden": "true" }, "⌃", -1))], 64)), _cache[19] || (_cache[19] = createTextVNode(" K ", -1))])]),
							_: 1
						}),
						__props.layout === "web" ? (openBlock(), createBlock(DownloadAppButton_default, { key: 1 })) : createCommentVNode("", true)
					])], 2)]),
					key: "0"
				} : void 0]), 1032, [
					"sidebarWidth",
					"activeWorkspace",
					"class",
					"documents",
					"layout",
					"sidebarState",
					"workspaces"
				]),
				menuTarget.value?.showMenu ? (openBlock(), createBlock(SidebarItemMenu_default, {
					key: 0,
					eventBus: __props.eventBus,
					item: menuTarget.value.item,
					sidebarState: __props.sidebarState,
					target: menuTarget.value.el,
					onCloseMenu: closeMenu,
					onShowDeleteModal: _cache[9] || (_cache[9] = ($event) => unref(deleteModalState).show())
				}, null, 8, [
					"eventBus",
					"item",
					"sidebarState",
					"target"
				])) : createCommentVNode("", true),
				menuTarget.value ? (openBlock(), createBlock(unref(ScalarModal), {
					key: 1,
					size: "xxs",
					state: unref(deleteModalState),
					title: `Delete ${menuTarget.value.item.title}`
				}, {
					default: withCtx(() => [createVNode(DeleteSidebarListElement_default, {
						variableName: menuTarget.value.item.title,
						warningMessage: deleteMessage.value,
						onClose: _cache[10] || (_cache[10] = ($event) => unref(deleteModalState).hide()),
						onDelete: handleDelete
					}, null, 8, ["variableName", "warningMessage"])]),
					_: 1
				}, 8, ["state", "title"])) : createCommentVNode("", true)
			]);
		};
	}
}), [["__scopeId", "data-v-8621f58a"]]);
//#endregion
//#region src/v2/features/app/components/DesktopTab.vue
var DesktopTab_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
	__name: "DesktopTab",
	props: {
		hotkey: {},
		active: { type: Boolean },
		isSingleTab: {
			type: Boolean,
			default: false
		},
		tab: {}
	},
	emits: [
		"click",
		"close",
		"newTab",
		"copyUrl",
		"closeOtherTabs"
	],
	setup(__props, { emit: __emit }) {
		const emit = __emit;
		const ICONS = {
			request: ScalarIconArrowUpRight,
			document: ScalarIconFolderSimple
		};
		/** Display the appropriate modifier key based on the operating system */
		const modifierKey = computed(() => isMacOS() ? "⌘" : "^");
		/** The tooltip content showing the keyboard shortcut */
		const tooltipContent = computed(() => __props.hotkey ? `${modifierKey.value} ${__props.hotkey}` : "");
		/**
		* Handle the close button click.
		* We stop propagation to prevent triggering the tab activation click.
		*/
		const handleClose = (event) => {
			event.stopPropagation();
			emit("close");
		};
		return (_ctx, _cache) => {
			return openBlock(), createBlock(unref(ScalarContextMenu), { triggerClass: "overflow-hidden w-full flex-1 select-none\n" }, {
				trigger: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(__props.isSingleTab ? "div" : unref(ScalarTooltip)), {
					content: tooltipContent.value,
					placement: "bottom"
				}, {
					default: withCtx(() => [createElementVNode("div", {
						class: normalizeClass(["app-no-drag-region", [__props.isSingleTab ? "nav-single-tab" : "nav-item", { "nav-item__active": __props.active && !__props.isSingleTab }]]),
						onClick: _cache[0] || (_cache[0] = ($event) => !__props.isSingleTab && emit("click"))
					}, [createElementVNode("div", { class: normalizeClass(["flex items-center justify-center gap-1.5", __props.isSingleTab ? "custom-scroll h-full w-full whitespace-nowrap" : "nav-item-icon-copy flex-1"]) }, [__props.tab.icon && ICONS[__props.tab.icon] ? (openBlock(), createBlock(resolveDynamicComponent(ICONS[__props.tab.icon]), { key: 0 })) : createCommentVNode("", true), createElementVNode("span", { class: normalizeClass([__props.isSingleTab ? "" : "custom-scroll nav-item-copy", "text-sm"]) }, toDisplayString(__props.tab.title), 3)], 2), !__props.isSingleTab ? (openBlock(), createElementBlock("button", {
						key: 0,
						class: "nav-item-close",
						type: "button",
						onClick: handleClose
					}, [(openBlock(), createBlock(resolveDynamicComponent(unref(ScalarIconX))))])) : createCommentVNode("", true)], 2)]),
					_: 1
				}, 8, ["content"]))]),
				content: withCtx(() => [createVNode(unref(ScalarFloating), { placement: "right-start" }, {
					floating: withCtx(() => [createVNode(unref(ScalarDropdownMenu), { class: "scalar-app scalar-client" }, {
						default: withCtx(() => [
							createVNode(unref(ScalarDropdownButton), {
								class: "flex items-center gap-1.5",
								onClick: _cache[1] || (_cache[1] = ($event) => emit("newTab"))
							}, {
								default: withCtx(() => [
									(openBlock(), createBlock(resolveDynamicComponent(unref(ScalarIconPlusSquare)))),
									_cache[5] || (_cache[5] = createTextVNode(" New Tab ", -1)),
									createVNode(unref(ScalarHotkey), {
										class: "bg-b-2 ml-auto",
										hotkey: "T"
									})
								]),
								_: 1
							}),
							createVNode(unref(ScalarDropdownButton), {
								class: "flex items-center gap-1.5",
								onClick: _cache[2] || (_cache[2] = ($event) => emit("copyUrl"))
							}, {
								default: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(unref(ScalarIconLinkSimple)))), _cache[6] || (_cache[6] = createTextVNode(" Copy URL ", -1))]),
								_: 1
							}),
							!__props.isSingleTab ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
								createVNode(unref(ScalarDropdownDivider)),
								createVNode(unref(ScalarDropdownButton), {
									class: "flex items-center gap-1.5",
									onClick: _cache[3] || (_cache[3] = ($event) => emit("close"))
								}, {
									default: withCtx(() => [
										(openBlock(), createBlock(resolveDynamicComponent(unref(ScalarIconXSquare)))),
										_cache[7] || (_cache[7] = createTextVNode(" Close Tab ", -1)),
										createVNode(unref(ScalarHotkey), {
											class: "bg-b-2 ml-auto",
											hotkey: "W"
										})
									]),
									_: 1
								}),
								createVNode(unref(ScalarDropdownButton), {
									class: "flex items-center gap-1.5",
									onClick: _cache[4] || (_cache[4] = ($event) => emit("closeOtherTabs"))
								}, {
									default: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(unref(ScalarIconTabs)))), _cache[8] || (_cache[8] = createTextVNode(" Close Other Tabs ", -1))]),
									_: 1
								})
							], 64)) : createCommentVNode("", true)
						]),
						_: 1
					})]),
					_: 1
				})]),
				_: 1
			});
		};
	}
}), [["__scopeId", "data-v-2e741aab"]]);
//#endregion
//#region src/v2/features/app/components/DesktopTabs.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$1 = { class: "t-app__top-nav" };
var _hoisted_2$1 = { class: "mac:app-drag-region" };
var _hoisted_3$1 = { class: "z-1 flex h-10 items-center gap-2 px-2" };
//#endregion
//#region src/v2/features/app/components/DesktopTabs.vue
var DesktopTabs_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$1, [createElementVNode("div", _hoisted_2$1, [createElementVNode("div", _hoisted_3$1, [(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
//#region src/v2/features/app/App.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1 = ["innerHTML"];
var _hoisted_2 = { key: 0 };
var _hoisted_3 = { class: "relative flex h-dvh w-dvw flex-1 flex-col" };
var _hoisted_4 = { class: "flex min-h-0 flex-1 flex-row" };
var _hoisted_5 = { class: "flex flex-1 flex-col" };
var _hoisted_6 = { class: "bg-b-1 min-h-0 flex-1" };
var _hoisted_7 = { key: 1 };
//#endregion
//#region src/v2/features/app/App.vue
var App_default = /* @__PURE__ */ defineComponent({
	__name: "App",
	props: {
		layout: {},
		plugins: { default: () => [] },
		getAppState: { type: Function },
		getCommandPaletteState: { type: Function },
		fetchRegistryDocument: { type: Function }
	},
	setup(__props, { expose: __expose }) {
		__expose({ openCreateWorkspace: () => createWorkspaceModalState.show() });
		const app = __props.getAppState();
		const paletteState = __props.getCommandPaletteState();
		/** Expose workspace store to window for debugging purposes. */
		if (typeof window !== "undefined") {
			window.dataDumpWorkspace = () => app.store.value;
			window.dumpAppState = () => app;
		}
		/** Register global hotkeys for the app, passing the workspace event bus and layout state */
		useGlobalHotKeys(app.eventBus, __props.layout);
		/** Watch the active document for changes and rebase it with its remote source */
		useDocumentWatcher({
			documentName: () => app.store.value?.workspace[extensions.workspace.activeDocument],
			store: app.store,
			initialTimeout: 5e3
		});
		/** Color mode */
		useColorMode({ workspaceStore: app.store });
		/** Setup monaco editor configuration */
		useMonacoEditorConfiguration({
			theme: computed(() => app.theme.styles.value.themeStyles),
			darkMode: computed(() => app.isDarkMode.value)
		});
		const navigateToWorkspaceOverview = (namespace, slug) => {
			app.eventBus.emit("ui:navigate", {
				page: "workspace",
				path: "environment",
				namespace,
				workspaceSlug: slug
			});
		};
		/** Sets the active workspace by ID: finds the workspace in the list and updates app state & navigation. */
		const setActiveWorkspace = (id) => {
			if (!id) return;
			const workspace = app.workspace.workspaceList.value?.find((workspace) => workspace.id === id);
			if (!workspace) return;
			navigateToWorkspaceOverview(workspace.namespace, workspace.slug);
		};
		const createWorkspaceModalState = useModal();
		/** Props to pass to the RouterView component. */
		const routerViewProps = computed(() => {
			/** Ensure we have the auth store */
			const securitySchemes = app.store.value?.auth ? mergeSecurity(app.document.value?.components?.securitySchemes ?? {}, {}, app.store.value.auth, app.activeEntities.documentSlug.value ?? "") : {};
			return {
				documentSlug: app.activeEntities.documentSlug.value ?? "",
				document: app.store.value?.workspace.activeDocument ?? null,
				environment: app.environment.value,
				eventBus: app.eventBus,
				exampleName: app.activeEntities.exampleName.value,
				fetchRegistryDocument: __props.fetchRegistryDocument,
				layout: __props.layout,
				method: app.activeEntities.method.value,
				path: app.activeEntities.path.value,
				workspaceStore: app.store.value,
				activeWorkspace: app.workspace.activeWorkspace.value,
				plugins: __props.plugins,
				securitySchemes,
				isDarkMode: app.isDarkMode.value,
				currentTheme: app.theme.styles.value.themeStyles,
				customThemes: toValue(app.theme.customThemes)
			};
		});
		return (_ctx, _cache) => {
			return openBlock(), createBlock(unref(ScalarTeleportRoot), null, {
				default: withCtx(() => [
					createElementVNode("div", { innerHTML: unref(app).theme.themeStyleTag.value }, null, 8, _hoisted_1),
					createVNode(unref(ScalarToasts)),
					unref(app).store.value !== null && unref(app).workspace.activeWorkspace.value !== null && !unref(app).loading.value ? (openBlock(), createElementBlock("main", _hoisted_2, [
						createElementVNode("div", _hoisted_3, [createVNode(unref(SidebarToggle_default), {
							modelValue: unref(app).sidebar.isOpen.value,
							"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => unref(app).sidebar.isOpen.value = $event),
							class: "absolute top-4 left-3 z-[60] md:hidden"
						}, null, 8, ["modelValue"]), createElementVNode("div", _hoisted_4, [createVNode(AppSidebar_default, {
							isSidebarOpen: unref(app).sidebar.isOpen.value,
							"onUpdate:isSidebarOpen": _cache[1] || (_cache[1] = ($event) => unref(app).sidebar.isOpen.value = $event),
							activeWorkspace: unref(app).workspace.activeWorkspace.value,
							eventBus: unref(app).eventBus,
							isWorkspaceOpen: unref(app).workspace.isOpen.value,
							layout: __props.layout,
							sidebarState: unref(app).sidebar.state,
							sidebarWidth: unref(app).sidebar.width.value,
							store: unref(app).store.value,
							workspaces: unref(app).workspace.workspaceGroups.value,
							"onClick:workspace": navigateToWorkspaceOverview,
							"onCreate:workspace": _cache[2] || (_cache[2] = ($event) => unref(createWorkspaceModalState).show()),
							"onSelect:workspace": setActiveWorkspace,
							onSelectItem: unref(app).sidebar.handleSelectItem,
							"onUpdate:sidebarWidth": unref(app).sidebar.handleSidebarWidthUpdate
						}, {
							sidebarMenuActions: withCtx(() => [renderSlot(_ctx.$slots, "sidebar-menu-actions")]),
							_: 3
						}, 8, [
							"isSidebarOpen",
							"activeWorkspace",
							"eventBus",
							"isWorkspaceOpen",
							"layout",
							"sidebarState",
							"sidebarWidth",
							"store",
							"workspaces",
							"onSelectItem",
							"onUpdate:sidebarWidth"
						]), createElementVNode("div", _hoisted_5, [__props.layout === "desktop" ? (openBlock(), createBlock(DesktopTabs_default, {
							key: 0,
							activeTabIndex: unref(app).tabs.activeTabIndex.value,
							eventBus: unref(app).eventBus,
							tabs: unref(app).tabs.state.value
						}, null, 8, [
							"activeTabIndex",
							"eventBus",
							"tabs"
						])) : createCommentVNode("", true), createElementVNode("div", _hoisted_6, [createVNode(unref(RouterView), normalizeProps(guardReactiveProps(routerViewProps.value)), null, 16)])])])]),
						renderSlot(_ctx.$slots, "create-workspace", { state: unref(createWorkspaceModalState) }, () => [createVNode(CreateWorkspaceModal_default, {
							state: unref(createWorkspaceModalState),
							"onCreate:workspace": _cache[3] || (_cache[3] = (payload) => unref(app).workspace.create(payload))
						}, null, 8, ["state"])]),
						createVNode(TheCommandPalette_default, {
							eventBus: unref(app).eventBus,
							paletteState: unref(paletteState),
							workspaceStore: unref(app).store.value
						}, null, 8, [
							"eventBus",
							"paletteState",
							"workspaceStore"
						])
					])) : (openBlock(), createElementBlock("main", _hoisted_7, [createVNode(SplashScreen_default)]))
				]),
				_: 3
			});
		};
	}
});
//#endregion
export { workspaceStorage as i, CreateWorkspaceModal_default as n, createAppState as r, App_default as t };

//# sourceMappingURL=App-CvClwSlM.js.map