// ---------------------------------------------------------------------------
// home/HomePage.tsx — WAVE 23 item 9 (ruling R7, contract C10): the landing.
//
// The layout is `reference/Airtable Home.png`, in OUR tokens: an `h1`, a row of
// quick-start cards, then the recently-opened databases under Today / Past 7
// days / Older, with a list/grid toggle. Nothing is copied but the ANATOMY —
// every colour, size and weight is the Loopable palette (R1's rule for the
// builder, applied here for the same reason).
//
// ⛔ THIS PAGE IS CHROME, NOT A GRANTED SURFACE, and the distinction is the one
// the shell's oldest law turns on (`Shell.tsx` :1039 — "the nav is
// server-filtered and an undeclared surface is denied"). Home does not violate
// that law because it cannot: every database it names is resolved from the
// `entries` the server returned (`homeModel.groupRecents` drops a recent whose
// key is not in them), and the four cards open doors the rail already offered.
// There is no payload here that `GET /nav` did not send.
//
// It holds NO state of its own beyond the layout toggle. The recents come down
// with the nav; the four actions are the frame's, because the frame owns the
// dialogs and the hash.
// ---------------------------------------------------------------------------
import { useEffect, useState } from "react";
import { FolderMark } from "../customer-grid/icons";
// ⭐ WAVE 26 · ITEM 18 / R14 + C7 — THE LOOP MARK ON HOME'S FOURTH `.auto-dot` SITE.
// The scout table named three call sites; this is the fourth, found by SESSION B and handed over
// rather than reached across the fence. Same rule as the rail: consume the component that points
// at the generated artifact, never inline the path ([[loopable-nav-logo-toggle]] — one element
// paints the mark).
import { AGENTS_MODULE_LABEL } from "../inbox/inboxModel";
import { Mark } from "../shell/Brand";
import { dbChipClass } from "../shell/nav";
import type { DatabaseEntry, Recent } from "../shell/nav";
// ⭐ WAVE 35 · W35-T15 (R4, C2) — ONE STAR CONTROL, drawn in the module that owns the concept and
// worn by both surfaces. R4 makes star and "mark important" one idea and one flag; a second star
// component here would be the "one mark, one meaning" failure DESIGN.md 4 names, and `useStarred`
// is what keeps Home and Starred from ending up with different ideas of what is starred.
import { StarButton, Tile } from "../starred/StarredPage";
import { shapeStarred, useStarred, viewCount } from "../starred/starredApi";
import type { StarKind, Starred, StarredCounts, StarredLoad } from "../starred/starredApi";
import {
HOME_LAYOUT_KEY,
allDatabases,
parseLayout,
} from "./homeModel";
import type { AutomationTile, HomeLayout } from "./homeModel";
// ── the four quick-start marks ───────────────────────────────────────────────────────────────
//
// Drawn here, in the same 16x16 stroke vocabulary as the rail's `DbIcon`/`AutoIcon`/`BellIcon`
// — the established pattern in this tree (the shell and the alerts pane each draw their own
// bell rather than sharing an icon module). DESIGN.md's rule is "extend the set, don't import a
// new icon language", and these are the same language: 16x16, `currentColor` strokes, no fills,
// no emoji.
/** Templates — stacked sheets, the thing a template gives you. */
function TemplateIcon() {
return (
);
}
/** A blank database — the rail's cylinder with the plus that makes one. */
function NewDbIcon() {
return (
);
}
/*
* ⭐ WAVE 26 · ITEM 18 / R14 — `AutomationIcon` STOOD HERE AND IS DELETED WITH THE DOT.
*
* It drew two nodes and the edge between them. R14 replaces it with the Loopable loop mark on
* the grounds that *"these automations are basically loops"* — so the tile's chip now carries the
* same mark the rail does, and this hand-inlined path had no second caller left. (It had already
* survived one deletion: wave 25 R8 removed the "Automated database" card and KEPT this because
* the tiles still used it. The tiles no longer do.)
*
* ⛔ NOT REPLACED BY A NEW SVG. C7 is explicit — consume the existing component. The mark's one
* source of truth is generated, and `shell/Brand.tsx`'s header records that a hand-redrawn copy
* silently painted LAST WAVE'S BRAND while a comment claimed parity.
*/
/**
* Connect a source — a two-prong plug with a cord, which is the thing you put in an outlet.
*
* ⭐ WAVE 35 · W35-T15 (owner item 5): *"change the Icon for the connector to look like the cable
* head that you would put in an electrical outlet."* It drew two links of a CHAIN until now, and
* so does its twin on the rail (`shell/Shell.tsx::PlugIcon`, whose NAME has been wrong since wave
* 23). The prongs are the load-bearing part of the drawing; the cord is what stops it reading as
* a padlock at 16px.
*
* ⛔ THE TWO COPIES MUST NOT DIVERGE and they are in two different fences, so the geometry below
* was published in mailbox B-5 as an ASK to the session that owns the rail (W35-T04) rather than
* changed here and hoped about. One glyph, one meaning; two plugs that disagree is worse than the
* chain, because at least the chain was wrong in both places identically.
*/
function ConnectIcon() {
return (
);
}
/** The two layout marks: rows, and a 2x2 of tiles. The reference pair, in our stroke weight. */
function ListIcon() {
return (
);
}
function GridIcon() {
return (
);
}
/**
* One quick-start card. A `