import { x as head, e as ensure_array_like, c as escape_html, a as attr, d as attr_style, f as stringify } from './dev-BNpEUZI3.js';
import { C as Card, B as Badge } from './Tabs-DzG6Bn9a.js';
import { E as EmptyState } from './ui-DR8zOSpC.js';
import { V as VerifyQueuePanel, a as PromotionCountdown, T as TierBadge, Q as QualityBar } from './memory2-Cgc_4D5q.js';
import 'node:module';

//#region src/routes/brain/overview/+page.svelte
function _page($$renderer, $$props) {
	$$renderer.component(($$renderer) => {
		let { data } = $$props;
		function tableShort(t) {
			return t.replace("brain_", "");
		}
		function barMax(dist) {
			let max = 1;
			for (const d of dist) {
				const total = d.short + d.medium + d.long;
				if (total > max) max = total;
			}
			return max;
		}
		function pct(value, max) {
			if (max === 0) return 0;
			return Math.round(value / max * 100);
		}
		head("1x5k1qb", $$renderer, ($$renderer) => {
			$$renderer.title(($$renderer) => {
				$$renderer.push(`<title>BRAIN — CLEO Studio</title>`);
			});
		});
		$$renderer.push(`<section class="overview svelte-1x5k1qb"><header class="view-head svelte-1x5k1qb"><div class="view-ident svelte-1x5k1qb"><div class="view-icon svelte-1x5k1qb" aria-hidden="true">B</div> <div><h1 class="view-title svelte-1x5k1qb">BRAIN</h1> <p class="view-sub svelte-1x5k1qb">Cognitive memory · observations · decisions · patterns · learnings</p></div></div> <nav class="view-nav svelte-1x5k1qb" aria-label="Brain navigation"><a href="/brain" class="nav-pill nav-pill--canvas svelte-1x5k1qb">Open in Canvas →</a> <a href="/brain/search" class="nav-pill svelte-1x5k1qb">Search</a> <a href="/brain/causal" class="nav-pill svelte-1x5k1qb">Causal</a> <a href="/brain/tier-stats" class="nav-pill svelte-1x5k1qb">Tier stats</a> <a href="/brain/quality" class="nav-pill svelte-1x5k1qb">Quality</a> <a href="/brain/graph" class="nav-pill svelte-1x5k1qb">Graph</a></nav></header> `);
		if (!data.stats) {
			$$renderer.push("<!--[0-->");
			EmptyState($$renderer, {
				title: "brain.db not found",
				subtitle: "Start a CLEO session to populate memory; this view will light up as entries are recorded."
			});
		} else {
			$$renderer.push("<!--[-1-->");
			$$renderer.push(`<div class="stats-grid svelte-1x5k1qb"><!--[-->`);
			const each_array = ensure_array_like(data.stats);
			for (let $$index = 0, $$length = each_array.length; $$index < $$length; $$index++) {
				let stat = each_array[$$index];
				$$renderer.push(`<article class="stat svelte-1x5k1qb"><span class="stat-value svelte-1x5k1qb">${escape_html(stat.value)}</span> <span class="stat-label svelte-1x5k1qb">${escape_html(stat.label)}</span></article>`);
			}
			$$renderer.push(`<!--]--></div> `);
			if (data.tierDistribution.length > 0) {
				$$renderer.push("<!--[0-->");
				const maxCount = barMax(data.tierDistribution);
				{
					function header($$renderer) {
						$$renderer.push(`<div class="panel-head svelte-1x5k1qb"><h2 class="panel-title svelte-1x5k1qb">Tier distribution by table</h2> <div class="legend svelte-1x5k1qb">`);
						TierBadge($$renderer, { tier: "short" });
						$$renderer.push(`<!----> `);
						TierBadge($$renderer, { tier: "medium" });
						$$renderer.push(`<!----> `);
						TierBadge($$renderer, { tier: "long" });
						$$renderer.push(`<!----></div></div>`);
					}
					Card($$renderer, {
						header,
						children: ($$renderer) => {
							$$renderer.push(`<div class="chart-rows svelte-1x5k1qb"><!--[-->`);
							const each_array_1 = ensure_array_like(data.tierDistribution);
							for (let $$index_1 = 0, $$length = each_array_1.length; $$index_1 < $$length; $$index_1++) {
								let dist = each_array_1[$$index_1];
								$$renderer.push(`<a class="chart-row svelte-1x5k1qb"${attr("href", `/brain/${tableShort(dist.table)}`)}><span class="chart-label svelte-1x5k1qb">${escape_html(tableShort(dist.table))}</span> <div class="chart-bars svelte-1x5k1qb" aria-hidden="true">`);
								if (dist.short > 0) {
									$$renderer.push("<!--[0-->");
									$$renderer.push(`<span class="seg seg-short svelte-1x5k1qb"${attr_style(`width:${stringify(pct(dist.short, maxCount))}%`)}>`);
									if (pct(dist.short, maxCount) > 12) {
										$$renderer.push("<!--[0-->");
										$$renderer.push(`<span class="seg-n svelte-1x5k1qb">${escape_html(dist.short)}</span>`);
									} else $$renderer.push("<!--[-1-->");
									$$renderer.push(`<!--]--></span>`);
								} else $$renderer.push("<!--[-1-->");
								$$renderer.push(`<!--]--> `);
								if (dist.medium > 0) {
									$$renderer.push("<!--[0-->");
									$$renderer.push(`<span class="seg seg-medium svelte-1x5k1qb"${attr_style(`width:${stringify(pct(dist.medium, maxCount))}%`)}>`);
									if (pct(dist.medium, maxCount) > 12) {
										$$renderer.push("<!--[0-->");
										$$renderer.push(`<span class="seg-n svelte-1x5k1qb">${escape_html(dist.medium)}</span>`);
									} else $$renderer.push("<!--[-1-->");
									$$renderer.push(`<!--]--></span>`);
								} else $$renderer.push("<!--[-1-->");
								$$renderer.push(`<!--]--> `);
								if (dist.long > 0) {
									$$renderer.push("<!--[0-->");
									$$renderer.push(`<span class="seg seg-long svelte-1x5k1qb"${attr_style(`width:${stringify(pct(dist.long, maxCount))}%`)}>`);
									if (pct(dist.long, maxCount) > 12) {
										$$renderer.push("<!--[0-->");
										$$renderer.push(`<span class="seg-n svelte-1x5k1qb">${escape_html(dist.long)}</span>`);
									} else $$renderer.push("<!--[-1-->");
									$$renderer.push(`<!--]--></span>`);
								} else $$renderer.push("<!--[-1-->");
								$$renderer.push(`<!--]--> `);
								if (dist.short === 0 && dist.medium === 0 && dist.long === 0) {
									$$renderer.push("<!--[0-->");
									$$renderer.push(`<span class="seg-empty svelte-1x5k1qb">empty</span>`);
								} else $$renderer.push("<!--[-1-->");
								$$renderer.push(`<!--]--></div> <span class="chart-total svelte-1x5k1qb">${escape_html(dist.short + dist.medium + dist.long)}</span></a>`);
							}
							$$renderer.push(`<!--]--></div>`);
						}});
				}
			} else $$renderer.push("<!--[-1-->");
			$$renderer.push(`<!--]--> <div class="dual svelte-1x5k1qb">`);
			{
				function header($$renderer) {
					$$renderer.push(`<div><h2 class="panel-title svelte-1x5k1qb">Upcoming long-tier promotions</h2> <span class="panel-sub svelte-1x5k1qb">Medium entries eligible after the 7-day citation gate</span></div>`);
				}
				Card($$renderer, {
					header,
					children: ($$renderer) => {
						if (data.upcomingPromotions.length === 0) {
							$$renderer.push("<!--[0-->");
							EmptyState($$renderer, {
								title: "Nothing queued",
								subtitle: "Entries need ≥ 7 days age plus citation ≥ 5 (or owner-verified) to promote."
							});
						} else {
							$$renderer.push("<!--[-1-->");
							$$renderer.push(`<ul class="promo-list svelte-1x5k1qb"><!--[-->`);
							const each_array_2 = ensure_array_like(data.upcomingPromotions);
							for (let $$index_2 = 0, $$length = each_array_2.length; $$index_2 < $$length; $$index_2++) {
								let promo = each_array_2[$$index_2];
								$$renderer.push(`<li class="promo-row svelte-1x5k1qb"><code class="promo-id svelte-1x5k1qb">${escape_html(promo.id)}</code> <span class="promo-table svelte-1x5k1qb">${escape_html(tableShort(promo.table))}</span> `);
								Badge($$renderer, {
									tone: "accent",
									size: "sm",
									subtle: true,
									children: ($$renderer) => {
										$$renderer.push(`<!---->${escape_html(promo.track)}`);
									}});
								$$renderer.push(`<!----> <div class="promo-end svelte-1x5k1qb">`);
								PromotionCountdown($$renderer, { daysUntil: promo.daysUntil });
								$$renderer.push(`<!----></div></li>`);
							}
							$$renderer.push(`<!--]--></ul>`);
						}
						$$renderer.push(`<!--]-->`);
					}});
			}
			$$renderer.push(`<!----> `);
			VerifyQueuePanel($$renderer, { limit: 6 });
			$$renderer.push(`<!----></div> <div class="dual svelte-1x5k1qb">`);
			{
				function header($$renderer) {
					$$renderer.push(`<div class="panel-head svelte-1x5k1qb"><h2 class="panel-title svelte-1x5k1qb">Recent observations</h2> <a class="panel-link svelte-1x5k1qb" href="/brain/observations">See all →</a></div>`);
				}
				Card($$renderer, {
					header,
					children: ($$renderer) => {
						if (data.recentObservations.length === 0) {
							$$renderer.push("<!--[0-->");
							EmptyState($$renderer, { title: "No observations yet" });
						} else {
							$$renderer.push("<!--[-1-->");
							$$renderer.push(`<ul class="recent-list svelte-1x5k1qb"><!--[-->`);
							const each_array_3 = ensure_array_like(data.recentObservations);
							for (let $$index_3 = 0, $$length = each_array_3.length; $$index_3 < $$length; $$index_3++) {
								let o = each_array_3[$$index_3];
								$$renderer.push(`<li class="recent-row svelte-1x5k1qb"><span class="recent-head svelte-1x5k1qb"><code class="recent-id svelte-1x5k1qb">${escape_html(o.id)}</code> `);
								TierBadge($$renderer, { tier: o.memory_tier });
								$$renderer.push(`<!----> `);
								Badge($$renderer, {
									tone: "info",
									size: "sm",
									subtle: true,
									children: ($$renderer) => {
										$$renderer.push(`<!---->${escape_html(o.type)}`);
									}});
								$$renderer.push(`<!----> <span class="recent-date svelte-1x5k1qb">${escape_html(o.created_at.slice(0, 10))}</span></span> <span class="recent-body svelte-1x5k1qb"><span class="recent-title svelte-1x5k1qb">${escape_html(o.title)}</span> `);
								QualityBar($$renderer, {
									score: o.quality_score,
									width: 60,
									showLabel: false
								});
								$$renderer.push(`<!----></span></li>`);
							}
							$$renderer.push(`<!--]--></ul>`);
						}
						$$renderer.push(`<!--]-->`);
					}});
			}
			$$renderer.push(`<!----> `);
			{
				function header($$renderer) {
					$$renderer.push(`<div class="panel-head svelte-1x5k1qb"><h2 class="panel-title svelte-1x5k1qb">Recent decisions</h2> <a class="panel-link svelte-1x5k1qb" href="/brain/decisions">See all →</a></div>`);
				}
				Card($$renderer, {
					header,
					children: ($$renderer) => {
						if (data.recentDecisions.length === 0) {
							$$renderer.push("<!--[0-->");
							EmptyState($$renderer, { title: "No decisions yet" });
						} else {
							$$renderer.push("<!--[-1-->");
							$$renderer.push(`<ul class="recent-list svelte-1x5k1qb"><!--[-->`);
							const each_array_4 = ensure_array_like(data.recentDecisions);
							for (let $$index_4 = 0, $$length = each_array_4.length; $$index_4 < $$length; $$index_4++) {
								let d = each_array_4[$$index_4];
								$$renderer.push(`<li class="recent-row svelte-1x5k1qb"><span class="recent-head svelte-1x5k1qb"><code class="recent-id svelte-1x5k1qb">${escape_html(d.id)}</code> `);
								TierBadge($$renderer, { tier: d.memory_tier });
								$$renderer.push(`<!----> `);
								Badge($$renderer, {
									tone: d.confidence === "high" ? "success" : d.confidence === "low" ? "danger" : "warning",
									size: "sm",
									children: ($$renderer) => {
										$$renderer.push(`<!---->${escape_html(d.confidence ?? "unknown")}`);
									}});
								$$renderer.push(`<!----> <span class="recent-date svelte-1x5k1qb">${escape_html(d.created_at.slice(0, 10))}</span></span> <span class="recent-body svelte-1x5k1qb"><span class="recent-title svelte-1x5k1qb">${escape_html(d.decision)}</span></span></li>`);
							}
							$$renderer.push(`<!--]--></ul>`);
						}
						$$renderer.push(`<!--]-->`);
					}});
			}
			$$renderer.push(`<!----></div> <div class="actions svelte-1x5k1qb"><a href="/brain/graph" class="action svelte-1x5k1qb"><span class="action-icon svelte-1x5k1qb">G</span> <span class="action-body svelte-1x5k1qb"><span class="action-title svelte-1x5k1qb">Knowledge graph</span> <span class="action-desc svelte-1x5k1qb">Force-directed view of the full substrate</span></span></a> <a href="/brain/decisions" class="action svelte-1x5k1qb"><span class="action-icon svelte-1x5k1qb">D</span> <span class="action-body svelte-1x5k1qb"><span class="action-title svelte-1x5k1qb">Decisions</span> <span class="action-desc svelte-1x5k1qb">Timeline with rationale + outcomes</span></span></a> <a href="/brain/observations" class="action svelte-1x5k1qb"><span class="action-icon svelte-1x5k1qb">O</span> <span class="action-body svelte-1x5k1qb"><span class="action-title svelte-1x5k1qb">Observations</span> <span class="action-desc svelte-1x5k1qb">Filter by tier, type, and quality</span></span></a> <a href="/brain/patterns" class="action svelte-1x5k1qb"><span class="action-icon svelte-1x5k1qb">P</span> <span class="action-body svelte-1x5k1qb"><span class="action-title svelte-1x5k1qb">Patterns</span> <span class="action-desc svelte-1x5k1qb">Recurring workflow signals</span></span></a> <a href="/brain/learnings" class="action svelte-1x5k1qb"><span class="action-icon svelte-1x5k1qb">L</span> <span class="action-body svelte-1x5k1qb"><span class="action-title svelte-1x5k1qb">Learnings</span> <span class="action-desc svelte-1x5k1qb">Actionable insights with confidence</span></span></a> <a href="/brain/search" class="action svelte-1x5k1qb"><span class="action-icon svelte-1x5k1qb">S</span> <span class="action-body svelte-1x5k1qb"><span class="action-title svelte-1x5k1qb">Search</span> <span class="action-desc svelte-1x5k1qb">Cross-table FTS retrieval</span></span></a> <a href="/brain/causal" class="action svelte-1x5k1qb"><span class="action-icon svelte-1x5k1qb">C</span> <span class="action-body svelte-1x5k1qb"><span class="action-title svelte-1x5k1qb">Causal reasoning</span> <span class="action-desc svelte-1x5k1qb">Trace blocker chains to the root</span></span></a> <a href="/brain/tier-stats" class="action svelte-1x5k1qb"><span class="action-icon svelte-1x5k1qb">T</span> <span class="action-body svelte-1x5k1qb"><span class="action-title svelte-1x5k1qb">Tier stats</span> <span class="action-desc svelte-1x5k1qb">Retention split + verify queue</span></span></a></div>`);
		}
		$$renderer.push(`<!--]--></section>`);
	});
}

export { _page as default };
//# sourceMappingURL=_page.svelte-BVVTrzTL.js.map
