import { e as ensure_array_like, a as attr, b as attr_class, s as store_get, c as escape_html, u as unsubscribe_stores, d as attr_style, f as stringify, g as derived } from './dev-BNpEUZI3.js';
import 'node:module';
import { p as page } from './stores-CdeEEU9O.js';
import './client-CW9E6S_J.js';
import './internal-DYSVC9SL.js';
import '@sveltejs/kit/internal';
import './index-server-DocJvixA.js';
import './chunk-DDP5xfzh.js';
import '@sveltejs/kit/internal/server';

//#region src/lib/components/ProjectSelector.svelte
function ProjectSelector($$renderer, $$props) {
	$$renderer.component(($$renderer) => {
		/**
		* ProjectSelector — header dropdown for switching the active CLEO project.
		*
		* Displays the current project name with a colored chip and chevron.
		* Opens a searchable, filterable dropdown panel.  Switching POSTs to
		* /api/project/switch and reloads the page on success.
		*
		* @task T646
		*/
		/** Shape returned by listRegisteredProjects(). */
		let { projects, activeProjectId } = $$props;
		let isOpen = false;
		const activeProject = derived(() => projects.find((p) => p.projectId === activeProjectId) ?? null);
		/**
		* Chip colour tokens, resolved via `getComputedStyle` from
		* `tokens.css`. Using tokens (not raw hex) keeps the hash-to-colour
		* projection stable under dark / light theme swaps without leaking
		* literals into the component source. `--chip-1..8` fall back to
		* semantic tokens for the common rainbow progression.
		*
		* Order mirrors the historical raw-hex table so the name → chip
		* hash stays deterministic across the T990 tokenisation pass.
		*/
		const CHIP_COLOR_VARS = [
			"var(--info)",
			"var(--success)",
			"var(--warning)",
			"var(--accent)",
			"var(--priority-critical)",
			"var(--edge-definition)",
			"var(--edge-structural)",
			"var(--edge-extends)"
		];
		function chipColor(name) {
			return CHIP_COLOR_VARS[(name.charCodeAt(0) || 0) % CHIP_COLOR_VARS.length] ?? "var(--accent)";
		}
		function chipLetter(name) {
			return (name[0] ?? "?").toUpperCase();
		}
		$$renderer.push(`<div class="project-selector svelte-t4k058"><button type="button"${attr_class("trigger svelte-t4k058", void 0, { "open": isOpen })} aria-haspopup="listbox"${attr("aria-expanded", isOpen)}${attr("title", activeProject() ? activeProject().projectPath : "Select project")}>`);
		if (activeProject()) {
			$$renderer.push("<!--[0-->");
			$$renderer.push(`<span class="chip svelte-t4k058"${attr_style(`background: ${stringify(chipColor(activeProject().name))}`)} aria-hidden="true">${escape_html(chipLetter(activeProject().name))}</span> <span class="trigger-name svelte-t4k058">${escape_html(activeProject().name)}</span>`);
		} else {
			$$renderer.push("<!--[-1-->");
			$$renderer.push(`<span class="chip placeholder svelte-t4k058" aria-hidden="true">?</span> <span class="trigger-name muted svelte-t4k058">Select project</span>`);
		}
		$$renderer.push(`<!--]--> <svg${attr_class("chevron svelte-t4k058", void 0, { "rotated": isOpen })} width="10" height="10" viewBox="0 0 10 10" fill="none" aria-hidden="true"><path d="M2 3.5L5 6.5L8 3.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg></button> `);
		$$renderer.push("<!--[-1-->");
		$$renderer.push(`<!--]--></div>`);
	});
}
//#endregion
//#region src/routes/+layout.svelte
function _layout($$renderer, $$props) {
	$$renderer.component(($$renderer) => {
		var $$store_subs;
		let { data, children } = $$props;
		const consoleHref = derived(() => data.activeProjectId ? `/studio/${data.activeProjectId}` : "/projects");
		const navItems = derived(() => [
			{
				href: "/brain",
				label: "Brain",
				description: "5-substrate living canvas",
				exact: true
			},
			{
				href: "/brain/overview",
				label: "Memory",
				description: "BRAIN dashboard (decisions, observations, quality)",
				exact: false
			},
			{
				href: "/code",
				label: "Code",
				description: "Code intelligence",
				exact: false
			},
			{
				href: "/tasks",
				label: "Tasks",
				description: "Task management",
				exact: false
			},
			{
				href: "/tasks/kanban",
				label: "Board",
				description: "Agent-lifecycle dispatcher board (read-only)",
				exact: false
			},
			{
				href: consoleHref(),
				label: "Console",
				description: "Saga operator console — workgraph + live dispatcher board",
				exact: false
			},
			{
				href: "/settings/vault",
				label: "Vault",
				description: "Service vault — connected services + agent grants (read-only)",
				exact: false
			},
			{
				href: "/projects",
				label: "Admin",
				description: "Project registry — scan, index, and manage projects",
				exact: false
			}
		]);
		$$renderer.push(`<a class="skip-link" href="#main">Skip to content</a> <div class="studio-shell svelte-12qhfyh"><header class="studio-header svelte-12qhfyh"><a href="/" class="studio-logo svelte-12qhfyh"><span class="logo-mark svelte-12qhfyh">C</span> <span class="logo-text svelte-12qhfyh">CLEO Studio</span></a> `);
		ProjectSelector($$renderer, {
			projects: data.projects,
			activeProjectId: data.activeProjectId
		});
		$$renderer.push(`<!----> <nav class="studio-nav svelte-12qhfyh" aria-label="Primary"><!--[-->`);
		const each_array = ensure_array_like(navItems());
		for (let $$index = 0, $$length = each_array.length; $$index < $$length; $$index++) {
			let item = each_array[$$index];
			$$renderer.push(`<a${attr("href", item.href)}${attr_class("nav-link svelte-12qhfyh", void 0, { "active": item.exact ? store_get($$store_subs ??= {}, "$page", page).url.pathname === item.href : store_get($$store_subs ??= {}, "$page", page).url.pathname.startsWith(item.href) })}${attr("title", item.description)}${attr("aria-current", item.exact ? store_get($$store_subs ??= {}, "$page", page).url.pathname === item.href ? "page" : void 0 : store_get($$store_subs ??= {}, "$page", page).url.pathname.startsWith(item.href) ? "page" : void 0)}>${escape_html(item.label)}</a>`);
		}
		$$renderer.push(`<!--]--></nav></header> <main id="main" class="studio-main svelte-12qhfyh" tabindex="-1">`);
		children($$renderer);
		$$renderer.push(`<!----></main></div>`);
		if ($$store_subs) unsubscribe_stores($$store_subs);
	});
}

export { _layout as default };
//# sourceMappingURL=_layout.svelte-BlW8pTC8.js.map
