body", () => {
+ it("renders the problem statement as markdown", () => {
+ expect(view()).toMatch(/class="md-doc wt-problem">Panes cost more and nothing<\/code>/);
+ });
+ it("numbers the contents and the stops, and marks reviewed ones in the contents", () => {
+ const html = view({}, { reviewed: { "Adds a gauge": firstSig } });
+ expect(html).toContain('1. ');
+ expect(html).toContain('2. ');
+ // The ✓ sits on the reviewed entry, and only there.
+ expect(html).toMatch(/Adds a gauge<\/span>2. Reuses the cache');
+ });
+ it("colors each card by its kind", () => {
+ const html = view();
+ expect(html).toContain('class="wt-stop wt-kind-system-touch"');
+ expect(html).toContain('class="wt-stop wt-kind-reuse"');
+ });
+ it("draws a stop's diagrams in their own row, out of the prose", () => {
+ const html = view();
+ expect(count(html, 'class="wt-diagrams"')).toBe(1);
+ expect(count(html, 'class="md-mermaid"')).toBe(1);
+ expect(html).toMatch(/class="wt-diagrams"> {
+ const html = view();
+ expect(count(html, 'class="wt-cols"')).toBe(2);
+ expect(html).toContain('
one.py ');
+ expect(html).toContain('
1 change ');
+ expect(html).toContain("
1 not in this diff ");
+ });
+ it("lists files without hunks when there is no worktree", () => {
+ const html = view({ diff: null, stale_by: null });
+ expect(html).toContain('
missing.py ');
+ expect(html).toContain("no worktree, so code changes are unavailable");
+ expect(html).not.toContain("wt-file-count");
+ });
+ it("folds a reviewed stop to its title row, and only while its sig matches", () => {
+ const folded = view({}, { reviewed: { "Adds a gauge": firstSig } });
+ expect(folded).toContain('class="wt-stop wt-kind-system-touch is-folded"');
+ expect(folded).toContain('class="wt-fold"');
+ expect(folded).not.toContain("Prose one.");
+ expect(folded).toContain("Prose two.");
+ expect(folded).toContain("1 / 2 reviewed");
+ expect(view({}, { reviewed: { "Adds a gauge": "00000000" } })).toContain("Prose one.");
+ });
+ it("collapses the comment box to a link", () => {
+ const html = view();
+ expect(count(html, '
comment ')).toBe(2);
+ expect(html).not.toContain("
');
+ expect(html).toContain('
send ');
+ expect(html).toContain('
cancel ');
+ expect(html).toMatch(/
(⌘|Ctrl\+)↩ to send<\/span>/);
+ expect(render(
+ {}} onSend={() => {}} onCancel={() => {}} />,
+ )).toMatch(/send<\/button>/);
+ });
+ it("sendHint names the keys for the platform", () => {
+ expect(sendHint("MacIntel")).toBe("⌘↩ to send");
+ expect(sendHint("Win32")).toBe("Ctrl+↩ to send");
+ expect(sendHint(undefined)).toBe("Ctrl+↩ to send");
+ });
+ it("commentOutcome closes the box on delivery or save, and keeps the text on error", () => {
+ expect(commentOutcome({ ok: true, status: 200, data: {} })).toEqual({ close: true, note: "sent to the owning pane" });
+ expect(commentOutcome({ ok: false, status: 409, data: { detail: "no pane" } })).toEqual({ close: true, note: "saved, no pane" });
+ expect(commentOutcome({ ok: false, status: 500, data: {} })).toEqual({ close: false, note: "HTTP 500" });
+ });
+});
+````
+
+- [ ] **Step 2: Run it to verify it fails**
+
+Run: `npx vitest run static/src/review/__tests__/walkthroughRender.test.jsx`
+Expected: FAIL. `WalkthroughView`, `ReviewedToggle`, `CommentForm`, `sendHint` and `commentOutcome` are not exported.
+
+- [ ] **Step 3: Rewrite `static/src/review/Walkthrough.jsx`**
+
+Replace the whole file with:
+```jsx
+// The native review walkthrough (THI-443): a fixed header over one scrolling
+// body. Each stop is a card: its title row, its diagrams across the full
+// width, then its prose beside its files and code changes. Reads
+// /api/reviews/walkthrough; the file is the artifact, this is a lens on it
+// (2026-10-26 spec D2). No pane target here, so hunk heads are inert. The
+// lightbox host lives in Overlays.jsx, at the app root.
+import { useEffect, useMemo, useRef, useState } from "preact/hooks";
+import { Hunk, langFor } from "../diff/ChangesTab.jsx";
+import { refreshReviews } from "../poll.js";
+import { Mermaid } from "../split/Mermaid.jsx";
+import { renderMarkdown } from "../split/markdown.jsx";
+import { prStateMeta } from "../util.js";
+import { evidenceFor, evidenceIndex, HIDDEN_WHY, hiddenSummary, isReviewed, parseWalkthrough, stopSig, withMark } from "./walkthrough.js";
+
+async function postJson(url, body) {
+ const res = await fetch(url, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) });
+ const data = await res.json().catch(() => ({}));
+ return { ok: res.ok, status: res.status, data };
+}
+
+// The keys the comment box listens for, named the way this keyboard labels them.
+export function sendHint(platform) {
+ return /Mac|iPhone|iPad/.test(platform || "") ? "⌘↩ to send" : "Ctrl+↩ to send";
+}
+const SEND_HINT = sendHint(typeof navigator === "undefined" ? "" : navigator.platform);
+
+// What a comment POST's result does to the box: a delivered or saved comment
+// closes it; anything else keeps the text so nothing typed is lost.
+export function commentOutcome(r) {
+ if (r.ok) return { close: true, note: "sent to the owning pane" };
+ if (r.status === 409) return { close: true, note: `saved, ${r.data?.detail || "not delivered"}` };
+ return { close: false, note: r.data?.detail || `HTTP ${r.status}` };
+}
+
+// Smooth scrolling unless the viewer asked for less motion.
+const motion = () => (typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth");
+
+const kindOf = (stop) => (stop.knownKind ? stop.kind : "other");
+
+function Comments({ list }) {
+ if (!list.length) return null;
+ return (
+
+ );
+}
+
+// The open box, pure, so a render test can see it.
+export function CommentForm({ stop, text, busy, note, textRef, onInput, onSend, onCancel }) {
+ return (
+
+ );
+}
+
+// Half-typed comments, by stop. Marking a stop reviewed folds it, which unmounts
+// its box (hiding it instead would break mermaid, which can't measure text in a
+// display:none subtree), so a draft must outlive the component.
+const drafts = new Map();
+
+// A "comment" link until used: thirteen always-open boxes buried the stops.
+function CommentBox({ repo, branch, stop, onPosted }) {
+ const draftKey = `${repo}\n${branch}\n${stop}`;
+ const [open, setOpen] = useState(() => drafts.has(draftKey));
+ const [text, setTextState] = useState(() => drafts.get(draftKey) || "");
+ const setText = (v) => {
+ if (v) drafts.set(draftKey, v);
+ else drafts.delete(draftKey);
+ setTextState(v);
+ };
+ const [note, setNote] = useState("");
+ const [busy, setBusy] = useState(false);
+ const textRef = useRef(null);
+ useEffect(() => { if (open) textRef.current?.focus(); }, [open]);
+ async function send() {
+ if (busy || !text.trim()) return;
+ setBusy(true);
+ try {
+ const out = commentOutcome(await postJson("/api/reviews/comment", { repo, branch, stop, body: text }));
+ setNote(out.note);
+ if (out.close) { setText(""); setOpen(false); }
+ onPosted();
+ } catch (e) {
+ setNote(String(e));
+ } finally {
+ setBusy(false);
+ }
+ }
+ if (!open) {
+ return (
+
+ );
+ }
+ return setOpen(false)} />;
+}
+
+// One accessible name in both states: aria-pressed carries the state, and the ✓
+// is decoration (a changing label plus "pressed" would be announced twice).
+export function ReviewedToggle({ on, onToggle, error }) {
+ return (
+
+ {error ? {error} : null}
+
+ {on ? ✓ : null}reviewed
+
+
+ );
+}
+
+// The right column (THI-443 D5): the stop's files, one summary line for the
+// ones with nothing to show, then the hunks expanded.
+function Evidence({ ev, hl, colRef, onGo }) {
+ const summary = hiddenSummary(ev.hidden);
+ if (!ev.shown.length && !summary) return
;
+ return (
+
+
+ {ev.shown.map((e, i) => {
+ const label = (
+ <>
+ {e.name}
+ {e.ref.start != null ? {`:${e.ref.start}${e.ref.end !== e.ref.start ? `-${e.ref.end}` : ""}`} : null}
+ {ev.noDiff ? null : {`${e.hunks.length} change${e.hunks.length === 1 ? "" : "s"}`} }
+ >
+ );
+ return (
+
+ {ev.noDiff
+ ? {label}
+ : onGo(i)}>{label} }
+
+ );
+ })}
+
+ {summary ? (
+
+ {summary}
+
+ {Object.entries(ev.hidden).flatMap(([why, refs]) => refs.map((r, i) => (
+ {r.raw} {` · ${HIDDEN_WHY[why]}`}
+ )))}
+
+
+ ) : null}
+ {ev.noDiff ? no worktree, so code changes are unavailable
: ev.shown.map((e, i) => (
+
+ {e.ref.raw}
+ {e.hunks.map((h, j) => )}
+
+ ))}
+
+ );
+}
+
+function Stop({ stop, n, diffFiles, comments, repo, branch, hl, reviewed, toggleError, onToggleReviewed, onPosted }) {
+ const [unfolded, setUnfolded] = useState(false);
+ const col = useRef(null);
+ const done = isReviewed(stop, reviewed);
+ const folded = done && !unfolded;
+ const ev = evidenceFor(stop.refs, diffFiles);
+ // Wide, the column scrolls on its own, so move it rather than the page.
+ // Otherwise bring the file into view only if it isn't already ("nearest"), so
+ // a column that fits on screen never jumps the page (D5).
+ function goTo(i) {
+ const c = col.current;
+ const el = c?.querySelector(`[data-ev="${i}"]`);
+ if (!el) return;
+ if (c.scrollHeight > c.clientHeight) c.scrollTo({ top: el.offsetTop - 8, behavior: motion() });
+ else el.scrollIntoView({ block: "nearest", behavior: motion() });
+ // Restart the flash even on a second click of the same file: the reflow
+ // between remove and add makes the browser replay the animation.
+ el.classList.remove("is-flash");
+ el.getBoundingClientRect();
+ el.classList.add("is-flash");
+ }
+ const cite = (c) => {
+ const i = ev.noDiff ? -1 : evidenceIndex(ev.shown, c);
+ return (
+ = 0 ? "" : " is-inert"}`}
+ title={i >= 0 ? "show in the code column" : "not among this stop's changes"}
+ onClick={() => { if (i >= 0) goTo(i); }}>{c.raw}
+ );
+ };
+ const title = <>{`${n}.`} {stop.title}>;
+ return (
+
+
+
+ {done
+ ? setUnfolded(!unfolded)}>{title}
+ : title}
+
+ {stop.kind ? {stop.kind} : null}
+ { setUnfolded(false); onToggleReviewed(stop, !done); }} />
+
+ {folded ? null : (
+ <>
+ {stop.diagrams.length ? (
+
+ {/* label: a stop can have 2–3 diagrams, and their ⤢ buttons need telling apart. */}
+ {stop.diagrams.map((code, i) => )}
+
+ ) : null}
+
+
+
+ {renderMarkdown(stop.bodyMarkdown, { demote: false, softBreaks: "space", mermaid: true, meta: true, cite, zoom: true })}
+
+
+
+
+
+
+ >
+ )}
+
+ );
+}
+
+function Contents({ stops, reviewed }) {
+ if (!stops.length) return null;
+ return (
+
+
+ {stops.map((s, i) => (
+
+ {/* A button, not a #link: the URL and periscope's routing stay put. */}
+ document.getElementById(`stop-${s.id}`)?.scrollIntoView({ block: "start", behavior: motion() })}>
+ {`${i + 1}.`}
+
+ {s.title}
+ {isReviewed(s, reviewed) ? ✓ : null}
+
+
+ ))}
+
+
+ );
+}
+
+// stale_by is null both with no worktree (no diff either) and when the
+// worktree no longer has the recorded head (rebased away); the queue calls the
+// second "stale: unknown", and so does this.
+function Staleness({ staleBy, header, diff }) {
+ if (staleBy > 0) return {`stale: ${staleBy} commit${staleBy === 1 ? "" : "s"}`} ;
+ if (staleBy == null && header && !diff) return no worktree ;
+ if (staleBy == null && header && diff) return stale: unknown ;
+ return null;
+}
+
+// The page itself, pure, so render-to-string tests can see every state.
+export function WalkthroughView({ data, repo, branch, pr, hl, reviewed, toggleErrors, error, onToggleReviewed, onPosted }) {
+ const { text, comments, diff, stale_by } = data;
+ // Every mark and refetch re-renders the page; parse only when the text changes.
+ const w = useMemo(() => parseWalkthrough(text), [text]);
+ const byStop = new Map();
+ for (const c of comments) (byStop.get(c.stop) || byStop.set(c.stop, []).get(c.stop)).push(c);
+ const attached = new Set(w.stops.map((s) => s.title));
+ const unattached = comments.filter((c) => !attached.has(c.stop));
+ const done = w.stops.filter((s) => isReviewed(s, reviewed)).length;
+ return (
+
+ );
+}
+
+// `sig` changes when the row's head / staleness / unresolved count does (from
+// the 10 s reviews poll), so a reply, a resolve or a re-prepare refetches the
+// open view instead of leaving it stale until re-selected.
+export function Walkthrough({ repo, branch, pr, sig }) {
+ const [state, setState] = useState({ loading: true, error: null, data: null });
+ const [hl, setHl] = useState(null);
+ const [nonce, setNonce] = useState(0);
+ const [reviewed, setReviewed] = useState({});
+ const [toggleErrors, setToggleErrors] = useState({});
+ // Marks in flight, and marks settled: a refetch must not apply a `reviewed`
+ // it read before a mark landed, whether it arrives mid-POST or just after
+ // ("send a comment, then mark the stop" starts exactly that refetch).
+ const pending = useRef(0);
+ const settled = useRef(0);
+
+ useEffect(() => {
+ let alive = true;
+ import("../preview/highlightCode.jsx").then((m) => { if (alive) setHl(() => m.highlightCode); }).catch(() => {});
+ return () => { alive = false; };
+ }, []);
+
+ useEffect(() => {
+ let alive = true;
+ const marksAtStart = settled.current;
+ (async () => {
+ try {
+ const res = await fetch(`/api/reviews/walkthrough?repo=${encodeURIComponent(repo)}&branch=${encodeURIComponent(branch)}`);
+ const body = await res.json().catch(() => ({}));
+ if (!alive) return;
+ // Keep the last good data on a failed refetch: unmounting every Stop
+ // would drop the open hunks and any half-typed comment.
+ if (!res.ok) { setState((s) => ({ loading: false, error: body.detail || `HTTP ${res.status}`, data: s.data })); return; }
+ setState({ loading: false, error: null, data: body });
+ if (!pending.current && settled.current === marksAtStart) setReviewed(body.reviewed || {});
+ } catch (e) {
+ if (alive) setState((s) => ({ loading: false, error: String(e), data: s.data }));
+ }
+ })();
+ return () => { alive = false; };
+ }, [repo, branch, nonce, sig]);
+
+ const onPosted = () => { setNonce((n) => n + 1); refreshReviews(); };
+
+ async function onToggleReviewed(stop, on) {
+ const s = stopSig(stop);
+ const before = reviewed[stop.title] ?? null;
+ setReviewed((r) => withMark(r, stop.title, on ? s : null));
+ setToggleErrors((e) => ({ ...e, [stop.title]: null }));
+ pending.current++;
+ try {
+ const r = await postJson("/api/reviews/reviewed", { repo, branch, stop: stop.title, sig: s, reviewed: on });
+ if (!r.ok) throw new Error(r.data.detail || `HTTP ${r.status}`);
+ } catch (e) {
+ setReviewed((r) => withMark(r, stop.title, before));
+ setToggleErrors((x) => ({ ...x, [stop.title]: `not saved: ${e.message || e}` }));
+ } finally {
+ pending.current--;
+ settled.current++;
+ }
+ }
+
+ if (state.loading) return loading…
;
+ if (!state.data) return {state.error}
;
+ return (
+
+ );
+}
+```
+
+- [ ] **Step 4: Run the render tests and the review suite**
+
+Run: `npx vitest run static/src/review`
+Expected: all pass. If a markup assertion fails only on attribute order or whitespace, fix the **assertion**, not the component: the tests check structure and text.
+
+- [ ] **Step 5: Lint**
+
+Run: `npx biome lint static/src/review static/src/split`
+Expected: no errors in the touched files. The three existing warnings in `Rail.jsx` and `spawnAccountPickerRender.test.jsx` are not ours.
+
+- [ ] **Step 6: Commit**
+
+```bash
+git add static/src/review/Walkthrough.jsx static/src/review/__tests__/walkthroughRender.test.jsx
+git commit -m "reviews walkthrough: fixed header with staleness badge and progress, contents list, stop cards with a diagram row and prose beside the code column, reviewed marks that fold a stop, collapsed comment box (THI-443)" -m "Co-Authored-By: Claude Opus 5.5 (1M context) "
+```
+
+---
+
+### Task 9: Styles
+
+**Files:**
+- Modify: `static/styles.css`
+
+CSS has no unit tests here. Task 12 checks it in the browser.
+
+- [ ] **Step 1: Add the kind tokens to `:root`**
+
+In `static/styles.css`, replace
+```css
+ --r-sm: 4px;
+```
+with
+```css
+ --r-sm: 4px;
+ /* Walkthrough stop kinds (THI-443 D9). The accent marks a card's edge and its
+ contents dot (≥ 3:1 on --bg-1); -bg/-fg is the badge pair. */
+ --kind-new-subsystem: oklch(0.70 0.11 255); --kind-new-subsystem-bg: #2b4a7a; --kind-new-subsystem-fg: #cfe0ff;
+ --kind-extension: oklch(0.70 0.11 150); --kind-extension-bg: #2f5a3f; --kind-extension-fg: #cfe9d6;
+ --kind-reuse: oklch(0.72 0.10 80); --kind-reuse-bg: #5a4a2f; --kind-reuse-fg: #f2e2c4;
+ --kind-system-touch: oklch(0.68 0.14 25); --kind-system-touch-bg: #6a2f2f; --kind-system-touch-fg: #f6d0d0;
+ --kind-behavior: oklch(0.70 0.12 300); --kind-behavior-bg: #4a2f6a; --kind-behavior-fg: #e2d0f6;
+ --kind-other: var(--fg-2); /* unknown or missing kind: neutral */
+```
+If `--r-sm: 4px;` isn't unique, use the occurrence inside the first `:root` block.
+
+- [ ] **Step 2: Separate the queue's shared rule**
+
+Replace
+```css
+.walkthrough, .reviews-queue { padding: 14px 18px; overflow: auto; height: 100%; box-sizing: border-box; }
+```
+with
+```css
+.reviews-queue { padding: 14px 18px; overflow: auto; height: 100%; box-sizing: border-box; }
+```
+Keep `.wt-head`, `.wt-head h2` and `.wt-sub, .wt-empty, .rq-repo, .rq-note` as they are; the Reviews queue uses them.
+
+- [ ] **Step 3: Replace the old walkthrough rules**
+
+Delete these lines (from `.wt-problem` through `.wt-comment-actions`):
+```css
+.wt-problem { max-width: 72ch; margin: 0 0 16px; }
+.wt-stop { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; }
+.wt-stop-title { margin: 0 0 6px; font-size: 14px; display: flex; gap: 8px; align-items: baseline; }
+.wt-kind { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: 8px; background: var(--bg-1-hi); color: var(--fg-2); }
+.wt-kind-new-subsystem { background: #2b4a7a; color: #cfe0ff; }
+.wt-kind-extension { background: #2f5a3f; color: #cfe9d6; }
+.wt-kind-reuse { background: #5a4a2f; color: #f2e2c4; }
+.wt-kind-system-touch { background: #6a2f2f; color: #f6d0d0; }
+.wt-kind-behavior { background: #4a2f6a; color: #e2d0f6; }
+.wt-stop-body { max-width: 80ch; }
+.wt-evidence { margin-top: 8px; }
+.wt-evidence-toggle { font: inherit; font-size: 12px; background: none; border: 0; color: var(--fg-2); cursor: pointer; padding: 2px 0; }
+.wt-evidence-path { font-family: var(--mono, ui-monospace, monospace); font-size: 11.5px; color: var(--fg-3); margin: 6px 0 2px; }
+.wt-comments { list-style: none; padding: 0; margin: 10px 0 0; }
+.wt-comments li { border-left: 2px solid var(--s-needs); padding: 2px 8px; margin: 6px 0; }
+.wt-comments li.is-resolved { border-left-color: var(--fg-4); opacity: .75; }
+.wt-comment-ts, .wt-comment-state { font-size: 11px; color: var(--fg-3); margin-right: 8px; }
+.wt-comment-box { margin-top: 8px; }
+.wt-comment-box textarea { width: 100%; box-sizing: border-box; font: inherit; font-size: 12.5px; background: var(--bg-1); color: var(--fg-1); border: 1px solid var(--line); border-radius: 4px; padding: 4px 6px; }
+.wt-comment-actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
+```
+and put this block in their place:
+```css
+/* --- review walkthrough (THI-443) ---
+ Scoped to .walkthrough: the Reviews queue shares .wt-head/.wt-sub/.wt-empty,
+ and .md-doc is the file preview's text style too. One type scale; text is
+ --fg-2 or brighter, and --fg-1 on --bg-1-hi/--bg-2 chips (--fg-2 there is
+ under 4.5:1). */
+.walkthrough {
+ --wt-fs-meta: 12px; --wt-fs-ui: 13px; --wt-fs-body: 15px; --wt-fs-stop: 18px; --wt-fs-title: 22px;
+ display: flex; flex-direction: column; height: 100%; min-height: 0; box-sizing: border-box;
+ font-size: var(--wt-fs-ui); color: var(--fg-1);
+}
+.walkthrough > .wt-head { flex: none; display: block; margin: 0; padding: 14px 18px 10px; border-bottom: 1px solid var(--line-soft); }
+.walkthrough .wt-title { margin: 0 0 4px; font-size: var(--wt-fs-title); line-height: 1.25; font-weight: 650; color: var(--fg-0); }
+.walkthrough .wt-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: var(--wt-fs-meta); color: var(--fg-2); }
+.wt-badge { padding: 1px 8px; border-radius: 9px; background: var(--bg-2); color: var(--fg-1); }
+.wt-badge.is-warn { background: var(--s-needs-bg); color: var(--s-needs); }
+.wt-progress { margin-left: auto; color: var(--fg-1); font-variant-numeric: tabular-nums; }
+/* The scroll container is the size container: 100cqh is its visible height,
+ which caps the sticky code column; its width drives the one-column fallback. */
+.wt-scroll { flex: 1; min-height: 0; overflow: auto; padding: 16px 18px 40px; container: wt / size; }
+.walkthrough .wt-error { margin: 0 0 12px; color: var(--s-danger); font-size: var(--wt-fs-meta); }
+/* Prose keeps a readable measure; the code column gets the rest. ch tracks
+ the 15px body text because the grid itself is 15px. */
+.wt-cols { display: grid; grid-template-columns: minmax(0, 72ch) minmax(0, 1fr); gap: 16px 28px; align-items: start; font-size: var(--wt-fs-body); }
+.wt-intro { margin-bottom: 22px; }
+.walkthrough .md-doc { max-width: none; margin: 0; font-size: var(--wt-fs-body); }
+.walkthrough .md-doc .md-h { font-size: var(--wt-fs-body); margin: 14px 0 6px; border-bottom: 0; padding-bottom: 0; }
+.walkthrough .md-doc .md-icode { color: var(--fg-1); }
+/* Contents */
+.wt-toc ol { list-style: none; margin: 0; padding: 0; font-size: var(--wt-fs-ui); }
+.wt-toc-item { display: flex; align-items: baseline; gap: 8px; width: 100%; padding: 3px 6px; border: 0; border-radius: var(--r-sm); background: none; color: var(--fg-1); font: inherit; text-align: left; cursor: pointer; }
+.wt-toc-item:hover { background: var(--bg-1); color: var(--fg-0); }
+.wt-toc-n { min-width: 2.2em; text-align: right; color: var(--fg-2); font-variant-numeric: tabular-nums; }
+.wt-toc-item:hover .wt-toc-n { color: var(--fg-1); }
+.wt-toc-dot { flex: none; align-self: center; width: 8px; height: 8px; border-radius: 50%; background: var(--k); }
+.wt-toc-done { margin-left: auto; color: var(--s-success); }
+/* Kind: --k is the card edge and contents dot, --k-bg/--k-fg the badge. */
+.wt-kind-new-subsystem { --k: var(--kind-new-subsystem); --k-bg: var(--kind-new-subsystem-bg); --k-fg: var(--kind-new-subsystem-fg); }
+.wt-kind-extension { --k: var(--kind-extension); --k-bg: var(--kind-extension-bg); --k-fg: var(--kind-extension-fg); }
+.wt-kind-reuse { --k: var(--kind-reuse); --k-bg: var(--kind-reuse-bg); --k-fg: var(--kind-reuse-fg); }
+.wt-kind-system-touch { --k: var(--kind-system-touch); --k-bg: var(--kind-system-touch-bg); --k-fg: var(--kind-system-touch-fg); }
+.wt-kind-behavior { --k: var(--kind-behavior); --k-bg: var(--kind-behavior-bg); --k-fg: var(--kind-behavior-fg); }
+.wt-kind-other { --k: var(--kind-other); --k-bg: var(--bg-2); --k-fg: var(--fg-1); }
+/* Stop card */
+.wt-stop { margin-bottom: 16px; padding: 12px 16px 14px; background: var(--bg-1); border: 1px solid var(--line-soft); border-left: 3px solid var(--k); border-radius: 8px; }
+.wt-stop.is-folded { padding-bottom: 12px; }
+.wt-stop-head { display: flex; align-items: baseline; gap: 10px; }
+.wt-stop-title { flex: 1; min-width: 0; margin: 0; font-size: var(--wt-fs-stop); line-height: 1.3; font-weight: 650; color: var(--fg-0); }
+.wt-stop-n { color: var(--fg-2); font-variant-numeric: tabular-nums; }
+.wt-fold { padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
+.wt-fold:hover { text-decoration: underline dotted; text-underline-offset: 3px; }
+.wt-kind-badge { flex: none; padding: 1px 8px; border-radius: 9px; background: var(--k-bg); color: var(--k-fg); font-size: var(--wt-fs-meta); text-transform: uppercase; letter-spacing: .04em; }
+.wt-reviewed { flex: none; display: inline-flex; align-items: baseline; gap: 8px; }
+.wt-reviewed-btn { padding: 3px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg-2); color: var(--fg-1); font: inherit; font-size: var(--wt-fs-ui); cursor: pointer; }
+.wt-reviewed-btn:hover { color: var(--fg-0); border-color: var(--line-strong); }
+.wt-reviewed-btn.is-on { color: var(--s-success); }
+.wt-reviewed-err { color: var(--s-danger); font-size: var(--wt-fs-meta); }
+/* Diagram row: as wide as the card, never past mermaid's own inline max-width
+ (its natural size), and short enough that the prose stays on screen. */
+.wt-diagrams { margin: 12px 0 4px; }
+.wt-diagrams .md-mermaid { margin: 0 0 12px; }
+.wt-diagrams .md-mermaid-svg svg { width: 100%; height: auto; max-height: 70vh; }
+/* Outside .md-doc, so a failed diagram's source + error needs its own skin and
+ its own sideways scroll (5.8:1, --s-needs on --bg-term). */
+.wt-diagrams .md-mermaid-err { margin: 0; padding: 11px 14px; overflow-x: auto; white-space: pre; font-family: var(--mono); font-size: 13px; line-height: 1.55; background: var(--bg-term); border: 1px solid var(--line-soft); border-radius: var(--r-sm); }
+/* Zoom (split/Mermaid.jsx, split/markdown.jsx): a click on a diagram opens it,
+ the corner button is the keyboard way in; an image is wrapped in a button. */
+.walkthrough .md-mermaid { position: relative; }
+.md-mermaid-svg.is-zoomable, .md-img-zoom { cursor: zoom-in; }
+.md-mermaid-zoom { position: absolute; top: 6px; right: 6px; padding: 1px 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg-2); color: var(--fg-1); font: inherit; font-size: var(--wt-fs-ui); cursor: zoom-in; }
+.md-mermaid-zoom:hover:not(:disabled) { color: var(--fg-0); border-color: var(--line-strong); }
+/* Disabled until mermaid's ~3 MB chunk has drawn the diagram. */
+.md-mermaid-zoom:disabled { opacity: .55; cursor: default; }
+.md-img-zoom { display: inline-block; padding: 0; border: 0; background: none; }
+.md-mermaid-zoom:focus-visible, .md-img-zoom:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
+/* Prose column */
+.wt-prose { min-width: 0; }
+/* Code column: sticks beside the prose while the stop is on screen and
+ scrolls on its own when taller. */
+.wt-evidence { position: sticky; top: 12px; align-self: start; min-width: 0; max-height: calc(100cqh - 24px); overflow: auto; font-size: var(--wt-fs-ui); }
+.wt-files { list-style: none; margin: 0 0 8px; padding: 0; }
+.wt-file { display: flex; align-items: baseline; gap: 8px; width: 100%; padding: 2px 6px; border: 0; border-radius: var(--r-sm); background: none; color: var(--fg-1); font: inherit; text-align: left; }
+button.wt-file { cursor: pointer; }
+button.wt-file:hover { background: var(--bg-2); color: var(--fg-0); }
+.wt-file-name, .wt-file-range, .wt-hidden-path, .wt-ev-path { font-family: var(--mono); font-size: var(--wt-fs-meta); }
+.wt-file-range, .wt-file-count { color: var(--fg-2); }
+button.wt-file:hover .wt-file-range, button.wt-file:hover .wt-file-count { color: var(--fg-1); }
+.wt-file-count { margin-left: auto; font-size: var(--wt-fs-meta); }
+.wt-hidden { margin: 0 0 10px; font-size: var(--wt-fs-meta); color: var(--fg-2); }
+.wt-hidden summary { padding: 2px 6px; cursor: pointer; }
+.wt-hidden ul { list-style: none; margin: 4px 0 0; padding: 0 6px; }
+.wt-nodiff { margin: 6px; color: var(--fg-2); font-size: var(--wt-fs-meta); }
+.wt-ev-file { margin-top: 10px; border-radius: var(--r-sm); }
+.wt-ev-path { margin: 0 0 4px; color: var(--fg-2); }
+/* A background fade, not motion, so it plays under reduced motion too (an
+ outline instead would stay forever: nothing removes is-flash). */
+.wt-ev-file.is-flash { animation: wt-flash 1.2s ease-out; }
+@keyframes wt-flash { from { background: color-mix(in oklch, var(--accent) 22%, transparent); } to { background: transparent; } }
+/* Shared styles that put --fg-3 text in the view (D9: nothing under 4.5:1). */
+.walkthrough .dhunk-head { color: var(--fg-1); }
+.walkthrough .md-doc .md-ul li::marker, .walkthrough .md-doc .md-ol li::marker { color: var(--fg-2); }
+.walkthrough .rq-pr-link.is-closed { color: var(--fg-2); }
+/* Comments */
+.wt-comments { list-style: none; margin: 14px 0 0; padding: 0; font-size: var(--wt-fs-ui); }
+.wt-comments li { margin: 8px 0; padding: 2px 10px; border-left: 2px solid var(--s-needs); }
+.wt-comments li.is-resolved { border-left-color: var(--fg-4); }
+.wt-comment-ts, .wt-comment-state { margin-right: 8px; color: var(--fg-2); font-size: var(--wt-fs-meta); }
+.wt-comment-box { margin-top: 10px; font-size: var(--wt-fs-ui); }
+.wt-link { padding: 0; border: 0; background: none; color: var(--fg-1); font: inherit; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 2px; }
+.wt-link:hover { color: var(--fg-0); }
+.wt-comment-box textarea { width: 100%; box-sizing: border-box; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg-0); color: var(--fg-0); font: inherit; }
+.wt-comment-box textarea:focus { outline: none; border-color: var(--accent); }
+.wt-comment-actions { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
+.wt-btn { padding: 4px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg-2); color: var(--fg-0); font: inherit; cursor: pointer; }
+.wt-btn:hover:not(:disabled) { border-color: var(--line-strong); }
+.wt-btn:disabled { opacity: .55; cursor: default; }
+.wt-hint, .wt-comment-note { color: var(--fg-2); font-size: var(--wt-fs-meta); }
+/* Narrow: one column, prose then code; the code column stops sticking. 1100px
+ leaves the code column ~45 mono columns at the switch; Task 12 tunes it. */
+@container wt (width < 1100px) {
+ .wt-cols { grid-template-columns: minmax(0, 1fr); }
+ .wt-evidence { position: static; max-height: none; overflow: visible; }
+}
+/* Full-size view (overlays/Lightbox.jsx). z-index 90: above the sticky header
+ (10), below toasts (100) and the modals (200, ⌘K 1000), so a notification
+ or a palette opened over it still shows. */
+.lightbox { position: fixed; inset: 0; z-index: 90; display: flex; background: color-mix(in oklch, var(--bg-0) 92%, transparent); }
+.lightbox-body { flex: 1; display: flex; overflow: auto; padding: 48px 32px 32px; }
+/* margin:auto, not place-items:center: centering would clip an oversized
+ child's top-left edge out of the scroll range. */
+.lightbox-body > * { margin: auto; }
+.lightbox-body img, .lightbox-svg svg { display: block; max-width: none; }
+.lightbox-close { position: fixed; top: 12px; right: 16px; z-index: 1; padding: 4px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg-2); color: var(--fg-0); font: inherit; font-size: 16px; cursor: pointer; }
+```
+
+- [ ] **Step 4: Lint and run the frontend suite**
+
+Run:
+```bash
+npx biome lint static/src
+npx vitest run
+```
+Expected: biome reports only the three existing warnings; vitest passes. CSS isn't linted, so check the block by eye for unbalanced braces.
+
+- [ ] **Step 5: Commit**
+
+```bash
+git add static/styles.css
+git commit -m "reviews walkthrough: styles — fixed header, two-column grids with a 1000px container fallback, sticky code column, kind-colored cards and tokens, five-step type scale, ≥4.5:1 text, lightbox (THI-443)" -m "Co-Authored-By: Claude Opus 5.5 (1M context) "
+```
+
+---
+
+### Task 10: Docs
+
+**Files:**
+- Modify: `docs/superpowers/specs/2026-10-26-review-walkthrough-design.md`, `skills/walkthrough/SKILL.md`, `CLAUDE.md`
+
+- [ ] **Step 1: Point the old spec's D5 at the new one**
+
+In `docs/superpowers/specs/2026-10-26-review-walkthrough-design.md`, after D5's paragraph (the one ending `…still\nshows them.`), add:
+```markdown
+
+> **Layout superseded by `2026-10-29-walkthrough-two-column-design.md`
+> (THI-443):** the hunks now sit expanded in a column beside each stop's
+> prose, diagrams render in a full-width row above it, the comment box is
+> collapsed until used, and per-stop reviewed marks live in `reviewed.json`
+> (`POST /api/reviews/reviewed`).
+```
+
+- [ ] **Step 1b: Add `reviewed.json` to D2's one-writer list**
+
+In the same file, the D2 section's paragraph starting "One writer per file:" ends with
+```
+whole dir only on the row's **clear**.
+```
+Replace that line with
+```
+whole dir only on the row's **clear**. Periscope is also the only writer of
+`reviewed.json` (per-stop reviewed marks, THI-443).
+```
+
+- [ ] **Step 2: Tell walkthrough authors where diagrams land, and that the marks file isn't theirs**
+
+In `skills/walkthrough/SKILL.md`, in the `## Diagrams` paragraph, replace
+```
+Mermaid goes in a ```` ```mermaid ```` fence.
+```
+with
+```
+Mermaid goes in a ```` ```mermaid ```` fence. The view draws a stop's diagrams in a full-width row above its text, so a diagram should make sense before the prose explains it.
+```
+
+In the same file, replace
+```
+A re-run leaves `comments.md` alone apart from step 6.
+```
+with
+```
+A re-run leaves `comments.md` alone apart from step 6, and never touches `reviewed.json` (periscope's reviewed marks).
+```
+
+- [ ] **Step 3: Name the new spec in CLAUDE.md**
+
+In `CLAUDE.md`'s reference table, in the row that starts ``| `reviews.py`, `routes/reviews.py`, `static/src/review/*` ``, replace
+```
+D6 queue sourced from `gh` with panes joined on |
+```
+with
+```
+D6 queue sourced from `gh` with panes joined on; the walkthrough view's layout and `reviewed.json`: `docs/superpowers/specs/2026-10-29-walkthrough-two-column-design.md` |
+```
+
+- [ ] **Step 4: Commit**
+
+```bash
+git add docs/superpowers/specs/2026-10-26-review-walkthrough-design.md skills/walkthrough/SKILL.md CLAUDE.md
+git commit -m "docs: the walkthrough's two-column layout and reviewed.json — D5 points at the THI-443 spec, the skill says diagrams render above the text, CLAUDE.md names the spec" -m "Co-Authored-By: Claude Opus 5.5 (1M context) "
+```
+
+---
+
+### Task 11: Bundle and full checks
+
+- [ ] **Step 1: Build and commit the bundle**
+
+Run:
+```bash
+npm run build
+git add static/dist
+git commit -m "build: static/dist" -m "Co-Authored-By: Claude Opus 5.5 (1M context) "
+```
+Expected: `✓ built in …`.
+
+- [ ] **Step 2: Run every gate**
+
+Run:
+```bash
+npx vitest run
+uv run pytest -q
+bin/check
+```
+Expected:
+- vitest: all pass, about 1256 + the new cases.
+- pytest: all pass.
+- `bin/check`: `✓ all checks passed`, with only the three existing biome warnings.
+
+---
+
+### Task 12: Check it in the real app
+
+The dev server shares `~/.claude/reviews` with prod. A mark set during testing is real review state, so unmark what you mark.
+
+- [ ] **Step 1: Start the dev server from the worktree** (in the background)
+
+Run: `PERISCOPE_PORT=17375 PERISCOPE_DEV=1 uv run server.py`
+Wait until `curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:17375/api/reviews` prints `200`.
+
+- [ ] **Step 2: Wide window (1600×1000)**
+
+Open `http://127.0.0.1:17375/` and select the 13-stop review in the rail (`~/.claude/reviews/fdy/project`, branch `project`). If its header shows "no worktree", that review has no diff: run the code-column checks below on a review whose branch has a worktree instead (any rail review row without that badge). Check:
+- the header stays put while the body scrolls; it shows the staleness badge (if stale) and "0 / 13 reviewed";
+- the problem statement and the contents list sit side by side; a contents entry jumps to its stop;
+- each diagram fills the card width up to its natural size, with labels readable at 100% zoom. Measure one: its rendered width ÷ viewBox width should be well above the old 0.30;
+- clicking a diagram opens the lightbox at natural size, scrolling both ways, **above the app header** (✕ visible and clickable at the top right); Esc, a backdrop click and ✕ each close it; Tab to the diagram's ⤢ button, then Enter, opens it; inside, the arrow keys scroll it and Tab only moves between the scroller and ✕;
+- the code column sticks while the prose scrolls, and scrolls on its own; a file-list click and a prose cite chip both land on that file and flash it, and the page itself doesn't jump;
+- "N not in this diff" is one line and expands;
+- marking the stop reviewed while a comment is half-typed, then unfolding it, brings the draft back;
+- the theme is app-wide, so check one non-flowchart diagram too. Write a scratch `.md` with a `pie` and a `gitGraph` fence outside the repo (in the scratchpad), open it as a file preview, and check that the pie slices and git branches are distinct colors, not one grey.
+
+- [ ] **Step 3: Narrow window (1000×900), and the breakpoint**
+
+Check: every grid is one column, with the prose first; no sideways page scroll (`document.querySelector('.wt-scroll').scrollWidth <= clientWidth`); long hunk lines scroll inside their hunk.
+
+Then widen the window until the stops switch to two columns, and record `.wt-scroll`'s width and the code column's width (`.wt-evidence` `getBoundingClientRect().width`) at the switch. The code column should hold at least ~80 monospace characters at 12px (about 580px). If it doesn't, raise the `@container` threshold in `static/styles.css` (it starts at 1100px) and commit.
+
+- [ ] **Step 4: Reviewed mark round trip**
+
+Mark the first stop reviewed. It folds, the contents shows ✓, and the header reads "1 / 13". Check that `~/.claude/reviews///reviewed.json` holds its title and an 8-hex sig. Reload: still folded. Click the title: it unfolds without unmarking. Unmark it, and the file is gone.
+
+- [ ] **Step 5: Comments**
+
+"comment" opens a focused box with the ⌘↩ hint; cancel closes it. Don't post a real comment unless you mean it: posting delivers to the owning pane.
+
+- [ ] **Step 6: Contrast and fonts**
+
+In the page, measure contrast for:
+- the header line, the file-list range and count, the hidden summary, the comment timestamp, the kind badge, `wt-badge is-warn`, `wt-reviewed-btn.is-on`, the hint, a hunk's `@@` head (`.dhunk-head`), an ordered list's numbers in prose, and the ⤢ button.
+
+Each must be ≥ 4.5:1 against its actual background. Use a canvas pixel read (paint the computed `color` over the computed background chain) to convert oklch first. Also check that the diagram labels' computed font family matches the computed `--sans`: it's Hanken Grotesk with the default font setting, and the user's choice otherwise (`main.jsx` sets `--sans` from Settings → Fonts).
+
+If anything misses, fix the CSS, re-run Task 11, and commit as `reviews walkthrough: (THI-443)`.
+
+- [ ] **Step 7: Stop the dev server**
+
+---
+
+### Task 13: Hand-off
+
+- [ ] **Step 1: Re-run the gates if Task 12 changed anything** (Task 11, Step 2)
+- [ ] **Step 2: Catch up with `origin/main`.** Run `git fetch origin`. If `git rev-list --count HEAD..origin/main` isn't 0, run `git rebase origin/main`. Nearly every periscope commit rebuilds `static/dist/app.js`, so expect conflicts on `build: static/dist` commits. Resolve each by running `npm run build`, then `git add static/dist`, then `GIT_EDITOR=true git rebase --continue`. Then re-run Task 11, Step 2.
+- [ ] **Step 3: Ask the user before pushing.** When approved:
+ - `git push -u origin thibaultdody/thi-443-review-walkthrough-full-width-layout-legible-diagrams`
+ - `gh pr create --repo tomplex/periscope --base main --head thibaultdody/thi-443-review-walkthrough-full-width-layout-legible-diagrams --title "THI-443: review walkthrough — two-column stops, legible diagrams, reviewed marks, type and color"`
+ - link the PR on THI-443 and move it to In Review.
diff --git a/docs/superpowers/specs/2026-10-26-review-walkthrough-design.md b/docs/superpowers/specs/2026-10-26-review-walkthrough-design.md
index d81dc0eb..b556dc55 100644
--- a/docs/superpowers/specs/2026-10-26-review-walkthrough-design.md
+++ b/docs/superpowers/specs/2026-10-26-review-walkthrough-design.md
@@ -117,7 +117,8 @@ it by convention.
One writer per file: the pane writes `walkthrough.md`; periscope only ever
appends to `comments.md`; the pane edits `comments.md` only to add a reply
paragraph inside an entry and flip its `resolved`. Periscope removes the
-whole dir only on the row's **clear**.
+whole dir only on the row's **clear**. Periscope is also the only writer of
+`reviewed.json` (per-stop reviewed marks, THI-443).
### D3. Markdown with three conventions, each degrading to plain markdown
@@ -193,6 +194,12 @@ HEAD differs from the header's `head`. Hunks come from the branch's worktree
path, not a pane, so a branch with no live pane but a worktree on disk still
shows them.
+> **Layout superseded by `2026-10-29-walkthrough-two-column-design.md`
+> (THI-443):** the hunks now sit expanded in a column beside each stop's
+> prose, diagrams render in a full-width row above it, the comment box is
+> collapsed until used, and per-stop reviewed marks live in `reviewed.json`
+> (`POST /api/reviews/reviewed`).
+
### D6. The Reviews queue is a detail-area selection, one row per (repo, branch), sourced from GitHub
**The queue answers "what's waiting on me," not "what's running in
diff --git a/docs/superpowers/specs/2026-10-29-walkthrough-two-column-design.md b/docs/superpowers/specs/2026-10-29-walkthrough-two-column-design.md
new file mode 100644
index 00000000..5033d27e
--- /dev/null
+++ b/docs/superpowers/specs/2026-10-29-walkthrough-two-column-design.md
@@ -0,0 +1,434 @@
+# Review walkthrough: two-column stops, legible diagrams, reviewed marks (THI-443)
+
+The individual walkthrough view (`static/src/review/Walkthrough.jsx`) gets a
+new layout and a type and color pass. Each stop becomes a card with its
+diagrams across the full width, its text on the left at a readable line
+length, and its files and code changes in a column on the right. The page
+gains a fixed header, a contents list, per-stop "reviewed" marks saved in
+the review folder, and a quieter comment box. Builds on
+`2026-10-26-review-walkthrough-design.md`. D1 (periscope never mutates git
+or GitHub), D2 (review state is files under `~/.claude/reviews//`,
+one writer per file) and D3 (the walkthrough.md format) are unchanged; this
+replaces D5's layout.
+
+## Problem
+
+Measured in the running app on a 13-stop walkthrough (2026-10-29; the full
+list is THI-443's 22 findings):
+
+- **Text is a narrow centered column.** `.md-doc` (shared with file previews)
+ sets `max-width: 72ch; margin: 0 auto`, and `.wt-stop-body` raises it to
+ 80ch. The body is 672px wide inside a 2085px card, centered, while the
+ title, refs, hunks and comment box are full-width and left-aligned. The
+ problem statement is a third column: 72ch, left-aligned, 13px.
+- **Diagrams are unreadable.** Mermaid's `width="100%"` attribute fits each
+ diagram to that 672px column (its inline `max-width` is the natural width,
+ so the stylesheet's `max-width: 100%` never applies). The widest is naturally 2274px, so
+ it draws at 30% scale with labels around 5px. It never grows and can't be
+ opened larger. They also use mermaid's stock dark theme (Trebuchet MS,
+ near-black nodes), not periscope's fonts or colors.
+- **Code changes are hard to reach.** A wall of full paths in small mono
+ comes before the text, a small "▸ 3 hunks" toggle sits below it, and
+ expanding it lists every cited file, most reading "— not in this diff".
+ Clicking a path opens all hunks rather than going to that file's.
+- **No way through a long walkthrough.** No contents list or stop numbers,
+ the header scrolls away, and nothing records which stops you've read.
+- **Typography and color.** Eleven font sizes (10–16px; stop titles are
+ smaller than body text), four kinds of text below 4.5:1 contrast, the
+ staleness warning in the same grey as the repo name, stop kinds visible
+ only in a 10px badge, inline code brighter than the prose around it, and
+ cards with no fill. The problem statement drops its markdown.
+- **Comment boxes everywhere.** Every stop has an open textarea and a
+ disabled button drawn in the browser default (1.4:1). ⌘↩ posts, unannounced.
+
+## Decisions
+
+### D1. Diagrams are lifted out of a stop's text by the parser
+
+`parseWalkthrough` already slices each stop out of the source by mdast
+positions. Each stop now also returns `diagrams`: the code of every
+**top-level** ```` ```mermaid ```` fence in its body, in order. Its
+`bodyMarkdown` is the body with exactly those fences cut out (by their
+`position` offsets). A mermaid fence nested inside a list or blockquote is
+not lifted. It stays in the text and renders inline as today, because
+moving it out of its list item can't be done without reordering content.
+
+Rejected: moving diagrams with CSS (turning the text container into grid
+items is fragile with an unknown number of paragraphs), and a "collect" mode
+in the shared renderer (couples `renderMarkdown` to one page's layout).
+
+The problem statement comes back as `problemMarkdown` (its source slice) in
+addition to the existing plain-text `problem`, and renders as markdown.
+
+### D2. Page structure: a fixed header over one scrolling body
+
+`.walkthrough` becomes a flex column:
+
+- **Header** (`.wt-head`, doesn't scroll): the title at 22px, then
+ repo · branch · PR link at 12px. Beside them:
+ - a **staleness badge**: "stale: N commits" in `--s-needs` when
+ `stale_by > 0`; a neutral "no worktree" badge when the walkthrough has a
+ header but no diff; "stale: unknown" in `--s-needs` when there is a diff
+ but `stale_by` is null (the recorded head was rebased away, which the
+ queue also calls "stale: unknown"); nothing when current;
+ - **progress**: "4 / 13 reviewed" (D7).
+- **Scrolling body** (`.wt-scroll`, `overflow: auto`,
+ `container-type: size; container-name: wt`). Everything below lives here.
+
+The top of the body uses the same two-column grid as a stop: the problem
+statement on the left (15px, the prose measure), a numbered **contents list**
+on the right. Each entry is the stop number, a dot in its kind's color, the
+title, and ✓ once reviewed. Clicking an entry calls `scrollIntoView` on the
+stop (buttons, not `#` links, so the URL and periscope's routing are
+untouched).
+
+### D3. A stop is a card: title row, diagram row, then two columns
+
+```
+┌──────────────────────────────────────────────────────────────┐
+│▌ 4. Adds the Project resource… [NEW-SUBSYSTEM] [reviewed] │ title row
+│▌ ┌──────────────────── diagram, full width ────────────────┐ │ diagram row
+│▌ └──────────────────────────────────────────────────────────┘ │ (if any)
+│▌ prose (≤ 72ch) │ files: payload.ts 2 changes │
+│▌ … │ compiler.ts 1 change │
+│▌ comments │ 8 not in this diff │
+│▌ comment │ ─ hunks, expanded ─ │
+└──────────────────────────────────────────────────────────────┘
+```
+
+- **Card:** `--bg-1` fill and a 3px left edge in the stop kind's accent (D9).
+- **Title row:** "N." plus the title at 18px, the kind badge, and a
+ "reviewed" toggle at the right edge.
+- **Diagram row:** present only when `stop.diagrams` is non-empty (D4).
+- **Two columns** (`.wt-cols`): `grid-template-columns: minmax(min(52ch,
+ 440px), 72ch) minmax(540px, 1fr)` with the grid's font size at 15px so `ch`
+ tracks body text. The prose gives up width (down to 52ch, capped at 440px
+ so a wide UI font can't push the floor past the switch) before the code
+ column drops below ~70 monospace characters. Left: the prose, then the stop's comments and the comment control
+ (D8). Right: the code-changes column (D5).
+- **Narrow:** `@container wt (width < 1050px)` switches every `.wt-cols`
+ grid to one column, with the prose first and the code changes after. The
+ page never scrolls sideways; long code lines scroll inside their hunk. The
+ breakpoint was tuned in the browser (container queries measure the
+ content box): 440px + 540px + the gap and card chrome is about 1044px.
+- **Reviewed stops fold** to the title row, as "viewed" folds a file in the
+ Changes tab. On a reviewed stop the title itself is a button. Pressing it
+ unfolds or refolds the stop for this visit without unmarking it; the
+ "reviewed" toggle beside it is a separate button and only marks or
+ unmarks. The unfolded state is local and not saved. A half-typed comment
+ survives its stop folding and unfolding (D8). A folded stop with comments
+ shows a chip in its title row, e.g. "2 comments · 1 open". The owning
+ pane answers inside a comment and resolves it without rewriting the stop
+ (the skill's step 6), so the stop stays folded and its reply would
+ otherwise go unseen.
+
+### D4. Diagrams render near natural size, in periscope's theme, and open full size
+
+- **Size.** In the diagram row the SVG is `width: 100%` capped by mermaid's
+ own inline `max-width` (its natural width), so it fills the card but never
+ scales a small diagram up. It also gets a `min-width` of 75% of its
+ natural width: below that, a wide flowchart's 16px labels drop under
+ ~12px (measured at 7.6px on a 1600px window). That floor holds for wide
+ diagrams; a tall one capped by the height limit still scales down to fit,
+ and the full-size view is the way to read it. Wider than the card, the
+ diagram scrolls sideways inside its own box, never the page. A 70% height
+ cap keeps a tall top-down chart from pushing the stop's text off screen.
+ Several diagrams stack in order.
+- **Full size on click.** With the new `zoom: true` renderer option:
+ - a **diagram** opens on a mouse click, and gets a small real button in its
+ corner (⤢, `aria-label="open diagram full size"`) as the keyboard and
+ screen-reader way in. The diagram itself is not given `role="button"`,
+ which would make its text labels presentational and hide them from
+ screen readers;
+ - an **image** in the text is wrapped in a `` (biome rejects
+ ` `);
+ - an image **inside a link** is left alone, so one click doesn't both zoom
+ and follow the link.
+
+ The lightbox is a dark backdrop with the content at natural size, on a
+ solid panel so the page doesn't show through between a diagram's boxes,
+ scrolling both ways when larger than the window. On open, focus goes to the scroller,
+ so the arrow keys scroll a big diagram, and Tab moves only between the
+ scroller and ✕. Esc (`useEscape`), a backdrop click or ✕ closes it, and
+ focus returns to what opened it. For a diagram it re-renders the source
+ through `renderDiagram` with a fresh id (a copied SVG's duplicate ids
+ would bind its arrowheads to the original's markers), then sets its width
+ and height to the viewBox's. What it assigns is still only mermaid's own
+ sanitized output, per `Mermaid.jsx`'s innerHTML rule. Its host is
+ mounted once, in `overlays/Overlays.jsx`: inside `#split-view`
+ (`position: fixed; z-index: 1`) the sticky app header would paint over it.
+ Only the walkthrough passes `zoom: true`; file previews keep their existing
+ in-place image zoom.
+- **Theme (app-wide).** `split/mermaidRender.js` initializes mermaid with
+ `theme: "base"` and `themeVariables` from a pure `mermaidTheme({ color,
+ font })` builder, where `color(name)` returns a token's color as
+ `#rrggbb`. The intent is:
+
+ | Element | Token |
+ |---|---|
+ | node fill | `--bg-2` |
+ | node text | `--fg-0` |
+ | node border, arrows | `--fg-2` (non-text contrast ≥ 3:1 on `--bg-1`) |
+ | edge-label background | `--bg-1` |
+ | groups / clusters | `--bg-1-hi` |
+ | other text | `--fg-1` |
+ | font | `--sans` (Hanken Grotesk), 14px |
+
+ The base theme derives pie, mindmap/timeline (`cScale*`) and git colors by
+ rotating `primaryColor`'s hue, and `--bg-2` is near-grey. So those sets
+ are given explicitly from periscope's opaque accents (`--accent`,
+ `--s-done`, `--s-working`, `--s-needs`, `--effort`, `--worktree`,
+ `--s-shell`, `--s-danger`), with `--bg-0` labels on them. Sequence notes,
+ autonumbers and gantt sections also get token colors.
+
+ `darkMode: true`. Mermaid's color parser can't read `oklch()`, so tokens
+ are converted to hex at load by painting them on a 1×1 canvas and reading
+ the pixel. The stylesheet stays the single source of truth, and only opaque
+ tokens are used. This restyles diagrams in file previews too.
+- Render failures are unchanged: the source and the error show as text. In
+ the diagram row, outside `.md-doc`, that text gets its own code skin and
+ scrolls sideways inside its box, never the page.
+
+### D5. The code-changes column
+
+A pure `evidenceFor(refs, diffFiles)` (built on `matchRefs`) returns:
+
+- `shown`: refs with at least one matched hunk, each with its basename, any
+ line range, the hunk count and the hunks;
+- `hidden`: refs grouped as `missing` (no such file in the diff),
+ `generated` (the server dropped its hunks) and `unchanged` (the file is in
+ the diff but no hunk meets the cited lines);
+- with `diffFiles === null` (no worktree), every ref goes to `shown` with no
+ hunks, and the column shows "no worktree, so code changes are unavailable".
+
+The column (`.wt-evidence`) renders:
+
+- **File list:** one row per `shown` ref with the file name in mono, the line
+ range, and "N changes", full path in `title`. Clicking a row scrolls the
+ column to that file's block and flashes it. When the column scrolls on its
+ own that's `col.scrollTo`; otherwise `scrollIntoView({block: "nearest"})`,
+ which does nothing when the file is already on screen. Either way the page
+ itself doesn't jump. A cite chip in the prose does the same, landing on
+ the entry for its path whose hunks cover its line, else the first entry
+ for that path. Chips with no match stay inert, as today.
+- **One closing summary line** for `hidden`, e.g. "8 not in this diff · 1
+ generated", a `` that expands to the paths.
+- **The hunks,** expanded, under each file's path, drawn by `Hunk` from
+ `diff/ChangesTab.jsx` with `onOpen={null}`, memoized so a reviewed toggle
+ doesn't re-highlight them. A file whose hunks total more than 300 lines
+ (`COLLAPSE_LINES`) starts collapsed behind "show N lines". Whole-file
+ cites of new files made one real walkthrough mount about 10.7k
+ highlighted lines.
+- **Wide panes:** `position: sticky; top: 12px; align-self: start;
+ max-height: calc(100cqh + 32px); overflow: auto`. `cqh` measures
+ `.wt-scroll`'s content box, 56px of padding shorter than what's visible,
+ so +32px leaves a 12px gap at both ends. The column stays beside
+ the text while the stop is on screen, scrolls on its own when taller, and
+ leaves with the stop. **Narrow:** static, no max-height.
+- A stop with no refs leaves the column empty.
+
+The old `md-meta` refs row above the prose and the `wt-evidence-toggle` go
+away.
+
+### D6. Reviewed marks live in `reviewed.json` in the review folder
+
+- **File:** `~/.claude/reviews///reviewed.json`, a JSON object
+ of `{"": ""}`. periscope is its only writer (D2 of the
+ original spec). "clear" removes it with the folder, under the same flock
+ as a mark. Otherwise a mark landing mid-`rmtree` makes the final `rmdir`
+ fail, leaving a folder holding only `reviewed.json`, which would surface
+ as an orphan queue row.
+- **Signature:** `stopSig(stop)`, an FNV-1a 32-bit hash (8 hex chars) of the
+ stop's full source slice, trailing whitespace trimmed: heading, metadata
+ and body before diagrams are lifted. Any rewrite of the stop's title,
+ kind, refs or text yields a new sig. Appending a stop after it, or the
+ file's final newline, doesn't. Computed in the browser so it always
+ matches what is displayed.
+- **Expiry:** a stop is reviewed only while `reviewed[title] === stopSig(stop)`.
+ A re-prepare that rewrites a stop lapses its mark, mirroring the Changes
+ tab's `viewedSig`. Stale entries stay in the file harmlessly until the
+ stop is marked or unmarked again.
+- **Keyed by title**, like comments. Two stops with the same title share one
+ slot, and since their sigs differ only one can show reviewed. Accepted,
+ since the skill keeps titles distinct.
+- **Server** (`periscope/reviews.py`):
+ - `reviewed_path(repo, branch)`;
+ - `read_reviewed(repo, branch) -> dict[str, str]`, where missing,
+ unreadable or non-object JSON reads as `{}` and non-string values are
+ dropped;
+ - `set_reviewed(repo, branch, stop, sig | None)`, a read-modify-write under
+ a module-level `threading.Lock` **and** an `fcntl.flock` on the review
+ dir. `~/.claude/reviews` isn't instance-separated, so the dev and prod
+ servers both write it. It's written atomically (temp file in the same
+ dir, then `os.replace`, and the temp file is removed on error). `None`
+ removes the entry, and an empty result deletes the file. It never
+ creates the review dir: a missing one raises `FileNotFoundError`.
+- **Routes** (`periscope/routes/reviews.py`):
+ - `POST /api/reviews/reviewed` with `{repo, branch, stop, sig, reviewed}`:
+ `_check(repo, branch)`; 400 for an empty stop or one with a newline (the
+ comment route's rule), or a sig not matching `^[0-9a-f]{8}$`; 404 when
+ the walkthrough file doesn't exist, or when the review is cleared
+ mid-request (`FileNotFoundError`), so a mark never creates or recreates
+ a folder; otherwise `{"ok": true}`.
+ - `GET /api/reviews/walkthrough` gains `"reviewed": read_reviewed(...)`.
+- **Frontend:** the toggle updates a local copy at once and POSTs. On failure
+ it reverts and shows the error beside the toggle. A refetch whose request
+ started before a mark settled doesn't overwrite the local marks. The
+ toggle's accessible name is "reviewed" in both states, with
+ `aria-pressed` carrying the state and the ✓ hidden from screen readers.
+
+### D7. Progress and the contents list read the same marks
+
+The header's "N / M reviewed" and the contents list's ✓ use the same
+`isReviewed(stop, reviewed)` as the cards, so the three can't disagree.
+
+### D8. The comment control is collapsed until used
+
+The stop's comments still list under its prose. The always-open textarea
+becomes a "comment" text button. It opens the box, focused, with "send" and
+"cancel" and a hint "⌘↩ to send" ("Ctrl+↩ to send" when the platform isn't
+a Mac). A successful post closes the box and shows the existing delivery
+note. A 409 also closes it, with the "saved, not delivered" note. Any other
+error keeps it open with the error. The buttons get periscope's normal
+button styling rather than the browser default. A half-typed draft is kept
+per stop outside the component, so folding a stop (which unmounts its box)
+doesn't lose it.
+
+### D9. Type and color are scoped to the walkthrough
+
+On `.walkthrough`, so `.md-doc` and file previews don't change:
+
+- **Five sizes** as custom properties:
+
+ | Property | Size | Used for |
+ |---|---|---|
+ | `--wt-fs-meta` | 12px | header line, file paths, badges, comment timestamps, summary line |
+ | `--wt-fs-ui` | 13px | buttons, links, contents list, comment text |
+ | `--wt-fs-body` | 15px | prose and the problem statement |
+ | `--wt-fs-stop` | 18px | stop titles |
+ | `--wt-fs-title` | 22px | page title |
+
+ Headings inside a stop's prose render at 15px semibold. Hunk code keeps
+ the Changes tab's own sizes.
+- **Contrast:** all text at 4.5:1 or better, estimated from the tokens'
+ oklch lightness (luminance ≈ L³) and checked in the browser:
+
+ | Text | `--bg-0` (page) | `--bg-1` (card) | `--bg-1-hi` | `--bg-2` (chips) |
+ |---|---|---|---|---|
+ | `--fg-3` | 3.0:1 | 2.6:1 | 2.3:1 | 2.2:1 |
+ | `--fg-2` | 5.4:1 | 4.7:1 | 4.1:1 | 3.9:1 |
+ | `--fg-1` | 10.6:1 | 9.2:1 | 8.1:1 | 7.6:1 |
+
+ So metadata moves from `--fg-3` to `--fg-2` on the page and on cards, and
+ any text on a `--bg-1-hi` or `--bg-2` chip (badges, the file list's hover,
+ inline code) uses `--fg-1`. `--fg-3` is not used for text in the view,
+ including the shared styles that would bring it in: hunk heads
+ (`.dhunk-head`) take `--fg-1`, and ordered-list numbers and a closed PR
+ link take `--fg-2`.
+- **Inline code** in prose takes `--fg-1` (the body's color) on its chip
+ background. `strong` stays `--fg-0`.
+- **Kind tokens:** each kind gets `--kind-` (an accent for the card
+ edge and the contents dot, at ≥ 3:1 against `--bg-1`) beside its existing
+ badge background and text pair, moved into `:root` as tokens. Unknown
+ kinds use a neutral `--kind-other`.
+
+## Mechanics
+
+### Frontend
+
+- **`review/walkthrough.js`:**
+ - `parseWalkthrough` adds `problemMarkdown`, and per stop `source`,
+ `diagrams` and the trimmed `bodyMarkdown` (D1);
+ - new pure `stopSig`, `isReviewed` and `evidenceFor`.
+- **`split/mermaidTheme.js`** (new, pure): `mermaidTheme({ color, font })`,
+ beside `Mermaid.jsx`, since the theme is app-wide and not review-specific.
+ The canvas-based token reader (`tokenHex`) lives in `split/mermaidRender.js`,
+ so the builder stays testable without a DOM.
+- **`review/Walkthrough.jsx`** splits in two:
+ - `Walkthrough` fetches and owns `reviewed` and the posting nonce;
+ - a pure `WalkthroughView({data, repo, branch, pr, hl, reviewed,
+ toggleErrors, error, onToggleReviewed, onPosted})` renders the page, so
+ render-to-string can test it.
+
+ Stops become `Stop`, `Evidence`, `Contents`, `Comments`, `CommentBox`
+ (with a pure `CommentForm`) and `ReviewedToggle`.
+- **`split/markdown.jsx`:** a new `zoom` option. An image is wrapped in a
+ zoom button, except inside a link, and `Mermaid` receives `zoom`.
+- **`split/Mermaid.jsx`:** draws through `renderDiagram` (which applies the
+ base theme), plus the `zoom` and `label` props. A click on the diagram, or
+ its corner ⤢ button (disabled until drawn), opens the lightbox, and a
+ zoomable diagram keeps at least 75% of its natural width.
+- **`overlays/Lightbox.jsx`** (new): a `lightbox` signal and ` `
+ (backdrop, scroller, ✕, `useEscape`, Tab kept inside). It re-renders a
+ diagram from its source with a fresh id rather than copying the SVG, whose
+ duplicated ids would bind its arrowheads to the original's markers.
+ `overlays/Overlays.jsx` mounts the host at the app root.
+- **`split/mermaidRender.js`** (new): the DOM side of diagrams. It loads
+ mermaid lazily, converts tokens to hex, and waits for the UI font before
+ mermaid measures labels. It re-initializes when Settings → Fonts changes
+ `--sans`, and exposes `renderDiagram(code)`.
+- **`static/styles.css`:** the walkthrough section is rewritten: tokens,
+ grids, the container query, sticky column, cards, badges, comment control
+ and lightbox.
+
+### Server
+
+`reviews.py` and `routes/reviews.py` per D6. No change to the queue,
+`list_reviews`, comments or prepare.
+
+### Skill
+
+`skills/walkthrough/SKILL.md`, Diagrams section: one line saying the view
+draws a stop's diagrams above its text at full width, so a diagram should
+make sense before the prose explains it.
+
+## Tests
+
+- **vitest, pure** (`review/__tests__/walkthrough.test.js`):
+ - `parseWalkthrough`: top-level diagrams lifted in order; nested fence left
+ in place; `bodyMarkdown` loses only the lifted fences; `problemMarkdown`
+ keeps inline markdown;
+ - `stopSig`: stable for the same source and changed by a one-character
+ edit to title, metadata or body;
+ - `isReviewed`: match, mismatch, missing;
+ - `evidenceFor`: shown, missing, generated, unchanged and no-diff cases,
+ plus the summary counts.
+- **vitest, pure** (`split/__tests__/mermaidTheme.test.js`, new):
+ `mermaidTheme` maps a stub token reader to the D4 table.
+- **vitest, render** (`review/__tests__/walkthroughRender.test.jsx`, new),
+ against `WalkthroughView`:
+ - the staleness badge class and text, and the progress count;
+ - contents numbering and ✓;
+ - card kind classes;
+ - the diagram row present only with diagrams;
+ - the two-column markup;
+ - the hidden summary line;
+ - a reviewed stop folded to its title row;
+ - the comment link versus the open box.
+
+ Buttons are pressed by calling components and invoking `onClick`, as
+ `hunk.test.jsx` and `reviewsQueueRender.test.jsx` do.
+- **pytest** (`tests/test_reviews.py`, `tests/routes/test_reviews.py`), per
+ `docs/testing.md`:
+ - `read_reviewed`: missing, corrupt, non-object and non-string values;
+ - `set_reviewed`: set, overwrite, unset, and deleting the file when empty;
+ - the route: 200 round-trip visible in `GET /api/reviews/walkthrough`; 400
+ for a bad stop and a bad sig; 404 with no walkthrough; `_check`
+ rejection.
+- **In the browser,** on the dev server (:17375) with the real 13-stop
+ walkthrough, at a wide and a narrow width:
+ - diagrams are legible; the lightbox opens and closes (click, Enter, Esc,
+ backdrop);
+ - the code column sticks and scrolls on its own; a ref click lands on its
+ file;
+ - no sideways page scroll when narrow;
+ - a reviewed mark survives a reload and lands in `reviewed.json`;
+ - contrast measured.
+
+## Out of scope
+
+- **Why most refs read "not in this diff"** (THI-443 finding 11). It may be
+ a ref-matching or diff-base bug on the server, and gets its own ticket.
+- **The Reviews queue and file previews,** apart from the app-wide diagram
+ theme (D4).
+- **Showing reviewed progress in the queue.**
diff --git a/periscope/reviews.py b/periscope/reviews.py
index 3b2c4a45..4b1ad8ae 100644
--- a/periscope/reviews.py
+++ b/periscope/reviews.py
@@ -1,7 +1,8 @@
"""The review walkthrough convention: files under ~/.claude/reviews that the
`walkthrough` skill writes and periscope renders. Periscope only ever appends
-to comments.md and removes a whole review dir on an explicit clear — the pane
-is the sole writer of walkthrough.md (spec D2).
+to comments.md, writes reviewed.json (per-stop reviewed marks, THI-443) and
+removes a whole review dir on an explicit clear — the pane is the sole writer
+of walkthrough.md (spec D2).
Two parsers read this format: this line-based one (header, stop count,
comments — cheap enough to run per queue refresh) and the frontend's mdast one
@@ -11,6 +12,7 @@
from __future__ import annotations
+import fcntl
import json
import os
import re
@@ -67,6 +69,10 @@ def comments_path(repo: str, branch: str) -> Path:
return review_dir(repo, branch) / "comments.md"
+def reviewed_path(repo: str, branch: str) -> Path:
+ return review_dir(repo, branch) / "reviewed.json"
+
+
# --- parse -----------------------------------------------------------------
@@ -184,12 +190,74 @@ def append_comment(repo: str, branch: str, stop: str, body: str, ts: str) -> Non
f.write(f"## {ts} · {stop}\n> resolved: no\n\n{body.strip()}\n\n")
+# reviewed.json is a read-modify-write, and the dev and prod servers both write
+# ~/.claude/reviews (it isn't instance_file()-separated): the flock serializes
+# writers across processes and threads (flock is per open file description,
+# not per process); the module lock is belt-and-braces (THI-443 D6).
+_reviewed_lock = threading.Lock()
+
+
+def read_reviewed(repo: str, branch: str) -> dict[str, str]:
+ """stop title → the stop's sig when it was marked (THI-443 D6). A missing,
+ unreadable or hand-mangled file reads as nothing reviewed."""
+ try:
+ data = json.loads(_read(reviewed_path(repo, branch)) or "{}")
+ except (ValueError, RecursionError): # deeply nested junk blows the decoder's stack, not just malformed JSON
+ return {}
+ if not isinstance(data, dict):
+ return {}
+ return {k: v for k, v in data.items() if isinstance(k, str) and isinstance(v, str)}
+
+
+def set_reviewed(repo: str, branch: str, stop: str, sig: str | None) -> None:
+ """Mark `stop` reviewed at `sig`, or unmark it with None. Written through a
+ temp file + os.replace so a crash mid-write can't leave half a JSON object;
+ an empty result removes the file rather than leaving `{}` behind. Raises
+ FileNotFoundError when the review dir is gone: a mark never creates it."""
+ path = reviewed_path(repo, branch)
+ with _reviewed_lock:
+ dfd = os.open(path.parent, os.O_RDONLY | os.O_DIRECTORY)
+ try:
+ fcntl.flock(dfd, fcntl.LOCK_EX)
+ marks = read_reviewed(repo, branch)
+ if sig is None:
+ marks.pop(stop, None)
+ else:
+ marks[stop] = sig
+ if not marks:
+ path.unlink(missing_ok=True)
+ return
+ # One temp name is safe under the flock; a crash leaves at most this
+ # file, which the next write replaces.
+ tmp = path.with_suffix(".json.tmp")
+ try:
+ tmp.write_text(json.dumps(marks, indent=1, sort_keys=True, ensure_ascii=False) + "\n", encoding="utf-8")
+ os.replace(tmp, path)
+ except BaseException:
+ # ensure_ascii=False lets a lone surrogate reach write_text, which raises
+ # UnicodeEncodeError, not OSError; _check_stop rejects that before this
+ # runs, but nothing here may leave the temp file behind either way.
+ tmp.unlink(missing_ok=True)
+ raise
+ finally:
+ os.close(dfd) # releases the flock
+
+
def clear_review(repo: str, branch: str) -> None:
d = review_dir(repo, branch).resolve()
if not d.is_relative_to(REVIEWS_DIR.resolve()) or d == REVIEWS_DIR.resolve():
raise ValueError(f"refusing to remove {d}: outside the reviews dir")
- if d.exists(): # only a missing dir is a no-op; permission errors must surface
+ try:
+ dfd = os.open(d, os.O_RDONLY | os.O_DIRECTORY)
+ except FileNotFoundError:
+ return # only a missing dir is a no-op; permission errors must surface
+ try:
+ # A reviewed.json write in flight finishes first; one that waits gets
+ # the lock on the dead dir and its temp write fails -> the route's 404.
+ fcntl.flock(dfd, fcntl.LOCK_EX)
shutil.rmtree(d)
+ finally:
+ os.close(dfd)
# --- queue -----------------------------------------------------------------
diff --git a/periscope/routes/reviews.py b/periscope/routes/reviews.py
index 4c4996a1..bf891d00 100644
--- a/periscope/routes/reviews.py
+++ b/periscope/routes/reviews.py
@@ -2,7 +2,8 @@
Periscope never mutates git or GitHub here (spec D1): prepare and merge are
channel messages to the pane that owns the branch; the only filesystem
-writes are an append to comments.md and the explicit clear of a review dir.
+writes are an append to comments.md, reviewed.json's per-stop marks, and the
+explicit clear of a review dir.
All handlers are async because delivery goes through channels._deliver;
blocking git/file work runs in a thread so the event loop (every pane
mirror, every MCP connection) never stalls.
@@ -11,6 +12,7 @@
import asyncio
import json
import os
+import re
import time
from datetime import datetime
@@ -65,6 +67,29 @@ class CommentBody(ReviewRef):
body: str
+class ReviewedBody(ReviewRef):
+ stop: str
+ sig: str
+ reviewed: bool
+
+
+# stopSig in static/src/review/walkthrough.js: 32-bit FNV-1a as 8 lowercase hex.
+_SIG_RE = re.compile(r"[0-9a-f]{8}")
+
+
+def _check_stop(stop: str) -> None:
+ # A newline would split comments.md's heading line, and parse_comments
+ # would drop the entry; reviewed.json keys follow the same rule.
+ if not stop.strip() or "\n" in stop or "\r" in stop:
+ raise HTTPException(400, "bad stop")
+ # A lone surrogate round-trips through JSON but can't be written as UTF-8:
+ # set_reviewed's write_text (ensure_ascii=False) would raise mid-write.
+ try:
+ stop.encode("utf-8")
+ except UnicodeEncodeError:
+ raise HTTPException(400, "bad stop") from None
+
+
@router.get("/api/reviews")
async def reviews_list():
team_keys = store.linear_team_keys()
@@ -101,6 +126,7 @@ def load():
return {
"text": text,
"comments": reviews.parse_comments(reviews._read(reviews.comments_path(repo, branch))),
+ "reviewed": reviews.read_reviewed(repo, branch),
"head_now": reviews.head_sha(worktree) if worktree else None,
"stale_by": reviews.stale_by(worktree, header["head"]) if header and worktree else None,
"diff": diff,
@@ -123,9 +149,7 @@ async def _deliver_or_409(owner: dict | None, message: str) -> None:
@router.post("/api/reviews/comment")
async def reviews_comment(body: CommentBody):
_check(body.repo, body.branch)
- # A newline would split the heading line and parse_comments would drop the entry.
- if not body.stop.strip() or "\n" in body.stop or "\r" in body.stop:
- raise HTTPException(400, "bad stop")
+ _check_stop(body.stop)
ts = datetime.now().strftime("%Y-%m-%dT%H:%M")
# Append BEFORE delivery: a comment with no pane to hear it is still kept,
# and the next pane to prepare the branch is told to read the file.
@@ -140,6 +164,32 @@ async def reviews_comment(body: CommentBody):
return {"ok": True}
+def _set_reviewed(repo: str, branch: str, stop: str, sig: str | None) -> None:
+ # A dir can hold comments.md but no walkthrough: there's nothing to mark.
+ # Checked in the same thread as the write so the stat never blocks the
+ # event loop; raising here maps to the route's 404 same as a mid-request clear.
+ if not reviews.walkthrough_path(repo, branch).is_file():
+ raise FileNotFoundError
+ reviews.set_reviewed(repo, branch, stop, sig)
+
+
+@router.post("/api/reviews/reviewed")
+async def reviews_reviewed(body: ReviewedBody):
+ """Mark or unmark one stop reviewed (THI-443 D6). The sig ties the mark to
+ the stop's text, so a re-prepare that rewrites the stop lapses it."""
+ _check(body.repo, body.branch)
+ _check_stop(body.stop)
+ if not _SIG_RE.fullmatch(body.sig):
+ raise HTTPException(400, "bad sig")
+ sig = body.sig if body.reviewed else None
+ try:
+ await asyncio.to_thread(_set_reviewed, body.repo, body.branch, body.stop, sig)
+ except FileNotFoundError:
+ # No walkthrough, or one cleared mid-request; a mark never recreates it (THI-443 D6).
+ raise HTTPException(404, f"no walkthrough for {body.repo} {body.branch}") from None
+ return {"ok": True}
+
+
def _prepare_prompt(repo: str, branch: str) -> str:
return (
f"Run the `walkthrough` skill for branch `{branch}` and write it to "
diff --git a/skills/walkthrough/SKILL.md b/skills/walkthrough/SKILL.md
index 5965366a..4a2486f4 100644
--- a/skills/walkthrough/SKILL.md
+++ b/skills/walkthrough/SKILL.md
@@ -51,7 +51,7 @@ Start from the stat and group files into conceptual units: a new module, its rou
### 4. Write walkthrough.md
-Write `/walkthrough.md` in the format below, stops ordered as in "Ordering", with diagrams where "Diagrams" calls for them. A re-run rewrites the file wholesale with the new `head`, keeping the titles of stops that still hold so their comments stay attached. A re-run leaves `comments.md` alone apart from step 6.
+Write `/walkthrough.md` in the format below, stops ordered as in "Ordering", with diagrams where "Diagrams" calls for them. A re-run rewrites the file wholesale with the new `head`, keeping the titles of stops that still hold so their comments stay attached. A re-run leaves `comments.md` alone apart from step 6, and never touches `reviewed.json` (periscope's reviewed marks).
### 5. Verify
@@ -127,7 +127,7 @@ Order stops by damage-if-wrong; the first stop is the one Tom must not skip. By
## Diagrams
-Draw a mermaid `flowchart` on a stop that introduces a new boundary or changes a path every existing caller takes. Two or three per walkthrough is the usual count, well short of one per stop; a stop that only consumes an existing module gets none. Show the mechanism: who calls whom, what flows where, what crosses the boundary. Mermaid goes in a ```` ```mermaid ```` fence.
+Draw a mermaid `flowchart` on a stop that introduces a new boundary or changes a path every existing caller takes. Two or three per walkthrough is the usual count, well short of one per stop; a stop that only consumes an existing module gets none. Show the mechanism: who calls whom, what flows where, what crosses the boundary. Mermaid goes in a ```` ```mermaid ```` fence. The view draws a stop's diagrams in a full-width row above its text, so a diagram should make sense before the prose explains it.
## Example
diff --git a/static/dist/app.js b/static/dist/app.js
index 43c99170..60d26131 100644
--- a/static/dist/app.js
+++ b/static/dist/app.js
@@ -1,48 +1,50 @@
-var Ai,le,lc,ac,dt,ts,sc,oc,il,Fr,qn,cc,oa,Ml,Ll,ri={},ii=[],uh=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Mi=Array.isArray;function Xe(e,t){for(var n in t)e[n]=t[n];return e}function ca(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function dh(e,t,n){var i,l,a,s={};for(a in t)a=="key"?i=t[a]:a=="ref"?l=t[a]:s[a]=t[a];if(arguments.length>2&&(s.children=arguments.length>3?Ai.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(a in e.defaultProps)s[a]===void 0&&(s[a]=e.defaultProps[a]);return Nr(e,s,i,l,null)}function Nr(e,t,n,i,l){var a={type:e,props:t,key:n,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:l??++lc,__i:-1,__u:0};return l==null&&le.vnode!=null&&le.vnode(a),a}function K(e){return e.children}function Un(e,t){this.props=e,this.context=t}function gn(e,t){if(t==null)return e.__?gn(e.__,e.__i+1):null;for(var n;tt&&dt.sort(oc),e=dt.shift(),t=dt.length,hh(e)}finally{dt.length=li.__r=0}}function dc(e,t,n,i,l,a,s,o,u,c,p){var d,f,h,m,b,x,w,C=i&&i.__k||ii,y=t.length;for(u=fh(n,t,C,u,y),d=0;d0?s=e.__k[a]=Nr(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):e.__k[a]=s,u=a+f,s.__=e,s.__b=e.__b+1,o=null,(c=s.__i=ph(s,n,u,d))!=-1&&(d--,(o=n[c])&&(o.__u|=2)),o==null||o.__v==null?(c==-1&&(l>p?f--:lu?f--:f++,s.__u|=4))):e.__k[a]=null;if(d)for(a=0;a
(p?1:0)){for(l=n-1,a=n+1;l>=0||a=0?l--:a++])!=null&&!(2&c.__u)&&o==c.key&&u==c.type)return s}return-1}function rs(e,t,n){t[0]=="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||uh.test(t)?n:n+"px"}function Cr(e,t,n,i,l){var a,s;e:if(t=="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof i=="string"&&(e.style.cssText=i=""),i)for(t in i)n&&t in n||rs(e.style,t,"");if(n)for(t in n)i&&n[t]==i[t]||rs(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")a=t!=(t=t.replace(cc,"$1")),s=t.toLowerCase(),t=s in e||t=="onFocusOut"||t=="onFocusIn"?s.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+a]=n,n?i?n[qn]=i[qn]:(n[qn]=oa,e.addEventListener(t,a?Ll:Ml,a)):e.removeEventListener(t,a?Ll:Ml,a);else{if(l=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n))}}function is(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[Fr]==null)t[Fr]=oa++;else if(t[Fr]0?e:Mi(e)?e.map(pc):e.constructor!==void 0?null:Xe({},e)}function mh(e,t,n,i,l,a,s,o,u){var c,p,d,f,h,m,b,x=n.props||ri,w=t.props,C=t.type;if(C=="svg"?l="http://www.w3.org/2000/svg":C=="math"?l="http://www.w3.org/1998/Math/MathML":l||(l="http://www.w3.org/1999/xhtml"),a!=null){for(c=0;c=n.__.length&&n.__.push({}),n.__[e]}function B(e){return tr=1,kh(bc,e)}function kh(e,t,n){var i=ha(er++,2);if(i.t=e,!i.__c&&(i.__=[bc(void 0,t),function(o){var u=i.__N?i.__N[0]:i.__[0],c=i.t(u,o);u!==c&&(i.__N=[c,i.__[1]],i.__c.setState({}))}],i.__c=pe,!pe.__f)){var l=function(o,u,c){if(!i.__c.__H)return!0;var p=i.__c.__H.__.filter(function(f){return f.__c});if(p.every(function(f){return!f.__N}))return!a||a.call(this,o,u,c);var d=i.__c.props!==o;return p.some(function(f){if(f.__N){var h=f.__[0];f.__=f.__N,f.__N=void 0,h!==f.__[0]&&(d=!0)}}),a&&a.call(this,o,u,c)||d};pe.__f=!0;var a=pe.shouldComponentUpdate,s=pe.componentWillUpdate;pe.componentWillUpdate=function(o,u,c){if(this.__e){var p=a;a=void 0,l(o,u,c),a=p}s&&s.call(this,o,u,c)},pe.shouldComponentUpdate=l}return i.__N||i.__}function j(e,t){var n=ha(er++,3);!ge.__s&&yc(n.__H,t)&&(n.__=e,n.u=t,pe.__H.__h.push(n))}function te(e){return tr=5,yr(function(){return{current:e}},[])}function yr(e,t){var n=ha(er++,7);return yc(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function br(e,t){return tr=8,yr(function(){return e},t)}function wh(){for(var e;e=gc.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Br),t.__h.some(Ol),t.__h=[]}catch(n){t.__h=[],ge.__e(n,e.__v)}}}ge.__b=function(e){pe=null,as&&as(e)},ge.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),ds&&ds(e,t)},ge.__r=function(e){ss&&ss(e),er=0;var t=(pe=e.__c).__H;t&&(ll===pe?(t.__h=[],pe.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(Br),t.__h.some(Ol),t.__h=[],er=0)),ll=pe},ge.diffed=function(e){os&&os(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(gc.push(t)!==1&&ls===ge.requestAnimationFrame||((ls=ge.requestAnimationFrame)||vh)(wh)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),ll=pe=null},ge.__c=function(e,t){t.some(function(n){try{n.__h.some(Br),n.__h=n.__h.filter(function(i){return!i.__||Ol(i)})}catch(i){t.some(function(l){l.__h&&(l.__h=[])}),t=[],ge.__e(i,n.__v)}}),cs&&cs(e,t)},ge.unmount=function(e){us&&us(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(i){try{Br(i)}catch(l){t=l}}),n.__H=void 0,t&&ge.__e(t,n.__v))};var hs=typeof requestAnimationFrame=="function";function vh(e){var t,n=function(){clearTimeout(i),hs&&cancelAnimationFrame(t),setTimeout(e)},i=setTimeout(n,35);hs&&(t=requestAnimationFrame(n))}function Br(e){var t=pe,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),pe=t}function Ol(e){var t=pe;e.__c=e.__(),pe=t}function yc(e,t){return!e||e.length!==t.length||t.some(function(n,i){return n!==e[i]})}function bc(e,t){return typeof t=="function"?t(e):t}var _h=Symbol.for("preact-signals");function fa(){if(Rt>1)Rt--;else{var e,t=!1;for(function(){var l=si;for(si=void 0;l!==void 0;)l.S.v===l.v&&(l.S.i=l.i),l=l.o}();Wn!==void 0;){var n=Wn;for(Wn=void 0,ai++;n!==void 0;){var i=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&wc(n))try{n.c()}catch(l){t||(e=l,t=!0)}n=i}}if(ai=0,Rt--,t)throw e}}var se=void 0;function Li(e){var t=se;se=void 0;try{return e()}finally{se=t}}var Wn=void 0,Rt=0,ai=0,fs=0,si=void 0,oi=0;function kc(e){if(se!==void 0){var t=e.n;if(t===void 0||t.t!==se)return t={i:0,S:e,p:se.s,n:void 0,t:se,e:void 0,x:void 0,r:t},se.s!==void 0&&(se.s.n=t),se.s=t,e.n=t,32&se.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=se.s,t.n=void 0,se.s.n=t,se.s=t),t}}function ve(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t==null?void 0:t.watched,this.Z=t==null?void 0:t.unwatched,this.name=t==null?void 0:t.name}ve.prototype.brand=_h;ve.prototype.h=function(){return!0};ve.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n!==void 0?n.e=e:Li(function(){var i;(i=t.W)==null||i.call(t)}))};ve.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,i=e.x;n!==void 0&&(n.x=i,e.e=void 0),i!==void 0&&(i.e=n,e.x=void 0),e===this.t&&(this.t=i,i===void 0&&Li(function(){var l;(l=t.Z)==null||l.call(t)}))}};ve.prototype.subscribe=function(e){var t=this;return it(function(){var n=t.value,i=se;se=void 0;try{e(n)}finally{se=i}},{name:"sub"})};ve.prototype.valueOf=function(){return this.value};ve.prototype.toString=function(){return this.value+""};ve.prototype.toJSON=function(){return this.value};ve.prototype.peek=function(){var e=this;return Li(function(){return e.value})};Object.defineProperty(ve.prototype,"value",{get:function(){var e=kc(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(ai>100)throw new Error("Cycle detected");(function(n){Rt!==0&&ai===0&&n.l!==fs&&(n.l=fs,si={S:n,v:n.v,i:n.i,o:si})})(this),this.v=e,this.i++,oi++,Rt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{fa()}}}});function H(e,t){return new ve(e,t)}function wc(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function vc(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function _c(e){for(var t=e.s,n=void 0;t!==void 0;){var i=t.p;t.i===-1?(t.S.U(t),i!==void 0&&(i.n=t.n),t.n!==void 0&&(t.n.p=i)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=i}e.s=n}function Kt(e,t){ve.call(this,void 0),this.x=e,this.s=void 0,this.g=oi-1,this.f=4,this.W=t==null?void 0:t.watched,this.Z=t==null?void 0:t.unwatched,this.name=t==null?void 0:t.name}Kt.prototype=new ve;Kt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===oi))return!0;if(this.g=oi,this.f|=1,this.i>0&&!wc(this))return this.f&=-2,!0;var e=se;try{vc(this),se=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return se=e,_c(this),this.f&=-2,!0};Kt.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}ve.prototype.S.call(this,e)};Kt.prototype.U=function(e){if(this.t!==void 0&&(ve.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};Kt.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(Kt.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=kc(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function Vt(e,t){return new Kt(e,t)}function xc(e){var t=e.m;if(e.m=void 0,typeof t=="function"){Rt++;var n=se;se=void 0;try{t()}catch(i){throw e.f&=-2,e.f|=8,pa(e),i}finally{se=n,fa()}}}function pa(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,xc(e)}function xh(e){if(se!==this)throw new Error("Out-of-order effect");_c(this),se=e,this.f&=-2,8&this.f&&pa(this),fa()}function xn(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t==null?void 0:t.name}xn.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.m=t)}finally{e()}};xn.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,xc(this),vc(this),Rt++;var e=se;return se=this,xh.bind(this,e)};xn.prototype.N=function(){2&this.f||(this.f|=2,this.u=Wn,Wn=this)};xn.prototype.d=function(){this.f|=8,1&this.f||pa(this)};xn.prototype.dispose=function(){this.d()};function it(e,t){var n=new xn(e,t);try{n.c()}catch(l){throw n.d(),l}var i=n.d.bind(n);return i[Symbol.dispose]=i,i}var Ii,Tr;function Sn(e,t){le[e]=t.bind(null,le[e]||function(){})}function ci(e){if(Tr){var t=Tr;Tr=void 0,t()}Tr=e&&e.S()}function Sc(e){var t=this,n=e.data,i=$c(n);i.value=n;var l=yr(function(){for(var a=t.__v;a=a.__;)if(a.__c){a.__c.__$f|=4;break}return t.__$u.c=function(){var s,o=t.__$u.S(),u=l.value;o(),ac(u)||((s=t.base)==null?void 0:s.nodeType)!==3?(t.__$f|=1,t.setState({})):t.base.data=u},Vt(function(){var s=i.value.value;return s===0?0:s===!0?"":s||""})},[]);return l.value}Sc.displayName="_st";Object.defineProperties(ve.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:Sc},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});Sn("__b",function(e,t){if(typeof t.type=="string"){var n,i=t.props;for(var l in i)if(l!=="children"){var a=i[l];a instanceof ve&&(n||(t.__np=n={}),n[l]=a,i[l]=a.peek())}}e(t)});Sn("__r",function(e,t){e(t),ci();var n,i=t.__c;i&&(i.__$f&=-2,(n=i.__$u)===void 0&&(i.__$u=n=function(l){var a;return it(function(){a=this}),a.c=function(){i.__$f|=1,i.setState({})},a}())),Ii=i,ci(n)});Sn("__e",function(e,t,n,i){ci(),Ii=void 0,e(t,n,i)});Sn("diffed",function(e,t){ci(),Ii=void 0;var n;if(typeof t.type=="string"&&(n=t.__e)){var i=t.__np,l=t.props;if(i){var a=n.U;if(a)for(var s in a){var o=a[s];o!==void 0&&!(s in i)&&(o.d(),a[s]=void 0)}else n.U=a={};for(var u in i){var c=a[u],p=i[u];c===void 0?(c=Sh(n,u,p,l),a[u]=c):c.o(p,l)}}}e(t)});function Sh(e,t,n,i){var l=t in e&&e.ownerSVGElement===void 0,a=H(n);return{o:function(s,o){a.value=s,i=o},d:it(function(){var s=a.value.value;i[t]!==s&&(i[t]=s,l?e[t]=s:s?e.setAttribute(t,s):e.removeAttribute(t))})}}Sn("unmount",function(e,t){if(typeof t.type=="string"){var n=t.__e;if(n){var i=n.U;if(i){n.U=void 0;for(var l in i){var a=i[l];a&&a.d()}}}}else{var s=t.__c;if(s){var o=s.__$u;o&&(s.__$u=void 0,o.d())}}e(t)});Sn("__h",function(e,t,n,i){(i<3||i===9)&&(t.__$f|=2),e(t,n,i)});Un.prototype.shouldComponentUpdate=function(e,t){if(this.__R)return!0;var n=this.__$u,i=n&&n.s!==void 0;for(var l in t)return!0;if(this.__f||typeof this.u=="boolean"&&this.u===!0){if(!(i||2&this.__$f||4&this.__$f)||1&this.__$f)return!0}else if(!(i||4&this.__$f)||3&this.__$f)return!0;for(var a in e)if(a!=="__source"&&e[a]!==this.props[a])return!0;for(var s in this.props)if(!(s in e))return!0;return!1};function $c(e){return yr(function(){return H(e)},[])}function al(e){var t=te(e);return t.current=e,Ii.__$f|=4,yr(function(){return Vt(function(){return t.current()})},[])}const ce=H([]),Oi=H([]),Di=H([]),Bt=H([]),gt=H(null),ps=H(""),Dl=H(null),nr=H(null),Rl=H("all"),rr=H(null),ke=H(null),Et=H(null),Ri=H(null),ma=H(null),Cc=H(null),lt=H([]),ui=H({}),Kn=H(null),Vn=H(null),Gn=H(null),Tc=H(null),ga=H([]),sn=H(null),Ec=H(""),Pc=H(0),ya=H(null),zr=H({}),Ft=H({}),Ne=H({}),Re=H({}),ms=H(0);let Ac=0;function $h(e){if(Date.now()-Ac<3e3)return;const t={},n={};for(const i of e){if(!i.pid)continue;const l=i.open_tabs||[];l.length&&(t[i.pid]=l.map(a=>({...a,target:i.target}))),i.active_tab&&i.active_tab!=="pane"&&(n[i.pid]=i.active_tab)}Ne.value=t,Re.value=n}function ba(e,t){Ac=Date.now(),fetch(`/api/pane/tabs/${e}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)}).catch(()=>{})}function kr(e){const t=rr.value;if(!t)return;const n=(ce.value||[]).find(s=>s.target===t);if(!n)return;const i=n.pid,l=Ne.value[i]||[],a=l.find(s=>s.path===e.path);a?e.line&&e.line!==a.line&&(Ne.value={...Ne.value,[i]:l.map(s=>s.path===e.path?{...s,line:e.line}:s)}):Ne.value={...Ne.value,[i]:[...l,{...e,target:t}]},Re.value={...Re.value,[i]:`file:${e.path}`},ba("open",{pid:i,path:e.path,line:e.line??null})}function Mc(e,t){const i=(Ne.value[e]||[]).filter(l=>l.path!==t);Ne.value={...Ne.value,[e]:i},Re.value[e]===`file:${t}`&&(Re.value={...Re.value,[e]:"pane"}),ba("close",{pid:e,path:t})}function jr(e,t){Re.value={...Re.value,[e]:t},ba("activate",{pid:e,tab:t})}const ir=H(new Set),ft=H(new Set),pt=H(new Set);function yn(e,t=lt.value){var n;return((n=t.find(i=>i.id===e))==null?void 0:n.label)||e}function $n(e=lt.value){return e.length>1}function Ch(e,t=lt.value,n=ui.value){if(!(e.agent==="claude"||e.is_claude))return null;const i=e.account||"default";if(!t.some(a=>a.id===i))return null;const l=n==null?void 0:n[i];return t.find(a=>a.id===l&&l!==i)||null}const on=[];function Th(e){e.key==="Escape"&&on.length&&(e.stopPropagation(),on[on.length-1](e))}typeof window<"u"&&window.addEventListener("keydown",Th,!0);function ot(e,t=!0){j(()=>{if(t)return on.push(e),()=>{const n=on.indexOf(e);n>=0&&on.splice(n,1)}},[e,t])}function Fi(e,t,n){ot(n,t),j(()=>{if(!t)return;function i(l){e.current&&!e.current.contains(l.target)&&n()}return document.addEventListener("click",i),()=>document.removeEventListener("click",i)},[t,n])}const Eh={};function Ph(e,t){const n=Eh,i=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,l=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return Lc(e,i,l)}function Lc(e,t,n){if(Ah(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return gs(e.children,t,n)}return Array.isArray(e)?gs(e,t,n):""}function gs(e,t,n){const i=[];let l=-1;for(;++ll?0:l+t:t=t>l?l:t,n=n>0?n:0,i.length<1e4)s=Array.from(i),s.unshift(t,n),e.splice(...s);else for(n&&e.splice(t,n);a0?(Ie(e,e.length,0,t),e):t}const bs={}.hasOwnProperty;function Ic(e){const t={};let n=-1;for(;++n13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function je(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Se=wt(/[A-Za-z]/),Ee=wt(/[\dA-Za-z]/),Ih=wt(/[#-'*+\--9=?A-Z^-~]/);function di(e){return e!==null&&(e<32||e===127)}const Fl=wt(/\d/),Oh=wt(/[\dA-Fa-f]/),Dh=wt(/[!-/:-@[-`{-~]/);function U(e){return e!==null&&e<-2}function oe(e){return e!==null&&(e<0||e===32)}function ee(e){return e===-2||e===-1||e===32}const Ni=wt(new RegExp("\\p{P}|\\p{S}","u")),zt=wt(/\s/);function wt(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function re(e,t,n,i){const l=i?i-1:Number.POSITIVE_INFINITY;let a=0;return s;function s(u){return ee(u)?(e.enter(n),o(u)):t(u)}function o(u){return ee(u)&&a++s))return;const E=t.events.length;let M=E,T,S;for(;M--;)if(t.events[M][0]==="exit"&&t.events[M][1].type==="chunkFlow"){if(T){S=t.events[M][1].end;break}T=!0}for(w(i),v=E;vy;){const $=n[g];t.containerState=$[1],$[0].exit.call(t,e)}n.length=y}function C(){l.write([null]),a=void 0,l=void 0,t.containerState._closeFlow=void 0}}function zh(e,t,n){return re(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function hi(e){if(e===null||oe(e)||zt(e))return 1;if(Ni(e))return 2}function Bi(e,t,n){const i=[];let l=-1;for(;++l1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const d={...e[i][1].end},f={...e[n][1].start};ws(d,-u),ws(f,u),s={type:u>1?"strongSequence":"emphasisSequence",start:d,end:{...e[i][1].end}},o={type:u>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:f},a={type:u>1?"strongText":"emphasisText",start:{...e[i][1].end},end:{...e[n][1].start}},l={type:u>1?"strong":"emphasis",start:{...s.start},end:{...o.end}},e[i][1].end={...s.start},e[n][1].start={...o.end},c=[],e[i][1].end.offset-e[i][1].start.offset&&(c=De(c,[["enter",e[i][1],t],["exit",e[i][1],t]])),c=De(c,[["enter",l,t],["enter",s,t],["exit",s,t],["enter",a,t]]),c=De(c,Bi(t.parser.constructs.insideSpan.null,e.slice(i+1,n),t)),c=De(c,[["exit",a,t],["enter",o,t],["exit",o,t],["exit",l,t]]),e[n][1].end.offset-e[n][1].start.offset?(p=2,c=De(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):p=0,Ie(e,i-1,n-i+3,c),n=i+c.length-p-2;break}}for(n=-1;++n0&&ee(v)?re(e,C,"linePrefix",a+1)(v):C(v)}function C(v){return v===null||U(v)?e.check(vs,b,g)(v):(e.enter("codeFlowValue"),y(v))}function y(v){return v===null||U(v)?(e.exit("codeFlowValue"),C(v)):(e.consume(v),y)}function g(v){return e.exit("codeFenced"),t(v)}function $(v,E,M){let T=0;return S;function S(I){return v.enter("lineEnding"),v.consume(I),v.exit("lineEnding"),R}function R(I){return v.enter("codeFencedFence"),ee(I)?re(v,F,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(I):F(I)}function F(I){return I===o?(v.enter("codeFencedFenceSequence"),q(I)):M(I)}function q(I){return I===o?(T++,v.consume(I),q):T>=s?(v.exit("codeFencedFenceSequence"),ee(I)?re(v,L,"whitespace")(I):L(I)):M(I)}function L(I){return I===null||U(I)?(v.exit("codeFencedFence"),E(I)):M(I)}}}function Zh(e,t,n){const i=this;return l;function l(s){return s===null?n(s):(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),a)}function a(s){return i.parser.lazy[i.now().line]?n(s):t(s)}}const sl={name:"codeIndented",tokenize:ef},Xh={partial:!0,tokenize:tf};function ef(e,t,n){const i=this;return l;function l(c){return e.enter("codeIndented"),re(e,a,"linePrefix",5)(c)}function a(c){const p=i.events[i.events.length-1];return p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?s(c):n(c)}function s(c){return c===null?u(c):U(c)?e.attempt(Xh,s,u)(c):(e.enter("codeFlowValue"),o(c))}function o(c){return c===null||U(c)?(e.exit("codeFlowValue"),s(c)):(e.consume(c),o)}function u(c){return e.exit("codeIndented"),t(c)}}function tf(e,t,n){const i=this;return l;function l(s){return i.parser.lazy[i.now().line]?n(s):U(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),l):re(e,a,"linePrefix",5)(s)}function a(s){const o=i.events[i.events.length-1];return o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(s):U(s)?l(s):n(s)}}const nf={name:"codeText",previous:lf,resolve:rf,tokenize:af};function rf(e){let t=e.length-4,n=3,i,l;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(i=n;++i=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return tthis.left.length?this.right.slice(this.right.length-i+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-i+this.left.length).reverse())}splice(t,n,i){const l=n||0;this.setCursor(Math.trunc(t));const a=this.right.splice(this.right.length-l,Number.POSITIVE_INFINITY);return i&&Mn(this.left,i),a.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Mn(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Mn(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t=4?t(s):e.interrupt(i.parser.constructs.flow,n,t)(s)}}function Bc(e,t,n,i,l,a,s,o,u){const c=u||Number.POSITIVE_INFINITY;let p=0;return d;function d(w){return w===60?(e.enter(i),e.enter(l),e.enter(a),e.consume(w),e.exit(a),f):w===null||w===32||w===41||di(w)?n(w):(e.enter(i),e.enter(s),e.enter(o),e.enter("chunkString",{contentType:"string"}),b(w))}function f(w){return w===62?(e.enter(a),e.consume(w),e.exit(a),e.exit(l),e.exit(i),t):(e.enter(o),e.enter("chunkString",{contentType:"string"}),h(w))}function h(w){return w===62?(e.exit("chunkString"),e.exit(o),f(w)):w===null||w===60||U(w)?n(w):(e.consume(w),w===92?m:h)}function m(w){return w===60||w===62||w===92?(e.consume(w),h):h(w)}function b(w){return!p&&(w===null||w===41||oe(w))?(e.exit("chunkString"),e.exit(o),e.exit(s),e.exit(i),t(w)):p999||h===null||h===91||h===93&&!u||h===94&&!o&&"_hiddenFootnoteSupport"in s.parser.constructs?n(h):h===93?(e.exit(a),e.enter(l),e.consume(h),e.exit(l),e.exit(i),t):U(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),p):(e.enter("chunkString",{contentType:"string"}),d(h))}function d(h){return h===null||h===91||h===93||U(h)||o++>999?(e.exit("chunkString"),p(h)):(e.consume(h),u||(u=!ee(h)),h===92?f:d)}function f(h){return h===91||h===92||h===93?(e.consume(h),o++,d):d(h)}}function jc(e,t,n,i,l,a){let s;return o;function o(f){return f===34||f===39||f===40?(e.enter(i),e.enter(l),e.consume(f),e.exit(l),s=f===40?41:f,u):n(f)}function u(f){return f===s?(e.enter(l),e.consume(f),e.exit(l),e.exit(i),t):(e.enter(a),c(f))}function c(f){return f===s?(e.exit(a),u(s)):f===null?n(f):U(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),re(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),p(f))}function p(f){return f===s||f===null||U(f)?(e.exit("chunkString"),c(f)):(e.consume(f),f===92?d:p)}function d(f){return f===s||f===92?(e.consume(f),p):p(f)}}function Jn(e,t){let n;return i;function i(l){return U(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),n=!0,i):ee(l)?re(e,i,n?"linePrefix":"lineSuffix")(l):t(l)}}const pf={name:"definition",tokenize:gf},mf={partial:!0,tokenize:yf};function gf(e,t,n){const i=this;let l;return a;function a(h){return e.enter("definition"),s(h)}function s(h){return zc.call(i,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function o(h){return l=je(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),u):n(h)}function u(h){return oe(h)?Jn(e,c)(h):c(h)}function c(h){return Bc(e,p,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function p(h){return e.attempt(mf,d,d)(h)}function d(h){return ee(h)?re(e,f,"whitespace")(h):f(h)}function f(h){return h===null||U(h)?(e.exit("definition"),i.parser.defined.push(l),t(h)):n(h)}}function yf(e,t,n){return i;function i(o){return oe(o)?Jn(e,l)(o):n(o)}function l(o){return jc(e,a,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(o)}function a(o){return ee(o)?re(e,s,"whitespace")(o):s(o)}function s(o){return o===null||U(o)?t(o):n(o)}}const bf={name:"hardBreakEscape",tokenize:kf};function kf(e,t,n){return i;function i(a){return e.enter("hardBreakEscape"),e.consume(a),l}function l(a){return U(a)?(e.exit("hardBreakEscape"),t(a)):n(a)}}const wf={name:"headingAtx",resolve:vf,tokenize:_f};function vf(e,t){let n=e.length-2,i=3,l,a;return e[i][1].type==="whitespace"&&(i+=2),n-2>i&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(i===n-1||n-4>i&&e[n-2][1].type==="whitespace")&&(n-=i+1===n?2:4),n>i&&(l={type:"atxHeadingText",start:e[i][1].start,end:e[n][1].end},a={type:"chunkText",start:e[i][1].start,end:e[n][1].end,contentType:"text"},Ie(e,i,n-i+1,[["enter",l,t],["enter",a,t],["exit",a,t],["exit",l,t]])),e}function _f(e,t,n){let i=0;return l;function l(p){return e.enter("atxHeading"),a(p)}function a(p){return e.enter("atxHeadingSequence"),s(p)}function s(p){return p===35&&i++<6?(e.consume(p),s):p===null||oe(p)?(e.exit("atxHeadingSequence"),o(p)):n(p)}function o(p){return p===35?(e.enter("atxHeadingSequence"),u(p)):p===null||U(p)?(e.exit("atxHeading"),t(p)):ee(p)?re(e,o,"whitespace")(p):(e.enter("atxHeadingText"),c(p))}function u(p){return p===35?(e.consume(p),u):(e.exit("atxHeadingSequence"),o(p))}function c(p){return p===null||p===35||oe(p)?(e.exit("atxHeadingText"),o(p)):(e.consume(p),c)}}const xf=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],xs=["pre","script","style","textarea"],Sf={concrete:!0,name:"htmlFlow",resolveTo:Tf,tokenize:Ef},$f={partial:!0,tokenize:Af},Cf={partial:!0,tokenize:Pf};function Tf(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Ef(e,t,n){const i=this;let l,a,s,o,u;return c;function c(_){return p(_)}function p(_){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(_),d}function d(_){return _===33?(e.consume(_),f):_===47?(e.consume(_),a=!0,b):_===63?(e.consume(_),l=3,i.interrupt?t:k):Se(_)?(e.consume(_),s=String.fromCharCode(_),x):n(_)}function f(_){return _===45?(e.consume(_),l=2,h):_===91?(e.consume(_),l=5,o=0,m):Se(_)?(e.consume(_),l=4,i.interrupt?t:k):n(_)}function h(_){return _===45?(e.consume(_),i.interrupt?t:k):n(_)}function m(_){const X="CDATA[";return _===X.charCodeAt(o++)?(e.consume(_),o===X.length?i.interrupt?t:F:m):n(_)}function b(_){return Se(_)?(e.consume(_),s=String.fromCharCode(_),x):n(_)}function x(_){if(_===null||_===47||_===62||oe(_)){const X=_===47,he=s.toLowerCase();return!X&&!a&&xs.includes(he)?(l=1,i.interrupt?t(_):F(_)):xf.includes(s.toLowerCase())?(l=6,X?(e.consume(_),w):i.interrupt?t(_):F(_)):(l=7,i.interrupt&&!i.parser.lazy[i.now().line]?n(_):a?C(_):y(_))}return _===45||Ee(_)?(e.consume(_),s+=String.fromCharCode(_),x):n(_)}function w(_){return _===62?(e.consume(_),i.interrupt?t:F):n(_)}function C(_){return ee(_)?(e.consume(_),C):S(_)}function y(_){return _===47?(e.consume(_),S):_===58||_===95||Se(_)?(e.consume(_),g):ee(_)?(e.consume(_),y):S(_)}function g(_){return _===45||_===46||_===58||_===95||Ee(_)?(e.consume(_),g):$(_)}function $(_){return _===61?(e.consume(_),v):ee(_)?(e.consume(_),$):y(_)}function v(_){return _===null||_===60||_===61||_===62||_===96?n(_):_===34||_===39?(e.consume(_),u=_,E):ee(_)?(e.consume(_),v):M(_)}function E(_){return _===u?(e.consume(_),u=null,T):_===null||U(_)?n(_):(e.consume(_),E)}function M(_){return _===null||_===34||_===39||_===47||_===60||_===61||_===62||_===96||oe(_)?$(_):(e.consume(_),M)}function T(_){return _===47||_===62||ee(_)?y(_):n(_)}function S(_){return _===62?(e.consume(_),R):n(_)}function R(_){return _===null||U(_)?F(_):ee(_)?(e.consume(_),R):n(_)}function F(_){return _===45&&l===2?(e.consume(_),O):_===60&&l===1?(e.consume(_),Q):_===62&&l===4?(e.consume(_),W):_===63&&l===3?(e.consume(_),k):_===93&&l===5?(e.consume(_),z):U(_)&&(l===6||l===7)?(e.exit("htmlFlowData"),e.check($f,Z,q)(_)):_===null||U(_)?(e.exit("htmlFlowData"),q(_)):(e.consume(_),F)}function q(_){return e.check(Cf,L,Z)(_)}function L(_){return e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),I}function I(_){return _===null||U(_)?q(_):(e.enter("htmlFlowData"),F(_))}function O(_){return _===45?(e.consume(_),k):F(_)}function Q(_){return _===47?(e.consume(_),s="",A):F(_)}function A(_){if(_===62){const X=s.toLowerCase();return xs.includes(X)?(e.consume(_),W):F(_)}return Se(_)&&s.length<8?(e.consume(_),s+=String.fromCharCode(_),A):F(_)}function z(_){return _===93?(e.consume(_),k):F(_)}function k(_){return _===62?(e.consume(_),W):_===45&&l===2?(e.consume(_),k):F(_)}function W(_){return _===null||U(_)?(e.exit("htmlFlowData"),Z(_)):(e.consume(_),W)}function Z(_){return e.exit("htmlFlow"),t(_)}}function Pf(e,t,n){const i=this;return l;function l(s){return U(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),a):n(s)}function a(s){return i.parser.lazy[i.now().line]?n(s):t(s)}}function Af(e,t,n){return i;function i(l){return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),e.attempt(wr,t,n)}}const Mf={name:"htmlText",tokenize:Lf};function Lf(e,t,n){const i=this;let l,a,s;return o;function o(k){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(k),u}function u(k){return k===33?(e.consume(k),c):k===47?(e.consume(k),$):k===63?(e.consume(k),y):Se(k)?(e.consume(k),M):n(k)}function c(k){return k===45?(e.consume(k),p):k===91?(e.consume(k),a=0,m):Se(k)?(e.consume(k),C):n(k)}function p(k){return k===45?(e.consume(k),h):n(k)}function d(k){return k===null?n(k):k===45?(e.consume(k),f):U(k)?(s=d,Q(k)):(e.consume(k),d)}function f(k){return k===45?(e.consume(k),h):d(k)}function h(k){return k===62?O(k):k===45?f(k):d(k)}function m(k){const W="CDATA[";return k===W.charCodeAt(a++)?(e.consume(k),a===W.length?b:m):n(k)}function b(k){return k===null?n(k):k===93?(e.consume(k),x):U(k)?(s=b,Q(k)):(e.consume(k),b)}function x(k){return k===93?(e.consume(k),w):b(k)}function w(k){return k===62?O(k):k===93?(e.consume(k),w):b(k)}function C(k){return k===null||k===62?O(k):U(k)?(s=C,Q(k)):(e.consume(k),C)}function y(k){return k===null?n(k):k===63?(e.consume(k),g):U(k)?(s=y,Q(k)):(e.consume(k),y)}function g(k){return k===62?O(k):y(k)}function $(k){return Se(k)?(e.consume(k),v):n(k)}function v(k){return k===45||Ee(k)?(e.consume(k),v):E(k)}function E(k){return U(k)?(s=E,Q(k)):ee(k)?(e.consume(k),E):O(k)}function M(k){return k===45||Ee(k)?(e.consume(k),M):k===47||k===62||oe(k)?T(k):n(k)}function T(k){return k===47?(e.consume(k),O):k===58||k===95||Se(k)?(e.consume(k),S):U(k)?(s=T,Q(k)):ee(k)?(e.consume(k),T):O(k)}function S(k){return k===45||k===46||k===58||k===95||Ee(k)?(e.consume(k),S):R(k)}function R(k){return k===61?(e.consume(k),F):U(k)?(s=R,Q(k)):ee(k)?(e.consume(k),R):T(k)}function F(k){return k===null||k===60||k===61||k===62||k===96?n(k):k===34||k===39?(e.consume(k),l=k,q):U(k)?(s=F,Q(k)):ee(k)?(e.consume(k),F):(e.consume(k),L)}function q(k){return k===l?(e.consume(k),l=void 0,I):k===null?n(k):U(k)?(s=q,Q(k)):(e.consume(k),q)}function L(k){return k===null||k===34||k===39||k===60||k===61||k===96?n(k):k===47||k===62||oe(k)?T(k):(e.consume(k),L)}function I(k){return k===47||k===62||oe(k)?T(k):n(k)}function O(k){return k===62?(e.consume(k),e.exit("htmlTextData"),e.exit("htmlText"),t):n(k)}function Q(k){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),A}function A(k){return ee(k)?re(e,z,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(k):z(k)}function z(k){return e.enter("htmlTextData"),s(k)}}const wa={name:"labelEnd",resolveAll:Rf,resolveTo:Ff,tokenize:Nf},If={tokenize:Bf},Of={tokenize:zf},Df={tokenize:jf};function Rf(e){let t=-1;const n=[];for(;++t=3&&(c===null||U(c))?(e.exit("thematicBreak"),t(c)):n(c)}function u(c){return c===l?(e.consume(c),i++,u):(e.exit("thematicBreakSequence"),ee(c)?re(e,o,"whitespace")(c):o(c))}}const Te={continuation:{tokenize:Yf},exit:Xf,name:"list",tokenize:Qf},Gf={partial:!0,tokenize:ep},Jf={partial:!0,tokenize:Zf};function Qf(e,t,n){const i=this,l=i.events[i.events.length-1];let a=l&&l[1].type==="linePrefix"?l[2].sliceSerialize(l[1],!0).length:0,s=0;return o;function o(h){const m=i.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!i.containerState.marker||h===i.containerState.marker:Fl(h)){if(i.containerState.type||(i.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),h===42||h===45?e.check(Hr,n,c)(h):c(h);if(!i.interrupt||h===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),u(h)}return n(h)}function u(h){return Fl(h)&&++s<10?(e.consume(h),u):(!i.interrupt||s<2)&&(i.containerState.marker?h===i.containerState.marker:h===41||h===46)?(e.exit("listItemValue"),c(h)):n(h)}function c(h){return e.enter("listItemMarker"),e.consume(h),e.exit("listItemMarker"),i.containerState.marker=i.containerState.marker||h,e.check(wr,i.interrupt?n:p,e.attempt(Gf,f,d))}function p(h){return i.containerState.initialBlankLine=!0,a++,f(h)}function d(h){return ee(h)?(e.enter("listItemPrefixWhitespace"),e.consume(h),e.exit("listItemPrefixWhitespace"),f):n(h)}function f(h){return i.containerState.size=a+i.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(h)}}function Yf(e,t,n){const i=this;return i.containerState._closeFlow=void 0,e.check(wr,l,a);function l(o){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,re(e,t,"listItemIndent",i.containerState.size+1)(o)}function a(o){return i.containerState.furtherBlankLines||!ee(o)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,s(o)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,e.attempt(Jf,t,s)(o))}function s(o){return i.containerState._closeFlow=!0,i.interrupt=void 0,re(e,e.attempt(Te,t,n),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}function Zf(e,t,n){const i=this;return re(e,l,"listItemIndent",i.containerState.size+1);function l(a){const s=i.events[i.events.length-1];return s&&s[1].type==="listItemIndent"&&s[2].sliceSerialize(s[1],!0).length===i.containerState.size?t(a):n(a)}}function Xf(e){e.exit(this.containerState.type)}function ep(e,t,n){const i=this;return re(e,l,"listItemPrefixWhitespace",i.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function l(a){const s=i.events[i.events.length-1];return!ee(a)&&s&&s[1].type==="listItemPrefixWhitespace"?t(a):n(a)}}const Ss={name:"setextUnderline",resolveTo:tp,tokenize:np};function tp(e,t){let n=e.length,i,l,a;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){i=n;break}e[n][1].type==="paragraph"&&(l=n)}else e[n][1].type==="content"&&e.splice(n,1),!a&&e[n][1].type==="definition"&&(a=n);const s={type:"setextHeading",start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[l][1].type="setextHeadingText",a?(e.splice(l,0,["enter",s,t]),e.splice(a+1,0,["exit",e[i][1],t]),e[i][1].end={...e[a][1].end}):e[i][1]=s,e.push(["exit",s,t]),e}function np(e,t,n){const i=this;let l;return a;function a(c){let p=i.events.length,d;for(;p--;)if(i.events[p][1].type!=="lineEnding"&&i.events[p][1].type!=="linePrefix"&&i.events[p][1].type!=="content"){d=i.events[p][1].type==="paragraph";break}return!i.parser.lazy[i.now().line]&&(i.interrupt||d)?(e.enter("setextHeadingLine"),l=c,s(c)):n(c)}function s(c){return e.enter("setextHeadingLineSequence"),o(c)}function o(c){return c===l?(e.consume(c),o):(e.exit("setextHeadingLineSequence"),ee(c)?re(e,u,"lineSuffix")(c):u(c))}function u(c){return c===null||U(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const rp={tokenize:ip};function ip(e){const t=this,n=e.attempt(wr,i,e.attempt(this.parser.constructs.flowInitial,l,re(e,e.attempt(this.parser.constructs.flow,l,e.attempt(cf,l)),"linePrefix")));return n;function i(a){if(a===null){e.consume(a);return}return e.enter("lineEndingBlank"),e.consume(a),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function l(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const lp={resolveAll:qc()},ap=Hc("string"),sp=Hc("text");function Hc(e){return{resolveAll:qc(e==="text"?op:void 0),tokenize:t};function t(n){const i=this,l=this.parser.constructs[e],a=n.attempt(l,s,o);return s;function s(p){return c(p)?a(p):o(p)}function o(p){if(p===null){n.consume(p);return}return n.enter("data"),n.consume(p),u}function u(p){return c(p)?(n.exit("data"),a(p)):(n.consume(p),u)}function c(p){if(p===null)return!0;const d=l[p];let f=-1;if(d)for(;++f-1){const o=s[0];typeof o=="string"?s[0]=o.slice(i):s.shift()}a>0&&s.push(e[l].slice(0,a))}return s}function vp(e,t){let n=-1;const i=[];let l;for(;++n2&&(s.children=arguments.length>3?Oi.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(a in e.defaultProps)s[a]===void 0&&(s[a]=e.defaultProps[a]);return zr(e,s,i,l,null)}function zr(e,t,n,i,l){var a={type:e,props:t,key:n,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:l??++gc,__i:-1,__u:0};return l==null&&le.vnode!=null&&le.vnode(a),a}function U(e){return e.children}function un(e,t){this.props=e,this.context=t}function wn(e,t){if(t==null)return e.__?wn(e.__,e.__i+1):null;for(var n;tt&&ht.sort(kc),e=ht.shift(),t=ht.length,Ih(e)}finally{ht.length=si.__r=0}}function xc(e,t,n,i,l,a,s,o,c,u,h){var d,p,f,m,k,x,b,C=i&&i.__k||ai,g=t.length;for(c=Oh(n,t,C,c,g),d=0;d0?s=e.__k[a]=zr(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):e.__k[a]=s,c=a+p,s.__=e,s.__b=e.__b+1,o=null,(u=s.__i=Dh(s,n,c,d))!=-1&&(d--,(o=n[u])&&(o.__u|=2)),o==null||o.__v==null?(u==-1&&(l>h?p--:lc?p--:p++,s.__u|=4))):e.__k[a]=null;if(d)for(a=0;a(h?1:0)){for(l=n-1,a=n+1;l>=0||a=0?l--:a++])!=null&&!(2&u.__u)&&o==u.key&&c==u.type)return s}return-1}function hs(e,t,n){t[0]=="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||Ah.test(t)?n:n+"px"}function Tr(e,t,n,i,l){var a,s;e:if(t=="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof i=="string"&&(e.style.cssText=i=""),i)for(t in i)n&&t in n||hs(e.style,t,"");if(n)for(t in n)i&&n[t]==i[t]||hs(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")a=t!=(t=t.replace(wc,"$1")),s=t.toLowerCase(),t=s in e||t=="onFocusOut"||t=="onFocusIn"?s.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+a]=n,n?i?n[Gn]=i[Gn]:(n[Gn]=ma,e.addEventListener(t,a?Fl:Rl,a)):e.removeEventListener(t,a?Fl:Rl,a);else{if(l=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n))}}function fs(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[Br]==null)t[Br]=ma++;else if(t[Br]0?e:Di(e)?e.map($c):e.constructor!==void 0?null:et({},e)}function Rh(e,t,n,i,l,a,s,o,c){var u,h,d,p,f,m,k,x=n.props||li,b=t.props,C=t.type;if(C=="svg"?l="http://www.w3.org/2000/svg":C=="math"?l="http://www.w3.org/1998/Math/MathML":l||(l="http://www.w3.org/1999/xhtml"),a!=null){for(u=0;u=n.__.length&&n.__.push({}),n.__[e]}function N(e){return lr=1,zh(Pc,e)}function zh(e,t,n){var i=ka(ir++,2);if(i.t=e,!i.__c&&(i.__=[Pc(void 0,t),function(o){var c=i.__N?i.__N[0]:i.__[0],u=i.t(c,o);c!==u&&(i.__N=[u,i.__[1]],i.__c.setState({}))}],i.__c=pe,!pe.__f)){var l=function(o,c,u){if(!i.__c.__H)return!0;var h=i.__c.__H.__.filter(function(p){return p.__c});if(h.every(function(p){return!p.__N}))return!a||a.call(this,o,c,u);var d=i.__c.props!==o;return h.some(function(p){if(p.__N){var f=p.__[0];p.__=p.__N,p.__N=void 0,f!==p.__[0]&&(d=!0)}}),a&&a.call(this,o,c,u)||d};pe.__f=!0;var a=pe.shouldComponentUpdate,s=pe.componentWillUpdate;pe.componentWillUpdate=function(o,c,u){if(this.__e){var h=a;a=void 0,l(o,c,u),a=h}s&&s.call(this,o,c,u)},pe.shouldComponentUpdate=l}return i.__N||i.__}function H(e,t){var n=ka(ir++,3);!ge.__s&&Ec(n.__H,t)&&(n.__=e,n.u=t,pe.__H.__h.push(n))}function J(e){return lr=5,lt(function(){return{current:e}},[])}function lt(e,t){var n=ka(ir++,7);return Ec(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function jt(e,t){return lr=8,lt(function(){return e},t)}function jh(){for(var e;e=Tc.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(jr),t.__h.some(Bl),t.__h=[]}catch(n){t.__h=[],ge.__e(n,e.__v)}}}ge.__b=function(e){pe=null,ms&&ms(e)},ge.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),ws&&ws(e,t)},ge.__r=function(e){gs&&gs(e),ir=0;var t=(pe=e.__c).__H;t&&(cl===pe?(t.__h=[],pe.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(jr),t.__h.some(Bl),t.__h=[],ir=0)),cl=pe},ge.diffed=function(e){ys&&ys(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Tc.push(t)!==1&&ps===ge.requestAnimationFrame||((ps=ge.requestAnimationFrame)||Hh)(jh)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),cl=pe=null},ge.__c=function(e,t){t.some(function(n){try{n.__h.some(jr),n.__h=n.__h.filter(function(i){return!i.__||Bl(i)})}catch(i){t.some(function(l){l.__h&&(l.__h=[])}),t=[],ge.__e(i,n.__v)}}),bs&&bs(e,t)},ge.unmount=function(e){ks&&ks(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(i){try{jr(i)}catch(l){t=l}}),n.__H=void 0,t&&ge.__e(t,n.__v))};var vs=typeof requestAnimationFrame=="function";function Hh(e){var t,n=function(){clearTimeout(i),vs&&cancelAnimationFrame(t),setTimeout(e)},i=setTimeout(n,35);vs&&(t=requestAnimationFrame(n))}function jr(e){var t=pe,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),pe=t}function Bl(e){var t=pe;e.__c=e.__(),pe=t}function Ec(e,t){return!e||e.length!==t.length||t.some(function(n,i){return n!==e[i]})}function Pc(e,t){return typeof t=="function"?t(e):t}var qh=Symbol.for("preact-signals");function wa(){if(Nt>1)Nt--;else{var e,t=!1;for(function(){var l=ci;for(ci=void 0;l!==void 0;)l.S.v===l.v&&(l.S.i=l.i),l=l.o}();Jn!==void 0;){var n=Jn;for(Jn=void 0,oi++;n!==void 0;){var i=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Ac(n))try{n.c()}catch(l){t||(e=l,t=!0)}n=i}}if(oi=0,Nt--,t)throw e}}var se=void 0;function Ri(e){var t=se;se=void 0;try{return e()}finally{se=t}}var Jn=void 0,Nt=0,oi=0,xs=0,ci=void 0,ui=0;function Mc(e){if(se!==void 0){var t=e.n;if(t===void 0||t.t!==se)return t={i:0,S:e,p:se.s,n:void 0,t:se,e:void 0,x:void 0,r:t},se.s!==void 0&&(se.s.n=t),se.s=t,e.n=t,32&se.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=se.s,t.n=void 0,se.s.n=t,se.s=t),t}}function ve(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t==null?void 0:t.watched,this.Z=t==null?void 0:t.unwatched,this.name=t==null?void 0:t.name}ve.prototype.brand=qh;ve.prototype.h=function(){return!0};ve.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n!==void 0?n.e=e:Ri(function(){var i;(i=t.W)==null||i.call(t)}))};ve.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,i=e.x;n!==void 0&&(n.x=i,e.e=void 0),i!==void 0&&(i.e=n,e.x=void 0),e===this.t&&(this.t=i,i===void 0&&Ri(function(){var l;(l=t.Z)==null||l.call(t)}))}};ve.prototype.subscribe=function(e){var t=this;return at(function(){var n=t.value,i=se;se=void 0;try{e(n)}finally{se=i}},{name:"sub"})};ve.prototype.valueOf=function(){return this.value};ve.prototype.toString=function(){return this.value+""};ve.prototype.toJSON=function(){return this.value};ve.prototype.peek=function(){var e=this;return Ri(function(){return e.value})};Object.defineProperty(ve.prototype,"value",{get:function(){var e=Mc(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(oi>100)throw new Error("Cycle detected");(function(n){Nt!==0&&oi===0&&n.l!==xs&&(n.l=xs,ci={S:n,v:n.v,i:n.i,o:ci})})(this),this.v=e,this.i++,ui++,Nt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{wa()}}}});function q(e,t){return new ve(e,t)}function Ac(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Lc(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function Ic(e){for(var t=e.s,n=void 0;t!==void 0;){var i=t.p;t.i===-1?(t.S.U(t),i!==void 0&&(i.n=t.n),t.n!==void 0&&(t.n.p=i)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=i}e.s=n}function Jt(e,t){ve.call(this,void 0),this.x=e,this.s=void 0,this.g=ui-1,this.f=4,this.W=t==null?void 0:t.watched,this.Z=t==null?void 0:t.unwatched,this.name=t==null?void 0:t.name}Jt.prototype=new ve;Jt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===ui))return!0;if(this.g=ui,this.f|=1,this.i>0&&!Ac(this))return this.f&=-2,!0;var e=se;try{Lc(this),se=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return se=e,Ic(this),this.f&=-2,!0};Jt.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}ve.prototype.S.call(this,e)};Jt.prototype.U=function(e){if(this.t!==void 0&&(ve.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};Jt.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(Jt.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Mc(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function Qt(e,t){return new Jt(e,t)}function Oc(e){var t=e.m;if(e.m=void 0,typeof t=="function"){Nt++;var n=se;se=void 0;try{t()}catch(i){throw e.f&=-2,e.f|=8,va(e),i}finally{se=n,wa()}}}function va(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Oc(e)}function Uh(e){if(se!==this)throw new Error("Out-of-order effect");Ic(this),se=e,this.f&=-2,8&this.f&&va(this),wa()}function En(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t==null?void 0:t.name}En.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.m=t)}finally{e()}};En.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Oc(this),Lc(this),Nt++;var e=se;return se=this,Uh.bind(this,e)};En.prototype.N=function(){2&this.f||(this.f|=2,this.u=Jn,Jn=this)};En.prototype.d=function(){this.f|=8,1&this.f||va(this)};En.prototype.dispose=function(){this.d()};function at(e,t){var n=new En(e,t);try{n.c()}catch(l){throw n.d(),l}var i=n.d.bind(n);return i[Symbol.dispose]=i,i}var Fi,Er;function Pn(e,t){le[e]=t.bind(null,le[e]||function(){})}function di(e){if(Er){var t=Er;Er=void 0,t()}Er=e&&e.S()}function Dc(e){var t=this,n=e.data,i=Rc(n);i.value=n;var l=lt(function(){for(var a=t.__v;a=a.__;)if(a.__c){a.__c.__$f|=4;break}return t.__$u.c=function(){var s,o=t.__$u.S(),c=l.value;o(),yc(c)||((s=t.base)==null?void 0:s.nodeType)!==3?(t.__$f|=1,t.setState({})):t.base.data=c},Qt(function(){var s=i.value.value;return s===0?0:s===!0?"":s||""})},[]);return l.value}Dc.displayName="_st";Object.defineProperties(ve.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:Dc},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});Pn("__b",function(e,t){if(typeof t.type=="string"){var n,i=t.props;for(var l in i)if(l!=="children"){var a=i[l];a instanceof ve&&(n||(t.__np=n={}),n[l]=a,i[l]=a.peek())}}e(t)});Pn("__r",function(e,t){e(t),di();var n,i=t.__c;i&&(i.__$f&=-2,(n=i.__$u)===void 0&&(i.__$u=n=function(l){var a;return at(function(){a=this}),a.c=function(){i.__$f|=1,i.setState({})},a}())),Fi=i,di(n)});Pn("__e",function(e,t,n,i){di(),Fi=void 0,e(t,n,i)});Pn("diffed",function(e,t){di(),Fi=void 0;var n;if(typeof t.type=="string"&&(n=t.__e)){var i=t.__np,l=t.props;if(i){var a=n.U;if(a)for(var s in a){var o=a[s];o!==void 0&&!(s in i)&&(o.d(),a[s]=void 0)}else n.U=a={};for(var c in i){var u=a[c],h=i[c];u===void 0?(u=Wh(n,c,h,l),a[c]=u):u.o(h,l)}}}e(t)});function Wh(e,t,n,i){var l=t in e&&e.ownerSVGElement===void 0,a=q(n);return{o:function(s,o){a.value=s,i=o},d:at(function(){var s=a.value.value;i[t]!==s&&(i[t]=s,l?e[t]=s:s?e.setAttribute(t,s):e.removeAttribute(t))})}}Pn("unmount",function(e,t){if(typeof t.type=="string"){var n=t.__e;if(n){var i=n.U;if(i){n.U=void 0;for(var l in i){var a=i[l];a&&a.d()}}}}else{var s=t.__c;if(s){var o=s.__$u;o&&(s.__$u=void 0,o.d())}}e(t)});Pn("__h",function(e,t,n,i){(i<3||i===9)&&(t.__$f|=2),e(t,n,i)});un.prototype.shouldComponentUpdate=function(e,t){if(this.__R)return!0;var n=this.__$u,i=n&&n.s!==void 0;for(var l in t)return!0;if(this.__f||typeof this.u=="boolean"&&this.u===!0){if(!(i||2&this.__$f||4&this.__$f)||1&this.__$f)return!0}else if(!(i||4&this.__$f)||3&this.__$f)return!0;for(var a in e)if(a!=="__source"&&e[a]!==this.props[a])return!0;for(var s in this.props)if(!(s in e))return!0;return!1};function Rc(e){return lt(function(){return q(e)},[])}function ul(e){var t=J(e);return t.current=e,Fi.__$f|=4,lt(function(){return Qt(function(){return t.current()})},[])}const ce=q([]),Ni=q([]),Bi=q([]),Ht=q([]),yt=q(null),_s=q(""),zl=q(null),ar=q(null),jl=q("all"),sr=q(null),ke=q(null),Mt=q(null),zi=q(null),xa=q(null),Fc=q(null),st=q([]),hi=q({}),Qn=q(null),Yn=q(null),Zn=q(null),Nc=q(null),_a=q([]),dn=q(null),Bc=q(""),zc=q(0),Sa=q(null),Hr=q({}),Bt=q({}),Ne=q({}),Re=q({}),Ss=q(0);let jc=0;function Kh(e){if(Date.now()-jc<3e3)return;const t={},n={};for(const i of e){if(!i.pid)continue;const l=i.open_tabs||[];l.length&&(t[i.pid]=l.map(a=>({...a,target:i.target}))),i.active_tab&&i.active_tab!=="pane"&&(n[i.pid]=i.active_tab)}Ne.value=t,Re.value=n}function $a(e,t){jc=Date.now(),fetch(`/api/pane/tabs/${e}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)}).catch(()=>{})}function wr(e){const t=sr.value;if(!t)return;const n=(ce.value||[]).find(s=>s.target===t);if(!n)return;const i=n.pid,l=Ne.value[i]||[],a=l.find(s=>s.path===e.path);a?e.line&&e.line!==a.line&&(Ne.value={...Ne.value,[i]:l.map(s=>s.path===e.path?{...s,line:e.line}:s)}):Ne.value={...Ne.value,[i]:[...l,{...e,target:t}]},Re.value={...Re.value,[i]:`file:${e.path}`},$a("open",{pid:i,path:e.path,line:e.line??null})}function Hc(e,t){const i=(Ne.value[e]||[]).filter(l=>l.path!==t);Ne.value={...Ne.value,[e]:i},Re.value[e]===`file:${t}`&&(Re.value={...Re.value,[e]:"pane"}),$a("close",{pid:e,path:t})}function qr(e,t){Re.value={...Re.value,[e]:t},$a("activate",{pid:e,tab:t})}const or=q(new Set),pt=q(new Set),mt=q(new Set);function vn(e,t=st.value){var n;return((n=t.find(i=>i.id===e))==null?void 0:n.label)||e}function Mn(e=st.value){return e.length>1}function Vh(e,t=st.value,n=hi.value){if(!(e.agent==="claude"||e.is_claude))return null;const i=e.account||"default";if(!t.some(a=>a.id===i))return null;const l=n==null?void 0:n[i];return t.find(a=>a.id===l&&l!==i)||null}const hn=[];function Gh(e){e.key==="Escape"&&hn.length&&(e.stopPropagation(),hn[hn.length-1](e))}typeof window<"u"&&window.addEventListener("keydown",Gh,!0);function We(e,t=!0){H(()=>{if(t)return hn.push(e),()=>{const n=hn.indexOf(e);n>=0&&hn.splice(n,1)}},[e,t])}function ji(e,t,n){We(n,t),H(()=>{if(!t)return;function i(l){e.current&&!e.current.contains(l.target)&&n()}return document.addEventListener("click",i),()=>document.removeEventListener("click",i)},[t,n])}const Jh={};function Qh(e,t){const n=Jh,i=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,l=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return qc(e,i,l)}function qc(e,t,n){if(Yh(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return $s(e.children,t,n)}return Array.isArray(e)?$s(e,t,n):""}function $s(e,t,n){const i=[];let l=-1;for(;++ll?0:l+t:t=t>l?l:t,n=n>0?n:0,i.length<1e4)s=Array.from(i),s.unshift(t,n),e.splice(...s);else for(n&&e.splice(t,n);a0?(Ie(e,e.length,0,t),e):t}const Ts={}.hasOwnProperty;function Uc(e){const t={};let n=-1;for(;++n13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function je(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Se=vt(/[A-Za-z]/),Ee=vt(/[\dA-Za-z]/),ef=vt(/[#-'*+\--9=?A-Z^-~]/);function fi(e){return e!==null&&(e<32||e===127)}const Hl=vt(/\d/),tf=vt(/[\dA-Fa-f]/),nf=vt(/[!-/:-@[-`{-~]/);function W(e){return e!==null&&e<-2}function oe(e){return e!==null&&(e<0||e===32)}function te(e){return e===-2||e===-1||e===32}const Hi=vt(new RegExp("\\p{P}|\\p{S}","u")),qt=vt(/\s/);function vt(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function re(e,t,n,i){const l=i?i-1:Number.POSITIVE_INFINITY;let a=0;return s;function s(c){return te(c)?(e.enter(n),o(c)):t(c)}function o(c){return te(c)&&a++s))return;const E=t.events.length;let M=E,T,S;for(;M--;)if(t.events[M][0]==="exit"&&t.events[M][1].type==="chunkFlow"){if(T){S=t.events[M][1].end;break}T=!0}for(b(i),v=E;vg;){const $=n[y];t.containerState=$[1],$[0].exit.call(t,e)}n.length=g}function C(){l.write([null]),a=void 0,l=void 0,t.containerState._closeFlow=void 0}}function of(e,t,n){return re(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function pi(e){if(e===null||oe(e)||qt(e))return 1;if(Hi(e))return 2}function qi(e,t,n){const i=[];let l=-1;for(;++l1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const d={...e[i][1].end},p={...e[n][1].start};Ps(d,-c),Ps(p,c),s={type:c>1?"strongSequence":"emphasisSequence",start:d,end:{...e[i][1].end}},o={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:p},a={type:c>1?"strongText":"emphasisText",start:{...e[i][1].end},end:{...e[n][1].start}},l={type:c>1?"strong":"emphasis",start:{...s.start},end:{...o.end}},e[i][1].end={...s.start},e[n][1].start={...o.end},u=[],e[i][1].end.offset-e[i][1].start.offset&&(u=De(u,[["enter",e[i][1],t],["exit",e[i][1],t]])),u=De(u,[["enter",l,t],["enter",s,t],["exit",s,t],["enter",a,t]]),u=De(u,qi(t.parser.constructs.insideSpan.null,e.slice(i+1,n),t)),u=De(u,[["exit",a,t],["enter",o,t],["exit",o,t],["exit",l,t]]),e[n][1].end.offset-e[n][1].start.offset?(h=2,u=De(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):h=0,Ie(e,i-1,n-i+3,u),n=i+u.length-h-2;break}}for(n=-1;++n0&&te(v)?re(e,C,"linePrefix",a+1)(v):C(v)}function C(v){return v===null||W(v)?e.check(Ms,k,y)(v):(e.enter("codeFlowValue"),g(v))}function g(v){return v===null||W(v)?(e.exit("codeFlowValue"),C(v)):(e.consume(v),g)}function y(v){return e.exit("codeFenced"),t(v)}function $(v,E,M){let T=0;return S;function S(D){return v.enter("lineEnding"),v.consume(D),v.exit("lineEnding"),L}function L(D){return v.enter("codeFencedFence"),te(D)?re(v,O,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):O(D)}function O(D){return D===o?(v.enter("codeFencedFenceSequence"),j(D)):M(D)}function j(D){return D===o?(T++,v.consume(D),j):T>=s?(v.exit("codeFencedFenceSequence"),te(D)?re(v,I,"whitespace")(D):I(D)):M(D)}function I(D){return D===null||W(D)?(v.exit("codeFencedFence"),E(D)):M(D)}}}function wf(e,t,n){const i=this;return l;function l(s){return s===null?n(s):(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),a)}function a(s){return i.parser.lazy[i.now().line]?n(s):t(s)}}const dl={name:"codeIndented",tokenize:xf},vf={partial:!0,tokenize:_f};function xf(e,t,n){const i=this;return l;function l(u){return e.enter("codeIndented"),re(e,a,"linePrefix",5)(u)}function a(u){const h=i.events[i.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?s(u):n(u)}function s(u){return u===null?c(u):W(u)?e.attempt(vf,s,c)(u):(e.enter("codeFlowValue"),o(u))}function o(u){return u===null||W(u)?(e.exit("codeFlowValue"),s(u)):(e.consume(u),o)}function c(u){return e.exit("codeIndented"),t(u)}}function _f(e,t,n){const i=this;return l;function l(s){return i.parser.lazy[i.now().line]?n(s):W(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),l):re(e,a,"linePrefix",5)(s)}function a(s){const o=i.events[i.events.length-1];return o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(s):W(s)?l(s):n(s)}}const Sf={name:"codeText",previous:Cf,resolve:$f,tokenize:Tf};function $f(e){let t=e.length-4,n=3,i,l;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(i=n;++i=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return tthis.left.length?this.right.slice(this.right.length-i+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-i+this.left.length).reverse())}splice(t,n,i){const l=n||0;this.setCursor(Math.trunc(t));const a=this.right.splice(this.right.length-l,Number.POSITIVE_INFINITY);return i&&Rn(this.left,i),a.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Rn(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Rn(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t=4?t(s):e.interrupt(i.parser.constructs.flow,n,t)(s)}}function Qc(e,t,n,i,l,a,s,o,c){const u=c||Number.POSITIVE_INFINITY;let h=0;return d;function d(b){return b===60?(e.enter(i),e.enter(l),e.enter(a),e.consume(b),e.exit(a),p):b===null||b===32||b===41||fi(b)?n(b):(e.enter(i),e.enter(s),e.enter(o),e.enter("chunkString",{contentType:"string"}),k(b))}function p(b){return b===62?(e.enter(a),e.consume(b),e.exit(a),e.exit(l),e.exit(i),t):(e.enter(o),e.enter("chunkString",{contentType:"string"}),f(b))}function f(b){return b===62?(e.exit("chunkString"),e.exit(o),p(b)):b===null||b===60||W(b)?n(b):(e.consume(b),b===92?m:f)}function m(b){return b===60||b===62||b===92?(e.consume(b),f):f(b)}function k(b){return!h&&(b===null||b===41||oe(b))?(e.exit("chunkString"),e.exit(o),e.exit(s),e.exit(i),t(b)):h999||f===null||f===91||f===93&&!c||f===94&&!o&&"_hiddenFootnoteSupport"in s.parser.constructs?n(f):f===93?(e.exit(a),e.enter(l),e.consume(f),e.exit(l),e.exit(i),t):W(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),h):(e.enter("chunkString",{contentType:"string"}),d(f))}function d(f){return f===null||f===91||f===93||W(f)||o++>999?(e.exit("chunkString"),h(f)):(e.consume(f),c||(c=!te(f)),f===92?p:d)}function p(f){return f===91||f===92||f===93?(e.consume(f),o++,d):d(f)}}function Zc(e,t,n,i,l,a){let s;return o;function o(p){return p===34||p===39||p===40?(e.enter(i),e.enter(l),e.consume(p),e.exit(l),s=p===40?41:p,c):n(p)}function c(p){return p===s?(e.enter(l),e.consume(p),e.exit(l),e.exit(i),t):(e.enter(a),u(p))}function u(p){return p===s?(e.exit(a),c(s)):p===null?n(p):W(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),re(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),h(p))}function h(p){return p===s||p===null||W(p)?(e.exit("chunkString"),u(p)):(e.consume(p),p===92?d:h)}function d(p){return p===s||p===92?(e.consume(p),h):h(p)}}function Xn(e,t){let n;return i;function i(l){return W(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),n=!0,i):te(l)?re(e,i,n?"linePrefix":"lineSuffix")(l):t(l)}}const Df={name:"definition",tokenize:Ff},Rf={partial:!0,tokenize:Nf};function Ff(e,t,n){const i=this;let l;return a;function a(f){return e.enter("definition"),s(f)}function s(f){return Yc.call(i,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(f)}function o(f){return l=je(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),f===58?(e.enter("definitionMarker"),e.consume(f),e.exit("definitionMarker"),c):n(f)}function c(f){return oe(f)?Xn(e,u)(f):u(f)}function u(f){return Qc(e,h,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(f)}function h(f){return e.attempt(Rf,d,d)(f)}function d(f){return te(f)?re(e,p,"whitespace")(f):p(f)}function p(f){return f===null||W(f)?(e.exit("definition"),i.parser.defined.push(l),t(f)):n(f)}}function Nf(e,t,n){return i;function i(o){return oe(o)?Xn(e,l)(o):n(o)}function l(o){return Zc(e,a,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(o)}function a(o){return te(o)?re(e,s,"whitespace")(o):s(o)}function s(o){return o===null||W(o)?t(o):n(o)}}const Bf={name:"hardBreakEscape",tokenize:zf};function zf(e,t,n){return i;function i(a){return e.enter("hardBreakEscape"),e.consume(a),l}function l(a){return W(a)?(e.exit("hardBreakEscape"),t(a)):n(a)}}const jf={name:"headingAtx",resolve:Hf,tokenize:qf};function Hf(e,t){let n=e.length-2,i=3,l,a;return e[i][1].type==="whitespace"&&(i+=2),n-2>i&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(i===n-1||n-4>i&&e[n-2][1].type==="whitespace")&&(n-=i+1===n?2:4),n>i&&(l={type:"atxHeadingText",start:e[i][1].start,end:e[n][1].end},a={type:"chunkText",start:e[i][1].start,end:e[n][1].end,contentType:"text"},Ie(e,i,n-i+1,[["enter",l,t],["enter",a,t],["exit",a,t],["exit",l,t]])),e}function qf(e,t,n){let i=0;return l;function l(h){return e.enter("atxHeading"),a(h)}function a(h){return e.enter("atxHeadingSequence"),s(h)}function s(h){return h===35&&i++<6?(e.consume(h),s):h===null||oe(h)?(e.exit("atxHeadingSequence"),o(h)):n(h)}function o(h){return h===35?(e.enter("atxHeadingSequence"),c(h)):h===null||W(h)?(e.exit("atxHeading"),t(h)):te(h)?re(e,o,"whitespace")(h):(e.enter("atxHeadingText"),u(h))}function c(h){return h===35?(e.consume(h),c):(e.exit("atxHeadingSequence"),o(h))}function u(h){return h===null||h===35||oe(h)?(e.exit("atxHeadingText"),o(h)):(e.consume(h),u)}}const Uf=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Ls=["pre","script","style","textarea"],Wf={concrete:!0,name:"htmlFlow",resolveTo:Gf,tokenize:Jf},Kf={partial:!0,tokenize:Yf},Vf={partial:!0,tokenize:Qf};function Gf(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Jf(e,t,n){const i=this;let l,a,s,o,c;return u;function u(_){return h(_)}function h(_){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(_),d}function d(_){return _===33?(e.consume(_),p):_===47?(e.consume(_),a=!0,k):_===63?(e.consume(_),l=3,i.interrupt?t:w):Se(_)?(e.consume(_),s=String.fromCharCode(_),x):n(_)}function p(_){return _===45?(e.consume(_),l=2,f):_===91?(e.consume(_),l=5,o=0,m):Se(_)?(e.consume(_),l=4,i.interrupt?t:w):n(_)}function f(_){return _===45?(e.consume(_),i.interrupt?t:w):n(_)}function m(_){const ee="CDATA[";return _===ee.charCodeAt(o++)?(e.consume(_),o===ee.length?i.interrupt?t:O:m):n(_)}function k(_){return Se(_)?(e.consume(_),s=String.fromCharCode(_),x):n(_)}function x(_){if(_===null||_===47||_===62||oe(_)){const ee=_===47,he=s.toLowerCase();return!ee&&!a&&Ls.includes(he)?(l=1,i.interrupt?t(_):O(_)):Uf.includes(s.toLowerCase())?(l=6,ee?(e.consume(_),b):i.interrupt?t(_):O(_)):(l=7,i.interrupt&&!i.parser.lazy[i.now().line]?n(_):a?C(_):g(_))}return _===45||Ee(_)?(e.consume(_),s+=String.fromCharCode(_),x):n(_)}function b(_){return _===62?(e.consume(_),i.interrupt?t:O):n(_)}function C(_){return te(_)?(e.consume(_),C):S(_)}function g(_){return _===47?(e.consume(_),S):_===58||_===95||Se(_)?(e.consume(_),y):te(_)?(e.consume(_),g):S(_)}function y(_){return _===45||_===46||_===58||_===95||Ee(_)?(e.consume(_),y):$(_)}function $(_){return _===61?(e.consume(_),v):te(_)?(e.consume(_),$):g(_)}function v(_){return _===null||_===60||_===61||_===62||_===96?n(_):_===34||_===39?(e.consume(_),c=_,E):te(_)?(e.consume(_),v):M(_)}function E(_){return _===c?(e.consume(_),c=null,T):_===null||W(_)?n(_):(e.consume(_),E)}function M(_){return _===null||_===34||_===39||_===47||_===60||_===61||_===62||_===96||oe(_)?$(_):(e.consume(_),M)}function T(_){return _===47||_===62||te(_)?g(_):n(_)}function S(_){return _===62?(e.consume(_),L):n(_)}function L(_){return _===null||W(_)?O(_):te(_)?(e.consume(_),L):n(_)}function O(_){return _===45&&l===2?(e.consume(_),R):_===60&&l===1?(e.consume(_),Y):_===62&&l===4?(e.consume(_),K):_===63&&l===3?(e.consume(_),w):_===93&&l===5?(e.consume(_),z):W(_)&&(l===6||l===7)?(e.exit("htmlFlowData"),e.check(Kf,X,j)(_)):_===null||W(_)?(e.exit("htmlFlowData"),j(_)):(e.consume(_),O)}function j(_){return e.check(Vf,I,X)(_)}function I(_){return e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),D}function D(_){return _===null||W(_)?j(_):(e.enter("htmlFlowData"),O(_))}function R(_){return _===45?(e.consume(_),w):O(_)}function Y(_){return _===47?(e.consume(_),s="",A):O(_)}function A(_){if(_===62){const ee=s.toLowerCase();return Ls.includes(ee)?(e.consume(_),K):O(_)}return Se(_)&&s.length<8?(e.consume(_),s+=String.fromCharCode(_),A):O(_)}function z(_){return _===93?(e.consume(_),w):O(_)}function w(_){return _===62?(e.consume(_),K):_===45&&l===2?(e.consume(_),w):O(_)}function K(_){return _===null||W(_)?(e.exit("htmlFlowData"),X(_)):(e.consume(_),K)}function X(_){return e.exit("htmlFlow"),t(_)}}function Qf(e,t,n){const i=this;return l;function l(s){return W(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),a):n(s)}function a(s){return i.parser.lazy[i.now().line]?n(s):t(s)}}function Yf(e,t,n){return i;function i(l){return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),e.attempt(vr,t,n)}}const Zf={name:"htmlText",tokenize:Xf};function Xf(e,t,n){const i=this;let l,a,s;return o;function o(w){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(w),c}function c(w){return w===33?(e.consume(w),u):w===47?(e.consume(w),$):w===63?(e.consume(w),g):Se(w)?(e.consume(w),M):n(w)}function u(w){return w===45?(e.consume(w),h):w===91?(e.consume(w),a=0,m):Se(w)?(e.consume(w),C):n(w)}function h(w){return w===45?(e.consume(w),f):n(w)}function d(w){return w===null?n(w):w===45?(e.consume(w),p):W(w)?(s=d,Y(w)):(e.consume(w),d)}function p(w){return w===45?(e.consume(w),f):d(w)}function f(w){return w===62?R(w):w===45?p(w):d(w)}function m(w){const K="CDATA[";return w===K.charCodeAt(a++)?(e.consume(w),a===K.length?k:m):n(w)}function k(w){return w===null?n(w):w===93?(e.consume(w),x):W(w)?(s=k,Y(w)):(e.consume(w),k)}function x(w){return w===93?(e.consume(w),b):k(w)}function b(w){return w===62?R(w):w===93?(e.consume(w),b):k(w)}function C(w){return w===null||w===62?R(w):W(w)?(s=C,Y(w)):(e.consume(w),C)}function g(w){return w===null?n(w):w===63?(e.consume(w),y):W(w)?(s=g,Y(w)):(e.consume(w),g)}function y(w){return w===62?R(w):g(w)}function $(w){return Se(w)?(e.consume(w),v):n(w)}function v(w){return w===45||Ee(w)?(e.consume(w),v):E(w)}function E(w){return W(w)?(s=E,Y(w)):te(w)?(e.consume(w),E):R(w)}function M(w){return w===45||Ee(w)?(e.consume(w),M):w===47||w===62||oe(w)?T(w):n(w)}function T(w){return w===47?(e.consume(w),R):w===58||w===95||Se(w)?(e.consume(w),S):W(w)?(s=T,Y(w)):te(w)?(e.consume(w),T):R(w)}function S(w){return w===45||w===46||w===58||w===95||Ee(w)?(e.consume(w),S):L(w)}function L(w){return w===61?(e.consume(w),O):W(w)?(s=L,Y(w)):te(w)?(e.consume(w),L):T(w)}function O(w){return w===null||w===60||w===61||w===62||w===96?n(w):w===34||w===39?(e.consume(w),l=w,j):W(w)?(s=O,Y(w)):te(w)?(e.consume(w),O):(e.consume(w),I)}function j(w){return w===l?(e.consume(w),l=void 0,D):w===null?n(w):W(w)?(s=j,Y(w)):(e.consume(w),j)}function I(w){return w===null||w===34||w===39||w===60||w===61||w===96?n(w):w===47||w===62||oe(w)?T(w):(e.consume(w),I)}function D(w){return w===47||w===62||oe(w)?T(w):n(w)}function R(w){return w===62?(e.consume(w),e.exit("htmlTextData"),e.exit("htmlText"),t):n(w)}function Y(w){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),A}function A(w){return te(w)?re(e,z,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(w):z(w)}function z(w){return e.enter("htmlTextData"),s(w)}}const Ta={name:"labelEnd",resolveAll:rp,resolveTo:ip,tokenize:lp},ep={tokenize:ap},tp={tokenize:sp},np={tokenize:op};function rp(e){let t=-1;const n=[];for(;++t=3&&(u===null||W(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===l?(e.consume(u),i++,c):(e.exit("thematicBreakSequence"),te(u)?re(e,o,"whitespace")(u):o(u))}}const Te={continuation:{tokenize:bp},exit:wp,name:"list",tokenize:yp},mp={partial:!0,tokenize:vp},gp={partial:!0,tokenize:kp};function yp(e,t,n){const i=this,l=i.events[i.events.length-1];let a=l&&l[1].type==="linePrefix"?l[2].sliceSerialize(l[1],!0).length:0,s=0;return o;function o(f){const m=i.containerState.type||(f===42||f===43||f===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!i.containerState.marker||f===i.containerState.marker:Hl(f)){if(i.containerState.type||(i.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),f===42||f===45?e.check(Ur,n,u)(f):u(f);if(!i.interrupt||f===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(f)}return n(f)}function c(f){return Hl(f)&&++s<10?(e.consume(f),c):(!i.interrupt||s<2)&&(i.containerState.marker?f===i.containerState.marker:f===41||f===46)?(e.exit("listItemValue"),u(f)):n(f)}function u(f){return e.enter("listItemMarker"),e.consume(f),e.exit("listItemMarker"),i.containerState.marker=i.containerState.marker||f,e.check(vr,i.interrupt?n:h,e.attempt(mp,p,d))}function h(f){return i.containerState.initialBlankLine=!0,a++,p(f)}function d(f){return te(f)?(e.enter("listItemPrefixWhitespace"),e.consume(f),e.exit("listItemPrefixWhitespace"),p):n(f)}function p(f){return i.containerState.size=a+i.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(f)}}function bp(e,t,n){const i=this;return i.containerState._closeFlow=void 0,e.check(vr,l,a);function l(o){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,re(e,t,"listItemIndent",i.containerState.size+1)(o)}function a(o){return i.containerState.furtherBlankLines||!te(o)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,s(o)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,e.attempt(gp,t,s)(o))}function s(o){return i.containerState._closeFlow=!0,i.interrupt=void 0,re(e,e.attempt(Te,t,n),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}function kp(e,t,n){const i=this;return re(e,l,"listItemIndent",i.containerState.size+1);function l(a){const s=i.events[i.events.length-1];return s&&s[1].type==="listItemIndent"&&s[2].sliceSerialize(s[1],!0).length===i.containerState.size?t(a):n(a)}}function wp(e){e.exit(this.containerState.type)}function vp(e,t,n){const i=this;return re(e,l,"listItemPrefixWhitespace",i.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function l(a){const s=i.events[i.events.length-1];return!te(a)&&s&&s[1].type==="listItemPrefixWhitespace"?t(a):n(a)}}const Is={name:"setextUnderline",resolveTo:xp,tokenize:_p};function xp(e,t){let n=e.length,i,l,a;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){i=n;break}e[n][1].type==="paragraph"&&(l=n)}else e[n][1].type==="content"&&e.splice(n,1),!a&&e[n][1].type==="definition"&&(a=n);const s={type:"setextHeading",start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[l][1].type="setextHeadingText",a?(e.splice(l,0,["enter",s,t]),e.splice(a+1,0,["exit",e[i][1],t]),e[i][1].end={...e[a][1].end}):e[i][1]=s,e.push(["exit",s,t]),e}function _p(e,t,n){const i=this;let l;return a;function a(u){let h=i.events.length,d;for(;h--;)if(i.events[h][1].type!=="lineEnding"&&i.events[h][1].type!=="linePrefix"&&i.events[h][1].type!=="content"){d=i.events[h][1].type==="paragraph";break}return!i.parser.lazy[i.now().line]&&(i.interrupt||d)?(e.enter("setextHeadingLine"),l=u,s(u)):n(u)}function s(u){return e.enter("setextHeadingLineSequence"),o(u)}function o(u){return u===l?(e.consume(u),o):(e.exit("setextHeadingLineSequence"),te(u)?re(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||W(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const Sp={tokenize:$p};function $p(e){const t=this,n=e.attempt(vr,i,e.attempt(this.parser.constructs.flowInitial,l,re(e,e.attempt(this.parser.constructs.flow,l,e.attempt(Mf,l)),"linePrefix")));return n;function i(a){if(a===null){e.consume(a);return}return e.enter("lineEndingBlank"),e.consume(a),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function l(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const Cp={resolveAll:eu()},Tp=Xc("string"),Ep=Xc("text");function Xc(e){return{resolveAll:eu(e==="text"?Pp:void 0),tokenize:t};function t(n){const i=this,l=this.parser.constructs[e],a=n.attempt(l,s,o);return s;function s(h){return u(h)?a(h):o(h)}function o(h){if(h===null){n.consume(h);return}return n.enter("data"),n.consume(h),c}function c(h){return u(h)?(n.exit("data"),a(h)):(n.consume(h),c)}function u(h){if(h===null)return!0;const d=l[h];let p=-1;if(d)for(;++p-1){const o=s[0];typeof o=="string"?s[0]=o.slice(i):s.shift()}a>0&&s.push(e[l].slice(0,a))}return s}function Hp(e,t){let n=-1;const i=[];let l;for(;++n0){const Fe=J.tokenStack[J.tokenStack.length-1];(Fe[1]||Es).call(J,void 0,Fe[0])}for(D.position={start:ut(P.length>0?P[0][1].start:{line:1,column:1,offset:0}),end:ut(P.length>0?P[P.length-2][1].end:{line:1,column:1,offset:0})},ae=-1;++ae":""))+")"})}return f;function f(){let h=Vc,m,b,x;if(a(u,c,p[p.length-1]||void 0)&&(h=Bp(n(u,p)),h[0]===As))return h;if("children"in u&&u.children){const w=u;if(w.children&&h[0]!==Fp)for(b=-1+s,x=p.concat(w);b>-1&&b0?{type:"text",value:v}:void 0),v===!1?f.lastIndex=g+1:(m!==g&&C.push({type:"text",value:c.value.slice(m,g)}),Array.isArray(v)?C.push(...v):v&&C.push(v),m=g+y[0].length,w=!0),!f.global)break;y=f.exec(c.value)}return w?(m?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],i=n.indexOf(")");const l=Ps(e,"(");let a=Ps(e,")");for(;i!==-1&&l>a;)e+=n.slice(0,i+1),n=n.slice(i+1),i=n.indexOf(")"),a++;return[e,n]}function Gc(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||zt(n)||Ni(n))&&(!t||n!==47)}function tm(){this.buffer()}function nm(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function rm(){this.buffer()}function im(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function lm(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=je(this.sliceSerialize(e)).toLowerCase(),n.label=t}function am(e){this.exit(e)}function sm(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=je(this.sliceSerialize(e)).toLowerCase(),n.label=t}function om(e){this.exit(e)}function cm(){return{enter:{gfmFootnoteCallString:tm,gfmFootnoteCall:nm,gfmFootnoteDefinitionLabelString:rm,gfmFootnoteDefinition:im},exit:{gfmFootnoteCallString:lm,gfmFootnoteCall:am,gfmFootnoteDefinitionLabelString:sm,gfmFootnoteDefinition:om}}}function um(){return{canContainEols:["delete"],enter:{strikethrough:dm},exit:{strikethrough:hm}}}function dm(e){this.enter({type:"delete",children:[]},e)}function hm(e){this.exit(e)}function fm(){return{enter:{table:pm,tableData:Ms,tableHeader:Ms,tableRow:gm},exit:{codeText:ym,table:mm,tableData:ul,tableHeader:ul,tableRow:ul}}}function pm(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function mm(e){this.exit(e),this.data.inTable=void 0}function gm(e){this.enter({type:"tableRow",children:[]},e)}function ul(e){this.exit(e)}function Ms(e){this.enter({type:"tableCell",children:[]},e)}function ym(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,bm));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function bm(e,t){return t==="|"?t:e}function km(){return{exit:{taskListCheckValueChecked:Ls,taskListCheckValueUnchecked:Ls,paragraph:wm}}}function Ls(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function wm(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const i=n.children[0];if(i&&i.type==="text"){const l=t.children;let a=-1,s;for(;++a0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const Lm={tokenize:zm,partial:!0};function Im(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Fm,continuation:{tokenize:Nm},exit:Bm}},text:{91:{name:"gfmFootnoteCall",tokenize:Rm},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Om,resolveTo:Dm}}}}function Om(e,t,n){const i=this;let l=i.events.length;const a=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let s;for(;l--;){const u=i.events[l][1];if(u.type==="labelImage"){s=u;break}if(u.type==="gfmFootnoteCall"||u.type==="labelLink"||u.type==="label"||u.type==="image"||u.type==="link")break}return o;function o(u){if(!s||!s._balanced)return n(u);const c=je(i.sliceSerialize({start:s.end,end:i.now()}));return c.codePointAt(0)!==94||!a.includes(c.slice(1))?n(u):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(u),e.exit("gfmFootnoteCallLabelMarker"),t(u))}}function Dm(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const i={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},l={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};l.end.column++,l.end.offset++,l.end._bufferIndex++;const a={type:"gfmFootnoteCallString",start:Object.assign({},l.end),end:Object.assign({},e[e.length-1][1].start)},s={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},o=[e[n+1],e[n+2],["enter",i,t],e[n+3],e[n+4],["enter",l,t],["exit",l,t],["enter",a,t],["enter",s,t],["exit",s,t],["exit",a,t],e[e.length-2],e[e.length-1],["exit",i,t]];return e.splice(n,e.length-n+1,...o),e}function Rm(e,t,n){const i=this,l=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let a=0,s;return o;function o(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),u}function u(d){return d!==94?n(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(d){if(a>999||d===93&&!s||d===null||d===91||oe(d))return n(d);if(d===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return l.includes(je(i.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return oe(d)||(s=!0),a++,e.consume(d),d===92?p:c}function p(d){return d===91||d===92||d===93?(e.consume(d),a++,c):c(d)}}function Fm(e,t,n){const i=this,l=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let a,s=0,o;return u;function u(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",p):n(m)}function p(m){if(s>999||m===93&&!o||m===null||m===91||oe(m))return n(m);if(m===93){e.exit("chunkString");const b=e.exit("gfmFootnoteDefinitionLabelString");return a=je(i.sliceSerialize(b)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return oe(m)||(o=!0),s++,e.consume(m),m===92?d:p}function d(m){return m===91||m===92||m===93?(e.consume(m),s++,p):p(m)}function f(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),l.includes(a)||l.push(a),re(e,h,"gfmFootnoteDefinitionWhitespace")):n(m)}function h(m){return t(m)}}function Nm(e,t,n){return e.check(wr,t,e.attempt(Lm,t,n))}function Bm(e){e.exit("gfmFootnoteDefinition")}function zm(e,t,n){const i=this;return re(e,l,"gfmFootnoteDefinitionIndent",5);function l(a){const s=i.events[i.events.length-1];return s&&s[1].type==="gfmFootnoteDefinitionIndent"&&s[2].sliceSerialize(s[1],!0).length===4?t(a):n(a)}}function jm(e){let n={}.singleTilde;const i={name:"strikethrough",tokenize:a,resolveAll:l};return n==null&&(n=!0),{text:{126:i},insideSpan:{null:[i]},attentionMarkers:{null:[126]}};function l(s,o){let u=-1;for(;++u1?u(m):(s.consume(m),d++,h);if(d<2&&!n)return u(m);const x=s.exit("strikethroughSequenceTemporary"),w=hi(m);return x._open=!w||w===2&&!!b,x._close=!b||b===2&&!!w,o(m)}}}class Hm{constructor(){this.map=[]}add(t,n,i){qm(this,t,n,i)}consume(t){if(this.map.sort(function(a,s){return a[0]-s[0]}),this.map.length===0)return;let n=this.map.length;const i=[];for(;n>0;)n-=1,i.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];i.push(t.slice()),t.length=0;let l=i.pop();for(;l;){for(const a of l)t.push(a);l=i.pop()}this.map.length=0}}function qm(e,t,n,i){let l=0;if(!(n===0&&i.length===0)){for(;l-1;){const L=i.events[R][1].type;if(L==="lineEnding"||L==="linePrefix")R--;else break}const F=R>-1?i.events[R][1].type:null,q=F==="tableHead"||F==="tableRow"?v:u;return q===v&&i.parser.lazy[i.now().line]?n(S):q(S)}function u(S){return e.enter("tableHead"),e.enter("tableRow"),c(S)}function c(S){return S===124||(s=!0,a+=1),p(S)}function p(S){return S===null?n(S):U(S)?a>1?(a=0,i.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(S),e.exit("lineEnding"),h):n(S):ee(S)?re(e,p,"whitespace")(S):(a+=1,s&&(s=!1,l+=1),S===124?(e.enter("tableCellDivider"),e.consume(S),e.exit("tableCellDivider"),s=!0,p):(e.enter("data"),d(S)))}function d(S){return S===null||S===124||oe(S)?(e.exit("data"),p(S)):(e.consume(S),S===92?f:d)}function f(S){return S===92||S===124?(e.consume(S),d):d(S)}function h(S){return i.interrupt=!1,i.parser.lazy[i.now().line]?n(S):(e.enter("tableDelimiterRow"),s=!1,ee(S)?re(e,m,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(S):m(S))}function m(S){return S===45||S===58?x(S):S===124?(s=!0,e.enter("tableCellDivider"),e.consume(S),e.exit("tableCellDivider"),b):$(S)}function b(S){return ee(S)?re(e,x,"whitespace")(S):x(S)}function x(S){return S===58?(a+=1,s=!0,e.enter("tableDelimiterMarker"),e.consume(S),e.exit("tableDelimiterMarker"),w):S===45?(a+=1,w(S)):S===null||U(S)?g(S):$(S)}function w(S){return S===45?(e.enter("tableDelimiterFiller"),C(S)):$(S)}function C(S){return S===45?(e.consume(S),C):S===58?(s=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(S),e.exit("tableDelimiterMarker"),y):(e.exit("tableDelimiterFiller"),y(S))}function y(S){return ee(S)?re(e,g,"whitespace")(S):g(S)}function g(S){return S===124?m(S):S===null||U(S)?!s||l!==a?$(S):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(S)):$(S)}function $(S){return n(S)}function v(S){return e.enter("tableRow"),E(S)}function E(S){return S===124?(e.enter("tableCellDivider"),e.consume(S),e.exit("tableCellDivider"),E):S===null||U(S)?(e.exit("tableRow"),t(S)):ee(S)?re(e,E,"whitespace")(S):(e.enter("data"),M(S))}function M(S){return S===null||S===124||oe(S)?(e.exit("data"),E(S)):(e.consume(S),S===92?T:M)}function T(S){return S===92||S===124?(e.consume(S),M):M(S)}}function Vm(e,t){let n=-1,i=!0,l=0,a=[0,0,0,0],s=[0,0,0,0],o=!1,u=0,c,p,d;const f=new Hm;for(;++nn[2]+1){const m=n[2]+1,b=n[3]-n[2]-1;e.add(m,b,[])}}e.add(n[3]+1,0,[["exit",d,t]])}return l!==void 0&&(a.end=Object.assign({},Xt(t.events,l)),e.add(l,0,[["exit",a,t]]),a=void 0),a}function Is(e,t,n,i,l){const a=[],s=Xt(t.events,n);l&&(l.end=Object.assign({},s),a.push(["exit",l,t])),i.end=Object.assign({},s),a.push(["exit",i,t]),e.add(n+1,0,a)}function Xt(e,t){const n=e[t],i=n[0]==="enter"?"start":"end";return n[1][i]}const Gm={name:"tasklistCheck",tokenize:Qm};function Jm(){return{text:{91:Gm}}}function Qm(e,t,n){const i=this;return l;function l(u){return i.previous!==null||!i._gfmTasklistFirstContentOfListItem?n(u):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(u),e.exit("taskListCheckMarker"),a)}function a(u){return oe(u)?(e.enter("taskListCheckValueUnchecked"),e.consume(u),e.exit("taskListCheckValueUnchecked"),s):u===88||u===120?(e.enter("taskListCheckValueChecked"),e.consume(u),e.exit("taskListCheckValueChecked"),s):n(u)}function s(u){return u===93?(e.enter("taskListCheckMarker"),e.consume(u),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),o):n(u)}function o(u){return U(u)?t(u):ee(u)?e.check({tokenize:Ym},t,n)(u):n(u)}}function Ym(e,t,n){return re(e,i,"whitespace");function i(l){return l===null?n(l):t(l)}}function iu(e){return Ic([xm(),Im(),jm(),Wm(),Jm()])}const Zm={pr_title:"from the PR title",branch:"from the branch name"};function vr(e){if(e!=null&&e.linked_linear){const t=e.linked_linear,n=e.linked_linear_title?`: ${e.linked_linear_title}`:"",i=e.linked_linear_status?` [${e.linked_linear_status}]`:"";return{id:t,href:`https://linear.app/issue/${t}`,tip:`Linear ${t}${n}${i}`,note:null,derived:!1}}if(e!=null&&e.linear_ticket){const t=e.linear_ticket,n=Zm[e.linear_ticket_source]||"derived";return{id:t,href:`https://linear.app/issue/${t}`,tip:`Linear ${t} (${n})`,note:n,derived:!0}}return null}const Xm=/^([a-z-]+): (.+)$/;function jl(e,t){if((e==null?void 0:e.type)!=="blockquote"||typeof t!="string")return null;const n=t.slice(e.position.start.offset,e.position.end.offset),i=[];for(const l of n.split(`
-`))for(const a of l.replace(/^\s*> ?/,"").split(" · ")){const s=Xm.exec(a.trim());if(!s)return null;i.push([s[1],s[2].trim()])}return i.length?i:null}function lu(e){return e.split(",").map(t=>t.trim().replace(/^`+|`+$/g,""))}const eg=/^([\w.-]*[\w-]\/[\w./-]*[\w-]|[\w-]+(?:\.[\w-]+)*\.[A-Za-z][A-Za-z0-9]{1,5})(?::(\d+)(?:-(\d+))?)?$/;function ji(e){const t=eg.exec(e);if(!t)return null;const n=t[1];if(!/[A-Za-z]/.test(n)||!n.includes("/")&&t[2]==null)return null;const i=n.split("/").pop();if(t[2]==null&&n.includes("/")&&!/\.[A-Za-z][A-Za-z0-9]{0,5}$/.test(i)&&!/^[\w.-]+\/[\w.-]+\//.test(n))return null;const l=t[2]!=null?Number(t[2]):null;return{path:n,start:l,end:t[3]!=null?Number(t[3]):l,raw:e}}function tg(e){const t=[];let n="";const i=/\S+/g;let l=0;for(let a=i.exec(e);a;a=i.exec(e)){const s=a[0],o=(s.match(/^[(["']+/)||[""])[0],u=s.slice(o.length).replace(/[.,;:)\]"']+$/,""),c=u?ji(u):null;c?(n+=e.slice(l,a.index)+o,n&&t.push(n),n=s.slice(o.length+u.length),t.push(c)):n+=e.slice(l,a.index)+s,l=a.index+s.length}return n+=e.slice(l),n&&t.push(n),t}const ng=new Set(["new-subsystem","extension","reuse","system-touch","behavior"]);function rg(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"stop"}function Ur(e){return e.type==="text"||e.type==="inlineCode"?e.value:(e.children||[]).map(Ur).join("")}function ig(e){var p,d,f;const t=String(e||""),i=Wc(t,{extensions:[iu()],mdastExtensions:[Jc()]}).children;let l="",a=null,s="";const o=[],u=new Map;let c=0;if(((p=i[c])==null?void 0:p.type)==="heading"&&i[c].depth===1){l=Ur(i[c]),c++;const h=((d=i[c])==null?void 0:d.type)==="blockquote"?jl(i[c],t):null;if(h){const m=Object.fromEntries(h);m.branch&&m.head&&(a={branch:m.branch,head:m.head,pr:/^\d+$/.test(m.pr||"")?Number(m.pr):null,repo:m.repo??null}),c++}((f=i[c])==null?void 0:f.type)==="paragraph"&&(s=Ur(i[c]),c++)}for(;cn.kind==="ctx"||n.kind==="add").length;return e.new_start+Math.max(t,1)-1}function ag(e,t){const n=new Map((t||[]).map(i=>[i.path,i]));return e.map(i=>{const l=n.get(i.path)||null;if(!l)return{ref:i,file:null,hunks:[],generated:!1};const a=i.start==null?l.hunks:l.hunks.filter(s=>s.new_start<=i.end&&lg(s)>=i.start);return{ref:i,file:l.path,hunks:a,generated:!!l.generated}})}const fi=e=>{var t;return((t=e.pr)==null?void 0:t.state)==="merged"};function Os(e){if(fi(e))return 99;const t=e.owner?0:e.worktree?10:20;return e.unresolved>0?t:e.role==="review-requested"?t+1:e.pr&&!e.walkthrough?t+2:e.role==="local"?t+4:t+3}const Hi={branch:{label:"branch",what:"branch name",first:"asc",value:e=>e.branch},pr:{label:"PR",what:"PR number",first:"desc",value:e=>{var t;return((t=e.pr)==null?void 0:t.number)??null}},walkthrough:{label:"walkthrough",what:"staleness",first:"desc",value:e=>{var t;return((t=e.walkthrough)==null?void 0:t.stale_by)??null}},comments:{label:"comments",what:"open comments",first:"desc",value:e=>e.unresolved||null},who:{label:"who",what:"owner",first:"asc",value:e=>{var t,n;return((t=e.owner)==null?void 0:t.name)||((n=e.pr)==null?void 0:n.author)||null}}};function sg(e){if(!e.walkthrough)return null;const t=e.walkthrough.stale_by;return t>0?`stale ${t}`:t===0?"current":e.worktree?"stale: unknown":"no worktree"}const og=(e,t)=>typeof e=="string"?e.localeCompare(t):e-t;function cg(e,t=null){const n=[...e||[]].sort((a,s)=>{var o,u;return Os(a)-Os(s)||(((o=s.pr)==null?void 0:o.number)||0)-(((u=a.pr)==null?void 0:u.number)||0)||a.branch.localeCompare(s.branch)}),i=t&&Hi[t.key];if(!i)return n;const l=t.dir==="asc"?1:-1;return n.sort((a,s)=>{const o=i.value(a),u=i.value(s);return fi(a)-fi(s)||(o===null)-(u===null)||(o===null?0:l*og(o,u))})}function ug(e,t){const n=Hi[t].first;return(e==null?void 0:e.key)!==t?{key:t,dir:n}:e.dir===n?{key:t,dir:n==="asc"?"desc":"asc"}:null}function dg(e,t){const n=(t||"").toLowerCase().split(/\s+/).filter(Boolean);return n.length?(e||[]).filter(i=>{var a,s,o,u;const l=[i.branch,i.repo,i.pr?`#${i.pr.number}`:null,(a=i.pr)==null?void 0:a.title,(s=i.pr)==null?void 0:s.author,(o=i.owner)==null?void 0:o.name,(u=vr(i))==null?void 0:u.id,i.linked_linear_title].filter(Boolean).join(" ").toLowerCase();return n.every(c=>l.includes(c))}):e||[]}function Ds(e){return(e||[]).filter(t=>!fi(t)).reduce((t,n)=>t+(n.unresolved||0),0)}const hg={scope:{name:"Scope",root:[{r:[11,1,2,6],a:{fill:"#2a86b3"}},{r:[11,1,5,2],a:{fill:"#2a86b3"}},{g:[{r:[16,1,1,2],a:{fill:"#ffd166"}}],anim:"crit-scope-1"},{r:[1,9,2,4],a:{fill:"#2a86b3"}},{r:[4,6,12,1],a:{fill:"#40b8ee"}},{r:[3,7,14,8],a:{fill:"#40b8ee"}},{r:[4,15,12,1],a:{fill:"#2a86b3"}},{r:[5,7,3,1],a:{fill:"#7fd0f5"}},{g:[{r:[6,9,2,2],a:{fill:"#0f1215"}}],anim:"crit-scope-2",role:"eye",shut:[6,10,2,.4]},{g:[{r:[12,9,2,2],a:{fill:"#0f1215"}}],anim:"crit-scope-3",role:"eye",shut:[12,10,2,.4]},{g:[{r:[6,9,.7,.7]},{r:[12,9,.7,.7]}],a:{fill:"#f3f5f8"},mood:"calm",role:"glint"},{g:[{r:[5.5,7.9,3,.7]},{r:[11.5,7.9,3,.7]},{r:[8.5,12.2,3,.7]}],a:{fill:"#16384a"},mood:"grumpy"},{g:[{r:[5.4,7.5,1.6,.7]},{r:[7,8.1,1.6,.7]},{r:[11.4,8.1,1.6,.7]},{r:[13,7.5,1.6,.7]},{r:[8.5,11.7,3,1.6]}],a:{fill:"#16384a"},mood:"furious"},{g:[{r:[8.4,11.6,.7,.7],a:{fill:"#16384a"}},{r:[9,12.2,2,.7],a:{fill:"#16384a"}},{r:[10.9,11.6,.7,.7],a:{fill:"#16384a"}},{r:[4.4,11.6,1.5,.8],a:{fill:"#f58967",opacity:"0.7"}},{r:[14.1,11.6,1.5,.8],a:{fill:"#f58967",opacity:"0.7"}}],mood:"calm"},{g:[{r:[5,16,2,2],a:{fill:"#2a86b3"}},{r:[13,16,2,2],a:{fill:"#2a86b3"}}],legs:!0},{g:[{g:[{r:[3,3,1,1]}],anim:"crit-scope-4"},{g:[{r:[6,2,1,1]}],anim:"crit-scope-5"}],a:{fill:"#8f9397"},mood:"furious"}],anchors:{eyes:[{x:6,y:9,w:2,h:2,role:"eye"},{x:12,y:9,w:2,h:2,role:"eye"}],head:{top:1,right:17},hat:{cx:10,top:6,w:12},neck:{y:13,x0:3,x1:17}},ink:"#0f1215",limb:{style:"arm",root:[17,10.6],width:1.2,color:"#2a86b3"}},faradaysie:{name:"Faradaysie",root:[{g:[{r:[12,0,1,1]},{r:[11,1,3,1]},{r:[10,2,5,1]},{r:[12,3,1,2]}],a:{fill:"#f72f96"}},{g:[{g:[{r:[7,0,1,2]}],anim:"crit-faradaysie-1"},{g:[{r:[5,2,5,1]}],anim:"crit-faradaysie-2"},{g:[{r:[6,3,3,1]}],anim:"crit-faradaysie-3"},{g:[{r:[7,4,1,1]}],anim:"crit-faradaysie-4"}],a:{fill:"#e4baff"}},{g:[{r:[7,5,6,1]},{r:[5,6,10,1]},{r:[4,7,12,7]},{r:[5,14,10,1]}],a:{fill:"#b641ff"}},{r:[6,15,8,1],a:{fill:"#6d1ba0"}},{r:[6,6,3,1],a:{fill:"#e4baff"}},{r:[5,7,1,2],a:{fill:"#e4baff"}},{r:[7,11.5,6,2.5],a:{fill:"#fcb0d7"}},{g:[{r:[3,9,1,2]},{g:[{r:[16,9,1,2]}],anim:"crit-faradaysie-5"}],arms:!0,a:{fill:"#6d1ba0"}},{g:[{r:[6,16,2,1]},{r:[12,16,2,1]}],legs:!0,a:{fill:"#6d1ba0"}},{g:[{r:[6,8,2,2],a:{fill:"#240835"}}],anim:"crit-faradaysie-6",role:"eye",shut:[6,9,2,.4]},{g:[{r:[12,8,2,2],a:{fill:"#240835"}}],anim:"crit-faradaysie-7",role:"eye",shut:[12,9,2,.4]},{g:[{r:[6,8,.7,.7]},{r:[12,8,.7,.7]}],a:{fill:"#fdfaff"},mood:"calm",role:"glint"},{g:[{r:[8.4,10.6,.7,.7],a:{fill:"#240835"}},{r:[9,11.2,2,.7],a:{fill:"#240835"}},{r:[10.9,10.6,.7,.7],a:{fill:"#240835"}},{r:[4.4,10.4,1.5,.8],a:{fill:"#f72f96",opacity:"0.75"}},{r:[14.1,10.4,1.5,.8],a:{fill:"#f72f96",opacity:"0.75"}}],mood:"calm"},{g:[{r:[5.5,6.9,3,.7]},{r:[11.5,6.9,3,.7]},{r:[8.5,11,3,.7]}],a:{fill:"#240835"},mood:"grumpy"},{g:[{r:[5.4,6.5,1.6,.7]},{r:[7,7.1,1.6,.7]},{r:[11.4,7.1,1.6,.7]},{r:[13,6.5,1.6,.7]},{r:[8.5,10.5,3,1.6]}],a:{fill:"#240835"},mood:"furious"},{g:[{g:[{r:[2,4,1,2]}],anim:"crit-faradaysie-8"},{g:[{r:[17,3,1,2]}],anim:"crit-faradaysie-9"},{g:[{r:[1,12,1,1]}],anim:"crit-faradaysie-10"},{g:[{r:[18,13,1,1]}],anim:"crit-faradaysie-11"}],a:{fill:"#f72f96"},mood:"furious"}],anchors:{eyes:[{x:6,y:8,w:2,h:2,role:"eye"},{x:12,y:8,w:2,h:2,role:"eye"}],head:{top:0,right:17},hat:{cx:10,top:6,w:10},neck:{y:12.8,x0:4,x1:16}},ink:"#240835",limb:{style:"arm",root:[16.4,9.4],width:1.2,color:"#6d1ba0"}},jelly:{name:"Jelly",root:[{r:[7,3,6,1],a:{fill:"#ab93ed"}},{r:[5,4,10,1],a:{fill:"#ab93ed"}},{r:[4,5,12,6],a:{fill:"#ab93ed"}},{r:[4,11,12,1],a:{fill:"#7d62c9"}},{g:[{r:[4,12,2,1]},{r:[7.3,12,2,1]},{r:[10.7,12,2,1]},{r:[14,12,2,1]}],a:{fill:"#7d62c9"}},{g:[{r:[7,4,3,1]},{r:[5,5,1,2]},{r:[13,5,1,1]},{r:[14,7,1,1]}],a:{fill:"#d4c6fa"}},{g:[{r:[6,13,1,2]},{r:[5,15,1,2]},{r:[6,17,1,1]},{r:[9.5,13,1,2]},{r:[10.5,15,1,2]},{r:[9.5,17,1,1]},{r:[13,13,1,2]},{r:[14,15,1,2]},{r:[13,17,1,1]}],legs:!0,keepSeated:!0,a:{fill:"#7d62c9"},anim:"crit-jelly-1"},{g:[{r:[7,7,2,2],a:{fill:"#2a1f45"}}],anim:"crit-jelly-2",role:"eye",shut:[7,8,2,.4]},{g:[{r:[11,7,2,2],a:{fill:"#2a1f45"}}],anim:"crit-jelly-3",role:"eye",shut:[11,8,2,.4]},{g:[{r:[7,7,.7,.7]},{r:[11,7,.7,.7]}],a:{fill:"#f3f5f8"},mood:"calm",role:"glint"},{g:[{r:[8.4,9.6,.7,.7],a:{fill:"#2a1f45"}},{r:[9,10.2,2,.7],a:{fill:"#2a1f45"}},{r:[10.9,9.6,.7,.7],a:{fill:"#2a1f45"}},{r:[5,9.2,1.5,.8],a:{fill:"#f2a7c3"}},{r:[13.5,9.2,1.5,.8],a:{fill:"#f2a7c3"}}],mood:"calm"},{g:[{r:[6.5,5.9,3,.7]},{r:[10.5,5.9,3,.7]},{r:[8.5,10,3,.7]}],a:{fill:"#2a1f45"},mood:"grumpy"},{g:[{r:[6.4,5.5,1.6,.7]},{r:[8,6.1,1.6,.7]},{r:[10.4,6.1,1.6,.7]},{r:[12,5.5,1.6,.7]},{r:[8.5,9.5,3,1.4]}],a:{fill:"#2a1f45"},mood:"furious"},{g:[{g:[{r:[2,4,1,1]}],anim:"crit-jelly-4"},{g:[{r:[17,6,1,1]}],anim:"crit-jelly-5"}],a:{fill:"#f3e9c6"},mood:"furious"}],anchors:{eyes:[{x:7,y:7,w:2,h:2,role:"eye"},{x:11,y:7,w:2,h:2,role:"eye"}],head:{top:3,right:16},hat:{cx:10,top:3,w:8},neck:{y:10.5,x0:4,x1:16}},ink:"#2a1f45",limb:{style:"tentacle",root:[16,10.2],width:1,color:"#7d62c9"}},nox:{name:"Nox",root:[{g:[{g:[{r:[15,16,3,1]},{r:[17,12,1,4]},{r:[16,11,1,1]}],a:{fill:"#1a1c20",stroke:"#4a4f57","stroke-width":"1"}},{g:[{r:[15,16,3,1]},{r:[17,12,1,4]},{r:[16,11,1,1]}],a:{fill:"#1a1c20"}}],rest:!0,anim:"crit-nox-1"},{g:[{r:[5,3,1,2]},{r:[6,4,1,1]},{r:[14,3,1,2]},{r:[13,4,1,1]},{r:[5,5,10,1]},{r:[4,6,12,5]},{r:[5,11,10,1]},{r:[6,12,8,1]},{r:[5,13,10,5]}],a:{fill:"#1a1c20",stroke:"#4a4f57","stroke-width":"1"}},{g:[{r:[5,3,1,2]},{r:[6,4,1,1]},{r:[14,3,1,2]},{r:[13,4,1,1]},{r:[5,5,10,1]},{r:[4,6,12,5]},{r:[5,11,10,1]},{r:[6,12,8,1]},{r:[5,13,10,5]}],a:{fill:"#1a1c20"}},{g:[{r:[5.2,4.2,.6,.7]},{r:[14.2,4.2,.6,.7]}],a:{fill:"#f2a7c3",opacity:"0.8"}},{r:[6,5,3,1],a:{fill:"#2c3036"}},{g:[{r:[6,17,2,1]},{r:[12,17,2,1]}],legs:!0,keepSeated:!0,a:{fill:"#3a3f46"}},{g:[{r:[1.8,8.8,2.2,.4]},{r:[1.8,10,2.2,.4]},{r:[16,8.8,2.2,.4]},{r:[16,10,2.2,.4]}],a:{fill:"#5c626b"}},{r:[6,6,3,3],a:{fill:"#c6e05a"}},{r:[11,6,3,3],a:{fill:"#c6e05a"}},{g:[{g:[{r:[7,6.5,1.4,2]}],anim:"crit-nox-2"},{g:[{r:[12,6.5,1.4,2]}],anim:"crit-nox-3"}],a:{fill:"#0b0c0e"}},{g:[{r:[6.3,6.3,.7,.7]},{r:[11.3,6.3,.7,.7]}],a:{fill:"#f3f5f8"},mood:"calm"},{g:[{g:[{r:[6,6,3,3]}],anim:"crit-nox-4",role:"lid",shut:[6,6,3,3]},{g:[{r:[11,6,3,3]}],anim:"crit-nox-5",role:"lid",shut:[11,6,3,3]}],a:{fill:"#1a1c20"}},{r:[9.5,9,1,.7],a:{fill:"#f2a7c3"}},{g:[{r:[9,9.9,.5,.5]},{r:[9.4,10.3,.6,.4]},{r:[10,10.3,.6,.4]},{r:[10.5,9.9,.5,.5]}],a:{fill:"#8f9397"},mood:"calm"},{g:[{r:[6,6,3,1.3],a:{fill:"#1a1c20"}},{r:[11,6,3,1.3],a:{fill:"#1a1c20"}},{r:[8.8,10.2,2.4,.5],a:{fill:"#8f9397"}}],mood:"grumpy"},{g:[{r:[8,6,1,1],a:{fill:"#1a1c20"}},{r:[11,6,1,1],a:{fill:"#1a1c20"}},{r:[8.8,9.8,2.4,1.3],a:{fill:"#f2a7c3"}},{r:[9,9.8,.5,.6],a:{fill:"#f3f5f8"}},{r:[10.5,9.8,.5,.6],a:{fill:"#f3f5f8"}},{g:[{g:[{r:[7.5,3.6,1,1.2]}],anim:"crit-nox-6"},{g:[{r:[9.5,3.2,1,1.6]}],anim:"crit-nox-7"},{g:[{r:[11.5,3.6,1,1.2]}],anim:"crit-nox-8"}],a:{fill:"#5c626b"}}],mood:"furious"}],anchors:{eyes:[{x:6,y:6,w:3,h:3,role:"lid"},{x:11,y:6,w:3,h:3,role:"lid"}],head:{top:3,right:18.2},hat:{cx:10,top:5,w:9},neck:{y:12,x0:6,x1:14}},ink:"#c6e05a",faces:{worried:[{g:[{r:[5.8,5.9,1.4,.6]},{r:[7.2,5.4,1.6,.6]},{r:[11.2,5.4,1.6,.6]},{r:[12.8,5.9,1.4,.6]}],a:{fill:"#d5d8dc"}}]},limb:{style:"tail",root:[15.2,16],width:1,color:"#1a1c20",outline:"#4a4f57"}},ember:{name:"Ember",root:[{g:[{r:[4,2,1,2]},{r:[5,3,1,2]},{r:[15,2,1,2]},{r:[14,3,1,2]}],a:{fill:"#ffd9a0"}},{r:[6,4,8,1],a:{fill:"#e8574f"}},{r:[5,5,10,1],a:{fill:"#e8574f"}},{r:[4,6,12,8],a:{fill:"#e8574f"}},{r:[5,14,10,1],a:{fill:"#e8574f"}},{r:[6,15,8,1],a:{fill:"#b8403a"}},{r:[8,11,4,3],a:{fill:"#ff9a8f"}},{r:[6,5,2,1],a:{fill:"#ff9a8f"}},{g:[{r:[3,9,1,2]},{r:[16,9,1,2]}],arms:!0,a:{fill:"#b8403a"}},{g:[{r:[6,16,2,1]},{r:[12,16,2,1]}],legs:!0,a:{fill:"#b8403a"}},{g:[{r:[16,13,1,1]},{r:[17,12,1,1]},{r:[18,10,1,2]},{r:[17,9,1,1]},{r:[19,9,1,1]},{r:[18,8,1,1]}],rest:!0,a:{fill:"#b8403a"},anim:"crit-ember-1"},{g:[{r:[7,7,2,2],a:{fill:"#3a1312"}}],anim:"crit-ember-2",role:"eye",shut:[7,8,2,.4]},{g:[{r:[11,7,2,2],a:{fill:"#3a1312"}}],anim:"crit-ember-3",role:"eye",shut:[11,8,2,.4]},{g:[{r:[7,7,.7,.7]},{r:[11,7,.7,.7]}],a:{fill:"#f3f5f8"},mood:"calm",role:"glint"},{g:[{r:[8.4,9.6,.7,.7],a:{fill:"#3a1312"}},{r:[9,10.2,2,.7],a:{fill:"#3a1312"}},{r:[10.9,9.6,.7,.7],a:{fill:"#3a1312"}},{r:[10.2,10.9,.7,.7],a:{fill:"#ffd9a0"}}],mood:"calm"},{g:[{r:[6.5,5.9,3,.7]},{r:[10.5,5.9,3,.7]},{r:[8.5,10,3,.7]}],a:{fill:"#3a1312"},mood:"grumpy"},{g:[{r:[6.4,5.6,1.6,.7]},{r:[8,6.2,1.6,.7]},{r:[10.4,6.2,1.6,.7]},{r:[12,5.6,1.6,.7]},{r:[8.5,9.5,3,1.5]}],a:{fill:"#3a1312"},mood:"furious"},{g:[{g:[{r:[9,1,2,2],a:{fill:"#ffd166"}}],anim:"crit-ember-4"},{r:[9.5,0,1,1],a:{fill:"#f58967"}}],mood:"furious"}],anchors:{eyes:[{x:7,y:7,w:2,h:2,role:"eye"},{x:11,y:7,w:2,h:2,role:"eye"}],head:{top:2,right:20},hat:{cx:10,top:5,w:10},neck:{y:13.4,x0:4,x1:16}},ink:"#3a1312",limb:{style:"tail",root:[16,13.4],width:1,color:"#b8403a",spade:!0}},volt:{name:"Volt",root:[{g:[{r:[9,4,1,2]},{r:[10,3,1,1]},{r:[9,2,1,1]},{r:[10,1,1,1]}],a:{fill:"#d1a92b"}},{g:[{r:[10,0,1,1],a:{fill:"#fff1a8"}}],anim:"crit-volt-1"},{r:[5,6,10,1],a:{fill:"#f5d547"}},{r:[3,7,14,7],a:{fill:"#f5d547"}},{r:[4,14,12,1],a:{fill:"#d1a92b"}},{r:[6,7,3,1],a:{fill:"#fff1a8"}},{g:[{r:[10,12,1,1]},{r:[9,13,1,1]}],a:{fill:"#fff1a8"}},{g:[{r:[2,9,1,2]},{r:[17,9,1,2]}],arms:!0,a:{fill:"#d1a92b"},anim:"crit-volt-2"},{g:[{r:[5,15,3,1]},{r:[12,15,3,1]}],legs:!0,a:{fill:"#d1a92b"}},{g:[{r:[6,8,2,2],a:{fill:"#3a2f10"}}],anim:"crit-volt-3",role:"eye",shut:[6,9,2,.4]},{g:[{r:[12,8,2,2],a:{fill:"#3a2f10"}}],anim:"crit-volt-4",role:"eye",shut:[12,9,2,.4]},{g:[{r:[6,8,.7,.7]},{r:[12,8,.7,.7]}],a:{fill:"#f3f5f8"},mood:"calm",role:"glint"},{g:[{r:[8.4,10.2,.7,.7],a:{fill:"#3a2f10"}},{r:[9,10.8,2,.7],a:{fill:"#3a2f10"}},{r:[10.9,10.2,.7,.7],a:{fill:"#3a2f10"}},{r:[4.2,10.2,1.5,.8],a:{fill:"#f58967",opacity:"0.7"}},{r:[14.3,10.2,1.5,.8],a:{fill:"#f58967",opacity:"0.7"}}],mood:"calm"},{g:[{r:[5.5,6.9,3,.7]},{r:[11.5,6.9,3,.7]},{r:[8.5,10.6,3,.7]}],a:{fill:"#3a2f10"},mood:"grumpy"},{g:[{r:[5.4,6.5,1.6,.7]},{r:[7,7.1,1.6,.7]},{r:[11.4,7.1,1.6,.7]},{r:[13,6.5,1.6,.7]},{r:[8.5,10,3,1.6]}],a:{fill:"#3a2f10"},mood:"furious"},{g:[{g:[{r:[1,3,1,2]}],anim:"crit-volt-5"},{g:[{r:[18,4,1,2]}],anim:"crit-volt-6"}],a:{fill:"#fff1a8"},mood:"furious"}],anchors:{eyes:[{x:6,y:8,w:2,h:2,role:"eye"},{x:12,y:8,w:2,h:2,role:"eye"}],head:{top:0,right:18},hat:{cx:10,top:6,w:10},neck:{y:12.4,x0:3,x1:17}},ink:"#3a2f10",limb:{style:"arm",root:[17.4,9.4],width:1.2,color:"#d1a92b"}},moss:{name:"Moss",root:[{g:[{r:[7,3,2,1]},{r:[9.5,2,1.5,2]},{r:[11.5,3,2,1]}],a:{fill:"#2e9a56"},anim:"crit-moss-1"},{r:[7,4,6,1],a:{fill:"#47cf79"}},{r:[6,5,8,1],a:{fill:"#47cf79"}},{r:[5,6,10,9],a:{fill:"#47cf79"}},{r:[6,15,8,1],a:{fill:"#2e9a56"}},{g:[{r:[6,6,1,1]},{r:[12,5,1,1]},{r:[13,12,1,1]},{r:[6,13,1,1]}],a:{fill:"#9ae8b6"}},{g:[{r:[4,10,1,3],a:{fill:"#2e9a56"}},{g:[{r:[15,10,1,3],a:{fill:"#2e9a56"}}],anim:"crit-moss-2"}],arms:!0},{g:[{r:[6,16,2,1]},{r:[12,16,2,1]}],legs:!0,a:{fill:"#2e9a56"}},{r:[8,7,4,3],a:{fill:"#f3f5f8"}},{g:[{r:[9,7.5,2,2],a:{fill:"#0f2e1b"}}],anim:"crit-moss-3"},{g:[{r:[8,7,4,3],a:{fill:"#47cf79"}}],anim:"crit-moss-4",role:"lid",shut:[8,7,4,3]},{g:[{r:[8.4,11.4,.7,.7],a:{fill:"#0f2e1b"}},{r:[9,12,2,.7],a:{fill:"#0f2e1b"}},{r:[10.9,11.4,.7,.7],a:{fill:"#0f2e1b"}},{r:[6,11,1.3,.7],a:{fill:"#f2a7c3"}},{r:[12.7,11,1.3,.7],a:{fill:"#f2a7c3"}}],mood:"calm"},{g:[{r:[8,7,4,1.3],a:{fill:"#2e9a56"}},{r:[8.5,12,3,.7],a:{fill:"#0f2e1b"}}],mood:"grumpy"},{g:[{r:[7.6,5.6,1.6,.7]},{r:[9.2,6.2,1.6,.7]},{r:[10.8,5.6,1.6,.7]},{r:[8.5,11.4,3,1.6]}],a:{fill:"#0f2e1b"},mood:"furious"}],anchors:{eyes:[{x:8,y:7,w:4,h:3,role:"lid"}],head:{top:2,right:16},hat:{cx:10,top:4,w:7},neck:{y:12.4,x0:5,x1:15}},ink:"#0f2e1b",limb:{style:"arm",root:[15.6,10.6],width:1.1,color:"#2e9a56"}},octocat:{name:"Octocat",root:[{g:[{g:[{r:[4,14,1,2]},{r:[3,16,2,1]},{r:[7,14,1,3]},{r:[6,17,2,1]},{r:[12,14,1,3]},{r:[12,17,2,1]},{r:[15,14,1,2]},{r:[15,16,2,1]}],a:{fill:"#24292f",stroke:"#6e7781","stroke-width":"1"}},{g:[{r:[4,14,1,2]},{r:[3,16,2,1]},{r:[7,14,1,3]},{r:[6,17,2,1]},{r:[12,14,1,3]},{r:[12,17,2,1]},{r:[15,14,1,2]},{r:[15,16,2,1]}],a:{fill:"#24292f"}}],legs:!0,anim:"crit-octocat-1"},{g:[{r:[4,2,1,2]},{r:[5,3,1,1]},{r:[15,2,1,2]},{r:[14,3,1,1]},{r:[4,4,12,1]},{r:[3,5,14,7]},{r:[4,12,12,2]}],a:{fill:"#24292f",stroke:"#6e7781","stroke-width":"1"}},{g:[{r:[4,2,1,2]},{r:[5,3,1,1]},{r:[15,2,1,2]},{r:[14,3,1,1]},{r:[4,4,12,1]},{r:[3,5,14,7]},{r:[4,12,12,2]}],a:{fill:"#24292f"}},{g:[{r:[6,6,8,1]},{r:[5,7,10,4]},{r:[6,11,8,1]}],a:{fill:"#f4c7ad"}},{g:[{r:[7,8,2,2],a:{fill:"#2b1d16"}}],anim:"crit-octocat-2",role:"eye",shut:[7,9,2,.4]},{g:[{r:[11,8,2,2],a:{fill:"#2b1d16"}}],anim:"crit-octocat-3",role:"eye",shut:[11,9,2,.4]},{g:[{r:[7,8,.7,.7]},{r:[11,8,.7,.7]}],a:{fill:"#f3f5f8"},mood:"calm",role:"glint"},{g:[{r:[9,10.4,2,.6],a:{fill:"#2b1d16"}},{r:[5.4,10,1.2,.6],a:{fill:"#e8909c"}},{r:[13.4,10,1.2,.6],a:{fill:"#e8909c"}}],mood:"calm"},{g:[{r:[6.5,6.8,3,.6]},{r:[10.5,6.8,3,.6]},{r:[8.5,10.6,3,.6]}],a:{fill:"#2b1d16"},mood:"grumpy"},{g:[{r:[6.4,6.4,1.6,.6]},{r:[8,7,1.6,.6]},{r:[10.4,7,1.6,.6]},{r:[12,6.4,1.6,.6]},{r:[8.5,10.2,3,1.2]}],a:{fill:"#2b1d16"},mood:"furious"},{g:[{g:[{r:[1,4,1,1]}],anim:"crit-octocat-4"},{g:[{r:[18,5,1,1]}],anim:"crit-octocat-5"}],a:{fill:"#f3e9c6"},mood:"furious"}],anchors:{eyes:[{x:7,y:8,w:2,h:2,role:"eye"},{x:11,y:8,w:2,h:2,role:"eye"}],head:{top:2,right:17},hat:{cx:10,top:4,w:12},neck:{y:11.6,x0:4,x1:16}},ink:"#2b1d16",limb:{style:"tentacle",root:[16.6,12.4],width:1,color:"#24292f"}}},pi=[{id:"clawd",name:"Clawd",sprite:null},...Object.entries(hg).map(([e,t])=>({id:e,name:t.name,sprite:t}))];function au(e){return pi.find(t=>t.id===e)||pi[0]}const su=10,xa=12,fg=19,pg=17,N=e=>Math.round(e*1e4)/1e4;function bn(e,{seated:t=!1}={}){let n=1/0,i=1/0,l=-1/0,a=-1/0;const s=o=>{if(!o.mood&&!(t&&o.legs&&!o.keepSeated)){if(o.r){const[u,c,p,d]=o.r;n=Math.min(n,u),i=Math.min(i,c),l=Math.max(l,u+p),a=Math.max(a,c+d);return}o.g.forEach(s)}};return e.root.forEach(s),{x:n,y:i,w:l-n,h:a-i}}function Sa(e,{x0:t,sitting:n,height:i=xa}){const l=bn(e),a=i/l.h,s=n?(({y:u,h:c})=>u+c)(bn(e,{seated:!0})):l.y+l.h,o=(n?pg:fg)-a*s;return{scale:a,tx:N(t+8.5-a*(l.x+l.w/2)),ty:N(o),top:N(o+a*l.y),drop:n?N(a*(l.y+l.h-s)):0}}const mg=.75,dl=(e,t=mg)=>({fill:"none",stroke:e,"stroke-width":t,"stroke-linecap":"square"});function gg(e){const t=bn(e),n=t.x+t.w/2,i=l=>l.r?{...l,r:[N(l.r[0]+(l.r[0]+l.r[2]/2l.legs?[{g:[l],cls:"tama-legs-a"},{g:[i(l)],cls:"tama-legs-b"}]:[l])}const yg=new Set(["happy","x","down"]);function bg(e){if(e.length===1){const{x:n,y:i,w:l}=e[0];return[{p:`M${N(n-.3)} ${N(i-.7)} l${N(l/2+.3)} -0.8 l${N(l/2+.3)} 0.8`}]}const t=e.reduce((n,i)=>n+i.x+i.w/2,0)/e.length;return e.map(({x:n,y:i,w:l})=>n+l/2({p:`M${o} ${N(u+.75*p)} l${N(c/2)} ${N(-p/2)} l${N(c/2)} ${N(p/2)}`}))}]:t==="x"?[{a:dl(l),g:n.map(({x:o,y:u,w:c,h:p})=>({p:`M${N(o+.1)} ${N(u+.1)} L${N(o+c-.1)} ${N(u+p-.1)} M${N(o+c-.1)} ${N(u+.1)} L${N(o+.1)} ${N(u+p-.1)}`}))}]:t==="down"?[{a:{fill:l},g:n.map(({x:o,y:u,w:c,h:p})=>({r:[o,N(u+.45*p),c,N(.55*p)]}))}]:[]}function wg(e,t=!1){const{head:n}=e.anchors,i=N(t?bn(e).x-1.4:n.right+.4);return[{cls:"tama-startle",a:{fill:"#f2c14e"},g:[{r:[i,N(n.top+.5),1,3]},{r:[i,N(n.top+4.1),1,1]}]}]}function vg(e){const{cx:t,top:n,w:i}=e.anchors.hat;return`translate(${t} ${n}) scale(${N(i/12)}) translate(-9 -9)`}function _g(e,t){if(t==="goggles"){const{eyes:n}=e.anchors,i=n.reduce((o,u)=>o+u.y+u.h/2,0)/n.length,l=Math.min(...n.map(o=>o.x))-2,a=Math.max(...n.map(o=>o.x+o.w))+2,s={rx:1,fill:"#7fd1e6","fill-opacity":.45,stroke:"#2b2f36","stroke-width":.5};return[{cls:"tama-goggles",g:[{r:[N(l),N(i-.4),N(a-l),.8],a:{fill:"#2b2f36"}},...n.map(o=>({r:[N(o.x-.6),N(o.y-.6),N(o.w+1.2),N(o.h+1.2)],a:s}))]}]}if(t==="scarf"){const{y:n,x0:i,x1:l}=e.anchors.neck,a=[];for(let s=i+2;s+.7<=l;s+=3)a.push({r:[N(s),n,.7,1.6]});return[{cls:"tama-scarf",g:[{r:[i,n,N(l-i),1.6],a:{fill:"#d64541"}},{g:a,a:{fill:"#f4f4f6"}},{r:[N(i-3),N(n+.3),3.6,1.1],cls:"tama-scarf-tail",a:{fill:"#d64541"}}]}]}return[]}function Rs(e,t){const n=/^#([0-9a-f]{6})$/i.exec(e||"");if(!n)return e;const i=Number.parseInt(n[1],16),[l,a,s]=[i>>16&255,i>>8&255,i&255].map(x=>x/255),o=Math.max(l,a,s),u=Math.min(l,a,s),c=o-u;if(c===0)return e.toLowerCase();const d=(((o===l?(a-s)/c%6:o===a?(s-l)/c+2:(l-a)/c+4)*60+t)%360+360)%360,f=c*(1-Math.abs(d/60%2-1)),[h,m,b]=d<60?[c,f,0]:d<120?[f,c,0]:d<180?[0,c,f]:d<240?[0,f,c]:d<300?[f,0,c]:[c,0,f];return`#${[h,m,b].map(x=>Math.round((x+u)*255).toString(16).padStart(2,"0")).join("")}`}const $a={pint:{reach:2.6,at:.42},mug:{reach:2.2,at:.55},spoon:{reach:2.4,at:.55},can:{reach:2.6,at:.45},leash:{reach:2.4,at:.65}};function qi(e,t){const n=bn(e),{reach:i,at:l}=$a[t];return[N(e.limb.root[0]+i),N(n.y+l*n.h)]}function xg(e,t,{scale:n,tx:i,ty:l}){const[a,s]=qi(e,t);return[N(i+n*a),N(l+n*s)]}function Fs({scale:e,tx:t,ty:n},[i,l]){return[N((i-t)/e),N((l-n)/e)]}function Hl(e,t,n=qi(e,t)){const{style:i,root:[l,a],width:s,color:o,outline:u,spade:c}=e.limb,[p,d]=n,f=(m,b,x,w)=>({r:[N(m),N(b),N(x),N(w)]});if(i==="arm")return[{a:{fill:o},g:[f(l,a,p-l,s),f(p-s,Math.min(a,d),s,Math.abs(d-a)+s),f(p-s*1.1,d-s*.4,s*1.4,s)]}];if(i==="tentacle"){const m=Math.max(2,Math.ceil(Math.max(Math.abs(p-l),Math.abs(d-a))/(.75*s))),b=[];for(let x=0;x<=m;x++)b.push(f(l+(p-l)*x/m-.45*s,a+(d-a)*x/m-.45*s,.95*s,.95*s));return[{a:{fill:o},g:[...b,f(p+.3*s,d-.9*s,.8*s,.8*s)]}]}const h=[f(l,a,p-l,s),f(p-s,d,s,a-d+s),f(p-s,d-s*.2,s*1.6,s)];return[...u?[{a:{fill:o,stroke:u,"stroke-width":1},g:h}]:[],{a:{fill:o},g:[...h,...c?[f(p+.4,d-.9,1.2,1.2)]:[]]}]}function Ca(e,t=!1,n=void 0){return e.flatMap(i=>{var a;if(i.mood)return[];const l=((a=i.a)==null?void 0:a.fill)??n;return i.r?t?[{r:i.r,fill:l}]:[]:Ca(i.g,t||!!i.arms,l)})}function Sg(e){return Ca(e.root).length===0}function $g(e){const t=Ca(e.root);if(t.length)return t.map(({r:[i,l,a],fill:s},o)=>({r:[i,N(l-4),a,4],a:{fill:s},cls:o?"tama-cheer tama-cheer2":"tama-cheer"}));const n=bn(e);return[{cls:"tama-cheer",g:Hl(e,null,[N(e.limb.root[0]+1.6),N(n.y+.12*n.h)])}]}const ou="#ff3b2f",Cg="#f3f5f8";function Tg(e){let t=null;const n=(d,f)=>{const h=f||d.mood==="furious";if(d.r){h&&d.r[2]>=2.4&&d.r[3]>=1.2&&(!t||d.r[2]>t[2])&&(t=d.r);return}(d.g||[]).forEach(m=>{n(m,h)})};if(e.root.forEach(d=>{n(d,!1)}),!t)return[];const[i,l,a,s]=t,o=l+s*.3,u=l+s*.7,c=a/4-.05;let p=`M${N(i+.1)} ${N(u)}`;for(let d=1;d<=4;d++)p+=` L${N(i+.1+c*d)} ${N(d%2?o:u)}`;return[{p,a:{fill:"none",stroke:Cg,"stroke-width":.35,"stroke-linejoin":"miter"}}]}const mi=[{id:"hanken",name:"Hanken Grotesk",face:"Hanken Grotesk",stack:"'Hanken Grotesk', -apple-system, system-ui, sans-serif"},{id:"inter",name:"Inter",face:"Inter",stack:"'Inter', -apple-system, system-ui, sans-serif"},{id:"system-sans",name:"System sans",face:"system-ui",stack:"-apple-system, system-ui, sans-serif"},{id:"plex-mono",name:"IBM Plex Mono",face:"IBM Plex Mono",mono:!0,stack:"'IBM Plex Mono', ui-monospace, 'JetBrains Mono', Menlo, monospace"},{id:"jetbrains-mono",name:"JetBrains Mono",face:"JetBrains Mono",mono:!0,stack:"'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace"},{id:"sf-mono",name:"SF Mono",face:"SF Mono",mono:!0,stack:"'SF Mono', ui-monospace, Menlo, monospace"},{id:"menlo",name:"Menlo",face:"Menlo",mono:!0,stack:"Menlo, Monaco, monospace"}],cu={ui:"hanken",code:"plex-mono"};function uu(e,t){return mi.find(n=>n.id===e)||mi.find(n=>n.id===cu[t])}const Qe=H([]);let Eg=1;function kn(e,t="info",n=4e3){const i=Eg++;return Qe.value=[...Qe.value,{id:i,message:e,kind:t,ms:n,show:!1}],requestAnimationFrame(()=>{Qe.value=Qe.value.map(l=>l.id===i?{...l,show:!0}:l)}),setTimeout(()=>{Qe.value=Qe.value.map(l=>l.id===i?{...l,show:!1}:l),setTimeout(()=>{Qe.value=Qe.value.filter(l=>l.id!==i)},200)},n),i}function Pg(){const e=Qe.value;return r("div",{id:"toast-container",children:e.map(t=>r("div",{class:`toast toast-${t.kind}${t.show?" toast-show":""}`,children:t.message},t.id))})}let Pt=[];function ye(e,t){Pt.push({name:e,detail:t||null,t:Math.floor(Date.now()/1e3)}),Pt.length>500&&(Pt=Pt.slice(-500))}function hl(e){if(!Pt.length)return;const t=JSON.stringify({events:Pt});Pt=[],e&&navigator.sendBeacon?navigator.sendBeacon("/api/events",new Blob([t],{type:"application/json"})):fetch("/api/events",{method:"POST",headers:{"Content-Type":"application/json"},body:t,keepalive:!0}).catch(()=>{})}typeof addEventListener=="function"&&(setInterval(()=>hl(!1),5e3),addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&hl(!0)}),addEventListener("pagehide",()=>hl(!0)));const ql={claude:{label:"Claude",glyph:"✻",className:"icon-claude"},codex:{label:"Codex",glyph:"⬡",className:"icon-codex"}};function wn(e,t,n=`${t}s`){return`${e} ${e===1?t:n}`}function _e(e){return(e==null?void 0:e.name)||(e==null?void 0:e.agent)||"shell"}function tt(e){const t=e.lastIndexOf(":"),n=e.slice(0,t),i=e.slice(t+1);return`session=${encodeURIComponent(n)}&index=${encodeURIComponent(i)}`}function Ag(e){return`pane_id=${encodeURIComponent(e)}`}function Pe(e){if(!e)return"";const t=Math.max(0,Math.floor(Date.now()/1e3)-e);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:t<86400?`${Math.floor(t/3600)}h`:`${Math.floor(t/86400)}d`}function Mg(e){return e?{"approve askuserquestion":"needs answer","permission prompt":"needs approval","dialog open":"needs input"}[e.toLowerCase()]||e.toLowerCase():"needs input"}function du(e){if(!e)return null;const t=e.toLowerCase();return t==="permission prompt"?"permission":t==="approve askuserquestion"?"question":"dialog"}function hu(e,t){if(!e)return e;const n=e.split("/");for(let i=1;is!==e&&s&&s.split("/").slice(-i).join("/")===l))return l}return e}function fu(e){if(!e)return null;const t=Math.floor(e.age_s/86400),n=Math.floor(e.age_s%86400/3600),i=t>0?`${t}d ${n}h`:`${n}h`;return{label:e.trigger==="mem"?`${e.gb}G`:`${t}d`,title:`Claude is using ${e.gb}GB after ${i} — consider exiting and resuming this session`,cls:`mem-${e.tier}`}}function lr(e,t){return e?`https://github.com/${e}/pull/${t}`:null}function Ui(e){return e==="merged"?{cls:"is-merged",suffix:" (merged)"}:e==="closed"?{cls:"is-closed",suffix:" (closed)"}:{cls:"",suffix:""}}async function ie(e,t,n={}){const i=n.method||"GET";let l;try{l=await fetch(t,n)}catch(s){return ye(`api:${e}`,{path:t,method:i,ok:!1}),kn(`${e} failed: ${s.message}`,"bad",6e3),null}let a={};try{a=await l.json()}catch{}if(!l.ok||a.ok===!1){ye(`api:${e}`,{path:t,method:i,ok:!1});const s=a.error||a.detail||`HTTP ${l.status}`;return kn(`${e} failed: ${s}`,"bad",6e3),null}return ye(`api:${e}`,{path:t,method:i,ok:!0}),a}async function Lg(e,t){var a,s;let n;try{n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),...typeof AbortSignal<"u"&&typeof AbortSignal.timeout=="function"?{signal:AbortSignal.timeout(1e4)}:{}})}catch(o){return{ok:!1,status:0,detail:(o==null?void 0:o.message)||String(o)}}let i={};try{i=await n.json()||{}}catch{}const l=typeof i.detail=="string"?i.detail:typeof i.error=="string"?i.error:((s=(a=i.detail)==null?void 0:a[0])==null?void 0:s.msg)||`HTTP ${n.status}`;return{ok:n.ok,status:n.status,detail:l}}const me=H({loaded:!1,ui:{},windows:{},commands:[]}),G=()=>me.value;async function Wi(){try{const e=await fetch("/api/prefs");if(!e.ok)throw new Error(`HTTP ${e.status}`);const t=await e.json();return me.value={...me.value,ui:t.ui||{},windows:t.windows||{},commands:t.commands||[],loaded:!0},await Bg(),me.value}catch{return me.value={...me.value,loaded:!1},null}}function Wr(){return G().commands||[]}async function Ig({label:e,exec:t}){if(!G().loaded)return!1;const n=await ie("add command","/api/prefs/commands",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({label:e,exec:""})});return n?(me.value={...G(),commands:n.commands},!0):!1}async function Og(e,{label:t,exec:n}){if(!G().loaded)return!1;const i=await ie("update command",`/api/prefs/commands/${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({label:t,exec:n||""})});return i?(me.value={...G(),commands:i.commands},!0):!1}async function Dg(e){if(!G().loaded)return!1;const t=await ie("delete command",`/api/prefs/commands/${encodeURIComponent(e)}`,{method:"DELETE"});return t?(me.value={...G(),commands:t.commands},!0):!1}async function Rg(e){if(!G().loaded)return!1;const t=await ie("reorder commands","/api/prefs/commands",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({labels:e})});return t?(me.value={...G(),commands:t.commands},!0):!1}async function $e(e,t){if(!G().loaded&&(await Wi(),!G().loaded))return!1;const n={...G().ui};me.value={...G(),ui:{...G().ui,...e}};const i=await ie("save prefs","/api/prefs/ui",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{...e,writer:t}:e)});return i?(me.value={...G(),ui:i.ui},!0):(me.value={...G(),ui:n},!1)}function Fg(e){me.value={...G(),ui:e}}function Pr(e){if(!e)return null;const t=G().windows[e];if(!t)return null;const n=t.notes||"",i=t.tags||[],l=t.pinned_files||[];return!n&&!i.length&&!l.length?null:{notes:n,tags:i,pinned_files:l}}async function Kr(e,{notes:t,tags:n,pinned_files:i}){if(!G().loaded&&(await Wi(),!G().loaded))return!1;const l=G().windows[e],a=l||{},s={...a,notes:t??a.notes,tags:n??a.tags,pinned_files:i??a.pinned_files};me.value={...G(),windows:{...G().windows,[e]:s}};const o={};t!==void 0&&(o.notes=t),n!==void 0&&(o.tags=n),i!==void 0&&(o.pinned_files=i);const u=await ie("save annotation",`/api/prefs/windows/${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!u){const c={...G().windows};return l===void 0?delete c[e]:c[e]=l,me.value={...G(),windows:c},!1}return me.value={...G(),windows:{...G().windows,[e]:{...G().windows[e]||{},...u.annotation}}},!0}function pu(e){if(!e)return[];const t=G().windows[e];return[...(t==null?void 0:t.pinned_files)||[]]}function Ng(e,t){if(!e||!t)return Promise.resolve(!1);const n=pu(e),i=n.includes(t)?n.filter(l=>l!==t):[...n,t];return Kr(e,{pinned_files:i})}async function Bg(){const e={"periscope:sessionOrder":"session_order","periscope:collapsedSessions":"collapsed_sessions","periscope:view":"view"};if(!Object.keys(e).some(l=>localStorage.getItem(l)!==null))return;const n=G().ui;if(!n.session_order&&!n.collapsed_sessions&&!n.view){const l={};for(const[a,s]of Object.entries(e)){const o=localStorage.getItem(a);if(o!==null)try{l[s]=s==="view"?o:JSON.parse(o)}catch{}}if(Object.keys(l).length&&!await $e(l))return}for(const l of Object.keys(e))localStorage.removeItem(l)}function gi(){const e=G().ui||{};return[...e.track_order||e.repo_order||[]]}function zg(e,t){return $e({track_order:e},t)}function ar(){return{...(G().ui||{}).tabs_by_track||{}}}function jg(e){return $e({tabs_by_track:e})}function Ta(){var e;return{...((e=G().ui)==null?void 0:e.branch_order_by_track)||{}}}function sr(){var e;return{...((e=G().ui)==null?void 0:e.rail_collapsed)||{}}}function mu(e,t){const n=sr();return n[e]=t,$e({rail_collapsed:n})}function Hg(){var e;return((e=G().ui)==null?void 0:e.last_selected)||null}function yt(e){return $e({last_selected:e})}function qg(){var e;return((e=G().ui)==null?void 0:e.launch_profile)||"default"}function Ug(e){return $e({launch_profile:e})}function gu(){var e;return au((e=G().ui)==null?void 0:e.tama_critter).id}function Wg(e){return $e({tama_critter:e})}function or(e){var t;return uu((t=G().ui)==null?void 0:t[`${e}_font`],e)}function Kg(e,t){return $e({[`${e}_font`]:t})}const Vg={needs_input:!0,done:!0,ci_failed:!0,pr_merged:!0,usage:!0,quiet_when_focused:!0,group:!0,badge:!0};function yi(){var e;return{...Vg,...((e=G().ui)==null?void 0:e.notify)||{}}}function Gg(e,t){return $e({notify:{...yi(),[e]:t}})}function Ea(){var e;return[...((e=G().ui)==null?void 0:e.pinned_pids)||[]]}function Jg(e){return $e({pinned_pids:e})}function Qg(e){const t=Ea(),n=t.includes(e)?t.filter(i=>i!==e):[...t,e];return Jg(n)}function Yg(e){var t;return((t=G().ui)==null?void 0:t[e])??null}function Ns(e,t){return $e({[e]:t})}function Pa(e){var t;return!!((t=G().ui)!=null&&t[`${e}_hidden`])}function Zg(e,t){return $e({[`${e}_hidden`]:t})}function yu(e){var t,n;return((n=(t=G().ui)==null?void 0:t.detail_mode_by_pid)==null?void 0:n[e])||null}function Ul(e,t){var i;const n={...((i=G().ui)==null?void 0:i.detail_mode_by_pid)||{}};return n[e]=t,$e({detail_mode_by_pid:n})}function Aa(){const e=G().ui||{};return{merged:e.clawd_merged,furious:e.clawd_furious}}async function bu(e,t){var n;return G().loaded||await Wi(),!G().loaded||((n=Aa()[e])==null?void 0:n.slice(0,10))===t.slice(0,10)?!1:$e({[`clawd_${e}`]:t})}function Ke(){return typeof window<"u"&&typeof window.__TAURI_INTERNALS__<"u"&&typeof window.__TAURI_INTERNALS__.invoke=="function"}function Cn(e,t){return window.__TAURI_INTERNALS__.invoke(e,t||{})}async function Ma(e,t){const n=window.__TAURI_INTERNALS__.transformCallback(i=>{i!=null&&i.payload&&t(i.payload)});await Cn("plugin:event|listen",{event:e,target:{kind:"Any"},handler:n})}async function Xg(e){if(Ke())try{const t=e>0?Math.floor(e):null;await Cn("plugin:window|set_badge_count",{count:t})}catch(t){console.warn("[tauri] setBadgeCount failed:",t)}}async function ku({title:e,body:t,target:n="",...i}){if(Ke())try{await Cn("plugin:event|emit",{event:"periscope:notify",payload:{title:e,body:t,target:n,...i}})}catch(l){console.warn("[tauri] notify failed:",l)}}async function e1(e){if(Ke())try{await Ma("periscope:notification-clicked",e)}catch(t){console.warn("[tauri] notification-click listener failed:",t)}}async function t1(e){if(Ke())try{await Ma("periscope:notification-opened",e)}catch(t){console.warn("[tauri] notification-opened listener failed:",t)}}async function n1(e){if(Ke())try{await Ma("periscope:notification-action",e)}catch(t){console.warn("[tauri] notification-action listener failed:",t)}}async function r1(e){if(Ke())try{await Cn("plugin:event|emit",{event:"periscope:notify-categories",payload:e})}catch(t){console.warn("[tauri] setNotifyCategories failed:",t)}}function Ki(e){if(Ke())return Cn("plugin:opener|open_url",{url:e}).catch(t=>{console.warn("[tauri] open_url failed:",t)}),!0;try{if(window.open(e,"_blank","noopener,noreferrer"))return!0}catch(t){console.warn("[periscope] window.open threw:",t)}try{const t=document.createElement("a");return t.href=e,t.target="_blank",t.rel="noopener noreferrer",document.body.appendChild(t),t.click(),t.remove(),!0}catch(t){console.warn("[periscope] anchor-click fallback threw:",t)}return!1}function i1(){Ke()&&document.addEventListener("click",e=>{const t=e.target.closest("a[href]");if(!t)return;let n;try{n=new URL(t.href)}catch{return}n.protocol!=="http:"&&n.protocol!=="https:"||n.origin!==location.origin&&(e.preventDefault(),e.stopPropagation(),Cn("plugin:opener|open_url",{url:n.href}).catch(i=>{console.warn("[tauri] open_url failed:",i)}))},!0)}function l1(e){return!!(e!=null&&e.asked_question)&&!(e!=null&&e.waiting_for)}function Bs(e,t,n){const i=new Set((t||[]).filter(a=>a.state===n).map(a=>a.pid)),l=new Set;for(const a of e)i.has(a)&&l.add(a);return l}function La(e,t,n,i=new Set){const l=Oa(e),a=(e||[]).filter(o=>o.state==="needs-input").filter(o=>!i.has(o.pid)).map(o=>({kind:"live",pid:o.pid,w:o})),s=(t||[]).filter(o=>o.kind==="need_human").filter(o=>!n.has(o.id)).filter(o=>!Ia(o,l)).sort((o,u)=>u.ts-o.ts).map(o=>({kind:"event",id:o.id,pane_id:o.pane_id,target:o.target,w:l[o.target]||null,message:o.message,ts:o.ts,session:o.session,name:o.name}));return[...a,...s]}function wu(e,t,n,i=new Set){const l=Oa(e),a=(e||[]).filter(u=>u.state==="done").filter(u=>!i.has(u.pid)).map(u=>({kind:"live",pid:u.pid,w:u})),s=new Set(a.map(u=>u.w.target)),o=(t||[]).filter(u=>u.kind==="done").filter(u=>!n.has(u.id)).filter(u=>!s.has(u.target)).filter(u=>!Ia(u,l)).sort((u,c)=>c.ts-u.ts).map(u=>({kind:"event",id:u.id,pane_id:u.pane_id,target:u.target,w:l[u.target]||null,message:u.message,ts:u.ts,session:u.session,name:u.name}));return[...a,...o]}function Ia(e,t){const n=t[e.target];return n?Math.max(n.focused_at||0,n.acted_at||0)>e.ts:!1}function a1(e){return e.length}const s1=600,o1=3600;function vu(e,t){const n=(t||0)-(e||0);return n>=o1?"urgent":n>=s1?"stale":"fresh"}function _u(e,t,n=new Set){var a;const i=Oa(e),l=new Map;for(const s of t||[]){if(s.kind!=="need_human"||n.has(s.id)||Ia(s,i))continue;const o=(a=i[s.target])==null?void 0:a.pid;if(!o)continue;const u=l.get(o);(u===void 0||s.ts!0){var u,c;const s=_u(e,t,n),o=new Map;for(const p of La(e,t,n,i)){if(!a(p.w))continue;const d=((u=p.w)==null?void 0:u.pid)!=null?`pid:${p.w.pid}`:`target:${p.target}`,f=Math.min(p.kind==="event"?p.ts:p.w.needs_since||l,...((c=p.w)==null?void 0:c.pid)!=null&&s.has(p.w.pid)?[s.get(p.w.pid)]:[]),h=o.get(d);o.set(d,{row:(h==null?void 0:h.row.kind)==="live"?h.row:p,since:h?Math.min(h.since,f):f})}return o}function Su(e){return(e||[]).filter(t=>t.state==="working").map(t=>({kind:"live",pid:t.pid,w:t}))}function c1(e,t){const n={};for(const i of t||[])n[i.pid]=i;return(e||[]).map(i=>n[i]).filter(Boolean)}function u1(e){return(e||[]).filter(t=>t.kind==="done"||t.kind==="info")}function Oa(e){const t={};for(const n of e||[])t[n.target]=n;return t}const Da=nr;let zs=!1;function jt(e){e&&at((ce.value||[]).find(t=>t.target===e))}function at(e){e!=null&&e.pid&&(ke.value=`pane:${e.pid}`,yt({kind:"pane",pid:e.pid}))}function $u(e){l1(e)&&(ft.value=new Set([...ft.value,e.pid])),at(e)}function Cu(e){e!=null&&e.pid&&(pt.value=new Set([...pt.value,e.pid]))}function Tu(e){Cu(e),at(e)}function d1(){zs||(zs=!0,e1(e=>jt(e)))}function Eu(e,t){!e||!t||(ke.value=`review:${e}/${t.replace(/\//g,"--")}`,yt({kind:"review",repo:e,branch:t}))}function Ra(){ke.value="reviews",yt({kind:"reviews"})}const fl=[{key:"all",label:"all"},{key:"needs-input",label:"needs input"},{key:"working",label:"working"},{key:"done",label:"done"},{key:"idle",label:"idle"},{key:"agents",label:"agents"},{key:"shell",label:"shells"},{key:"ci-bad",label:"CI ✗"}];function h1(){const[e,t]=B(!1),n=te(null),i=Rl.value,l=(fl.find(o=>o.key===i)||fl[0]).label,a=br(()=>t(!1),[]);Fi(n,e,a);function s(o){Rl.value=o,ye("filter.use"),t(!1)}return r("div",{class:"tb-dd","data-dd":"filter",ref:n,children:[r("button",{type:"button",class:"filter-btn tb-dd-toggle",id:"filter-dd-toggle","aria-haspopup":"menu","aria-expanded":e?"true":"false",title:"filter by state",onClick:o=>{o.stopPropagation(),t(u=>!u)},children:[r("span",{id:"filter-dd-label",children:l}),r("span",{class:"tb-dd-chev","aria-hidden":"true",children:"▾"})]}),r("div",{class:"tb-dd-menu",id:"filter-dd-menu",role:"menu",hidden:!e,children:fl.map(o=>r("button",{"data-filter":o.key,class:`tb-dd-item${o.key===i?" active":""}`,role:"menuitem",onClick:()=>s(o.key),children:o.label},o.key))})]})}const Pu=Vt(()=>Pa("rail")),bi=Vt(()=>Pa("side"));function Wl(e){return Zg(e,!Pa(e))}function js({side:e,shown:t}){return r("svg",{width:"16",height:"12",viewBox:"0 0 16 12","aria-hidden":"true",children:[r("rect",{x:"0.5",y:"0.5",width:"15",height:"11",rx:"1.5",fill:"none",stroke:"currentColor"}),r("rect",{x:e==="left"?2:10,y:"2",width:"4",height:"8",rx:"0.5",fill:t?"currentColor":"none",stroke:"currentColor","stroke-width":"0.75"})]})}function f1(){const e=!Pu.value,t=!bi.value;return r("span",{class:"panel-toggles",children:[r("button",{type:"button",class:"filter-btn is-action panel-toggle","aria-pressed":e,title:`${e?"Hide":"Show"} the navigator (⌘B)`,onClick:()=>Wl("rail"),children:r(js,{side:"left",shown:e})}),r("button",{type:"button",class:"filter-btn is-action panel-toggle","aria-pressed":t,title:`${t?"Hide":"Show"} the context column (⌥⌘B)`,onClick:()=>Wl("side"),children:r(js,{side:"right",shown:t})})]})}function cn(e){return e>=1024?`${(e/1024).toFixed(1)}G`:`${e}M`}function Au(e){return e==null?"–":e<10?`${e.toFixed(1)}%`:`${Math.round(e)}%`}function p1(e){var t;return e.server.mem_mb+(((t=e.webview)==null?void 0:t.mem_mb)||0)+e.panes.mem_mb}function m1(e){return e.filter(t=>t.res).map(t=>({w:t,...t.res})).sort((t,n)=>n.mem_mb-t.mem_mb)}function g1(e){return`${cn(e.ram_mb)} RAM · swap ${cn(e.swap_used_mb)}/${cn(e.swap_total_mb)} · ${e.mem_free_pct}% free · load ${e.load1}`}const y1="share of the whole machine's CPU: 100% is every core busy";function Ln({label:e,group:t,onClick:n}){const i=r(K,{children:[r("span",{class:"res-label",children:e}),r("span",{class:"res-mem",children:cn(t.mem_mb)}),r("span",{class:"res-cpu",title:y1,children:Au(t.cpu_pct)})]});return n?r("button",{type:"button",class:"res-line is-pane",onClick:n,children:i}):r("div",{class:"res-line",children:i})}function b1({r:e}){const t=te(null),n=te(null),[i,l]=B(!1),a=br(()=>{var o,u;const s=(o=t.current)==null?void 0:o.contains(document.activeElement);l(!1),s&&((u=n.current)==null||u.focus())},[]);return Fi(t,i,a),r("div",{class:"pill-dd",ref:t,children:[r("button",{type:"button",class:"res-pill",ref:n,title:"memory held by periscope's server, its webview and its panes — click for each one's memory and CPU","aria-haspopup":"dialog","aria-expanded":i?"true":"false",onClick:()=>l(!i),children:["▣ ",cn(p1(e))]}),r("div",{class:"tb-dd-menu res-menu",role:"dialog","aria-label":"resource usage",hidden:!i,children:[r(Ln,{label:"periscope server",group:e.server}),e.webview&&r(Ln,{label:"webview",group:e.webview}),r(Ln,{label:"all panes",group:e.panes}),r("div",{class:"res-pane-lines",children:m1(ce.value||[]).map(({w:s,mem_mb:o,cpu_pct:u})=>r(Ln,{label:_e(s),group:{mem_mb:o,cpu_pct:u},onClick:()=>{at(s),a()}},s.pid))}),r(Ln,{label:"elsewhere",group:e.elsewhere}),r("div",{class:"res-machine",children:g1(e.machine)})]})]})}function k1(){const e=Cc.value;return e&&r(b1,{r:e})}async function Mu(e){const t=Kn.value;Kn.value=e;const n=await ie("spawn account","/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({spawn_account:e})});return n||(Kn.value=t),!!n}function w1(){if(!$n())return null;const e=[{id:null,label:"auto"},...lt.value],t=Kn.value||null,n=sn.value;return r("div",{class:"spawn-acct",title:`which account new Claude panes launch on
+`;break}case-2:{s=t?" ":" ";break}case-1:{if(!t&&l)continue;s=" ";break}default:s=String.fromCharCode(a)}l=a===-2,i.push(s)}return i.join("")}function qp(e){const i={constructs:Uc([Bp,...(e||{}).extensions||[]]),content:l(rf),defined:[],document:l(af),flow:l(Sp),lazy:{},string:l(Tp),text:l(Ep)};return i;function l(a){return s;function s(o){return zp(i,a,o)}}}function Up(e){for(;!Jc(e););return e}const Os=/[\0\t\n\r]/g;function Wp(){let e=1,t="",n=!0,i;return l;function l(a,s,o){const c=[];let u,h,d,p,f;for(a=t+(typeof a=="string"?a.toString():new TextDecoder(s||void 0).decode(a)),d=0,t="",n&&(a.charCodeAt(0)===65279&&d++,n=void 0);d0){const Fe=Q.tokenStack[Q.tokenStack.length-1];(Fe[1]||Fs).call(Q,void 0,Fe[0])}for(F.position={start:dt(P.length>0?P[0][1].start:{line:1,column:1,offset:0}),end:dt(P.length>0?P[P.length-2][1].end:{line:1,column:1,offset:0})},ae=-1;++ae":""))+")"})}return p;function p(){let f=iu,m,k,x;if(a(c,u,h[h.length-1]||void 0)&&(f=am(n(c,h)),f[0]===Bs))return f;if("children"in c&&c.children){const b=c;if(b.children&&f[0]!==im)for(k=-1+s,x=h.concat(b);k>-1&&k0?{type:"text",value:v}:void 0),v===!1?p.lastIndex=y+1:(m!==y&&C.push({type:"text",value:u.value.slice(m,y)}),Array.isArray(v)?C.push(...v):v&&C.push(v),m=y+g[0].length,b=!0),!p.global)break;g=p.exec(u.value)}return b?(m?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],i=n.indexOf(")");const l=Ns(e,"(");let a=Ns(e,")");for(;i!==-1&&l>a;)e+=n.slice(0,i+1),n=n.slice(i+1),i=n.indexOf(")"),a++;return[e,n]}function lu(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||qt(n)||Hi(n))&&(!t||n!==47)}function xm(){this.buffer()}function _m(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Sm(){this.buffer()}function $m(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Cm(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=je(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Tm(e){this.exit(e)}function Em(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=je(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Pm(e){this.exit(e)}function Mm(){return{enter:{gfmFootnoteCallString:xm,gfmFootnoteCall:_m,gfmFootnoteDefinitionLabelString:Sm,gfmFootnoteDefinition:$m},exit:{gfmFootnoteCallString:Cm,gfmFootnoteCall:Tm,gfmFootnoteDefinitionLabelString:Em,gfmFootnoteDefinition:Pm}}}function Am(){return{canContainEols:["delete"],enter:{strikethrough:Lm},exit:{strikethrough:Im}}}function Lm(e){this.enter({type:"delete",children:[]},e)}function Im(e){this.exit(e)}function Om(){return{enter:{table:Dm,tableData:zs,tableHeader:zs,tableRow:Fm},exit:{codeText:Nm,table:Rm,tableData:pl,tableHeader:pl,tableRow:pl}}}function Dm(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function Rm(e){this.exit(e),this.data.inTable=void 0}function Fm(e){this.enter({type:"tableRow",children:[]},e)}function pl(e){this.exit(e)}function zs(e){this.enter({type:"tableCell",children:[]},e)}function Nm(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Bm));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Bm(e,t){return t==="|"?t:e}function zm(){return{exit:{taskListCheckValueChecked:js,taskListCheckValueUnchecked:js,paragraph:jm}}}function js(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function jm(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const i=n.children[0];if(i&&i.type==="text"){const l=t.children;let a=-1,s;for(;++a0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const Xm={tokenize:sg,partial:!0};function eg(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:ig,continuation:{tokenize:lg},exit:ag}},text:{91:{name:"gfmFootnoteCall",tokenize:rg},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:tg,resolveTo:ng}}}}function tg(e,t,n){const i=this;let l=i.events.length;const a=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let s;for(;l--;){const c=i.events[l][1];if(c.type==="labelImage"){s=c;break}if(c.type==="gfmFootnoteCall"||c.type==="labelLink"||c.type==="label"||c.type==="image"||c.type==="link")break}return o;function o(c){if(!s||!s._balanced)return n(c);const u=je(i.sliceSerialize({start:s.end,end:i.now()}));return u.codePointAt(0)!==94||!a.includes(u.slice(1))?n(c):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),t(c))}}function ng(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const i={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},l={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};l.end.column++,l.end.offset++,l.end._bufferIndex++;const a={type:"gfmFootnoteCallString",start:Object.assign({},l.end),end:Object.assign({},e[e.length-1][1].start)},s={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},o=[e[n+1],e[n+2],["enter",i,t],e[n+3],e[n+4],["enter",l,t],["exit",l,t],["enter",a,t],["enter",s,t],["exit",s,t],["exit",a,t],e[e.length-2],e[e.length-1],["exit",i,t]];return e.splice(n,e.length-n+1,...o),e}function rg(e,t,n){const i=this,l=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let a=0,s;return o;function o(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),c}function c(d){return d!==94?n(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(d){if(a>999||d===93&&!s||d===null||d===91||oe(d))return n(d);if(d===93){e.exit("chunkString");const p=e.exit("gfmFootnoteCallString");return l.includes(je(i.sliceSerialize(p)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return oe(d)||(s=!0),a++,e.consume(d),d===92?h:u}function h(d){return d===91||d===92||d===93?(e.consume(d),a++,u):u(d)}}function ig(e,t,n){const i=this,l=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let a,s=0,o;return c;function c(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",h):n(m)}function h(m){if(s>999||m===93&&!o||m===null||m===91||oe(m))return n(m);if(m===93){e.exit("chunkString");const k=e.exit("gfmFootnoteDefinitionLabelString");return a=je(i.sliceSerialize(k)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}return oe(m)||(o=!0),s++,e.consume(m),m===92?d:h}function d(m){return m===91||m===92||m===93?(e.consume(m),s++,h):h(m)}function p(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),l.includes(a)||l.push(a),re(e,f,"gfmFootnoteDefinitionWhitespace")):n(m)}function f(m){return t(m)}}function lg(e,t,n){return e.check(vr,t,e.attempt(Xm,t,n))}function ag(e){e.exit("gfmFootnoteDefinition")}function sg(e,t,n){const i=this;return re(e,l,"gfmFootnoteDefinitionIndent",5);function l(a){const s=i.events[i.events.length-1];return s&&s[1].type==="gfmFootnoteDefinitionIndent"&&s[2].sliceSerialize(s[1],!0).length===4?t(a):n(a)}}function og(e){let n={}.singleTilde;const i={name:"strikethrough",tokenize:a,resolveAll:l};return n==null&&(n=!0),{text:{126:i},insideSpan:{null:[i]},attentionMarkers:{null:[126]}};function l(s,o){let c=-1;for(;++c1?c(m):(s.consume(m),d++,f);if(d<2&&!n)return c(m);const x=s.exit("strikethroughSequenceTemporary"),b=pi(m);return x._open=!b||b===2&&!!k,x._close=!k||k===2&&!!b,o(m)}}}class cg{constructor(){this.map=[]}add(t,n,i){ug(this,t,n,i)}consume(t){if(this.map.sort(function(a,s){return a[0]-s[0]}),this.map.length===0)return;let n=this.map.length;const i=[];for(;n>0;)n-=1,i.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];i.push(t.slice()),t.length=0;let l=i.pop();for(;l;){for(const a of l)t.push(a);l=i.pop()}this.map.length=0}}function ug(e,t,n,i){let l=0;if(!(n===0&&i.length===0)){for(;l-1;){const I=i.events[L][1].type;if(I==="lineEnding"||I==="linePrefix")L--;else break}const O=L>-1?i.events[L][1].type:null,j=O==="tableHead"||O==="tableRow"?v:c;return j===v&&i.parser.lazy[i.now().line]?n(S):j(S)}function c(S){return e.enter("tableHead"),e.enter("tableRow"),u(S)}function u(S){return S===124||(s=!0,a+=1),h(S)}function h(S){return S===null?n(S):W(S)?a>1?(a=0,i.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(S),e.exit("lineEnding"),f):n(S):te(S)?re(e,h,"whitespace")(S):(a+=1,s&&(s=!1,l+=1),S===124?(e.enter("tableCellDivider"),e.consume(S),e.exit("tableCellDivider"),s=!0,h):(e.enter("data"),d(S)))}function d(S){return S===null||S===124||oe(S)?(e.exit("data"),h(S)):(e.consume(S),S===92?p:d)}function p(S){return S===92||S===124?(e.consume(S),d):d(S)}function f(S){return i.interrupt=!1,i.parser.lazy[i.now().line]?n(S):(e.enter("tableDelimiterRow"),s=!1,te(S)?re(e,m,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(S):m(S))}function m(S){return S===45||S===58?x(S):S===124?(s=!0,e.enter("tableCellDivider"),e.consume(S),e.exit("tableCellDivider"),k):$(S)}function k(S){return te(S)?re(e,x,"whitespace")(S):x(S)}function x(S){return S===58?(a+=1,s=!0,e.enter("tableDelimiterMarker"),e.consume(S),e.exit("tableDelimiterMarker"),b):S===45?(a+=1,b(S)):S===null||W(S)?y(S):$(S)}function b(S){return S===45?(e.enter("tableDelimiterFiller"),C(S)):$(S)}function C(S){return S===45?(e.consume(S),C):S===58?(s=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(S),e.exit("tableDelimiterMarker"),g):(e.exit("tableDelimiterFiller"),g(S))}function g(S){return te(S)?re(e,y,"whitespace")(S):y(S)}function y(S){return S===124?m(S):S===null||W(S)?!s||l!==a?$(S):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(S)):$(S)}function $(S){return n(S)}function v(S){return e.enter("tableRow"),E(S)}function E(S){return S===124?(e.enter("tableCellDivider"),e.consume(S),e.exit("tableCellDivider"),E):S===null||W(S)?(e.exit("tableRow"),t(S)):te(S)?re(e,E,"whitespace")(S):(e.enter("data"),M(S))}function M(S){return S===null||S===124||oe(S)?(e.exit("data"),E(S)):(e.consume(S),S===92?T:M)}function T(S){return S===92||S===124?(e.consume(S),M):M(S)}}function pg(e,t){let n=-1,i=!0,l=0,a=[0,0,0,0],s=[0,0,0,0],o=!1,c=0,u,h,d;const p=new cg;for(;++nn[2]+1){const m=n[2]+1,k=n[3]-n[2]-1;e.add(m,k,[])}}e.add(n[3]+1,0,[["exit",d,t]])}return l!==void 0&&(a.end=Object.assign({},nn(t.events,l)),e.add(l,0,[["exit",a,t]]),a=void 0),a}function Hs(e,t,n,i,l){const a=[],s=nn(t.events,n);l&&(l.end=Object.assign({},s),a.push(["exit",l,t])),i.end=Object.assign({},s),a.push(["exit",i,t]),e.add(n+1,0,a)}function nn(e,t){const n=e[t],i=n[0]==="enter"?"start":"end";return n[1][i]}const mg={name:"tasklistCheck",tokenize:yg};function gg(){return{text:{91:mg}}}function yg(e,t,n){const i=this;return l;function l(c){return i.previous!==null||!i._gfmTasklistFirstContentOfListItem?n(c):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),a)}function a(c){return oe(c)?(e.enter("taskListCheckValueUnchecked"),e.consume(c),e.exit("taskListCheckValueUnchecked"),s):c===88||c===120?(e.enter("taskListCheckValueChecked"),e.consume(c),e.exit("taskListCheckValueChecked"),s):n(c)}function s(c){return c===93?(e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),o):n(c)}function o(c){return W(c)?t(c):te(c)?e.check({tokenize:bg},t,n)(c):n(c)}}function bg(e,t,n){return re(e,i,"whitespace");function i(l){return l===null?n(l):t(l)}}function mu(e){return Uc([Um(),eg(),og(),hg(),gg()])}const kg={pr_title:"from the PR title",branch:"from the branch name"};function xr(e){if(e!=null&&e.linked_linear){const t=e.linked_linear,n=e.linked_linear_title?`: ${e.linked_linear_title}`:"",i=e.linked_linear_status?` [${e.linked_linear_status}]`:"";return{id:t,href:`https://linear.app/issue/${t}`,tip:`Linear ${t}${n}${i}`,note:null,derived:!1}}if(e!=null&&e.linear_ticket){const t=e.linear_ticket,n=kg[e.linear_ticket_source]||"derived";return{id:t,href:`https://linear.app/issue/${t}`,tip:`Linear ${t} (${n})`,note:n,derived:!0}}return null}const wg=/^([a-z-]+): (.+)$/;function Kl(e,t){if((e==null?void 0:e.type)!=="blockquote"||typeof t!="string")return null;const n=t.slice(e.position.start.offset,e.position.end.offset),i=[];for(const l of n.split(`
+`))for(const a of l.replace(/^\s*> ?/,"").split(" · ")){const s=wg.exec(a.trim());if(!s)return null;i.push([s[1],s[2].trim()])}return i.length?i:null}function gu(e){return e.split(",").map(t=>t.trim().replace(/^`+|`+$/g,""))}const vg=/^([\w.-]*[\w-]\/[\w./-]*[\w-]|[\w-]+(?:\.[\w-]+)*\.[A-Za-z][A-Za-z0-9]{1,5})(?::(\d+)(?:-(\d+))?)?$/;function Wi(e){const t=vg.exec(e);if(!t)return null;const n=t[1];if(!/[A-Za-z]/.test(n)||!n.includes("/")&&t[2]==null)return null;const i=n.split("/").pop();if(t[2]==null&&n.includes("/")&&!/\.[A-Za-z][A-Za-z0-9]{0,5}$/.test(i)&&!/^[\w.-]+\/[\w.-]+\//.test(n))return null;const l=t[2]!=null?Number(t[2]):null;return{path:n,start:l,end:t[3]!=null?Number(t[3]):l,raw:e}}function xg(e){const t=[];let n="";const i=/\S+/g;let l=0;for(let a=i.exec(e);a;a=i.exec(e)){const s=a[0],o=(s.match(/^[(["']+/)||[""])[0],c=s.slice(o.length).replace(/[.,;:)\]"']+$/,""),u=c?Wi(c):null;u?(n+=e.slice(l,a.index)+o,n&&t.push(n),n=s.slice(o.length+c.length),t.push(u)):n+=e.slice(l,a.index)+s,l=a.index+s.length}return n+=e.slice(l),n&&t.push(n),t}const _g=new Set(["new-subsystem","extension","reuse","system-touch","behavior"]);function Sg(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"stop"}function Kr(e){return e.type==="text"||e.type==="inlineCode"?e.value:(e.children||[]).map(Kr).join("")}function $g(e){var d,p,f;const t=String(e||""),i=nu(t,{extensions:[mu()],mdastExtensions:[au()]}).children;let l="",a=null,s="",o="";const c=[],u=new Map;let h=0;if(((d=i[h])==null?void 0:d.type)==="heading"&&i[h].depth===1){l=Kr(i[h]),h++;const m=((p=i[h])==null?void 0:p.type)==="blockquote"?Kl(i[h],t):null;if(m){const k=Object.fromEntries(m);k.branch&&k.head&&(a={branch:k.branch,head:k.head,pr:/^\d+$/.test(k.pr||"")?Number(k.pr):null,repo:k.repo??null}),h++}((f=i[h])==null?void 0:f.type)==="paragraph"&&(s=Kr(i[h]),o=t.slice(i[h].position.start.offset,i[h].position.end.offset),h++)}for(;h>>0).toString(16).padStart(8,"0")}function Ma(e,t){return!!t&&t[e.title]===yu(e)}function bu(e,t,n){const i={...e};return n==null?delete i[t]:i[t]=n,i}function Cg({post:e,show:t,fail:n}){const i=new Map,l=new Map;let a={},s=0;const o={pending:0,settled:0,seed(c){a={...c}},toggle(c,u,h){const d=++s;l.set(c,d),t(c,h?u:null),n(c,null),o.pending++;const p=(i.get(c)||Promise.resolve()).then(async()=>{try{await e(c,u,h),a=bu(a,c,h?u:null),l.get(c)===d&&n(c,null)}catch(f){n(c,`not saved: ${(f==null?void 0:f.message)||f}`)}finally{o.pending--,o.settled++,l.get(c)===d&&t(c,a[c]??null)}});return i.set(c,p),p}};return o}function Tg(e,t){return!e.pending&&e.settled===t}function Eg(e){const t=(e.lines||[]).filter(n=>n.kind==="ctx"||n.kind==="add").length;return e.new_start+Math.max(t,1)-1}const ku=(e,t)=>e.new_start<=t.end&&Eg(e)>=t.start;function Pg(e,t){const n=new Map((t||[]).map(i=>[i.path,i]));return e.map(i=>{const l=n.get(i.path)||null;if(!l)return{ref:i,file:null,hunks:[],generated:!1};const a=i.start==null?l.hunks:l.hunks.filter(s=>ku(s,i));return{ref:i,file:l.path,hunks:a,generated:!!l.generated}})}const qs=e=>e.slice(e.lastIndexOf("/")+1);function Mg(e,t){const n={missing:[],generated:[],unchanged:[],noText:[]};if(t==null)return{shown:e.map(l=>({ref:l,name:qs(l.path),hunks:[]})),hidden:n,noDiff:!0};const i=[];for(const l of Pg(e,t))l.file?l.generated?n.generated.push(l.ref):l.hunks.length?i.push({ref:l.ref,name:qs(l.ref.path),hunks:l.hunks}):n[l.ref.start==null?"noText":"unchanged"].push(l.ref):n.missing.push(l.ref);return{shown:i,hidden:n,noDiff:!1}}const Vl={missing:"not in this diff",generated:"generated",unchanged:"unchanged at the cited lines",noText:"no text changes"};function Ag(e){return Object.keys(Vl).filter(t=>{var n;return(n=e[t])==null?void 0:n.length}).map(t=>`${e[t].length} ${Vl[t]}`).join(" · ")}function Lg(e,t){const n=l=>t.start!=null&&l.hunks.some(a=>ku(a,t)),i=e.findIndex(l=>l.ref.path===t.path&&n(l));return i>=0?i:e.findIndex(l=>l.ref.path===t.path)}const Ig=300,Og=e=>e.reduce((t,n)=>{var i;return t+(((i=n.lines)==null?void 0:i.length)||0)},0);function Dg(e){if(!e.length)return"";const t=e.filter(n=>!n.resolved).length;return`${e.length} comment${e.length===1?"":"s"}${t?` · ${t} open`:""}`}const mi=e=>{var t;return((t=e.pr)==null?void 0:t.state)==="merged"};function Us(e){if(mi(e))return 99;const t=e.owner?0:e.worktree?10:20;return e.unresolved>0?t:e.role==="review-requested"?t+1:e.pr&&!e.walkthrough?t+2:e.role==="local"?t+4:t+3}const Ki={branch:{label:"branch",what:"branch name",first:"asc",value:e=>e.branch},pr:{label:"PR",what:"PR number",first:"desc",value:e=>{var t;return((t=e.pr)==null?void 0:t.number)??null}},walkthrough:{label:"walkthrough",what:"staleness",first:"desc",value:e=>{var t;return((t=e.walkthrough)==null?void 0:t.stale_by)??null}},comments:{label:"comments",what:"open comments",first:"desc",value:e=>e.unresolved||null},who:{label:"who",what:"owner",first:"asc",value:e=>{var t,n;return((t=e.owner)==null?void 0:t.name)||((n=e.pr)==null?void 0:n.author)||null}}};function Rg(e){if(!e.walkthrough)return null;const t=e.walkthrough.stale_by;return t>0?`stale ${t}`:t===0?"current":e.worktree?"stale: unknown":"no worktree"}const Fg=(e,t)=>typeof e=="string"?e.localeCompare(t):e-t;function Ng(e,t=null){const n=[...e||[]].sort((a,s)=>{var o,c;return Us(a)-Us(s)||(((o=s.pr)==null?void 0:o.number)||0)-(((c=a.pr)==null?void 0:c.number)||0)||a.branch.localeCompare(s.branch)}),i=t&&Ki[t.key];if(!i)return n;const l=t.dir==="asc"?1:-1;return n.sort((a,s)=>{const o=i.value(a),c=i.value(s);return mi(a)-mi(s)||(o===null)-(c===null)||(o===null?0:l*Fg(o,c))})}function Bg(e,t){const n=Ki[t].first;return(e==null?void 0:e.key)!==t?{key:t,dir:n}:e.dir===n?{key:t,dir:n==="asc"?"desc":"asc"}:null}function zg(e,t){const n=(t||"").toLowerCase().split(/\s+/).filter(Boolean);return n.length?(e||[]).filter(i=>{var a,s,o,c;const l=[i.branch,i.repo,i.pr?`#${i.pr.number}`:null,(a=i.pr)==null?void 0:a.title,(s=i.pr)==null?void 0:s.author,(o=i.owner)==null?void 0:o.name,(c=xr(i))==null?void 0:c.id,i.linked_linear_title].filter(Boolean).join(" ").toLowerCase();return n.every(u=>l.includes(u))}):e||[]}function Ws(e){return(e||[]).filter(t=>!mi(t)).reduce((t,n)=>t+(n.unresolved||0),0)}const jg={scope:{name:"Scope",root:[{r:[11,1,2,6],a:{fill:"#2a86b3"}},{r:[11,1,5,2],a:{fill:"#2a86b3"}},{g:[{r:[16,1,1,2],a:{fill:"#ffd166"}}],anim:"crit-scope-1"},{r:[1,9,2,4],a:{fill:"#2a86b3"}},{r:[4,6,12,1],a:{fill:"#40b8ee"}},{r:[3,7,14,8],a:{fill:"#40b8ee"}},{r:[4,15,12,1],a:{fill:"#2a86b3"}},{r:[5,7,3,1],a:{fill:"#7fd0f5"}},{g:[{r:[6,9,2,2],a:{fill:"#0f1215"}}],anim:"crit-scope-2",role:"eye",shut:[6,10,2,.4]},{g:[{r:[12,9,2,2],a:{fill:"#0f1215"}}],anim:"crit-scope-3",role:"eye",shut:[12,10,2,.4]},{g:[{r:[6,9,.7,.7]},{r:[12,9,.7,.7]}],a:{fill:"#f3f5f8"},mood:"calm",role:"glint"},{g:[{r:[5.5,7.9,3,.7]},{r:[11.5,7.9,3,.7]},{r:[8.5,12.2,3,.7]}],a:{fill:"#16384a"},mood:"grumpy"},{g:[{r:[5.4,7.5,1.6,.7]},{r:[7,8.1,1.6,.7]},{r:[11.4,8.1,1.6,.7]},{r:[13,7.5,1.6,.7]},{r:[8.5,11.7,3,1.6]}],a:{fill:"#16384a"},mood:"furious"},{g:[{r:[8.4,11.6,.7,.7],a:{fill:"#16384a"}},{r:[9,12.2,2,.7],a:{fill:"#16384a"}},{r:[10.9,11.6,.7,.7],a:{fill:"#16384a"}},{r:[4.4,11.6,1.5,.8],a:{fill:"#f58967",opacity:"0.7"}},{r:[14.1,11.6,1.5,.8],a:{fill:"#f58967",opacity:"0.7"}}],mood:"calm"},{g:[{r:[5,16,2,2],a:{fill:"#2a86b3"}},{r:[13,16,2,2],a:{fill:"#2a86b3"}}],legs:!0},{g:[{g:[{r:[3,3,1,1]}],anim:"crit-scope-4"},{g:[{r:[6,2,1,1]}],anim:"crit-scope-5"}],a:{fill:"#8f9397"},mood:"furious"}],anchors:{eyes:[{x:6,y:9,w:2,h:2,role:"eye"},{x:12,y:9,w:2,h:2,role:"eye"}],head:{top:1,right:17},hat:{cx:10,top:6,w:12},neck:{y:13,x0:3,x1:17}},ink:"#0f1215",limb:{style:"arm",root:[17,10.6],width:1.2,color:"#2a86b3"}},faradaysie:{name:"Faradaysie",root:[{g:[{r:[12,0,1,1]},{r:[11,1,3,1]},{r:[10,2,5,1]},{r:[12,3,1,2]}],a:{fill:"#f72f96"}},{g:[{g:[{r:[7,0,1,2]}],anim:"crit-faradaysie-1"},{g:[{r:[5,2,5,1]}],anim:"crit-faradaysie-2"},{g:[{r:[6,3,3,1]}],anim:"crit-faradaysie-3"},{g:[{r:[7,4,1,1]}],anim:"crit-faradaysie-4"}],a:{fill:"#e4baff"}},{g:[{r:[7,5,6,1]},{r:[5,6,10,1]},{r:[4,7,12,7]},{r:[5,14,10,1]}],a:{fill:"#b641ff"}},{r:[6,15,8,1],a:{fill:"#6d1ba0"}},{r:[6,6,3,1],a:{fill:"#e4baff"}},{r:[5,7,1,2],a:{fill:"#e4baff"}},{r:[7,11.5,6,2.5],a:{fill:"#fcb0d7"}},{g:[{r:[3,9,1,2]},{g:[{r:[16,9,1,2]}],anim:"crit-faradaysie-5"}],arms:!0,a:{fill:"#6d1ba0"}},{g:[{r:[6,16,2,1]},{r:[12,16,2,1]}],legs:!0,a:{fill:"#6d1ba0"}},{g:[{r:[6,8,2,2],a:{fill:"#240835"}}],anim:"crit-faradaysie-6",role:"eye",shut:[6,9,2,.4]},{g:[{r:[12,8,2,2],a:{fill:"#240835"}}],anim:"crit-faradaysie-7",role:"eye",shut:[12,9,2,.4]},{g:[{r:[6,8,.7,.7]},{r:[12,8,.7,.7]}],a:{fill:"#fdfaff"},mood:"calm",role:"glint"},{g:[{r:[8.4,10.6,.7,.7],a:{fill:"#240835"}},{r:[9,11.2,2,.7],a:{fill:"#240835"}},{r:[10.9,10.6,.7,.7],a:{fill:"#240835"}},{r:[4.4,10.4,1.5,.8],a:{fill:"#f72f96",opacity:"0.75"}},{r:[14.1,10.4,1.5,.8],a:{fill:"#f72f96",opacity:"0.75"}}],mood:"calm"},{g:[{r:[5.5,6.9,3,.7]},{r:[11.5,6.9,3,.7]},{r:[8.5,11,3,.7]}],a:{fill:"#240835"},mood:"grumpy"},{g:[{r:[5.4,6.5,1.6,.7]},{r:[7,7.1,1.6,.7]},{r:[11.4,7.1,1.6,.7]},{r:[13,6.5,1.6,.7]},{r:[8.5,10.5,3,1.6]}],a:{fill:"#240835"},mood:"furious"},{g:[{g:[{r:[2,4,1,2]}],anim:"crit-faradaysie-8"},{g:[{r:[17,3,1,2]}],anim:"crit-faradaysie-9"},{g:[{r:[1,12,1,1]}],anim:"crit-faradaysie-10"},{g:[{r:[18,13,1,1]}],anim:"crit-faradaysie-11"}],a:{fill:"#f72f96"},mood:"furious"}],anchors:{eyes:[{x:6,y:8,w:2,h:2,role:"eye"},{x:12,y:8,w:2,h:2,role:"eye"}],head:{top:0,right:17},hat:{cx:10,top:6,w:10},neck:{y:12.8,x0:4,x1:16}},ink:"#240835",limb:{style:"arm",root:[16.4,9.4],width:1.2,color:"#6d1ba0"}},jelly:{name:"Jelly",root:[{r:[7,3,6,1],a:{fill:"#ab93ed"}},{r:[5,4,10,1],a:{fill:"#ab93ed"}},{r:[4,5,12,6],a:{fill:"#ab93ed"}},{r:[4,11,12,1],a:{fill:"#7d62c9"}},{g:[{r:[4,12,2,1]},{r:[7.3,12,2,1]},{r:[10.7,12,2,1]},{r:[14,12,2,1]}],a:{fill:"#7d62c9"}},{g:[{r:[7,4,3,1]},{r:[5,5,1,2]},{r:[13,5,1,1]},{r:[14,7,1,1]}],a:{fill:"#d4c6fa"}},{g:[{r:[6,13,1,2]},{r:[5,15,1,2]},{r:[6,17,1,1]},{r:[9.5,13,1,2]},{r:[10.5,15,1,2]},{r:[9.5,17,1,1]},{r:[13,13,1,2]},{r:[14,15,1,2]},{r:[13,17,1,1]}],legs:!0,keepSeated:!0,a:{fill:"#7d62c9"},anim:"crit-jelly-1"},{g:[{r:[7,7,2,2],a:{fill:"#2a1f45"}}],anim:"crit-jelly-2",role:"eye",shut:[7,8,2,.4]},{g:[{r:[11,7,2,2],a:{fill:"#2a1f45"}}],anim:"crit-jelly-3",role:"eye",shut:[11,8,2,.4]},{g:[{r:[7,7,.7,.7]},{r:[11,7,.7,.7]}],a:{fill:"#f3f5f8"},mood:"calm",role:"glint"},{g:[{r:[8.4,9.6,.7,.7],a:{fill:"#2a1f45"}},{r:[9,10.2,2,.7],a:{fill:"#2a1f45"}},{r:[10.9,9.6,.7,.7],a:{fill:"#2a1f45"}},{r:[5,9.2,1.5,.8],a:{fill:"#f2a7c3"}},{r:[13.5,9.2,1.5,.8],a:{fill:"#f2a7c3"}}],mood:"calm"},{g:[{r:[6.5,5.9,3,.7]},{r:[10.5,5.9,3,.7]},{r:[8.5,10,3,.7]}],a:{fill:"#2a1f45"},mood:"grumpy"},{g:[{r:[6.4,5.5,1.6,.7]},{r:[8,6.1,1.6,.7]},{r:[10.4,6.1,1.6,.7]},{r:[12,5.5,1.6,.7]},{r:[8.5,9.5,3,1.4]}],a:{fill:"#2a1f45"},mood:"furious"},{g:[{g:[{r:[2,4,1,1]}],anim:"crit-jelly-4"},{g:[{r:[17,6,1,1]}],anim:"crit-jelly-5"}],a:{fill:"#f3e9c6"},mood:"furious"}],anchors:{eyes:[{x:7,y:7,w:2,h:2,role:"eye"},{x:11,y:7,w:2,h:2,role:"eye"}],head:{top:3,right:16},hat:{cx:10,top:3,w:8},neck:{y:10.5,x0:4,x1:16}},ink:"#2a1f45",limb:{style:"tentacle",root:[16,10.2],width:1,color:"#7d62c9"}},nox:{name:"Nox",root:[{g:[{g:[{r:[15,16,3,1]},{r:[17,12,1,4]},{r:[16,11,1,1]}],a:{fill:"#1a1c20",stroke:"#4a4f57","stroke-width":"1"}},{g:[{r:[15,16,3,1]},{r:[17,12,1,4]},{r:[16,11,1,1]}],a:{fill:"#1a1c20"}}],rest:!0,anim:"crit-nox-1"},{g:[{r:[5,3,1,2]},{r:[6,4,1,1]},{r:[14,3,1,2]},{r:[13,4,1,1]},{r:[5,5,10,1]},{r:[4,6,12,5]},{r:[5,11,10,1]},{r:[6,12,8,1]},{r:[5,13,10,5]}],a:{fill:"#1a1c20",stroke:"#4a4f57","stroke-width":"1"}},{g:[{r:[5,3,1,2]},{r:[6,4,1,1]},{r:[14,3,1,2]},{r:[13,4,1,1]},{r:[5,5,10,1]},{r:[4,6,12,5]},{r:[5,11,10,1]},{r:[6,12,8,1]},{r:[5,13,10,5]}],a:{fill:"#1a1c20"}},{g:[{r:[5.2,4.2,.6,.7]},{r:[14.2,4.2,.6,.7]}],a:{fill:"#f2a7c3",opacity:"0.8"}},{r:[6,5,3,1],a:{fill:"#2c3036"}},{g:[{r:[6,17,2,1]},{r:[12,17,2,1]}],legs:!0,keepSeated:!0,a:{fill:"#3a3f46"}},{g:[{r:[1.8,8.8,2.2,.4]},{r:[1.8,10,2.2,.4]},{r:[16,8.8,2.2,.4]},{r:[16,10,2.2,.4]}],a:{fill:"#5c626b"}},{r:[6,6,3,3],a:{fill:"#c6e05a"}},{r:[11,6,3,3],a:{fill:"#c6e05a"}},{g:[{g:[{r:[7,6.5,1.4,2]}],anim:"crit-nox-2"},{g:[{r:[12,6.5,1.4,2]}],anim:"crit-nox-3"}],a:{fill:"#0b0c0e"}},{g:[{r:[6.3,6.3,.7,.7]},{r:[11.3,6.3,.7,.7]}],a:{fill:"#f3f5f8"},mood:"calm"},{g:[{g:[{r:[6,6,3,3]}],anim:"crit-nox-4",role:"lid",shut:[6,6,3,3]},{g:[{r:[11,6,3,3]}],anim:"crit-nox-5",role:"lid",shut:[11,6,3,3]}],a:{fill:"#1a1c20"}},{r:[9.5,9,1,.7],a:{fill:"#f2a7c3"}},{g:[{r:[9,9.9,.5,.5]},{r:[9.4,10.3,.6,.4]},{r:[10,10.3,.6,.4]},{r:[10.5,9.9,.5,.5]}],a:{fill:"#8f9397"},mood:"calm"},{g:[{r:[6,6,3,1.3],a:{fill:"#1a1c20"}},{r:[11,6,3,1.3],a:{fill:"#1a1c20"}},{r:[8.8,10.2,2.4,.5],a:{fill:"#8f9397"}}],mood:"grumpy"},{g:[{r:[8,6,1,1],a:{fill:"#1a1c20"}},{r:[11,6,1,1],a:{fill:"#1a1c20"}},{r:[8.8,9.8,2.4,1.3],a:{fill:"#f2a7c3"}},{r:[9,9.8,.5,.6],a:{fill:"#f3f5f8"}},{r:[10.5,9.8,.5,.6],a:{fill:"#f3f5f8"}},{g:[{g:[{r:[7.5,3.6,1,1.2]}],anim:"crit-nox-6"},{g:[{r:[9.5,3.2,1,1.6]}],anim:"crit-nox-7"},{g:[{r:[11.5,3.6,1,1.2]}],anim:"crit-nox-8"}],a:{fill:"#5c626b"}}],mood:"furious"}],anchors:{eyes:[{x:6,y:6,w:3,h:3,role:"lid"},{x:11,y:6,w:3,h:3,role:"lid"}],head:{top:3,right:18.2},hat:{cx:10,top:5,w:9},neck:{y:12,x0:6,x1:14}},ink:"#c6e05a",faces:{worried:[{g:[{r:[5.8,5.9,1.4,.6]},{r:[7.2,5.4,1.6,.6]},{r:[11.2,5.4,1.6,.6]},{r:[12.8,5.9,1.4,.6]}],a:{fill:"#d5d8dc"}}]},limb:{style:"tail",root:[15.2,16],width:1,color:"#1a1c20",outline:"#4a4f57"}},ember:{name:"Ember",root:[{g:[{r:[4,2,1,2]},{r:[5,3,1,2]},{r:[15,2,1,2]},{r:[14,3,1,2]}],a:{fill:"#ffd9a0"}},{r:[6,4,8,1],a:{fill:"#e8574f"}},{r:[5,5,10,1],a:{fill:"#e8574f"}},{r:[4,6,12,8],a:{fill:"#e8574f"}},{r:[5,14,10,1],a:{fill:"#e8574f"}},{r:[6,15,8,1],a:{fill:"#b8403a"}},{r:[8,11,4,3],a:{fill:"#ff9a8f"}},{r:[6,5,2,1],a:{fill:"#ff9a8f"}},{g:[{r:[3,9,1,2]},{r:[16,9,1,2]}],arms:!0,a:{fill:"#b8403a"}},{g:[{r:[6,16,2,1]},{r:[12,16,2,1]}],legs:!0,a:{fill:"#b8403a"}},{g:[{r:[16,13,1,1]},{r:[17,12,1,1]},{r:[18,10,1,2]},{r:[17,9,1,1]},{r:[19,9,1,1]},{r:[18,8,1,1]}],rest:!0,a:{fill:"#b8403a"},anim:"crit-ember-1"},{g:[{r:[7,7,2,2],a:{fill:"#3a1312"}}],anim:"crit-ember-2",role:"eye",shut:[7,8,2,.4]},{g:[{r:[11,7,2,2],a:{fill:"#3a1312"}}],anim:"crit-ember-3",role:"eye",shut:[11,8,2,.4]},{g:[{r:[7,7,.7,.7]},{r:[11,7,.7,.7]}],a:{fill:"#f3f5f8"},mood:"calm",role:"glint"},{g:[{r:[8.4,9.6,.7,.7],a:{fill:"#3a1312"}},{r:[9,10.2,2,.7],a:{fill:"#3a1312"}},{r:[10.9,9.6,.7,.7],a:{fill:"#3a1312"}},{r:[10.2,10.9,.7,.7],a:{fill:"#ffd9a0"}}],mood:"calm"},{g:[{r:[6.5,5.9,3,.7]},{r:[10.5,5.9,3,.7]},{r:[8.5,10,3,.7]}],a:{fill:"#3a1312"},mood:"grumpy"},{g:[{r:[6.4,5.6,1.6,.7]},{r:[8,6.2,1.6,.7]},{r:[10.4,6.2,1.6,.7]},{r:[12,5.6,1.6,.7]},{r:[8.5,9.5,3,1.5]}],a:{fill:"#3a1312"},mood:"furious"},{g:[{g:[{r:[9,1,2,2],a:{fill:"#ffd166"}}],anim:"crit-ember-4"},{r:[9.5,0,1,1],a:{fill:"#f58967"}}],mood:"furious"}],anchors:{eyes:[{x:7,y:7,w:2,h:2,role:"eye"},{x:11,y:7,w:2,h:2,role:"eye"}],head:{top:2,right:20},hat:{cx:10,top:5,w:10},neck:{y:13.4,x0:4,x1:16}},ink:"#3a1312",limb:{style:"tail",root:[16,13.4],width:1,color:"#b8403a",spade:!0}},volt:{name:"Volt",root:[{g:[{r:[9,4,1,2]},{r:[10,3,1,1]},{r:[9,2,1,1]},{r:[10,1,1,1]}],a:{fill:"#d1a92b"}},{g:[{r:[10,0,1,1],a:{fill:"#fff1a8"}}],anim:"crit-volt-1"},{r:[5,6,10,1],a:{fill:"#f5d547"}},{r:[3,7,14,7],a:{fill:"#f5d547"}},{r:[4,14,12,1],a:{fill:"#d1a92b"}},{r:[6,7,3,1],a:{fill:"#fff1a8"}},{g:[{r:[10,12,1,1]},{r:[9,13,1,1]}],a:{fill:"#fff1a8"}},{g:[{r:[2,9,1,2]},{r:[17,9,1,2]}],arms:!0,a:{fill:"#d1a92b"},anim:"crit-volt-2"},{g:[{r:[5,15,3,1]},{r:[12,15,3,1]}],legs:!0,a:{fill:"#d1a92b"}},{g:[{r:[6,8,2,2],a:{fill:"#3a2f10"}}],anim:"crit-volt-3",role:"eye",shut:[6,9,2,.4]},{g:[{r:[12,8,2,2],a:{fill:"#3a2f10"}}],anim:"crit-volt-4",role:"eye",shut:[12,9,2,.4]},{g:[{r:[6,8,.7,.7]},{r:[12,8,.7,.7]}],a:{fill:"#f3f5f8"},mood:"calm",role:"glint"},{g:[{r:[8.4,10.2,.7,.7],a:{fill:"#3a2f10"}},{r:[9,10.8,2,.7],a:{fill:"#3a2f10"}},{r:[10.9,10.2,.7,.7],a:{fill:"#3a2f10"}},{r:[4.2,10.2,1.5,.8],a:{fill:"#f58967",opacity:"0.7"}},{r:[14.3,10.2,1.5,.8],a:{fill:"#f58967",opacity:"0.7"}}],mood:"calm"},{g:[{r:[5.5,6.9,3,.7]},{r:[11.5,6.9,3,.7]},{r:[8.5,10.6,3,.7]}],a:{fill:"#3a2f10"},mood:"grumpy"},{g:[{r:[5.4,6.5,1.6,.7]},{r:[7,7.1,1.6,.7]},{r:[11.4,7.1,1.6,.7]},{r:[13,6.5,1.6,.7]},{r:[8.5,10,3,1.6]}],a:{fill:"#3a2f10"},mood:"furious"},{g:[{g:[{r:[1,3,1,2]}],anim:"crit-volt-5"},{g:[{r:[18,4,1,2]}],anim:"crit-volt-6"}],a:{fill:"#fff1a8"},mood:"furious"}],anchors:{eyes:[{x:6,y:8,w:2,h:2,role:"eye"},{x:12,y:8,w:2,h:2,role:"eye"}],head:{top:0,right:18},hat:{cx:10,top:6,w:10},neck:{y:12.4,x0:3,x1:17}},ink:"#3a2f10",limb:{style:"arm",root:[17.4,9.4],width:1.2,color:"#d1a92b"}},moss:{name:"Moss",root:[{g:[{r:[7,3,2,1]},{r:[9.5,2,1.5,2]},{r:[11.5,3,2,1]}],a:{fill:"#2e9a56"},anim:"crit-moss-1"},{r:[7,4,6,1],a:{fill:"#47cf79"}},{r:[6,5,8,1],a:{fill:"#47cf79"}},{r:[5,6,10,9],a:{fill:"#47cf79"}},{r:[6,15,8,1],a:{fill:"#2e9a56"}},{g:[{r:[6,6,1,1]},{r:[12,5,1,1]},{r:[13,12,1,1]},{r:[6,13,1,1]}],a:{fill:"#9ae8b6"}},{g:[{r:[4,10,1,3],a:{fill:"#2e9a56"}},{g:[{r:[15,10,1,3],a:{fill:"#2e9a56"}}],anim:"crit-moss-2"}],arms:!0},{g:[{r:[6,16,2,1]},{r:[12,16,2,1]}],legs:!0,a:{fill:"#2e9a56"}},{r:[8,7,4,3],a:{fill:"#f3f5f8"}},{g:[{r:[9,7.5,2,2],a:{fill:"#0f2e1b"}}],anim:"crit-moss-3"},{g:[{r:[8,7,4,3],a:{fill:"#47cf79"}}],anim:"crit-moss-4",role:"lid",shut:[8,7,4,3]},{g:[{r:[8.4,11.4,.7,.7],a:{fill:"#0f2e1b"}},{r:[9,12,2,.7],a:{fill:"#0f2e1b"}},{r:[10.9,11.4,.7,.7],a:{fill:"#0f2e1b"}},{r:[6,11,1.3,.7],a:{fill:"#f2a7c3"}},{r:[12.7,11,1.3,.7],a:{fill:"#f2a7c3"}}],mood:"calm"},{g:[{r:[8,7,4,1.3],a:{fill:"#2e9a56"}},{r:[8.5,12,3,.7],a:{fill:"#0f2e1b"}}],mood:"grumpy"},{g:[{r:[7.6,5.6,1.6,.7]},{r:[9.2,6.2,1.6,.7]},{r:[10.8,5.6,1.6,.7]},{r:[8.5,11.4,3,1.6]}],a:{fill:"#0f2e1b"},mood:"furious"}],anchors:{eyes:[{x:8,y:7,w:4,h:3,role:"lid"}],head:{top:2,right:16},hat:{cx:10,top:4,w:7},neck:{y:12.4,x0:5,x1:15}},ink:"#0f2e1b",limb:{style:"arm",root:[15.6,10.6],width:1.1,color:"#2e9a56"}},octocat:{name:"Octocat",root:[{g:[{g:[{r:[4,14,1,2]},{r:[3,16,2,1]},{r:[7,14,1,3]},{r:[6,17,2,1]},{r:[12,14,1,3]},{r:[12,17,2,1]},{r:[15,14,1,2]},{r:[15,16,2,1]}],a:{fill:"#24292f",stroke:"#6e7781","stroke-width":"1"}},{g:[{r:[4,14,1,2]},{r:[3,16,2,1]},{r:[7,14,1,3]},{r:[6,17,2,1]},{r:[12,14,1,3]},{r:[12,17,2,1]},{r:[15,14,1,2]},{r:[15,16,2,1]}],a:{fill:"#24292f"}}],legs:!0,anim:"crit-octocat-1"},{g:[{r:[4,2,1,2]},{r:[5,3,1,1]},{r:[15,2,1,2]},{r:[14,3,1,1]},{r:[4,4,12,1]},{r:[3,5,14,7]},{r:[4,12,12,2]}],a:{fill:"#24292f",stroke:"#6e7781","stroke-width":"1"}},{g:[{r:[4,2,1,2]},{r:[5,3,1,1]},{r:[15,2,1,2]},{r:[14,3,1,1]},{r:[4,4,12,1]},{r:[3,5,14,7]},{r:[4,12,12,2]}],a:{fill:"#24292f"}},{g:[{r:[6,6,8,1]},{r:[5,7,10,4]},{r:[6,11,8,1]}],a:{fill:"#f4c7ad"}},{g:[{r:[7,8,2,2],a:{fill:"#2b1d16"}}],anim:"crit-octocat-2",role:"eye",shut:[7,9,2,.4]},{g:[{r:[11,8,2,2],a:{fill:"#2b1d16"}}],anim:"crit-octocat-3",role:"eye",shut:[11,9,2,.4]},{g:[{r:[7,8,.7,.7]},{r:[11,8,.7,.7]}],a:{fill:"#f3f5f8"},mood:"calm",role:"glint"},{g:[{r:[9,10.4,2,.6],a:{fill:"#2b1d16"}},{r:[5.4,10,1.2,.6],a:{fill:"#e8909c"}},{r:[13.4,10,1.2,.6],a:{fill:"#e8909c"}}],mood:"calm"},{g:[{r:[6.5,6.8,3,.6]},{r:[10.5,6.8,3,.6]},{r:[8.5,10.6,3,.6]}],a:{fill:"#2b1d16"},mood:"grumpy"},{g:[{r:[6.4,6.4,1.6,.6]},{r:[8,7,1.6,.6]},{r:[10.4,7,1.6,.6]},{r:[12,6.4,1.6,.6]},{r:[8.5,10.2,3,1.2]}],a:{fill:"#2b1d16"},mood:"furious"},{g:[{g:[{r:[1,4,1,1]}],anim:"crit-octocat-4"},{g:[{r:[18,5,1,1]}],anim:"crit-octocat-5"}],a:{fill:"#f3e9c6"},mood:"furious"}],anchors:{eyes:[{x:7,y:8,w:2,h:2,role:"eye"},{x:11,y:8,w:2,h:2,role:"eye"}],head:{top:2,right:17},hat:{cx:10,top:4,w:12},neck:{y:11.6,x0:4,x1:16}},ink:"#2b1d16",limb:{style:"tentacle",root:[16.6,12.4],width:1,color:"#24292f"}}},gi=[{id:"clawd",name:"Clawd",sprite:null},...Object.entries(jg).map(([e,t])=>({id:e,name:t.name,sprite:t}))];function wu(e){return gi.find(t=>t.id===e)||gi[0]}const vu=10,Aa=12,Hg=19,qg=17,B=e=>Math.round(e*1e4)/1e4;function xn(e,{seated:t=!1}={}){let n=1/0,i=1/0,l=-1/0,a=-1/0;const s=o=>{if(!o.mood&&!(t&&o.legs&&!o.keepSeated)){if(o.r){const[c,u,h,d]=o.r;n=Math.min(n,c),i=Math.min(i,u),l=Math.max(l,c+h),a=Math.max(a,u+d);return}o.g.forEach(s)}};return e.root.forEach(s),{x:n,y:i,w:l-n,h:a-i}}function La(e,{x0:t,sitting:n,height:i=Aa}){const l=xn(e),a=i/l.h,s=n?(({y:c,h:u})=>c+u)(xn(e,{seated:!0})):l.y+l.h,o=(n?qg:Hg)-a*s;return{scale:a,tx:B(t+8.5-a*(l.x+l.w/2)),ty:B(o),top:B(o+a*l.y),drop:n?B(a*(l.y+l.h-s)):0}}const Ug=.75,ml=(e,t=Ug)=>({fill:"none",stroke:e,"stroke-width":t,"stroke-linecap":"square"});function Wg(e){const t=xn(e),n=t.x+t.w/2,i=l=>l.r?{...l,r:[B(l.r[0]+(l.r[0]+l.r[2]/2l.legs?[{g:[l],cls:"tama-legs-a"},{g:[i(l)],cls:"tama-legs-b"}]:[l])}const Kg=new Set(["happy","x","down"]);function Vg(e){if(e.length===1){const{x:n,y:i,w:l}=e[0];return[{p:`M${B(n-.3)} ${B(i-.7)} l${B(l/2+.3)} -0.8 l${B(l/2+.3)} 0.8`}]}const t=e.reduce((n,i)=>n+i.x+i.w/2,0)/e.length;return e.map(({x:n,y:i,w:l})=>n+l/2({p:`M${o} ${B(c+.75*h)} l${B(u/2)} ${B(-h/2)} l${B(u/2)} ${B(h/2)}`}))}]:t==="x"?[{a:ml(l),g:n.map(({x:o,y:c,w:u,h})=>({p:`M${B(o+.1)} ${B(c+.1)} L${B(o+u-.1)} ${B(c+h-.1)} M${B(o+u-.1)} ${B(c+.1)} L${B(o+.1)} ${B(c+h-.1)}`}))}]:t==="down"?[{a:{fill:l},g:n.map(({x:o,y:c,w:u,h})=>({r:[o,B(c+.45*h),u,B(.55*h)]}))}]:[]}function Jg(e,t=!1){const{head:n}=e.anchors,i=B(t?xn(e).x-1.4:n.right+.4);return[{cls:"tama-startle",a:{fill:"#f2c14e"},g:[{r:[i,B(n.top+.5),1,3]},{r:[i,B(n.top+4.1),1,1]}]}]}function Qg(e){const{cx:t,top:n,w:i}=e.anchors.hat;return`translate(${t} ${n}) scale(${B(i/12)}) translate(-9 -9)`}function Yg(e,t){if(t==="goggles"){const{eyes:n}=e.anchors,i=n.reduce((o,c)=>o+c.y+c.h/2,0)/n.length,l=Math.min(...n.map(o=>o.x))-2,a=Math.max(...n.map(o=>o.x+o.w))+2,s={rx:1,fill:"#7fd1e6","fill-opacity":.45,stroke:"#2b2f36","stroke-width":.5};return[{cls:"tama-goggles",g:[{r:[B(l),B(i-.4),B(a-l),.8],a:{fill:"#2b2f36"}},...n.map(o=>({r:[B(o.x-.6),B(o.y-.6),B(o.w+1.2),B(o.h+1.2)],a:s}))]}]}if(t==="scarf"){const{y:n,x0:i,x1:l}=e.anchors.neck,a=[];for(let s=i+2;s+.7<=l;s+=3)a.push({r:[B(s),n,.7,1.6]});return[{cls:"tama-scarf",g:[{r:[i,n,B(l-i),1.6],a:{fill:"#d64541"}},{g:a,a:{fill:"#f4f4f6"}},{r:[B(i-3),B(n+.3),3.6,1.1],cls:"tama-scarf-tail",a:{fill:"#d64541"}}]}]}return[]}function Ks(e,t){const n=/^#([0-9a-f]{6})$/i.exec(e||"");if(!n)return e;const i=Number.parseInt(n[1],16),[l,a,s]=[i>>16&255,i>>8&255,i&255].map(x=>x/255),o=Math.max(l,a,s),c=Math.min(l,a,s),u=o-c;if(u===0)return e.toLowerCase();const d=(((o===l?(a-s)/u%6:o===a?(s-l)/u+2:(l-a)/u+4)*60+t)%360+360)%360,p=u*(1-Math.abs(d/60%2-1)),[f,m,k]=d<60?[u,p,0]:d<120?[p,u,0]:d<180?[0,u,p]:d<240?[0,p,u]:d<300?[p,0,u]:[u,0,p];return`#${[f,m,k].map(x=>Math.round((x+c)*255).toString(16).padStart(2,"0")).join("")}`}const Ia={pint:{reach:2.6,at:.42},mug:{reach:2.2,at:.55},spoon:{reach:2.4,at:.55},can:{reach:2.6,at:.45},leash:{reach:2.4,at:.65}};function Vi(e,t){const n=xn(e),{reach:i,at:l}=Ia[t];return[B(e.limb.root[0]+i),B(n.y+l*n.h)]}function Zg(e,t,{scale:n,tx:i,ty:l}){const[a,s]=Vi(e,t);return[B(i+n*a),B(l+n*s)]}function Vs({scale:e,tx:t,ty:n},[i,l]){return[B((i-t)/e),B((l-n)/e)]}function Gl(e,t,n=Vi(e,t)){const{style:i,root:[l,a],width:s,color:o,outline:c,spade:u}=e.limb,[h,d]=n,p=(m,k,x,b)=>({r:[B(m),B(k),B(x),B(b)]});if(i==="arm")return[{a:{fill:o},g:[p(l,a,h-l,s),p(h-s,Math.min(a,d),s,Math.abs(d-a)+s),p(h-s*1.1,d-s*.4,s*1.4,s)]}];if(i==="tentacle"){const m=Math.max(2,Math.ceil(Math.max(Math.abs(h-l),Math.abs(d-a))/(.75*s))),k=[];for(let x=0;x<=m;x++)k.push(p(l+(h-l)*x/m-.45*s,a+(d-a)*x/m-.45*s,.95*s,.95*s));return[{a:{fill:o},g:[...k,p(h+.3*s,d-.9*s,.8*s,.8*s)]}]}const f=[p(l,a,h-l,s),p(h-s,d,s,a-d+s),p(h-s,d-s*.2,s*1.6,s)];return[...c?[{a:{fill:o,stroke:c,"stroke-width":1},g:f}]:[],{a:{fill:o},g:[...f,...u?[p(h+.4,d-.9,1.2,1.2)]:[]]}]}function Oa(e,t=!1,n=void 0){return e.flatMap(i=>{var a;if(i.mood)return[];const l=((a=i.a)==null?void 0:a.fill)??n;return i.r?t?[{r:i.r,fill:l}]:[]:Oa(i.g,t||!!i.arms,l)})}function Xg(e){return Oa(e.root).length===0}function e1(e){const t=Oa(e.root);if(t.length)return t.map(({r:[i,l,a],fill:s},o)=>({r:[i,B(l-4),a,4],a:{fill:s},cls:o?"tama-cheer tama-cheer2":"tama-cheer"}));const n=xn(e);return[{cls:"tama-cheer",g:Gl(e,null,[B(e.limb.root[0]+1.6),B(n.y+.12*n.h)])}]}const xu="#ff3b2f",t1="#f3f5f8";function n1(e){let t=null;const n=(d,p)=>{const f=p||d.mood==="furious";if(d.r){f&&d.r[2]>=2.4&&d.r[3]>=1.2&&(!t||d.r[2]>t[2])&&(t=d.r);return}(d.g||[]).forEach(m=>{n(m,f)})};if(e.root.forEach(d=>{n(d,!1)}),!t)return[];const[i,l,a,s]=t,o=l+s*.3,c=l+s*.7,u=a/4-.05;let h=`M${B(i+.1)} ${B(c)}`;for(let d=1;d<=4;d++)h+=` L${B(i+.1+u*d)} ${B(d%2?o:c)}`;return[{p:h,a:{fill:"none",stroke:t1,"stroke-width":.35,"stroke-linejoin":"miter"}}]}const yi=[{id:"hanken",name:"Hanken Grotesk",face:"Hanken Grotesk",stack:"'Hanken Grotesk', -apple-system, system-ui, sans-serif"},{id:"inter",name:"Inter",face:"Inter",stack:"'Inter', -apple-system, system-ui, sans-serif"},{id:"system-sans",name:"System sans",face:"system-ui",stack:"-apple-system, system-ui, sans-serif"},{id:"plex-mono",name:"IBM Plex Mono",face:"IBM Plex Mono",mono:!0,stack:"'IBM Plex Mono', ui-monospace, 'JetBrains Mono', Menlo, monospace"},{id:"jetbrains-mono",name:"JetBrains Mono",face:"JetBrains Mono",mono:!0,stack:"'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace"},{id:"sf-mono",name:"SF Mono",face:"SF Mono",mono:!0,stack:"'SF Mono', ui-monospace, Menlo, monospace"},{id:"menlo",name:"Menlo",face:"Menlo",mono:!0,stack:"Menlo, Monaco, monospace"}],_u={ui:"hanken",code:"plex-mono"};function Su(e,t){return yi.find(n=>n.id===e)||yi.find(n=>n.id===_u[t])}const Ye=q([]);let r1=1;function _n(e,t="info",n=4e3){const i=r1++;return Ye.value=[...Ye.value,{id:i,message:e,kind:t,ms:n,show:!1}],requestAnimationFrame(()=>{Ye.value=Ye.value.map(l=>l.id===i?{...l,show:!0}:l)}),setTimeout(()=>{Ye.value=Ye.value.map(l=>l.id===i?{...l,show:!1}:l),setTimeout(()=>{Ye.value=Ye.value.filter(l=>l.id!==i)},200)},n),i}function i1(){const e=Ye.value;return r("div",{id:"toast-container",children:e.map(t=>r("div",{class:`toast toast-${t.kind}${t.show?" toast-show":""}`,children:t.message},t.id))})}let At=[];function ye(e,t){At.push({name:e,detail:t||null,t:Math.floor(Date.now()/1e3)}),At.length>500&&(At=At.slice(-500))}function gl(e){if(!At.length)return;const t=JSON.stringify({events:At});At=[],e&&navigator.sendBeacon?navigator.sendBeacon("/api/events",new Blob([t],{type:"application/json"})):fetch("/api/events",{method:"POST",headers:{"Content-Type":"application/json"},body:t,keepalive:!0}).catch(()=>{})}typeof addEventListener=="function"&&(setInterval(()=>gl(!1),5e3),addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&gl(!0)}),addEventListener("pagehide",()=>gl(!0)));const Jl={claude:{label:"Claude",glyph:"✻",className:"icon-claude"},codex:{label:"Codex",glyph:"⬡",className:"icon-codex"}};function Sn(e,t,n=`${t}s`){return`${e} ${e===1?t:n}`}function xe(e){return(e==null?void 0:e.name)||(e==null?void 0:e.agent)||"shell"}function nt(e){const t=e.lastIndexOf(":"),n=e.slice(0,t),i=e.slice(t+1);return`session=${encodeURIComponent(n)}&index=${encodeURIComponent(i)}`}function l1(e){return`pane_id=${encodeURIComponent(e)}`}function Pe(e){if(!e)return"";const t=Math.max(0,Math.floor(Date.now()/1e3)-e);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:t<86400?`${Math.floor(t/3600)}h`:`${Math.floor(t/86400)}d`}function a1(e){return e?{"approve askuserquestion":"needs answer","permission prompt":"needs approval","dialog open":"needs input"}[e.toLowerCase()]||e.toLowerCase():"needs input"}function $u(e){if(!e)return null;const t=e.toLowerCase();return t==="permission prompt"?"permission":t==="approve askuserquestion"?"question":"dialog"}function Cu(e,t){if(!e)return e;const n=e.split("/");for(let i=1;is!==e&&s&&s.split("/").slice(-i).join("/")===l))return l}return e}function Tu(e){if(!e)return null;const t=Math.floor(e.age_s/86400),n=Math.floor(e.age_s%86400/3600),i=t>0?`${t}d ${n}h`:`${n}h`;return{label:e.trigger==="mem"?`${e.gb}G`:`${t}d`,title:`Claude is using ${e.gb}GB after ${i} — consider exiting and resuming this session`,cls:`mem-${e.tier}`}}function cr(e,t){return e?`https://github.com/${e}/pull/${t}`:null}function Gi(e){return e==="merged"?{cls:"is-merged",suffix:" (merged)"}:e==="closed"?{cls:"is-closed",suffix:" (closed)"}:{cls:"",suffix:""}}async function ie(e,t,n={}){const i=n.method||"GET";let l;try{l=await fetch(t,n)}catch(s){return ye(`api:${e}`,{path:t,method:i,ok:!1}),_n(`${e} failed: ${s.message}`,"bad",6e3),null}let a={};try{a=await l.json()}catch{}if(!l.ok||a.ok===!1){ye(`api:${e}`,{path:t,method:i,ok:!1});const s=a.error||a.detail||`HTTP ${l.status}`;return _n(`${e} failed: ${s}`,"bad",6e3),null}return ye(`api:${e}`,{path:t,method:i,ok:!0}),a}async function s1(e,t){var a,s;let n;try{n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),...typeof AbortSignal<"u"&&typeof AbortSignal.timeout=="function"?{signal:AbortSignal.timeout(1e4)}:{}})}catch(o){return{ok:!1,status:0,detail:(o==null?void 0:o.message)||String(o)}}let i={};try{i=await n.json()||{}}catch{}const l=typeof i.detail=="string"?i.detail:typeof i.error=="string"?i.error:((s=(a=i.detail)==null?void 0:a[0])==null?void 0:s.msg)||`HTTP ${n.status}`;return{ok:n.ok,status:n.status,detail:l}}const me=q({loaded:!1,ui:{},windows:{},commands:[]}),G=()=>me.value;async function Ji(){try{const e=await fetch("/api/prefs");if(!e.ok)throw new Error(`HTTP ${e.status}`);const t=await e.json();return me.value={...me.value,ui:t.ui||{},windows:t.windows||{},commands:t.commands||[],loaded:!0},await p1(),me.value}catch{return me.value={...me.value,loaded:!1},null}}function Vr(){return G().commands||[]}async function o1({label:e,exec:t}){if(!G().loaded)return!1;const n=await ie("add command","/api/prefs/commands",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({label:e,exec:""})});return n?(me.value={...G(),commands:n.commands},!0):!1}async function c1(e,{label:t,exec:n}){if(!G().loaded)return!1;const i=await ie("update command",`/api/prefs/commands/${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({label:t,exec:n||""})});return i?(me.value={...G(),commands:i.commands},!0):!1}async function u1(e){if(!G().loaded)return!1;const t=await ie("delete command",`/api/prefs/commands/${encodeURIComponent(e)}`,{method:"DELETE"});return t?(me.value={...G(),commands:t.commands},!0):!1}async function d1(e){if(!G().loaded)return!1;const t=await ie("reorder commands","/api/prefs/commands",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({labels:e})});return t?(me.value={...G(),commands:t.commands},!0):!1}async function $e(e,t){if(!G().loaded&&(await Ji(),!G().loaded))return!1;const n={...G().ui};me.value={...G(),ui:{...G().ui,...e}};const i=await ie("save prefs","/api/prefs/ui",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{...e,writer:t}:e)});return i?(me.value={...G(),ui:i.ui},!0):(me.value={...G(),ui:n},!1)}function h1(e){me.value={...G(),ui:e}}function Mr(e){if(!e)return null;const t=G().windows[e];if(!t)return null;const n=t.notes||"",i=t.tags||[],l=t.pinned_files||[];return!n&&!i.length&&!l.length?null:{notes:n,tags:i,pinned_files:l}}async function Gr(e,{notes:t,tags:n,pinned_files:i}){if(!G().loaded&&(await Ji(),!G().loaded))return!1;const l=G().windows[e],a=l||{},s={...a,notes:t??a.notes,tags:n??a.tags,pinned_files:i??a.pinned_files};me.value={...G(),windows:{...G().windows,[e]:s}};const o={};t!==void 0&&(o.notes=t),n!==void 0&&(o.tags=n),i!==void 0&&(o.pinned_files=i);const c=await ie("save annotation",`/api/prefs/windows/${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!c){const u={...G().windows};return l===void 0?delete u[e]:u[e]=l,me.value={...G(),windows:u},!1}return me.value={...G(),windows:{...G().windows,[e]:{...G().windows[e]||{},...c.annotation}}},!0}function Eu(e){if(!e)return[];const t=G().windows[e];return[...(t==null?void 0:t.pinned_files)||[]]}function f1(e,t){if(!e||!t)return Promise.resolve(!1);const n=Eu(e),i=n.includes(t)?n.filter(l=>l!==t):[...n,t];return Gr(e,{pinned_files:i})}async function p1(){const e={"periscope:sessionOrder":"session_order","periscope:collapsedSessions":"collapsed_sessions","periscope:view":"view"};if(!Object.keys(e).some(l=>localStorage.getItem(l)!==null))return;const n=G().ui;if(!n.session_order&&!n.collapsed_sessions&&!n.view){const l={};for(const[a,s]of Object.entries(e)){const o=localStorage.getItem(a);if(o!==null)try{l[s]=s==="view"?o:JSON.parse(o)}catch{}}if(Object.keys(l).length&&!await $e(l))return}for(const l of Object.keys(e))localStorage.removeItem(l)}function bi(){const e=G().ui||{};return[...e.track_order||e.repo_order||[]]}function m1(e,t){return $e({track_order:e},t)}function ur(){return{...(G().ui||{}).tabs_by_track||{}}}function g1(e){return $e({tabs_by_track:e})}function Da(){var e;return{...((e=G().ui)==null?void 0:e.branch_order_by_track)||{}}}function dr(){var e;return{...((e=G().ui)==null?void 0:e.rail_collapsed)||{}}}function Pu(e,t){const n=dr();return n[e]=t,$e({rail_collapsed:n})}function y1(){var e;return((e=G().ui)==null?void 0:e.last_selected)||null}function bt(e){return $e({last_selected:e})}function b1(){var e;return((e=G().ui)==null?void 0:e.launch_profile)||"default"}function k1(e){return $e({launch_profile:e})}function Mu(){var e;return wu((e=G().ui)==null?void 0:e.tama_critter).id}function w1(e){return $e({tama_critter:e})}function hr(e){var t;return Su((t=G().ui)==null?void 0:t[`${e}_font`],e)}function v1(e,t){return $e({[`${e}_font`]:t})}const x1={needs_input:!0,done:!0,ci_failed:!0,pr_merged:!0,usage:!0,quiet_when_focused:!0,group:!0,badge:!0};function ki(){var e;return{...x1,...((e=G().ui)==null?void 0:e.notify)||{}}}function _1(e,t){return $e({notify:{...ki(),[e]:t}})}function Ra(){var e;return[...((e=G().ui)==null?void 0:e.pinned_pids)||[]]}function S1(e){return $e({pinned_pids:e})}function $1(e){const t=Ra(),n=t.includes(e)?t.filter(i=>i!==e):[...t,e];return S1(n)}function C1(e){var t;return((t=G().ui)==null?void 0:t[e])??null}function Gs(e,t){return $e({[e]:t})}function Fa(e){var t;return!!((t=G().ui)!=null&&t[`${e}_hidden`])}function T1(e,t){return $e({[`${e}_hidden`]:t})}function Au(e){var t,n;return((n=(t=G().ui)==null?void 0:t.detail_mode_by_pid)==null?void 0:n[e])||null}function Ql(e,t){var i;const n={...((i=G().ui)==null?void 0:i.detail_mode_by_pid)||{}};return n[e]=t,$e({detail_mode_by_pid:n})}function Na(){const e=G().ui||{};return{merged:e.clawd_merged,furious:e.clawd_furious}}async function Lu(e,t){var n;return G().loaded||await Ji(),!G().loaded||((n=Na()[e])==null?void 0:n.slice(0,10))===t.slice(0,10)?!1:$e({[`clawd_${e}`]:t})}function Ve(){return typeof window<"u"&&typeof window.__TAURI_INTERNALS__<"u"&&typeof window.__TAURI_INTERNALS__.invoke=="function"}function An(e,t){return window.__TAURI_INTERNALS__.invoke(e,t||{})}async function Ba(e,t){const n=window.__TAURI_INTERNALS__.transformCallback(i=>{i!=null&&i.payload&&t(i.payload)});await An("plugin:event|listen",{event:e,target:{kind:"Any"},handler:n})}async function E1(e){if(Ve())try{const t=e>0?Math.floor(e):null;await An("plugin:window|set_badge_count",{count:t})}catch(t){console.warn("[tauri] setBadgeCount failed:",t)}}async function Iu({title:e,body:t,target:n="",...i}){if(Ve())try{await An("plugin:event|emit",{event:"periscope:notify",payload:{title:e,body:t,target:n,...i}})}catch(l){console.warn("[tauri] notify failed:",l)}}async function P1(e){if(Ve())try{await Ba("periscope:notification-clicked",e)}catch(t){console.warn("[tauri] notification-click listener failed:",t)}}async function M1(e){if(Ve())try{await Ba("periscope:notification-opened",e)}catch(t){console.warn("[tauri] notification-opened listener failed:",t)}}async function A1(e){if(Ve())try{await Ba("periscope:notification-action",e)}catch(t){console.warn("[tauri] notification-action listener failed:",t)}}async function L1(e){if(Ve())try{await An("plugin:event|emit",{event:"periscope:notify-categories",payload:e})}catch(t){console.warn("[tauri] setNotifyCategories failed:",t)}}function Qi(e){if(Ve())return An("plugin:opener|open_url",{url:e}).catch(t=>{console.warn("[tauri] open_url failed:",t)}),!0;try{if(window.open(e,"_blank","noopener,noreferrer"))return!0}catch(t){console.warn("[periscope] window.open threw:",t)}try{const t=document.createElement("a");return t.href=e,t.target="_blank",t.rel="noopener noreferrer",document.body.appendChild(t),t.click(),t.remove(),!0}catch(t){console.warn("[periscope] anchor-click fallback threw:",t)}return!1}function I1(){Ve()&&document.addEventListener("click",e=>{const t=e.target.closest("a[href]");if(!t)return;let n;try{n=new URL(t.href)}catch{return}n.protocol!=="http:"&&n.protocol!=="https:"||n.origin!==location.origin&&(e.preventDefault(),e.stopPropagation(),An("plugin:opener|open_url",{url:n.href}).catch(i=>{console.warn("[tauri] open_url failed:",i)}))},!0)}function O1(e){return!!(e!=null&&e.asked_question)&&!(e!=null&&e.waiting_for)}function Js(e,t,n){const i=new Set((t||[]).filter(a=>a.state===n).map(a=>a.pid)),l=new Set;for(const a of e)i.has(a)&&l.add(a);return l}function za(e,t,n,i=new Set){const l=Ha(e),a=(e||[]).filter(o=>o.state==="needs-input").filter(o=>!i.has(o.pid)).map(o=>({kind:"live",pid:o.pid,w:o})),s=(t||[]).filter(o=>o.kind==="need_human").filter(o=>!n.has(o.id)).filter(o=>!ja(o,l)).sort((o,c)=>c.ts-o.ts).map(o=>({kind:"event",id:o.id,pane_id:o.pane_id,target:o.target,w:l[o.target]||null,message:o.message,ts:o.ts,session:o.session,name:o.name}));return[...a,...s]}function Ou(e,t,n,i=new Set){const l=Ha(e),a=(e||[]).filter(c=>c.state==="done").filter(c=>!i.has(c.pid)).map(c=>({kind:"live",pid:c.pid,w:c})),s=new Set(a.map(c=>c.w.target)),o=(t||[]).filter(c=>c.kind==="done").filter(c=>!n.has(c.id)).filter(c=>!s.has(c.target)).filter(c=>!ja(c,l)).sort((c,u)=>u.ts-c.ts).map(c=>({kind:"event",id:c.id,pane_id:c.pane_id,target:c.target,w:l[c.target]||null,message:c.message,ts:c.ts,session:c.session,name:c.name}));return[...a,...o]}function ja(e,t){const n=t[e.target];return n?Math.max(n.focused_at||0,n.acted_at||0)>e.ts:!1}function D1(e){return e.length}const R1=600,F1=3600;function Du(e,t){const n=(t||0)-(e||0);return n>=F1?"urgent":n>=R1?"stale":"fresh"}function Ru(e,t,n=new Set){var a;const i=Ha(e),l=new Map;for(const s of t||[]){if(s.kind!=="need_human"||n.has(s.id)||ja(s,i))continue;const o=(a=i[s.target])==null?void 0:a.pid;if(!o)continue;const c=l.get(o);(c===void 0||s.ts!0){var c,u;const s=Ru(e,t,n),o=new Map;for(const h of za(e,t,n,i)){if(!a(h.w))continue;const d=((c=h.w)==null?void 0:c.pid)!=null?`pid:${h.w.pid}`:`target:${h.target}`,p=Math.min(h.kind==="event"?h.ts:h.w.needs_since||l,...((u=h.w)==null?void 0:u.pid)!=null&&s.has(h.w.pid)?[s.get(h.w.pid)]:[]),f=o.get(d);o.set(d,{row:(f==null?void 0:f.row.kind)==="live"?f.row:h,since:f?Math.min(f.since,p):p})}return o}function Nu(e){return(e||[]).filter(t=>t.state==="working").map(t=>({kind:"live",pid:t.pid,w:t}))}function N1(e,t){const n={};for(const i of t||[])n[i.pid]=i;return(e||[]).map(i=>n[i]).filter(Boolean)}function B1(e){return(e||[]).filter(t=>t.kind==="done"||t.kind==="info")}function Ha(e){const t={};for(const n of e||[])t[n.target]=n;return t}const qa=ar;let Qs=!1;function Ut(e){e&&ot((ce.value||[]).find(t=>t.target===e))}function ot(e){e!=null&&e.pid&&(ke.value=`pane:${e.pid}`,bt({kind:"pane",pid:e.pid}))}function Bu(e){O1(e)&&(pt.value=new Set([...pt.value,e.pid])),ot(e)}function zu(e){e!=null&&e.pid&&(mt.value=new Set([...mt.value,e.pid]))}function ju(e){zu(e),ot(e)}function z1(){Qs||(Qs=!0,P1(e=>Ut(e)))}function Hu(e,t){!e||!t||(ke.value=`review:${e}/${t.replace(/\//g,"--")}`,bt({kind:"review",repo:e,branch:t}))}function Ua(){ke.value="reviews",bt({kind:"reviews"})}const yl=[{key:"all",label:"all"},{key:"needs-input",label:"needs input"},{key:"working",label:"working"},{key:"done",label:"done"},{key:"idle",label:"idle"},{key:"agents",label:"agents"},{key:"shell",label:"shells"},{key:"ci-bad",label:"CI ✗"}];function j1(){const[e,t]=N(!1),n=J(null),i=jl.value,l=(yl.find(o=>o.key===i)||yl[0]).label,a=jt(()=>t(!1),[]);ji(n,e,a);function s(o){jl.value=o,ye("filter.use"),t(!1)}return r("div",{class:"tb-dd","data-dd":"filter",ref:n,children:[r("button",{type:"button",class:"filter-btn tb-dd-toggle",id:"filter-dd-toggle","aria-haspopup":"menu","aria-expanded":e?"true":"false",title:"filter by state",onClick:o=>{o.stopPropagation(),t(c=>!c)},children:[r("span",{id:"filter-dd-label",children:l}),r("span",{class:"tb-dd-chev","aria-hidden":"true",children:"▾"})]}),r("div",{class:"tb-dd-menu",id:"filter-dd-menu",role:"menu",hidden:!e,children:yl.map(o=>r("button",{"data-filter":o.key,class:`tb-dd-item${o.key===i?" active":""}`,role:"menuitem",onClick:()=>s(o.key),children:o.label},o.key))})]})}const qu=Qt(()=>Fa("rail")),wi=Qt(()=>Fa("side"));function Yl(e){return T1(e,!Fa(e))}function Ys({side:e,shown:t}){return r("svg",{width:"16",height:"12",viewBox:"0 0 16 12","aria-hidden":"true",children:[r("rect",{x:"0.5",y:"0.5",width:"15",height:"11",rx:"1.5",fill:"none",stroke:"currentColor"}),r("rect",{x:e==="left"?2:10,y:"2",width:"4",height:"8",rx:"0.5",fill:t?"currentColor":"none",stroke:"currentColor","stroke-width":"0.75"})]})}function H1(){const e=!qu.value,t=!wi.value;return r("span",{class:"panel-toggles",children:[r("button",{type:"button",class:"filter-btn is-action panel-toggle","aria-pressed":e,title:`${e?"Hide":"Show"} the navigator (⌘B)`,onClick:()=>Yl("rail"),children:r(Ys,{side:"left",shown:e})}),r("button",{type:"button",class:"filter-btn is-action panel-toggle","aria-pressed":t,title:`${t?"Hide":"Show"} the context column (⌥⌘B)`,onClick:()=>Yl("side"),children:r(Ys,{side:"right",shown:t})})]})}function fn(e){return e>=1024?`${(e/1024).toFixed(1)}G`:`${e}M`}function Uu(e){return e==null?"–":e<10?`${e.toFixed(1)}%`:`${Math.round(e)}%`}function q1(e){var t;return e.server.mem_mb+(((t=e.webview)==null?void 0:t.mem_mb)||0)+e.panes.mem_mb}function U1(e){return e.filter(t=>t.res).map(t=>({w:t,...t.res})).sort((t,n)=>n.mem_mb-t.mem_mb)}function W1(e){return`${fn(e.ram_mb)} RAM · swap ${fn(e.swap_used_mb)}/${fn(e.swap_total_mb)} · ${e.mem_free_pct}% free · load ${e.load1}`}const K1="share of the whole machine's CPU: 100% is every core busy";function Fn({label:e,group:t,onClick:n}){const i=r(U,{children:[r("span",{class:"res-label",children:e}),r("span",{class:"res-mem",children:fn(t.mem_mb)}),r("span",{class:"res-cpu",title:K1,children:Uu(t.cpu_pct)})]});return n?r("button",{type:"button",class:"res-line is-pane",onClick:n,children:i}):r("div",{class:"res-line",children:i})}function V1({r:e}){const t=J(null),n=J(null),[i,l]=N(!1),a=jt(()=>{var o,c;const s=(o=t.current)==null?void 0:o.contains(document.activeElement);l(!1),s&&((c=n.current)==null||c.focus())},[]);return ji(t,i,a),r("div",{class:"pill-dd",ref:t,children:[r("button",{type:"button",class:"res-pill",ref:n,title:"memory held by periscope's server, its webview and its panes — click for each one's memory and CPU","aria-haspopup":"dialog","aria-expanded":i?"true":"false",onClick:()=>l(!i),children:["▣ ",fn(q1(e))]}),r("div",{class:"tb-dd-menu res-menu",role:"dialog","aria-label":"resource usage",hidden:!i,children:[r(Fn,{label:"periscope server",group:e.server}),e.webview&&r(Fn,{label:"webview",group:e.webview}),r(Fn,{label:"all panes",group:e.panes}),r("div",{class:"res-pane-lines",children:U1(ce.value||[]).map(({w:s,mem_mb:o,cpu_pct:c})=>r(Fn,{label:xe(s),group:{mem_mb:o,cpu_pct:c},onClick:()=>{ot(s),a()}},s.pid))}),r(Fn,{label:"elsewhere",group:e.elsewhere}),r("div",{class:"res-machine",children:W1(e.machine)})]})]})}function G1(){const e=Fc.value;return e&&r(V1,{r:e})}async function Wu(e){const t=Qn.value;Qn.value=e;const n=await ie("spawn account","/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({spawn_account:e})});return n||(Qn.value=t),!!n}function J1(){if(!Mn())return null;const e=[{id:null,label:"auto"},...st.value],t=Qn.value||null,n=dn.value;return r("div",{class:"spawn-acct",title:`which account new Claude panes launch on
auto — the account whose weekly reset is soonest (drain it before it resets)
-a letter — pin every spawn (New Tab, + new, spawned workers) to one subscription`,children:[r("span",{class:"spawn-acct-label",children:"spawn"}),e.map(i=>r("button",{type:"button",class:`spawn-acct-btn${t===i.id?" is-active":""}`,title:i.id===null?n==null?void 0:n.reason:void 0,onClick:()=>Mu(i.id),children:i.id===null&&t===null&&n?`auto → ${yn(n.account)}`:i.label},i.id??"auto"))]})}const Fa=["default","low","medium","high","xhigh","max"];async function v1(e){const t=Gn.value;Gn.value=e,await ie("spawn effort","/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({spawn_effort:e})})||(Gn.value=t)}function _1(){const e=Gn.value||"default";return r("div",{class:"spawn-acct spawn-effort",title:`reasoning effort new Claude panes launch at
+a letter — pin every spawn (New Tab, + new, spawned workers) to one subscription`,children:[r("span",{class:"spawn-acct-label",children:"spawn"}),e.map(i=>r("button",{type:"button",class:`spawn-acct-btn${t===i.id?" is-active":""}`,title:i.id===null?n==null?void 0:n.reason:void 0,onClick:()=>Wu(i.id),children:i.id===null&&t===null&&n?`auto → ${vn(n.account)}`:i.label},i.id??"auto"))]})}const Wa=["default","low","medium","high","xhigh","max"];async function Q1(e){const t=Zn.value;Zn.value=e,await ie("spawn effort","/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({spawn_effort:e})})||(Zn.value=t)}function Y1(){const e=Zn.value||"default";return r("div",{class:"spawn-acct spawn-effort",title:`reasoning effort new Claude panes launch at
default — Claude's own choice for the model
-low … max — every new pane starts there (New Tab, + new, spawned workers); change a running pane from its own header`,children:[r("span",{class:"spawn-acct-label",children:"effort"}),Fa.map(t=>r("button",{type:"button",class:`spawn-acct-btn${e===t?" is-active":""}`,onClick:()=>v1(t),children:t},t))]})}const cr=[{id:"default",label:"default"},{id:"fable",label:"fable"},{id:"opus[1m]",label:"opus 1m"},{id:"sonnet",label:"sonnet"}],x1=[{id:"auto",label:"auto"},...cr];async function S1(e){const t=Vn.value;Vn.value=e,await ie("spawn model","/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({spawn_model:e})})||(Vn.value=t)}function $1(){const e=Vn.value||"auto",t=sn.value;return r("div",{class:"spawn-acct spawn-model",title:`which model new Claude panes launch on
+low … max — every new pane starts there (New Tab, + new, spawned workers); change a running pane from its own header`,children:[r("span",{class:"spawn-acct-label",children:"effort"}),Wa.map(t=>r("button",{type:"button",class:`spawn-acct-btn${e===t?" is-active":""}`,onClick:()=>Q1(t),children:t},t))]})}const fr=[{id:"default",label:"default"},{id:"fable",label:"fable"},{id:"opus[1m]",label:"opus 1m"},{id:"sonnet",label:"sonnet"}],Z1=[{id:"auto",label:"auto"},...fr];async function X1(e){const t=Yn.value;Yn.value=e,await ie("spawn model","/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({spawn_model:e})})||(Yn.value=t)}function e0(){const e=Yn.value||"auto",t=dn.value;return r("div",{class:"spawn-acct spawn-model",title:`which model new Claude panes launch on
auto — fable until its weekly sub-limit walls, then opus 1m (per account)
default — whatever the account's settings.json picks
-fable / opus 1m / sonnet — pin every spawn (New Tab, + new, spawned workers); the launcher can still override one launch`,children:[r("span",{class:"spawn-acct-label",children:"model"}),x1.map(n=>r("button",{type:"button",class:`spawn-acct-btn${e===n.id?" is-active":""}`,title:n.id==="auto"?t==null?void 0:t.reason:void 0,onClick:()=>S1(n.id),children:n.id==="auto"&&e==="auto"&&t?`auto → ${t.model??"default"}`:n.label},n.id))]})}const Lu={cols:0,rows:0,shrunkFrom:0},C1=4,T1=(e,t)=>e>0&&t>0?Math.min(e,t):e||t;function E1(e,t){return t>0&&Math.abs(e-t)<=C1?t:e}function P1(e,t,n,i){return{cols:e||n,rows:T1(t,i)}}function A1(e,t,n){return e.cols!==t.cols?e:n>0&&e.rows0&&e.rows>t.rows?{rows:Math.min(e.rows,t.shrunkFrom)}:null}function Iu(e,t){const n=e.shrunkFrom||e.rows;return{cols:t.cols??e.cols,rows:t.rows,shrunkFrom:t.rows0&&e.rows>0&&(Y.cols!==e.cols||Y.rows!==e.rows)&&Y.resize(e.cols,e.rows)}let Ye=null,et=null;function O1(){de&&de.readyState===WebSocket.OPEN&&de.send(JSON.stringify({type:"reconcile"}))}function D1(){if(!Y)return!0;const e=Y.buffer.active;return e.viewportY>=e.baseY}function Bu(e){Ye=e}let dr=null;function qs(e){dr=e}const zu=/\b(?:https?|wss?):\/\/[^\s)"'`<>]+/g,R1=new RegExp("(?=t.cols||o<0||o>=t.rows)return null;const u=t.buffer.active,c=u.getLine(u.viewportY+o);if(!c)return null;const p=c.translateToString(!0);for(const f of p.matchAll(zu)){const h=f.index,m=h+f[0].length;if(s>=h&&s{if(n.button!==0)return;const i=N1(n,e);i&&(Qt={url:i,x:n.clientX,y:n.clientY})},Ws=n=>{if(n.button!==0||!Qt)return;const i=Math.abs(n.clientX-Qt.x),l=Math.abs(n.clientY-Qt.y),{url:a}=Qt;if(Qt=null,i>4||l>4)return;Ki(a)||e.writeln(`\r
-\x1B[31m[periscope: failed to open ${a}]\x1B[0m`)},t.addEventListener("mousedown",Us,!0),t.addEventListener("mouseup",Ws,!0))}function j1(e){e.registerLinkProvider({provideLinks(t,n){var s;const i=(s=e.buffer.active.getLine(t-1))==null?void 0:s.translateToString(!0);if(!i)return n(void 0);const l=[];function a(o,u){for(const c of i.matchAll(o)){const p=c[0],d=c.index+1,f=d+p.length-1;l.push({text:p,range:{start:{x:d,y:t},end:{x:f,y:t}},activate(h,m){u!=="url"&&(!h.metaKey&&!h.ctrlKey||u==="file"&&dr&&dr(m))},hover(){},leave(){}})}}a(zu,"url"),a(R1,"file"),a(F1,"file"),n(l)}})}function H1(){try{return localStorage.getItem("periscope.noWebgl")==="1"}catch{return!1}}function q1(){var t,n;if(!Mt)return;const e=(t=Mt._renderer)==null?void 0:t._gl;try{Mt.dispose()}catch{}try{(n=e==null?void 0:e.getExtension("WEBGL_lose_context"))==null||n.loseContext()}catch{}Mt=null}function Ks(e){var n;if(!((n=document.fonts)!=null&&n.load))return;const t=`${Ou.fontSize}px "${e.face}"`;Promise.all([document.fonts.load(t),document.fonts.load(`bold ${t}`)]).then(()=>{!Y||en!==e||(Y.options.fontFamily="monospace",Y.options.fontFamily=e.stack,_r())},()=>{})}function U1(){if(!Y){if(et=document.createElement("div"),et.className="xterm-host",en=or("code"),Y=new Terminal({...Ou,fontFamily:en.stack,theme:M1,linkHandler:{allowNonHttpProtocols:!0,activate(e,t){if(t.startsWith("file://")){if(!e.metaKey&&!e.ctrlKey||!dr)return;let n=t.slice(7);n.startsWith("localhost/")&&(n=n.slice(9));try{n=decodeURIComponent(n)}catch{}dr(n);return}Ki(t)}}}),Y.open(et),Ks(en),it(()=>{const e=or("code");e!==en&&(en=e,Y.options.fontFamily=e.stack,Ks(e))}),Y.attachCustomWheelEventHandler(e=>{if(!Na||!e.deltaY)return!0;const t=B1(e,Y);if(!t)return!0;e.preventDefault();let n=e.deltaY;e.deltaMode===1?n*=t.cellH:e.deltaMode===2&&(n*=t.pageH),n<0!=tn<0&&(tn=0),tn+=n;const i=t.cellH*L1;let l=Math.trunc(tn/i);if(!l)return!1;tn-=l*i,l=Math.max(-8,Math.min(8,l));const a=l<0?64:65;return de&&de.readyState===WebSocket.OPEN&&de.send(`\x1B[<${a};${t.col};${t.row}M`.repeat(Math.abs(l))),!1}),H1())console.warn("[periscope] WebGL renderer disabled via localStorage periscope.noWebgl");else try{Mt=new WebglAddon.WebglAddon,Mt.onContextLoss(()=>{q1()}),Y.loadAddon(Mt)}catch(e){console.warn("[periscope] WebGL terminal renderer unavailable; using the DOM renderer:",e)}bt=new SearchAddon.SearchAddon,Y.loadAddon(bt);try{Y.loadAddon(new Unicode11Addon.Unicode11Addon),Y.unicode.activeVersion="11"}catch(e){console.warn("[periscope] Unicode 11 widths unavailable; emoji will offset the cursor:",e)}j1(Y),z1(Y),ur=new FitAddon.FitAddon,Y.loadAddon(ur),Y.attachCustomKeyEventHandler(e=>{if(e.type!=="keydown")return!0;if(e.key==="Escape"&&e.shiftKey&&!e.metaKey&&!e.ctrlKey&&!e.altKey)return e.preventDefault(),e.stopPropagation(),de&&de.readyState===WebSocket.OPEN&&de.send("\x1B"),!1;if(e.key==="Escape"&&!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&!e.altKey)return!1;if(e.key==="Enter"&&e.shiftKey&&!e.metaKey&&!e.ctrlKey&&!e.altKey)return e.preventDefault(),de&&de.readyState===WebSocket.OPEN&&de.send("\x1B\r"),!1;if(!e.metaKey)return!0;const t=n=>{e.preventDefault(),de&&de.readyState===WebSocket.OPEN&&de.send(n)};switch(e.key){case"Backspace":return t("".repeat(200)),!1;case"Delete":return t("\v"),!1;case"ArrowLeft":return t(""),!1;case"ArrowRight":return t(""),!1;case"r":case"R":return!1;default:return!0}}),Y.onData(e=>{de&&de.readyState===WebSocket.OPEN&&de.send(e)}),Y.onBell(()=>{Ye&&(Ye.classList.add("bell-pulse"),setTimeout(()=>Ye.classList.remove("bell-pulse"),400))})}}function W1(e){ye("terminal.open",{target:e});const t=Y!==null;if(U1(),Ye&&et.parentElement!==Ye&&Ye.appendChild(et),t){try{Y.reset()}catch{}Na=!1,tn=0}if(Y.focus(),Nu(),ja(),Lt)try{Lt.disconnect()}catch{}Lt=new ResizeObserver(_r),Ye&&Lt.observe(Ye),ki=e,wi=!1,Bn=0,Vr=!1,ju(e,st.cols,st.rows)}function ju(e,t=0,n=0){let l=`${location.protocol==="https:"?"wss":"ws"}://${location.host}/ws/pane?${Ag(e)}`;t>0&&n>0&&(l+=`&cols=${t}&rows=${n}`,un=Iu(un,{cols:t,rows:n}));const a=new WebSocket(l);a.binaryType="arraybuffer",de=a,a.onopen=()=>{Bn>0&&Y&&Y.writeln(`\r
-\x1B[32m[periscope: reconnected]\x1B[0m`),Bn=0,Vr=!1},a.onmessage=s=>{if(typeof s.data=="string")try{const o=JSON.parse(s.data);o.type==="size"?(za=o.cols,Vi=o.rows,ja(),_r()):o.type==="mouse"&&(Na=!!o.on)}catch{Y.write(Hs(s.data,Kl))}else Y.write(Hs(new Uint8Array(s.data),Kl))},a.onerror=()=>{},a.onclose=s=>{if(a!==de||wi||!Y||ki!==e)return;Vr||(Y.writeln(`\r
-\x1B[33m[periscope: reconnecting…]\x1B[0m`),Vr=!0);const o=[250,500,1e3,2e3],u=o[Math.min(Bn,o.length-1)]||4e3;Bn+=1,At&&clearTimeout(At),At=setTimeout(()=>{At=null,!(!Y||ki!==e||wi)&&ju(e,st.cols,st.rows)},u)}}function _r(){It&&clearTimeout(It),It=setTimeout(()=>{if(It=null,!Y||!ur||Ba||!Nu())return;ja();const e=A1(st,un,Vi);e&&de&&de.readyState===WebSocket.OPEN&&(un=Iu(un,e),de.send(JSON.stringify({type:"resize",...e})))},80)}function K1(){if(wi=!0,ki=null,At&&(clearTimeout(At),At=null),un=Lu,za=0,Vi=0,It&&(clearTimeout(It),It=null),Lt){try{Lt.disconnect()}catch{}Lt=null}if(de){try{de.close()}catch{}de=null}et!=null&&et.parentElement&&et.remove()}function Vs(e){Y&&Y.writeln(e)}function vi(){if(Y)try{Y.scrollToBottom()}catch{}}function V1(){!Y||!ur||_r()}function G1(){Ba=!0}function J1(){Ba=!1,_r()}function Gs(e,t={}){return bt?bt.findNext(e,t):!1}function Js(e,t={}){return bt?bt.findPrevious(e,t):!1}function Q1(){bt&&bt.clearDecorations()}let Qn=null,Gr=null;function Y1(e,t,n={}){Hu(),Bu(e),Kl=n.agent||null,n.onPaste&&(Qn=n.onPaste,e.addEventListener("paste",Qn,!0)),Gr=e,W1(t),requestAnimationFrame(()=>requestAnimationFrame(()=>{V1(),vi()})),setTimeout(vi,300)}function Hu(){K1(),Gr&&Qn&&Gr.removeEventListener("paste",Qn,!0),Qn=null,Gr=null,Bu(null)}function qu(e){return typeof e!="string"?null:e.startsWith("pane:")?e.slice(5):null}function Z1(e,t){const n=qu(e),i=n?t==null?void 0:t[n]:null;return typeof i=="string"&&i.startsWith("file:")?"document":"terminal"}function X1(e){return(e.metaKey||e.ctrlKey)&&(e.key==="r"||e.key==="R")}function e0(e){return e.repeat||!(e.metaKey||e.ctrlKey)||e.shiftKey||e.code!=="KeyB"?null:e.altKey?"side":"rail"}function t0(e=window){e.addEventListener("keydown",t=>{const n=e0(t);if(n){t.preventDefault(),Wl(n);return}if(X1(t)){if(t.preventDefault(),t.shiftKey){location.reload();return}if(Z1(ke.value,Re.value)==="document"){ms.value=ms.value+1;return}O1()}})}function Mr(e,t){if(!t||!e)return e;const n={...e};return e.fill&&(n.fill=Rs(e.fill,t)),e.stroke&&(n.stroke=Rs(e.stroke,t)),n}const Qs=e=>e!=null&&e.stroke?{stroke:ou,"stroke-width":e["stroke-width"]}:void 0;function Oe({n:e,mood:t,asleep:n,hide:i,tint:l,rest:a,paws:s,seated:o,flush:u}){if(u&&e.mood||e.mood&&e.mood!==t||a&&e.rest||s&&e.arms||o&&e.legs&&!e.keepSeated||(n||i)&&e.role==="glint"||i&&e.role==="eye")return null;if(e.r){const[c,p,d,f]=e.r;return u?r("rect",{class:e.cls,x:c,y:p,width:N(d+.02),height:N(f+.02),...Qs(e.a)}):r("rect",{class:e.cls,x:c,y:p,width:d,height:f,...Mr(e.a,l)})}if(e.p)return u?null:r("path",{class:e.cls,d:e.p,...Mr(e.a,l)});if(u){if((n||i)&&e.shut){const[c,p,d,f]=e.shut;return r("rect",{"data-role":"shut",x:c,y:p,width:N(d+.02),height:N(f+.02)})}return r("g",{class:e.anim||e.cls,...Qs(e.a),children:e.g.map((c,p)=>r(Oe,{n:c,mood:t,asleep:n,hide:i,rest:a,paws:s,seated:o,flush:!0},p))})}if((n||i)&&e.shut){const[c,p,d,f]=e.shut;return r("rect",{"data-role":"shut",x:c,y:p,width:d,height:f,...Mr(e.g[0].a,l)})}return r("g",{class:e.anim||e.cls,"data-mood":e.mood,"data-role":e.role,...Mr(e.a,l),children:e.g.map((c,p)=>r(Oe,{n:c,mood:t,asleep:n,hide:i,tint:l,rest:a,paws:s,seated:o},p))})}function Gi({sprite:e,mood:t="calm",asleep:n=!1,face:i=null,startle:l=!1,tint:a=0,worn:s=null,holding:o=null,tip:u=null,paws:c=!1,cheer:p=!1,seated:d=!1,stride:f=!1,children:h}){const m=yg.has(i),b=u??(o&&$a[o]?qi(e,o):null),x=!!b||p&&Sg(e),w=t==="furious"&&!n,C=v=>v.role!==void 0||(v.g||[]).some(C),y=f?gg(e):e.root,g=w?e.root.filter(v=>v.mood==="furious"||C(v)):[],$=w?y.filter(v=>!g.includes(v)):y;return r("g",{class:"critter","data-face":i||void 0,"data-worn":s||void 0,"data-holding":o||void 0,children:[$.map((v,E)=>r(Oe,{n:v,mood:t,asleep:n,hide:m,tint:a,rest:x,paws:c,seated:d},E)),i&&kg(e,i).map((v,E)=>r(Oe,{n:v,mood:t,tint:a},`face-${E}`)),s&&_g(e,s).map((v,E)=>r(Oe,{n:v,mood:t,tint:a},`worn-${E}`)),l&&wg(e,!!b).map((v,E)=>r(Oe,{n:v,mood:t,tint:a},`startle-${E}`)),h,b&&Hl(e,o,b).map((v,E)=>r(Oe,{n:v,mood:t,tint:a},`hold-${E}`)),p&&$g(e).map((v,E)=>r(Oe,{n:v,mood:t,tint:a},`cheer-${E}`)),w&&r("g",{class:"tama-flush",fill:ou,opacity:"0.5",children:[y.map((v,E)=>r(Oe,{n:v,mood:t,hide:m,rest:x,paws:c,seated:d,flush:!0},E)),b&&Hl(e,o,b).map((v,E)=>r(Oe,{n:v,mood:t,flush:!0},`hold-${E}`))]}),w&&g.map((v,E)=>r(Oe,{n:v,mood:t,asleep:n,hide:m,tint:a,rest:x,paws:c,seated:d},`fu-${E}`)),w&&Tg(e).map((v,E)=>r(Oe,{n:v,mood:t,tint:a},`teeth-${E}`))]},w?"furious":"calm")}function n0(e){return e==null?"":e>=80?" ctx-hot":e>=60?" ctx-warn":""}function Vl(e){return e.ctx_class&&e.ctx_class!=="none"?` ctx-${e.ctx_class}`:n0(e.context_pct)}const Ys=["bell","api","done","merged","ctx","ci","update"],Uu=600;function Zs(e,t){const n=Math.floor((t-e)/60);return n<1?"":n<60?` (${n} min)`:` (${Math.floor(n/60)}h ${n%60}m)`}const In=(e,t,n={})=>({action:e,pid:t.pid,says:`open ${_e(t)}`,...n});function r0({windows:e=[],alerts:t=[],dismissedAlertIds:n=new Set,dismissedNeedsPids:i=new Set,dismissedReadyPids:l=new Set,selectedPid:a=null,parties:s=[],update:o=null,nowSec:u}){const c=[],p=g=>!g||a==null||String(g.pid)!==String(a),d=e.filter(p),f=new Map(e.map(g=>[String(g.pid),g])),h=xu(e,t,n,i,u,p);if(h.size){const g=[...h.values()].reduce((E,M)=>M.sinceg.api_error);m.length&&c.push({kind:"api",count:m.length,label:"API",phrase:`the Anthropic API is erroring in ${wn(m.length,"pane")}, not your code`,target:In("select",m[0])});const b=new Map;for(const g of e){if(g.ci!=="✗"||!g.pr||g.pr_state&&g.pr_state!=="open")continue;const $=`${g.repo_slug||g.repo_key||""}#${g.pr}`;b.has($)||b.set($,{pr:g.pr,panes:[]}),b.get($).panes.push(g)}const x=[...b.values()].filter(g=>g.panes.every(p));x.length&&c.push({kind:"ci",count:x.length,label:String(x.length),phrase:x.length===1?`PR #${x[0].pr} is failing CI`:`${x.length} PRs failing CI`,target:In("select",x[0].panes[0])});const w=wu(e,t,n,l).filter(g=>p(g.w));if(w.length){const g=w[0],$=g.w?_e(g.w):g.name||"a pane";c.push({kind:"done",count:w.length,label:String(w.length),phrase:w.length===1?`${$} finished`:`${w.length} panes finished`,target:g.kind==="live"?In("ready",g.w):{action:"reveal",target:g.target,says:`open ${$}`}})}const C=s.filter(g=>u-g.atVl(g)===" ctx-hot");if(y.length){const g=y.filter(M=>(M.context_pct??0)>=80),$=g.length?g.reduce((M,T)=>T.context_pct>M.context_pct?T:M):y[0],v=g.length?Math.round($.context_pct):null,E=y.length>1?`${y.length} panes worth compacting`:v!=null?`${_e($)} is running out of context (${v}%)`:`${_e($)} is costly to keep carrying${$.ctx_hint?`: ${$.ctx_hint}`:""}`;c.push({kind:"ctx",count:y.length,label:v!=null?`${v}%`:String(y.length),pct:v,cost:v==null,phrase:E,target:In("select",$)})}return(o==null?void 0:o.behind)>0&&!o.running&&c.push({kind:"update",count:1,label:"new",phrase:`periscope ${o.target} is out`,target:{action:"update",says:"see the update"}}),c.sort((g,$)=>Ys.indexOf(g.kind)-Ys.indexOf($.kind))}function i0(e){return e.slice(1).reduce((t,n)=>t+n.count,0)}const l0=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function a0(e,t){if(!e)return{day:null,time:"later"};const n=new Date(e*1e3),i=n.getHours(),l=n.getMinutes(),a=`${i%12||12}${l?`:${String(l).padStart(2,"0")}`:""}${i<12?"am":"pm"}`;return{day:e-t>20*3600?l0[n.getDay()]:null,time:a}}function s0({day:e,time:t}){return`every account is at its limit until ${e?`${e} `:""}${t}`}const o0=new Set(["done","merged","ci","api","ctx"]);function Wu(e,t){const n=e==="code";return{atDesk:n,moodShown:n&&!t,showsPanes:n&&!o0.has(t)}}function c0({states:e,parties:t},n,i){const l={...e},a=t.filter(s=>i-s.atc.key===u)&&a.push({key:u,pid:s.pid,pr:s.pr,at:i})}return{states:l,parties:a}}const u0=600;function Ha(e,t){return!!(e!=null&&e.fetched_at)&&t-e.fetched_at>u0}function qa(e){const t=[e==null?void 0:e.projected_percent,e==null?void 0:e.projected_recent].filter(i=>i!=null);if(!t.length)return!1;const n=Math.max(...t);return n>(e.percent??0)&&n>=100}function Ku(e){return e!=null&&e.hot?"furious":qa(e)?"grumpy":"calm"}const d0={session:"session",week_all:"week",week_opus:"opus",week_sonnet:"sonnet"};function Ua(e){return d0[e]||e.replace(/^week_/,"")}const Vu=[{from:0,to:7,id:"sleep",label:"sleeping"},{from:7,to:9,id:"coffee",label:"having coffee"},{from:9,to:10,id:"code",label:"coding with a coffee",coffee:!0},{from:10,to:12,id:"code",label:"coding"},{from:12,to:13,id:"eat",meal:"lunch"},{from:13,to:17,id:"code",label:"coding"},{from:17,to:18,pastime:!0},{from:18,to:19,id:"eat",meal:"dinner"},{from:19,to:21,id:"read",label:"reading"},{from:21,to:24,id:"sleep",label:"sleeping"}],Gu=[{from:0,to:9,id:"sleep",label:"sleeping"},{from:9,to:11,id:"eat",meal:"brunch"},{from:11,to:18,pastime:!0},{from:18,to:19,id:"eat",meal:"dinner"},{from:19,to:21,id:"read",label:"reading"},{from:21,to:24,id:"sleep",label:"sleeping"}],dn=17,Xs=16,Be=.5,Wa=Vu.map(e=>{const t=e.id==="code"?{...e,id:"nap",label:"napping at the desk"}:e;return t.to===dn?{...t,to:Xs}:t.from===dn?{...t,from:Xs}:t}),Ju=e=>e.getDay()===0||e.getDay()===6,Ji=(e,t)=>e.find(n=>t>=n.from&&tJi(Ju(e)?Gu:Wa,dn),eo=[{id:"run",label:"out for a run"},{id:"cycle",label:"out cycling",seasons:["spring","summer","autumn"]},{id:"music",label:"practicing bass"},{id:"beer",label:"having a beer with friends"},{id:"kids",label:"spending time with the kids"},{id:"game",label:"playing video games"},{id:"garden",label:"gardening",seasons:["spring","summer"]},{id:"cook",label:"cooking"},{id:"dog",label:"walking the dog"},{id:"swim",label:"out for a swim",seasons:["summer"]},{id:"sled",label:"out sledding",seasons:["winter"]}],f0={run:"trick-or-treating",kids:"trick-or-treating with the kids"},p0=[{id:"ramen",label:"ramen"},{id:"pizza",label:"pizza"},{id:"burger",label:"a burger"},{id:"sushi",label:"sushi"},{id:"tacos",label:"tacos"},{id:"pasta",label:"pasta"},{id:"salad",label:"a salad"},{id:"soup",label:"soup",seasons:["winter"]}],m0=[{id:"pancakes",label:"pancakes"},{id:"waffles",label:"waffles"},{id:"eggs",label:"eggs and bacon"}],g0={id:"roast",label:"a roast"},to={halloween:{id:"pie",label:"pumpkin pie"},summer:{id:"icecream",label:"ice cream"}},Qu=e=>t=>!t.seasons||t.seasons.includes(xr(e)),hn=e=>e.getHours()+e.getMinutes()/60;function Yu(e,t){let n=2166136261;for(const i of`${Qi(e)}|${t}`)n=Math.imul(n^i.charCodeAt(0),16777619);return n=Math.imul(n^n>>>16,2246822507),n=Math.imul(n^n>>>13,3266489909),(n^n>>>16)>>>0}function Jr(e,t,n,i=[]){let l=Yu(t,n)%e.length;for(;i.includes(e[l].id);)l=(l+1)%e.length;return e[l]}const y0=e=>Math.floor(e/6e4)*6e4,Ka=e=>(e.walls||[]).map(t=>t.map(y0)).filter(([t,n])=>tKa(t).some(([n,i])=>n<=e.getTime()&&e.getTime()Ka(e).map(t=>t.map(b0)).filter(([t,n])=>ti<=n&&n({...e,label:`having ${t.label} for ${n}`,dish:t.id});function k0(e,t){var u;if(e.meal==="brunch")return pl(e,Jr(m0,t,"brunch"),"brunch");const n=(u=Yi(t))==null?void 0:u.id,i=e.meal==="dinner"&&(to[n]||to[xr(t)]),l=e.from+Be;if(i&&hn(t)>=l)return{...pl(e,i,"dessert"),from:l};const a=p0.filter(Qu(t)),s=Jr(a,t,"lunch"),o=e.meal==="lunch"?s:n==="yearend"?g0:Jr(a,t,"dinner",[s.id]);return{...pl(e,o,e.meal),...i?{to:l}:{}}}function w0(e,t,n){var f;const i=h=>eo.find(m=>m.id===h),l=(e.to-e.from)/Be,a=h=>(h-e.from)/Be,s=h=>e.from+h*Be,o=[dn,dn+Be].map(a),u=h=>!!Ji(ed(hr(t,s(h)),n),s(h)).pastime,c=[],p=eo.filter(Qu(t)),d=()=>{var m,b;const h=[];for(let x=0;x{const x=(h+b)%2?"kids":"run";c[m]={...i(x),label:f0[x],trick:!0}})}else{t.getDay()===5&&(c[a(dn+Be)]=i("beer"));const h=[["furious","run"],["merged","beer"]].filter(([m])=>n[m]!=null).sort(([m],[b])=>n[m]-n[b]);for(const[m,b]of h){if(o.some(C=>{var y;return((y=c[C])==null?void 0:y.id)===b}))continue;const x=Math.floor(a(n[m]));if(x>=o[0]-1&&x!c[C]&&C>x);w!==void 0&&(c[w]=i(b))}}return d()}function fr(e,t={}){const n=Ji(ed(e,t),e.getHours());if(n.meal)return k0(n,e);if(n.pastime){const o=h0(e),u=Math.floor((hn(e)-o.from)/Be),c=o.from+u*Be;return{...o,...w0(o,e,t)[u],from:c,to:c+Be}}if(n.id!=="code"&&n.id!=="nap")return n;const i=e.getTime(),l=Xu(t).flat(),a=Math.max(hr(e,n.from).getTime(),...l.filter(o=>o<=i)),s=Math.min(hr(e,n.to).getTime(),...l.filter(o=>o>i));return{...n,from:hn(new Date(a)),to:hn(new Date(s))}}function td(e,t={}){const n=e.getTime(),{to:i}=fr(e,t);return Math.min(hr(e,i).getTime(),...Ka(t).flat().filter(l=>l>n))-n}function v0(e,t={}){const n=fr(e,t);let i=e;for(let l=0;l<8;l++){i=new Date(i.getTime()+td(i,t));const a=fr(i,t);if(a.id!==n.id||a.dish!==n.dish)return{at:i,activity:a}}return null}function no(e,t={}){var i;const n=fr(e,t);return`${n.from}|${n.id}|${n.dish||""}|${xr(e)}|${((i=Yi(e))==null?void 0:i.id)||""}|${sd(e)||""}|${Zu(e,t)}`}const _i=e=>String(e).padStart(2,"0");function Qi(e){return`${e.getFullYear()}-${_i(e.getMonth()+1)}-${_i(e.getDate())}`}function nd(e){return`${Qi(e)}T${_i(e.getHours())}:${_i(e.getMinutes())}`}function rd(e,t){const n=Qi(t),i=l=>{const a=/^(\d{4}-\d{2}-\d{2})T(\d{2}):(\d{2})$/.exec(l||"");return(a==null?void 0:a[1])===n?Number(a[2])+Number(a[3])/60:null};return{merged:i(e==null?void 0:e.merged),furious:i(e==null?void 0:e.furious)}}const _0={spring:[245162380984e-5,365242.37404,.05169,-.00411,-57e-5],summer:[245171656767e-5,365241.62603,.00325,.00888,-3e-4],autumn:[245181021715e-5,365242.01767,-.11575,.00337,78e-5],winter:[245190005952e-5,365242.74049,-.06223,-.00823,32e-5]},x0=["spring","summer","autumn","winter"];function S0(e,t){const[n,i,l,a,s]=_0[e],o=(t-2e3)/1e3,u=n+i*o+l*o**2+a*o**3+s*o**4;return new Date((u-24405875e-1)*864e5)}const xi=e=>e.getFullYear()*1e4+(e.getMonth()+1)*100+e.getDate();function id(e){const t=e.getFullYear(),n=xi(e);return[t-1,t].flatMap(i=>x0.map(l=>({season:l,start:S0(l,i)}))).sort((i,l)=>i.start-l.start).filter(i=>xi(i.start)<=n).pop()}function xr(e){return id(e).season}function ld(e){return xi(id(e).start)===xi(e)}const $0={winter:"❄️ The winter solstice arrives — the longest night is upon us",spring:"🌱 The spring equinox arrives — light and dark stand in balance",summer:"☀️ The summer solstice arrives — the sun holds the sky the longest",autumn:"🍂 The autumn equinox arrives — the harvest season begins"},C0=[{id:"halloween",start:[10,24],end:[10,31],headline:"🎃 Halloween week — the veil is at its thinnest"},{id:"yearend",start:[12,18],end:[12,26],headline:"🌟 The year-end wind-down — code freeze, hearts warm"},{id:"newyear",start:[12,31],end:[1,2],headline:"🎆 The year turns — the ledger resets"}];function ad(e){const t=(e.getMonth()+1)*100+e.getDate();return C0.find(({start:i,end:l})=>{const a=i[0]*100+i[1],s=l[0]*100+l[1];return a<=s?t>=a&&t<=s:t>=a||t<=s})||null}function Yi(e){return ld(e)?null:ad(e)}function sd(e){var t;return ld(e)?$0[xr(e)]:((t=ad(e))==null?void 0:t.headline)||null}const vn={calm:{rank:0},grumpy:{rank:1,adverb:"grumpily",why:"is on track to hit its limit"},furious:{rank:2,adverb:"furiously",why:"is burning 🔥"}};function ro(e,t="calm"){var a;const n=e.id==="code"&&((a=vn[t])==null?void 0:a.adverb);if(!n)return e.label;const[i,...l]=e.label.split(" ");return[i,n,...l].join(" ")}function T0(e,t){let n={mood:"calm",account:null,meter:null,atLimit:!1};for(const[i,l]of Object.entries(e||{}))if(!(!(l!=null&&l.available)||!l.meters||Ha(l,t)))for(const[a,s]of Object.entries(l.meters)){if(!s)continue;const o=Ku(s);vn[o].rank>vn[n.mood].rank&&(n={mood:o,account:i,meter:a,atLimit:(s.percent??0)>=100})}return n}function E0({mood:e,meter:t,atLimit:n},i){var s;if(!((s=vn[e])!=null&&s.why)||!t)return null;const l=i?` on account ${i}`:"",a=e==="grumpy"&&n?"has hit its limit":vn[e].why;return`${Ua(t)} usage${l} ${a}`}function Gl(e){if(e===0||e===24)return"midnight";if(e===12)return"noon";const t=Math.round(e%1*60);return`${Math.floor(e)%12||12}${t?`:${String(t).padStart(2,"0")}`:""}${e<12?"am":"pm"}`}function P0(e){return Gl(hn(e))}const V=9,Ht="#d97757",we="#2b1d16",Tn=["...############..","...############..",".################","...############.."],A0=[5,12],od=["....#.#....#.#...",".....#.#..#.#...."];function qt(e){const t=[];return e.forEach((n,i)=>{for(let l=0;lt.key!==e)}function L0(){io||(io=!0,it(()=>{const e=pr.peek(),t=c0({states:lo,parties:e},ce.value,Date.now()/1e3);lo=t.states,(t.parties.length!==e.length||t.parties.some((n,i)=>n.key!==e[i].key))&&(pr.value=t.parties),t.parties.some(n=>!e.some(i=>i.key===n.key))&&bu("merged",nd(new Date))}))}const I0="modulepreload",O0=function(e){return"/"+e},ao={},Zi=function(t,n,i){let l=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const s=document.querySelector("meta[property=csp-nonce]"),o=(s==null?void 0:s.nonce)||(s==null?void 0:s.getAttribute("nonce"));l=Promise.allSettled(n.map(u=>{if(u=O0(u),u in ao)return;ao[u]=!0;const c=u.endsWith(".css"),p=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${p}`))return;const d=document.createElement("link");if(d.rel=c?"stylesheet":I0,c||(d.as="script"),d.crossOrigin="",d.href=u,o&&d.setAttribute("nonce",o),document.head.appendChild(d),c)return new Promise((f,h)=>{d.addEventListener("load",f),d.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${u}`)))})}))}function a(s){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=s,window.dispatchEvent(o),!o.defaultPrevented)throw s}return l.then(s=>{for(const o of s||[])o.status==="rejected"&&a(o.reason);return t().catch(a)})};let Lr=null;function D0(){return Lr||(Lr=Zi(()=>import("./chunks/mermaid.js"),[]).then(e=>{const t=e.default;return t.initialize({startOnLoad:!1,theme:"dark",securityLevel:"strict",suppressErrorRendering:!0}),t}).catch(e=>{throw Lr=null,e})),Lr}let R0=0;function F0({code:e}){const t=te(null),[n,i]=B(null);return j(()=>{let l=!0;return i(null),D0().then(a=>a.render(`md-mermaid-${++R0}`,e)).then(({svg:a})=>{l&&t.current&&(t.current.innerHTML=a)}).catch(a=>{l&&(t.current&&(t.current.innerHTML=""),i(String((a==null?void 0:a.message)||a)))}),()=>{l=!1}},[e]),r("div",{class:"md-mermaid",children:[r("div",{ref:t,class:"md-mermaid-svg"}),n?r("pre",{class:"md-code md-mermaid-err",children:[e,`
+fable / opus 1m / sonnet — pin every spawn (New Tab, + new, spawned workers); the launcher can still override one launch`,children:[r("span",{class:"spawn-acct-label",children:"model"}),Z1.map(n=>r("button",{type:"button",class:`spawn-acct-btn${e===n.id?" is-active":""}`,title:n.id==="auto"?t==null?void 0:t.reason:void 0,onClick:()=>X1(n.id),children:n.id==="auto"&&e==="auto"&&t?`auto → ${t.model??"default"}`:n.label},n.id))]})}const Ku={cols:0,rows:0,shrunkFrom:0},t0=4,n0=(e,t)=>e>0&&t>0?Math.min(e,t):e||t;function r0(e,t){return t>0&&Math.abs(e-t)<=t0?t:e}function i0(e,t,n,i){return{cols:e||n,rows:n0(t,i)}}function l0(e,t,n){return e.cols!==t.cols?e:n>0&&e.rows0&&e.rows>t.rows?{rows:Math.min(e.rows,t.shrunkFrom)}:null}function Vu(e,t){const n=e.shrunkFrom||e.rows;return{cols:t.cols??e.cols,rows:t.rows,shrunkFrom:t.rows0&&e.rows>0&&(Z.cols!==e.cols||Z.rows!==e.rows)&&Z.resize(e.cols,e.rows)}let Ze=null,tt=null;function c0(){de&&de.readyState===WebSocket.OPEN&&de.send(JSON.stringify({type:"reconcile"}))}function u0(){if(!Z)return!0;const e=Z.buffer.active;return e.viewportY>=e.baseY}function Xu(e){Ze=e}let mr=null;function Xs(e){mr=e}const ed=/\b(?:https?|wss?):\/\/[^\s)"'`<>]+/g,d0=new RegExp("(?=t.cols||o<0||o>=t.rows)return null;const c=t.buffer.active,u=c.getLine(c.viewportY+o);if(!u)return null;const h=u.translateToString(!0);for(const p of h.matchAll(ed)){const f=p.index,m=f+p[0].length;if(s>=f&&s{if(n.button!==0)return;const i=f0(n,e);i&&(Xt={url:i,x:n.clientX,y:n.clientY})},to=n=>{if(n.button!==0||!Xt)return;const i=Math.abs(n.clientX-Xt.x),l=Math.abs(n.clientY-Xt.y),{url:a}=Xt;if(Xt=null,i>4||l>4)return;Qi(a)||e.writeln(`\r
+\x1B[31m[periscope: failed to open ${a}]\x1B[0m`)},t.addEventListener("mousedown",eo,!0),t.addEventListener("mouseup",to,!0))}function g0(e){e.registerLinkProvider({provideLinks(t,n){var s;const i=(s=e.buffer.active.getLine(t-1))==null?void 0:s.translateToString(!0);if(!i)return n(void 0);const l=[];function a(o,c){for(const u of i.matchAll(o)){const h=u[0],d=u.index+1,p=d+h.length-1;l.push({text:h,range:{start:{x:d,y:t},end:{x:p,y:t}},activate(f,m){c!=="url"&&(!f.metaKey&&!f.ctrlKey||c==="file"&&mr&&mr(m))},hover(){},leave(){}})}}a(ed,"url"),a(d0,"file"),a(h0,"file"),n(l)}})}function y0(){try{return localStorage.getItem("periscope.noWebgl")==="1"}catch{return!1}}function b0(){var t,n;if(!It)return;const e=(t=It._renderer)==null?void 0:t._gl;try{It.dispose()}catch{}try{(n=e==null?void 0:e.getExtension("WEBGL_lose_context"))==null||n.loseContext()}catch{}It=null}function no(e){var n;if(!((n=document.fonts)!=null&&n.load))return;const t=`${Gu.fontSize}px "${e.face}"`;Promise.all([document.fonts.load(t),document.fonts.load(`bold ${t}`)]).then(()=>{!Z||rn!==e||(Z.options.fontFamily="monospace",Z.options.fontFamily=e.stack,_r())},()=>{})}function k0(){if(!Z){if(tt=document.createElement("div"),tt.className="xterm-host",rn=hr("code"),Z=new Terminal({...Gu,fontFamily:rn.stack,theme:a0,linkHandler:{allowNonHttpProtocols:!0,activate(e,t){if(t.startsWith("file://")){if(!e.metaKey&&!e.ctrlKey||!mr)return;let n=t.slice(7);n.startsWith("localhost/")&&(n=n.slice(9));try{n=decodeURIComponent(n)}catch{}mr(n);return}Qi(t)}}}),Z.open(tt),no(rn),at(()=>{const e=hr("code");e!==rn&&(rn=e,Z.options.fontFamily=e.stack,no(e))}),Z.attachCustomWheelEventHandler(e=>{if(!Ka||!e.deltaY)return!0;const t=p0(e,Z);if(!t)return!0;e.preventDefault();let n=e.deltaY;e.deltaMode===1?n*=t.cellH:e.deltaMode===2&&(n*=t.pageH),n<0!=ln<0&&(ln=0),ln+=n;const i=t.cellH*s0;let l=Math.trunc(ln/i);if(!l)return!1;ln-=l*i,l=Math.max(-8,Math.min(8,l));const a=l<0?64:65;return de&&de.readyState===WebSocket.OPEN&&de.send(`\x1B[<${a};${t.col};${t.row}M`.repeat(Math.abs(l))),!1}),y0())console.warn("[periscope] WebGL renderer disabled via localStorage periscope.noWebgl");else try{It=new WebglAddon.WebglAddon,It.onContextLoss(()=>{b0()}),Z.loadAddon(It)}catch(e){console.warn("[periscope] WebGL terminal renderer unavailable; using the DOM renderer:",e)}kt=new SearchAddon.SearchAddon,Z.loadAddon(kt);try{Z.loadAddon(new Unicode11Addon.Unicode11Addon),Z.unicode.activeVersion="11"}catch(e){console.warn("[periscope] Unicode 11 widths unavailable; emoji will offset the cursor:",e)}g0(Z),m0(Z),pr=new FitAddon.FitAddon,Z.loadAddon(pr),Z.attachCustomKeyEventHandler(e=>{if(e.type!=="keydown")return!0;if(e.key==="Escape"&&e.shiftKey&&!e.metaKey&&!e.ctrlKey&&!e.altKey)return e.preventDefault(),e.stopPropagation(),de&&de.readyState===WebSocket.OPEN&&de.send("\x1B"),!1;if(e.key==="Escape"&&!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&!e.altKey)return!1;if(e.key==="Enter"&&e.shiftKey&&!e.metaKey&&!e.ctrlKey&&!e.altKey)return e.preventDefault(),de&&de.readyState===WebSocket.OPEN&&de.send("\x1B\r"),!1;if(!e.metaKey)return!0;const t=n=>{e.preventDefault(),de&&de.readyState===WebSocket.OPEN&&de.send(n)};switch(e.key){case"Backspace":return t("".repeat(200)),!1;case"Delete":return t("\v"),!1;case"ArrowLeft":return t(""),!1;case"ArrowRight":return t(""),!1;case"r":case"R":return!1;default:return!0}}),Z.onData(e=>{de&&de.readyState===WebSocket.OPEN&&de.send(e)}),Z.onBell(()=>{Ze&&(Ze.classList.add("bell-pulse"),setTimeout(()=>Ze.classList.remove("bell-pulse"),400))})}}function w0(e){ye("terminal.open",{target:e});const t=Z!==null;if(k0(),Ze&&tt.parentElement!==Ze&&Ze.appendChild(tt),t){try{Z.reset()}catch{}Ka=!1,ln=0}if(Z.focus(),Zu(),Ja(),Ot)try{Ot.disconnect()}catch{}Ot=new ResizeObserver(_r),Ze&&Ot.observe(Ze),vi=e,xi=!1,Un=0,Jr=!1,td(e,ct.cols,ct.rows)}function td(e,t=0,n=0){let l=`${location.protocol==="https:"?"wss":"ws"}://${location.host}/ws/pane?${l1(e)}`;t>0&&n>0&&(l+=`&cols=${t}&rows=${n}`,pn=Vu(pn,{cols:t,rows:n}));const a=new WebSocket(l);a.binaryType="arraybuffer",de=a,a.onopen=()=>{Un>0&&Z&&Z.writeln(`\r
+\x1B[32m[periscope: reconnected]\x1B[0m`),Un=0,Jr=!1},a.onmessage=s=>{if(typeof s.data=="string")try{const o=JSON.parse(s.data);o.type==="size"?(Ga=o.cols,Yi=o.rows,Ja(),_r()):o.type==="mouse"&&(Ka=!!o.on)}catch{Z.write(Zs(s.data,Zl))}else Z.write(Zs(new Uint8Array(s.data),Zl))},a.onerror=()=>{},a.onclose=s=>{if(a!==de||xi||!Z||vi!==e)return;Jr||(Z.writeln(`\r
+\x1B[33m[periscope: reconnecting…]\x1B[0m`),Jr=!0);const o=[250,500,1e3,2e3],c=o[Math.min(Un,o.length-1)]||4e3;Un+=1,Lt&&clearTimeout(Lt),Lt=setTimeout(()=>{Lt=null,!(!Z||vi!==e||xi)&&td(e,ct.cols,ct.rows)},c)}}function _r(){Dt&&clearTimeout(Dt),Dt=setTimeout(()=>{if(Dt=null,!Z||!pr||Va||!Zu())return;Ja();const e=l0(ct,pn,Yi);e&&de&&de.readyState===WebSocket.OPEN&&(pn=Vu(pn,e),de.send(JSON.stringify({type:"resize",...e})))},80)}function v0(){if(xi=!0,vi=null,Lt&&(clearTimeout(Lt),Lt=null),pn=Ku,Ga=0,Yi=0,Dt&&(clearTimeout(Dt),Dt=null),Ot){try{Ot.disconnect()}catch{}Ot=null}if(de){try{de.close()}catch{}de=null}tt!=null&&tt.parentElement&&tt.remove()}function ro(e){Z&&Z.writeln(e)}function _i(){if(Z)try{Z.scrollToBottom()}catch{}}function x0(){!Z||!pr||_r()}function _0(){Va=!0}function S0(){Va=!1,_r()}function io(e,t={}){return kt?kt.findNext(e,t):!1}function lo(e,t={}){return kt?kt.findPrevious(e,t):!1}function $0(){kt&&kt.clearDecorations()}let er=null,Qr=null;function C0(e,t,n={}){nd(),Xu(e),Zl=n.agent||null,n.onPaste&&(er=n.onPaste,e.addEventListener("paste",er,!0)),Qr=e,w0(t),requestAnimationFrame(()=>requestAnimationFrame(()=>{x0(),_i()})),setTimeout(_i,300)}function nd(){v0(),Qr&&er&&Qr.removeEventListener("paste",er,!0),er=null,Qr=null,Xu(null)}function rd(e){return typeof e!="string"?null:e.startsWith("pane:")?e.slice(5):null}function T0(e,t){const n=rd(e),i=n?t==null?void 0:t[n]:null;return typeof i=="string"&&i.startsWith("file:")?"document":"terminal"}function E0(e){return(e.metaKey||e.ctrlKey)&&(e.key==="r"||e.key==="R")}function P0(e){return e.repeat||!(e.metaKey||e.ctrlKey)||e.shiftKey||e.code!=="KeyB"?null:e.altKey?"side":"rail"}function M0(e=window){e.addEventListener("keydown",t=>{const n=P0(t);if(n){t.preventDefault(),Yl(n);return}if(E0(t)){if(t.preventDefault(),t.shiftKey){location.reload();return}if(T0(ke.value,Re.value)==="document"){Ss.value=Ss.value+1;return}c0()}})}function Lr(e,t){if(!t||!e)return e;const n={...e};return e.fill&&(n.fill=Ks(e.fill,t)),e.stroke&&(n.stroke=Ks(e.stroke,t)),n}const ao=e=>e!=null&&e.stroke?{stroke:xu,"stroke-width":e["stroke-width"]}:void 0;function Oe({n:e,mood:t,asleep:n,hide:i,tint:l,rest:a,paws:s,seated:o,flush:c}){if(c&&e.mood||e.mood&&e.mood!==t||a&&e.rest||s&&e.arms||o&&e.legs&&!e.keepSeated||(n||i)&&e.role==="glint"||i&&e.role==="eye")return null;if(e.r){const[u,h,d,p]=e.r;return c?r("rect",{class:e.cls,x:u,y:h,width:B(d+.02),height:B(p+.02),...ao(e.a)}):r("rect",{class:e.cls,x:u,y:h,width:d,height:p,...Lr(e.a,l)})}if(e.p)return c?null:r("path",{class:e.cls,d:e.p,...Lr(e.a,l)});if(c){if((n||i)&&e.shut){const[u,h,d,p]=e.shut;return r("rect",{"data-role":"shut",x:u,y:h,width:B(d+.02),height:B(p+.02)})}return r("g",{class:e.anim||e.cls,...ao(e.a),children:e.g.map((u,h)=>r(Oe,{n:u,mood:t,asleep:n,hide:i,rest:a,paws:s,seated:o,flush:!0},h))})}if((n||i)&&e.shut){const[u,h,d,p]=e.shut;return r("rect",{"data-role":"shut",x:u,y:h,width:d,height:p,...Lr(e.g[0].a,l)})}return r("g",{class:e.anim||e.cls,"data-mood":e.mood,"data-role":e.role,...Lr(e.a,l),children:e.g.map((u,h)=>r(Oe,{n:u,mood:t,asleep:n,hide:i,tint:l,rest:a,paws:s,seated:o},h))})}function Zi({sprite:e,mood:t="calm",asleep:n=!1,face:i=null,startle:l=!1,tint:a=0,worn:s=null,holding:o=null,tip:c=null,paws:u=!1,cheer:h=!1,seated:d=!1,stride:p=!1,children:f}){const m=Kg.has(i),k=c??(o&&Ia[o]?Vi(e,o):null),x=!!k||h&&Xg(e),b=t==="furious"&&!n,C=v=>v.role!==void 0||(v.g||[]).some(C),g=p?Wg(e):e.root,y=b?e.root.filter(v=>v.mood==="furious"||C(v)):[],$=b?g.filter(v=>!y.includes(v)):g;return r("g",{class:"critter","data-face":i||void 0,"data-worn":s||void 0,"data-holding":o||void 0,children:[$.map((v,E)=>r(Oe,{n:v,mood:t,asleep:n,hide:m,tint:a,rest:x,paws:u,seated:d},E)),i&&Gg(e,i).map((v,E)=>r(Oe,{n:v,mood:t,tint:a},`face-${E}`)),s&&Yg(e,s).map((v,E)=>r(Oe,{n:v,mood:t,tint:a},`worn-${E}`)),l&&Jg(e,!!k).map((v,E)=>r(Oe,{n:v,mood:t,tint:a},`startle-${E}`)),f,k&&Gl(e,o,k).map((v,E)=>r(Oe,{n:v,mood:t,tint:a},`hold-${E}`)),h&&e1(e).map((v,E)=>r(Oe,{n:v,mood:t,tint:a},`cheer-${E}`)),b&&r("g",{class:"tama-flush",fill:xu,opacity:"0.5",children:[g.map((v,E)=>r(Oe,{n:v,mood:t,hide:m,rest:x,paws:u,seated:d,flush:!0},E)),k&&Gl(e,o,k).map((v,E)=>r(Oe,{n:v,mood:t,flush:!0},`hold-${E}`))]}),b&&y.map((v,E)=>r(Oe,{n:v,mood:t,asleep:n,hide:m,tint:a,rest:x,paws:u,seated:d},`fu-${E}`)),b&&n1(e).map((v,E)=>r(Oe,{n:v,mood:t,tint:a},`teeth-${E}`))]},b?"furious":"calm")}function A0(e){return e==null?"":e>=80?" ctx-hot":e>=60?" ctx-warn":""}function Xl(e){return e.ctx_class&&e.ctx_class!=="none"?` ctx-${e.ctx_class}`:A0(e.context_pct)}const so=["bell","api","done","merged","ctx","ci","update"],id=600;function oo(e,t){const n=Math.floor((t-e)/60);return n<1?"":n<60?` (${n} min)`:` (${Math.floor(n/60)}h ${n%60}m)`}const Nn=(e,t,n={})=>({action:e,pid:t.pid,says:`open ${xe(t)}`,...n});function L0({windows:e=[],alerts:t=[],dismissedAlertIds:n=new Set,dismissedNeedsPids:i=new Set,dismissedReadyPids:l=new Set,selectedPid:a=null,parties:s=[],update:o=null,nowSec:c}){const u=[],h=y=>!y||a==null||String(y.pid)!==String(a),d=e.filter(h),p=new Map(e.map(y=>[String(y.pid),y])),f=Fu(e,t,n,i,c,h);if(f.size){const y=[...f.values()].reduce((E,M)=>M.sincey.api_error);m.length&&u.push({kind:"api",count:m.length,label:"API",phrase:`the Anthropic API is erroring in ${Sn(m.length,"pane")}, not your code`,target:Nn("select",m[0])});const k=new Map;for(const y of e){if(y.ci!=="✗"||!y.pr||y.pr_state&&y.pr_state!=="open")continue;const $=`${y.repo_slug||y.repo_key||""}#${y.pr}`;k.has($)||k.set($,{pr:y.pr,panes:[]}),k.get($).panes.push(y)}const x=[...k.values()].filter(y=>y.panes.every(h));x.length&&u.push({kind:"ci",count:x.length,label:String(x.length),phrase:x.length===1?`PR #${x[0].pr} is failing CI`:`${x.length} PRs failing CI`,target:Nn("select",x[0].panes[0])});const b=Ou(e,t,n,l).filter(y=>h(y.w));if(b.length){const y=b[0],$=y.w?xe(y.w):y.name||"a pane";u.push({kind:"done",count:b.length,label:String(b.length),phrase:b.length===1?`${$} finished`:`${b.length} panes finished`,target:y.kind==="live"?Nn("ready",y.w):{action:"reveal",target:y.target,says:`open ${$}`}})}const C=s.filter(y=>c-y.atXl(y)===" ctx-hot");if(g.length){const y=g.filter(M=>(M.context_pct??0)>=80),$=y.length?y.reduce((M,T)=>T.context_pct>M.context_pct?T:M):g[0],v=y.length?Math.round($.context_pct):null,E=g.length>1?`${g.length} panes worth compacting`:v!=null?`${xe($)} is running out of context (${v}%)`:`${xe($)} is costly to keep carrying${$.ctx_hint?`: ${$.ctx_hint}`:""}`;u.push({kind:"ctx",count:g.length,label:v!=null?`${v}%`:String(g.length),pct:v,cost:v==null,phrase:E,target:Nn("select",$)})}return(o==null?void 0:o.behind)>0&&!o.running&&u.push({kind:"update",count:1,label:"new",phrase:`periscope ${o.target} is out`,target:{action:"update",says:"see the update"}}),u.sort((y,$)=>so.indexOf(y.kind)-so.indexOf($.kind))}function I0(e){return e.slice(1).reduce((t,n)=>t+n.count,0)}const O0=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function D0(e,t){if(!e)return{day:null,time:"later"};const n=new Date(e*1e3),i=n.getHours(),l=n.getMinutes(),a=`${i%12||12}${l?`:${String(l).padStart(2,"0")}`:""}${i<12?"am":"pm"}`;return{day:e-t>20*3600?O0[n.getDay()]:null,time:a}}function R0({day:e,time:t}){return`every account is at its limit until ${e?`${e} `:""}${t}`}const F0=new Set(["done","merged","ci","api","ctx"]);function ld(e,t){const n=e==="code";return{atDesk:n,moodShown:n&&!t,showsPanes:n&&!F0.has(t)}}function N0({states:e,parties:t},n,i){const l={...e},a=t.filter(s=>i-s.atu.key===c)&&a.push({key:c,pid:s.pid,pr:s.pr,at:i})}return{states:l,parties:a}}const B0=600;function Qa(e,t){return!!(e!=null&&e.fetched_at)&&t-e.fetched_at>B0}function Ya(e){const t=[e==null?void 0:e.projected_percent,e==null?void 0:e.projected_recent].filter(i=>i!=null);if(!t.length)return!1;const n=Math.max(...t);return n>(e.percent??0)&&n>=100}function ad(e){return e!=null&&e.hot?"furious":Ya(e)?"grumpy":"calm"}const z0={session:"session",week_all:"week",week_opus:"opus",week_sonnet:"sonnet"};function Za(e){return z0[e]||e.replace(/^week_/,"")}const sd=[{from:0,to:7,id:"sleep",label:"sleeping"},{from:7,to:9,id:"coffee",label:"having coffee"},{from:9,to:10,id:"code",label:"coding with a coffee",coffee:!0},{from:10,to:12,id:"code",label:"coding"},{from:12,to:13,id:"eat",meal:"lunch"},{from:13,to:17,id:"code",label:"coding"},{from:17,to:18,pastime:!0},{from:18,to:19,id:"eat",meal:"dinner"},{from:19,to:21,id:"read",label:"reading"},{from:21,to:24,id:"sleep",label:"sleeping"}],od=[{from:0,to:9,id:"sleep",label:"sleeping"},{from:9,to:11,id:"eat",meal:"brunch"},{from:11,to:18,pastime:!0},{from:18,to:19,id:"eat",meal:"dinner"},{from:19,to:21,id:"read",label:"reading"},{from:21,to:24,id:"sleep",label:"sleeping"}],mn=17,co=16,Be=.5,Xa=sd.map(e=>{const t=e.id==="code"?{...e,id:"nap",label:"napping at the desk"}:e;return t.to===mn?{...t,to:co}:t.from===mn?{...t,from:co}:t}),cd=e=>e.getDay()===0||e.getDay()===6,Xi=(e,t)=>e.find(n=>t>=n.from&&tXi(cd(e)?od:Xa,mn),uo=[{id:"run",label:"out for a run"},{id:"cycle",label:"out cycling",seasons:["spring","summer","autumn"]},{id:"music",label:"practicing bass"},{id:"beer",label:"having a beer with friends"},{id:"kids",label:"spending time with the kids"},{id:"game",label:"playing video games"},{id:"garden",label:"gardening",seasons:["spring","summer"]},{id:"cook",label:"cooking"},{id:"dog",label:"walking the dog"},{id:"swim",label:"out for a swim",seasons:["summer"]},{id:"sled",label:"out sledding",seasons:["winter"]}],H0={run:"trick-or-treating",kids:"trick-or-treating with the kids"},q0=[{id:"ramen",label:"ramen"},{id:"pizza",label:"pizza"},{id:"burger",label:"a burger"},{id:"sushi",label:"sushi"},{id:"tacos",label:"tacos"},{id:"pasta",label:"pasta"},{id:"salad",label:"a salad"},{id:"soup",label:"soup",seasons:["winter"]}],U0=[{id:"pancakes",label:"pancakes"},{id:"waffles",label:"waffles"},{id:"eggs",label:"eggs and bacon"}],W0={id:"roast",label:"a roast"},ho={halloween:{id:"pie",label:"pumpkin pie"},summer:{id:"icecream",label:"ice cream"}},ud=e=>t=>!t.seasons||t.seasons.includes(Sr(e)),gn=e=>e.getHours()+e.getMinutes()/60;function dd(e,t){let n=2166136261;for(const i of`${el(e)}|${t}`)n=Math.imul(n^i.charCodeAt(0),16777619);return n=Math.imul(n^n>>>16,2246822507),n=Math.imul(n^n>>>13,3266489909),(n^n>>>16)>>>0}function Yr(e,t,n,i=[]){let l=dd(t,n)%e.length;for(;i.includes(e[l].id);)l=(l+1)%e.length;return e[l]}const K0=e=>Math.floor(e/6e4)*6e4,es=e=>(e.walls||[]).map(t=>t.map(K0)).filter(([t,n])=>tes(t).some(([n,i])=>n<=e.getTime()&&e.getTime()es(e).map(t=>t.map(V0)).filter(([t,n])=>ti<=n&&n({...e,label:`having ${t.label} for ${n}`,dish:t.id});function G0(e,t){var c;if(e.meal==="brunch")return bl(e,Yr(U0,t,"brunch"),"brunch");const n=(c=tl(t))==null?void 0:c.id,i=e.meal==="dinner"&&(ho[n]||ho[Sr(t)]),l=e.from+Be;if(i&&gn(t)>=l)return{...bl(e,i,"dessert"),from:l};const a=q0.filter(ud(t)),s=Yr(a,t,"lunch"),o=e.meal==="lunch"?s:n==="yearend"?W0:Yr(a,t,"dinner",[s.id]);return{...bl(e,o,e.meal),...i?{to:l}:{}}}function J0(e,t,n){var p;const i=f=>uo.find(m=>m.id===f),l=(e.to-e.from)/Be,a=f=>(f-e.from)/Be,s=f=>e.from+f*Be,o=[mn,mn+Be].map(a),c=f=>!!Xi(pd(gr(t,s(f)),n),s(f)).pastime,u=[],h=uo.filter(ud(t)),d=()=>{var m,k;const f=[];for(let x=0;x{const x=(f+k)%2?"kids":"run";u[m]={...i(x),label:H0[x],trick:!0}})}else{t.getDay()===5&&(u[a(mn+Be)]=i("beer"));const f=[["furious","run"],["merged","beer"]].filter(([m])=>n[m]!=null).sort(([m],[k])=>n[m]-n[k]);for(const[m,k]of f){if(o.some(C=>{var g;return((g=u[C])==null?void 0:g.id)===k}))continue;const x=Math.floor(a(n[m]));if(x>=o[0]-1&&x!u[C]&&C>x);b!==void 0&&(u[b]=i(k))}}return d()}function yr(e,t={}){const n=Xi(pd(e,t),e.getHours());if(n.meal)return G0(n,e);if(n.pastime){const o=j0(e),c=Math.floor((gn(e)-o.from)/Be),u=o.from+c*Be;return{...o,...J0(o,e,t)[c],from:u,to:u+Be}}if(n.id!=="code"&&n.id!=="nap")return n;const i=e.getTime(),l=fd(t).flat(),a=Math.max(gr(e,n.from).getTime(),...l.filter(o=>o<=i)),s=Math.min(gr(e,n.to).getTime(),...l.filter(o=>o>i));return{...n,from:gn(new Date(a)),to:gn(new Date(s))}}function md(e,t={}){const n=e.getTime(),{to:i}=yr(e,t);return Math.min(gr(e,i).getTime(),...es(t).flat().filter(l=>l>n))-n}function Q0(e,t={}){const n=yr(e,t);let i=e;for(let l=0;l<8;l++){i=new Date(i.getTime()+md(i,t));const a=yr(i,t);if(a.id!==n.id||a.dish!==n.dish)return{at:i,activity:a}}return null}function fo(e,t={}){var i;const n=yr(e,t);return`${n.from}|${n.id}|${n.dish||""}|${Sr(e)}|${((i=tl(e))==null?void 0:i.id)||""}|${vd(e)||""}|${hd(e,t)}`}const Si=e=>String(e).padStart(2,"0");function el(e){return`${e.getFullYear()}-${Si(e.getMonth()+1)}-${Si(e.getDate())}`}function gd(e){return`${el(e)}T${Si(e.getHours())}:${Si(e.getMinutes())}`}function yd(e,t){const n=el(t),i=l=>{const a=/^(\d{4}-\d{2}-\d{2})T(\d{2}):(\d{2})$/.exec(l||"");return(a==null?void 0:a[1])===n?Number(a[2])+Number(a[3])/60:null};return{merged:i(e==null?void 0:e.merged),furious:i(e==null?void 0:e.furious)}}const Y0={spring:[245162380984e-5,365242.37404,.05169,-.00411,-57e-5],summer:[245171656767e-5,365241.62603,.00325,.00888,-3e-4],autumn:[245181021715e-5,365242.01767,-.11575,.00337,78e-5],winter:[245190005952e-5,365242.74049,-.06223,-.00823,32e-5]},Z0=["spring","summer","autumn","winter"];function X0(e,t){const[n,i,l,a,s]=Y0[e],o=(t-2e3)/1e3,c=n+i*o+l*o**2+a*o**3+s*o**4;return new Date((c-24405875e-1)*864e5)}const $i=e=>e.getFullYear()*1e4+(e.getMonth()+1)*100+e.getDate();function bd(e){const t=e.getFullYear(),n=$i(e);return[t-1,t].flatMap(i=>Z0.map(l=>({season:l,start:X0(l,i)}))).sort((i,l)=>i.start-l.start).filter(i=>$i(i.start)<=n).pop()}function Sr(e){return bd(e).season}function kd(e){return $i(bd(e).start)===$i(e)}const ey={winter:"❄️ The winter solstice arrives — the longest night is upon us",spring:"🌱 The spring equinox arrives — light and dark stand in balance",summer:"☀️ The summer solstice arrives — the sun holds the sky the longest",autumn:"🍂 The autumn equinox arrives — the harvest season begins"},ty=[{id:"halloween",start:[10,24],end:[10,31],headline:"🎃 Halloween week — the veil is at its thinnest"},{id:"yearend",start:[12,18],end:[12,26],headline:"🌟 The year-end wind-down — code freeze, hearts warm"},{id:"newyear",start:[12,31],end:[1,2],headline:"🎆 The year turns — the ledger resets"}];function wd(e){const t=(e.getMonth()+1)*100+e.getDate();return ty.find(({start:i,end:l})=>{const a=i[0]*100+i[1],s=l[0]*100+l[1];return a<=s?t>=a&&t<=s:t>=a||t<=s})||null}function tl(e){return kd(e)?null:wd(e)}function vd(e){var t;return kd(e)?ey[Sr(e)]:((t=wd(e))==null?void 0:t.headline)||null}const $n={calm:{rank:0},grumpy:{rank:1,adverb:"grumpily",why:"is on track to hit its limit"},furious:{rank:2,adverb:"furiously",why:"is burning 🔥"}};function po(e,t="calm"){var a;const n=e.id==="code"&&((a=$n[t])==null?void 0:a.adverb);if(!n)return e.label;const[i,...l]=e.label.split(" ");return[i,n,...l].join(" ")}function ny(e,t){let n={mood:"calm",account:null,meter:null,atLimit:!1};for(const[i,l]of Object.entries(e||{}))if(!(!(l!=null&&l.available)||!l.meters||Qa(l,t)))for(const[a,s]of Object.entries(l.meters)){if(!s)continue;const o=ad(s);$n[o].rank>$n[n.mood].rank&&(n={mood:o,account:i,meter:a,atLimit:(s.percent??0)>=100})}return n}function ry({mood:e,meter:t,atLimit:n},i){var s;if(!((s=$n[e])!=null&&s.why)||!t)return null;const l=i?` on account ${i}`:"",a=e==="grumpy"&&n?"has hit its limit":$n[e].why;return`${Za(t)} usage${l} ${a}`}function ea(e){if(e===0||e===24)return"midnight";if(e===12)return"noon";const t=Math.round(e%1*60);return`${Math.floor(e)%12||12}${t?`:${String(t).padStart(2,"0")}`:""}${e<12?"am":"pm"}`}function iy(e){return ea(gn(e))}const V=9,Wt="#d97757",we="#2b1d16",Ln=["...############..","...############..",".################","...############.."],ly=[5,12],xd=["....#.#....#.#...",".....#.#..#.#...."];function Kt(e){const t=[];return e.forEach((n,i)=>{for(let l=0;lt.key!==e)}function sy(){mo||(mo=!0,at(()=>{const e=br.peek(),t=N0({states:go,parties:e},ce.value,Date.now()/1e3);go=t.states,(t.parties.length!==e.length||t.parties.some((n,i)=>n.key!==e[i].key))&&(br.value=t.parties),t.parties.some(n=>!e.some(i=>i.key===n.key))&&Lu("merged",gd(new Date))}))}const oy="modulepreload",cy=function(e){return"/"+e},yo={},nl=function(t,n,i){let l=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const s=document.querySelector("meta[property=csp-nonce]"),o=(s==null?void 0:s.nonce)||(s==null?void 0:s.getAttribute("nonce"));l=Promise.allSettled(n.map(c=>{if(c=cy(c),c in yo)return;yo[c]=!0;const u=c.endsWith(".css"),h=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${h}`))return;const d=document.createElement("link");if(d.rel=u?"stylesheet":oy,u||(d.as="script"),d.crossOrigin="",d.href=c,o&&d.setAttribute("nonce",o),document.head.appendChild(d),u)return new Promise((p,f)=>{d.addEventListener("load",p),d.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${c}`)))})}))}function a(s){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=s,window.dispatchEvent(o),!o.defaultPrevented)throw s}return l.then(s=>{for(const o of s||[])o.status==="rejected"&&a(o.reason);return t().catch(a)})},uy=["--accent","--s-done","--s-working","--s-needs","--effort","--worktree","--s-shell","--s-danger"];function dy({color:e,font:t}){const n=e("--bg-1"),i=e("--bg-1-hi"),l=e("--fg-2"),a=e("--fg-0"),s=e("--fg-1"),o=e("--bg-0"),c=uy.map(e),u={darkMode:!0,fontFamily:t,fontSize:"14px",background:n,primaryColor:e("--bg-2"),primaryTextColor:a,nodeTextColor:a,titleColor:a,primaryBorderColor:l,lineColor:l,clusterBorder:l,secondaryColor:i,clusterBkg:i,tertiaryColor:n,edgeLabelBackground:n,textColor:s,pieSectionTextColor:o,pieTitleTextColor:a,pieLegendTextColor:s,pieStrokeColor:n,pieOuterStrokeColor:l,pieOpacity:"1",noteBkgColor:i,noteTextColor:a,noteBorderColor:l,sequenceNumberColor:n,altSectionBkgColor:i,taskTextDarkColor:n,activeTaskBkgColor:c[0],critBkgColor:e("--bg-2"),critBorderColor:e("--s-danger"),excludeBkgColor:i};for(let h=0;h<12;h++)u[`pie${h+1}`]=c[h%c.length],u[`cScale${h}`]=c[h%c.length],u[`cScaleLabel${h}`]=o;for(let h=0;hgetComputedStyle(document.documentElement).getPropertyValue(e).trim();let $t=null;function hy(e){const t=ts(e);if(!t)return;$t||($t=document.createElement("canvas").getContext("2d",{willReadFrequently:!0})),$t.clearRect(0,0,1,1),$t.fillStyle="#000",$t.fillStyle=t,$t.fillRect(0,0,1,1);const[n,i,l]=$t.getImageData(0,0,1,1).data;return`#${[n,i,l].map(a=>a.toString(16).padStart(2,"0")).join("")}`}let Ir=null,_d=null;function Sd(e,t){_d=t,e.initialize({...dy({color:hy,font:t}),startOnLoad:!1,securityLevel:"strict",suppressErrorRendering:!0})}function fy(){return Ir||(Ir=nl(()=>import("./chunks/mermaid.js"),[]).then(e=>{const t=e.default;return Sd(t,ts("--sans")),t}).catch(e=>{throw Ir=null,e})),Ir}let py=0;async function $d(e){var i,l;const t=await fy(),n=ts("--sans");try{await Promise.race([(l=(i=document.fonts)==null?void 0:i.load)==null?void 0:l.call(i,`14px ${n}`),new Promise(a=>setTimeout(a,1500))])}catch{}return n!==_d&&Sd(t,n),t.render(`md-mermaid-${++py}`,e)}const Ci=q(null);function Cd(e){Ci.value={...e,from:typeof document>"u"?null:document.activeElement}}function kl(){var t,n;const e=(t=Ci.value)==null?void 0:t.from;Ci.value=null,e!=null&&e.isConnected&&((n=e.focus)==null||n.call(e,{preventScroll:!0}))}function my(e,t,n){return e===n?t:n}function gy(e,t,n){return e&&t&&n}function yy(){const e=Ci.value,t=J(null),n=J(null),i=J(null),l=J(!1),a=J(!1);if(We(kl,!!e),H(()=>{var d;if(!e||((d=t.current)==null||d.focus(),e.kind!=="svg"))return;let h=!0;return $d(e.code).then(({svg:p})=>{var k;if(!h||!n.current)return;n.current.innerHTML=p;const f=n.current.querySelector("svg"),m=(k=f==null?void 0:f.viewBox)==null?void 0:k.baseVal;f&&(m!=null&&m.width)&&(f.style.maxWidth="none",f.setAttribute("width",String(Math.round(m.width))),f.setAttribute("height",String(Math.round(m.height))))}).catch(()=>{}),()=>{h=!1}},[e]),!e)return null;const s=h=>{l.current=h.target===h.currentTarget},o=h=>{a.current=h.target===h.currentTarget},c=h=>{gy(l.current,a.current,h.target===h.currentTarget)&&kl()},u=h=>{var d;h.key==="Tab"&&(h.preventDefault(),(d=my(document.activeElement,t.current,i.current))==null||d.focus())};return r("div",{class:"lightbox",role:"dialog","aria-modal":"true","aria-label":e.kind==="img"?"image, full size":"diagram, full size",onKeyDown:u,children:[r("button",{type:"button",class:"lightbox-close",ref:i,"aria-label":"close",onClick:kl,children:"✕"}),r("div",{class:"lightbox-body",ref:t,tabIndex:-1,onMouseDown:s,onMouseUp:o,onClick:c,children:e.kind==="img"?r("img",{src:e.src,alt:e.alt}):r("div",{class:"lightbox-svg",ref:n})})]})}const by=.75;function Td({code:e,zoom:t=!1,label:n}){const i=J(null),[l,a]=N(null),[s,o]=N(!1);H(()=>{let h=!0;return a(null),o(!1),$d(e).then(({svg:d})=>{var p;if(!(!h||!i.current)){if(i.current.innerHTML=d,t){const f=i.current.querySelector("svg"),m=(p=f==null?void 0:f.viewBox)==null?void 0:p.baseVal;(m==null?void 0:m.width)>0&&(f.style.minWidth=`${Math.round(m.width*by)}px`)}o(!0)}}).catch(d=>{h&&(i.current&&(i.current.innerHTML=""),a(String((d==null?void 0:d.message)||d)))}),()=>{h=!1}},[e,t]);const c=()=>Cd({kind:"svg",code:e}),u=t&&!l;return r("div",{class:"md-mermaid",children:[r("div",{ref:i,class:`md-mermaid-svg${u?" is-zoomable":""}`,onClick:u?h=>{var d,p;(p=(d=h.target).closest)!=null&&p.call(d,"a")||c()}:void 0}),u?r("button",{type:"button",class:"md-mermaid-zoom",disabled:!s,"aria-label":n?`open diagram full size: ${n}`:"open diagram full size",title:"open full size",onClick:c,children:"⤢"}):null,l?r("pre",{class:"md-code md-mermaid-err",children:[e,`
-`,n]}):null]})}const cd=/^([a-z][a-z0-9+.-]*:|\/|#)/i;function so(e,t){return!t.resolveUrl||cd.test(e)?e:t.resolveUrl(e)}function ze(e,t){return(e||[]).map((n,i)=>N0(n,t,i))}function N0(e,t,n){switch(e.type){case"text":{const i=t.softBreaks==="br"&&e.value.includes(`
+`,l]}):null]})}const Ed=/^([a-z][a-z0-9+.-]*:|\/|#)/i;function bo(e,t){return!t.resolveUrl||Ed.test(e)?e:t.resolveUrl(e)}function ze(e,t){return(e||[]).map((n,i)=>ky(n,t,i))}function ky(e,t,n){switch(e.type){case"text":{const i=t.softBreaks==="br"&&e.value.includes(`
`)?e.value.split(`
-`):[e.value],l=[];return i.forEach((a,s)=>{if(s&&l.push(r("br",{},`${n}b${s}`)),!t.cite){l.push(a);return}tg(a).forEach((o,u)=>{if(typeof o=="string"){l.push(o);return}const c=t.cite(o);l.push(c==null?o.raw:r("span",{children:c},`${n}c${s}-${u}`))})}),l.length===1?l[0]:l}case"inlineCode":{const i=t.cite?ji(e.value):null,l=i?t.cite(i):null;return l!=null?r("span",{children:l},n):r("code",{class:"md-icode",children:e.value},n)}case"strong":return r("strong",{children:ze(e.children,t)},n);case"emphasis":return r("em",{children:ze(e.children,t)},n);case"delete":return r("del",{children:ze(e.children,t)},n);case"link":return r("a",{class:"md-link",href:so(e.url,t),target:"_blank",rel:"noopener",children:ze(e.children,{...t,cite:null})},n);case"image":return!cd.test(e.url)&&!t.resolveUrl?e.alt||e.url:r("img",{class:"md-img",src:so(e.url,t),alt:e.alt||""},n);case"break":return r("br",{},n);case"html":return e.value;case"footnoteReference":return r("sup",{children:["[",e.label||e.identifier,"]"]},n);default:return e.children?ze(e.children,t):e.value??null}}function B0(e,t,n){const i=(e.children||[]).map((l,a)=>l.type==="paragraph"&&!e.spread?ze(l.children,t):Va(l,t,a));return e.checked==null?r("li",{children:i},n):r("li",{class:"md-task",children:[r("input",{type:"checkbox",checked:e.checked,disabled:!0})," ",i]},n)}function z0(e,t,n){const i=e.align||[],[l,...a]=e.children,s=l.children.length,o=c=>i[c]?`text-align:${i[c]}`:void 0,u=c=>Array.from({length:s},(p,d)=>c.children[d]??null);return r("table",{class:"md-table",children:[r("thead",{children:r("tr",{children:u(l).map((c,p)=>r("th",{style:o(p),children:c?ze(c.children,t):""},p))})}),r("tbody",{children:a.map((c,p)=>r("tr",{children:u(c).map((d,f)=>r("td",{style:o(f),children:d?ze(d.children,t):""},f))},p))})]},n)}function Va(e,t,n,i){switch(e.type){case"paragraph":return r("p",{class:"md-p",children:ze(e.children,t)},n);case"heading":{const a=`h${t.demote?Math.min(e.depth+2,6):e.depth}`;return r(a,{class:`md-h md-h${e.depth}`,children:ze(e.children,t)},n)}case"code":return t.mermaid&&e.lang==="mermaid"?r(F0,{code:e.value},n):r("pre",{class:"md-code",children:r("code",{children:t.highlight&&e.lang?t.highlight(e.value,e.lang):e.value})},n);case"blockquote":{const l=t.meta&&(i==null?void 0:i.type)==="heading"?jl(e,t.src):null;return l?r("div",{class:"md-meta",children:l.map(([a,s],o)=>r("span",{class:"md-meta-kv","data-key":a,children:[r("span",{class:"md-meta-k",children:a}),r("span",{class:"md-meta-v",children:a==="refs"&&t.cite?lu(s).map((u,c)=>{const p=ji(u),d=p?t.cite(p):null;return r("span",{children:[c?", ":"",d??u]},c)}):s})]},o))},n):r("blockquote",{class:"md-quote",children:(e.children||[]).map((a,s)=>Va(a,t,s))},n)}case"list":{const l=(e.children||[]).map((a,s)=>B0(a,t,s));return e.ordered?r("ol",{class:"md-ol",start:e.start!==1?e.start:void 0,children:l},n):r("ul",{class:"md-ul",children:l},n)}case"thematicBreak":return r("hr",{class:"md-hr"},n);case"table":return z0(e,t,n);case"html":return r("p",{class:"md-p",children:e.value},n);default:return e.children?r("p",{class:"md-p",children:ze(e.children,t)},n):e.value?r("p",{class:"md-p",children:e.value},n):null}}function mr(e,t={}){const n=String(e||""),i={src:n,demote:t.demote??!0,softBreaks:t.softBreaks??"br",highlight:t.highlight??null,resolveUrl:t.resolveUrl??null,meta:t.meta??!1,cite:t.cite??null,mermaid:t.mermaid??!1},l=Wc(n,{extensions:[iu()],mdastExtensions:[Jc()]});return l.children.map((a,s)=>Va(a,i,s,l.children[s-1]))}const j0=2e3,Qr=H(!1);let Jl=!1;function H0({focus:e=!1}={}){Jl=e,Qr.value=!0}const q0=12e4;function U0({releases:e}){return e?e==="error"?r("div",{class:"update-note-muted",children:"couldn't load the release notes"}):e.length?e.map(t=>r("div",{class:"update-release",children:[r("div",{class:"update-release-head",children:t.heading}),r("div",{class:"update-release-body",children:mr(t.body)})]},t.heading)):r("div",{class:"update-note-muted",children:"no release notes recorded — CHANGELOG.md was unreadable on the last check"}):r("div",{class:"update-note-muted",children:"loading…"})}function W0(){const[e,t]=B(!1),[n,i]=B(null),l=Qr.value,a=M=>{Qr.value=M},[s,o]=B(null),u=te(null),c=te(null),p=br(()=>{Qr.value=!1},[]);Fi(u,l,p);const d=ma.value,f=(d==null?void 0:d.behind)||0,h=(d==null?void 0:d.ahead)||0;if(j(()=>{f||a(!1)},[f]),j(()=>{var T;if(!l)return;let M=!0;return o(null),Jl&&(Jl=!1,(T=c.current)==null||T.focus()),fetch("/api/update/status").then(async S=>{M&&o(S.ok?(await S.json()).releases||[]:"error")}).catch(()=>{M&&o("error")}),()=>{M=!1}},[l]),!d||!f&&!d.running&&!e&&!n)return null;function m(){a(!l)}async function b(){const M=Date.now()+q0;for(;Date.now()setTimeout(S,j0));let T;try{const S=await fetch("/api/update/status");if(!S.ok)continue;T=await S.json()}catch{continue}if(!T.running)return T.behind===0?t(!1):(t(!1),i((T.log||[]).filter(Boolean).slice(-3).join(`
-`)||"update exited without applying — see ~/.config/periscope/update.log"))}t(!1),i("no response for 2 minutes — periscope may not have come back up.\ncheck `bin/periscope status` and ~/.config/periscope/update.log")}async function x(){if(a(!1),i(null),t(!0),!await ie("update","/api/update",{method:"POST"}))return t(!1);b()}const w=e||d.running,C=d.behind,y=d.target,g=`${y} is out — ${wn(C,"commit")} newer than this checkout`,$=C>0&&h>0,v=`${wn(h,"local commit")} not in ${y} — the update's fast-forward will refuse. Get them into a release, or off this checkout's main.`,E=n?`update failed:
-${n}`:w?"updating — periscope will restart itself":$?`${g}, but ${v}`:`${g} — click to see what's new`;return r("div",{class:"pill-dd",ref:u,children:[r("button",{type:"button",class:`update-pill${w?" is-running":""}${n?" is-error":""}`,title:E,"aria-haspopup":"dialog","aria-expanded":l?"true":"false",disabled:w,onClick:w?void 0:m,children:w?"updating…":n?"⚠ update failed":`↑ ${y}${$?" ⚠":""}`}),r("div",{class:"tb-dd-menu update-menu",role:"dialog",hidden:!l,children:[r("div",{class:"update-menu-head",children:g}),$&&r("div",{class:"update-menu-warn",children:v}),n&&r("pre",{class:"update-menu-error",children:n}),r("div",{class:"update-notes",children:r(U0,{releases:s})}),r("button",{type:"button",class:"update-pill update-menu-go",ref:c,onClick:x,children:[n?"retry — ":"","pull, re-provision and restart"]})]})]})}function K0(e){const t=e.pid!=null&&(ce.value||[]).find(n=>String(n.pid)===String(e.pid))||null;if(e.action==="update")return H0({focus:!0});if(e.action==="needs")return $u(t);if(e.action==="ready")return Tu(t);if(e.action==="reveal")return jt(e.target);e.action==="party"&&M0(e.key),at(t)}const V0=250;function G0({target:e,pet:t,act:n=K0,schedule:i=setTimeout,cancel:l=clearTimeout}){let a=null;return{onClick(s){if(s.detail>1)return;const o=e();if(!o)return t();if(o.action==="update"){a=i(()=>n(o),V0);return}n(o)},onDblClick(){l(a),t()},dispose(){l(a)}}}const J0="geometricPrecision";function nn({x:e,y:t}){return r("g",{fill:"var(--fg-3)",children:[r("rect",{class:"tama-steam",x:e,y:t,width:"0.5",height:"1.6"}),r("rect",{class:"tama-steam tama-steam2",x:e+1.2,y:t-.6,width:"0.5",height:"1.6"})]})}function Ir({y:e=18.2}){return r("rect",{x:"25.8",y:e,width:"7.6",height:"0.8",rx:"0.4",fill:"#e8e2d4"})}const oo={ramen:()=>r("g",{children:[r("line",{x1:"29.2",y1:"10.4",x2:"28.1",y2:"15.6",stroke:"#b07a4f","stroke-width":"0.45"}),r("line",{x1:"30.4",y1:"10.7",x2:"29",y2:"15.6",stroke:"#b07a4f","stroke-width":"0.45"}),r("rect",{x:"26.8",y:"15.3",width:"4.9",height:"1.5",rx:"0.7",fill:"#f8f4ea"}),r("rect",{x:"26",y:"16.2",width:"6.5",height:"2.8",rx:"1.2",fill:"#e8e2d4"}),r("rect",{class:"tama-steam",x:"31.6",y:"12.2",width:"0.5",height:"1.6",fill:"var(--fg-3)"})]}),pizza:()=>r("g",{children:[r("rect",{x:"26",y:"12",width:"7.4",height:"5.4",fill:"#d8b384"}),r("rect",{x:"26.5",y:"12.5",width:"6.4",height:"4.4",fill:"#c9a06b"}),r("rect",{x:"25.6",y:"17.2",width:"8.2",height:"1.8",fill:"#c49a6c"}),r("ellipse",{cx:"29.7",cy:"17.3",rx:"3.6",ry:"1.1",fill:"#e0a94a"}),r("ellipse",{cx:"29.7",cy:"17.3",rx:"3",ry:"0.8",fill:"#f2c94c"}),r("path",{d:"M29.7 17.3 L33.4 17.1 L32.6 18.2 Z",fill:"#c49a6c"}),r("g",{fill:"#c0392b",children:[r("circle",{cx:"28",cy:"17.2",r:"0.35"}),r("circle",{cx:"29.6",cy:"16.9",r:"0.35"}),r("circle",{cx:"29.2",cy:"17.7",r:"0.35"}),r("circle",{cx:"31",cy:"16.9",r:"0.3"})]}),r(nn,{x:28.6,y:13.6})]}),burger:()=>r("g",{children:[r(Ir,{}),r("rect",{x:"27",y:"17.2",width:"5",height:"1",rx:"0.4",fill:"#d9913f"}),r("rect",{x:"26.8",y:"16.2",width:"5.4",height:"1.1",rx:"0.5",fill:"#6b3a22"}),r("path",{d:"M26.9 15.8 H32.1 V16.3 H29.2 L28.6 17 L28 16.3 H26.9 Z",fill:"#f2c94c"}),r("rect",{x:"27.1",y:"15.3",width:"4.8",height:"0.5",fill:"#e05252"}),r("rect",{x:"26.7",y:"14.9",width:"5.6",height:"0.5",rx:"0.25",fill:"#6fae5a"}),r("path",{d:"M26.9 15 Q26.9 12.4 29.5 12.4 Q32.1 12.4 32.1 15 Z",fill:"#e0a04a"}),r("g",{fill:"#f8f0d8",children:[r("rect",{x:"28.2",y:"13.4",width:"0.4",height:"0.25"}),r("rect",{x:"29.6",y:"13",width:"0.4",height:"0.25"}),r("rect",{x:"30.8",y:"13.6",width:"0.4",height:"0.25"})]})]}),sushi:()=>r("g",{children:[r("rect",{x:"25.4",y:"17.4",width:"8.4",height:"0.9",fill:"#c8955c"}),r("g",{fill:"#a5743f",children:[r("rect",{x:"26.2",y:"18.3",width:"0.8",height:"0.7"}),r("rect",{x:"32.2",y:"18.3",width:"0.8",height:"0.7"})]}),[[26,"#f28c6b"],[28.7,"#d64550"]].map(([e,t])=>r("g",{children:[r("rect",{x:e,y:"16.2",width:"2.4",height:"1.2",rx:"0.5",fill:"#f6f3ec"}),r("rect",{x:e-.2,y:"15.5",width:"2.8",height:"0.9",rx:"0.45",fill:t}),r("rect",{x:e+.7,y:"15.6",width:"0.15",height:"0.7",fill:"#fbd0c0",opacity:"0.8"}),r("rect",{x:e+1.5,y:"15.6",width:"0.15",height:"0.7",fill:"#fbd0c0",opacity:"0.8"})]},e)),r("rect",{x:"31.4",y:"15.6",width:"1.9",height:"1.8",rx:"0.3",fill:"#1f2a1f"}),r("rect",{x:"31.7",y:"15.9",width:"1.3",height:"1.2",fill:"#f6f3ec"}),r("rect",{x:"32.1",y:"16.25",width:"0.5",height:"0.5",fill:"#f28c6b"})]}),tacos:()=>r("g",{children:[r(Ir,{}),[26,29.8].map(e=>r("g",{children:[r("rect",{x:e+.2,y:"14.6",width:"3.2",height:"0.9",rx:"0.4",fill:"#6fae5a"}),r("rect",{x:e+.3,y:"15.2",width:"3",height:"0.5",fill:"#8a4b2a"}),r("rect",{x:e+.7,y:"14.4",width:"0.6",height:"0.6",fill:"#e05252"}),r("rect",{x:e+2.3,y:"14.3",width:"0.6",height:"0.6",fill:"#e05252"}),r("path",{d:`M${e} 15.4 h3.6 a1.8 2.6 0 0 1 -3.6 0 z`,fill:"#e8b84a"})]},e))]}),pasta:()=>r("g",{children:[r("line",{x1:"31.4",y1:"15.6",x2:"33",y2:"11.8",stroke:"#c9ced6","stroke-width":"0.35"}),r("rect",{x:"25.8",y:"17.6",width:"7.6",height:"1.2",rx:"0.6",fill:"#f8f4ea"}),r("rect",{x:"26.6",y:"18.4",width:"6",height:"0.6",fill:"#e8e2d4"}),r("path",{d:"M26.6 17.8 Q27 14.6 29.6 14.6 Q32.2 14.6 32.6 17.8 Z",fill:"#f2d27a"}),r("g",{fill:"none",stroke:"#d9b45a","stroke-width":"0.25",children:[r("path",{d:"M27.4 17.1 q0.6 -0.7 1.2 0 t1.2 0 t1.2 0 t1.2 0"}),r("path",{d:"M27.9 16.2 q0.6 -0.7 1.2 0 t1.2 0 t1.2 0"})]}),r("path",{d:"M28 15.4 Q29.6 14 31.2 15.4 Q29.6 16.2 28 15.4 Z",fill:"#c0392b"}),r("circle",{cx:"28.9",cy:"15",r:"0.55",fill:"#6b3a22"}),r("circle",{cx:"30.3",cy:"14.9",r:"0.55",fill:"#6b3a22"}),r(nn,{x:27.6,y:11.6})]}),salad:()=>r("g",{children:[r("line",{x1:"31.8",y1:"15.8",x2:"33.2",y2:"11.8",stroke:"#c9ced6","stroke-width":"0.35"}),r("ellipse",{cx:"27.8",cy:"15.6",rx:"1.4",ry:"1",fill:"#4f9a46"}),r("ellipse",{cx:"29.6",cy:"15.1",rx:"1.5",ry:"1.1",fill:"#6fae5a"}),r("ellipse",{cx:"31.4",cy:"15.6",rx:"1.3",ry:"0.9",fill:"#9be38f"}),r("circle",{cx:"28.6",cy:"15.2",r:"0.45",fill:"#e05252"}),r("circle",{cx:"30.9",cy:"15.4",r:"0.45",fill:"#e05252"}),r("rect",{x:"29.4",y:"14.3",width:"0.4",height:"1.2",fill:"#ef8a2c"}),r("path",{d:"M26 16 h7.2 q-0.4 3 -3.6 3 q-3.2 0 -3.6 -3 z",fill:"#b07a4f"}),r("rect",{x:"25.8",y:"15.8",width:"7.6",height:"0.5",rx:"0.25",fill:"#9a6a43"})]}),soup:()=>r("g",{children:[r("line",{x1:"31.4",y1:"15.8",x2:"33.4",y2:"12.4",stroke:"#c9ced6","stroke-width":"0.35"}),r("path",{d:"M26 15.6 h7 q-0.4 3.4 -3.5 3.4 q-3.1 0 -3.5 -3.4 z",fill:"#e8e2d4"}),r("ellipse",{cx:"29.5",cy:"15.7",rx:"3.4",ry:"0.55",fill:"#d9622b"}),r("g",{fill:"#e8b84a",children:[r("rect",{x:"28",y:"15.4",width:"0.6",height:"0.4"}),r("rect",{x:"30.2",y:"15.6",width:"0.6",height:"0.4"})]}),r("rect",{x:"25.6",y:"18.4",width:"7.8",height:"0.6",rx:"0.3",fill:"#d4ccbd"}),r(nn,{x:28.2,y:12.4})]}),roast:()=>r("g",{children:[r("ellipse",{cx:"29.6",cy:"18.4",rx:"4.1",ry:"0.7",fill:"#e8e2d4"}),r("g",{fill:"#4f9a46",children:[r("circle",{cx:"26",cy:"18.1",r:"0.4"}),r("circle",{cx:"33.2",cy:"18.1",r:"0.4"})]}),r("path",{d:"M26.6 18.2 Q26.4 14.6 29.6 14.4 Q32.8 14.6 32.6 18.2 Z",fill:"#b5733a"}),r("ellipse",{cx:"29",cy:"15.6",rx:"1.6",ry:"0.7",fill:"#d9913f"}),[[26.9,25.9],[32.3,33.3]].map(([e,t])=>r("g",{children:[r("ellipse",{cx:e,cy:"16.8",rx:"1",ry:"0.7",fill:"#a5642e"}),r("circle",{cx:t,cy:"16.3",r:"0.4",fill:"#f4efe6"})]},e)),r(nn,{x:28.4,y:11.4})]}),icecream:()=>r("g",{children:[r("rect",{x:"27.8",y:"18.4",width:"3.4",height:"0.6",rx:"0.3",fill:"#cfe3ef"}),r("rect",{x:"29.2",y:"16.6",width:"0.6",height:"1.8",fill:"#cfe3ef"}),r("circle",{cx:"28.3",cy:"13.8",r:"1.2",fill:"#f28ab2"}),r("circle",{cx:"30.7",cy:"13.8",r:"1.2",fill:"#9be38f"}),r("circle",{cx:"29.5",cy:"12.5",r:"1.2",fill:"#7a4e2d"}),r("path",{d:"M26.8 14.4 h5.4 q-0.4 2.4 -2.7 2.4 q-2.3 0 -2.7 -2.4z",fill:"#cfe3ef",opacity:"0.85"}),r("rect",{x:"31.4",y:"10.6",width:"0.7",height:"2.8",fill:"#e8b84a"}),r("path",{d:"M29.5 11 q0.3 -0.9 1 -1.2",fill:"none",stroke:"#4f7a2c","stroke-width":"0.2"}),r("circle",{cx:"29.5",cy:"11.1",r:"0.45",fill:"#e05252"})]}),pie:()=>r("g",{children:[r("ellipse",{cx:"29.6",cy:"18.4",rx:"4.1",ry:"0.7",fill:"#e8e2d4"}),r("rect",{x:"26.2",y:"17.3",width:"6.8",height:"0.9",fill:"#a5642e"}),r("ellipse",{cx:"29.6",cy:"18.2",rx:"3.4",ry:"0.5",fill:"#a5642e"}),r("ellipse",{cx:"29.6",cy:"17.3",rx:"3.4",ry:"1.1",fill:"#c8813a"}),r("ellipse",{cx:"29.6",cy:"17.3",rx:"2.8",ry:"0.8",fill:"#e07b39"}),r("path",{d:"M29.6 17.3 L33.1 17.2 L32.4 18.2 Z",fill:"#e8e2d4"}),r("g",{fill:"#fbf6ea",children:[r("circle",{cx:"28.2",cy:"17",r:"0.45"}),r("circle",{cx:"29.8",cy:"16.8",r:"0.45"}),r("circle",{cx:"28.9",cy:"17.6",r:"0.45"})]})]}),pancakes:()=>r("g",{children:[r(Ir,{}),[17.3,16.4,15.5,14.6].map((e,t)=>r("rect",{x:"26.6",y:e,width:"6",height:"0.95",rx:"0.45",fill:t%2?"#c8913a":"#d9a441"},e)),r("g",{fill:"#8a4b1a",children:[r("rect",{x:"26.9",y:"14.5",width:"5.4",height:"0.45",rx:"0.2"}),r("rect",{x:"27.4",y:"14.9",width:"0.45",height:"1.4",rx:"0.2"}),r("rect",{x:"31.5",y:"14.9",width:"0.45",height:"0.8",rx:"0.2"})]}),r("rect",{x:"28.9",y:"13.9",width:"1.4",height:"0.65",fill:"#fbe7a1"}),r(nn,{x:28.6,y:11})]}),waffles:()=>r("g",{children:[r(Ir,{}),r("rect",{x:"26.6",y:"15.8",width:"6",height:"2.4",rx:"0.3",fill:"#e0a94a"}),r("g",{fill:"#c8913a",children:[[27.8,29,30.2,31.4].map(e=>r("rect",{x:e,y:"15.8",width:"0.2",height:"2.4"},e)),r("rect",{x:"26.6",y:"16.6",width:"6",height:"0.2"}),r("rect",{x:"26.6",y:"17.4",width:"6",height:"0.2"})]}),r("circle",{cx:"28.4",cy:"15.6",r:"0.5",fill:"#3f5fb5"}),r("circle",{cx:"29.3",cy:"15.4",r:"0.5",fill:"#e05252"}),r("circle",{cx:"30.6",cy:"15.5",r:"0.6",fill:"#fbf6ea"})]}),eggs:()=>r("g",{children:[r("rect",{x:"31.6",y:"13.8",width:"2",height:"3.4",rx:"0.5",fill:"#d9a441",stroke:"#a5743f","stroke-width":"0.25"}),r("ellipse",{cx:"29.6",cy:"17.7",rx:"4.1",ry:"1.2",fill:"#f4f1ea"}),r("ellipse",{cx:"27.9",cy:"17.4",rx:"1.3",ry:"0.65",fill:"#ffffff"}),r("circle",{cx:"27.9",cy:"17.3",r:"0.42",fill:"#f2b52a"}),r("ellipse",{cx:"30.4",cy:"17.2",rx:"1.3",ry:"0.65",fill:"#ffffff"}),r("circle",{cx:"30.4",cy:"17.1",r:"0.42",fill:"#f2b52a"}),r("g",{fill:"none",stroke:"#b5452a","stroke-width":"0.45",children:[r("path",{d:"M26.6 18.2 q0.6 -0.4 1.2 0 t1.2 0 t1.2 0"}),r("path",{d:"M29.6 18.5 q0.6 -0.4 1.2 0 t1.2 0"})]})]})};function Q0({dish:e}){const t=oo[e]?e:"ramen";return r("g",{"data-dish":t,"shape-rendering":J0,children:oo[t]()})}const xe="geometricPrecision",co=e=>[...e].reverse().join("");function nt({cells:e,cls:t,x0:n,y0:i=V,w:l=1,h:a=2,fill:s=Ht}){return r("g",{class:t,children:e.map(({x:o,y:u})=>r("rect",{x:n+o*l,y:i+u*a,width:l+.02,height:a+.02,fill:s},`${o},${u}`))})}const ud=[od[0]],uo={body:qt(Tn),legs:qt(ud)},ho={body:qt(Tn.map(co)),legs:qt(ud.map(co))};function Y0({season:e,trick:t}){return r(K,{children:[r("g",{class:"tama-motion",fill:"var(--fg-3)",children:[r("rect",{x:"1",y:"10.6",width:"4",height:"0.5"}),r("rect",{x:"2.4",y:"13.6",width:"3.6",height:"0.5"}),r("rect",{x:"0.6",y:"16.6",width:"4.6",height:"0.5"})]}),e!=="winter"&&!t&&r("path",{class:"tama-sweat",d:"M25 7.6 q1.1 1.7 0 2.5 q-1.1 -0.8 0 -2.5z",fill:"#7fb6e6"})]})}function fo({cx:e}){return r("g",{children:[r("circle",{cx:e,cy:"16.7",r:"2.2",fill:"none",stroke:"#2b2f36","stroke-width":"0.55"}),r("g",{class:"tama-spokes",stroke:"#9aa3ae","stroke-width":"0.18",children:[r("line",{x1:e-2,y1:"16.7",x2:e+2,y2:"16.7"}),r("line",{x1:e,y1:"14.7",x2:e,y2:"18.7"}),r("line",{x1:e-1.4,y1:"15.3",x2:e+1.4,y2:"18.1"}),r("line",{x1:e-1.4,y1:"18.1",x2:e+1.4,y2:"15.3"})]}),r("circle",{cx:e,cy:"16.7",r:"0.35",fill:"#2b2f36"})]})}function Z0(){return r("g",{class:"tama-bike","shape-rendering":xe,children:[r("g",{class:"tama-motion",fill:"var(--fg-3)",children:[r("rect",{x:"0.6",y:"9.2",width:"3.4",height:"0.5"}),r("rect",{x:"1.4",y:"11.6",width:"3",height:"0.5"}),r("rect",{x:"0.4",y:"13.6",width:"3.6",height:"0.5"})]}),r(fo,{cx:7.2}),r(fo,{cx:26.8}),r("g",{fill:"none",stroke:"#2a9d8f","stroke-width":"0.5","stroke-linecap":"round",children:[r("path",{d:"M7.2 16.7 L15.5 16.9 L24.4 13.2 L26.8 16.7"}),r("path",{d:"M7.2 16.7 L11.6 13.8"})]}),r("path",{d:"M24.4 13.2 L24 11.4 M23.2 11.5 H25.4",fill:"none",stroke:"#2b2f36","stroke-width":"0.45","stroke-linecap":"round"}),r("circle",{cx:"15.5",cy:"16.9",r:"0.8",fill:"none",stroke:"#5a6472","stroke-width":"0.3"}),r("g",{class:"tama-crank",fill:"#2b2f36",children:[r("path",{d:"M14.5 15.9 L16.5 17.9",stroke:"#2b2f36","stroke-width":"0.3"}),r("rect",{x:"14",y:"15.6",width:"0.9",height:"0.4"}),r("rect",{x:"16.1",y:"17.8",width:"0.9",height:"0.4"})]})]})}function X0({x0:e}){return r("g",{class:"tama-helmet","shape-rendering":xe,children:[r("path",{d:`M${e+3.6} ${V+.5} Q${e+3.6} ${V-1.6} ${e+9} ${V-1.6} Q${e+14.4} ${V-1.6} ${e+14.4} ${V+.5} Z`,fill:"#e05252"}),r("g",{fill:"#8f2a2a",children:[6.4,8.5,10.6].map(t=>r("rect",{x:e+t,y:V-.9,width:"0.9",height:"0.45",rx:"0.2"},t))}),r("rect",{x:e+13.2,y:V+.1,width:"2.4",height:"0.5",rx:"0.25",fill:"#8f2a2a"})]})}const po={dx:18,y:11.7};function _n({limb:e,x:t,y:n,w:i,h:l,cls:a}){const s=e.style==="tentacle";return r("rect",{class:a,x:t,y:n,width:i,height:l,rx:s?l/2:.25,fill:e.color,stroke:e.outline||void 0,"stroke-width":e.outline?.25:void 0})}function dd({x0:e,limb:t}){return r("g",{class:"tama-bass","shape-rendering":xe,children:[r("path",{d:`M${e+9.6} 13.7 L${e+23} 9.6 L${e+23.3} 10.5 L${e+9.9} 14.6 Z`,fill:"#4a2c1a"}),r("g",{fill:"#efe6d8",children:[13.5,16.5,19.5].map(n=>r("circle",{cx:e+n,cy:14.15-.306*(n-9.75),r:"0.13"},n))}),r("path",{d:`M${e+23} 9.4 L${e+26.4} 8.2 L${e+26.7} 9.1 L${e+23.3} 10.7 Z`,fill:"#e3c48a"}),r("g",{fill:"#c9ced6",children:[23.9,24.7,25.5,26.2].map((n,i)=>r("circle",{cx:e+n,cy:9.1-i*.3,r:"0.25"},n))}),r("ellipse",{cx:e+5,cy:"15.3",rx:"3",ry:"2.1",fill:"#3f6fb5"}),r("ellipse",{cx:e+8.1,cy:"14.4",rx:"1.9",ry:"1.5",fill:"#3f6fb5"}),r("ellipse",{cx:e+9.4,cy:"13.4",rx:"1.1",ry:"0.6",fill:"#3f6fb5"}),r("ellipse",{cx:e+6.6,cy:"14.7",rx:"2",ry:"1.1",fill:"#f4f1ea"}),r("rect",{x:e+5.6,y:"14.1",width:"1.4",height:"0.9",rx:"0.2",fill:"#1d1f24"}),r("rect",{x:e+2.6,y:"14.9",width:"1.6",height:"0.7",fill:"#c9ced6"}),r("g",{stroke:"#e6e9ef","stroke-width":"0.1",children:[r("line",{x1:e+3.4,y1:"15.1",x2:e+23.1,y2:"9.9"}),r("line",{x1:e+3.4,y1:"15.4",x2:e+23.2,y2:"10.2"})]}),t?r(_n,{limb:t,x:e+7.3,y:14.5,w:1.3,h:1,cls:"tama-strum"}):r(K,{children:[r("rect",{x:e+17.5,y:"11.1",width:"1",height:"0.9",fill:Ht}),r("rect",{class:"tama-strum",x:e+7.4,y:"14.6",width:"1.1",height:"0.8",fill:Ht})]})]})}function mo({x:e,y:t,cls:n}){return r("g",{class:n,fill:"var(--fg-2)",children:[r("ellipse",{cx:e,cy:t+2.4,rx:"0.6",ry:"0.45"}),r("rect",{x:e+.35,y:t,width:"0.3",height:"2.4"}),r("path",{d:`M${e+.65} ${t} q1 0.5 0.6 1.6 q-0.1 -0.9 -0.6 -1`})]})}function ey(){return r("g",{class:"tama-amp","shape-rendering":xe,children:[r(mo,{x:24.4,y:6,cls:"tama-note"}),r(mo,{x:26.6,y:4.4,cls:"tama-note tama-note2"}),r("path",{d:"M9 17.2 C8.6 19, 12 18.9, 16 18.9 S26.4 18.9, 27.6 17.6",fill:"none",stroke:"#1d1f24","stroke-width":"0.3"}),r("rect",{x:"27.6",y:"12.6",width:"6",height:"6.4",rx:"0.3",fill:"#2b2f36"}),r("rect",{x:"27.6",y:"12.6",width:"6",height:"1.2",fill:"#3b404a"}),r("g",{fill:"#c9ced6",children:[28.4,29.3,30.2,31.1].map(e=>r("circle",{cx:e,cy:"13.2",r:"0.25"},e))}),r("circle",{cx:"32.8",cy:"13.2",r:"0.2",fill:"#e05252"}),r("rect",{x:"28",y:"14.2",width:"5.2",height:"4.4",fill:"#4a4f58"}),r("g",{class:"tama-speaker",children:[r("circle",{cx:"30.6",cy:"16.4",r:"1.8",fill:"#3b404a"}),r("circle",{cx:"30.6",cy:"16.4",r:"0.7",fill:"#2b2f36"})]})]})}const Ct=18,go="#6f93d6",ty=150,mt=e=>Math.round(e*1e4)/1e4;function ny({sprite:e}){const{scale:t,tx:n,ty:i}=Sa(e,{x0:Ct,sitting:!1}),l=Ct+8.5;return r("g",{class:"tama-critter",style:"transform-box: view-box",transform:`translate(${mt(2*l-n)} ${mt(i)}) scale(${mt(-t)} ${mt(t)})`,children:[r(Gi,{sprite:e,face:"happy",tint:ty,holding:"pint"}),r(hd,{sprite:e,kind:"pint",scale:t})]})}function hd({sprite:e,kind:t,scale:n}){if(!$a[t])return null;const[i,l]=qi(e,t),a=mt(1/n),s=(o,u)=>r("g",{style:"transform-box: view-box",transform:`translate(${i} ${l}) scale(${a}) ${o}`,children:u});return t==="pint"?s("translate(0 -11.5)",r(Ga,{x:0,cls:"tama-pint tama-clink"})):t==="mug"?s("scale(-1 1) translate(-30.1 -14.2)",r(pd,{})):t==="can"?s("translate(-17.8 -11.7)",r(md,{x0:0})):null}function Ga({x:e,cls:t}){return r("g",{class:t,children:[r("rect",{x:e,y:"10.4",width:"2",height:"2.8",fill:"#e8a92e"}),r("rect",{x:e+.3,y:"10.9",width:"0.3",height:"1.8",fill:"#ffd98a"}),r("rect",{x:e-.1,y:"9.8",width:"2.2",height:"0.9",rx:"0.4",fill:"#fbf6ea"})]})}function ry({x0:e}){return r(Ga,{x:e+15.2,cls:"tama-pint tama-clink"})}const iy=[["#ffd166",15.4],["#f28ab2",19.6],["#7fb6e6",23.8],["#9be38f",28],["#ffd166",32.2]];function ly({critter:e}){return r("g",{children:[r("path",{d:"M13.4 1.2 Q23.6 3.6 34 1.2",fill:"none",stroke:"var(--fg-3)","stroke-width":"0.2","shape-rendering":xe}),iy.map(([t,n],i)=>r("rect",{class:`tama-twinkle${i%2?" tama-twinkle2":""}`,x:n-.35,y:1.9+Math.sin((n-13.4)/6.5)*.9,width:"0.7",height:"0.9",rx:"0.3",fill:t},n)),r("g",{class:"tama-friend",children:e!=null&&e.sprite?r(ny,{sprite:e.sprite}):r(K,{children:[r(nt,{cells:ho.body,x0:Ct,fill:go}),r(nt,{cells:ho.legs,x0:Ct,y0:V+2*Tn.length,fill:go}),r("g",{fill:"none",stroke:we,"stroke-width":"0.45","stroke-linecap":"square",children:[r("path",{d:`M${Ct+3.8} ${V+3.5} l0.7 -0.9 l0.7 0.9`}),r("path",{d:`M${Ct+10.8} ${V+3.5} l0.7 -0.9 l0.7 0.9`})]}),r(Ga,{x:Ct+1.2,cls:"tama-pint tama-clink tama-clink2"})]})}),r("g",{class:"tama-cheers",fill:"#ffd166",children:[r("rect",{x:"18.1",y:"7.6",width:"0.4",height:"1.2"}),r("rect",{x:"16.6",y:"8.3",width:"0.9",height:"0.4"}),r("rect",{x:"19.1",y:"8.3",width:"0.9",height:"0.4"})]})]})}function ay({x:e}){const t=e+1.1,n=e+7.4,i=`q-${(n-t)/16} 0.55 -${(n-t)/8} 0 `.repeat(8);return r("g",{class:"tama-kid-sheet","shape-rendering":xe,children:[r("path",{fill:"#f5f5f7",d:`M${t} 18.8 V15.6 Q${t} 13.6 ${(t+n)/2} 13.6 Q${n} 13.6 ${n} 15.6 V18.8 ${i}Z`}),r("ellipse",{cx:e+3.1,cy:"15.6",rx:"0.35",ry:"0.5",fill:we}),r("ellipse",{cx:e+5.4,cy:"15.6",rx:"0.35",ry:"0.5",fill:we}),r("path",{d:`M${e+6.5} 17.2 q0.8 -1.2 1.6 0`,fill:"none",stroke:"#3a2a1a","stroke-width":"0.2"}),r("rect",{x:e+6.4,y:"17",width:"1.8",height:"1.5",rx:"0.5",fill:"#ef8a2c"})]})}function sy({x:e,sprite:t,costume:n}){const{scale:i,tx:l,ty:a}=Sa(t,{x0:e-4.25,sitting:!1,height:(n?su:xa)/2});return r("g",{class:"tama-critter",style:"transform-box: view-box",transform:`translate(${mt(l)} ${mt(a)}) scale(${mt(i)})`,children:r(Gi,{sprite:t})})}function yo({x:e,cls:t,costume:n,sprite:i}){return r("g",{class:t,children:[i?r(sy,{x:e,sprite:i,costume:n}):r(K,{children:[r(nt,{cells:uo.body,x0:e,y0:14,w:.5,h:1}),r(nt,{cells:uo.legs,x0:e,y0:18,w:.5,h:1})]}),n?r(ay,{x:e}):!i&&r("g",{fill:we,children:[r("rect",{x:e+2.5,y:"15",width:"0.5",height:"1"}),r("rect",{x:e+6,y:"15",width:"0.5",height:"1"})]})]})}function oy({trick:e=!1,critter:t}){return r("g",{children:[r(yo,{x:17.4,cls:"tama-kid",costume:e,sprite:t==null?void 0:t.sprite}),r(yo,{x:25.4,cls:"tama-kid tama-kid2",costume:e,sprite:t==null?void 0:t.sprite})]})}function cy(){return r("g",{children:[r("g",{fill:"#4d5f95",children:[r("rect",{x:"0.6",y:"8.4",width:"20.4",height:"9",rx:"1"}),r("rect",{x:"0.2",y:"13.4",width:"2.6",height:"5",rx:"0.8"})]}),r("rect",{x:"1",y:"16.6",width:"21",height:"1.6",rx:"0.6",fill:"#5f75b0"}),r("g",{fill:"#3a2a1a",children:[r("rect",{x:"1.6",y:"18.2",width:"0.9",height:"0.8"}),r("rect",{x:"20.2",y:"18.2",width:"0.9",height:"0.8"})]}),r("g",{class:"tama-tv",children:[r("rect",{x:"22.4",y:"15.6",width:"11.2",height:"3.4",fill:"#6f533c"}),r("rect",{x:"22.4",y:"17.1",width:"11.2",height:"0.3",fill:"#5a4230"}),r("rect",{x:"27.4",y:"14.6",width:"1.6",height:"1",fill:"#1d1f24"}),r("rect",{x:"23",y:"7.4",width:"10.4",height:"7.2",rx:"0.4",fill:"#1d1f24"}),r("rect",{x:"23.6",y:"8",width:"9.2",height:"6",fill:"#20304a"}),r("rect",{x:"23.6",y:"13",width:"9.2",height:"1",fill:"#4f9a46"}),r("rect",{x:"29.6",y:"10.8",width:"2.4",height:"0.5",fill:"#b5733a"}),r("circle",{class:"tama-twinkle",cx:"30.8",cy:"9.9",r:"0.35",fill:"#ffd166"}),r("rect",{class:"tama-hero",x:"25.2",y:"11.9",width:"0.8",height:"1.1",fill:"#e05252"})]})]})}const uy={style:"arm",color:Ht};function fd({x0:e,limb:t=uy}){return r("g",{class:"tama-controller","shape-rendering":xe,children:[r("rect",{x:e+6.6,y:"14.2",width:"4.8",height:"1.4",rx:"0.6",fill:"#3b404a"}),r("rect",{x:e+6.4,y:"14.6",width:"1.4",height:"1.6",rx:"0.6",fill:"#3b404a"}),r("rect",{x:e+10.2,y:"14.6",width:"1.4",height:"1.6",rx:"0.6",fill:"#3b404a"}),r("path",{d:`M${e+7.4} 14.9 h0.9 M${e+7.85} 14.45 v0.9`,stroke:"#c9ced6","stroke-width":"0.25"}),r("circle",{cx:e+10.2,cy:"14.7",r:"0.22",fill:"#e05252"}),r("circle",{cx:e+10.7,cy:"15.1",r:"0.22",fill:"#5aa9e6"}),r(_n,{limb:t,x:e+6.2,y:14.3,w:1.6,h:1.3}),r(_n,{limb:t,x:e+10,y:14.3,w:1.6,h:1.3,cls:"tama-thumb"})]})}function dy(){return r("g",{"shape-rendering":xe,children:[r("rect",{x:"21.4",y:"18.2",width:"12.4",height:"1",fill:"#6b4a33"}),r("g",{class:"tama-flowers",children:[r("g",{fill:"#3f8238",children:[r("rect",{x:"23",y:"13.4",width:"0.4",height:"4.8"}),r("rect",{x:"23.4",y:"15.6",width:"1",height:"0.4"}),r("rect",{x:"26",y:"15.2",width:"0.4",height:"3"}),r("rect",{x:"29",y:"15.4",width:"0.4",height:"2.8"}),r("rect",{x:"31.6",y:"17",width:"0.4",height:"1.2"}),r("rect",{x:"31.9",y:"16.6",width:"0.8",height:"0.4"})]}),r("circle",{cx:"23.2",cy:"13",r:"1.2",fill:"#ffd166"}),r("circle",{cx:"23.2",cy:"13",r:"0.5",fill:"#7a4e2d"}),r("path",{d:"M25.4 15.4 V14.2 L25.9 14.7 L26.2 14 L26.5 14.7 L27 14.2 V15.4 Z",fill:"#e05252"}),r("circle",{cx:"29.2",cy:"15",r:"0.8",fill:"#f28ab2"}),r("circle",{cx:"29.2",cy:"15",r:"0.3",fill:"#ffd166"})]}),r("g",{fill:"#7fb6e6",children:[[23.4,0],[23.9,-.3],[24.4,-.6]].map(([e,t])=>r("rect",{class:"tama-drop",x:e,y:"12.2",width:"0.3",height:"0.5",style:{animationDelay:`${t}s`}},e))})]})}function pd(){return r(K,{children:[r("g",{fill:"#efe6d8",children:[r("rect",{x:"25.5",y:"12",width:"3.4",height:"4.6",rx:"0.4"}),r("rect",{x:"28.9",y:"12.9",width:"1.2",height:"0.6"}),r("rect",{x:"29.5",y:"12.9",width:"0.6",height:"2.6"}),r("rect",{x:"28.9",y:"14.9",width:"1.2",height:"0.6"})]}),r("rect",{x:"25.5",y:"12",width:"3.4",height:"0.9",fill:"#7a4e2d"}),r("rect",{class:"tama-steam",x:"26.4",y:"8.6",width:"0.6",height:"2",fill:"var(--fg-3)"}),r("rect",{class:"tama-steam tama-steam2",x:"27.7",y:"7.8",width:"0.6",height:"2",fill:"var(--fg-3)"})]})}function md({x0:e}){return r("g",{class:"tama-can","shape-rendering":xe,children:[r("path",{d:`M${e+16.6} 12.6 Q${e+17.8} 10.8 ${e+19} 12.6`,fill:"none",stroke:"#3f7fb5","stroke-width":"0.4"}),r("line",{x1:e+19.2,y1:"13.6",x2:e+21.3,y2:"11.9",stroke:"#5aa9e6","stroke-width":"0.45"}),r("rect",{x:e+21.1,y:"11.5",width:"0.6",height:"0.7",fill:"#3f7fb5"}),r("rect",{x:e+16.2,y:"12.6",width:"3.2",height:"2.4",rx:"0.4",fill:"#5aa9e6"})]})}function hy(){return r("g",{class:"tama-stove","shape-rendering":xe,children:[r("rect",{x:"21",y:"12.8",width:"12.8",height:"6.2",fill:"#d9dde3"}),r("rect",{x:"20.8",y:"12.2",width:"13.2",height:"0.6",fill:"#3b404a"}),r("g",{fill:"#3b404a",children:[23,25,29.8,31.8].map(e=>r("circle",{cx:e,cy:"13.6",r:"0.35"},e))}),r("rect",{x:"22.4",y:"14.8",width:"10",height:"2.8",rx:"0.3",fill:"#2b2f36"}),r("rect",{class:"tama-glow",x:"23",y:"15.4",width:"8.8",height:"1.6",fill:"#ef8a2c",opacity:"0.18"}),r("rect",{x:"21.6",y:"9.4",width:"4.8",height:"2.8",rx:"0.3",fill:"#8a93a1"}),r("rect",{x:"21",y:"9.8",width:"0.6",height:"0.4",fill:"#5a6472"}),r("rect",{x:"26.4",y:"9.8",width:"0.6",height:"0.4",fill:"#5a6472"}),r("rect",{x:"21.6",y:"9.4",width:"4.8",height:"0.5",fill:"#6b7480"}),r(nn,{x:22.8,y:6.6}),r("rect",{x:"27.6",y:"11.6",width:"4",height:"0.6",rx:"0.2",fill:"#2b2f36"}),r("line",{x1:"31.6",y1:"11.8",x2:"33.8",y2:"11.2",stroke:"#2b2f36","stroke-width":"0.4"}),r("g",{fill:"#e8a92e",children:[r("rect",{class:"tama-steam",x:"28.4",y:"10.8",width:"0.5",height:"0.5"}),r("rect",{class:"tama-steam tama-steam2",x:"30.2",y:"10.6",width:"0.5",height:"0.5"})]})]})}function gd({x0:e,from:t}){return r("line",{class:"tama-spoon",x1:t?t[0]:e+16.8,y1:t?t[1]:"13.6",x2:e+21.6,y2:"9.6",stroke:"#b07a4f","stroke-width":"0.45"})}function fy({x0:e}){return r("g",{class:"tama-toque","shape-rendering":xe,children:[r("g",{fill:"#f4f4f6",children:[r("circle",{cx:e+6.4,cy:V-2.4,r:"1.5"}),r("circle",{cx:e+9,cy:V-3,r:"1.8"}),r("circle",{cx:e+11.6,cy:V-2.4,r:"1.5"}),r("rect",{x:e+5,y:V-1.6,width:"8",height:"1.9"})]}),r("g",{fill:"#d8dce2",children:[r("rect",{x:e+7,y:V-1.4,width:"0.25",height:"1.6"}),r("rect",{x:e+9,y:V-1.4,width:"0.25",height:"1.6"}),r("rect",{x:e+11,y:V-1.4,width:"0.25",height:"1.6"})]})]})}function py({from:e}){const[t,n]=e??[18.2,14.2];return r("g",{"shape-rendering":xe,children:[r("path",{class:"tama-leash",d:`M${t} ${n} Q23 12.4 28.1 15`,fill:"none",stroke:"#e05252","stroke-width":"0.25"}),r("g",{class:"tama-dog",children:[r("path",{class:"tama-tail",d:"M23 15.4 L21.8 13.4",stroke:"#b07a4f","stroke-width":"0.55","stroke-linecap":"round"}),r("g",{fill:"#b07a4f",children:[r("rect",{class:"tama-dog-a",x:"23.4",y:"16.6",width:"0.6",height:"2.4"}),r("rect",{class:"tama-dog-a",x:"27.6",y:"16.6",width:"0.6",height:"2.4"}),r("rect",{class:"tama-dog-b",x:"24",y:"16.6",width:"0.6",height:"2.4"}),r("rect",{class:"tama-dog-b",x:"27",y:"16.6",width:"0.6",height:"2.4"}),r("rect",{x:"22.8",y:"14.8",width:"5.8",height:"2.2",rx:"0.6"}),r("rect",{x:"27.8",y:"13",width:"2.8",height:"2.8",rx:"0.6"})]}),r("rect",{x:"30.2",y:"14.4",width:"1.4",height:"1.2",rx:"0.3",fill:"#c8915e"}),r("rect",{x:"31.3",y:"14.4",width:"0.5",height:"0.5",fill:we}),r("rect",{x:"28.2",y:"12.8",width:"1",height:"2.2",rx:"0.3",fill:"#7a4e2d"}),r("rect",{x:"29.6",y:"13.8",width:"0.45",height:"0.5",fill:we}),r("rect",{x:"27.8",y:"14.6",width:"0.6",height:"1.2",fill:"#e05252"})]})]})}function my(){return r("g",{"shape-rendering":xe,children:[r("rect",{x:"0",y:"0",width:"34",height:"24",fill:"#6fb4ea",opacity:"0.13"}),r("circle",{class:"tama-sun",cx:"4.5",cy:"4",r:"2.1",fill:"#ffd166"}),r("g",{class:"tama-ball",children:[r("circle",{cx:"29.5",cy:"13.8",r:"1.8",fill:"#f4f4f6"}),r("path",{d:"M29.5 12 A1.8 1.8 0 0 1 31.3 13.8 H29.5 Z",fill:"#e05252"}),r("path",{d:"M29.5 15.6 A1.8 1.8 0 0 1 27.7 13.8 H29.5 Z",fill:"#5aa9e6"})]})]})}function gy(){const e="q0.85 -0.6 1.7 0 ".repeat(21);return r("g",{"shape-rendering":xe,children:[r("g",{class:"tama-water",children:[r("path",{d:`M-1 14.6 ${e} V24 H-1 Z`,fill:"#3b8fd0",opacity:"0.9"}),r("g",{fill:"#cfe9fa",children:[r("rect",{x:"4",y:"17.4",width:"1.6",height:"0.3"}),r("rect",{x:"15",y:"19.6",width:"2",height:"0.3"}),r("rect",{x:"26",y:"18",width:"1.4",height:"0.3"})]})]}),r("g",{fill:"#cfe9fa",children:[r("rect",{class:"tama-splash",x:"6.4",y:"13",width:"0.5",height:"0.5"}),r("rect",{class:"tama-splash tama-splash2",x:"23.4",y:"13",width:"0.5",height:"0.5"})]})]})}function Ja({x0:e}){return r("g",{class:"tama-goggles","shape-rendering":xe,children:[r("rect",{x:e+3,y:V+2.6,width:"12",height:"0.5",fill:"#2b2f36"}),[4.3,11.3].map(t=>r("rect",{x:e+t,y:V+1.5,width:"2.4",height:"2.8",rx:"0.8",fill:"#7fd1e6","fill-opacity":"0.45",stroke:"#2b2f36","stroke-width":"0.35"},t))]})}function yy(){return r("g",{"shape-rendering":xe,children:[r("g",{class:"tama-motion",fill:"var(--fg-3)",children:[r("rect",{x:"0.6",y:"9.6",width:"3",height:"0.5"}),r("rect",{x:"1.2",y:"12",width:"2.6",height:"0.5"}),r("rect",{x:"0.4",y:"14.4",width:"3.2",height:"0.5"})]}),r("g",{fill:"#f4f8fb",children:[[3.6,0],[4.4,-.2],[3.2,-.4]].map(([e,t])=>r("rect",{class:"tama-kick",x:e,y:"17.8",width:"0.6",height:"0.6",style:{animationDelay:`${t}s`}},t))}),r("g",{class:"tama-sled",children:[r("path",{d:"M5.4 19 H23.4 Q25.8 19 25.4 16.8",fill:"none",stroke:"#8a93a1","stroke-width":"0.4"}),r("g",{fill:"#8a93a1",children:[7.6,14,20.4].map(e=>r("rect",{x:e,y:"17.8",width:"0.4",height:"1.2"},e))}),r("rect",{x:"5",y:"16.8",width:"18.8",height:"1.1",rx:"0.3",fill:"#b5452a"}),r("path",{d:"M25.2 17 Q24.4 15.4 22.6 14.6",fill:"none",stroke:"#e8b84a","stroke-width":"0.25"})]})]})}function Qa({x0:e}){return r("g",{class:"tama-scarf",children:[r("rect",{x:e+3,y:V+4,width:"12",height:"1.1",fill:"#d64541"}),r("g",{fill:"#f4f4f6",children:[5,8,11,14].map(t=>r("rect",{x:e+t,y:V+4,width:"0.5",height:"1.1"},t))}),r("rect",{class:"tama-scarf-tail",x:e-1.4,y:V+4.2,width:"2.8",height:"0.8",fill:"#d64541"})]})}const by={run:{tempo:.3,stride:!0,outdoors:!0,snowcap:!0,Behind:Y0,trick:{pail:!0}},cycle:{pose:{x0:7,lift:2},tempo:.4,stride:!0,outdoors:!0,jack:{x:.6,y:16.4},Behind:Z0,Headwear:X0},music:{pose:{x0:6},tempo:.5,jack:{x:1.5,y:16.4},Behind:ey,Held:dd},beer:{pose:{x0:1},tempo:.9,smile:!0,Behind:ly,Held:ry},kids:{pose:{x0:1},tempo:.7,smile:!0,Behind:oy,trick:{outdoors:!0}},game:{pose:{x0:3,sitting:!0},tempo:1.2,Behind:cy,Held:fd,paws:!0},garden:{pose:{x0:2},tempo:.8,outdoors:!0,Behind:dy,Held:md},cook:{pose:{x0:2},tempo:.6,Behind:hy,Held:gd,Headwear:fy},dog:{pose:{x0:1},tempo:.5,stride:!0,smile:!0,outdoors:!0,Behind:py},swim:{pose:{x0:6,sitting:!0},tempo:1,Behind:my,Held:Ja,Front:gy},sled:{pose:{x0:5,sitting:!0},tempo:.35,smile:!0,outdoors:!0,snowcap:!0,Behind:yy,Held:Qa}},Ve="geometricPrecision";function kt({fill:e="#1d2026"}){return r("rect",{x:"23.4",y:"6",width:"8.2",height:"5.6",fill:e})}function Ue({x:e,y:t,size:n,fill:i,weight:l=700,anchor:a="start",children:s}){return r("text",{x:e,y:t,"font-size":n,"font-weight":l,"font-family":"var(--mono)","text-anchor":a,fill:i,children:s})}const ky={bell:r("g",{children:[r("rect",{x:"2.9",y:"1.35",width:"0.6",height:"0.55",fill:"#b8862a"}),r("path",{d:"M1.9 4.3 Q1.9 1.8 3.2 1.8 Q4.5 1.8 4.5 4.3 Z",fill:"#e8a92e"}),r("rect",{x:"1.55",y:"4.1",width:"3.3",height:"0.55",rx:"0.2",fill:"#e8a92e"}),r("circle",{cx:"3.2",cy:"4.95",r:"0.38",fill:"#8a5a1a"})]}),done:r("path",{d:"M1.7 3.4 l1.1 1.1 l2.1 -2.4",fill:"none",stroke:"#2f9a57","stroke-width":"0.8","stroke-linecap":"square"}),ci:r("path",{d:"M1.9 1.9 l2.6 2.6 M4.5 1.9 l-2.6 2.6",fill:"none",stroke:"#d64541","stroke-width":"0.8","stroke-linecap":"square"}),api:r("path",{d:"M3.8 1.3 L1.9 3.5 H3.1 L2.6 5.3 L4.6 2.9 H3.4 Z",fill:"#e8a92e"}),ctx:r("g",{children:[r("rect",{x:"2",y:"1.5",width:"2.4",height:"3.7",rx:"0.3",fill:"none",stroke:"#5a6472","stroke-width":"0.35"}),r("rect",{x:"2.35",y:"2.05",width:"1.7",height:"2.8",fill:"#e8892e"})]}),update:r("g",{children:[r("rect",{x:"1.6",y:"2.3",width:"3.2",height:"2.8",fill:"#c49a6c"}),r("rect",{x:"1.6",y:"2.3",width:"3.2",height:"0.65",fill:"#d8b384"}),r("rect",{x:"2.95",y:"2.3",width:"0.5",height:"2.8",fill:"#a57c4f"})]}),merged:r("g",{children:[r("path",{d:"M2.2 2 V4.6 M2.2 2.4 Q2.2 3.3 4.3 3.3",fill:"none",stroke:"#8957e5","stroke-width":"0.4"}),r("circle",{cx:"2.2",cy:"1.9",r:"0.55",fill:"#8957e5"}),r("circle",{cx:"2.2",cy:"4.7",r:"0.55",fill:"#8957e5"}),r("circle",{cx:"4.4",cy:"3.3",r:"0.55",fill:"#8957e5"})]})};function wy({kind:e,label:t,urgent:n,more:i,x0:l}){const a=4.6+t.length*2.16+.9,[s,o]=n?["#e05252","#ffffff"]:["#f4f4f6","#1b2028"],u=Math.max(l+3.6,9.4),c=.8+a+.7;return r("g",{class:`tama-bubble${n?" tama-bubble-urgent":""}`,"shape-rendering":Ve,children:[r("path",{d:`M6.4 5.6 L${u} 8.3 L8.4 5.6 Z`,fill:s}),r("rect",{x:"0.8",y:"0.8",width:a,height:"5",rx:"1.3",fill:s}),ky[e],r(Ue,{x:"5.3",y:"4.75",size:"3.6",fill:o,children:t}),i>0&&r("g",{class:"tama-more",children:[r("rect",{x:c,y:"1.9",width:"4.4",height:"2.8",rx:"1.4",fill:"#3b404a"}),r(Ue,{x:c+2.2,y:"3.95",size:"2.1",fill:"#e6e9ef",weight:600,anchor:"middle",children:`+${i}`})]})]})}function bo({x0:e}){return r("g",{class:"tama-happy-eyes",fill:"none",stroke:we,"stroke-width":"0.45","stroke-linecap":"square",children:[r("path",{d:`M${e+4.8} ${V+3.5} l0.7 -0.9 l0.7 0.9`}),r("path",{d:`M${e+11.8} ${V+3.5} l0.7 -0.9 l0.7 0.9`})]})}function vy({x0:e}){return r("g",{fill:"none",stroke:we,"stroke-width":"0.45","stroke-linecap":"square",children:[r("path",{d:`M${e+4.9} ${V+2.3} l1.2 1.5 M${e+6.1} ${V+2.3} l-1.2 1.5`}),r("path",{d:`M${e+11.9} ${V+2.3} l1.2 1.5 M${e+13.1} ${V+2.3} l-1.2 1.5`})]})}function _y({x0:e}){return r("g",{children:[r("g",{fill:"none",stroke:we,"stroke-width":"0.4",children:[r("path",{d:`M${e+4.4} ${V+1.5} l1.8 -0.6`}),r("path",{d:`M${e+11.8} ${V+.9} l1.8 0.6`})]}),r("path",{class:"tama-sweat",fill:"#7fb6e6",d:`M${e+2.2} ${V+.4} q0.8 1.2 0 1.8 q-0.8 -0.6 0 -1.8z`}),r("path",{class:"tama-sweat",style:{animationDelay:"-0.6s"},fill:"#7fb6e6",d:`M${e+15.9} ${V+.8} q0.8 1.2 0 1.8 q-0.8 -0.6 0 -1.8z`})]})}function Yr({x:e,y:t,cls:n="tama-sparkle",delay:i=0}){const l=[[0,-.9],[.25,-.25],[.9,0],[.25,.25],[0,.9],[-.25,.25],[-.9,0],[-.25,-.25]];return r("path",{class:n||void 0,style:i?{animationDelay:`${i}s`}:void 0,fill:"#ffd166","shape-rendering":Ve,d:`M${l.map(([a,s])=>`${(e+a).toFixed(2)} ${(t+s).toFixed(2)}`).join(" L")} Z`})}function xy({x0:e}){return r("g",{children:[[6,7.4,0],[9,6.6,-.6],[12,7.4,-1.2]].map(([t,n,i])=>r("g",{class:"tama-orbit",style:{animationDelay:`${i}s`},children:r(Yr,{x:e+t,y:n,cls:""})},t))})}function Sy({x0:e}){return r("g",{class:"tama-startle",fill:"#f2c14e",children:[r("rect",{x:e+16.6,y:"5.8",width:"0.6",height:"1.8"}),r("rect",{x:e+16.6,y:"8",width:"0.6",height:"0.6"})]})}function $y({x0:e}){return r("g",{fill:Ht,children:[r("rect",{class:"tama-cheer",x:e,y:"9.8",width:"1.02",height:"3.4"}),r("rect",{class:"tama-cheer tama-cheer2",x:e+16,y:"9.8",width:"1.02",height:"3.4"})]})}const yd=({d:e})=>r("g",{class:"tama-ding",fill:"none",stroke:"#f2c14e","stroke-width":"0.3","shape-rendering":Ve,children:r("path",{d:e})});function Cy(){return r("rect",{class:"tama-slap",x:"21.6",y:"8.7",width:"1.2",height:"0.9",fill:Ht})}const Ty=[21.25,12.3],Ey=[22.2,9.6];function Py({limb:e}){return r("g",{children:[r(_n,{limb:e,x:20.7,y:11.9,w:1.1,h:.8,cls:"tama-hand"}),r(_n,{limb:e,x:22.7,y:11.9,w:1.1,h:.8,cls:"tama-hand tama-hand2"})]})}function Ay({limb:e}){return r(_n,{limb:e,x:21.6,y:8.7,w:1.2,h:.9,cls:"tama-slap"})}function My(){return r("g",{children:[r("g",{"shape-rendering":Ve,children:[r("rect",{x:"20.7",y:"12.6",width:"3",height:"0.6",rx:"0.2",fill:"#8b93a1"}),r("path",{d:"M20.95 12.65 Q20.95 10.9 22.2 10.9 Q23.45 10.9 23.45 12.65 Z",fill:"#f2c14e"}),r("rect",{x:"21.4",y:"11.4",width:"0.4",height:"0.5",fill:"#fff3c4"}),r("rect",{x:"21.95",y:"10.4",width:"0.5",height:"0.55",fill:"#c9a03a"})]}),r(yd,{d:"M20.3 10.4 l-1 -0.5 M20.6 9.5 l-0.6 -0.9 M24.1 10.4 l1 -0.5 M23.8 9.5 l0.6 -0.9"})]})}function Ly(){return r("g",{children:[r("g",{class:"tama-alarm","shape-rendering":Ve,children:[r("rect",{x:"27.4",y:"18.2",width:"0.5",height:"0.8",fill:"#8b93a1"}),r("rect",{x:"30.1",y:"18.2",width:"0.5",height:"0.8",fill:"#8b93a1"}),r("circle",{cx:"27.4",cy:"14.3",r:"0.9",fill:"#e8a92e"}),r("circle",{cx:"30.6",cy:"14.3",r:"0.9",fill:"#e8a92e"}),r("rect",{x:"28.8",y:"13.4",width:"0.4",height:"1",fill:"#3b404a"}),r("circle",{cx:"29",cy:"16.4",r:"2.1",fill:"#e6e9ef",stroke:"#d03a3a","stroke-width":"0.45"}),r("path",{d:"M29 16.4 v-1.3 M29 16.4 h0.9",stroke:we,"stroke-width":"0.3",fill:"none"})]}),r(yd,{d:"M26 14 l-0.9 -0.6 M25.8 15.3 l-1 0 M32 14 l0.9 -0.6 M32.2 15.3 l1 0"})]})}function Iy(){return r("g",{children:[r(Yr,{x:22.2,y:4.4}),r(Yr,{x:32.6,y:4.8,delay:-.5}),r(Yr,{x:20.6,y:7.2,delay:-1})]})}function Oy(){return r("g",{children:[r(kt,{}),r("path",{d:"M25.3 8.8 l1.7 1.7 l3.4 -3.6",fill:"none",stroke:"#6fcf8f","stroke-width":"0.9","stroke-linecap":"square","shape-rendering":Ve})]})}function Dy(){return r("g",{children:[r(kt,{fill:"#1d1a26"}),r("g",{"shape-rendering":Ve,children:[r("path",{d:"M26.3 6.9 V9.4 M26.3 7.3 Q26.3 8.1 28.9 8.1",fill:"none",stroke:"#a371f7","stroke-width":"0.45"}),r("circle",{cx:"26.3",cy:"6.9",r:"0.6",fill:"#a371f7"}),r("circle",{cx:"26.3",cy:"9.5",r:"0.6",fill:"#a371f7"}),r("circle",{cx:"29",cy:"8.1",r:"0.6",fill:"#a371f7"})]}),r(Ue,{x:"27.5",y:"11.15",size:"1.35",fill:"#a371f7",weight:600,anchor:"middle",children:"merged"})]})}const ko=({x:e})=>r("g",{children:[r("path",{class:"tama-flame",fill:"#f08a3c",d:`M${e} 5.6 q-0.5 -1.8 0.7 -3 q0.2 1.1 0.7 1.5 q0.3 -1 1 -1.6 q0.8 1.8 0.1 3.1z`}),r("path",{class:"tama-flame tama-flame2",fill:"#ffd166",d:`M${e+.5} 5.6 q-0.2 -1 0.6 -1.8 q0.2 0.7 0.6 0.9 q0.3 -0.5 0.4 -0.9 q0.6 1 0.1 1.8z`})]});function Ry(){return r("g",{children:[r(kt,{fill:"#2a1416"}),r("g",{class:"tama-errors",children:[r("path",{d:"M25.4 7.1 l3.2 3.2 M28.6 7.1 l-3.2 3.2",fill:"none",stroke:"#e05252","stroke-width":"0.8","stroke-linecap":"square"}),r(Ue,{x:"29.4",y:"10.7",size:"1.8",fill:"#e05252",children:"CI"})]}),r(ko,{x:24.6}),r(ko,{x:28.4}),r("g",{fill:"#f4f4f6","shape-rendering":Ve,children:[r("circle",{class:"tama-spray",cx:"23",cy:"6",r:"0.5"}),r("circle",{class:"tama-spray tama-spray2",cx:"23",cy:"6",r:"0.6"}),r("circle",{class:"tama-spray tama-spray3",cx:"23",cy:"6",r:"0.45"})]})]})}function Fy(){return r("g",{"shape-rendering":Ve,children:[r("path",{d:"M20.4 9.2 q0.8 -1.6 2.3 -2.6",fill:"none",stroke:"#2b2f36","stroke-width":"0.35"}),r("rect",{x:"19.3",y:"9.3",width:"1.5",height:"3.8",rx:"0.55",fill:"#d03a3a"}),r("rect",{x:"19.6",y:"8.7",width:"0.9",height:"0.7",fill:"#3b404a"}),r("rect",{x:"19.5",y:"10.4",width:"1.1",height:"0.9",fill:"#f4f4f6"})]})}const Ny=Array.from({length:18},(e,t)=>[23.6+t*1.7%7.4,6.2+t*1.3%4.8]),By=Array.from({length:18},(e,t)=>[24.1+t*2.3%7.2,6.5+t*.9%4.8]);function zy(){const e=t=>t.map(([n,i])=>r("rect",{x:n.toFixed(1),y:i.toFixed(1),width:"0.6",height:"0.6"},`${n},${i}`));return r("g",{children:[r(kt,{fill:"#22252b"}),r("g",{class:"tama-static",fill:"#8b93a1",children:e(Ny)}),r("g",{class:"tama-static tama-static2",fill:"#5d6470",children:e(By)}),r("rect",{x:"25.2",y:"7.8",width:"4.6",height:"2.4",fill:"#22252b"}),r(Ue,{x:"27.5",y:"9.7",size:"2",fill:"#ffd166",anchor:"middle",children:"529"})]})}function jy(){return r("g",{class:"tama-stack",children:Array.from({length:12},(e,t)=>r("rect",{x:20.5+(t%2?.35:0),y:(12.65-t*.68).toFixed(2),width:"2.6",height:"0.55",fill:t%2?"#f2ece0":"#e2dccf"},t))})}function Hy({pct:e,cost:t}){if(t)return r("g",{children:[r(kt,{}),r(Ue,{x:"27.5",y:"9.6",size:"1.7",fill:"#f2a33a",anchor:"middle",children:"compact?"})]});const n=Math.min(100,Math.max(0,e??90));return r("g",{children:[r(kt,{}),r(Ue,{x:"24.2",y:"7.9",size:"1.4",fill:"#a4acb9",weight:500,children:"context"}),r("rect",{x:"24.2",y:"8.6",width:"6.6",height:"1.5",fill:"none",stroke:"#707884","stroke-width":"0.25"}),r("rect",{class:"tama-fill",x:"24.4",y:"8.8",width:6.2*n/100,height:"1.1",fill:"#f2a33a"}),e!=null&&r(Ue,{x:"30.8",y:"11.3",size:"1.5",fill:"#f2a33a",anchor:"end",children:`${e}%`})]})}const qy=["#52b4ea","#7fbf7f","#c792ea","#e6e9ef"],Uy=[.85,.55,.7,.4,.9,.6],Wy={1:[[23.4,6,8.2,5]],2:[[23.4,6,4.1,5],[27.5,6,4.1,5]],4:[[23.4,6,4.1,2.5],[27.5,6,4.1,2.5],[23.4,8.5,4.1,2.5],[27.5,8.5,4.1,2.5]]};function Ky({n:e}){const t=e===0?[]:Wy[e===1?1:e===2?2:4];let n=0;return r("g",{children:[r(kt,{}),r("rect",{x:"23.4",y:"11",width:"8.2",height:"0.6",fill:e?"#3d8f5a":"#2c4234"}),e===0&&r("rect",{class:"tama-cursor",x:"24",y:"6.6",width:"0.6",height:"0.6",fill:"#707884"}),t.length>=2&&r("rect",{x:"27.45",y:"6",width:"0.12",height:"5",fill:"#4b515c"}),t.length===4&&r("rect",{x:"23.4",y:"8.45",width:"8.2",height:"0.12",fill:"#4b515c"}),t.slice(0,Math.min(e,4)).flatMap(([i,l,a,s])=>Array.from({length:s>=5?3:2},(o,u)=>{const c=n++;return r("rect",{class:"tama-type",style:{animationDelay:`${(-.37*c).toFixed(2)}s`},x:(i+.5).toFixed(2),y:(l+.6+u*1.1).toFixed(2),width:((a-1)*Uy[c%6]).toFixed(2),height:"0.45",fill:qy[c%4]},c)}))]})}function Vy({day:e,time:t}){const n=Math.min(3,7.6/(.6*t.length));return r("g",{children:[r(kt,{fill:"#16181d"}),r(Ue,{x:"24.1",y:"7.9",size:"1.3",fill:"#a4acb9",weight:500,children:e?`back ${e}`:"back at"}),r(Ue,{x:"27.5",y:"10.9",size:n.toFixed(2),fill:"#f2c14e",anchor:"middle",children:t}),r("circle",{cx:"30.85",cy:"6.95",r:"0.5",fill:"#f3e9c6"}),r("circle",{cx:"31.1",cy:"6.8",r:"0.42",fill:"#16181d"})]})}function Gy(){return r("g",{fill:"var(--fg-2)","font-family":"var(--mono)","font-weight":"700",children:[r("text",{class:"tama-z",x:"17.5",y:"8.4","font-size":"3",children:"z"}),r("text",{class:"tama-z tama-z2",x:"19.6",y:"6","font-size":"3.8",children:"Z"})]})}function Jy({x0:e}){return r("g",{fill:we,children:[r("rect",{x:e+5.5,y:V+2.6,width:"1",height:"1.6"}),r("rect",{x:e+12.5,y:V+2.6,width:"1",height:"1.6"})]})}function Qy(){return r("g",{class:"tama-parcel","shape-rendering":Ve,children:[r("rect",{x:"24.6",y:"15.6",width:"4.8",height:"3.4",fill:"#c49a6c"}),r("rect",{x:"24.6",y:"15.6",width:"4.8",height:"0.7",fill:"#d8b384"}),r("rect",{x:"26.75",y:"15.6",width:"0.5",height:"3.4",fill:"#a57c4f"}),r("rect",{x:"28.3",y:"14.4",width:"2.2",height:"1.8",rx:"0.25",fill:"#52b4ea"}),r("path",{d:"M29.4 14.75 v1 M28.95 15.3 l0.45 0.5 l0.45 -0.5",fill:"none",stroke:"#ffffff","stroke-width":"0.28"})]})}const Yy={code:{x0:3,sitting:!0},nap:{x0:3,sitting:!0},read:{x0:4,sitting:!0}},Zy={x0:8},bd=qt(Tn),Xy=qt(Tn.map((e,t)=>t===2?e.replace(/^.##/,"...").replace(/##$/,".."):e)),Ql=od.map(e=>qt([e])),Yl=V+2*Tn.length;function e2(){return r("g",{children:[r(nt,{cells:bd,cls:"tama-body",x0:0}),r(Zl,{x0:0}),r(nt,{cells:Ql[0],cls:"tama-legs-a",x0:0,y0:Yl})]})}const t2=new Set([Ja,Qa]),n2={beer:"pint",coffee:"mug",cook:"spoon",garden:"can",dog:"leash",music:"bass",game:"controller"};function zn({dy:e,children:t}){return e?r("g",{transform:`translate(0 ${e})`,children:t}):t}function Zl({closed:e,x0:t}){return r("g",{class:e?"tama-eyes-closed":"tama-eyes",children:A0.map(n=>r("rect",{x:t+n,y:e?V+3.3:V+2,width:"1",height:e?.5:2,fill:we},n))})}const wo={spring:{sky:"#7fb3e0",ground:"#5c9a4c",canopy:["#6fae5a","#f2a7c3"],fall:"#f4b6cc"},summer:{sky:"#6fb4ea",ground:"#4f9443",canopy:["#4f9a46","#3f8238"]},autumn:{sky:"#c9a36b",ground:"#7a6a3a",canopy:["#d9822b","#b5452a"],fall:"#e07b39"},winter:{sky:"#9fb3c8",ground:"#e6edf3",fall:"#f4f8fb"}},r2=[[3,0],[11,-.7],[18,-1.6],[25.5,-.3],[32,-1.1]];function i2({season:e,night:t}){const n=wo[e]||wo.summer;return r("g",{class:"tama-scenery","data-season":e,children:[r("rect",{x:"0",y:"0",width:"34",height:"19.2",fill:n.sky,opacity:"0.13"}),r("rect",{x:"0",y:"19.4",width:"34",height:"4.6",fill:n.ground,opacity:e==="winter"?.85:.55}),t&&r("g",{children:[r("rect",{x:"0",y:"0",width:"34",height:"24",fill:"#0b0a1a",opacity:"0.5"}),r("g",{class:"tama-moon",children:[r("circle",{cx:"5",cy:"4.2",r:"2",fill:"#f3e9c6"}),r("circle",{cx:"4.3",cy:"3.7",r:"0.4",fill:"#d8ccaa"}),r("circle",{cx:"5.7",cy:"4.9",r:"0.3",fill:"#d8ccaa"})]}),r("g",{transform:"translate(19 3.2)",children:r("path",{class:"tama-bat",fill:"#1a1626",d:"M0 0.6 q1 -1 2 0 q0.4 -0.8 1 -0.2 q0.6 -0.6 1 0.2 q1 -1 2 0 q-1.2 0.1 -2 1 q-0.6 -0.4 -1 0 q-0.4 -0.4 -1 0 q-0.8 -0.9 -2 -1z"})})]}),e==="summer"&&!t&&r("circle",{class:"tama-sun",cx:"4.5",cy:"4",r:"2.1",fill:"#ffd166"}),r("rect",{x:"30.2",y:"11.6",width:"1.4",height:"7.6",fill:"#6b4a33"}),n.canopy?r("g",{children:[r("rect",{x:"27.4",y:"7.4",width:"6.6",height:"4.6",rx:"1.4",fill:n.canopy[0]}),r("rect",{x:"28.4",y:"5.8",width:"4.6",height:"2.2",rx:"1",fill:n.canopy[0]}),r("g",{fill:n.canopy[1],children:[r("rect",{x:"28.2",y:"8.2",width:"0.8",height:"0.8"}),r("rect",{x:"31.4",y:"7",width:"0.8",height:"0.8"}),r("rect",{x:"32.4",y:"9.8",width:"0.8",height:"0.8"}),r("rect",{x:"29.6",y:"10.4",width:"0.8",height:"0.8"})]})]}):r("g",{stroke:"#6b4a33","stroke-width":"0.5",children:[r("line",{x1:"30.9",y1:"12",x2:"28.4",y2:"8.2"}),r("line",{x1:"30.9",y1:"11",x2:"33.4",y2:"8"}),r("line",{x1:"30.9",y1:"9.6",x2:"30.4",y2:"6.2"})]}),e==="spring"&&r("g",{children:[r("rect",{x:"3",y:"19.8",width:"0.7",height:"0.7",fill:"#f2a7c3"}),r("rect",{x:"6.5",y:"20.6",width:"0.7",height:"0.7",fill:"#ffd166"}),r("rect",{x:"26",y:"20.2",width:"0.7",height:"0.7",fill:"#f2a7c3"})]}),e==="summer"&&r("g",{fill:"#3f8238",children:[r("rect",{x:"2.6",y:"18.4",width:"0.4",height:"1.2"}),r("rect",{x:"3.3",y:"18.1",width:"0.4",height:"1.5"}),r("rect",{x:"26.4",y:"18.3",width:"0.4",height:"1.3"})]}),e==="autumn"&&r("g",{fill:"#c2452d",children:[r("rect",{x:"4",y:"19.7",width:"1",height:"0.5"}),r("rect",{x:"24.8",y:"20.1",width:"1",height:"0.5"}),r("rect",{x:"27.6",y:"19.6",width:"1",height:"0.5",fill:"#e07b39"})]}),n.fall&&r("g",{fill:n.fall,children:r2.map(([i,l])=>r("rect",{class:"tama-fall",x:i,y:"-1",width:"0.7",height:"0.7",style:{animationDelay:`${l}s`}},i))})]})}function l2({x:e,y:t}){return r("g",{class:"tama-jack","shape-rendering":"geometricPrecision",children:[r("rect",{x:e+1.3,y:t,width:"0.5",height:"0.7",fill:"#4f7a2c"}),r("rect",{x:e,y:t+.4,width:"3.1",height:"2.2",rx:"1",fill:"#ef8a2c"}),r("rect",{x:e+1,y:t+.5,width:"0.15",height:"2",fill:"#d9741f"}),r("rect",{x:e+1.95,y:t+.5,width:"0.15",height:"2",fill:"#d9741f"}),r("path",{class:"tama-jack-face",fill:"#ffcf5a",d:`M${e+.6} ${t+1.4} l0.4 -0.6 l0.4 0.6z M${e+2.1} ${t+1.4} l0.4 -0.6 l0.4 0.6z M${e+.6} ${t+1.8} h1.9 l-0.3 0.5 h-1.3z`})]})}const a2={sleep:{x:1.5,y:16.4},coffee:{x:1.5,y:16.4},eat:{x:1.5,y:16.4},code:{x:25.5,y:16.4},nap:{x:25.5,y:16.4},read:{x:24.6,y:3.4}};function s2(){return r("g",{class:"tama-xmas-tree","shape-rendering":"geometricPrecision",children:[r("rect",{x:"2.9",y:"18.2",width:"1",height:"0.8",fill:"#5a3a26"}),r("polygon",{points:"3.4,12 7.6,18.2 -0.8,18.2",fill:"#276b3e"}),r("polygon",{points:"3.4,8.6 7.2,14.6 -0.4,14.6",fill:"#2f7d4a"}),r("polygon",{points:"3.4,5.2 6.8,10.8 0,10.8",fill:"#276b3e"}),r("polygon",{points:"3.4,2.4 6.2,7.2 0.6,7.2",fill:"#2f7d4a"}),r("polygon",{class:"tama-twinkle",points:"3.4,0.8 3.8,1.8 4.8,1.9 4,2.5 4.3,3.4 3.4,2.9 2.5,3.4 2.8,2.5 2,1.9 3,1.8",fill:"#ffd166"}),r("circle",{cx:"2.6",cy:"6.2",r:"0.42",fill:"#e05252"}),r("circle",{class:"tama-twinkle",cx:"4.6",cy:"9.4",r:"0.42",fill:"#7fb6e6"}),r("circle",{cx:"1.4",cy:"10",r:"0.42",fill:"#ffd166"}),r("circle",{class:"tama-twinkle tama-twinkle2",cx:"5.6",cy:"12.8",r:"0.42",fill:"#e05252"}),r("circle",{cx:"0.8",cy:"13.8",r:"0.42",fill:"#c792ea"}),r("circle",{cx:"6.6",cy:"16.6",r:"0.42",fill:"#ffd166"})]})}function o2(){return r("g",{class:"tama-stocking",children:[25.4,30.2].map(e=>r("g",{children:[r("rect",{x:e,y:"7.1",width:"1.2",height:"2.1",fill:"#c0392b"}),r("rect",{x:e,y:"8.6",width:"2",height:"0.9",rx:"0.4",fill:"#c0392b"}),r("rect",{x:e-.1,y:"7.1",width:"1.4",height:"0.6",fill:"#f4f4f6"})]},e))})}function kd({x0:e}){return r("g",{class:"tama-hat-santa",children:[r("g",{fill:"#d03a3a",children:[r("rect",{x:e+4,y:"6.8",width:"10",height:"1.5"}),r("rect",{x:e+5.6,y:"5.6",width:"6.6",height:"1.3"}),r("rect",{x:e+7.4,y:"4.6",width:"3.6",height:"1.1"}),r("rect",{x:e+10.6,y:"4.6",width:"3",height:"1"}),r("rect",{x:e+13,y:"5.2",width:"1.2",height:"1"})]}),r("rect",{x:e+3,y:"8.2",width:"12",height:"1.3",rx:"0.5",fill:"#f4f4f6"}),r("rect",{x:e+13.6,y:"5.6",width:"1.6",height:"1.6",rx:"0.8",fill:"#f4f4f6"})]})}function wd({x0:e}){return r("g",{class:"tama-hat-party","shape-rendering":"geometricPrecision",children:[r("polygon",{points:`${e+6.6},9 ${e+11.4},9 ${e+9},3.8`,fill:"#5aa9e6"}),r("rect",{x:e+7.5,y:"6.8",width:"3",height:"0.6",fill:"#ffd166"}),r("rect",{x:e+8.25,y:"5.2",width:"1.5",height:"0.5",fill:"#ffd166"}),r("circle",{cx:e+9,cy:"3.6",r:"0.8",fill:"#f28ab2"})]})}function c2({sprite:e,p:t,hat:n,season:i,ghost:l}){const a=(t==null?void 0:t.Headwear)&&!n,s=(t==null?void 0:t.snowcap)&&i==="winter"&&!n&&!l;return!a&&!s&&!n?null:r("g",{class:"tama-hat-seat",style:"transform-box: view-box",transform:vg(e),children:[a&&r(t.Headwear,{x0:0}),s&&r("rect",{class:"tama-snowcap",x:"3",y:"8.4",width:"12",height:"0.7",rx:"0.3",fill:"#f4f8fb"}),n==="santa"&&r(kd,{x0:0}),n==="party"&&r(wd,{x0:0})]})}function u2({x0:e}){const t=e+2.2,n=e+15.8,i="q-0.85 1.1 -1.7 0 ".repeat(8);return r("g",{class:"tama-ghost","shape-rendering":"geometricPrecision",children:[r("path",{fill:"#f5f5f7",d:`M${t} 17.6 V10.4 Q${t} 7.6 ${(t+n)/2} 7.6 Q${n} 7.6 ${n} 10.4 V17.6 ${i}Z`}),r("ellipse",{cx:e+5.6,cy:"11.6",rx:"0.7",ry:"1",fill:we}),r("ellipse",{cx:e+12.4,cy:"11.6",rx:"0.7",ry:"1",fill:we}),r("ellipse",{cx:e+9,cy:"14",rx:"0.6",ry:"0.8",fill:we})]})}function d2({x0:e}){const t=e+16.4;return r("g",{class:"tama-pail","shape-rendering":"geometricPrecision",children:[r("path",{d:`M${t+.3} 13.8 Q${t+1.8} 11.2 ${t+3.3} 13.8`,fill:"none",stroke:"#3a2a1a","stroke-width":"0.35"}),r("rect",{x:t+.9,y:"13.1",width:"0.7",height:"0.7",fill:"#e05252"}),r("rect",{x:t+1.9,y:"12.9",width:"0.7",height:"0.7",fill:"#7fb6e6"}),r("rect",{x:t,y:"13.6",width:"3.6",height:"3.2",rx:"1.2",fill:"#ef8a2c"}),r("path",{fill:"#3a1e0e",d:`M${t+.7} 14.9 l0.5 -0.7 l0.5 0.7z M${t+2} 14.9 l0.5 -0.7 l0.5 0.7z M${t+.7} 15.5 h2.2 l-0.4 0.6 h-1.4z`})]})}const h2=[[5,4,"#ffd166",0],[22,2.6,"#f28ab2",-.9]],f2=[[17.4,2.8,"#ffd166",0],[24.6,2.1,"#f28ab2",-.6],[31.2,3,"#7fb6e6",-1.2]];function p2({clear:e}){const t=(n,i,l,a)=>r("g",{class:"tama-firework",style:{animationDelay:`${a}s`},fill:l,children:[[0,45,90,135,180,225,270,315].map(s=>{const o=s*Math.PI/180;return r("rect",{x:n+Math.cos(o)*1.8-.25,y:i+Math.sin(o)*1.8-.25,width:"0.5",height:"0.5"},s)}),r("rect",{x:n-.25,y:i-.25,width:"0.5",height:"0.5"})]},n);return r("g",{children:(e?f2:h2).map(([n,i,l,a])=>t(n,i,l,a))})}const vo=["#ffd166","#f28ab2","#7fb6e6","#9be38f","#c792ea"];function m2(){return r("g",{class:"tama-confetti",children:[[2.5,0],[9,-.6],[15,-1.4],[21,-.3],[27,-1.9],[32,-1]].map(([e,t],n)=>r("rect",{class:"tama-fall",x:e,y:"-1",width:"0.6",height:"0.6",fill:vo[n%vo.length],style:{animationDelay:`${t}s`}},e))})}function g2({mood:e}){return e==="furious"?r("g",{class:"tama-errors",fill:"#e05252",children:[r("rect",{x:"24",y:"7",width:"4.4",height:"0.6"}),r("rect",{x:"24",y:"8.4",width:"6.2",height:"0.6"}),r("rect",{x:"24.8",y:"9.8",width:"3.6",height:"0.6"}),r("rect",{x:"29.4",y:"9.8",width:"0.6",height:"0.6",fill:"#ffd166"})]}):r("g",{children:[r("rect",{x:"24",y:"7",width:"4.4",height:"0.6",fill:"var(--accent)"}),e==="grumpy"?r("rect",{class:"tama-red-line",x:"24",y:"8.4",width:"3",height:"0.6",fill:"#e05252"}):r("rect",{x:"24",y:"8.4",width:"3",height:"0.6",fill:"#7fbf7f"}),r("rect",{x:"24.8",y:"9.8",width:"3.4",height:"0.6",fill:"#c792ea"}),r("rect",{class:"tama-cursor",x:"28.6",y:"9.8",width:"0.6",height:"0.6",fill:"#e6e9ef"})]})}function y2({activity:e,occasion:t,coffee:n,ringing:i,keyboard:l=!0,mood:a="calm",screen:s=null,dish:o,mugHeld:u=!1}){switch(e){case"sleep":return i?null:r("g",{fill:"var(--fg-2)","font-family":"var(--mono)","font-weight":"700",children:[r("text",{class:"tama-z",x:"26",y:"10","font-size":"4",children:"z"}),r("text",{class:"tama-z tama-z2",x:"29",y:"7","font-size":"5",children:"Z"})]});case"coffee":return r("g",{children:!u&&r(pd,{})});case"code":return r("g",{children:[r("g",{class:"tama-chair",fill:"#4c525c",children:[r("rect",{x:"1.6",y:"9.6",width:"1.6",height:"8.4",rx:"0.5"}),r("rect",{x:"3.2",y:"16.9",width:"15",height:"1.3",rx:"0.4"}),r("rect",{x:"10",y:"18.2",width:"1.2",height:"0.8"}),r("rect",{x:"7",y:"18.6",width:"7.2",height:"0.5",rx:"0.25"})]}),r("g",{class:"tama-desk",children:[r("rect",{x:"20.2",y:"13.2",width:"13.6",height:"0.9",fill:"#8b6a4e"}),r("rect",{x:"21",y:"14.1",width:"0.9",height:"4.9",fill:"#6f533c"}),r("rect",{x:"32.2",y:"14.1",width:"0.9",height:"4.9",fill:"#6f533c"}),r("rect",{x:"26.9",y:"12",width:"1.2",height:"1.2",fill:"var(--fg-3)"}),r("rect",{x:"23",y:"5.6",width:"9",height:"6.4",rx:"0.4",fill:a==="furious"?"#2a1416":"#1d2026",stroke:"var(--fg-3)","stroke-width":"0.3"}),s||r(g2,{mood:a}),l&&r("rect",{x:"20.4",y:"12.6",width:"4.2",height:"0.6",rx:"0.2",fill:"#c9ced6"})]}),n&&r("g",{class:"tama-desk-mug",children:[r("rect",{class:"tama-steam",x:"25.2",y:"9.4",width:"0.4",height:"1.4",fill:"var(--fg-3)"}),r("rect",{class:"tama-steam tama-steam2",x:"25.9",y:"8.8",width:"0.4",height:"1.4",fill:"var(--fg-3)"}),r("g",{fill:"#efe6d8",children:[r("rect",{x:"24.9",y:"11.3",width:"1.5",height:"1.9",rx:"0.25"}),r("rect",{x:"26.4",y:"11.8",width:"0.5",height:"0.35"}),r("rect",{x:"26.6",y:"11.8",width:"0.3",height:"1"}),r("rect",{x:"26.4",y:"12.5",width:"0.5",height:"0.35"})]}),r("rect",{x:"24.9",y:"11.3",width:"1.5",height:"0.45",fill:"#7a4e2d"})]})]});case"read":return r("g",{children:[r("ellipse",{class:"tama-glow",cx:"28",cy:"19",rx:"9",ry:"2.4",fill:"#f0a24a",opacity:"0.18"}),r("g",{class:"tama-fire",children:[r("rect",{x:"23.4",y:"6",width:"10.6",height:"1.1",fill:"#8a7a6a"}),r("rect",{x:"24.2",y:"7.1",width:"9.8",height:"11.9",fill:"#7b4a3a"}),r("g",{fill:"#6a3e30",children:[r("rect",{x:"24.2",y:"9.4",width:"9.8",height:"0.3"}),r("rect",{x:"24.2",y:"11.8",width:"9.8",height:"0.3"}),r("rect",{x:"24.2",y:"14.2",width:"9.8",height:"0.3"}),r("rect",{x:"24.2",y:"16.6",width:"9.8",height:"0.3"})]}),r("rect",{x:"25.8",y:"11",width:"6.6",height:"8",rx:"2.4",fill:"#1a1110"}),r("path",{class:"tama-flame",d:"M27.2 19 q-0.6 -2.6 1 -4.4 q0.2 1.6 1 2.2 q0.4 -1.4 1.4 -2.4 q1 2.6 0.2 4.6z",fill:"#f08a3c"}),r("path",{class:"tama-flame tama-flame2",d:"M28 19 q-0.2 -1.6 0.9 -2.8 q0.3 1.1 0.9 1.4 q0.5 -0.8 0.6 -1.4 q0.9 1.6 0.2 2.8z",fill:"#ffd166"}),r("rect",{x:"26.6",y:"18.4",width:"5",height:"0.6",rx:"0.3",fill:"#5a3a26"})]}),t==="yearend"&&r(o2,{}),t==="yearend"&&r(s2,{}),r("g",{class:"tama-chair",fill:"#8e3b3b",children:[r("rect",{x:"1",y:"8.6",width:"3.2",height:"9.6",rx:"1"}),r("rect",{x:"3.6",y:"16.8",width:"16.8",height:"1.5",rx:"0.6"})]}),r("g",{class:"tama-chair-legs",fill:"#4a2f22",children:[r("rect",{x:"1.5",y:"18.2",width:"0.9",height:"0.8"}),r("rect",{x:"5",y:"18.2",width:"0.9",height:"0.8"}),r("rect",{x:"16.4",y:"18.2",width:"0.9",height:"0.8"})]})]});case"eat":return r(Q0,{dish:o});default:return null}}function b2({p:e,season:t,trick:n,critter:i,from:l}){const a=r(e.Behind,{season:t,trick:n,critter:i,from:l});return e.outdoors?r("g",{children:[r(i2,{season:t,night:n}),a]}):a}function k2({activity:e}){return e!=="read"?null:r("g",{children:[r("rect",{class:"tama-chair",x:"17.4",y:"13.6",width:"3.6",height:"4.7",rx:"0.8",fill:"#7a3030"}),r("rect",{class:"tama-chair-legs",x:"19.6",y:"18.2",width:"0.9",height:"0.8",fill:"#4a2f22"}),r("g",{class:"tama-book",children:[r("rect",{x:"17.4",y:"10.6",width:"2.9",height:"3.4",fill:"#f2ece0"}),r("rect",{x:"20.3",y:"10.6",width:"2.9",height:"3.4",fill:"#ebe3d3"}),r("g",{fill:"#c9bfae",children:[r("rect",{x:"17.9",y:"11.4",width:"1.9",height:"0.3"}),r("rect",{x:"17.9",y:"12.3",width:"1.6",height:"0.3"}),r("rect",{x:"20.8",y:"11.4",width:"1.9",height:"0.3"}),r("rect",{x:"20.8",y:"12.3",width:"1.5",height:"0.3"})]}),r("rect",{class:"tama-page",x:"20.3",y:"10.6",width:"2.9",height:"3.4",fill:"#f6f1e6"}),r("rect",{x:"20.15",y:"10.6",width:"0.3",height:"3.4",fill:"#b9ae9b"})]})]})}function w2({x0:e,mood:t}){return r("g",{class:"tama-mood",children:[t==="furious"&&r("g",{class:"tama-flush",fill:"#ff3b2f",opacity:"0.5",children:[r("rect",{x:e+3,y:V,width:"12",height:"4"}),r("rect",{x:e+1,y:V+4,width:"16",height:"2"}),r("rect",{x:e+3,y:V+6,width:"12",height:"2"})]}),r("g",{class:"tama-brows",fill:we,children:[r("rect",{x:e+5,y:V+2.9,width:"1",height:"1.1"}),r("rect",{x:e+12,y:V+2.9,width:"1",height:"1.1"}),r("rect",{x:e+3.9,y:V+1.5,width:"1.3",height:"0.55"}),r("rect",{x:e+5.1,y:V+2.05,width:"1.3",height:"0.55"}),r("rect",{x:e+11.6,y:V+2.05,width:"1.3",height:"0.55"}),r("rect",{x:e+12.8,y:V+1.5,width:"1.3",height:"0.55"})]}),t==="furious"&&r("path",{class:"tama-scowl",fill:"none",stroke:we,"stroke-width":"0.35","shape-rendering":"geometricPrecision",d:`M${e+7.4} ${V+6} l0.8 -0.6 l0.8 0.6 l0.8 -0.6 l0.8 0.6`}),r("g",{fill:Ht,children:[r("rect",{class:"tama-hand",x:"20.7",y:"11.9",width:"1.1",height:"0.8"}),r("rect",{class:"tama-hand tama-hand2",x:"22.7",y:"11.9",width:"1.1",height:"0.8"})]}),r("g",{class:"tama-clack",fill:"#e6e9ef",children:[r("rect",{x:"21.1",y:"10.9",width:"0.25",height:"0.55"}),r("rect",{x:"23.3",y:"10.8",width:"0.25",height:"0.55"})]})]})}function v2({mood:e,x0:t,coffee:n,hat:i,headDy:l}){return e!=="furious"?null:r("g",{children:[r("g",{fill:"#c9ced6",children:[r("rect",{class:"tama-flying-key",x:"21.4",y:"12",width:"0.7",height:"0.7"}),r("rect",{class:"tama-flying-key tama-flying-key2",x:"23.1",y:"12",width:"0.7",height:"0.7"}),r("rect",{class:"tama-flying-key tama-flying-key3",x:"22.3",y:"12",width:"0.6",height:"0.6"})]}),r("g",{fill:"#8b93a1","shape-rendering":"geometricPrecision",children:[r("circle",{class:"tama-smoke",cx:"21.6",cy:"12.2",r:"0.5"}),r("circle",{class:"tama-smoke tama-smoke2",cx:"23.4",cy:"12.2",r:"0.45"})]}),!i&&r(zn,{dy:l,children:r("g",{class:"tama-shimmer",fill:"none",stroke:"#ff8a5c","stroke-width":"0.3",opacity:"0.8","shape-rendering":"geometricPrecision",children:[6,9,12].map((a,s)=>r("path",{class:s===1?"tama-shimmer2":void 0,d:`M${t+a} ${s===1?7.2:7.6} q0.5 -0.7 0 -1.4 q-0.5 -0.7 0 -1.4`},a))})}),n&&r("g",{class:"tama-spill",fill:"#7a4e2d","shape-rendering":"geometricPrecision",children:[r("circle",{cx:"25.4",cy:"11.1",r:"0.25"}),r("circle",{class:"tama-spill2",cx:"26",cy:"11",r:"0.22"})]})]})}const _2=new Set(["bell","done","merged","api","ctx"]);function x2({activity:e,view:t,kind:n,duty:i,working:l,walled:a,mirroring:s}){return e==="nap"?r(Vy,{...a}):t.atDesk?n==="done"?r(Oy,{}):n==="merged"?r(Dy,{}):n==="ci"?r(Ry,{}):n==="api"?r(zy,{}):n==="ctx"?r(Hy,{pct:i==null?void 0:i.pct,cost:i==null?void 0:i.cost}):s?r(Ky,{n:l}):null:null}function S2({kind:e}){return r("g",{children:[e==="bell"&&r(My,{}),e==="ctx"&&r(jy,{}),e==="update"&&r(Qy,{})]})}function $2({activity:e,season:t="summer",occasion:n=null,coffee:i=!1,mood:l="calm",petted:a=!1,petKey:s=0,duty:o=null,working:u,walled:c=null,party:p=!1,dish:d,trick:f=!1,critter:h=pi[0]}){var Me;const m=(o==null?void 0:o.kind)||null,b=Wu(e,m),{atDesk:x}=b,w=f,C=by[e],y=C&&f?{...C,...C.trick}:C,{x0:g,sitting:$=!1,lift:v=0}=(y==null?void 0:y.pose)||Yy[e]||Zy,E=y?y.jack:a2[e],M=h.sprite,T=M&&Sa(M,{x0:g,sitting:$,height:w?su:xa}),S=T?N(T.top-V):0,R=e==="sleep"||e==="nap",F=m==="bell"&&R,q=R&&!F,L=m==="bell"&&(x||e==="nap"),I=w||q?null:x||_2.has(m)?m:null,O=!w&&!q&&(I==="done"||I==="merged"),Q=I==="merged",A=p&&!w&&!q?"party":n==="yearend"?"santa":n==="newyear"?"party":null,z=b.moodShown&&((Me=vn[l])==null?void 0:Me.rank)>0,k=b.showsPanes&&u!=null&&!z,W=x2({activity:e,view:b,kind:m,duty:o,working:u,walled:c,mirroring:k}),Z=w?r(u2,{x0:g}):M?null:z?r(w2,{x0:g,mood:l}):q?r(Zl,{closed:!0,x0:g}):O?r(bo,{x0:g}):I==="api"?r(vy,{x0:g}):I==="update"?r(Jy,{x0:g}):!I&&(y!=null&&y.smile)?r(bo,{x0:g}):r(Zl,{x0:g}),_=!M||w||q||z?null:O?"happy":I==="api"?"x":I==="update"?"down":I==="ctx"?"worried":!I&&(y!=null&&y.smile)?"happy":null,X=M&&(y==null?void 0:y.Held)===Ja?"goggles":M&&(y==null?void 0:y.Held)===Qa?"scarf":null,he=M?n2[e]??null:null,fe=he==="spoon"||he==="leash"?xg(M,he,T):null,He=he==="bass"?Fs(T,[g+po.dx,po.y]):null,Ae=M&&(z?Ty:L?Ey:null),ue=He??(Ae?Fs(T,Ae):null);return r("svg",{viewBox:"0 0 34 24","shape-rendering":"crispEdges","aria-hidden":"true","data-activity":e,"data-occasion":n||void 0,"data-mood":z?l:void 0,"data-duty":m||void 0,"data-pose":I||void 0,"data-urgent":o!=null&&o.urgent?"":void 0,"data-working":k?Math.min(u,4):void 0,"data-critter":M?h.id:void 0,"data-tempo":y==null?void 0:y.tempo,"data-stride":y!=null&&y.stride?"":void 0,style:y&&`--tama-tempo: ${y.tempo}s`,children:[r("rect",{x:"0",y:"19",width:"34",height:"0.4",fill:"var(--line)"}),(n==="newyear"||Q)&&r(p2,{clear:!!o}),y?r(b2,{p:y,season:t,trick:f,critter:h,from:fe}):r(y2,{activity:e==="nap"?"code":e,occasion:n,coffee:i,ringing:F,keyboard:!(L||x&&m==="ctx"),mood:z?l:"calm",screen:W,dish:d,mugHeld:he==="mug"}),n==="halloween"&&E&&r(l2,{...E}),r("g",{transform:v?`translate(0 ${-v})`:void 0,children:r("g",{class:`tama-creature${a?" tama-hop":""}`,children:[M?r("g",{class:"tama-critter",style:"transform-box: view-box",transform:`translate(${T.tx} ${T.ty}) scale(${T.scale})`,children:[r(Gi,{sprite:M,mood:z?l:"calm",asleep:q,face:_,startle:I==="bell"&&!L,worn:X,holding:he,tip:ue,paws:!!(y!=null&&y.paws),cheer:x&&O,seated:$,stride:!!(y!=null&&y.stride),children:He&&r("g",{style:"transform-box: view-box",transform:`scale(${1/T.scale}) translate(${-T.tx} ${-T.ty})`,children:r(dd,{x0:g,limb:M.limb})})}),r(c2,{sprite:M,p:y,hat:A,season:t,ghost:w}),he&&r(hd,{sprite:M,kind:he,scale:T.scale})]}):r(nt,{cells:y!=null&&y.paws?Xy:bd,cls:"tama-body",x0:g}),Z,(y==null?void 0:y.Held)&&!(M&&(t2.has(y.Held)||he))&&r(y.Held,{x0:g}),he==="spoon"&&r(gd,{x0:g,from:fe}),he==="controller"&&r("g",{transform:`translate(0 ${Math.min(T.drop,.8)})`,children:r(fd,{x0:g,limb:M.limb})}),!M&&r(zn,{dy:S,children:(y==null?void 0:y.Headwear)&&!A&&r(y.Headwear,{x0:g})}),r(zn,{dy:S,children:I==="api"&&r(xy,{x0:g})}),!M&&I==="ctx"&&r(_y,{x0:g}),!M&&x&&O&&r($y,{x0:g}),x&&I==="ci"&&r(Fy,{}),!M&&L&&r(Cy,{}),M&&z&&r(Py,{limb:M.limb}),M&&L&&r(Ay,{limb:M.limb}),!M&&r(zn,{dy:S,children:I==="bell"&&!L&&r(Sy,{x0:g})}),!M&&!$&&r(nt,{cells:Ql[0],cls:"tama-legs-a",x0:g,y0:Yl}),!M&&(y==null?void 0:y.stride)&&r(nt,{cells:Ql[1],cls:"tama-legs-b",x0:g,y0:Yl}),w&&(y==null?void 0:y.pail)&&r(d2,{x0:g}),!M&&r(zn,{dy:S,children:[(y==null?void 0:y.snowcap)&&t==="winter"&&!A&&!w&&r("rect",{class:"tama-snowcap",x:g+3,y:"8.4",width:"12",height:"0.7",rx:"0.3",fill:"#f4f8fb"}),A==="santa"&&r(kd,{x0:g}),A==="party"&&r(wd,{x0:g})]})]},s)}),(y==null?void 0:y.Front)&&r(y.Front,{}),r(k2,{activity:e}),(x||L)&&r(S2,{kind:m}),e==="nap"&&!F&&r(Gy,{}),F&&e==="sleep"&&r(Ly,{}),O&&r(Iy,{}),z&&r(v2,{mood:l,x0:g,coffee:i,hat:A,headDy:S}),(n==="newyear"||Q)&&r(m2,{}),o&&r(wy,{kind:m,label:o.label,urgent:o.urgent,more:o.more,x0:g}),a&&r("g",{transform:`translate(${g-8} 0)`,children:r("path",{class:"tama-heart",fill:"#e8657a","shape-rendering":"geometricPrecision",d:"M17 7.2 l-2.3 -2.3 a1.25 1.25 0 0 1 2.3 -1.7 a1.25 1.25 0 0 1 2.3 1.7z"})},`heart-${s}`)]})}const C2=Vt(()=>au(gu())),vd=e=>e.map(t=>[t.since*1e3,t.until==null?1/0:t.until*1e3]),_o=e=>({...rd(Aa(),e),walls:vd(ga.value)});function T2(){const[e,t]=B(()=>new Date),[n,i]=B(0),[l,a]=B(!1),o=al(()=>{const O=Aa();return JSON.stringify([O.merged??null,O.furious??null,ga.value])}).value,[u,c,p]=JSON.parse(o),d={...rd({merged:u,furious:c},e),walls:vd(p)},f=te(o);j(()=>{if(f.current!==o){f.current=o,t(new Date);return}const O=setTimeout(()=>t(new Date),td(e,d)+50);return()=>clearTimeout(O)},[e,o]),j(()=>{const O=setInterval(()=>{const Q=new Date;t(A=>no(Q,_o(Q))===no(A,_o(A))?A:Q)},6e4);return()=>clearInterval(O)},[]),j(()=>{if(!l)return;const O=setTimeout(()=>a(!1),900);return()=>clearTimeout(O)},[l,n]);const h=$c(0);j(()=>{const O=setInterval(()=>{h.value+=1},6e4);return()=>clearInterval(O)},[]),j(()=>{L0()},[]);const m=C2.value,b=al(()=>{var z;h.value;const O=(z=Ri.value)==null?void 0:z.plan,Q=T0(O,Date.now()/1e3),A=Q.account&&$n()?yn(Q.account):null;return JSON.stringify([Q.mood,E0(Q,A)])}),[x,w]=JSON.parse(b.value);j(()=>{x==="furious"&&bu("furious",nd(new Date))},[x,Qi(e)]);const C=al(()=>{h.value;const O=Date.now()/1e3,Q=r0({windows:ce.value||[],alerts:nr.value||[],dismissedAlertIds:ir.value,dismissedNeedsPids:ft.value,dismissedReadyPids:pt.value,selectedPid:qu(ke.value),parties:pr.value,update:ma.value,nowSec:O}),A=Tc.value;return JSON.stringify({items:Q,more:i0(Q),wall:A&&a0(A.until,O),working:nr.value===null?null:Su(ce.value).length})}),y=JSON.parse(C.value),g=y.items[0]||null,$=fr(e,d),v=v0(e,d),E=Yi(e),M=sd(e),T=Wu($.id,g==null?void 0:g.kind),S=ro($,T.moodShown?x:"calm"),R=[...y.wall&&Zu(e,d)?[s0(y.wall)]:[],...y.items.map(O=>O.phrase),...T.showsPanes&&y.working?[`${wn(y.working,"agent")} working`]:[],...T.moodShown&&w?[w]:[],...M?[M]:[],...v?[`up next at ${P0(v.at)}: ${ro(v.activity)}`]:[]],F=`${m.sprite?m.name:"Claude"} is ${S} (${Gl($.from)}–${Gl($.to)})${R.map(O=>` · ${O}`).join("")}`+(g!=null&&g.target?` · click to ${g.target.says}`:"");function q(){i(O=>O+1),a(!0)}const L=te(g);L.current=g;const[I]=B(()=>G0({target:()=>{var O;return(O=L.current)==null?void 0:O.target},pet:q}));return j(()=>()=>I.dispose(),[]),r("button",{type:"button",class:"tama",title:F,"aria-label":F,onClick:I.onClick,onDblClick:I.onDblClick,children:r($2,{activity:$.id,dish:$.dish,trick:!!$.trick,season:xr(e),occasion:E==null?void 0:E.id,coffee:!!$.coffee,mood:x,petted:l,petKey:n,duty:g&&{kind:g.kind,label:g.label,urgent:!!g.urgent,more:y.more,pct:g.pct,cost:g.cost},working:y.working,walled:y.wall,party:y.items.some(O=>O.kind==="merged"),critter:m})})}const xo=["session","week_all","week_opus","week_sonnet"];function E2(e){const t=Object.keys(e).filter(n=>!xo.includes(n)).sort();return[...xo,...t].filter(n=>e[n]).map(n=>({key:n,label:Ua(n),m:e[n]}))}function P2(e){const t=lt.value.map(i=>i.id).filter(i=>e.includes(i)),n=e.filter(i=>!t.includes(i)).sort();return[...t,...n]}function A2(e,t){return e?P2(Object.keys(e)).map(n=>{const i=e[n]||{},l=i.available&&i.meters?E2(i.meters):[],a=l.length>0,s=a?l.reduce((o,u)=>(u.m.percent||0)>(o.m.percent||0)?u:o):null;return{id:n,label:yn(n),available:a,stale:a&&Ha(i,t),fetchedAt:i.fetched_at||null,meters:l,headline:s}}):[]}function M2(e){const t=(e.meters||[]).filter(n=>n!==e.headline);return{hot:t.filter(n=>n.m.hot),blow:t.filter(n=>!n.m.hot&&qa(n.m))}}const L2=48*3600;function _d(e){return e==="week_fable"||e.startsWith("week_fable_")}function I2(e,t){const n=(e==null?void 0:e.available)&&e.meters||{},i=Object.keys(n).find(_d),l=i&&n[i];if(!l||l.projected_percent==null||!l.resets_at)return!1;const a=l.resets_at-t;return l.projected_percent<100&&a>0&&al!=null);if(!t.length)return null;const n=Math.min(...t),i=Math.max(...t);return i<=e.percent?null:{text:i-n>10?`→${n}–${i}%`:`→${i}%`,blow:qa(e)}}function D2({a:e}){const{hot:t,blow:n}=M2(e);if(!t.length&&!n.length)return null;const i=[...t.map(l=>`${l.label}: burning 🔥`),...n.map(l=>`${l.label}: on track to hit its limit`)];return r("span",{class:`usage-acct-more${t.length?"":" blow"}`,title:[...i,"(click to show every meter)"].join(`
-`),children:t.length?"🔥":"→"})}function R2({label:e,m:t,resets:n,pace:i}){const l=t.percent,a=l>=90?"danger":l>=70?"warn":"ok",s=[`${e} — ${l}% used. ${n||""}`,...i].join(`
-`),o=O2(t);return r("div",{class:"usage-item",title:s,children:[r("span",{class:"usage-item-label",children:e}),r("span",{class:"usage-item-bar",children:r("span",{class:`usage-item-fill ${a}`,style:`width:${l}%`})}),r("b",{children:[l,"%"]}),o&&r("span",{class:`usage-item-proj${o.blow?" blow":""}`,children:o.text}),t.hot&&r("span",{class:"usage-item-hot",children:"🔥"})]})}const Xl=H(!1);function Cd(){Xl.value=!0}function F2(e,t,n,i){const l=e.meters.map(({m:a})=>[`${a.label}: ${a.percent}% used`,Sd(a.resets_at),...$d(a)].filter(Boolean).join(`
- `));if(n){const a=n.verified?`resets ${Si(n.resets_at)}`:"not anchored";l.push(`poked ${Si(n.at)} → ${a}`)}if(i){const a=e.meters.find(({key:s})=>_d(s));a&&l.push(`💤 fable on pace for ${a.m.projected_percent}% at reset — burn it or lose it`)}return e.stale&&l.push(`⚠ stale — last updated ${Pe(e.fetchedAt)} ago`),l.push(t?"(click to collapse)":"(click to show every meter)"),[`account ${e.label}`,...l].join(`
+`):[e.value],l=[];return i.forEach((a,s)=>{if(s&&l.push(r("br",{},`${n}b${s}`)),!t.cite){l.push(a);return}xg(a).forEach((o,c)=>{if(typeof o=="string"){l.push(o);return}const u=t.cite(o);l.push(u==null?o.raw:r("span",{children:u},`${n}c${s}-${c}`))})}),l.length===1?l[0]:l}case"inlineCode":{const i=t.cite?Wi(e.value):null,l=i?t.cite(i):null;return l!=null?r("span",{children:l},n):r("code",{class:"md-icode",children:e.value},n)}case"strong":return r("strong",{children:ze(e.children,t)},n);case"emphasis":return r("em",{children:ze(e.children,t)},n);case"delete":return r("del",{children:ze(e.children,t)},n);case"link":return r("a",{class:"md-link",href:bo(e.url,t),target:"_blank",rel:"noopener",children:ze(e.children,{...t,cite:null,zoom:!1})},n);case"image":if(!Ed.test(e.url)&&!t.resolveUrl)return e.alt||e.url;{const i=bo(e.url,t),l=e.alt||"";return t.zoom?r("button",{type:"button",class:"md-img-zoom","aria-label":l?`open image full size: ${l}`:"open image full size",onClick:()=>Cd({kind:"img",src:i,alt:l}),children:r("img",{class:"md-img is-zoomable",src:i,alt:l})},n):r("img",{class:"md-img",src:i,alt:l},n)}case"break":return r("br",{},n);case"html":return e.value;case"footnoteReference":return r("sup",{children:["[",e.label||e.identifier,"]"]},n);default:return e.children?ze(e.children,t):e.value??null}}function wy(e,t,n){const i=(e.children||[]).map((l,a)=>l.type==="paragraph"&&!e.spread?ze(l.children,t):ns(l,t,a));return e.checked==null?r("li",{children:i},n):r("li",{class:"md-task",children:[r("input",{type:"checkbox",checked:e.checked,disabled:!0})," ",i]},n)}function vy(e,t,n){const i=e.align||[],[l,...a]=e.children,s=l.children.length,o=u=>i[u]?`text-align:${i[u]}`:void 0,c=u=>Array.from({length:s},(h,d)=>u.children[d]??null);return r("table",{class:"md-table",children:[r("thead",{children:r("tr",{children:c(l).map((u,h)=>r("th",{style:o(h),children:u?ze(u.children,t):""},h))})}),r("tbody",{children:a.map((u,h)=>r("tr",{children:c(u).map((d,p)=>r("td",{style:o(p),children:d?ze(d.children,t):""},p))},h))})]},n)}function ns(e,t,n,i){switch(e.type){case"paragraph":return r("p",{class:"md-p",children:ze(e.children,t)},n);case"heading":{const a=`h${t.demote?Math.min(e.depth+2,6):e.depth}`;return r(a,{class:`md-h md-h${e.depth}`,children:ze(e.children,t)},n)}case"code":return t.mermaid&&e.lang==="mermaid"?r(Td,{code:e.value,zoom:t.zoom},n):r("pre",{class:"md-code",children:r("code",{children:t.highlight&&e.lang?t.highlight(e.value,e.lang):e.value})},n);case"blockquote":{const l=t.meta&&(i==null?void 0:i.type)==="heading"?Kl(e,t.src):null;return l?r("div",{class:"md-meta",children:l.map(([a,s],o)=>r("span",{class:"md-meta-kv","data-key":a,children:[r("span",{class:"md-meta-k",children:a}),r("span",{class:"md-meta-v",children:a==="refs"&&t.cite?gu(s).map((c,u)=>{const h=Wi(c),d=h?t.cite(h):null;return r("span",{children:[u?", ":"",d??c]},u)}):s})]},o))},n):r("blockquote",{class:"md-quote",children:(e.children||[]).map((a,s)=>ns(a,t,s))},n)}case"list":{const l=(e.children||[]).map((a,s)=>wy(a,t,s));return e.ordered?r("ol",{class:"md-ol",start:e.start!==1?e.start:void 0,children:l},n):r("ul",{class:"md-ul",children:l},n)}case"thematicBreak":return r("hr",{class:"md-hr"},n);case"table":return vy(e,t,n);case"html":return r("p",{class:"md-p",children:e.value},n);default:return e.children?r("p",{class:"md-p",children:ze(e.children,t)},n):e.value?r("p",{class:"md-p",children:e.value},n):null}}function Cn(e,t={}){const n=String(e||""),i={src:n,demote:t.demote??!0,softBreaks:t.softBreaks??"br",highlight:t.highlight??null,resolveUrl:t.resolveUrl??null,meta:t.meta??!1,cite:t.cite??null,mermaid:t.mermaid??!1,zoom:t.zoom??!1},l=nu(n,{extensions:[mu()],mdastExtensions:[au()]});return l.children.map((a,s)=>ns(a,i,s,l.children[s-1]))}const xy=2e3,Zr=q(!1);let ta=!1;function _y({focus:e=!1}={}){ta=e,Zr.value=!0}const Sy=12e4;function $y({releases:e}){return e?e==="error"?r("div",{class:"update-note-muted",children:"couldn't load the release notes"}):e.length?e.map(t=>r("div",{class:"update-release",children:[r("div",{class:"update-release-head",children:t.heading}),r("div",{class:"update-release-body",children:Cn(t.body)})]},t.heading)):r("div",{class:"update-note-muted",children:"no release notes recorded — CHANGELOG.md was unreadable on the last check"}):r("div",{class:"update-note-muted",children:"loading…"})}function Cy(){const[e,t]=N(!1),[n,i]=N(null),l=Zr.value,a=M=>{Zr.value=M},[s,o]=N(null),c=J(null),u=J(null),h=jt(()=>{Zr.value=!1},[]);ji(c,l,h);const d=xa.value,p=(d==null?void 0:d.behind)||0,f=(d==null?void 0:d.ahead)||0;if(H(()=>{p||a(!1)},[p]),H(()=>{var T;if(!l)return;let M=!0;return o(null),ta&&(ta=!1,(T=u.current)==null||T.focus()),fetch("/api/update/status").then(async S=>{M&&o(S.ok?(await S.json()).releases||[]:"error")}).catch(()=>{M&&o("error")}),()=>{M=!1}},[l]),!d||!p&&!d.running&&!e&&!n)return null;function m(){a(!l)}async function k(){const M=Date.now()+Sy;for(;Date.now()setTimeout(S,xy));let T;try{const S=await fetch("/api/update/status");if(!S.ok)continue;T=await S.json()}catch{continue}if(!T.running)return T.behind===0?t(!1):(t(!1),i((T.log||[]).filter(Boolean).slice(-3).join(`
+`)||"update exited without applying — see ~/.config/periscope/update.log"))}t(!1),i("no response for 2 minutes — periscope may not have come back up.\ncheck `bin/periscope status` and ~/.config/periscope/update.log")}async function x(){if(a(!1),i(null),t(!0),!await ie("update","/api/update",{method:"POST"}))return t(!1);k()}const b=e||d.running,C=d.behind,g=d.target,y=`${g} is out — ${Sn(C,"commit")} newer than this checkout`,$=C>0&&f>0,v=`${Sn(f,"local commit")} not in ${g} — the update's fast-forward will refuse. Get them into a release, or off this checkout's main.`,E=n?`update failed:
+${n}`:b?"updating — periscope will restart itself":$?`${y}, but ${v}`:`${y} — click to see what's new`;return r("div",{class:"pill-dd",ref:c,children:[r("button",{type:"button",class:`update-pill${b?" is-running":""}${n?" is-error":""}`,title:E,"aria-haspopup":"dialog","aria-expanded":l?"true":"false",disabled:b,onClick:b?void 0:m,children:b?"updating…":n?"⚠ update failed":`↑ ${g}${$?" ⚠":""}`}),r("div",{class:"tb-dd-menu update-menu",role:"dialog",hidden:!l,children:[r("div",{class:"update-menu-head",children:y}),$&&r("div",{class:"update-menu-warn",children:v}),n&&r("pre",{class:"update-menu-error",children:n}),r("div",{class:"update-notes",children:r($y,{releases:s})}),r("button",{type:"button",class:"update-pill update-menu-go",ref:u,onClick:x,children:[n?"retry — ":"","pull, re-provision and restart"]})]})]})}function Ty(e){const t=e.pid!=null&&(ce.value||[]).find(n=>String(n.pid)===String(e.pid))||null;if(e.action==="update")return _y({focus:!0});if(e.action==="needs")return Bu(t);if(e.action==="ready")return ju(t);if(e.action==="reveal")return Ut(e.target);e.action==="party"&&ay(e.key),ot(t)}const Ey=250;function Py({target:e,pet:t,act:n=Ty,schedule:i=setTimeout,cancel:l=clearTimeout}){let a=null;return{onClick(s){if(s.detail>1)return;const o=e();if(!o)return t();if(o.action==="update"){a=i(()=>n(o),Ey);return}n(o)},onDblClick(){l(a),t()},dispose(){l(a)}}}const My="geometricPrecision";function an({x:e,y:t}){return r("g",{fill:"var(--fg-3)",children:[r("rect",{class:"tama-steam",x:e,y:t,width:"0.5",height:"1.6"}),r("rect",{class:"tama-steam tama-steam2",x:e+1.2,y:t-.6,width:"0.5",height:"1.6"})]})}function Or({y:e=18.2}){return r("rect",{x:"25.8",y:e,width:"7.6",height:"0.8",rx:"0.4",fill:"#e8e2d4"})}const ko={ramen:()=>r("g",{children:[r("line",{x1:"29.2",y1:"10.4",x2:"28.1",y2:"15.6",stroke:"#b07a4f","stroke-width":"0.45"}),r("line",{x1:"30.4",y1:"10.7",x2:"29",y2:"15.6",stroke:"#b07a4f","stroke-width":"0.45"}),r("rect",{x:"26.8",y:"15.3",width:"4.9",height:"1.5",rx:"0.7",fill:"#f8f4ea"}),r("rect",{x:"26",y:"16.2",width:"6.5",height:"2.8",rx:"1.2",fill:"#e8e2d4"}),r("rect",{class:"tama-steam",x:"31.6",y:"12.2",width:"0.5",height:"1.6",fill:"var(--fg-3)"})]}),pizza:()=>r("g",{children:[r("rect",{x:"26",y:"12",width:"7.4",height:"5.4",fill:"#d8b384"}),r("rect",{x:"26.5",y:"12.5",width:"6.4",height:"4.4",fill:"#c9a06b"}),r("rect",{x:"25.6",y:"17.2",width:"8.2",height:"1.8",fill:"#c49a6c"}),r("ellipse",{cx:"29.7",cy:"17.3",rx:"3.6",ry:"1.1",fill:"#e0a94a"}),r("ellipse",{cx:"29.7",cy:"17.3",rx:"3",ry:"0.8",fill:"#f2c94c"}),r("path",{d:"M29.7 17.3 L33.4 17.1 L32.6 18.2 Z",fill:"#c49a6c"}),r("g",{fill:"#c0392b",children:[r("circle",{cx:"28",cy:"17.2",r:"0.35"}),r("circle",{cx:"29.6",cy:"16.9",r:"0.35"}),r("circle",{cx:"29.2",cy:"17.7",r:"0.35"}),r("circle",{cx:"31",cy:"16.9",r:"0.3"})]}),r(an,{x:28.6,y:13.6})]}),burger:()=>r("g",{children:[r(Or,{}),r("rect",{x:"27",y:"17.2",width:"5",height:"1",rx:"0.4",fill:"#d9913f"}),r("rect",{x:"26.8",y:"16.2",width:"5.4",height:"1.1",rx:"0.5",fill:"#6b3a22"}),r("path",{d:"M26.9 15.8 H32.1 V16.3 H29.2 L28.6 17 L28 16.3 H26.9 Z",fill:"#f2c94c"}),r("rect",{x:"27.1",y:"15.3",width:"4.8",height:"0.5",fill:"#e05252"}),r("rect",{x:"26.7",y:"14.9",width:"5.6",height:"0.5",rx:"0.25",fill:"#6fae5a"}),r("path",{d:"M26.9 15 Q26.9 12.4 29.5 12.4 Q32.1 12.4 32.1 15 Z",fill:"#e0a04a"}),r("g",{fill:"#f8f0d8",children:[r("rect",{x:"28.2",y:"13.4",width:"0.4",height:"0.25"}),r("rect",{x:"29.6",y:"13",width:"0.4",height:"0.25"}),r("rect",{x:"30.8",y:"13.6",width:"0.4",height:"0.25"})]})]}),sushi:()=>r("g",{children:[r("rect",{x:"25.4",y:"17.4",width:"8.4",height:"0.9",fill:"#c8955c"}),r("g",{fill:"#a5743f",children:[r("rect",{x:"26.2",y:"18.3",width:"0.8",height:"0.7"}),r("rect",{x:"32.2",y:"18.3",width:"0.8",height:"0.7"})]}),[[26,"#f28c6b"],[28.7,"#d64550"]].map(([e,t])=>r("g",{children:[r("rect",{x:e,y:"16.2",width:"2.4",height:"1.2",rx:"0.5",fill:"#f6f3ec"}),r("rect",{x:e-.2,y:"15.5",width:"2.8",height:"0.9",rx:"0.45",fill:t}),r("rect",{x:e+.7,y:"15.6",width:"0.15",height:"0.7",fill:"#fbd0c0",opacity:"0.8"}),r("rect",{x:e+1.5,y:"15.6",width:"0.15",height:"0.7",fill:"#fbd0c0",opacity:"0.8"})]},e)),r("rect",{x:"31.4",y:"15.6",width:"1.9",height:"1.8",rx:"0.3",fill:"#1f2a1f"}),r("rect",{x:"31.7",y:"15.9",width:"1.3",height:"1.2",fill:"#f6f3ec"}),r("rect",{x:"32.1",y:"16.25",width:"0.5",height:"0.5",fill:"#f28c6b"})]}),tacos:()=>r("g",{children:[r(Or,{}),[26,29.8].map(e=>r("g",{children:[r("rect",{x:e+.2,y:"14.6",width:"3.2",height:"0.9",rx:"0.4",fill:"#6fae5a"}),r("rect",{x:e+.3,y:"15.2",width:"3",height:"0.5",fill:"#8a4b2a"}),r("rect",{x:e+.7,y:"14.4",width:"0.6",height:"0.6",fill:"#e05252"}),r("rect",{x:e+2.3,y:"14.3",width:"0.6",height:"0.6",fill:"#e05252"}),r("path",{d:`M${e} 15.4 h3.6 a1.8 2.6 0 0 1 -3.6 0 z`,fill:"#e8b84a"})]},e))]}),pasta:()=>r("g",{children:[r("line",{x1:"31.4",y1:"15.6",x2:"33",y2:"11.8",stroke:"#c9ced6","stroke-width":"0.35"}),r("rect",{x:"25.8",y:"17.6",width:"7.6",height:"1.2",rx:"0.6",fill:"#f8f4ea"}),r("rect",{x:"26.6",y:"18.4",width:"6",height:"0.6",fill:"#e8e2d4"}),r("path",{d:"M26.6 17.8 Q27 14.6 29.6 14.6 Q32.2 14.6 32.6 17.8 Z",fill:"#f2d27a"}),r("g",{fill:"none",stroke:"#d9b45a","stroke-width":"0.25",children:[r("path",{d:"M27.4 17.1 q0.6 -0.7 1.2 0 t1.2 0 t1.2 0 t1.2 0"}),r("path",{d:"M27.9 16.2 q0.6 -0.7 1.2 0 t1.2 0 t1.2 0"})]}),r("path",{d:"M28 15.4 Q29.6 14 31.2 15.4 Q29.6 16.2 28 15.4 Z",fill:"#c0392b"}),r("circle",{cx:"28.9",cy:"15",r:"0.55",fill:"#6b3a22"}),r("circle",{cx:"30.3",cy:"14.9",r:"0.55",fill:"#6b3a22"}),r(an,{x:27.6,y:11.6})]}),salad:()=>r("g",{children:[r("line",{x1:"31.8",y1:"15.8",x2:"33.2",y2:"11.8",stroke:"#c9ced6","stroke-width":"0.35"}),r("ellipse",{cx:"27.8",cy:"15.6",rx:"1.4",ry:"1",fill:"#4f9a46"}),r("ellipse",{cx:"29.6",cy:"15.1",rx:"1.5",ry:"1.1",fill:"#6fae5a"}),r("ellipse",{cx:"31.4",cy:"15.6",rx:"1.3",ry:"0.9",fill:"#9be38f"}),r("circle",{cx:"28.6",cy:"15.2",r:"0.45",fill:"#e05252"}),r("circle",{cx:"30.9",cy:"15.4",r:"0.45",fill:"#e05252"}),r("rect",{x:"29.4",y:"14.3",width:"0.4",height:"1.2",fill:"#ef8a2c"}),r("path",{d:"M26 16 h7.2 q-0.4 3 -3.6 3 q-3.2 0 -3.6 -3 z",fill:"#b07a4f"}),r("rect",{x:"25.8",y:"15.8",width:"7.6",height:"0.5",rx:"0.25",fill:"#9a6a43"})]}),soup:()=>r("g",{children:[r("line",{x1:"31.4",y1:"15.8",x2:"33.4",y2:"12.4",stroke:"#c9ced6","stroke-width":"0.35"}),r("path",{d:"M26 15.6 h7 q-0.4 3.4 -3.5 3.4 q-3.1 0 -3.5 -3.4 z",fill:"#e8e2d4"}),r("ellipse",{cx:"29.5",cy:"15.7",rx:"3.4",ry:"0.55",fill:"#d9622b"}),r("g",{fill:"#e8b84a",children:[r("rect",{x:"28",y:"15.4",width:"0.6",height:"0.4"}),r("rect",{x:"30.2",y:"15.6",width:"0.6",height:"0.4"})]}),r("rect",{x:"25.6",y:"18.4",width:"7.8",height:"0.6",rx:"0.3",fill:"#d4ccbd"}),r(an,{x:28.2,y:12.4})]}),roast:()=>r("g",{children:[r("ellipse",{cx:"29.6",cy:"18.4",rx:"4.1",ry:"0.7",fill:"#e8e2d4"}),r("g",{fill:"#4f9a46",children:[r("circle",{cx:"26",cy:"18.1",r:"0.4"}),r("circle",{cx:"33.2",cy:"18.1",r:"0.4"})]}),r("path",{d:"M26.6 18.2 Q26.4 14.6 29.6 14.4 Q32.8 14.6 32.6 18.2 Z",fill:"#b5733a"}),r("ellipse",{cx:"29",cy:"15.6",rx:"1.6",ry:"0.7",fill:"#d9913f"}),[[26.9,25.9],[32.3,33.3]].map(([e,t])=>r("g",{children:[r("ellipse",{cx:e,cy:"16.8",rx:"1",ry:"0.7",fill:"#a5642e"}),r("circle",{cx:t,cy:"16.3",r:"0.4",fill:"#f4efe6"})]},e)),r(an,{x:28.4,y:11.4})]}),icecream:()=>r("g",{children:[r("rect",{x:"27.8",y:"18.4",width:"3.4",height:"0.6",rx:"0.3",fill:"#cfe3ef"}),r("rect",{x:"29.2",y:"16.6",width:"0.6",height:"1.8",fill:"#cfe3ef"}),r("circle",{cx:"28.3",cy:"13.8",r:"1.2",fill:"#f28ab2"}),r("circle",{cx:"30.7",cy:"13.8",r:"1.2",fill:"#9be38f"}),r("circle",{cx:"29.5",cy:"12.5",r:"1.2",fill:"#7a4e2d"}),r("path",{d:"M26.8 14.4 h5.4 q-0.4 2.4 -2.7 2.4 q-2.3 0 -2.7 -2.4z",fill:"#cfe3ef",opacity:"0.85"}),r("rect",{x:"31.4",y:"10.6",width:"0.7",height:"2.8",fill:"#e8b84a"}),r("path",{d:"M29.5 11 q0.3 -0.9 1 -1.2",fill:"none",stroke:"#4f7a2c","stroke-width":"0.2"}),r("circle",{cx:"29.5",cy:"11.1",r:"0.45",fill:"#e05252"})]}),pie:()=>r("g",{children:[r("ellipse",{cx:"29.6",cy:"18.4",rx:"4.1",ry:"0.7",fill:"#e8e2d4"}),r("rect",{x:"26.2",y:"17.3",width:"6.8",height:"0.9",fill:"#a5642e"}),r("ellipse",{cx:"29.6",cy:"18.2",rx:"3.4",ry:"0.5",fill:"#a5642e"}),r("ellipse",{cx:"29.6",cy:"17.3",rx:"3.4",ry:"1.1",fill:"#c8813a"}),r("ellipse",{cx:"29.6",cy:"17.3",rx:"2.8",ry:"0.8",fill:"#e07b39"}),r("path",{d:"M29.6 17.3 L33.1 17.2 L32.4 18.2 Z",fill:"#e8e2d4"}),r("g",{fill:"#fbf6ea",children:[r("circle",{cx:"28.2",cy:"17",r:"0.45"}),r("circle",{cx:"29.8",cy:"16.8",r:"0.45"}),r("circle",{cx:"28.9",cy:"17.6",r:"0.45"})]})]}),pancakes:()=>r("g",{children:[r(Or,{}),[17.3,16.4,15.5,14.6].map((e,t)=>r("rect",{x:"26.6",y:e,width:"6",height:"0.95",rx:"0.45",fill:t%2?"#c8913a":"#d9a441"},e)),r("g",{fill:"#8a4b1a",children:[r("rect",{x:"26.9",y:"14.5",width:"5.4",height:"0.45",rx:"0.2"}),r("rect",{x:"27.4",y:"14.9",width:"0.45",height:"1.4",rx:"0.2"}),r("rect",{x:"31.5",y:"14.9",width:"0.45",height:"0.8",rx:"0.2"})]}),r("rect",{x:"28.9",y:"13.9",width:"1.4",height:"0.65",fill:"#fbe7a1"}),r(an,{x:28.6,y:11})]}),waffles:()=>r("g",{children:[r(Or,{}),r("rect",{x:"26.6",y:"15.8",width:"6",height:"2.4",rx:"0.3",fill:"#e0a94a"}),r("g",{fill:"#c8913a",children:[[27.8,29,30.2,31.4].map(e=>r("rect",{x:e,y:"15.8",width:"0.2",height:"2.4"},e)),r("rect",{x:"26.6",y:"16.6",width:"6",height:"0.2"}),r("rect",{x:"26.6",y:"17.4",width:"6",height:"0.2"})]}),r("circle",{cx:"28.4",cy:"15.6",r:"0.5",fill:"#3f5fb5"}),r("circle",{cx:"29.3",cy:"15.4",r:"0.5",fill:"#e05252"}),r("circle",{cx:"30.6",cy:"15.5",r:"0.6",fill:"#fbf6ea"})]}),eggs:()=>r("g",{children:[r("rect",{x:"31.6",y:"13.8",width:"2",height:"3.4",rx:"0.5",fill:"#d9a441",stroke:"#a5743f","stroke-width":"0.25"}),r("ellipse",{cx:"29.6",cy:"17.7",rx:"4.1",ry:"1.2",fill:"#f4f1ea"}),r("ellipse",{cx:"27.9",cy:"17.4",rx:"1.3",ry:"0.65",fill:"#ffffff"}),r("circle",{cx:"27.9",cy:"17.3",r:"0.42",fill:"#f2b52a"}),r("ellipse",{cx:"30.4",cy:"17.2",rx:"1.3",ry:"0.65",fill:"#ffffff"}),r("circle",{cx:"30.4",cy:"17.1",r:"0.42",fill:"#f2b52a"}),r("g",{fill:"none",stroke:"#b5452a","stroke-width":"0.45",children:[r("path",{d:"M26.6 18.2 q0.6 -0.4 1.2 0 t1.2 0 t1.2 0"}),r("path",{d:"M29.6 18.5 q0.6 -0.4 1.2 0 t1.2 0"})]})]})};function Ay({dish:e}){const t=ko[e]?e:"ramen";return r("g",{"data-dish":t,"shape-rendering":My,children:ko[t]()})}const _e="geometricPrecision",wo=e=>[...e].reverse().join("");function rt({cells:e,cls:t,x0:n,y0:i=V,w:l=1,h:a=2,fill:s=Wt}){return r("g",{class:t,children:e.map(({x:o,y:c})=>r("rect",{x:n+o*l,y:i+c*a,width:l+.02,height:a+.02,fill:s},`${o},${c}`))})}const Pd=[xd[0]],vo={body:Kt(Ln),legs:Kt(Pd)},xo={body:Kt(Ln.map(wo)),legs:Kt(Pd.map(wo))};function Ly({season:e,trick:t}){return r(U,{children:[r("g",{class:"tama-motion",fill:"var(--fg-3)",children:[r("rect",{x:"1",y:"10.6",width:"4",height:"0.5"}),r("rect",{x:"2.4",y:"13.6",width:"3.6",height:"0.5"}),r("rect",{x:"0.6",y:"16.6",width:"4.6",height:"0.5"})]}),e!=="winter"&&!t&&r("path",{class:"tama-sweat",d:"M25 7.6 q1.1 1.7 0 2.5 q-1.1 -0.8 0 -2.5z",fill:"#7fb6e6"})]})}function _o({cx:e}){return r("g",{children:[r("circle",{cx:e,cy:"16.7",r:"2.2",fill:"none",stroke:"#2b2f36","stroke-width":"0.55"}),r("g",{class:"tama-spokes",stroke:"#9aa3ae","stroke-width":"0.18",children:[r("line",{x1:e-2,y1:"16.7",x2:e+2,y2:"16.7"}),r("line",{x1:e,y1:"14.7",x2:e,y2:"18.7"}),r("line",{x1:e-1.4,y1:"15.3",x2:e+1.4,y2:"18.1"}),r("line",{x1:e-1.4,y1:"18.1",x2:e+1.4,y2:"15.3"})]}),r("circle",{cx:e,cy:"16.7",r:"0.35",fill:"#2b2f36"})]})}function Iy(){return r("g",{class:"tama-bike","shape-rendering":_e,children:[r("g",{class:"tama-motion",fill:"var(--fg-3)",children:[r("rect",{x:"0.6",y:"9.2",width:"3.4",height:"0.5"}),r("rect",{x:"1.4",y:"11.6",width:"3",height:"0.5"}),r("rect",{x:"0.4",y:"13.6",width:"3.6",height:"0.5"})]}),r(_o,{cx:7.2}),r(_o,{cx:26.8}),r("g",{fill:"none",stroke:"#2a9d8f","stroke-width":"0.5","stroke-linecap":"round",children:[r("path",{d:"M7.2 16.7 L15.5 16.9 L24.4 13.2 L26.8 16.7"}),r("path",{d:"M7.2 16.7 L11.6 13.8"})]}),r("path",{d:"M24.4 13.2 L24 11.4 M23.2 11.5 H25.4",fill:"none",stroke:"#2b2f36","stroke-width":"0.45","stroke-linecap":"round"}),r("circle",{cx:"15.5",cy:"16.9",r:"0.8",fill:"none",stroke:"#5a6472","stroke-width":"0.3"}),r("g",{class:"tama-crank",fill:"#2b2f36",children:[r("path",{d:"M14.5 15.9 L16.5 17.9",stroke:"#2b2f36","stroke-width":"0.3"}),r("rect",{x:"14",y:"15.6",width:"0.9",height:"0.4"}),r("rect",{x:"16.1",y:"17.8",width:"0.9",height:"0.4"})]})]})}function Oy({x0:e}){return r("g",{class:"tama-helmet","shape-rendering":_e,children:[r("path",{d:`M${e+3.6} ${V+.5} Q${e+3.6} ${V-1.6} ${e+9} ${V-1.6} Q${e+14.4} ${V-1.6} ${e+14.4} ${V+.5} Z`,fill:"#e05252"}),r("g",{fill:"#8f2a2a",children:[6.4,8.5,10.6].map(t=>r("rect",{x:e+t,y:V-.9,width:"0.9",height:"0.45",rx:"0.2"},t))}),r("rect",{x:e+13.2,y:V+.1,width:"2.4",height:"0.5",rx:"0.25",fill:"#8f2a2a"})]})}const So={dx:18,y:11.7};function Tn({limb:e,x:t,y:n,w:i,h:l,cls:a}){const s=e.style==="tentacle";return r("rect",{class:a,x:t,y:n,width:i,height:l,rx:s?l/2:.25,fill:e.color,stroke:e.outline||void 0,"stroke-width":e.outline?.25:void 0})}function Md({x0:e,limb:t}){return r("g",{class:"tama-bass","shape-rendering":_e,children:[r("path",{d:`M${e+9.6} 13.7 L${e+23} 9.6 L${e+23.3} 10.5 L${e+9.9} 14.6 Z`,fill:"#4a2c1a"}),r("g",{fill:"#efe6d8",children:[13.5,16.5,19.5].map(n=>r("circle",{cx:e+n,cy:14.15-.306*(n-9.75),r:"0.13"},n))}),r("path",{d:`M${e+23} 9.4 L${e+26.4} 8.2 L${e+26.7} 9.1 L${e+23.3} 10.7 Z`,fill:"#e3c48a"}),r("g",{fill:"#c9ced6",children:[23.9,24.7,25.5,26.2].map((n,i)=>r("circle",{cx:e+n,cy:9.1-i*.3,r:"0.25"},n))}),r("ellipse",{cx:e+5,cy:"15.3",rx:"3",ry:"2.1",fill:"#3f6fb5"}),r("ellipse",{cx:e+8.1,cy:"14.4",rx:"1.9",ry:"1.5",fill:"#3f6fb5"}),r("ellipse",{cx:e+9.4,cy:"13.4",rx:"1.1",ry:"0.6",fill:"#3f6fb5"}),r("ellipse",{cx:e+6.6,cy:"14.7",rx:"2",ry:"1.1",fill:"#f4f1ea"}),r("rect",{x:e+5.6,y:"14.1",width:"1.4",height:"0.9",rx:"0.2",fill:"#1d1f24"}),r("rect",{x:e+2.6,y:"14.9",width:"1.6",height:"0.7",fill:"#c9ced6"}),r("g",{stroke:"#e6e9ef","stroke-width":"0.1",children:[r("line",{x1:e+3.4,y1:"15.1",x2:e+23.1,y2:"9.9"}),r("line",{x1:e+3.4,y1:"15.4",x2:e+23.2,y2:"10.2"})]}),t?r(Tn,{limb:t,x:e+7.3,y:14.5,w:1.3,h:1,cls:"tama-strum"}):r(U,{children:[r("rect",{x:e+17.5,y:"11.1",width:"1",height:"0.9",fill:Wt}),r("rect",{class:"tama-strum",x:e+7.4,y:"14.6",width:"1.1",height:"0.8",fill:Wt})]})]})}function $o({x:e,y:t,cls:n}){return r("g",{class:n,fill:"var(--fg-2)",children:[r("ellipse",{cx:e,cy:t+2.4,rx:"0.6",ry:"0.45"}),r("rect",{x:e+.35,y:t,width:"0.3",height:"2.4"}),r("path",{d:`M${e+.65} ${t} q1 0.5 0.6 1.6 q-0.1 -0.9 -0.6 -1`})]})}function Dy(){return r("g",{class:"tama-amp","shape-rendering":_e,children:[r($o,{x:24.4,y:6,cls:"tama-note"}),r($o,{x:26.6,y:4.4,cls:"tama-note tama-note2"}),r("path",{d:"M9 17.2 C8.6 19, 12 18.9, 16 18.9 S26.4 18.9, 27.6 17.6",fill:"none",stroke:"#1d1f24","stroke-width":"0.3"}),r("rect",{x:"27.6",y:"12.6",width:"6",height:"6.4",rx:"0.3",fill:"#2b2f36"}),r("rect",{x:"27.6",y:"12.6",width:"6",height:"1.2",fill:"#3b404a"}),r("g",{fill:"#c9ced6",children:[28.4,29.3,30.2,31.1].map(e=>r("circle",{cx:e,cy:"13.2",r:"0.25"},e))}),r("circle",{cx:"32.8",cy:"13.2",r:"0.2",fill:"#e05252"}),r("rect",{x:"28",y:"14.2",width:"5.2",height:"4.4",fill:"#4a4f58"}),r("g",{class:"tama-speaker",children:[r("circle",{cx:"30.6",cy:"16.4",r:"1.8",fill:"#3b404a"}),r("circle",{cx:"30.6",cy:"16.4",r:"0.7",fill:"#2b2f36"})]})]})}const Et=18,Co="#6f93d6",Ry=150,gt=e=>Math.round(e*1e4)/1e4;function Fy({sprite:e}){const{scale:t,tx:n,ty:i}=La(e,{x0:Et,sitting:!1}),l=Et+8.5;return r("g",{class:"tama-critter",style:"transform-box: view-box",transform:`translate(${gt(2*l-n)} ${gt(i)}) scale(${gt(-t)} ${gt(t)})`,children:[r(Zi,{sprite:e,face:"happy",tint:Ry,holding:"pint"}),r(Ad,{sprite:e,kind:"pint",scale:t})]})}function Ad({sprite:e,kind:t,scale:n}){if(!Ia[t])return null;const[i,l]=Vi(e,t),a=gt(1/n),s=(o,c)=>r("g",{style:"transform-box: view-box",transform:`translate(${i} ${l}) scale(${a}) ${o}`,children:c});return t==="pint"?s("translate(0 -11.5)",r(rs,{x:0,cls:"tama-pint tama-clink"})):t==="mug"?s("scale(-1 1) translate(-30.1 -14.2)",r(Id,{})):t==="can"?s("translate(-17.8 -11.7)",r(Od,{x0:0})):null}function rs({x:e,cls:t}){return r("g",{class:t,children:[r("rect",{x:e,y:"10.4",width:"2",height:"2.8",fill:"#e8a92e"}),r("rect",{x:e+.3,y:"10.9",width:"0.3",height:"1.8",fill:"#ffd98a"}),r("rect",{x:e-.1,y:"9.8",width:"2.2",height:"0.9",rx:"0.4",fill:"#fbf6ea"})]})}function Ny({x0:e}){return r(rs,{x:e+15.2,cls:"tama-pint tama-clink"})}const By=[["#ffd166",15.4],["#f28ab2",19.6],["#7fb6e6",23.8],["#9be38f",28],["#ffd166",32.2]];function zy({critter:e}){return r("g",{children:[r("path",{d:"M13.4 1.2 Q23.6 3.6 34 1.2",fill:"none",stroke:"var(--fg-3)","stroke-width":"0.2","shape-rendering":_e}),By.map(([t,n],i)=>r("rect",{class:`tama-twinkle${i%2?" tama-twinkle2":""}`,x:n-.35,y:1.9+Math.sin((n-13.4)/6.5)*.9,width:"0.7",height:"0.9",rx:"0.3",fill:t},n)),r("g",{class:"tama-friend",children:e!=null&&e.sprite?r(Fy,{sprite:e.sprite}):r(U,{children:[r(rt,{cells:xo.body,x0:Et,fill:Co}),r(rt,{cells:xo.legs,x0:Et,y0:V+2*Ln.length,fill:Co}),r("g",{fill:"none",stroke:we,"stroke-width":"0.45","stroke-linecap":"square",children:[r("path",{d:`M${Et+3.8} ${V+3.5} l0.7 -0.9 l0.7 0.9`}),r("path",{d:`M${Et+10.8} ${V+3.5} l0.7 -0.9 l0.7 0.9`})]}),r(rs,{x:Et+1.2,cls:"tama-pint tama-clink tama-clink2"})]})}),r("g",{class:"tama-cheers",fill:"#ffd166",children:[r("rect",{x:"18.1",y:"7.6",width:"0.4",height:"1.2"}),r("rect",{x:"16.6",y:"8.3",width:"0.9",height:"0.4"}),r("rect",{x:"19.1",y:"8.3",width:"0.9",height:"0.4"})]})]})}function jy({x:e}){const t=e+1.1,n=e+7.4,i=`q-${(n-t)/16} 0.55 -${(n-t)/8} 0 `.repeat(8);return r("g",{class:"tama-kid-sheet","shape-rendering":_e,children:[r("path",{fill:"#f5f5f7",d:`M${t} 18.8 V15.6 Q${t} 13.6 ${(t+n)/2} 13.6 Q${n} 13.6 ${n} 15.6 V18.8 ${i}Z`}),r("ellipse",{cx:e+3.1,cy:"15.6",rx:"0.35",ry:"0.5",fill:we}),r("ellipse",{cx:e+5.4,cy:"15.6",rx:"0.35",ry:"0.5",fill:we}),r("path",{d:`M${e+6.5} 17.2 q0.8 -1.2 1.6 0`,fill:"none",stroke:"#3a2a1a","stroke-width":"0.2"}),r("rect",{x:e+6.4,y:"17",width:"1.8",height:"1.5",rx:"0.5",fill:"#ef8a2c"})]})}function Hy({x:e,sprite:t,costume:n}){const{scale:i,tx:l,ty:a}=La(t,{x0:e-4.25,sitting:!1,height:(n?vu:Aa)/2});return r("g",{class:"tama-critter",style:"transform-box: view-box",transform:`translate(${gt(l)} ${gt(a)}) scale(${gt(i)})`,children:r(Zi,{sprite:t})})}function To({x:e,cls:t,costume:n,sprite:i}){return r("g",{class:t,children:[i?r(Hy,{x:e,sprite:i,costume:n}):r(U,{children:[r(rt,{cells:vo.body,x0:e,y0:14,w:.5,h:1}),r(rt,{cells:vo.legs,x0:e,y0:18,w:.5,h:1})]}),n?r(jy,{x:e}):!i&&r("g",{fill:we,children:[r("rect",{x:e+2.5,y:"15",width:"0.5",height:"1"}),r("rect",{x:e+6,y:"15",width:"0.5",height:"1"})]})]})}function qy({trick:e=!1,critter:t}){return r("g",{children:[r(To,{x:17.4,cls:"tama-kid",costume:e,sprite:t==null?void 0:t.sprite}),r(To,{x:25.4,cls:"tama-kid tama-kid2",costume:e,sprite:t==null?void 0:t.sprite})]})}function Uy(){return r("g",{children:[r("g",{fill:"#4d5f95",children:[r("rect",{x:"0.6",y:"8.4",width:"20.4",height:"9",rx:"1"}),r("rect",{x:"0.2",y:"13.4",width:"2.6",height:"5",rx:"0.8"})]}),r("rect",{x:"1",y:"16.6",width:"21",height:"1.6",rx:"0.6",fill:"#5f75b0"}),r("g",{fill:"#3a2a1a",children:[r("rect",{x:"1.6",y:"18.2",width:"0.9",height:"0.8"}),r("rect",{x:"20.2",y:"18.2",width:"0.9",height:"0.8"})]}),r("g",{class:"tama-tv",children:[r("rect",{x:"22.4",y:"15.6",width:"11.2",height:"3.4",fill:"#6f533c"}),r("rect",{x:"22.4",y:"17.1",width:"11.2",height:"0.3",fill:"#5a4230"}),r("rect",{x:"27.4",y:"14.6",width:"1.6",height:"1",fill:"#1d1f24"}),r("rect",{x:"23",y:"7.4",width:"10.4",height:"7.2",rx:"0.4",fill:"#1d1f24"}),r("rect",{x:"23.6",y:"8",width:"9.2",height:"6",fill:"#20304a"}),r("rect",{x:"23.6",y:"13",width:"9.2",height:"1",fill:"#4f9a46"}),r("rect",{x:"29.6",y:"10.8",width:"2.4",height:"0.5",fill:"#b5733a"}),r("circle",{class:"tama-twinkle",cx:"30.8",cy:"9.9",r:"0.35",fill:"#ffd166"}),r("rect",{class:"tama-hero",x:"25.2",y:"11.9",width:"0.8",height:"1.1",fill:"#e05252"})]})]})}const Wy={style:"arm",color:Wt};function Ld({x0:e,limb:t=Wy}){return r("g",{class:"tama-controller","shape-rendering":_e,children:[r("rect",{x:e+6.6,y:"14.2",width:"4.8",height:"1.4",rx:"0.6",fill:"#3b404a"}),r("rect",{x:e+6.4,y:"14.6",width:"1.4",height:"1.6",rx:"0.6",fill:"#3b404a"}),r("rect",{x:e+10.2,y:"14.6",width:"1.4",height:"1.6",rx:"0.6",fill:"#3b404a"}),r("path",{d:`M${e+7.4} 14.9 h0.9 M${e+7.85} 14.45 v0.9`,stroke:"#c9ced6","stroke-width":"0.25"}),r("circle",{cx:e+10.2,cy:"14.7",r:"0.22",fill:"#e05252"}),r("circle",{cx:e+10.7,cy:"15.1",r:"0.22",fill:"#5aa9e6"}),r(Tn,{limb:t,x:e+6.2,y:14.3,w:1.6,h:1.3}),r(Tn,{limb:t,x:e+10,y:14.3,w:1.6,h:1.3,cls:"tama-thumb"})]})}function Ky(){return r("g",{"shape-rendering":_e,children:[r("rect",{x:"21.4",y:"18.2",width:"12.4",height:"1",fill:"#6b4a33"}),r("g",{class:"tama-flowers",children:[r("g",{fill:"#3f8238",children:[r("rect",{x:"23",y:"13.4",width:"0.4",height:"4.8"}),r("rect",{x:"23.4",y:"15.6",width:"1",height:"0.4"}),r("rect",{x:"26",y:"15.2",width:"0.4",height:"3"}),r("rect",{x:"29",y:"15.4",width:"0.4",height:"2.8"}),r("rect",{x:"31.6",y:"17",width:"0.4",height:"1.2"}),r("rect",{x:"31.9",y:"16.6",width:"0.8",height:"0.4"})]}),r("circle",{cx:"23.2",cy:"13",r:"1.2",fill:"#ffd166"}),r("circle",{cx:"23.2",cy:"13",r:"0.5",fill:"#7a4e2d"}),r("path",{d:"M25.4 15.4 V14.2 L25.9 14.7 L26.2 14 L26.5 14.7 L27 14.2 V15.4 Z",fill:"#e05252"}),r("circle",{cx:"29.2",cy:"15",r:"0.8",fill:"#f28ab2"}),r("circle",{cx:"29.2",cy:"15",r:"0.3",fill:"#ffd166"})]}),r("g",{fill:"#7fb6e6",children:[[23.4,0],[23.9,-.3],[24.4,-.6]].map(([e,t])=>r("rect",{class:"tama-drop",x:e,y:"12.2",width:"0.3",height:"0.5",style:{animationDelay:`${t}s`}},e))})]})}function Id(){return r(U,{children:[r("g",{fill:"#efe6d8",children:[r("rect",{x:"25.5",y:"12",width:"3.4",height:"4.6",rx:"0.4"}),r("rect",{x:"28.9",y:"12.9",width:"1.2",height:"0.6"}),r("rect",{x:"29.5",y:"12.9",width:"0.6",height:"2.6"}),r("rect",{x:"28.9",y:"14.9",width:"1.2",height:"0.6"})]}),r("rect",{x:"25.5",y:"12",width:"3.4",height:"0.9",fill:"#7a4e2d"}),r("rect",{class:"tama-steam",x:"26.4",y:"8.6",width:"0.6",height:"2",fill:"var(--fg-3)"}),r("rect",{class:"tama-steam tama-steam2",x:"27.7",y:"7.8",width:"0.6",height:"2",fill:"var(--fg-3)"})]})}function Od({x0:e}){return r("g",{class:"tama-can","shape-rendering":_e,children:[r("path",{d:`M${e+16.6} 12.6 Q${e+17.8} 10.8 ${e+19} 12.6`,fill:"none",stroke:"#3f7fb5","stroke-width":"0.4"}),r("line",{x1:e+19.2,y1:"13.6",x2:e+21.3,y2:"11.9",stroke:"#5aa9e6","stroke-width":"0.45"}),r("rect",{x:e+21.1,y:"11.5",width:"0.6",height:"0.7",fill:"#3f7fb5"}),r("rect",{x:e+16.2,y:"12.6",width:"3.2",height:"2.4",rx:"0.4",fill:"#5aa9e6"})]})}function Vy(){return r("g",{class:"tama-stove","shape-rendering":_e,children:[r("rect",{x:"21",y:"12.8",width:"12.8",height:"6.2",fill:"#d9dde3"}),r("rect",{x:"20.8",y:"12.2",width:"13.2",height:"0.6",fill:"#3b404a"}),r("g",{fill:"#3b404a",children:[23,25,29.8,31.8].map(e=>r("circle",{cx:e,cy:"13.6",r:"0.35"},e))}),r("rect",{x:"22.4",y:"14.8",width:"10",height:"2.8",rx:"0.3",fill:"#2b2f36"}),r("rect",{class:"tama-glow",x:"23",y:"15.4",width:"8.8",height:"1.6",fill:"#ef8a2c",opacity:"0.18"}),r("rect",{x:"21.6",y:"9.4",width:"4.8",height:"2.8",rx:"0.3",fill:"#8a93a1"}),r("rect",{x:"21",y:"9.8",width:"0.6",height:"0.4",fill:"#5a6472"}),r("rect",{x:"26.4",y:"9.8",width:"0.6",height:"0.4",fill:"#5a6472"}),r("rect",{x:"21.6",y:"9.4",width:"4.8",height:"0.5",fill:"#6b7480"}),r(an,{x:22.8,y:6.6}),r("rect",{x:"27.6",y:"11.6",width:"4",height:"0.6",rx:"0.2",fill:"#2b2f36"}),r("line",{x1:"31.6",y1:"11.8",x2:"33.8",y2:"11.2",stroke:"#2b2f36","stroke-width":"0.4"}),r("g",{fill:"#e8a92e",children:[r("rect",{class:"tama-steam",x:"28.4",y:"10.8",width:"0.5",height:"0.5"}),r("rect",{class:"tama-steam tama-steam2",x:"30.2",y:"10.6",width:"0.5",height:"0.5"})]})]})}function Dd({x0:e,from:t}){return r("line",{class:"tama-spoon",x1:t?t[0]:e+16.8,y1:t?t[1]:"13.6",x2:e+21.6,y2:"9.6",stroke:"#b07a4f","stroke-width":"0.45"})}function Gy({x0:e}){return r("g",{class:"tama-toque","shape-rendering":_e,children:[r("g",{fill:"#f4f4f6",children:[r("circle",{cx:e+6.4,cy:V-2.4,r:"1.5"}),r("circle",{cx:e+9,cy:V-3,r:"1.8"}),r("circle",{cx:e+11.6,cy:V-2.4,r:"1.5"}),r("rect",{x:e+5,y:V-1.6,width:"8",height:"1.9"})]}),r("g",{fill:"#d8dce2",children:[r("rect",{x:e+7,y:V-1.4,width:"0.25",height:"1.6"}),r("rect",{x:e+9,y:V-1.4,width:"0.25",height:"1.6"}),r("rect",{x:e+11,y:V-1.4,width:"0.25",height:"1.6"})]})]})}function Jy({from:e}){const[t,n]=e??[18.2,14.2];return r("g",{"shape-rendering":_e,children:[r("path",{class:"tama-leash",d:`M${t} ${n} Q23 12.4 28.1 15`,fill:"none",stroke:"#e05252","stroke-width":"0.25"}),r("g",{class:"tama-dog",children:[r("path",{class:"tama-tail",d:"M23 15.4 L21.8 13.4",stroke:"#b07a4f","stroke-width":"0.55","stroke-linecap":"round"}),r("g",{fill:"#b07a4f",children:[r("rect",{class:"tama-dog-a",x:"23.4",y:"16.6",width:"0.6",height:"2.4"}),r("rect",{class:"tama-dog-a",x:"27.6",y:"16.6",width:"0.6",height:"2.4"}),r("rect",{class:"tama-dog-b",x:"24",y:"16.6",width:"0.6",height:"2.4"}),r("rect",{class:"tama-dog-b",x:"27",y:"16.6",width:"0.6",height:"2.4"}),r("rect",{x:"22.8",y:"14.8",width:"5.8",height:"2.2",rx:"0.6"}),r("rect",{x:"27.8",y:"13",width:"2.8",height:"2.8",rx:"0.6"})]}),r("rect",{x:"30.2",y:"14.4",width:"1.4",height:"1.2",rx:"0.3",fill:"#c8915e"}),r("rect",{x:"31.3",y:"14.4",width:"0.5",height:"0.5",fill:we}),r("rect",{x:"28.2",y:"12.8",width:"1",height:"2.2",rx:"0.3",fill:"#7a4e2d"}),r("rect",{x:"29.6",y:"13.8",width:"0.45",height:"0.5",fill:we}),r("rect",{x:"27.8",y:"14.6",width:"0.6",height:"1.2",fill:"#e05252"})]})]})}function Qy(){return r("g",{"shape-rendering":_e,children:[r("rect",{x:"0",y:"0",width:"34",height:"24",fill:"#6fb4ea",opacity:"0.13"}),r("circle",{class:"tama-sun",cx:"4.5",cy:"4",r:"2.1",fill:"#ffd166"}),r("g",{class:"tama-ball",children:[r("circle",{cx:"29.5",cy:"13.8",r:"1.8",fill:"#f4f4f6"}),r("path",{d:"M29.5 12 A1.8 1.8 0 0 1 31.3 13.8 H29.5 Z",fill:"#e05252"}),r("path",{d:"M29.5 15.6 A1.8 1.8 0 0 1 27.7 13.8 H29.5 Z",fill:"#5aa9e6"})]})]})}function Yy(){const e="q0.85 -0.6 1.7 0 ".repeat(21);return r("g",{"shape-rendering":_e,children:[r("g",{class:"tama-water",children:[r("path",{d:`M-1 14.6 ${e} V24 H-1 Z`,fill:"#3b8fd0",opacity:"0.9"}),r("g",{fill:"#cfe9fa",children:[r("rect",{x:"4",y:"17.4",width:"1.6",height:"0.3"}),r("rect",{x:"15",y:"19.6",width:"2",height:"0.3"}),r("rect",{x:"26",y:"18",width:"1.4",height:"0.3"})]})]}),r("g",{fill:"#cfe9fa",children:[r("rect",{class:"tama-splash",x:"6.4",y:"13",width:"0.5",height:"0.5"}),r("rect",{class:"tama-splash tama-splash2",x:"23.4",y:"13",width:"0.5",height:"0.5"})]})]})}function is({x0:e}){return r("g",{class:"tama-goggles","shape-rendering":_e,children:[r("rect",{x:e+3,y:V+2.6,width:"12",height:"0.5",fill:"#2b2f36"}),[4.3,11.3].map(t=>r("rect",{x:e+t,y:V+1.5,width:"2.4",height:"2.8",rx:"0.8",fill:"#7fd1e6","fill-opacity":"0.45",stroke:"#2b2f36","stroke-width":"0.35"},t))]})}function Zy(){return r("g",{"shape-rendering":_e,children:[r("g",{class:"tama-motion",fill:"var(--fg-3)",children:[r("rect",{x:"0.6",y:"9.6",width:"3",height:"0.5"}),r("rect",{x:"1.2",y:"12",width:"2.6",height:"0.5"}),r("rect",{x:"0.4",y:"14.4",width:"3.2",height:"0.5"})]}),r("g",{fill:"#f4f8fb",children:[[3.6,0],[4.4,-.2],[3.2,-.4]].map(([e,t])=>r("rect",{class:"tama-kick",x:e,y:"17.8",width:"0.6",height:"0.6",style:{animationDelay:`${t}s`}},t))}),r("g",{class:"tama-sled",children:[r("path",{d:"M5.4 19 H23.4 Q25.8 19 25.4 16.8",fill:"none",stroke:"#8a93a1","stroke-width":"0.4"}),r("g",{fill:"#8a93a1",children:[7.6,14,20.4].map(e=>r("rect",{x:e,y:"17.8",width:"0.4",height:"1.2"},e))}),r("rect",{x:"5",y:"16.8",width:"18.8",height:"1.1",rx:"0.3",fill:"#b5452a"}),r("path",{d:"M25.2 17 Q24.4 15.4 22.6 14.6",fill:"none",stroke:"#e8b84a","stroke-width":"0.25"})]})]})}function ls({x0:e}){return r("g",{class:"tama-scarf",children:[r("rect",{x:e+3,y:V+4,width:"12",height:"1.1",fill:"#d64541"}),r("g",{fill:"#f4f4f6",children:[5,8,11,14].map(t=>r("rect",{x:e+t,y:V+4,width:"0.5",height:"1.1"},t))}),r("rect",{class:"tama-scarf-tail",x:e-1.4,y:V+4.2,width:"2.8",height:"0.8",fill:"#d64541"})]})}const Xy={run:{tempo:.3,stride:!0,outdoors:!0,snowcap:!0,Behind:Ly,trick:{pail:!0}},cycle:{pose:{x0:7,lift:2},tempo:.4,stride:!0,outdoors:!0,jack:{x:.6,y:16.4},Behind:Iy,Headwear:Oy},music:{pose:{x0:6},tempo:.5,jack:{x:1.5,y:16.4},Behind:Dy,Held:Md},beer:{pose:{x0:1},tempo:.9,smile:!0,Behind:zy,Held:Ny},kids:{pose:{x0:1},tempo:.7,smile:!0,Behind:qy,trick:{outdoors:!0}},game:{pose:{x0:3,sitting:!0},tempo:1.2,Behind:Uy,Held:Ld,paws:!0},garden:{pose:{x0:2},tempo:.8,outdoors:!0,Behind:Ky,Held:Od},cook:{pose:{x0:2},tempo:.6,Behind:Vy,Held:Dd,Headwear:Gy},dog:{pose:{x0:1},tempo:.5,stride:!0,smile:!0,outdoors:!0,Behind:Jy},swim:{pose:{x0:6,sitting:!0},tempo:1,Behind:Qy,Held:is,Front:Yy},sled:{pose:{x0:5,sitting:!0},tempo:.35,smile:!0,outdoors:!0,snowcap:!0,Behind:Zy,Held:ls}},Ge="geometricPrecision";function wt({fill:e="#1d2026"}){return r("rect",{x:"23.4",y:"6",width:"8.2",height:"5.6",fill:e})}function Ue({x:e,y:t,size:n,fill:i,weight:l=700,anchor:a="start",children:s}){return r("text",{x:e,y:t,"font-size":n,"font-weight":l,"font-family":"var(--mono)","text-anchor":a,fill:i,children:s})}const e2={bell:r("g",{children:[r("rect",{x:"2.9",y:"1.35",width:"0.6",height:"0.55",fill:"#b8862a"}),r("path",{d:"M1.9 4.3 Q1.9 1.8 3.2 1.8 Q4.5 1.8 4.5 4.3 Z",fill:"#e8a92e"}),r("rect",{x:"1.55",y:"4.1",width:"3.3",height:"0.55",rx:"0.2",fill:"#e8a92e"}),r("circle",{cx:"3.2",cy:"4.95",r:"0.38",fill:"#8a5a1a"})]}),done:r("path",{d:"M1.7 3.4 l1.1 1.1 l2.1 -2.4",fill:"none",stroke:"#2f9a57","stroke-width":"0.8","stroke-linecap":"square"}),ci:r("path",{d:"M1.9 1.9 l2.6 2.6 M4.5 1.9 l-2.6 2.6",fill:"none",stroke:"#d64541","stroke-width":"0.8","stroke-linecap":"square"}),api:r("path",{d:"M3.8 1.3 L1.9 3.5 H3.1 L2.6 5.3 L4.6 2.9 H3.4 Z",fill:"#e8a92e"}),ctx:r("g",{children:[r("rect",{x:"2",y:"1.5",width:"2.4",height:"3.7",rx:"0.3",fill:"none",stroke:"#5a6472","stroke-width":"0.35"}),r("rect",{x:"2.35",y:"2.05",width:"1.7",height:"2.8",fill:"#e8892e"})]}),update:r("g",{children:[r("rect",{x:"1.6",y:"2.3",width:"3.2",height:"2.8",fill:"#c49a6c"}),r("rect",{x:"1.6",y:"2.3",width:"3.2",height:"0.65",fill:"#d8b384"}),r("rect",{x:"2.95",y:"2.3",width:"0.5",height:"2.8",fill:"#a57c4f"})]}),merged:r("g",{children:[r("path",{d:"M2.2 2 V4.6 M2.2 2.4 Q2.2 3.3 4.3 3.3",fill:"none",stroke:"#8957e5","stroke-width":"0.4"}),r("circle",{cx:"2.2",cy:"1.9",r:"0.55",fill:"#8957e5"}),r("circle",{cx:"2.2",cy:"4.7",r:"0.55",fill:"#8957e5"}),r("circle",{cx:"4.4",cy:"3.3",r:"0.55",fill:"#8957e5"})]})};function t2({kind:e,label:t,urgent:n,more:i,x0:l}){const a=4.6+t.length*2.16+.9,[s,o]=n?["#e05252","#ffffff"]:["#f4f4f6","#1b2028"],c=Math.max(l+3.6,9.4),u=.8+a+.7;return r("g",{class:`tama-bubble${n?" tama-bubble-urgent":""}`,"shape-rendering":Ge,children:[r("path",{d:`M6.4 5.6 L${c} 8.3 L8.4 5.6 Z`,fill:s}),r("rect",{x:"0.8",y:"0.8",width:a,height:"5",rx:"1.3",fill:s}),e2[e],r(Ue,{x:"5.3",y:"4.75",size:"3.6",fill:o,children:t}),i>0&&r("g",{class:"tama-more",children:[r("rect",{x:u,y:"1.9",width:"4.4",height:"2.8",rx:"1.4",fill:"#3b404a"}),r(Ue,{x:u+2.2,y:"3.95",size:"2.1",fill:"#e6e9ef",weight:600,anchor:"middle",children:`+${i}`})]})]})}function Eo({x0:e}){return r("g",{class:"tama-happy-eyes",fill:"none",stroke:we,"stroke-width":"0.45","stroke-linecap":"square",children:[r("path",{d:`M${e+4.8} ${V+3.5} l0.7 -0.9 l0.7 0.9`}),r("path",{d:`M${e+11.8} ${V+3.5} l0.7 -0.9 l0.7 0.9`})]})}function n2({x0:e}){return r("g",{fill:"none",stroke:we,"stroke-width":"0.45","stroke-linecap":"square",children:[r("path",{d:`M${e+4.9} ${V+2.3} l1.2 1.5 M${e+6.1} ${V+2.3} l-1.2 1.5`}),r("path",{d:`M${e+11.9} ${V+2.3} l1.2 1.5 M${e+13.1} ${V+2.3} l-1.2 1.5`})]})}function r2({x0:e}){return r("g",{children:[r("g",{fill:"none",stroke:we,"stroke-width":"0.4",children:[r("path",{d:`M${e+4.4} ${V+1.5} l1.8 -0.6`}),r("path",{d:`M${e+11.8} ${V+.9} l1.8 0.6`})]}),r("path",{class:"tama-sweat",fill:"#7fb6e6",d:`M${e+2.2} ${V+.4} q0.8 1.2 0 1.8 q-0.8 -0.6 0 -1.8z`}),r("path",{class:"tama-sweat",style:{animationDelay:"-0.6s"},fill:"#7fb6e6",d:`M${e+15.9} ${V+.8} q0.8 1.2 0 1.8 q-0.8 -0.6 0 -1.8z`})]})}function Xr({x:e,y:t,cls:n="tama-sparkle",delay:i=0}){const l=[[0,-.9],[.25,-.25],[.9,0],[.25,.25],[0,.9],[-.25,.25],[-.9,0],[-.25,-.25]];return r("path",{class:n||void 0,style:i?{animationDelay:`${i}s`}:void 0,fill:"#ffd166","shape-rendering":Ge,d:`M${l.map(([a,s])=>`${(e+a).toFixed(2)} ${(t+s).toFixed(2)}`).join(" L")} Z`})}function i2({x0:e}){return r("g",{children:[[6,7.4,0],[9,6.6,-.6],[12,7.4,-1.2]].map(([t,n,i])=>r("g",{class:"tama-orbit",style:{animationDelay:`${i}s`},children:r(Xr,{x:e+t,y:n,cls:""})},t))})}function l2({x0:e}){return r("g",{class:"tama-startle",fill:"#f2c14e",children:[r("rect",{x:e+16.6,y:"5.8",width:"0.6",height:"1.8"}),r("rect",{x:e+16.6,y:"8",width:"0.6",height:"0.6"})]})}function a2({x0:e}){return r("g",{fill:Wt,children:[r("rect",{class:"tama-cheer",x:e,y:"9.8",width:"1.02",height:"3.4"}),r("rect",{class:"tama-cheer tama-cheer2",x:e+16,y:"9.8",width:"1.02",height:"3.4"})]})}const Rd=({d:e})=>r("g",{class:"tama-ding",fill:"none",stroke:"#f2c14e","stroke-width":"0.3","shape-rendering":Ge,children:r("path",{d:e})});function s2(){return r("rect",{class:"tama-slap",x:"21.6",y:"8.7",width:"1.2",height:"0.9",fill:Wt})}const o2=[21.25,12.3],c2=[22.2,9.6];function u2({limb:e}){return r("g",{children:[r(Tn,{limb:e,x:20.7,y:11.9,w:1.1,h:.8,cls:"tama-hand"}),r(Tn,{limb:e,x:22.7,y:11.9,w:1.1,h:.8,cls:"tama-hand tama-hand2"})]})}function d2({limb:e}){return r(Tn,{limb:e,x:21.6,y:8.7,w:1.2,h:.9,cls:"tama-slap"})}function h2(){return r("g",{children:[r("g",{"shape-rendering":Ge,children:[r("rect",{x:"20.7",y:"12.6",width:"3",height:"0.6",rx:"0.2",fill:"#8b93a1"}),r("path",{d:"M20.95 12.65 Q20.95 10.9 22.2 10.9 Q23.45 10.9 23.45 12.65 Z",fill:"#f2c14e"}),r("rect",{x:"21.4",y:"11.4",width:"0.4",height:"0.5",fill:"#fff3c4"}),r("rect",{x:"21.95",y:"10.4",width:"0.5",height:"0.55",fill:"#c9a03a"})]}),r(Rd,{d:"M20.3 10.4 l-1 -0.5 M20.6 9.5 l-0.6 -0.9 M24.1 10.4 l1 -0.5 M23.8 9.5 l0.6 -0.9"})]})}function f2(){return r("g",{children:[r("g",{class:"tama-alarm","shape-rendering":Ge,children:[r("rect",{x:"27.4",y:"18.2",width:"0.5",height:"0.8",fill:"#8b93a1"}),r("rect",{x:"30.1",y:"18.2",width:"0.5",height:"0.8",fill:"#8b93a1"}),r("circle",{cx:"27.4",cy:"14.3",r:"0.9",fill:"#e8a92e"}),r("circle",{cx:"30.6",cy:"14.3",r:"0.9",fill:"#e8a92e"}),r("rect",{x:"28.8",y:"13.4",width:"0.4",height:"1",fill:"#3b404a"}),r("circle",{cx:"29",cy:"16.4",r:"2.1",fill:"#e6e9ef",stroke:"#d03a3a","stroke-width":"0.45"}),r("path",{d:"M29 16.4 v-1.3 M29 16.4 h0.9",stroke:we,"stroke-width":"0.3",fill:"none"})]}),r(Rd,{d:"M26 14 l-0.9 -0.6 M25.8 15.3 l-1 0 M32 14 l0.9 -0.6 M32.2 15.3 l1 0"})]})}function p2(){return r("g",{children:[r(Xr,{x:22.2,y:4.4}),r(Xr,{x:32.6,y:4.8,delay:-.5}),r(Xr,{x:20.6,y:7.2,delay:-1})]})}function m2(){return r("g",{children:[r(wt,{}),r("path",{d:"M25.3 8.8 l1.7 1.7 l3.4 -3.6",fill:"none",stroke:"#6fcf8f","stroke-width":"0.9","stroke-linecap":"square","shape-rendering":Ge})]})}function g2(){return r("g",{children:[r(wt,{fill:"#1d1a26"}),r("g",{"shape-rendering":Ge,children:[r("path",{d:"M26.3 6.9 V9.4 M26.3 7.3 Q26.3 8.1 28.9 8.1",fill:"none",stroke:"#a371f7","stroke-width":"0.45"}),r("circle",{cx:"26.3",cy:"6.9",r:"0.6",fill:"#a371f7"}),r("circle",{cx:"26.3",cy:"9.5",r:"0.6",fill:"#a371f7"}),r("circle",{cx:"29",cy:"8.1",r:"0.6",fill:"#a371f7"})]}),r(Ue,{x:"27.5",y:"11.15",size:"1.35",fill:"#a371f7",weight:600,anchor:"middle",children:"merged"})]})}const Po=({x:e})=>r("g",{children:[r("path",{class:"tama-flame",fill:"#f08a3c",d:`M${e} 5.6 q-0.5 -1.8 0.7 -3 q0.2 1.1 0.7 1.5 q0.3 -1 1 -1.6 q0.8 1.8 0.1 3.1z`}),r("path",{class:"tama-flame tama-flame2",fill:"#ffd166",d:`M${e+.5} 5.6 q-0.2 -1 0.6 -1.8 q0.2 0.7 0.6 0.9 q0.3 -0.5 0.4 -0.9 q0.6 1 0.1 1.8z`})]});function y2(){return r("g",{children:[r(wt,{fill:"#2a1416"}),r("g",{class:"tama-errors",children:[r("path",{d:"M25.4 7.1 l3.2 3.2 M28.6 7.1 l-3.2 3.2",fill:"none",stroke:"#e05252","stroke-width":"0.8","stroke-linecap":"square"}),r(Ue,{x:"29.4",y:"10.7",size:"1.8",fill:"#e05252",children:"CI"})]}),r(Po,{x:24.6}),r(Po,{x:28.4}),r("g",{fill:"#f4f4f6","shape-rendering":Ge,children:[r("circle",{class:"tama-spray",cx:"23",cy:"6",r:"0.5"}),r("circle",{class:"tama-spray tama-spray2",cx:"23",cy:"6",r:"0.6"}),r("circle",{class:"tama-spray tama-spray3",cx:"23",cy:"6",r:"0.45"})]})]})}function b2(){return r("g",{"shape-rendering":Ge,children:[r("path",{d:"M20.4 9.2 q0.8 -1.6 2.3 -2.6",fill:"none",stroke:"#2b2f36","stroke-width":"0.35"}),r("rect",{x:"19.3",y:"9.3",width:"1.5",height:"3.8",rx:"0.55",fill:"#d03a3a"}),r("rect",{x:"19.6",y:"8.7",width:"0.9",height:"0.7",fill:"#3b404a"}),r("rect",{x:"19.5",y:"10.4",width:"1.1",height:"0.9",fill:"#f4f4f6"})]})}const k2=Array.from({length:18},(e,t)=>[23.6+t*1.7%7.4,6.2+t*1.3%4.8]),w2=Array.from({length:18},(e,t)=>[24.1+t*2.3%7.2,6.5+t*.9%4.8]);function v2(){const e=t=>t.map(([n,i])=>r("rect",{x:n.toFixed(1),y:i.toFixed(1),width:"0.6",height:"0.6"},`${n},${i}`));return r("g",{children:[r(wt,{fill:"#22252b"}),r("g",{class:"tama-static",fill:"#8b93a1",children:e(k2)}),r("g",{class:"tama-static tama-static2",fill:"#5d6470",children:e(w2)}),r("rect",{x:"25.2",y:"7.8",width:"4.6",height:"2.4",fill:"#22252b"}),r(Ue,{x:"27.5",y:"9.7",size:"2",fill:"#ffd166",anchor:"middle",children:"529"})]})}function x2(){return r("g",{class:"tama-stack",children:Array.from({length:12},(e,t)=>r("rect",{x:20.5+(t%2?.35:0),y:(12.65-t*.68).toFixed(2),width:"2.6",height:"0.55",fill:t%2?"#f2ece0":"#e2dccf"},t))})}function _2({pct:e,cost:t}){if(t)return r("g",{children:[r(wt,{}),r(Ue,{x:"27.5",y:"9.6",size:"1.7",fill:"#f2a33a",anchor:"middle",children:"compact?"})]});const n=Math.min(100,Math.max(0,e??90));return r("g",{children:[r(wt,{}),r(Ue,{x:"24.2",y:"7.9",size:"1.4",fill:"#a4acb9",weight:500,children:"context"}),r("rect",{x:"24.2",y:"8.6",width:"6.6",height:"1.5",fill:"none",stroke:"#707884","stroke-width":"0.25"}),r("rect",{class:"tama-fill",x:"24.4",y:"8.8",width:6.2*n/100,height:"1.1",fill:"#f2a33a"}),e!=null&&r(Ue,{x:"30.8",y:"11.3",size:"1.5",fill:"#f2a33a",anchor:"end",children:`${e}%`})]})}const S2=["#52b4ea","#7fbf7f","#c792ea","#e6e9ef"],$2=[.85,.55,.7,.4,.9,.6],C2={1:[[23.4,6,8.2,5]],2:[[23.4,6,4.1,5],[27.5,6,4.1,5]],4:[[23.4,6,4.1,2.5],[27.5,6,4.1,2.5],[23.4,8.5,4.1,2.5],[27.5,8.5,4.1,2.5]]};function T2({n:e}){const t=e===0?[]:C2[e===1?1:e===2?2:4];let n=0;return r("g",{children:[r(wt,{}),r("rect",{x:"23.4",y:"11",width:"8.2",height:"0.6",fill:e?"#3d8f5a":"#2c4234"}),e===0&&r("rect",{class:"tama-cursor",x:"24",y:"6.6",width:"0.6",height:"0.6",fill:"#707884"}),t.length>=2&&r("rect",{x:"27.45",y:"6",width:"0.12",height:"5",fill:"#4b515c"}),t.length===4&&r("rect",{x:"23.4",y:"8.45",width:"8.2",height:"0.12",fill:"#4b515c"}),t.slice(0,Math.min(e,4)).flatMap(([i,l,a,s])=>Array.from({length:s>=5?3:2},(o,c)=>{const u=n++;return r("rect",{class:"tama-type",style:{animationDelay:`${(-.37*u).toFixed(2)}s`},x:(i+.5).toFixed(2),y:(l+.6+c*1.1).toFixed(2),width:((a-1)*$2[u%6]).toFixed(2),height:"0.45",fill:S2[u%4]},u)}))]})}function E2({day:e,time:t}){const n=Math.min(3,7.6/(.6*t.length));return r("g",{children:[r(wt,{fill:"#16181d"}),r(Ue,{x:"24.1",y:"7.9",size:"1.3",fill:"#a4acb9",weight:500,children:e?`back ${e}`:"back at"}),r(Ue,{x:"27.5",y:"10.9",size:n.toFixed(2),fill:"#f2c14e",anchor:"middle",children:t}),r("circle",{cx:"30.85",cy:"6.95",r:"0.5",fill:"#f3e9c6"}),r("circle",{cx:"31.1",cy:"6.8",r:"0.42",fill:"#16181d"})]})}function P2(){return r("g",{fill:"var(--fg-2)","font-family":"var(--mono)","font-weight":"700",children:[r("text",{class:"tama-z",x:"17.5",y:"8.4","font-size":"3",children:"z"}),r("text",{class:"tama-z tama-z2",x:"19.6",y:"6","font-size":"3.8",children:"Z"})]})}function M2({x0:e}){return r("g",{fill:we,children:[r("rect",{x:e+5.5,y:V+2.6,width:"1",height:"1.6"}),r("rect",{x:e+12.5,y:V+2.6,width:"1",height:"1.6"})]})}function A2(){return r("g",{class:"tama-parcel","shape-rendering":Ge,children:[r("rect",{x:"24.6",y:"15.6",width:"4.8",height:"3.4",fill:"#c49a6c"}),r("rect",{x:"24.6",y:"15.6",width:"4.8",height:"0.7",fill:"#d8b384"}),r("rect",{x:"26.75",y:"15.6",width:"0.5",height:"3.4",fill:"#a57c4f"}),r("rect",{x:"28.3",y:"14.4",width:"2.2",height:"1.8",rx:"0.25",fill:"#52b4ea"}),r("path",{d:"M29.4 14.75 v1 M28.95 15.3 l0.45 0.5 l0.45 -0.5",fill:"none",stroke:"#ffffff","stroke-width":"0.28"})]})}const L2={code:{x0:3,sitting:!0},nap:{x0:3,sitting:!0},read:{x0:4,sitting:!0}},I2={x0:8},Fd=Kt(Ln),O2=Kt(Ln.map((e,t)=>t===2?e.replace(/^.##/,"...").replace(/##$/,".."):e)),na=xd.map(e=>Kt([e])),ra=V+2*Ln.length;function D2(){return r("g",{children:[r(rt,{cells:Fd,cls:"tama-body",x0:0}),r(ia,{x0:0}),r(rt,{cells:na[0],cls:"tama-legs-a",x0:0,y0:ra})]})}const R2=new Set([is,ls]),F2={beer:"pint",coffee:"mug",cook:"spoon",garden:"can",dog:"leash",music:"bass",game:"controller"};function Wn({dy:e,children:t}){return e?r("g",{transform:`translate(0 ${e})`,children:t}):t}function ia({closed:e,x0:t}){return r("g",{class:e?"tama-eyes-closed":"tama-eyes",children:ly.map(n=>r("rect",{x:t+n,y:e?V+3.3:V+2,width:"1",height:e?.5:2,fill:we},n))})}const Mo={spring:{sky:"#7fb3e0",ground:"#5c9a4c",canopy:["#6fae5a","#f2a7c3"],fall:"#f4b6cc"},summer:{sky:"#6fb4ea",ground:"#4f9443",canopy:["#4f9a46","#3f8238"]},autumn:{sky:"#c9a36b",ground:"#7a6a3a",canopy:["#d9822b","#b5452a"],fall:"#e07b39"},winter:{sky:"#9fb3c8",ground:"#e6edf3",fall:"#f4f8fb"}},N2=[[3,0],[11,-.7],[18,-1.6],[25.5,-.3],[32,-1.1]];function B2({season:e,night:t}){const n=Mo[e]||Mo.summer;return r("g",{class:"tama-scenery","data-season":e,children:[r("rect",{x:"0",y:"0",width:"34",height:"19.2",fill:n.sky,opacity:"0.13"}),r("rect",{x:"0",y:"19.4",width:"34",height:"4.6",fill:n.ground,opacity:e==="winter"?.85:.55}),t&&r("g",{children:[r("rect",{x:"0",y:"0",width:"34",height:"24",fill:"#0b0a1a",opacity:"0.5"}),r("g",{class:"tama-moon",children:[r("circle",{cx:"5",cy:"4.2",r:"2",fill:"#f3e9c6"}),r("circle",{cx:"4.3",cy:"3.7",r:"0.4",fill:"#d8ccaa"}),r("circle",{cx:"5.7",cy:"4.9",r:"0.3",fill:"#d8ccaa"})]}),r("g",{transform:"translate(19 3.2)",children:r("path",{class:"tama-bat",fill:"#1a1626",d:"M0 0.6 q1 -1 2 0 q0.4 -0.8 1 -0.2 q0.6 -0.6 1 0.2 q1 -1 2 0 q-1.2 0.1 -2 1 q-0.6 -0.4 -1 0 q-0.4 -0.4 -1 0 q-0.8 -0.9 -2 -1z"})})]}),e==="summer"&&!t&&r("circle",{class:"tama-sun",cx:"4.5",cy:"4",r:"2.1",fill:"#ffd166"}),r("rect",{x:"30.2",y:"11.6",width:"1.4",height:"7.6",fill:"#6b4a33"}),n.canopy?r("g",{children:[r("rect",{x:"27.4",y:"7.4",width:"6.6",height:"4.6",rx:"1.4",fill:n.canopy[0]}),r("rect",{x:"28.4",y:"5.8",width:"4.6",height:"2.2",rx:"1",fill:n.canopy[0]}),r("g",{fill:n.canopy[1],children:[r("rect",{x:"28.2",y:"8.2",width:"0.8",height:"0.8"}),r("rect",{x:"31.4",y:"7",width:"0.8",height:"0.8"}),r("rect",{x:"32.4",y:"9.8",width:"0.8",height:"0.8"}),r("rect",{x:"29.6",y:"10.4",width:"0.8",height:"0.8"})]})]}):r("g",{stroke:"#6b4a33","stroke-width":"0.5",children:[r("line",{x1:"30.9",y1:"12",x2:"28.4",y2:"8.2"}),r("line",{x1:"30.9",y1:"11",x2:"33.4",y2:"8"}),r("line",{x1:"30.9",y1:"9.6",x2:"30.4",y2:"6.2"})]}),e==="spring"&&r("g",{children:[r("rect",{x:"3",y:"19.8",width:"0.7",height:"0.7",fill:"#f2a7c3"}),r("rect",{x:"6.5",y:"20.6",width:"0.7",height:"0.7",fill:"#ffd166"}),r("rect",{x:"26",y:"20.2",width:"0.7",height:"0.7",fill:"#f2a7c3"})]}),e==="summer"&&r("g",{fill:"#3f8238",children:[r("rect",{x:"2.6",y:"18.4",width:"0.4",height:"1.2"}),r("rect",{x:"3.3",y:"18.1",width:"0.4",height:"1.5"}),r("rect",{x:"26.4",y:"18.3",width:"0.4",height:"1.3"})]}),e==="autumn"&&r("g",{fill:"#c2452d",children:[r("rect",{x:"4",y:"19.7",width:"1",height:"0.5"}),r("rect",{x:"24.8",y:"20.1",width:"1",height:"0.5"}),r("rect",{x:"27.6",y:"19.6",width:"1",height:"0.5",fill:"#e07b39"})]}),n.fall&&r("g",{fill:n.fall,children:N2.map(([i,l])=>r("rect",{class:"tama-fall",x:i,y:"-1",width:"0.7",height:"0.7",style:{animationDelay:`${l}s`}},i))})]})}function z2({x:e,y:t}){return r("g",{class:"tama-jack","shape-rendering":"geometricPrecision",children:[r("rect",{x:e+1.3,y:t,width:"0.5",height:"0.7",fill:"#4f7a2c"}),r("rect",{x:e,y:t+.4,width:"3.1",height:"2.2",rx:"1",fill:"#ef8a2c"}),r("rect",{x:e+1,y:t+.5,width:"0.15",height:"2",fill:"#d9741f"}),r("rect",{x:e+1.95,y:t+.5,width:"0.15",height:"2",fill:"#d9741f"}),r("path",{class:"tama-jack-face",fill:"#ffcf5a",d:`M${e+.6} ${t+1.4} l0.4 -0.6 l0.4 0.6z M${e+2.1} ${t+1.4} l0.4 -0.6 l0.4 0.6z M${e+.6} ${t+1.8} h1.9 l-0.3 0.5 h-1.3z`})]})}const j2={sleep:{x:1.5,y:16.4},coffee:{x:1.5,y:16.4},eat:{x:1.5,y:16.4},code:{x:25.5,y:16.4},nap:{x:25.5,y:16.4},read:{x:24.6,y:3.4}};function H2(){return r("g",{class:"tama-xmas-tree","shape-rendering":"geometricPrecision",children:[r("rect",{x:"2.9",y:"18.2",width:"1",height:"0.8",fill:"#5a3a26"}),r("polygon",{points:"3.4,12 7.6,18.2 -0.8,18.2",fill:"#276b3e"}),r("polygon",{points:"3.4,8.6 7.2,14.6 -0.4,14.6",fill:"#2f7d4a"}),r("polygon",{points:"3.4,5.2 6.8,10.8 0,10.8",fill:"#276b3e"}),r("polygon",{points:"3.4,2.4 6.2,7.2 0.6,7.2",fill:"#2f7d4a"}),r("polygon",{class:"tama-twinkle",points:"3.4,0.8 3.8,1.8 4.8,1.9 4,2.5 4.3,3.4 3.4,2.9 2.5,3.4 2.8,2.5 2,1.9 3,1.8",fill:"#ffd166"}),r("circle",{cx:"2.6",cy:"6.2",r:"0.42",fill:"#e05252"}),r("circle",{class:"tama-twinkle",cx:"4.6",cy:"9.4",r:"0.42",fill:"#7fb6e6"}),r("circle",{cx:"1.4",cy:"10",r:"0.42",fill:"#ffd166"}),r("circle",{class:"tama-twinkle tama-twinkle2",cx:"5.6",cy:"12.8",r:"0.42",fill:"#e05252"}),r("circle",{cx:"0.8",cy:"13.8",r:"0.42",fill:"#c792ea"}),r("circle",{cx:"6.6",cy:"16.6",r:"0.42",fill:"#ffd166"})]})}function q2(){return r("g",{class:"tama-stocking",children:[25.4,30.2].map(e=>r("g",{children:[r("rect",{x:e,y:"7.1",width:"1.2",height:"2.1",fill:"#c0392b"}),r("rect",{x:e,y:"8.6",width:"2",height:"0.9",rx:"0.4",fill:"#c0392b"}),r("rect",{x:e-.1,y:"7.1",width:"1.4",height:"0.6",fill:"#f4f4f6"})]},e))})}function Nd({x0:e}){return r("g",{class:"tama-hat-santa",children:[r("g",{fill:"#d03a3a",children:[r("rect",{x:e+4,y:"6.8",width:"10",height:"1.5"}),r("rect",{x:e+5.6,y:"5.6",width:"6.6",height:"1.3"}),r("rect",{x:e+7.4,y:"4.6",width:"3.6",height:"1.1"}),r("rect",{x:e+10.6,y:"4.6",width:"3",height:"1"}),r("rect",{x:e+13,y:"5.2",width:"1.2",height:"1"})]}),r("rect",{x:e+3,y:"8.2",width:"12",height:"1.3",rx:"0.5",fill:"#f4f4f6"}),r("rect",{x:e+13.6,y:"5.6",width:"1.6",height:"1.6",rx:"0.8",fill:"#f4f4f6"})]})}function Bd({x0:e}){return r("g",{class:"tama-hat-party","shape-rendering":"geometricPrecision",children:[r("polygon",{points:`${e+6.6},9 ${e+11.4},9 ${e+9},3.8`,fill:"#5aa9e6"}),r("rect",{x:e+7.5,y:"6.8",width:"3",height:"0.6",fill:"#ffd166"}),r("rect",{x:e+8.25,y:"5.2",width:"1.5",height:"0.5",fill:"#ffd166"}),r("circle",{cx:e+9,cy:"3.6",r:"0.8",fill:"#f28ab2"})]})}function U2({sprite:e,p:t,hat:n,season:i,ghost:l}){const a=(t==null?void 0:t.Headwear)&&!n,s=(t==null?void 0:t.snowcap)&&i==="winter"&&!n&&!l;return!a&&!s&&!n?null:r("g",{class:"tama-hat-seat",style:"transform-box: view-box",transform:Qg(e),children:[a&&r(t.Headwear,{x0:0}),s&&r("rect",{class:"tama-snowcap",x:"3",y:"8.4",width:"12",height:"0.7",rx:"0.3",fill:"#f4f8fb"}),n==="santa"&&r(Nd,{x0:0}),n==="party"&&r(Bd,{x0:0})]})}function W2({x0:e}){const t=e+2.2,n=e+15.8,i="q-0.85 1.1 -1.7 0 ".repeat(8);return r("g",{class:"tama-ghost","shape-rendering":"geometricPrecision",children:[r("path",{fill:"#f5f5f7",d:`M${t} 17.6 V10.4 Q${t} 7.6 ${(t+n)/2} 7.6 Q${n} 7.6 ${n} 10.4 V17.6 ${i}Z`}),r("ellipse",{cx:e+5.6,cy:"11.6",rx:"0.7",ry:"1",fill:we}),r("ellipse",{cx:e+12.4,cy:"11.6",rx:"0.7",ry:"1",fill:we}),r("ellipse",{cx:e+9,cy:"14",rx:"0.6",ry:"0.8",fill:we})]})}function K2({x0:e}){const t=e+16.4;return r("g",{class:"tama-pail","shape-rendering":"geometricPrecision",children:[r("path",{d:`M${t+.3} 13.8 Q${t+1.8} 11.2 ${t+3.3} 13.8`,fill:"none",stroke:"#3a2a1a","stroke-width":"0.35"}),r("rect",{x:t+.9,y:"13.1",width:"0.7",height:"0.7",fill:"#e05252"}),r("rect",{x:t+1.9,y:"12.9",width:"0.7",height:"0.7",fill:"#7fb6e6"}),r("rect",{x:t,y:"13.6",width:"3.6",height:"3.2",rx:"1.2",fill:"#ef8a2c"}),r("path",{fill:"#3a1e0e",d:`M${t+.7} 14.9 l0.5 -0.7 l0.5 0.7z M${t+2} 14.9 l0.5 -0.7 l0.5 0.7z M${t+.7} 15.5 h2.2 l-0.4 0.6 h-1.4z`})]})}const V2=[[5,4,"#ffd166",0],[22,2.6,"#f28ab2",-.9]],G2=[[17.4,2.8,"#ffd166",0],[24.6,2.1,"#f28ab2",-.6],[31.2,3,"#7fb6e6",-1.2]];function J2({clear:e}){const t=(n,i,l,a)=>r("g",{class:"tama-firework",style:{animationDelay:`${a}s`},fill:l,children:[[0,45,90,135,180,225,270,315].map(s=>{const o=s*Math.PI/180;return r("rect",{x:n+Math.cos(o)*1.8-.25,y:i+Math.sin(o)*1.8-.25,width:"0.5",height:"0.5"},s)}),r("rect",{x:n-.25,y:i-.25,width:"0.5",height:"0.5"})]},n);return r("g",{children:(e?G2:V2).map(([n,i,l,a])=>t(n,i,l,a))})}const Ao=["#ffd166","#f28ab2","#7fb6e6","#9be38f","#c792ea"];function Q2(){return r("g",{class:"tama-confetti",children:[[2.5,0],[9,-.6],[15,-1.4],[21,-.3],[27,-1.9],[32,-1]].map(([e,t],n)=>r("rect",{class:"tama-fall",x:e,y:"-1",width:"0.6",height:"0.6",fill:Ao[n%Ao.length],style:{animationDelay:`${t}s`}},e))})}function Y2({mood:e}){return e==="furious"?r("g",{class:"tama-errors",fill:"#e05252",children:[r("rect",{x:"24",y:"7",width:"4.4",height:"0.6"}),r("rect",{x:"24",y:"8.4",width:"6.2",height:"0.6"}),r("rect",{x:"24.8",y:"9.8",width:"3.6",height:"0.6"}),r("rect",{x:"29.4",y:"9.8",width:"0.6",height:"0.6",fill:"#ffd166"})]}):r("g",{children:[r("rect",{x:"24",y:"7",width:"4.4",height:"0.6",fill:"var(--accent)"}),e==="grumpy"?r("rect",{class:"tama-red-line",x:"24",y:"8.4",width:"3",height:"0.6",fill:"#e05252"}):r("rect",{x:"24",y:"8.4",width:"3",height:"0.6",fill:"#7fbf7f"}),r("rect",{x:"24.8",y:"9.8",width:"3.4",height:"0.6",fill:"#c792ea"}),r("rect",{class:"tama-cursor",x:"28.6",y:"9.8",width:"0.6",height:"0.6",fill:"#e6e9ef"})]})}function Z2({activity:e,occasion:t,coffee:n,ringing:i,keyboard:l=!0,mood:a="calm",screen:s=null,dish:o,mugHeld:c=!1}){switch(e){case"sleep":return i?null:r("g",{fill:"var(--fg-2)","font-family":"var(--mono)","font-weight":"700",children:[r("text",{class:"tama-z",x:"26",y:"10","font-size":"4",children:"z"}),r("text",{class:"tama-z tama-z2",x:"29",y:"7","font-size":"5",children:"Z"})]});case"coffee":return r("g",{children:!c&&r(Id,{})});case"code":return r("g",{children:[r("g",{class:"tama-chair",fill:"#4c525c",children:[r("rect",{x:"1.6",y:"9.6",width:"1.6",height:"8.4",rx:"0.5"}),r("rect",{x:"3.2",y:"16.9",width:"15",height:"1.3",rx:"0.4"}),r("rect",{x:"10",y:"18.2",width:"1.2",height:"0.8"}),r("rect",{x:"7",y:"18.6",width:"7.2",height:"0.5",rx:"0.25"})]}),r("g",{class:"tama-desk",children:[r("rect",{x:"20.2",y:"13.2",width:"13.6",height:"0.9",fill:"#8b6a4e"}),r("rect",{x:"21",y:"14.1",width:"0.9",height:"4.9",fill:"#6f533c"}),r("rect",{x:"32.2",y:"14.1",width:"0.9",height:"4.9",fill:"#6f533c"}),r("rect",{x:"26.9",y:"12",width:"1.2",height:"1.2",fill:"var(--fg-3)"}),r("rect",{x:"23",y:"5.6",width:"9",height:"6.4",rx:"0.4",fill:a==="furious"?"#2a1416":"#1d2026",stroke:"var(--fg-3)","stroke-width":"0.3"}),s||r(Y2,{mood:a}),l&&r("rect",{x:"20.4",y:"12.6",width:"4.2",height:"0.6",rx:"0.2",fill:"#c9ced6"})]}),n&&r("g",{class:"tama-desk-mug",children:[r("rect",{class:"tama-steam",x:"25.2",y:"9.4",width:"0.4",height:"1.4",fill:"var(--fg-3)"}),r("rect",{class:"tama-steam tama-steam2",x:"25.9",y:"8.8",width:"0.4",height:"1.4",fill:"var(--fg-3)"}),r("g",{fill:"#efe6d8",children:[r("rect",{x:"24.9",y:"11.3",width:"1.5",height:"1.9",rx:"0.25"}),r("rect",{x:"26.4",y:"11.8",width:"0.5",height:"0.35"}),r("rect",{x:"26.6",y:"11.8",width:"0.3",height:"1"}),r("rect",{x:"26.4",y:"12.5",width:"0.5",height:"0.35"})]}),r("rect",{x:"24.9",y:"11.3",width:"1.5",height:"0.45",fill:"#7a4e2d"})]})]});case"read":return r("g",{children:[r("ellipse",{class:"tama-glow",cx:"28",cy:"19",rx:"9",ry:"2.4",fill:"#f0a24a",opacity:"0.18"}),r("g",{class:"tama-fire",children:[r("rect",{x:"23.4",y:"6",width:"10.6",height:"1.1",fill:"#8a7a6a"}),r("rect",{x:"24.2",y:"7.1",width:"9.8",height:"11.9",fill:"#7b4a3a"}),r("g",{fill:"#6a3e30",children:[r("rect",{x:"24.2",y:"9.4",width:"9.8",height:"0.3"}),r("rect",{x:"24.2",y:"11.8",width:"9.8",height:"0.3"}),r("rect",{x:"24.2",y:"14.2",width:"9.8",height:"0.3"}),r("rect",{x:"24.2",y:"16.6",width:"9.8",height:"0.3"})]}),r("rect",{x:"25.8",y:"11",width:"6.6",height:"8",rx:"2.4",fill:"#1a1110"}),r("path",{class:"tama-flame",d:"M27.2 19 q-0.6 -2.6 1 -4.4 q0.2 1.6 1 2.2 q0.4 -1.4 1.4 -2.4 q1 2.6 0.2 4.6z",fill:"#f08a3c"}),r("path",{class:"tama-flame tama-flame2",d:"M28 19 q-0.2 -1.6 0.9 -2.8 q0.3 1.1 0.9 1.4 q0.5 -0.8 0.6 -1.4 q0.9 1.6 0.2 2.8z",fill:"#ffd166"}),r("rect",{x:"26.6",y:"18.4",width:"5",height:"0.6",rx:"0.3",fill:"#5a3a26"})]}),t==="yearend"&&r(q2,{}),t==="yearend"&&r(H2,{}),r("g",{class:"tama-chair",fill:"#8e3b3b",children:[r("rect",{x:"1",y:"8.6",width:"3.2",height:"9.6",rx:"1"}),r("rect",{x:"3.6",y:"16.8",width:"16.8",height:"1.5",rx:"0.6"})]}),r("g",{class:"tama-chair-legs",fill:"#4a2f22",children:[r("rect",{x:"1.5",y:"18.2",width:"0.9",height:"0.8"}),r("rect",{x:"5",y:"18.2",width:"0.9",height:"0.8"}),r("rect",{x:"16.4",y:"18.2",width:"0.9",height:"0.8"})]})]});case"eat":return r(Ay,{dish:o});default:return null}}function X2({p:e,season:t,trick:n,critter:i,from:l}){const a=r(e.Behind,{season:t,trick:n,critter:i,from:l});return e.outdoors?r("g",{children:[r(B2,{season:t,night:n}),a]}):a}function eb({activity:e}){return e!=="read"?null:r("g",{children:[r("rect",{class:"tama-chair",x:"17.4",y:"13.6",width:"3.6",height:"4.7",rx:"0.8",fill:"#7a3030"}),r("rect",{class:"tama-chair-legs",x:"19.6",y:"18.2",width:"0.9",height:"0.8",fill:"#4a2f22"}),r("g",{class:"tama-book",children:[r("rect",{x:"17.4",y:"10.6",width:"2.9",height:"3.4",fill:"#f2ece0"}),r("rect",{x:"20.3",y:"10.6",width:"2.9",height:"3.4",fill:"#ebe3d3"}),r("g",{fill:"#c9bfae",children:[r("rect",{x:"17.9",y:"11.4",width:"1.9",height:"0.3"}),r("rect",{x:"17.9",y:"12.3",width:"1.6",height:"0.3"}),r("rect",{x:"20.8",y:"11.4",width:"1.9",height:"0.3"}),r("rect",{x:"20.8",y:"12.3",width:"1.5",height:"0.3"})]}),r("rect",{class:"tama-page",x:"20.3",y:"10.6",width:"2.9",height:"3.4",fill:"#f6f1e6"}),r("rect",{x:"20.15",y:"10.6",width:"0.3",height:"3.4",fill:"#b9ae9b"})]})]})}function tb({x0:e,mood:t}){return r("g",{class:"tama-mood",children:[t==="furious"&&r("g",{class:"tama-flush",fill:"#ff3b2f",opacity:"0.5",children:[r("rect",{x:e+3,y:V,width:"12",height:"4"}),r("rect",{x:e+1,y:V+4,width:"16",height:"2"}),r("rect",{x:e+3,y:V+6,width:"12",height:"2"})]}),r("g",{class:"tama-brows",fill:we,children:[r("rect",{x:e+5,y:V+2.9,width:"1",height:"1.1"}),r("rect",{x:e+12,y:V+2.9,width:"1",height:"1.1"}),r("rect",{x:e+3.9,y:V+1.5,width:"1.3",height:"0.55"}),r("rect",{x:e+5.1,y:V+2.05,width:"1.3",height:"0.55"}),r("rect",{x:e+11.6,y:V+2.05,width:"1.3",height:"0.55"}),r("rect",{x:e+12.8,y:V+1.5,width:"1.3",height:"0.55"})]}),t==="furious"&&r("path",{class:"tama-scowl",fill:"none",stroke:we,"stroke-width":"0.35","shape-rendering":"geometricPrecision",d:`M${e+7.4} ${V+6} l0.8 -0.6 l0.8 0.6 l0.8 -0.6 l0.8 0.6`}),r("g",{fill:Wt,children:[r("rect",{class:"tama-hand",x:"20.7",y:"11.9",width:"1.1",height:"0.8"}),r("rect",{class:"tama-hand tama-hand2",x:"22.7",y:"11.9",width:"1.1",height:"0.8"})]}),r("g",{class:"tama-clack",fill:"#e6e9ef",children:[r("rect",{x:"21.1",y:"10.9",width:"0.25",height:"0.55"}),r("rect",{x:"23.3",y:"10.8",width:"0.25",height:"0.55"})]})]})}function nb({mood:e,x0:t,coffee:n,hat:i,headDy:l}){return e!=="furious"?null:r("g",{children:[r("g",{fill:"#c9ced6",children:[r("rect",{class:"tama-flying-key",x:"21.4",y:"12",width:"0.7",height:"0.7"}),r("rect",{class:"tama-flying-key tama-flying-key2",x:"23.1",y:"12",width:"0.7",height:"0.7"}),r("rect",{class:"tama-flying-key tama-flying-key3",x:"22.3",y:"12",width:"0.6",height:"0.6"})]}),r("g",{fill:"#8b93a1","shape-rendering":"geometricPrecision",children:[r("circle",{class:"tama-smoke",cx:"21.6",cy:"12.2",r:"0.5"}),r("circle",{class:"tama-smoke tama-smoke2",cx:"23.4",cy:"12.2",r:"0.45"})]}),!i&&r(Wn,{dy:l,children:r("g",{class:"tama-shimmer",fill:"none",stroke:"#ff8a5c","stroke-width":"0.3",opacity:"0.8","shape-rendering":"geometricPrecision",children:[6,9,12].map((a,s)=>r("path",{class:s===1?"tama-shimmer2":void 0,d:`M${t+a} ${s===1?7.2:7.6} q0.5 -0.7 0 -1.4 q-0.5 -0.7 0 -1.4`},a))})}),n&&r("g",{class:"tama-spill",fill:"#7a4e2d","shape-rendering":"geometricPrecision",children:[r("circle",{cx:"25.4",cy:"11.1",r:"0.25"}),r("circle",{class:"tama-spill2",cx:"26",cy:"11",r:"0.22"})]})]})}const rb=new Set(["bell","done","merged","api","ctx"]);function ib({activity:e,view:t,kind:n,duty:i,working:l,walled:a,mirroring:s}){return e==="nap"?r(E2,{...a}):t.atDesk?n==="done"?r(m2,{}):n==="merged"?r(g2,{}):n==="ci"?r(y2,{}):n==="api"?r(v2,{}):n==="ctx"?r(_2,{pct:i==null?void 0:i.pct,cost:i==null?void 0:i.cost}):s?r(T2,{n:l}):null:null}function lb({kind:e}){return r("g",{children:[e==="bell"&&r(h2,{}),e==="ctx"&&r(x2,{}),e==="update"&&r(A2,{})]})}function ab({activity:e,season:t="summer",occasion:n=null,coffee:i=!1,mood:l="calm",petted:a=!1,petKey:s=0,duty:o=null,working:c,walled:u=null,party:h=!1,dish:d,trick:p=!1,critter:f=gi[0]}){var Ae;const m=(o==null?void 0:o.kind)||null,k=ld(e,m),{atDesk:x}=k,b=p,C=Xy[e],g=C&&p?{...C,...C.trick}:C,{x0:y,sitting:$=!1,lift:v=0}=(g==null?void 0:g.pose)||L2[e]||I2,E=g?g.jack:j2[e],M=f.sprite,T=M&&La(M,{x0:y,sitting:$,height:b?vu:Aa}),S=T?B(T.top-V):0,L=e==="sleep"||e==="nap",O=m==="bell"&&L,j=L&&!O,I=m==="bell"&&(x||e==="nap"),D=b||j?null:x||rb.has(m)?m:null,R=!b&&!j&&(D==="done"||D==="merged"),Y=D==="merged",A=h&&!b&&!j?"party":n==="yearend"?"santa":n==="newyear"?"party":null,z=k.moodShown&&((Ae=$n[l])==null?void 0:Ae.rank)>0,w=k.showsPanes&&c!=null&&!z,K=ib({activity:e,view:k,kind:m,duty:o,working:c,walled:u,mirroring:w}),X=b?r(W2,{x0:y}):M?null:z?r(tb,{x0:y,mood:l}):j?r(ia,{closed:!0,x0:y}):R?r(Eo,{x0:y}):D==="api"?r(n2,{x0:y}):D==="update"?r(M2,{x0:y}):!D&&(g!=null&&g.smile)?r(Eo,{x0:y}):r(ia,{x0:y}),_=!M||b||j||z?null:R?"happy":D==="api"?"x":D==="update"?"down":D==="ctx"?"worried":!D&&(g!=null&&g.smile)?"happy":null,ee=M&&(g==null?void 0:g.Held)===is?"goggles":M&&(g==null?void 0:g.Held)===ls?"scarf":null,he=M?F2[e]??null:null,fe=he==="spoon"||he==="leash"?Zg(M,he,T):null,He=he==="bass"?Vs(T,[y+So.dx,So.y]):null,Me=M&&(z?o2:I?c2:null),ue=He??(Me?Vs(T,Me):null);return r("svg",{viewBox:"0 0 34 24","shape-rendering":"crispEdges","aria-hidden":"true","data-activity":e,"data-occasion":n||void 0,"data-mood":z?l:void 0,"data-duty":m||void 0,"data-pose":D||void 0,"data-urgent":o!=null&&o.urgent?"":void 0,"data-working":w?Math.min(c,4):void 0,"data-critter":M?f.id:void 0,"data-tempo":g==null?void 0:g.tempo,"data-stride":g!=null&&g.stride?"":void 0,style:g&&`--tama-tempo: ${g.tempo}s`,children:[r("rect",{x:"0",y:"19",width:"34",height:"0.4",fill:"var(--line)"}),(n==="newyear"||Y)&&r(J2,{clear:!!o}),g?r(X2,{p:g,season:t,trick:p,critter:f,from:fe}):r(Z2,{activity:e==="nap"?"code":e,occasion:n,coffee:i,ringing:O,keyboard:!(I||x&&m==="ctx"),mood:z?l:"calm",screen:K,dish:d,mugHeld:he==="mug"}),n==="halloween"&&E&&r(z2,{...E}),r("g",{transform:v?`translate(0 ${-v})`:void 0,children:r("g",{class:`tama-creature${a?" tama-hop":""}`,children:[M?r("g",{class:"tama-critter",style:"transform-box: view-box",transform:`translate(${T.tx} ${T.ty}) scale(${T.scale})`,children:[r(Zi,{sprite:M,mood:z?l:"calm",asleep:j,face:_,startle:D==="bell"&&!I,worn:ee,holding:he,tip:ue,paws:!!(g!=null&&g.paws),cheer:x&&R,seated:$,stride:!!(g!=null&&g.stride),children:He&&r("g",{style:"transform-box: view-box",transform:`scale(${1/T.scale}) translate(${-T.tx} ${-T.ty})`,children:r(Md,{x0:y,limb:M.limb})})}),r(U2,{sprite:M,p:g,hat:A,season:t,ghost:b}),he&&r(Ad,{sprite:M,kind:he,scale:T.scale})]}):r(rt,{cells:g!=null&&g.paws?O2:Fd,cls:"tama-body",x0:y}),X,(g==null?void 0:g.Held)&&!(M&&(R2.has(g.Held)||he))&&r(g.Held,{x0:y}),he==="spoon"&&r(Dd,{x0:y,from:fe}),he==="controller"&&r("g",{transform:`translate(0 ${Math.min(T.drop,.8)})`,children:r(Ld,{x0:y,limb:M.limb})}),!M&&r(Wn,{dy:S,children:(g==null?void 0:g.Headwear)&&!A&&r(g.Headwear,{x0:y})}),r(Wn,{dy:S,children:D==="api"&&r(i2,{x0:y})}),!M&&D==="ctx"&&r(r2,{x0:y}),!M&&x&&R&&r(a2,{x0:y}),x&&D==="ci"&&r(b2,{}),!M&&I&&r(s2,{}),M&&z&&r(u2,{limb:M.limb}),M&&I&&r(d2,{limb:M.limb}),!M&&r(Wn,{dy:S,children:D==="bell"&&!I&&r(l2,{x0:y})}),!M&&!$&&r(rt,{cells:na[0],cls:"tama-legs-a",x0:y,y0:ra}),!M&&(g==null?void 0:g.stride)&&r(rt,{cells:na[1],cls:"tama-legs-b",x0:y,y0:ra}),b&&(g==null?void 0:g.pail)&&r(K2,{x0:y}),!M&&r(Wn,{dy:S,children:[(g==null?void 0:g.snowcap)&&t==="winter"&&!A&&!b&&r("rect",{class:"tama-snowcap",x:y+3,y:"8.4",width:"12",height:"0.7",rx:"0.3",fill:"#f4f8fb"}),A==="santa"&&r(Nd,{x0:y}),A==="party"&&r(Bd,{x0:y})]})]},s)}),(g==null?void 0:g.Front)&&r(g.Front,{}),r(eb,{activity:e}),(x||I)&&r(lb,{kind:m}),e==="nap"&&!O&&r(P2,{}),O&&e==="sleep"&&r(f2,{}),R&&r(p2,{}),z&&r(nb,{mood:l,x0:y,coffee:i,hat:A,headDy:S}),(n==="newyear"||Y)&&r(Q2,{}),o&&r(t2,{kind:m,label:o.label,urgent:o.urgent,more:o.more,x0:y}),a&&r("g",{transform:`translate(${y-8} 0)`,children:r("path",{class:"tama-heart",fill:"#e8657a","shape-rendering":"geometricPrecision",d:"M17 7.2 l-2.3 -2.3 a1.25 1.25 0 0 1 2.3 -1.7 a1.25 1.25 0 0 1 2.3 1.7z"})},`heart-${s}`)]})}const sb=Qt(()=>wu(Mu())),zd=e=>e.map(t=>[t.since*1e3,t.until==null?1/0:t.until*1e3]),Lo=e=>({...yd(Na(),e),walls:zd(_a.value)});function ob(){const[e,t]=N(()=>new Date),[n,i]=N(0),[l,a]=N(!1),o=ul(()=>{const R=Na();return JSON.stringify([R.merged??null,R.furious??null,_a.value])}).value,[c,u,h]=JSON.parse(o),d={...yd({merged:c,furious:u},e),walls:zd(h)},p=J(o);H(()=>{if(p.current!==o){p.current=o,t(new Date);return}const R=setTimeout(()=>t(new Date),md(e,d)+50);return()=>clearTimeout(R)},[e,o]),H(()=>{const R=setInterval(()=>{const Y=new Date;t(A=>fo(Y,Lo(Y))===fo(A,Lo(A))?A:Y)},6e4);return()=>clearInterval(R)},[]),H(()=>{if(!l)return;const R=setTimeout(()=>a(!1),900);return()=>clearTimeout(R)},[l,n]);const f=Rc(0);H(()=>{const R=setInterval(()=>{f.value+=1},6e4);return()=>clearInterval(R)},[]),H(()=>{sy()},[]);const m=sb.value,k=ul(()=>{var z;f.value;const R=(z=zi.value)==null?void 0:z.plan,Y=ny(R,Date.now()/1e3),A=Y.account&&Mn()?vn(Y.account):null;return JSON.stringify([Y.mood,ry(Y,A)])}),[x,b]=JSON.parse(k.value);H(()=>{x==="furious"&&Lu("furious",gd(new Date))},[x,el(e)]);const C=ul(()=>{f.value;const R=Date.now()/1e3,Y=L0({windows:ce.value||[],alerts:ar.value||[],dismissedAlertIds:or.value,dismissedNeedsPids:pt.value,dismissedReadyPids:mt.value,selectedPid:rd(ke.value),parties:br.value,update:xa.value,nowSec:R}),A=Nc.value;return JSON.stringify({items:Y,more:I0(Y),wall:A&&D0(A.until,R),working:ar.value===null?null:Nu(ce.value).length})}),g=JSON.parse(C.value),y=g.items[0]||null,$=yr(e,d),v=Q0(e,d),E=tl(e),M=vd(e),T=ld($.id,y==null?void 0:y.kind),S=po($,T.moodShown?x:"calm"),L=[...g.wall&&hd(e,d)?[R0(g.wall)]:[],...g.items.map(R=>R.phrase),...T.showsPanes&&g.working?[`${Sn(g.working,"agent")} working`]:[],...T.moodShown&&b?[b]:[],...M?[M]:[],...v?[`up next at ${iy(v.at)}: ${po(v.activity)}`]:[]],O=`${m.sprite?m.name:"Claude"} is ${S} (${ea($.from)}–${ea($.to)})${L.map(R=>` · ${R}`).join("")}`+(y!=null&&y.target?` · click to ${y.target.says}`:"");function j(){i(R=>R+1),a(!0)}const I=J(y);I.current=y;const[D]=N(()=>Py({target:()=>{var R;return(R=I.current)==null?void 0:R.target},pet:j}));return H(()=>()=>D.dispose(),[]),r("button",{type:"button",class:"tama",title:O,"aria-label":O,onClick:D.onClick,onDblClick:D.onDblClick,children:r(ab,{activity:$.id,dish:$.dish,trick:!!$.trick,season:Sr(e),occasion:E==null?void 0:E.id,coffee:!!$.coffee,mood:x,petted:l,petKey:n,duty:y&&{kind:y.kind,label:y.label,urgent:!!y.urgent,more:g.more,pct:y.pct,cost:y.cost},working:g.working,walled:g.wall,party:g.items.some(R=>R.kind==="merged"),critter:m})})}const Io=["session","week_all","week_opus","week_sonnet"];function cb(e){const t=Object.keys(e).filter(n=>!Io.includes(n)).sort();return[...Io,...t].filter(n=>e[n]).map(n=>({key:n,label:Za(n),m:e[n]}))}function ub(e){const t=st.value.map(i=>i.id).filter(i=>e.includes(i)),n=e.filter(i=>!t.includes(i)).sort();return[...t,...n]}function db(e,t){return e?ub(Object.keys(e)).map(n=>{const i=e[n]||{},l=i.available&&i.meters?cb(i.meters):[],a=l.length>0,s=a?l.reduce((o,c)=>(c.m.percent||0)>(o.m.percent||0)?c:o):null;return{id:n,label:vn(n),available:a,stale:a&&Qa(i,t),fetchedAt:i.fetched_at||null,meters:l,headline:s}}):[]}function hb(e){const t=(e.meters||[]).filter(n=>n!==e.headline);return{hot:t.filter(n=>n.m.hot),blow:t.filter(n=>!n.m.hot&&Ya(n.m))}}const fb=48*3600;function jd(e){return e==="week_fable"||e.startsWith("week_fable_")}function pb(e,t){const n=(e==null?void 0:e.available)&&e.meters||{},i=Object.keys(n).find(jd),l=i&&n[i];if(!l||l.projected_percent==null||!l.resets_at)return!1;const a=l.resets_at-t;return l.projected_percent<100&&a>0&&al!=null);if(!t.length)return null;const n=Math.min(...t),i=Math.max(...t);return i<=e.percent?null:{text:i-n>10?`→${n}–${i}%`:`→${i}%`,blow:Ya(e)}}function gb({a:e}){const{hot:t,blow:n}=hb(e);if(!t.length&&!n.length)return null;const i=[...t.map(l=>`${l.label}: burning 🔥`),...n.map(l=>`${l.label}: on track to hit its limit`)];return r("span",{class:`usage-acct-more${t.length?"":" blow"}`,title:[...i,"(click to show every meter)"].join(`
+`),children:t.length?"🔥":"→"})}function yb({label:e,m:t,resets:n,pace:i}){const l=t.percent,a=l>=90?"danger":l>=70?"warn":"ok",s=[`${e} — ${l}% used. ${n||""}`,...i].join(`
+`),o=mb(t);return r("div",{class:"usage-item",title:s,children:[r("span",{class:"usage-item-label",children:e}),r("span",{class:"usage-item-bar",children:r("span",{class:`usage-item-fill ${a}`,style:`width:${l}%`})}),r("b",{children:[l,"%"]}),o&&r("span",{class:`usage-item-proj${o.blow?" blow":""}`,children:o.text}),t.hot&&r("span",{class:"usage-item-hot",children:"🔥"})]})}const la=q(!1);function Wd(){la.value=!0}function bb(e,t,n,i){const l=e.meters.map(({m:a})=>[`${a.label}: ${a.percent}% used`,qd(a.resets_at),...Ud(a)].filter(Boolean).join(`
+ `));if(n){const a=n.verified?`resets ${Ti(n.resets_at)}`:"not anchored";l.push(`poked ${Ti(n.at)} → ${a}`)}if(i){const a=e.meters.find(({key:s})=>jd(s));a&&l.push(`💤 fable on pace for ${a.m.projected_percent}% at reset — burn it or lose it`)}return e.stale&&l.push(`⚠ stale — last updated ${Pe(e.fetchedAt)} ago`),l.push(t?"(click to collapse)":"(click to show every meter)"),[`account ${e.label}`,...l].join(`
-`)}function N2(){const e=Xl.value,t=Ri.value||{},n=t.fallback,i=Math.floor(Date.now()/1e3),l=A2(t.plan,i),a=$n(),s=new Set(Object.keys(t.plan||{}).filter(c=>I2(t.plan[c],i)));if(l.some(c=>c.available))return r("div",{id:"usage",class:`usage${e?" is-expanded":""}`,onClick:()=>{Xl.value=!e},children:l.map(c=>{var p;return r("div",{class:`usage-acct${c.stale?" is-stale":""}`,title:F2(c,e,(p=t.poke)==null?void 0:p[c.id],s.has(c.id)),children:[a&&r("span",{class:"usage-acct-label",children:c.label}),c.available?(e?c.meters:[c.headline]).map(({key:d,label:f,m:h})=>r(R2,{label:f,m:h,resets:Sd(h.resets_at),pace:$d(h)},d)):r("span",{class:"usage-acct-off",title:"no usable credential for this account",children:"no data"}),!e&&c.available&&r(D2,{a:c}),c.stale&&r("span",{class:"usage-stale-mark",children:"⚠"}),s.has(c.id)&&r("span",{class:"usage-acct-waste",title:"Fable budget on pace to go unused at reset",children:"💤"})]},c.id)})});if(!(n!=null&&n.available))return r("div",{id:"usage",class:"usage"});const o=(n.input_tokens||0)+(n.cache_creation_tokens||0)+(n.output_tokens||0),u=`Claude Code plan usage estimate (JSONL-derived; plan fetch not yet ready)
+`)}function kb(){const e=la.value,t=zi.value||{},n=t.fallback,i=Math.floor(Date.now()/1e3),l=db(t.plan,i),a=Mn(),s=new Set(Object.keys(t.plan||{}).filter(u=>pb(t.plan[u],i)));if(l.some(u=>u.available))return r("div",{id:"usage",class:`usage${e?" is-expanded":""}`,onClick:()=>{la.value=!e},children:l.map(u=>{var h;return r("div",{class:`usage-acct${u.stale?" is-stale":""}`,title:bb(u,e,(h=t.poke)==null?void 0:h[u.id],s.has(u.id)),children:[a&&r("span",{class:"usage-acct-label",children:u.label}),u.available?(e?u.meters:[u.headline]).map(({key:d,label:p,m:f})=>r(yb,{label:p,m:f,resets:qd(f.resets_at),pace:Ud(f)},d)):r("span",{class:"usage-acct-off",title:"no usable credential for this account",children:"no data"}),!e&&u.available&&r(gb,{a:u}),u.stale&&r("span",{class:"usage-stale-mark",children:"⚠"}),s.has(u.id)&&r("span",{class:"usage-acct-waste",title:"Fable budget on pace to go unused at reset",children:"💤"})]},u.id)})});if(!(n!=null&&n.available))return r("div",{id:"usage",class:"usage"});const o=(n.input_tokens||0)+(n.cache_creation_tokens||0)+(n.output_tokens||0),c=`Claude Code plan usage estimate (JSONL-derived; plan fetch not yet ready)
${n.messages} assistant messages
- ${ml(o)} active tokens
- ${ml(n.cache_read_tokens)} cache reads (discounted)`;return r("div",{id:"usage",class:"usage usage-fallback",title:u,children:`5h: ${ml(o)} · ${xd(n.reset_at)}`})}function B2({id:e,toggleClass:t,toggleLabel:n,title:i,children:l}){const[a,s]=B(!1),o=te(null),u=br(()=>s(!1),[]);return Fi(o,a,u),r("div",{class:"tb-dd",ref:o,children:[r("button",{type:"button",class:t,id:e,"aria-haspopup":"menu","aria-expanded":a?"true":"false",title:i,onClick:c=>{c.stopPropagation(),s(p=>!p)},children:n}),r("div",{class:"tb-dd-menu",role:"menu",hidden:!a,onClick:()=>s(!1),children:l})]})}function z2(){const e=ce.value,t=e.length,n=e.filter(o=>o.state==="needs-input").length,i=e.filter(o=>o.state==="working").length,l=e.filter(o=>o.state==="done").length,a=e.filter(o=>o.state==="idle").length,s=()=>r("span",{class:"count-sep",children:"·"});return r("span",{id:"counts",children:[r("span",{children:[r("b",{children:t})," windows"]}),n>0&&r(K,{children:[" ",r(s,{})," ",r("span",{class:"count-needs",children:[n," needs input"]})]})," ",r(s,{})," ",r("span",{class:"count-working",children:[i," working"]})," ",r(s,{})," ",r("span",{class:"count-done",children:[l," done"]})," ",r(s,{})," ",r("span",{class:"count-idle",children:[a," idle"]})]})}function j2(){j(()=>{function t(n){(n.metaKey||n.ctrlKey)&&n.key==="/"&&(ye("key.shortcut",{key:"cmd+/"}),n.preventDefault(),window.location.href="/history")}return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[]);const e=te(null);return j(()=>{const t=e.current;if(!t)return;const n=()=>document.documentElement.style.setProperty("--header-h",`${t.offsetHeight}px`);n();const i=new ResizeObserver(n);return i.observe(t),()=>i.disconnect()},[]),r("header",{class:"periscope-header",ref:e,"data-pin-rows":$n()?3:2,children:[r("div",{class:"topbar",children:[r("span",{class:"brand",children:["periscope",r("i",{class:"brand-cursor"})]}),r(N2,{}),r(k1,{}),r("div",{class:"spawn-pins",children:[r(w1,{}),r($1,{}),r(_1,{})]}),r(W0,{})]}),r("nav",{class:"filters",id:"filters",children:[r("a",{href:"/history",class:"filter-btn is-action",id:"history-link",title:"search conversation history (⌘/)",children:["🔍 history ",r("span",{class:"ps-kbd",style:"margin-left:4px",children:"⌘"}),r("span",{class:"ps-kbd",children:"/"})]}),r("span",{class:"filters-sep"}),r(h1,{}),r("span",{class:"filters-sep"}),r("button",{type:"button",class:"filter-btn is-action",id:"new-open-btn",title:"open a repo, worktree, or PR",onClick:()=>{var t;return(t=window.__periscopeOpenOmnibox)==null?void 0:t.call(window)},children:"+ new"}),r("button",{type:"button",class:"filter-btn is-action",id:"reviews-btn",title:"open branches, walkthroughs, review comments",onClick:Ra,children:["◉ reviews",Ds(gt.value)?r("span",{class:"rail-review-badge",children:Ds(gt.value)}):null]}),r(B2,{id:"more-dd-toggle",toggleClass:"filter-btn is-action tb-dd-toggle",toggleLabel:"⋯",title:"more actions",children:[r("button",{id:"cleanup-btn",class:"tb-dd-item",role:"menuitem",title:"archive worktrees with merged PRs, deleted branches, or idle activity",children:"🧹 cleanup"}),r("button",{id:"settings-btn",class:"tb-dd-item",role:"menuitem",title:"settings",children:"🛠 settings"}),r("button",{id:"open-commands",class:"tb-dd-item",role:"menuitem",title:"edit + claude / + shell / + ... commands",children:"⚙ commands"})]}),r("span",{class:"filters-sep"}),r(f1,{}),r("div",{class:"meta",children:r(z2,{})})]}),r(T2,{})]})}const H2=3e3;let gl=null,Zr=!1,So=!1,jn=!1;function q2(){if(So)return;So=!0;const e=window.WebSocket;function t(){return{readyState:0,binaryType:"arraybuffer",send(){},close(){},onopen:null,onmessage:null,onerror:null,onclose:null}}function n(i,l){return jn&&String(i).includes("/ws/pane")?t():l===void 0?new e(i):new e(i,l)}n.CONNECTING=e.CONNECTING,n.OPEN=e.OPEN,n.CLOSING=e.CLOSING,n.CLOSED=e.CLOSED,n.prototype=e.prototype,window.WebSocket=n}async function U2(e){var w,C;Zr=!0;const t=e.settleMs||2e3,n=e.switches||20,i=(e.kind||"claude")==="claude",l=(ce.value||[]).filter(y=>y.agent==="claude"===i&&y.pid),a=Math.max(2,e.poolSize||(((w=e.pids)==null?void 0:w.length)??2)),s=((C=e.pids)==null?void 0:C.length)>=2?e.pids:l.slice(0,a).map(y=>y.pid),o=document.title;if(s.length<2){ye("memtest.abort",{nonce:e.nonce,reason:"need 2 pids"}),Zr=!1;return}const u=ke.value,c=s.map(y=>yu(y)),p=e.mode||"terminal";if(!e.realClick)for(const y of s)Ul(y,p);jn=!!e.blockWs,jn&&q2();const d=document.getElementById("rail")||document.querySelector(".rail, #left");ye("memtest.start",{nonce:e.nonce,n,mode:p,blockWs:jn,pids:s,realClick:!!e.realClick,scrollRail:!!e.scrollRail,hoverStorm:!!e.hoverStorm,railScroll:d?{sh:d.scrollHeight,ch:d.clientHeight}:null,noWebgl:(()=>{try{return localStorage.getItem("periscope.noWebgl")==="1"}catch{return null}})()});const f=e.tabPath||null,h=y=>new Promise(g=>setTimeout(g,y));let m=0,b=1;function x(){const y=document.querySelectorAll(".rail-row.pane-row");if(y.length<2)return;const g=Math.min(y.length,Math.max(2,e.poolSize||y.length));m>=g&&(m=g-1);const $=y[m];if(e.scrollRail&&$.scrollIntoView({behavior:"smooth",block:"center"}),e.hoverStorm)for(const v of y)v.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0})),v.dispatchEvent(new MouseEvent("mouseout",{bubbles:!0}));$.click(),m+=b,(m>=g-1||m<=0)&&(b=-b)}for(let y=1;y<=n;y++){const g=s[y%s.length];e.realClick?x():ke.value=`pane:${g}`,document.title=`memtest ${y}/${n}`,await h(f?t/3:t),f&&(kr({path:f}),await h(t/3),jr(g,"pane"),await h(t/3)),y%5===0&&ye("memtest.progress",{nonce:e.nonce,i:y})}if(f)for(const y of s)Mc(y,f);if(jn=!1,!e.realClick)for(const[y,g]of s.entries())Ul(g,c[y]||"terminal");ke.value=u,e.realClick&&(u!=null&&u.startsWith("pane:"))&&yt({kind:"pane",pid:u.slice(5)}),document.title=o,ye("memtest.done",{nonce:e.nonce,n,mode:p}),Zr=!1}async function $o(){try{const e=await fetch("/memtest.json",{cache:"no-store"});return e.ok?await e.json():null}catch{return null}}async function W2(){const e=await $o();e!==null&&(gl=e.nonce??null,setInterval(async()=>{if(Zr)return;const t=await $o();!t||t.nonce==null||t.nonce===gl||(gl=t.nonce,U2(t))},H2))}const fn=H([]);let K2=1;function V2(e){return new Promise(t=>{fn.value=[...fn.value,{...e,id:K2++,resolve:t}]})}function On(e,t){const n=fn.value.find(i=>i.id===e);fn.value=fn.value.filter(i=>i.id!==e),n&&n.resolve(t)}function Yn(e,t={}){return V2({type:"confirm",message:e,okLabel:t.okLabel||"OK",cancelLabel:t.cancelLabel||"Cancel",danger:!!t.danger})}function G2(e){return String(e??"").split(`
-`).map((n,i)=>r(K,{children:[i>0?r("br",{}):null,n]}))}function J2({req:e}){const t=te(null),n=te(null),i=e.type==="confirm"&&e.danger,l=e.type==="confirm"?!1:e.type==="prompt"?null:void 0;ot(()=>On(e.id,l)),j(()=>{var p,d;const c=t.current;if(c&&!c.open&&c.showModal(),e.type==="prompt"){const f=n.current;f&&(f.focus(),f.select())}else i?(p=c==null?void 0:c.querySelector(".confirm-dialog-cancel"))==null||p.focus():(d=c==null?void 0:c.querySelector(".confirm-dialog-ok"))==null||d.focus()},[]);const a=()=>{var c;e.type==="prompt"?On(e.id,((c=n.current)==null?void 0:c.value)??""):e.type==="alert"?On(e.id,void 0):On(e.id,!0)},s=()=>On(e.id,l),o=c=>{c.target===t.current&&s()},u=e.type==="prompt"?"confirm-dialog prompt-dialog":"confirm-dialog";return r("dialog",{ref:t,class:u,onClick:o,children:[r("p",{class:"confirm-dialog-msg",children:G2(e.message)}),e.type==="prompt"&&r("input",{ref:n,type:"text",class:"prompt-dialog-input",autocomplete:"off",spellcheck:!1,value:e.defaultValue,placeholder:e.placeholder||void 0,onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),a())}}),r("div",{class:"confirm-dialog-actions",children:[e.type!=="alert"&&r("button",{type:"button",class:"confirm-dialog-cancel",onClick:s,children:e.cancelLabel}),r("button",{type:"button",class:`confirm-dialog-ok${i?" is-danger":""}`,onClick:a,children:e.okLabel})]})]})}function Q2(){const e=fn.value;return r(K,{children:e.map(t=>r(J2,{req:t},t.id))})}async function gr(e,t,n={}){let i;try{i=await fetch(t,n)}catch(a){return{error:`${e} failed: ${a.message}`,reason:a.message}}let l={};try{l=await i.json()}catch{}if(!i.ok){const a=l.detail||`HTTP ${i.status}`;return{error:l.detail||`${e} failed: ${a}`,reason:a,status:i.status}}return{data:l}}const rn=H(!1),Nt=H(null);function Y2(e){return Array.isArray(e)?e.filter(Boolean):null}function Z2(e,t){return e===t?!0:!e||!t?!1:e.length===t.length&&e.every((n,i)=>n===t[i])}function Td(e){const{paths:t}=e||{},n=Y2(t);Z2(n,Nt.value)||(Nt.value=n),rn.value=!0,ye("overlay.open",{which:"cleanup",scoped:!!Nt.value})}function X2(e){return e!=null&&e.length?`/api/cleanup/candidates?${e.map(t=>`paths=${encodeURIComponent(t)}`).join("&")}`:"/api/cleanup/candidates"}function Dn(){rn.value=!1,Nt.value=null}function eb(){ot(Dn,rn.value);const[e,t]=B(""),[n,i]=B(!1),[l,a]=B([]),[s,o]=B({}),[u,c]=B(!1),[p,d]=B(!1),f=te(0);j(()=>{const x=document.getElementById("cleanup-btn"),w=()=>Td();return x&&x.addEventListener("click",w),()=>{x&&x.removeEventListener("click",w)}},[]);async function h(){const x=++f.current;t(""),i(!0),a([]),o({});const w=Nt.peek();if(w&&w.length===0){i(!1);return}const{data:C,error:y}=await gr("load candidates",X2(w));if(x!==f.current)return;if(i(!1),y){t(y),a([]);return}const g=C.candidates||[];a(g);const $={};g.forEach((v,E)=>{$[E]=!v.dirty}),o($)}j(()=>{if(!rn.value){f.current++;return}c(!1),h()},[rn.value,Nt.value]);const m=Object.values(s).filter(Boolean).length;async function b(){t("");const x=[];if(l.forEach((y,g)=>{s[g]&&x.push({pinned_dir:y.pinned_dir,delete_branch:u})}),x.length===0)return;d(!0);const{data:w,error:C}=await gr("archive","/api/cleanup/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({candidates:x})});if(d(!1),C){t(C);return}if(w.failed&&w.failed.length>0){const y=`Archived ${w.archived.length}, ${w.failed.length} failed: `+w.failed.map(g=>`${g.pinned_dir.split("/").pop()}: ${g.error}`).join("; ");await h(),t(g=>g||y);return}Dn()}return rn.value?r("div",{id:"cleanup-modal",class:"cleanup-modal-overlay",onClick:x=>{x.target.id==="cleanup-modal"&&Dn()},children:r("div",{class:"cleanup-modal-card",children:[r("header",{class:"cleanup-modal-head",children:[r("h2",{children:"🧹 cleanup"}),r("button",{id:"cleanup-modal-close",title:"close",onClick:Dn,children:"×"})]}),r("p",{class:"cleanup-modal-sub",children:"Worktrees with merged/closed PRs, deleted remote branches, or idle activity. Dirty worktrees are NOT auto-selected."}),r("div",{id:"cleanup-modal-controls",children:r("label",{class:"cleanup-delete-branches",children:[r("input",{type:"checkbox",id:"cleanup-delete-branches",checked:u,onChange:x=>c(x.currentTarget.checked)})," also delete local branches"]})}),r("div",{id:"cleanup-modal-list",children:n?r("div",{class:"cleanup-loading",children:"Walking worktrees…"}):l.length===0&&!e?r("div",{class:"cleanup-empty",children:Nt.value?"Nothing to clean up here. Cleanup only offers a worktree (never a main checkout) whose PR is merged or closed, whose remote branch is gone, or that sits idle.":"No cleanup candidates. 🎉"}):l.map((x,w)=>{const C=x.project_name||`(untracked: ${x.pinned_dir.split("/").pop()})`;return r("label",{class:x.dirty?"cleanup-row cleanup-row-dirty":"cleanup-row","data-i":w,children:[r("input",{type:"checkbox",class:"cleanup-row-check",checked:!!s[w],onChange:y=>o(g=>({...g,[w]:y.currentTarget.checked}))}),r("div",{class:"cleanup-row-body",children:[r("div",{class:"cleanup-row-title",children:C}),r("div",{class:"cleanup-row-meta",children:[x.branch," ",x.dirty?r("span",{class:"cleanup-dirty",children:"⚠ dirty"}):null]}),r("div",{class:"cleanup-row-signals",children:(x.signals||[]).map((y,g)=>r("span",{class:`cleanup-badge cleanup-badge-${y.kind}`,children:y.label},g))})]})]},x.pinned_dir)})}),r("div",{id:"cleanup-modal-error",class:"cleanup-modal-error",hidden:!e,children:e}),r("div",{class:"cleanup-modal-actions",children:[r("button",{type:"button",id:"cleanup-cancel",onClick:Dn,children:"cancel"}),r("button",{type:"button",id:"cleanup-submit",disabled:n||p||m===0,onClick:b,children:["archive selected (",m,")"]})]})]})}):null}const $i=H(!1);function Co(){$i.value=!0,ye("overlay.open",{which:"commands"})}function yl(){$i.value=!1}function tb({c:e,i:t,onDragState:n}){const i=te(null);async function l(s){const o=i.current;if(!o)return;const u=o.querySelector(".commands-label").value.trim(),c=o.querySelector(".commands-exec").value;u&&await Og(e.label,{label:u,exec:c})}async function a(){await Dg(e.label)}return r("div",{ref:i,class:"commands-row",draggable:!0,"data-label":e.label,"data-i":t,onDragStart:s=>{var o;n(e.label),(o=i.current)==null||o.classList.add("dragging"),s.dataTransfer.setData("text/plain",e.label),s.dataTransfer.effectAllowed="move"},onDragEnd:()=>n(null),onDragOver:s=>{s.preventDefault(),s.dataTransfer.dropEffect="move";const o=i.current.getBoundingClientRect(),u=s.clientY{var s;(s=i.current)==null||s.classList.remove("drag-over-top","drag-over-bottom")},onDrop:s=>{s.preventDefault();const o=i.current.getBoundingClientRect(),u=s.clientY{const l=document.getElementById("open-commands");return l&&l.addEventListener("click",Co),()=>{l&&l.removeEventListener("click",Co)}},[]);const e=te(null),t=l=>{e.current=l};t.drop=(l,a)=>{const s=e.current;if(!s||l===s)return;const o=Wr().map(d=>d.label),u=o.indexOf(s);if(u<0)return;o.splice(u,1);const c=o.indexOf(l),p=a?c:c+1;o.splice(p,0,s),Rg(o)};async function n(){const l="command";let a=l,s=1;const o=new Set(Wr().map(u=>u.label));for(;o.has(a);)a=`${l}-${++s}`;await Ig({label:a,exec:""})}if(!$i.value)return null;const i=Wr();return r("div",{id:"commands-modal",class:"commands-modal-overlay",onClick:l=>{l.target.id==="commands-modal"&&yl()},children:r("div",{class:"commands-modal-card",children:[r("header",{class:"commands-modal-head",children:[r("h2",{children:"New-window commands"}),r("button",{id:"commands-modal-close",title:"close",onClick:yl,children:"×"})]}),r("p",{class:"commands-modal-sub",children:["First row is the primary button. Drag rows to reorder. Empty ",r("code",{children:"exec"})," = bare shell."]}),r("div",{id:"commands-modal-list",children:i.map((l,a)=>r(tb,{c:l,i:a,onDragState:t},l.label))}),r("button",{id:"commands-modal-add",class:"commands-modal-add",onClick:n,children:"+ add command"})]})})}const Ed=[{id:"default",label:"default"},{id:"full",label:"full"}];function bl(e){return(e==null?void 0:e.mode)==="agent"&&(e.agent||"claude")==="claude"}function rb(e){return!e||e==="default"?null:e}function To(e){var t;return((t=Ed.find(n=>n.id===e))==null?void 0:t.label)||e}const Eo=["shell","idle","done","working","needs-input"];function Po(e){let t=-1;for(const n of e){const i=Eo.indexOf(n);i>t&&(t=i)}return t>=0?Eo[t]:"shell"}const Pd="";function Ya(e,t,n,i={},l=[]){const a=i.trackOrder||[],s=i.tabsByTrack||{},o=i.branchOrderByTrack||{},u=[],c={},p={},d={},f={};for(const v of e||[]){const E=v.track_id;if(!E)continue;const M=v.branch||Pd;c[E]||(u.push(E),c[E]=[],p[E]=[],d[E]={}),c[E].includes(v.pid)||c[E].push(v.pid),p[E].includes(M)||p[E].push(M),d[E][M]||(d[E][M]=[]),d[E][M].includes(v.pid)||d[E][M].push(v.pid),f[v.pid]=M}const h=(l||[]).filter(v=>v.id&&v.id!==v.repo).map(v=>v.id),m=new Set(h),b=new Set(u),x=a.filter(v=>b.has(v)||m.has(v)),w=new Set(x),C=[...x,...u.filter(v=>!w.has(v)),...h.filter(v=>!w.has(v)&&!b.has(v))],y={},g={},$={};for(const v of C){const E=c[v]||[],M=new Set(E),T=(s[v]||[]).filter(O=>M.has(O)),S=new Set(T);y[v]=[...T,...E.filter(O=>!S.has(O))];const R=p[v]||[],F=new Set(R),q=(o[v]||[]).filter(O=>F.has(O)),L=new Set(q),I=[...q,...R.filter(O=>!L.has(O))];if(I.length>=2){g[v]=I,$[v]={};for(const O of I)$[v][O]=[];for(const O of y[v]){const Q=f[O];$[v][Q]&&$[v][Q].push(O)}}else g[v]=[]}return{trackOrder:C,tabsByTrack:y,branchesByTrack:g,tabsByBranch:$}}function Ci(e,t,n=[]){for(const l of t||[])if(l.track_id===e&&l.track_name)return l.track_name;for(const l of n||[])if(l.id===e&&l.name)return l.name;if(e==="loose")return"loose";const i=String(e||"").split("/").filter(Boolean);return i[i.length-1]||e}function ib(e,t,n=[]){if(e==="loose")return"loose";for(const i of t||[])if(i.track_id===e&&i.track_kind)return i.track_kind;for(const i of n||[])if(i.id===e)return i.repo===i.id?"repo":"goal";return"repo"}function lb(e){return String(e||"").replace(/^\/(?:Users|home)\/[^/]+/,"~")}function ab(e){const t=e.worktree_affiliation||{};if(t.kind==="sibling")return t.label||null;if(t.kind==="no-repo"||t.kind==="off-repo"){if(e.repo_key&&e.repo_label)return e.branch?`${e.repo_label}/${e.branch}`:e.repo_label;if(e.cwd)return lb(e.cwd)}return null}function sb(e,t,n,i){const l={};for(const a of i||[])if(a.walkthrough){for(const s of e)if((t[s]||[]).map(u=>n[u]).find(u=>u&&u.repo_label===a.repo&&(u.branch||Pd)===a.branch)){l[s]||(l[s]={}),l[s][a.branch]||(l[s][a.branch]=[]),l[s][a.branch].push(a);break}}return l}const Ut=H(null),qe=H(null),Ze=H(null),Tt=H(""),Xr=H("default"),ei=H("default"),ti=H("default"),ni=H("default");function ob(e){return(e==null?void 0:e.mode)==="agent"&&(e.agent||"claude")==="claude"}const Ti=H(null);function Ad(e,t){const n=new Map;for(const i of t||[]){if(i.track_id!==e)continue;const l=i.branch;l&&(n.has(l)||n.set(l,i.cwd||""))}return[...n.entries()].map(([i,l])=>({branch:i,cwd:l}))}function cb(e,t,n,i){const l=[],a=new Set;for(const o of Ad(e,t))a.add(o.branch),l.push({...o,live:!0});if(!n||!i)return l;for(const o of i.worktrees||[])o.repo!==n||!o.branch||a.has(o.branch)||(a.add(o.branch),l.push({branch:o.branch,cwd:o.path,live:!1}));const s=(i.repos||[]).find(o=>o.repo===n);for(const o of(s==null?void 0:s.branches)||[])!o||a.has(o)||(a.add(o),l.push({branch:o,cwd:"",live:!1}));return l}function ub(e,t,n=5){const i=[],l=new Set,a=s=>{!s||l.has(s.branch)||(l.add(s.branch),i.push(s))};a(e.find(s=>s.branch===t));for(const s of e)s.live&&a(s);for(const s of e){if(i.length>=n)break;a(s)}return i}function db(e,t){const n=String(t||"").toLowerCase().split(/[\s/]+/).filter(Boolean);return n.length?e.filter(i=>{const l=i.branch.toLowerCase();return n.every(a=>l.includes(a))}):[]}function hb(e){const t=[{id:"claude",label:"Claude",mode:"agent",agent:"claude"},{id:"codex",label:"Codex",mode:"agent",agent:"codex"}],n=new Set(["claude","codex"]),i=(e||[]).filter(l=>!n.has((l.label||"").trim().toLowerCase())).map(l=>({id:`cmd:${l.label}`,label:l.label,mode:"shell",exec:l.exec||""}));return[...t,...i]}const fb=Vt(()=>cb(Ut.value,ce.value,Za(Ut.value),Ti.value));function Za(e){var t;return((t=(Bt.value||[]).find(n=>n.id===e))==null?void 0:t.repo)||null}function pb(e){var n,i;const t=Za(e);return t&&((i=(((n=Ti.value)==null?void 0:n.repos)||[]).find(l=>l.repo===t))==null?void 0:i.default_branch)||null}function Ao(e){var n,i,l;Ut.value=e;const t=Ad(e,ce.value);qe.value=t.length?t[0].branch:null,Ze.value=null,Tt.value="",Xr.value=((n=sn.value)==null?void 0:n.account)||"default",ti.value=((i=sn.value)==null?void 0:i.model)||"default",ni.value=((l=sn.value)==null?void 0:l.effort)||"default",ei.value=qg(),ye("overlay.open",{which:"launcher"}),Ti.value=null,ie("open catalog","/api/open/catalog").then(a=>{Ut.value===e&&(Ti.value=a)})}function Or(){Ut.value=null,qe.value=null,Ze.value=null,Tt.value=""}function Mo(e){qe.value=e,Ze.value=null}function mb(){qe.value=null,Ze.value=""}function gb(){ot(Or,Ut.value!=null),j(()=>(window.__periscopeOpenLauncher=Ao,()=>{window.__periscopeOpenLauncher===Ao&&delete window.__periscopeOpenLauncher}),[]);const e=Ut.value;if(e==null)return null;const t=Wr(),n=fb.value,i=Za(e),l=n.length>0||Ze.value!=null||!!i;async function a(f){const h=new URLSearchParams({session:e,agent:f.agent||"claude",mode:f.mode});f.mode==="shell"&&f.exec&&h.set("exec",f.exec),ob(f)&&h.set("account",Xr.value);const m=bl(f)?rb(ei.value):null;m&&h.set("profile",m),bl(f)&&h.set("model",ti.value),bl(f)&&h.set("effort",ni.value);const b=Ze.value;if(b!=null&&b.trim())h.set("branch",b.trim());else if(qe.value!=null){const x=n.find(w=>w.branch===qe.value);x!=null&&x.cwd?h.set("cwd",x.cwd):x&&h.set("branch",x.branch)}await ie("new window",`/api/window/new?${h.toString()}`,{method:"POST"}),Or()}const s=hb(t),o=s[0],u=Tt.value.trim(),c=u?db(n,u).slice(0,24):ub(n,pb(e)),p=qe.value!=null&&!c.some(f=>f.branch===qe.value)?n.find(f=>f.branch===qe.value):null,d=p?[p,...c]:c;return r("div",{id:"launcher-modal",class:"launcher-modal-overlay",onClick:f=>{f.target.id==="launcher-modal"&&Or()},children:r("div",{class:"launcher-modal-card",children:[r("header",{class:"launcher-modal-head",children:[r("h2",{children:"+ New tab"}),r("button",{id:"launcher-close",title:"close",onClick:Or,children:"×"})]}),r("p",{class:"launcher-modal-sub",id:"launcher-session-name",children:["Add to track: ",Ci(e,ce.value,Bt.value)]}),l&&r("div",{class:"launcher-section",children:[r("div",{class:"launcher-section-head",children:[r("div",{class:"launcher-section-label",children:"Branch"}),r("input",{class:"launcher-branch-search",type:"text",placeholder:n.length>1?`search ${n.length} branches…`:"search branches…",value:Tt.value,onInput:f=>{Tt.value=f.target.value},onKeyDown:f=>{if(f.key==="Escape"&&Tt.value)f.stopPropagation(),Tt.value="";else if(f.key==="Enter"){const h=d[0];h&&Mo(h.branch)}}})]}),r("div",{class:"launcher-branches",children:[d.map(f=>r("button",{class:`launcher-branch${qe.value===f.branch?" is-active":""}${f.live?"":" is-dormant"}`,title:f.live?"running now":f.cwd||"no worktree yet",onClick:()=>Mo(f.branch),children:["⎇ ",f.branch]},f.branch)),Ze.value==null?r("button",{class:"launcher-branch launcher-branch-new",onClick:mb,children:"+ new branch…"}):r("input",{class:"launcher-branch-input is-active",type:"text",placeholder:"new-branch-name",ref:f=>f==null?void 0:f.focus(),value:Ze.value,onInput:f=>{Ze.value=f.target.value},onKeyDown:f=>{f.key==="Enter"&&o&&a(o)}})]}),u&&d.length===0&&r("div",{class:"launcher-empty",children:["No branch matches “",u,"”."]})]}),$n()&&r("div",{class:"launcher-section",children:[r("div",{class:"launcher-section-label",children:"Account"}),r("div",{class:"launcher-branches",children:lt.value.map(f=>r("button",{class:`launcher-branch${Xr.value===f.id?" is-active":""}`,onClick:()=>{Xr.value=f.id},children:f.label},f.id))})]}),r("div",{class:"launcher-section",children:[r("div",{class:"launcher-section-label",children:"Profile"}),r("div",{class:"launcher-branches",children:Ed.map(f=>r("button",{class:`launcher-branch${ei.value===f.id?" is-active":""}`,title:f.id==="full"?"the pipeline: superpowers, tom-workflow, codebase-health-check, plus the pipeline direction prompt":"tom-core alone, on the plugin set settings.json enables",onClick:()=>{ei.value=f.id,Ug(f.id)},children:f.label},f.id))})]}),r("div",{class:"launcher-section",children:[r("div",{class:"launcher-section-label",children:"Model"}),r("div",{class:"launcher-branches",children:cr.map(f=>r("button",{class:`launcher-branch${ti.value===f.id?" is-active":""}`,title:f.id==="default"?"no override — whatever the account's settings.json picks (this launch only; the header pin is the standing default)":`spawn this launch on ${f.label} (ANTHROPIC_MODEL on the pane — a hand re-run claude there keeps it)`,onClick:()=>{ti.value=f.id},children:f.label},f.id))})]}),r("div",{class:"launcher-section",children:[r("div",{class:"launcher-section-label",children:"Effort"}),r("div",{class:"launcher-branches",children:Fa.map(f=>r("button",{class:`launcher-branch${ni.value===f?" is-active":""}`,title:f==="default"?"no override — Claude's own choice for the model; /effort works in the pane (this launch only; the header pin is the standing default)":`spawn this launch at ${f} (--effort on the pane's claude; /effort can still change it later)`,onClick:()=>{ni.value=f},children:f},f))})]}),r("div",{class:"launcher-section",children:[r("div",{class:"launcher-section-label",children:"Run"}),r("div",{id:"launcher-list",children:s.map((f,h)=>r("button",{class:`launcher-row${h===0?" is-default":""}`,"data-label":f.label,onClick:()=>a(f),children:[r("span",{class:"launcher-row-label",children:f.label}),h===0&&r("span",{class:"launcher-row-hint",children:"⏎"})]},f.id))})]})]})})}const yb=/github\.com\/([^/]+\/[^/]+)\/pull\/(\d+)/,bb=/^#?(\d+)$/;function kb(e){const t=e.match(yb);if(t)return{repo:t[1],pr:Number(t[2])};const n=e.trim().match(bb);return n?{repo:null,pr:Number(n[1])}:null}const wb=/^(~|\.{0,2}\/)/;function vb(e){const t=(e||"").trim();return!t||!wb.test(t)?null:t.replace(/\/+$/,"")||"/"}function Yt(e,t){return e.toLowerCase().includes(t.toLowerCase())}function _b(e,t){var s;const n=(e||"").trim(),i=[];if(!n)return i;"reviews".startsWith(n.toLowerCase())&&n.length>=2&&i.push({kind:"reviews",label:"Reviews · open branches and walkthroughs",sub:"the review queue",descriptor:null});const l=vb(n);l&&!(t.worktrees||[]).some(o=>o.path===l)&&i.push({kind:"open",label:`open path: ${l}`,sub:"register + open",descriptor:{path:l}});for(const o of t.repos||[])(Yt(o.label,n)||Yt(o.repo,n))&&i.push({kind:"worktree",label:`${o.label} · new worktree…`,sub:`off origin/${o.default_branch||"HEAD"}`,repo:o.repo,branches:o.branches,descriptor:null});for(const o of t.repos||[])(Yt(o.label,n)||Yt(o.repo,n))&&i.push({kind:"track",label:`${o.label} · new track…`,sub:"goal-scoped group",repo:o.repo,descriptor:null});for(const o of t.worktrees||[])if(Yt(o.path,n)||Yt(o.branch||"",n)){const u=((s=t.repos.find(c=>c.repo===o.repo))==null?void 0:s.label)||o.repo;i.push({kind:"open",label:`${u} · ${o.branch||"detached"}`,sub:o.path,descriptor:{path:o.path}})}const a=kb(n);return a&&i.push({kind:"pr",label:a.repo?`review PR #${a.pr} in ${a.repo}`:`review PR #${a.pr}`,sub:a.repo||"choose a repo",needsRepo:!a.repo,pr:a}),i.push({kind:"command",label:`⚡ run: ${n}`,text:n}),i}const ht=H(!1);function Lo(){ht.value=!0,ye("overlay.open",{which:"open"})}function St(){ht.value=!1}const Io={open:{group:"Open",icon:"▸"},worktree:{group:"New worktree",icon:"✦"},pr:{group:"Review PR",icon:"◆"},branch:{group:"Branches",icon:"⎇"},newbranch:{group:"Branches",icon:"+"},repo:{group:"Repositories",icon:"◳"},track:{group:"New track",icon:"▧"},command:{group:"Command",icon:"⚡"},reviews:{group:"Reviews",icon:"◉"}},xb=3e3;function Sb(e){const[t,n]=B([]);return j(()=>{if(!e)return;let i=!0,l=null;const a=async()=>{const s=await ie("jobs","/api/command/jobs");i&&(Array.isArray(s)&&n(s),l=setTimeout(a,xb))};return a(),()=>{i=!1,l&&clearTimeout(l)}},[e]),t}function $b(e){const[t,n]=B(null);return j(()=>{if(!e){n(null);return}let i=!0;return n(null),(async()=>{const l=await ie("job-turns",`/api/command/jobs/${encodeURIComponent(e)}/turns`);i&&n((l==null?void 0:l.messages)||[])})(),()=>{i=!1}},[e]),{messages:t,pending:t===null}}function Cb(e){if(e.role==="system")return"— context compacted —";const t=e.role==="user"?"❯":"⏺",n=e.tool_uses||[];if(n.length){const l=n[0],a=l.input||{},s=a.command||a.file_path||a.path||a.pattern||a.description||a.query||a.url||"",o=n.length>1?` +${n.length-1}`:"";return`${t} ${l.name||"tool"}${s?`(${s})`:""}${o}`}const i=String(e.text||"").split(`
-`).find(l=>l.trim())||"";return`${t} ${i}`}function Tb(){ot(St,ht.value);const[e,t]=B({repos:[],worktrees:[]}),[n,i]=B(""),[l,a]=B(null),[s,o]=B(!1),[u,c]=B(null),[p,d]=B(!1),[f,h]=B(""),[m,b]=B("claude");if(j(()=>{window.__periscopeOpenOmnibox=Lo;function $(v){(v.metaKey||v.ctrlKey)&&(v.key==="k"||v.key==="p")&&(v.preventDefault(),ht.value=!ht.value)}return document.addEventListener("keydown",$),()=>{document.removeEventListener("keydown",$),window.__periscopeOpenOmnibox===Lo&&delete window.__periscopeOpenOmnibox}},[]),j(()=>{ht.value&&(i(""),a(null),c(null),h(""),b("claude"),(async()=>{const $=await ie("open catalog","/api/open/catalog");$&&t($)})())},[ht.value]),!ht.value)return null;async function x($){if(p)return;d(!0),h("");const v=await ie("open","/api/open",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...$,agent:m})});if(d(!1),!v){h("open failed");return}Fg(v.ui),v.agent_pid&&(ke.value=`pane:${v.agent_pid}`,yt({kind:"pane",pid:v.agent_pid})),St()}async function w($,v){if(!v)return;d(!0),h("");const E=await ie("create track","/api/tracks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({repo:$||null,name:v})});if(d(!1),!E){h("create track failed");return}St()}async function C($){d(!0),h("");const v=await ie("command","/api/command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:$})});if(d(!1),!v){h("command failed");return}c(null),o(!0)}function y($){if($.kind==="reviews"){Ra(),St();return}if($.kind==="open")return x($.descriptor);if($.kind==="command")return C($.text);if($.kind==="pr"&&!$.needsRepo)return x({repo:$.pr.repo,pr:$.pr.pr});a({card:$})}const g=_b(n,e).map($=>({...$,group:Io[$.kind].group,icon:Io[$.kind].icon,key:$.label}));return r("div",{id:"open-omnibox",class:"open-omnibox-overlay",onClick:$=>{$.target.id==="open-omnibox"&&St()},children:r("div",{class:"open-omnibox-card",children:[!s&&r("div",{class:"launcher-branches",children:["claude","codex"].map($=>r("button",{class:`launcher-branch${m===$?" is-active":""}`,onClick:()=>b($),children:$==="claude"?"Claude":"Codex"},$))}),!l&&!s&&r(Xi,{value:n,onInput:i,placeholder:"repo, path, #PR…",items:g,onPick:y,onClose:St,empty:n?"no matches":e.roots&&!e.repos.length?`no repos found under ${e.roots.join(", ")} — add roots in ⚙ settings, or type a path`:"type a repo, path, or #PR…"}),s&&r(Eb,{selectedJob:u,onSelect:c,onBack:u?()=>c(null):()=>{o(!1),i("")},onClose:St}),l&&l.card.kind==="worktree"&&r(Ab,{card:l.card,onPick:$=>x({repo:l.card.repo,branch:$}),onBack:()=>a(null)}),l&&l.card.kind==="track"&&r(Mb,{card:l.card,onPick:$=>w(l.card.repo,$),onBack:()=>a(null)}),l&&l.card.kind==="pr"&&r(Lb,{repos:e.repos,onPick:$=>x({repo:$,pr:l.card.pr.pr}),onBack:()=>a(null)}),f&&r("div",{class:"open-omnibox-error",children:f}),p&&r("div",{class:"open-omnibox-busy",children:"opening…"})]})})}function Eb({selectedJob:e,onSelect:t,onBack:n}){const i=Sb(!e);return ot(n,!0),e?r(Pb,{jobId:e,onBack:n}):r("div",{class:"open-omnibox-jobs",children:[r("div",{class:"open-omnibox-jobs-head",children:"Commands"}),r("div",{class:"open-omnibox-list",children:[i.length===0&&r("div",{class:"open-omnibox-empty",children:"no commands yet"}),i.map(l=>r("button",{class:"open-omnibox-row",onClick:()=>t(l.id),children:[r("span",{class:`open-omnibox-jobdot${l.status==="running"?" is-running":""}`,children:l.status==="running"?"●":"✓"}),r("span",{class:"open-omnibox-label",children:l.text}),r("span",{class:"open-omnibox-sub",children:Pe(l.started_at)})]},l.id))]}),r("div",{class:"open-omnibox-footer",children:r("span",{children:[r("kbd",{children:"esc"})," back"]})})]})}function Pb({jobId:e,onBack:t}){const{messages:n,pending:i}=$b(e);return r("div",{class:"open-omnibox-console",children:[r("div",{class:"open-omnibox-console-cmd",children:r("button",{class:"open-omnibox-jobback",onClick:t,children:"← back"})}),r("div",{class:"open-omnibox-console-log",children:[i&&r("div",{class:"open-omnibox-console-spin",children:"no transcript yet — the commander is still starting…"}),!i&&n.length===0&&r("div",{class:"open-omnibox-console-spin",children:"no transcript yet"}),!i&&n.map((l,a)=>r("div",{class:"open-omnibox-console-line",children:Cb(l)},l.uuid||a))]})]})}function Xi({value:e,onInput:t,placeholder:n,items:i,onPick:l,onBack:a,empty:s}){const[o,u]=B(0),c=te(null),p=te(null),d=i.length,f=Math.min(o,Math.max(0,d-1));j(()=>{const b=requestAnimationFrame(()=>{var x;return(x=p.current)==null?void 0:x.focus()});return()=>cancelAnimationFrame(b)},[]),j(()=>{u(0)},[e]),j(()=>{var b,x;(x=(b=c.current)==null?void 0:b.querySelector(".is-active"))==null||x.scrollIntoView({block:"nearest"})},[f,d]);function h(b){b.key==="ArrowDown"?(b.preventDefault(),u(Math.min(f+1,d-1))):b.key==="ArrowUp"?(b.preventDefault(),u(Math.max(f-1,0))):b.key==="Enter"?(b.preventDefault(),i[f]&&l(i[f])):b.key==="Escape"&&a&&(b.preventDefault(),b.stopPropagation(),a())}let m=null;return r(K,{children:[r("input",{class:"open-omnibox-input",ref:p,placeholder:n,value:e,onInput:b=>t(b.target.value),onKeyDown:h}),r("div",{class:"open-omnibox-list",ref:c,children:[d===0&&r("div",{class:"open-omnibox-empty",children:s}),i.map((b,x)=>{const w=b.group&&b.group!==m?r("div",{class:"open-omnibox-group",children:b.group},`g:${b.group}`):null;return m=b.group,r(K,{children:[w,r("button",{class:`open-omnibox-row${x===f?" is-active":""}`,onMouseMove:()=>u(x),onClick:()=>l(b),children:[b.icon&&r("span",{class:"open-omnibox-icon",children:b.icon}),r("span",{class:"open-omnibox-label",children:b.label}),b.sub&&r("span",{class:"open-omnibox-sub",children:b.sub})]},b.key||x)]})})]}),r("div",{class:"open-omnibox-footer",children:[r("span",{children:[r("kbd",{children:"↑"}),r("kbd",{children:"↓"})," navigate"]}),r("span",{children:[r("kbd",{children:"↵"})," ",a?"select":"open"]}),r("span",{children:[r("kbd",{children:"esc"})," ",a?"back":"close"]})]})]})}function Ab({card:e,onPick:t,onBack:n}){const[i,l]=B(""),a=(e.branches||[]).filter(o=>o.toLowerCase().includes(i.toLowerCase())),s=a.map(o=>({key:o,group:"Branches",icon:"⎇",label:o,value:o}));return i&&!a.includes(i)&&s.push({key:`__new:${i}`,group:"Branches",icon:"+",label:`new branch "${i}"`,value:i}),r(Xi,{value:i,onInput:l,placeholder:`branch in ${e.repo}…`,items:s,onPick:o=>t(o.value),onBack:n,empty:"type a new branch name…"})}function Mb({card:e,onPick:t,onBack:n}){const[i,l]=B(""),a=i.trim(),s=a?[{key:`__tk:${a}`,group:"New track",icon:"▧",label:`create track "${a}"`,sub:e.repo,value:a}]:[];return r(Xi,{value:i,onInput:l,placeholder:`name this track (repo: ${e.repo})…`,items:s,onPick:o=>t(o.value),onBack:n,empty:"type a track name…"})}function Lb({repos:e,onPick:t,onBack:n}){const[i,l]=B(""),s=(e||[]).filter(o=>o.label.toLowerCase().includes(i.toLowerCase())||o.repo.toLowerCase().includes(i.toLowerCase())).map(o=>({key:o.repo,group:"Repositories",icon:"◳",label:o.label,sub:o.repo,value:o.repo}));return r(Xi,{value:i,onInput:l,placeholder:"repo for this PR…",items:s,onPick:o=>t(o.value),onBack:n,empty:"no matching repo"})}function Oo({which:e,label:t,fonts:n}){return r("label",{children:[t,r("select",{name:`font-${e}`,value:or(e).id,onChange:i=>Kg(e,i.currentTarget.value),children:n.map(i=>r("option",{value:i.id,children:i.name},i.id))})]})}function Ib(){return r("fieldset",{class:"font-picker",children:[r("legend",{children:"Fonts"}),r(Oo,{which:"ui",label:"Interface",fonts:mi}),r(Oo,{which:"code",label:"Code & terminal",fonts:mi.filter(e=>e.mono)})]})}const Ob=[["needs_input","A session needs input"],["done","A session finishes"],["ci_failed","CI fails on a session's PR"],["pr_merged","A linked PR merges"],["usage","Usage projected past a limit"],["quiet_when_focused","Stay quiet while the dashboard is focused"],["group","Group when more than 2 arrive at once"],["badge","Dock badge counts sessions waiting on you"]];function Db(){const e=yi();return r("fieldset",{class:"notify-settings",children:[r("legend",{children:"Notifications"}),!Ke()&&r("p",{class:"settings-overrides-hint",children:"Notifications appear in the Periscope macOS app only."}),Ob.map(([t,n])=>r("label",{class:"notify-option",children:[r("input",{type:"checkbox",name:`notify-${t}`,checked:e[t],onChange:i=>Gg(t,i.currentTarget.checked)}),n]},t))]})}function Rb({critter:e}){return r("svg",{class:"critter-preview",viewBox:e.sprite?"0 0 20 20":"-1.5 1 20 20",width:"40",height:"40","shape-rendering":"crispEdges","aria-hidden":"true",children:e.sprite?r(Gi,{sprite:e.sprite}):r(e2,{})})}function Fb(){const e=gu();return r("fieldset",{class:"tama-picker",children:[r("legend",{children:"Tamagotchi"}),r("div",{class:"tama-picker-options",children:pi.map(t=>r("label",{class:"tama-picker-option",children:[r("input",{type:"radio",name:"tama-critter",value:t.id,checked:t.id===e,onChange:()=>Wg(t.id)}),r(Rb,{critter:t}),r("span",{children:t.name})]},t.id))})]})}const ln=H(!1);function Do(){ln.value=!0,ye("overlay.open",{which:"settings"})}function Rn(){ln.value=!1}function Nb(){ot(Rn,ln.value);const[e,t]=B(""),[n,i]=B(!1),[l,a]=B(14),[s,o]=B("sibling"),[u,c]=B([]),[p,d]=B(""),[f,h]=B([]),[m,b]=B("");j(()=>{const w=document.getElementById("settings-btn");return w&&w.addEventListener("click",Do),()=>{w&&w.removeEventListener("click",Do)}},[]),j(()=>{ln.value&&(t(""),(async()=>{const{data:w,error:C}=await gr("load settings","/api/settings");if(C){t(C);return}const y=w.settings||{};a(y.cleanup_idle_days??14),o(y.worktree_layout_default??"sibling"),c(Object.entries(y.worktree_layout_overrides||{}).map(([g,$])=>({repo:g,layout:$}))),h(w.editors_available||[]),d(y.editor??""),b((y.repo_roots??["~/dev"]).join(`
-`))})())},[ln.value]);async function x(w){w.preventDefault(),t("");const C=parseInt(l,10);if(!C||C<1){t("cleanup idle days must be a positive integer");return}const y={};for(const{repo:v,layout:E}of u)v&&E&&(y[v]=E);const g={cleanup_idle_days:C,worktree_layout_default:s,worktree_layout_overrides:y,editor:p||null,repo_roots:m.split(`
-`).map(v=>v.trim()).filter(Boolean)};i(!0);const{error:$}=await gr("save settings","/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)});if(i(!1),$){t($);return}Rn()}return ln.value?r("div",{id:"settings-modal",class:"settings-modal-overlay",onClick:w=>{w.target.id==="settings-modal"&&Rn()},children:r("div",{class:"settings-modal-card",children:[r("header",{class:"settings-modal-head",children:[r("h2",{children:"🛠 settings"}),r("button",{id:"settings-modal-close",title:"close",onClick:Rn,children:"×"})]}),r("form",{id:"settings-form",onSubmit:x,children:[r(Ib,{}),r(Fb,{}),r(Db,{}),r("label",{children:["Cleanup idle threshold (days)",r("input",{id:"settings-cleanup-idle-days",type:"number",min:"1",value:l,onInput:w=>a(w.currentTarget.value)})]}),r("label",{children:["Preferred editor",r("select",{id:"settings-editor",value:p,onChange:w=>d(w.currentTarget.value),children:[r("option",{value:"",children:"(none — hides the rail's ↗ action)"}),f.map(w=>r("option",{value:w,children:w},w))]})]}),r("label",{children:["Repo roots",r("textarea",{id:"settings-repo-roots",rows:3,spellcheck:!1,value:m,onInput:w=>b(w.currentTarget.value)})]}),r("p",{class:"settings-overrides-hint",children:"One directory per line. Repos one level under each are offered in ⌘K; a repo elsewhere can be opened once by typing its path there."}),r("label",{children:["Default worktree layout",r("select",{id:"settings-worktree-default",value:s,onChange:w=>o(w.currentTarget.value),children:[r("option",{value:"sibling",children:"sibling — ~/dev/worktrees//"}),r("option",{value:"inline",children:"inline — /.worktrees/"})]})]}),r("fieldset",{children:[r("legend",{children:"Per-repo overrides"}),r("div",{id:"settings-overrides-list",children:u.length===0?r("div",{class:"settings-overrides-empty",children:"(none yet)"}):u.map((w,C)=>r("div",{class:"settings-overrides-row","data-repo":w.repo,children:[r("span",{class:"settings-overrides-repo",children:w.repo}),r("select",{class:"settings-overrides-layout",value:w.layout,onChange:y=>{const g=y.currentTarget.value;c($=>$.map((v,E)=>E===C?{...v,layout:g}:v))},children:[r("option",{value:"sibling",children:"sibling"}),r("option",{value:"inline",children:"inline"})]}),r("button",{type:"button",class:"settings-overrides-remove",title:"remove override",onClick:()=>c(y=>y.filter((g,$)=>$!==C)),children:"×"})]},w.repo))}),r("p",{class:"settings-overrides-hint",children:["Auto-detected on first ",r("code",{children:"+ project"})," per repo. Edit or remove rows here."]})]}),r("div",{id:"settings-modal-error",class:"settings-modal-error",hidden:!e,children:e}),r("div",{class:"settings-modal-actions",children:[r("button",{type:"button",id:"settings-cancel",onClick:Rn,children:"cancel"}),r("button",{type:"submit",id:"settings-submit",disabled:n,children:"save"})]})]})]})}):null}function Bb(){return j(()=>{i1(),"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js",{scope:"/"}).catch(()=>{})},[]),r(K,{children:[r(nb,{}),r(eb,{}),r(Nb,{}),r(gb,{}),r(Tb,{})]})}const Ro=120,zb=3600,ea=e=>`${e.repo_slug||e.repo_key||""}#${e.pr}`;function Fo(e){let t=0;for(const n of e.message||"")t=t*31+n.codePointAt(0)|0;return`question:${e.pane_id||e.target}@${e.ts}:${(t>>>0).toString(36)}`}const Dr={calm:0,grumpy:1,furious:2};function jb(e,t,n){const{windows:i=[],alerts:l=[],dismissedAlertIds:a=new Set,dismissedNeedsPids:s=new Set,dismissedReadyPids:o=new Set,plan:u={}}=t,c=!e,p=(e==null?void 0:e.pass)??0,d=p+1,f=(e==null?void 0:e.seen)||{},h=new Set;for(const[T,S]of Object.entries(f))typeof S=="number"&&S<=p&&p-S<=Ro&&h.add(T);const m={},b=[],x=(T,S)=>{m[T]=d,!c&&!h.has(T)&&b.push({key:T,...S})},w=T=>{m[T]=d},C=La(i,l,a,s),y=new Set;for(const T of C)T.kind==="live"&&(y.add(T.w.pid),x(`needs:${T.w.pid}@${T.w.needs_since||0}`,{kind:"needs_input",w:T.w}));for(const T of i)T.state==="needs-input"&&s.has(T.pid)&&w(`needs:${T.pid}@${T.needs_since||0}`);for(const T of C){if(T.kind!=="event")continue;const S=Fo(T);T.w&&y.has(T.w.pid)?(c||h.has(S))&&w(S):x(S,{kind:"question",w:T.w,alert:T})}for(const T of l)T.kind==="need_human"&&a.has(T.id)&&w(Fo(T));for(const T of i){if(T.state!=="done")continue;const S=`done:${T.pid}@${T.completed_at||0}`;o.has(T.pid)?w(S):x(S,{kind:"done",w:T})}const g={};for(const[T,S]of Object.entries((e==null?void 0:e.prAt)||{}))d-S<=zb&&(g[T]=S);const $={},v={};for(const T of Object.keys(g))T in((e==null?void 0:e.ci)||{})&&($[T]=e.ci[T]),T in((e==null?void 0:e.prs)||{})&&(v[T]=e.prs[T]);const E=new Map;for(const T of i){if(!T.pr||T.pr_linked&&!T.pr_state)continue;const S=ea(T);(!E.has(S)||T.pr_state&&!E.get(S).pr_state)&&E.set(S,T)}for(const[T,S]of E){g[T]=d;const F=(!S.pr_state||S.pr_state==="open")&&S.ci||null;!c&&T in $&&$[T]!=="✗"&&F==="✗"&&b.push({key:`ci:${T}`,kind:"ci_failed",w:S}),$[T]=F,S.pr_state&&(!c&&v[T]==="open"&&S.pr_state==="merged"&&b.push({key:`merged:${T}`,kind:"pr_merged",w:S}),v[T]=S.pr_state)}const M={};for(const[T,S]of Object.entries((e==null?void 0:e.meters)||{}))Number(T.slice(T.lastIndexOf("/")+1))*60>n&&(M[T]=S);for(const[T,S]of Object.entries(u||{})){if(!(S!=null&&S.available)||!S.meters||!c&&Ha(S,n))continue;let R=null;for(const[F,q]of Object.entries(S.meters)){if(!(q!=null&&q.resets_at))continue;const L=Ku(q),I=`${T}/${F}/${Math.round(q.resets_at/60)}`,O=M[I]??0;M[I]=Math.max(O,Dr[L]),!c&&Dr[L]>O&&(!R||Dr[L]>Dr[R.mood])&&(R={key:`usage:${I}:${L}`,kind:"usage",account:T,meter:F,m:q,mood:L})}R&&b.push(R)}for(const T of h)!(T in m)&&d-f[T]<=Ro&&(m[T]=f[T]);return{state:{pass:d,seen:m,ci:$,prs:v,prAt:g,meters:M},events:b}}const Zn=(e,t)=>{const n=String(e||"").trim(),i=Array.from(n);return i.length>t?`${i.slice(0,t-1).join("")}…`:n},kl=e=>Zn(_e(e),26),Fn=e=>[e==null?void 0:e.session,e==null?void 0:e.branch].filter(Boolean).join(" · "),wl=e=>!!(e!=null&&e.pid&&e.agent==="claude"),No=e=>{const t=/^mcp__(.+?)__(.+)$/.exec(e||"");return t?`${t[2]} (${t[1]})`:e||"this"};function Hb(e){const t=String(e||"").replace(/\s+/g," ").trim(),n=t.match(/^.*?[.!?](?=\s[A-Z0-9]|$)/);return Zn(n?n[0]:t,140)}const Bo={permission:"Waiting for your approval.",question:"Waiting for your answer.",dialog:"Waiting for your input."},qb={failure:"✗",pending:"⟳",success:"✓"},Md=e=>`usage_to_${e}`;function Ld(e,t={}){var l,a;const n=e.w,i={kind:e.kind,thread:e.kind,target:(n==null?void 0:n.target)||"",data:{}};switch(e.kind){case"needs_input":{const s=n.pending_permission;return s!=null&&s.request_id&&n.pid?{...i,title:`${kl(n)} needs you`,subtitle:Fn(n),body:s.summary?`Allow ${No(s.tool)}: ${s.summary}?`:`Allow ${No(s.tool)}?`,category:"needs_permission",data:{open:"pane",pid:n.pid,request_id:s.request_id}}:{...i,title:`${kl(n)} needs you`,subtitle:Fn(n),body:Bo[du(n.waiting_for)]||Bo.dialog,category:"needs_dialog",data:{open:"pane",pid:n.pid}}}case"question":{const s=e.alert;return{...i,title:`${Zn(n?_e(n):s.name||s.session||"A session",26)} asks`,subtitle:n?Fn(n):s.session||"",body:Zn(s.message,180),target:s.target||i.target,...wl(n)?{category:"question"}:{},data:{open:"pane",pid:(n==null?void 0:n.pid)??null}}}case"done":return{...i,title:`${kl(n)} is done`,subtitle:n.pr&&n.pr_linked?`${n.session} · PR #${n.pr}`:Fn(n),body:Hb(n.last_reply||n.recap||n.last_line)||"Finished.",category:"done_seen",data:{open:"pane",pid:n.pid,session:n.session}};case"ci_failed":{const s=(n.ci_checks||[]).map(p=>`${qb[p.state]||"·"} ${p.name}`).join(" · "),o=lr(n.repo_slug,n.pr),u=wl(n)?n:(t.windows||[]).find(p=>wl(p)&&ea(p)===ea(n));let c;return u!=null&&u.pid&&o?c="ci_failed":u!=null&&u.pid?c="ci_failed_fix":o&&(c="ci_failed_pr"),{...i,title:`CI failed on #${n.pr}`,subtitle:[n.session,_e(n)].filter(Boolean).join(" · "),body:s||"Checks are failing.",...c?{category:c}:{},data:{open:"url",url:o,pid:(u==null?void 0:u.pid)||n.pid,pr:n.pr,checks:(n.ci_checks||[]).filter(p=>p.state==="failure").map(p=>p.name)}}}case"pr_merged":{const s=lr(n.repo_slug,n.pr);let o;return n.cwd&&s?o="pr_merged":n.cwd?o="pr_merged_cleanup":s&&(o="pr_merged_pr"),{...i,title:`PR #${n.pr} merged`,subtitle:n.pr_base?`${n.session} · ${n.branch} → ${n.pr_base}`:Fn(n),body:"The worktree and its session can be cleaned up.",...o?{category:o}:{},data:{open:"url",url:s,pid:n.pid,cwd:n.cwd}}}case"usage":{const s=t.accounts||[],o=Zn(((l=s.find(h=>h.id===e.account))==null?void 0:l.label)||e.account,16),u=s.length>1,c=Math.max(...[e.m.projected_percent,e.m.projected_recent].filter(h=>h!=null),-1),p=(t.windows||[]).filter(h=>h.state==="working"&&h.account===e.account).length,d=(a=t.moveTargets)==null?void 0:a[e.account],f=d&&d!==e.account;return{...i,target:"",title:u?`Account ${o} is running hot`:"Usage is running hot",subtitle:`${Ua(e.meter)} usage ${Math.round(e.m.percent??0)}%`+(c>=0?` · →${Math.round(c)}% at reset`:""),body:u?`${wn(p,"session")} working on ${o}.`:`${wn(p,"session")} working.`,category:f?Md(d):"usage",data:f?{open:"usage",spawn_to:d}:{open:"usage"}}}default:return null}}const rt=(e,t,n={})=>Object.freeze({id:e,title:t,...n}),zo=rt("open_pr","Open PR"),Ub=rt("mark_seen","Mark seen"),jo=rt("cleanup","Clean up worktree",{foreground:!0}),Wb=rt("details","Details",{foreground:!0}),Kb=rt("open","Open",{foreground:!0}),Ho=rt("fix","Ask agent to fix",{auth:!0});function Vb({accounts:e=[],moveTargets:t={}}={}){const n=[{id:"done_seen",actions:[Ub]},{id:"ci_failed_pr",actions:[zo]},{id:"pr_merged",actions:[jo]},{id:"pr_merged_cleanup",actions:[jo]},{id:"pr_merged_pr",actions:[zo]},{id:"usage",actions:[Wb]},{id:"needs_permission",actions:[rt("allow","Allow",{auth:!0})]},{id:"needs_dialog",actions:[Kb]},{id:"question",actions:[rt("send","Reply",{auth:!0,reply:{button:"Send",placeholder:"Reply…"}})]},{id:"ci_failed",actions:[Ho]},{id:"ci_failed_fix",actions:[Ho]}];for(const i of[...new Set(Object.values(t||{}))].sort())n.push({id:Md(i),actions:[rt("spawn_on",`Spawn on ${yn(i,e||[])}`)]});return n}const Gb=Object.freeze({openExternal:Ki,openUsageDetails:Cd,pickSpawnAccount:Mu,openCleanupModal:Td,markReadySeen:Cu,selectPane:at,revealPane:jt,post:Lg,toast:kn,notify:ku}),Jb={allow:"Allow",deny:"Deny",send:"Reply",fix:"Ask agent to fix"},Qb={allow:"Couldn't allow",deny:"Couldn't deny",send:"Couldn't send your reply",fix:"Couldn't ask the agent to fix"},Yb=new Set(["allow","deny"]),Zb={"/api/pane/permission":"The dialog changed — open the pane to answer it.","/api/pane/reply":"The pane has a dialog open, or isn't running an agent — open it to see why."};function Xb(e,t){return(t==null?void 0:t.status)===404?"The pane is gone.":(t==null?void 0:t.status)===0?"Periscope isn't answering.":(t==null?void 0:t.status)===409?typeof t.detail=="string"&&t.detail!==`HTTP ${t.status}`?t.detail:Zb[e]:(t==null?void 0:t.detail)||"No answer"}const ek=e=>{const t=e.codePointAt(0);return t!==9&&t!==10&&(t<32||t>=127&&t<=159)},tk=e=>[...String(e)].filter(t=>!ek(t)).join("").trim();function nk(e,t){const n=(t||[]).map(tk).filter(Boolean),i=n.length?`${n.join(" · ")}.`:"Checks are failing.";return`CI failed on #${e}: ${i} Please investigate and fix.`}async function vl({target:e,show:t},n,i,l,a){let s=!1;const o=u=>{s||(s=!0,Promise.resolve().then(()=>a.notify({kind:"notice",thread:"notice",title:Qb[n],body:u,target:e,data:{open:"pane",pid:l.pid},quiet_when_focused:!0})).catch(c=>console.error("[notify] follow-up failed",c)))};try{if(!l.pid||Yb.has(n)&&!l.request_id){o("Open the pane to answer it."),t();return}const u=await a.post(i,l);if(u!=null&&u.ok)return;const c=Xb(i,u);o(c),t(),(u==null?void 0:u.status)!==409&&a.toast(`${Jb[n]} failed: ${(u==null?void 0:u.detail)||"no answer"}`,"bad",6e3)}catch(u){console.error("[notify] action failed",n,u),o((u==null?void 0:u.message)||"Periscope isn't answering.");try{t()}catch(c){console.error("[notify] reveal failed",c)}}}function rk({target:e,action:t,text:n,data:i}={},l=Gb){i||(i={});let a;const s=()=>a?l.selectPane(a):e&&l.revealPane(e);try{switch(a=i.pid?(ce.peek()||[]).find(o=>String(o.pid)===String(i.pid)):null,t){case"open_pr":i.url?l.openExternal(i.url):s();return;case"details":l.openUsageDetails();return;case"spawn_on":i.spawn_to&&l.pickSpawnAccount(i.spawn_to);return;case"mark_seen":a&&l.markReadySeen(a);return;case"cleanup":{const o=i.cwd||(a==null?void 0:a.cwd);o?l.openCleanupModal({paths:[o]}):s();return}case"allow":case"deny":return vl({target:e,show:s},t,"/api/pane/permission",{pid:i.pid,request_id:i.request_id,choice:t},l);case"send":{const o=String(n||"").trim();return o?vl({target:e,show:s},t,"/api/pane/reply",{pid:i.pid,text:o},l):void 0}case"fix":return vl({target:e,show:s},t,"/api/pane/reply",{pid:i.pid,text:nk(i.pr,i.checks)},l);case"open":s();return;default:console.warn("[notify] unknown action",t)}}catch(o){console.error("[notify] action failed",t,o);try{s()}catch(u){console.error("[notify] reveal failed",u)}}}const ta=3e3,ik=2,lk=new Set(["needs_input","question"]);function ak(e,t,n,i=!0){const l=t.filter(o=>n-o{var t;return e.kind==="question"?"question":du((t=e.w)==null?void 0:t.waiting_for)==="permission"?"permission":"input"};function ok(e){var n,i;const t=new Set(e.map((l,a)=>{var s,o;return((s=l.w)==null?void 0:s.pid)??((o=l.alert)==null?void 0:o.pane_id)??a})).size;return{kind:"summary",thread:"needs_you",target:"",data:{open:"pane",pid:((i=(n=e[0])==null?void 0:n.w)==null?void 0:i.pid)??null},title:t===1?"1 more session needs you":`${t} more sessions need you`,subtitle:"",body:e.map(l=>{var a;return`● ${l.w?_e(l.w):((a=l.alert)==null?void 0:a.name)||"a session"} · ${sk(l)}`}).join(`
-`)}}function Id(e,t,n){if(e.length===1)try{const i=t(e[0],n);if(i)return i}catch(i){console.error("[notify] banner failed",e[0].key,i)}return ok(e)}const Od="periscope.notify.v1",ck=15*60*1e3;function uk(e,t){try{const n=JSON.parse((e==null?void 0:e.getItem(Od))||"null");if(!(n!=null&&n.state)||!(n.at<=t)||t-n.at>ck)return null;const i=Array.isArray(n.held)?n.held:[];return{state:n.state,held:i,heldSince:i.length?n.heldSince??n.at:null}}catch{return null}}function dk(e,t,n,i=[],l=null){try{e==null||e.setItem(Od,JSON.stringify({at:n,state:t,held:i,heldSince:l}))}catch{}}const hk={question:"needs_input"},fk=(e,t)=>e[hk[t]||t]!==!1;function pk({target:e,data:t}={}){if(t||(t={}),t.open==="url"&&t.url){Ki(t.url);return}if(t.open==="usage"){Cd();return}const n=t.pid!=null&&(ce.value||[]).find(i=>String(i.pid)===String(t.pid));n?at(n):jt(e)}const mk={sends:[],flush:[],badge:null};function gk(e,t,n,i,l=Ld){let{state:a,recent:s,held:o,heldSince:u,lastBadge:c,lastCategories:p}=e;const d={quiet_when_focused:n.quiet_when_focused},f=[],h={accounts:t.accounts,windows:t.windows,moveTargets:t.moveTargets};o.length&&i-u>=ta&&(f.push({...Id(o,l,h),...d}),o=[],u=null);let m=null;const b=g=>({state:a,recent:s,held:o,heldSince:u,lastBadge:c,lastCategories:p,...mk,flush:f,categories:m,timerAt:o.length?u+ta:null,...g});if(t.alerts===null)return b();try{const g=Vb({accounts:t.accounts,moveTargets:t.moveTargets}),$=JSON.stringify(g);$!==p&&(m=g,p=$)}catch(g){console.error("[notify] category set failed",g)}const x=xu(t.windows,t.alerts,t.dismissedAlertIds,t.dismissedNeedsPids,i/1e3),w=n.badge?x.size:0,C=w===c?null:w;if(c=w,!a&&(!t.windows.length||e.editing))return b({badge:C});const y=[];if(!e.editing){const g=jb(a,t,i/1e3);a=g.state;const $=ak(g.events.filter(v=>fk(n,v.kind)),s,i,n.group);s=$.recent;for(const v of $.now){let E=null;try{E=l(v,h)}catch(M){console.error("[notify] banner failed",v.key,M)}E&&y.push({...E,...d})}$.held.length&&(o=[...o,...$.held],u??(u=i))}return b({sends:y,badge:C})}const yk=2e3;function bk(e={setNotifyCategories:r1,notify:ku}){let t=Promise.resolve();return(n,i)=>{n&&(t=t.then(()=>Promise.race([e.setNotifyCategories(n),new Promise(l=>setTimeout(l,yk))])).catch(l=>console.error("[notify] registration failed",l))),i.length&&(t=t.then(()=>{for(const l of i)try{e.notify(l)}catch(a){console.error("[notify] post failed",a)}}))}}let qo=!1;function kk(){if(qo||!Ke())return;qo=!0;const e=typeof localStorage>"u"?null:localStorage,t=uk(e,Date.now());let n={state:null,held:[],heldSince:null,...t,recent:[],lastBadge:void 0,lastCategories:void 0};const i=u=>dk(e,n.state,u,n.held,n.heldSince),l=bk();let a=null,s=null;const o=()=>{a=null,s=null;const u=n.held;if(n={...n,held:[],heldSince:null},!u.length)return;n.state&&i(Date.now());const c={accounts:lt.peek(),windows:ce.peek()||[],moveTargets:ui.peek()};l(null,[{...Id(u,Ld,c),quiet_when_focused:yi().quiet_when_focused}])};t1(pk),n1(u=>rk(u)),it(()=>{Pc.value,Li(()=>{var u;try{const c={windows:ce.peek()||[],alerts:nr.peek(),dismissedAlertIds:ir.peek(),dismissedNeedsPids:ft.peek(),dismissedReadyPids:pt.peek(),plan:((u=Ri.peek())==null?void 0:u.plan)||{},accounts:lt.peek(),moveTargets:ui.peek()},p=!!(ya.peek()||Et.peek()),d=Date.now(),f=n,{sends:h,flush:m,badge:b,categories:x,timerAt:w,...C}=gk({...n,editing:p},c,yi(),d);n=C,n.state&&(n.state!==f.state||n.held!==f.held)&&i(d),l(x,[...m,...h]),w==null?(a&&clearTimeout(a),a=null,s=null):w!==s&&(a&&clearTimeout(a),s=w,a=setTimeout(o,Math.max(0,w-d))),b!==null&&Xg(b)}catch(c){console.error("[notify] pass failed",c)}})})}const wk=3e3,vk=2e3;let Ei=0;function Dd(){return document.getElementById("connection-banner")}function Rd(e){try{if(nr.value=e.alerts||[],ya.value||Et.value)return;ce.value=e.windows||[],Oi.value=e.projects||[],Di.value=e.workspaces||[],Bt.value=e.tracks||[],$h(ce.value),Ri.value={plan:e.usage_plan,fallback:e.usage,poke:e.poke||{}},ma.value=e.update||null,Cc.value=e.resources||null,lt.value=e.accounts||[],ui.value=e.move_targets||{},Kn.value=e.spawn_account||null,Vn.value=e.spawn_model||null,Gn.value=e.spawn_effort||null,sn.value=e.launch_default||null,Tc.value=e.walls||null,ga.value=e.wall_spans||[],Ec.value=e.editor||""}finally{Pc.value+=1}}function Fd(){if(Ei>0){Ei=0;const e=Dd();e&&(e.hidden=!0),document.body.classList.remove("disconnected")}}function Nd(e){if(Ei+=1,Ei>=2){const t=Dd();t&&(t.hidden=!1),document.body.classList.add("disconnected")}e&&console.warn("[periscope]",e)}async function _k(){if(!ya.value&&!Et.value)try{const e=await fetch("/api/state");if(!e.ok)throw new Error(`HTTP ${e.status}`);Rd(await e.json()),Fd()}catch(e){Nd(`poll failed: ${e.message}`)}}let _l=!1,na=!1,Xn=null,Ot=null,pn=null;function xk(){if(Ot)return;const e=async()=>{await _k(),Ot!==null&&(Ot=setTimeout(e,wk))};Ot=setTimeout(e,0)}function Bd(){Ot&&(clearTimeout(Ot),Ot=null)}const Sk=1e4;let Dt=null,Uo=0;async function el(){const e=++Uo;try{const t=await fetch("/api/reviews");if(!t.ok)return;const n=await t.json();e===Uo&&(gt.value=n.rows||[])}catch{}}function $k(){if(Dt)return;const e=async()=>{await el(),Dt!==null&&(Dt=setTimeout(e,Sk))};Dt=setTimeout(e,0)}function Ck(){Dt&&(clearTimeout(Dt),Dt=null)}function zd(){const e=location.protocol==="https:"?"wss:":"ws:",t=new WebSocket(`${e}//${location.host}/ws/state`);Xn=t,t.onmessage=n=>{Bd();try{Rd(JSON.parse(n.data)),Fd()}catch(i){Nd(`bad frame: ${i.message}`)}},t.onclose=()=>{na||(Xn=null,xk(),pn||(pn=setTimeout(()=>{pn=null,zd()},vk)))},t.onerror=()=>{try{t.close()}catch{}}}function Tk(){return _l?()=>{}:(_l=!0,na=!1,zd(),$k(),()=>{if(na=!0,Ck(),_l=!1,Xn){try{Xn.close()}catch{}Xn=null}Bd(),pn&&(clearTimeout(pn),pn=null)})}const Ek=/[A-Za-z0-9_]+|\s+|[^A-Za-z0-9_\s]/g;function Wo(e){return String(e??"").match(Ek)||[]}function Pk(e,t){let n=0;for(;n{const b=[],x=(w,C)=>{if(!w)return;const y=b[b.length-1];y&&y.changed===C?y.text+=w:b.push({text:w,changed:C})};return x(f.slice(0,h).join(""),!1),x(f.slice(h,m).join(""),!0),x(f.slice(m).join(""),!1),b},p=c(i,a,i.length-s),d=c(l,a,l.length-s);return!p.some(f=>f.changed)&&!d.some(f=>f.changed)?null:{del:p,add:d}}function Lk(e,t=.5){const n=e.map(l=>({...l}));let i=0;for(;i0&&s===o)for(let u=0;ui?a:i+1}return n}const Ik=["dist/","build/","vendor/",".next/","target/debug/","target/release/"],Ok=new Set(["package-lock.json","yarn.lock","pnpm-lock.yaml","uv.lock","poetry.lock","Cargo.lock","Gemfile.lock","composer.lock","go.sum"]),Dk=[".min.js",".min.css",".map",".snap"];function jd(e){const t=String(e||"");if(!t)return!1;const n=t.split("/").pop()||"";if(Ok.has(n)||Dk.some(l=>n.endsWith(l)))return!0;const i=`${t}/`;return Ik.some(l=>i.includes(`/${l}`)||i.startsWith(l))}function Rk(e){const t=[],n=[];for(const i of e||[])(jd(i.path)?n:t).push(i);return t.concat(n)}const ra=H({}),Fk="\0";function Hd(e,t){return`${e}${Fk}${t}`}function qd(e,t,n,i,l=!1){const a=e[Hd(t,n)];if(!a)return{collapsed:l,viewed:!1};const s=!!a.viewedSig&&a.viewedSig===i;return{collapsed:a.collapsed===void 0?l:a.collapsed,viewed:s}}function Ud(e,t,n){const i=Hd(e,t),l={...ra.value},a={...l[i]||{},...n};a.collapsed===void 0&&!a.viewedSig?delete l[i]:l[i]=a,ra.value=l}function Nk(e,t,n){Ud(e,t,{collapsed:n})}function Bk(e,t,n,i){Ud(e,t,{viewedSig:i?n:void 0,collapsed:!!i})}function zk(e,t,n){return n.reduce((i,l)=>i+(qd(e,t,l.path,l.sig).viewed?1:0),0)}const jk=[["session","This session","Changes since the current Claude session started"],["branch","This branch","Changes vs where this branch forked"]],Hk={js:"js",mjs:"js",cjs:"js",jsx:"jsx",ts:"ts",tsx:"tsx",py:"py",rs:"rs",json:"json",css:"css",html:"html",htm:"html",md:"md",markdown:"md"};function Wd(e){const t=(e||"").split("/").pop()||"",n=t.lastIndexOf(".");return n>0&&Hk[t.slice(n+1).toLowerCase()]||""}function Ko({text:e,lang:t,hl:n}){if(!n||!t)return e||" ";try{return n(e,t)}catch{return e||" "}}function qk({line:e,lang:t,hl:n}){return r("div",{class:`dl dl-${e.kind}`,children:r("span",{class:"dl-text",children:e.segs?e.segs.map((i,l)=>r("span",{class:i.changed?"dl-intra":"",children:r(Ko,{text:i.text,lang:t,hl:n})},l)):r(Ko,{text:e.text,lang:t,hl:n})})})}function Kd({hunk:e,lang:t,hl:n,onOpen:i,title:l}){return r("div",{class:"dhunk",children:[r("button",{type:"button",class:"dhunk-head",disabled:!i,title:i?l:void 0,onClick:()=>i==null?void 0:i(e.new_start),children:[r("span",{class:"dhunk-range",children:["@@ ",e.new_start]}),e.header?r("span",{class:"dhunk-sym",children:e.header}):null]}),Lk(e.lines).map((a,s)=>r(qk,{line:a,lang:t,hl:n},s))]})}function Uk({file:e,repo:t,review:n,hl:i}){const l=jd(e.path),{collapsed:a,viewed:s}=qd(n,t,e.path,e.sig,l),o=!a,u=Wd(e.path),c=t&&e.status!=="deleted"&&e.status!=="binary",p=(e.additions||0)+(e.deletions||0);return r("div",{class:`dfile dfile-${e.status}${s?" is-viewed":""}${l?" is-generated":""}`,children:[r("div",{class:"dfile-head",children:[r("button",{type:"button",class:"dfile-toggle",onClick:()=>Nk(t,e.path,o),children:[r("span",{class:"dfile-caret",children:o?"▾":"▸"}),r("span",{class:"dfile-path",children:e.path}),l?r("span",{class:"dfile-gen",title:"Generated artifact — folded by default and sorted last",children:"generated"}):null,r("span",{class:"dfile-status",children:e.status}),r("span",{class:"dfile-stat",children:[e.additions?r("span",{class:"dstat-add",children:["+",e.additions]}):null,e.deletions?r("span",{class:"dstat-del",children:["−",e.deletions]}):null,!p&&e.status==="binary"?r("span",{class:"dstat-bin",children:"binary"}):null]})]}),r("button",{type:"button",class:`dfile-viewed${s?" is-on":""}`,title:s?"Marked viewed — re-surfaces automatically if this file changes again":"Mark viewed (folds it away until it changes again)",onClick:()=>Bk(t,e.path,e.sig,!s),children:s?"✓ viewed":"viewed"})]}),o&&e.hunks.map((d,f)=>r(Kd,{hunk:d,lang:u,hl:i,onOpen:c?h=>kr({path:`${t}/${e.path}`,line:h}):null,title:`Open ${e.path}:${d.new_start}`},f)),o&&e.truncated?r("div",{class:"dfile-trunc",children:"diff truncated — open the file to see the rest"}):null]})}const Wk=[3,10,25];function Kk({target:e,active:t,gitSig:n}){var x,w,C;const[i,l]=B("session"),[a,s]=B(3),[o,u]=B({loading:!0,error:null,data:null}),[c,p]=B(null);j(()=>{if(!t||c)return;let y=!0;return Zi(()=>import("./chunks/preview.js").then(g=>g.h),[]).then(g=>{y&&p(()=>g.highlightCode)}).catch(()=>{}),()=>{y=!1}},[t,c]),j(()=>{if(!t||!e)return;let y=!0;return(async()=>{try{const g=await fetch(`/api/fs/diff?${tt(e)}&scope=${i}&context=${a}`);if(!y)return;if(!g.ok){const $=await g.json().catch(()=>({}));u({loading:!1,error:$.detail||`HTTP ${g.status}`,data:null});return}u({loading:!1,error:null,data:await g.json()})}catch(g){y&&u({loading:!1,error:String(g),data:null})}})(),()=>{y=!1}},[e,i,t,n,a]);const d=Rk(((x=o.data)==null?void 0:x.files)||[]),f=((w=o.data)==null?void 0:w.repo)||"",h=ra.value,m=zk(h,f,d),b=d.reduce((y,g)=>({a:y.a+(g.additions||0),d:y.d+(g.deletions||0)}),{a:0,d:0});return r("div",{class:"changes-tab",children:[r("header",{class:"changes-head",children:[r("span",{class:"changes-scope",children:jk.map(([y,g,$])=>r("button",{type:"button",class:i===y?"is-active":"",title:$,onClick:()=>l(y),children:g},y))}),r("span",{class:"changes-ctx",title:"Lines of context around each change",children:Wk.map(y=>r("button",{type:"button",class:a===y?"is-active":"",onClick:()=>s(y),children:y},y))}),!o.loading&&!o.error&&r("span",{class:"changes-summary",children:d.length?r(K,{children:[m?`${m}/${d.length} viewed · `:`${d.length} file${d.length===1?"":"s"} · `,r("span",{class:"dstat-add",children:["+",b.a]})," ",r("span",{class:"dstat-del",children:["−",b.d]})]}):"no changes"})]}),r("div",{class:"changes-body",children:[o.loading?r("div",{class:"changes-msg",children:"loading…"}):null,o.error?r("div",{class:"changes-msg changes-err",children:o.error}):null,!o.loading&&!o.error&&!d.length?r("div",{class:"changes-msg",children:i==="session"?"Nothing changed on disk since this session started.":"This branch matches its fork point."}):null,d.map(y=>r(Uk,{file:y,repo:f,review:h,hl:c},y.path)),(C=o.data)!=null&&C.truncated?r("div",{class:"changes-msg",children:[o.data.truncated," more file",o.data.truncated===1?"":"s"," not shown"]}):null]})]})}const Vk=new Set(["Read","Edit","Write","MultiEdit","NotebookEdit"]),Gk=new Set(["html","md"]);function Jk(e,t){const n=(t||"").trim();if(!n)return!0;const i=(e||"").toLowerCase();if(!/[*?]/.test(n))return i.includes(n.toLowerCase());const l=n.split("**").map(a=>a.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,"[^/]*").replace(/\?/g,"[^/]")).join(".*");return new RegExp(`(?:^|/)${l}$`,"i").test(i)}function Qk(e){const t=(e||"").split("/").pop()||"",n=t.lastIndexOf(".");return n>0?t.slice(n+1).toLowerCase():""}function Yk(e,t=Gk){const n=[],i=[];for(const l of e)(t.has(Qk(l.path))?n:i).push(l);return{priority:n,others:i}}function Zk(e){if(!Array.isArray(e)||e.length===0)return[];const t=new Map;for(let n=e.length-1;n>=0;n--){const i=e[n],l=i==null?void 0:i.tool_uses;if(l!=null&&l.length)for(let a=l.length-1;a>=0;a--){const s=l[a];if(!s||!Vk.has(s.name))continue;const o=s.input&&(s.input.file_path||s.input.notebook_path);o&&(t.has(o)||t.set(o,s.name))}}return[...t.entries()].map(([n,i])=>({path:n,op:i}))}function Xk(e){return e==="need_human"?"var(--s-danger)":e==="done"?"var(--s-success)":"var(--fg-3)"}function ew(e,t){return e==="commit"?"var(--s-shell)":e==="ci"?t==="failed"?"var(--s-danger)":t==="running"?"var(--s-working)":"var(--s-success)":e==="open"?"var(--fg-3)":e==="reset"?"var(--s-working)":e==="rename"?"var(--accent)":"var(--fg-3)"}function tw(e,t){return e==="commit"?"commit":e==="ci"?t?`ci ${t}`:"ci":e==="open"?"opened":e==="reset"?t==="compacted"?"compacted":"cleared":e==="rename"?"renamed":e}function nw(e){return e?(e.replace(/[^A-Za-z0-9]/g,"").slice(0,2)||e.slice(0,1)).toUpperCase():"?"}const rw={pr:"Please link the PR you're working on for this pane using the `link_pr` MCP tool. If there isn't one, ignore this.",linear:"Please link the relevant Linear ticket for this pane using the `link_linear` MCP tool. If there isn't one, ignore this."};function iw({data:e,onLinkAsk:t}){if(!e.pr){if(e.agent!=="claude")return null;const o=!!e.channel_attached;return r("button",{class:"modal-side-link-btn",type:"button",disabled:!o,title:o?"Ask Claude to link the PR for this pane (via link_pr MCP tool)":"Channel not attached. Respawn Claude via + claude.",onClick:()=>t("pr"),children:"+ link pull request"})}const n=e.ci==="✓"?"passing":e.ci==="✗"?"failing":e.ci==="⟳"?"running":"—",i=e.ci==="✓"?"ci-passing":e.ci==="✗"?"ci-failing":e.ci==="⟳"?"ci-running":"",l=lr(e.repo_slug,e.pr),a=e.pr_additions||0,s=e.pr_deletions||0;return r("div",{class:"modal-card-inset",children:[r("div",{class:"pr-head",children:[l?r("a",{class:"pr-num",href:l,target:"_blank",rel:"noopener",onClick:o=>o.stopPropagation(),children:["#",e.pr]}):r("span",{class:"pr-num",children:["#",e.pr]}),r("span",{class:"pr-title",title:e.pr_title||"",children:e.pr_title||""})]}),r("div",{class:"pr-meta",children:[e.pr_draft?r("span",{class:"pr-mini pr-mini-draft",children:"draft"}):r("span",{class:"pr-mini pr-mini-open",children:"open"}),r("span",{class:"pr-diff",children:[r("span",{class:"diff-plus",children:["+",a]})," ",r("span",{class:"diff-minus",children:["−",s]})]}),r("span",{class:`pr-ci ${i}`,children:[r("span",{class:"ci-dot"}),"ci ",n]}),(e.pr_reviewers||[]).length>0&&r("span",{class:"pr-reviewers",children:(e.pr_reviewers||[]).map(o=>r("span",{class:"modal-avatar",title:o,children:nw(o)}))})]})]})}function lw({data:e,onLinkAsk:t}){if(e.linked_linear){const s=e.linked_linear,o=`https://linear.app/issue/${s}`,u=e.linked_linear_title||"linear ticket";return r("div",{class:"modal-card-inset",children:[r("div",{class:"pr-head",children:[r("a",{class:"pr-num",href:o,target:"_blank",rel:"noopener",onClick:c=>c.stopPropagation(),title:`Linear ticket ${s} (linked by claude)`,children:s}),r("span",{class:"pr-title",title:u,children:u})]}),e.linked_linear_status&&r("div",{class:"pr-meta",children:r("span",{class:"pr-mini",children:e.linked_linear_status})})]})}const n=vr(e),i=n&&r("div",{class:"modal-card-inset",children:r("div",{class:"pr-head",children:[r("a",{class:"pr-num",href:n.href,target:"_blank",rel:"noopener",onClick:s=>s.stopPropagation(),title:n.tip,children:n.id}),r("span",{class:"pr-title",children:n.note})]})});if(e.agent!=="claude")return i||null;const l=!!e.channel_attached;return r(K,{children:[i,r("button",{class:"modal-side-link-btn",type:"button",disabled:!l,title:l?"Ask Claude to link a Linear ticket for this pane (via link_linear MCP tool)":"Channel not attached. Respawn Claude via + claude.",onClick:()=>t("linear"),children:"+ link Linear ticket"})]})}function aw({e}){return e.src==="alert"?r("li",{class:"timeline-row timeline-row-alert","data-kind":e.kind,children:[r("span",{class:"timeline-dot",style:`background:${Xk(e.kind)}`}),r("div",{class:"timeline-body",children:[r("div",{class:"timeline-text",children:e.text}),r("div",{class:"timeline-when",children:["claude · ",e.kind," · ",Pe(e.at)," ago"]})]})]}):e.src==="channel"?r("li",{class:"timeline-row timeline-row-channel","data-kind":e.kind,children:[r("span",{class:"timeline-dot",style:"background:var(--accent)"}),r("div",{class:"timeline-body",children:[r("div",{class:"timeline-text",children:e.text}),r("div",{class:"timeline-when",children:["periscope · ",e.kind," · ",Pe(e.at)," ago"]})]})]}):r("li",{class:"timeline-row","data-kind":e.kind,children:[r("span",{class:"timeline-dot",style:`background:${ew(e.kind,e.state)}`}),r("div",{class:"timeline-body",children:[e.url?r("a",{class:"timeline-text timeline-link",href:e.url,target:"_blank",rel:"noopener",children:e.text}):r("div",{class:"timeline-text",children:e.text}),r("div",{class:"timeline-when",children:[tw(e.kind,e.state)," · ",Pe(e.at)," ago"]})]})]})}function sw({data:e,streamRef:t}){const n=e.activity||[],i=n.filter(s=>s.src==="alert").reduce((s,o)=>s&&s.at>=o.at?s:o,null),l=i&&i.kind==="need_human"?i:null,a=n.filter(s=>s!==l);return r(K,{children:[l&&r("div",{class:"activity-pinned",children:[r("div",{class:"activity-pinned-label",children:["needs you · ",Pe(l.at)," ago"]}),r("div",{class:"activity-pinned-text",children:l.text})]}),a.length?r("ol",{class:"timeline activity-stream",ref:t,children:a.map((s,o)=>r(aw,{e:s},o))}):l?null:r("div",{class:"timeline-empty",children:"no recent activity"})]})}function ow({pid:e,onRefresh:t,idPrefix:n}){const i=te(null),l=te(null),a=te(null),s=e?Pr(e):null,o=(s==null?void 0:s.tags)||[];function u(){if(!e)return;const d=Pr(e)||{tags:[]};Kr(e,{notes:i.current.value,tags:d.tags})}function c(){const d=(l.current.value||"").trim();if(!d||!e)return;const f=Pr(e)||{notes:i.current.value,tags:[]},h=d.split(/[\s,]+/).filter(Boolean);Kr(e,{notes:i.current.value,tags:[...f.tags,...h]}),l.current.value="",t==null||t()}function p(d){const f=Pr(e)||{notes:i.current.value,tags:[]};Kr(e,{notes:i.current.value,tags:f.tags.filter((h,m)=>m!==d)}),t==null||t()}return r(K,{children:[r("textarea",{ref:i,id:`${n}-notes`,class:"modal-notes",placeholder:e?"Notes — saves on blur":"Notes unavailable (no pid)",disabled:!e,defaultValue:(s==null?void 0:s.notes)||"",onInput:()=>{clearTimeout(a.current),a.current=setTimeout(u,600)},onBlur:()=>{clearTimeout(a.current),u()},onKeyDown:d=>d.stopPropagation()}),r("div",{class:"tag-row",children:[r("div",{class:"tag-chips",id:`${n}-tags`,children:o.map((d,f)=>r("span",{class:"tag-chip","data-tag-i":f,children:[d,r("button",{class:"tag-chip-x",title:"remove",onClick:()=>p(f),children:"×"})]}))}),r("input",{ref:l,id:`${n}-tag-input`,class:"modal-tag-input",type:"text",placeholder:"add tag, Enter or comma",disabled:!e,onKeyDown:d=>{d.stopPropagation(),(d.key==="Enter"||d.key===",")&&(d.preventDefault(),c())}})]})]})}function xl({it:e,label:t,priority:n,pinned:i,onTogglePin:l}){return r("li",{class:`files-row${n?" files-row-priority":""}${i?" files-row-pinned":""}`,onClick:()=>kr({path:e.path,line:null}),title:`Open ${e.path} as a preview tab`,children:[r("span",{class:"files-op",children:uw(e.op)}),r("span",{class:"files-path",children:t}),r("button",{type:"button",class:`files-pin${i?" files-pin-on":""}`,title:i?"Unpin file":"Pin file","aria-label":i?"Unpin file":"Pin file","aria-pressed":i?"true":"false",onClick:a=>{a.stopPropagation(),l()},children:i?"★":"☆"})]})}function cw({pid:e}){me.value;const[t,n]=B("");if(!e)return null;const l=zr.value[e]?Ft.value[e]:null,a=l!=null&&l.messages?Zk(l.messages):[],s=pu(e);if(!a.length&&!s.length)return null;const o=new Map(a.map(g=>[g.path,g])),u=s.map(g=>o.get(g)||{path:g,op:null}),c=new Set(s),p=a.filter(g=>!c.has(g.path)),d=[...s,...p.map(g=>g.path)],f=g=>hu(g,d),h=t.trim(),m=g=>Jk(g.path,h),b=u.filter(m),{priority:x,others:w}=Yk(p.filter(m)),C=g=>()=>Ng(e,g),y=[{items:b,render:g=>r(xl,{it:g,label:f(g.path),pinned:!0,onTogglePin:C(g.path)},`pin:${g.path}`)},{items:x,render:g=>r(xl,{it:g,label:f(g.path),priority:!0,pinned:!1,onTogglePin:C(g.path)},`pri:${g.path}`)},{items:w,render:g=>r(xl,{it:g,label:f(g.path),pinned:!1,onTogglePin:C(g.path)},`oth:${g.path}`)}].filter(g=>g.items.length>0);return r("section",{class:"modal-side-section modal-side-files",children:[r("h4",{children:"Files"}),r("input",{class:"files-filter",type:"text",placeholder:"filter files — text or glob",value:t,onInput:g=>n(g.currentTarget.value),onKeyDown:g=>{g.stopPropagation(),g.key==="Escape"&&(g.preventDefault(),n(""))}}),r("ul",{class:"files-list",children:[y.map((g,$)=>r(K,{children:[$>0&&r("li",{class:"files-divider","aria-hidden":"true"}),g.items.map(g.render)]})),h&&!y.length&&r("li",{class:"files-nomatch",children:"no files match"})]})]})}function uw(e){switch(e){case"Read":return"👁";case"Write":return"+";case"Edit":case"MultiEdit":case"NotebookEdit":return"✎";default:return"·"}}function dw({data:e,onRefresh:t,containerId:n,containerClass:i,idPrefix:l}){const a=te(null),s=te(0),o=(e==null?void 0:e.pid)||"";j(()=>{a.current&&s.current&&(a.current.scrollTop=s.current)});function u(c){const p=rw[c];!p||!(e!=null&&e.pane_id)||fetch(`/api/channel/push?pane_id=${encodeURIComponent(e.pane_id)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({content:p})}).catch(()=>{})}return a.current&&(s.current=a.current.scrollTop),r("aside",{id:n,class:i,children:[r("section",{class:"modal-side-section",children:[r("h4",{children:"Linked"}),r(iw,{data:e,onLinkAsk:u}),r(lw,{data:e,onLinkAsk:u})]}),r("section",{class:"modal-side-section modal-side-notes",children:[r("h4",{children:"Notes"}),r(ow,{pid:o,idPrefix:l,onRefresh:t},o)]}),r(cw,{pid:o}),r("section",{class:"modal-side-section modal-side-activity",children:[r("h4",{children:"Activity"}),r(sw,{data:e,streamRef:a})]})]})}let mn=null,Rr=null;function hw(){return mn?Promise.resolve(mn):(Rr||(Rr=Zi(()=>import("./chunks/preview.js").then(e=>e.P),[]).then(e=>(mn=e,e)).catch(e=>{throw Rr=null,e})),Rr)}function fw({entry:e,active:t=!0}){const[n,i]=B(()=>(mn==null?void 0:mn.PreviewTabInner)||null),[l,a]=B(null);return j(()=>{if(n)return;let s=!0;return a(null),hw().then(o=>{s&&i(()=>o.PreviewTabInner)}).catch(o=>{s&&a((o==null?void 0:o.message)||String(o))}),()=>{s=!1}},[n]),l?r("div",{class:"preview-tab-content",role:"region","aria-label":"File preview",children:[r("header",{class:"preview-header",children:r("span",{class:"preview-path",children:e.path})}),r("div",{class:"preview-body",children:r("div",{class:"preview-error",children:[r("div",{children:"Failed to load preview module:"}),r("div",{class:"preview-error-code",children:l})]})})]}):n?r(n,{entry:e,active:t}):r("div",{class:"preview-tab-content",role:"region","aria-label":"File preview",children:[r("header",{class:"preview-header",children:r("span",{class:"preview-path",children:[e.path,e.line?`:${e.line}`:""]})}),r("div",{class:"preview-body",children:r("div",{class:"preview-loading",children:"loading…"})})]})}async function Sl(e,t,n,i){i(!0);try{const l=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({repo:t.repo,branch:t.branch})}),a=await l.json().catch(()=>({}));n(l.ok?a.mode==="spawned"?a.checked_out?"checked out the PR and spawned a pane to prepare":"spawned a pane to prepare":"sent":a.detail||`HTTP ${l.status}`),el()}catch(l){n(String(l))}finally{i(!1)}}function pw({row:e}){const t=vr(e),n=t&&r("a",{class:"rq-linear",href:t.href,target:"_blank",rel:"noopener",title:t.tip,children:t.id});if(!e.pr)return n||"—";const i=Ui(e.pr.state),l=`rq-pr-link ${i.cls}`;return r(K,{children:[e.pr.url?r("a",{class:l,href:e.pr.url,target:"_blank",rel:"noopener",children:["#",e.pr.number]}):r("span",{class:l,children:["#",e.pr.number]}),n?r(K,{children:[" · ",n]}):null,e.pr.draft?" draft":""," ",e.pr.state||""," ",e.pr.ci&&!i.cls?e.pr.ci:"",r("div",{class:"rq-repo",children:e.pr.title})]})}const Vo="filter branches, PRs, people, tickets";function mw({col:e}){const{label:t,what:n}=Hi[e],i=Dl.value,l=(i==null?void 0:i.key)===e,a=ug(i,e);return r("th",{"aria-sort":l?i.dir==="asc"?"ascending":"descending":void 0,children:r("button",{type:"button",class:`rq-sort${l?" is-active":""}`,title:a?l?"reverse the order":`sort by ${n}`:"back to the default order",onClick:()=>{Dl.value=a},children:[t,l?r("span",{class:"rq-sort-dir","aria-hidden":"true",children:i.dir==="asc"?"▲":"▼"}):null]})})}function gw({row:e}){var p,d,f;const[t,n]=B(""),[i,l]=B(!1),a=((p=e.pr)==null?void 0:p.state)==="merged",s=!!e.owner||!!e.worktree||((d=e.pr)==null?void 0:d.state)==="open",o=e.walkthrough,u=e.owner?"ask the owning pane to write the walkthrough":e.worktree?"spawn a pane in the worktree to write the walkthrough":s?`check out PR #${e.pr.number} and spawn a pane to write the walkthrough`:"open the branch first (⌘K)",c=e.unresolved>0?`${e.unresolved} unresolved comment${e.unresolved===1?"":"s"}`:e.owner?"ask the owning pane to merge":"no pane on this branch";return r("tr",{class:`rq-row rq-${e.role}${a?" is-merged":""}`,children:[r("td",{class:"rq-branch",children:[o?r("button",{type:"button",class:"rq-open",onClick:()=>Eu(e.repo,e.branch),children:e.branch}):e.branch,r("div",{class:"rq-repo",children:[e.repo," · ",e.role==="review-requested"?"review requested":e.role]})]}),r("td",{class:"rq-pr",children:r(pw,{row:e})}),r("td",{class:"rq-wt",children:o?`${o.stops} stop${o.stops===1?"":"s"} · ${sg(e)}`:"none"}),r("td",{class:"rq-comments",children:e.unresolved?r("b",{children:[e.unresolved," open"]}):"—"}),r("td",{class:"rq-owner",children:[e.owner?e.owner.name:(f=e.pr)!=null&&f.author?`opened by ${e.pr.author}`:"—",e.owner?null:r("div",{class:"rq-repo",children:e.worktree?"no pane":"not checked out"})]}),r("td",{class:"rq-actions",children:[r("button",{type:"button",disabled:i||!s,title:u,onClick:()=>Sl("/api/reviews/prepare",e,n,l),children:o?"re-prepare":"prepare"}),r("button",{type:"button",disabled:i||!e.owner||a||e.unresolved>0,title:c,onClick:async()=>{await Yn(`Ask the owning pane to merge ${e.branch}?`,{okLabel:"Merge"})&&Sl("/api/reviews/merge",e,n,l)},children:"merge"}),(a||!e.worktree)&&(o||e.unresolved)?r("button",{type:"button",disabled:i,title:"remove this review's files",onClick:async()=>{await Yn(`Remove the walkthrough and comments for ${e.branch}? This can't be undone.`,{okLabel:"Clear",danger:!0})&&Sl("/api/reviews/clear",e,n,l)},children:"clear"}):null,t?r("span",{class:"rq-note",children:t}):null]})]})}function yw(){j(()=>{el()},[]);const e=gt.value;if(e===null)return r("div",{class:"wt-empty",children:"loading…"});const t=cg(e,Dl.value),n=ps.value,i=dg(t,n),l=`branch${t.length===1?"":"es"}`;return r("div",{class:"reviews-queue",children:[r("header",{class:"wt-head",children:[r("h2",{children:"Reviews"}),r("input",{type:"search",class:"rq-search",placeholder:Vo,"aria-label":Vo,spellcheck:!1,autocomplete:"off",value:n,onInput:a=>{ps.value=a.currentTarget.value}}),r("span",{class:"wt-sub","aria-live":"polite",children:n.trim()?`${i.length} of ${t.length} ${l}`:`${t.length} ${l}`})]}),t.length===0?r("div",{class:"wt-empty",children:"nothing open"}):i.length===0?r("div",{class:"wt-empty",children:['no branches match "',n.trim(),'"']}):r("table",{class:"rq-table",children:[r("thead",{children:r("tr",{children:[Object.keys(Hi).map(a=>r(mw,{col:a},a)),r("th",{})]})}),r("tbody",{children:i.map(a=>r(gw,{row:a},`${a.repo}/${a.branch}`))})]})]})}async function bw(e,t){const n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),i=await n.json().catch(()=>({}));return{ok:n.ok,status:n.status,data:i}}function Vd({list:e}){return e.length?r("ul",{class:"wt-comments",children:e.map((t,n)=>r("li",{class:t.resolved?"is-resolved":"",children:[r("span",{class:"wt-comment-ts",children:t.ts}),r("span",{class:"wt-comment-state",children:t.resolved?"resolved":"open"}),r("div",{class:"wt-comment-body",children:mr(t.body,{demote:!1,softBreaks:"space"})})]},n))}):null}function kw({repo:e,branch:t,stop:n,onPosted:i}){const[l,a]=B(""),[s,o]=B(""),[u,c]=B(!1);async function p(){if(!(u||!l.trim())){c(!0);try{const d=await bw("/api/reviews/comment",{repo:e,branch:t,stop:n,body:l});d.ok?(a(""),o("sent to the owning pane")):d.status===409?(a(""),o(`saved, ${d.data.detail||"not delivered"}`)):o(d.data.detail||`HTTP ${d.status}`),i()}catch(d){o(String(d))}finally{c(!1)}}}return r("div",{class:"wt-comment-box",children:[r("textarea",{rows:2,value:l,placeholder:"comment on this stop…",onInput:d=>a(d.currentTarget.value),onKeyDown:d=>{d.key==="Enter"&&(d.metaKey||d.ctrlKey)&&p()}}),r("div",{class:"wt-comment-actions",children:[r("button",{type:"button",disabled:u||!l.trim(),onClick:p,children:"comment"}),s?r("span",{class:"wt-comment-note",children:s}):null]})]})}function ww({stop:e,diffFiles:t,comments:n,repo:i,branch:l,hl:a,onPosted:s}){const[o,u]=B(!1),c=ag(e.refs,t||[]),p=c.reduce((f,h)=>f+h.hunks.length,0),d=f=>{const h=c.find(m=>m.ref.raw===f.raw&&m.hunks.length);return r("button",{type:"button",class:`md-cite${h?"":" is-inert"}`,title:h?"show hunks":"no hunk in this branch's diff",onClick:()=>h&&u(!0),children:f.raw})};return r("section",{class:"wt-stop",id:`stop-${e.id}`,children:[r("h3",{class:"wt-stop-title",children:[e.kind?r("span",{class:`wt-kind wt-kind-${e.knownKind?e.kind:"other"}`,children:e.kind}):null,e.title]}),e.refs.length?r("div",{class:"md-meta",children:r("span",{class:"md-meta-kv","data-key":"refs",children:[r("span",{class:"md-meta-k",children:"refs"}),r("span",{class:"md-meta-v",children:e.refs.map((f,h)=>r("span",{children:[h?", ":"",d(f)]},h))})]})}):null,r("div",{class:"md-doc wt-stop-body",children:mr(e.bodyMarkdown,{demote:!1,softBreaks:"space",mermaid:!0,meta:!0,cite:d})}),t&&e.refs.length?r("div",{class:"wt-evidence",children:[r("button",{type:"button",class:"wt-evidence-toggle",onClick:()=>u(!o),children:[o?"▾":"▸"," ",p," hunk",p===1?"":"s"]}),o&&c.map((f,h)=>r("div",{class:"wt-evidence-file",children:[r("div",{class:"wt-evidence-path",children:[f.ref.raw,f.file?f.generated?" — generated, not shown":"":" — not in this diff"]}),f.hunks.map((m,b)=>r(Kd,{hunk:m,lang:Wd(f.ref.path),hl:a,onOpen:null},b))]},h))]}):null,r(Vd,{list:n}),r(kw,{repo:i,branch:l,stop:e.title,onPosted:s})]})}function vw({repo:e,branch:t,pr:n,sig:i}){var y;const[l,a]=B({loading:!0,error:null,data:null}),[s,o]=B(null),[u,c]=B(0);j(()=>{let g=!0;return Zi(()=>import("./chunks/preview.js").then($=>$.h),[]).then($=>{g&&o(()=>$.highlightCode)}).catch(()=>{}),()=>{g=!1}},[]),j(()=>{let g=!0;return(async()=>{try{const $=await fetch(`/api/reviews/walkthrough?repo=${encodeURIComponent(e)}&branch=${encodeURIComponent(t)}`),v=await $.json().catch(()=>({}));if(!g)return;if(!$.ok){a(E=>({loading:!1,error:v.detail||`HTTP ${$.status}`,data:E.data}));return}a({loading:!1,error:null,data:v})}catch($){g&&a(v=>({loading:!1,error:String($),data:v.data}))}})(),()=>{g=!1}},[e,t,u,i]);const p=()=>{c(g=>g+1),el()};if(l.loading)return r("div",{class:"wt-empty",children:"loading…"});if(!l.data)return r("div",{class:"wt-empty",children:l.error});const{text:d,comments:f,diff:h,stale_by:m}=l.data,b=ig(d),x=new Map;for(const g of f)(x.get(g.stop)||x.set(g.stop,[]).get(g.stop)).push(g);const w=new Set(b.stops.map(g=>g.title)),C=f.filter(g=>!w.has(g.stop));return r("div",{class:"walkthrough",children:[l.error?r("div",{class:"wt-empty wt-error",children:["refresh failed: ",l.error]}):null,r("header",{class:"wt-head",children:[r("h2",{children:b.title||t}),r("span",{class:"wt-sub",children:[e," · ",t,(y=b.header)!=null&&y.pr?r(K,{children:[" · ",n!=null&&n.url&&n.number===b.header.pr?r("a",{class:`rq-pr-link ${Ui(n.state).cls}`,href:n.url,target:"_blank",rel:"noopener",children:["PR #",b.header.pr]}):`PR #${b.header.pr}`]}):"",m==null&&b.header?h?"":" · no worktree — hunks unavailable":m>0?` · stale: ${m} commit${m===1?"":"s"} since`:""]})]}),b.problem?r("p",{class:"wt-problem",children:b.problem}):null,b.stops.map(g=>r(ww,{stop:g,diffFiles:(h==null?void 0:h.files)||null,comments:x.get(g.title)||[],repo:e,branch:t,hl:s,onPosted:p},g.id)),C.length?r("section",{class:"wt-stop",children:[r("h3",{class:"wt-stop-title",children:"unattached comments"}),r(Vd,{list:C})]}):null]})}function _w({target:e,agent:t,onPaste:n,class:i="modal-xterm",id:l}){const a=te(null);return j(()=>(Y1(a.current,e,{agent:t,onPaste:n}),Hu),[]),r("div",{ref:a,id:l,class:i})}function xw(){const e=te(null),[t,n]=B(!1),[i,l]=B("");j(()=>{function o(u){(u.metaKey||u.ctrlKey)&&u.key==="f"&&(u.preventDefault(),n(!0),requestAnimationFrame(()=>{var c;return(c=e.current)==null?void 0:c.focus()}))}return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[]);const a=br(()=>{n(!1),l(""),Q1()},[]);ot(a,t);function s(o){o.preventDefault(),i&&(o.shiftKey?Js(i):Gs(i))}return t?r("form",{class:"term-search",onSubmit:s,children:[r("input",{ref:e,class:"term-search-input",value:i,placeholder:"find in terminal",onInput:o=>{l(o.currentTarget.value)}}),r("button",{type:"button",class:"term-search-btn",title:"Previous (Shift+Enter)",onClick:()=>i&&Js(i),children:"‹"}),r("button",{type:"button",class:"term-search-btn",title:"Next (Enter)",onClick:()=>i&&Gs(i),children:"›"}),r("button",{type:"button",class:"term-search-btn",title:"Close (Esc)",onClick:a,children:"✕"})]}):null}const Gd={rail:{pref:"rail_width",cssVar:"--rail-w",columnId:"rail",def:320,min:180,dir:1},side:{pref:"side_width",cssVar:"--side-w",columnId:"detail-side",def:280,min:200,dir:-1}},Sw=.5;function $w(e,t,n){return Math.round(Math.min(Math.max(e,t),Math.max(t,n)))}function Cw(e,t,n,i){return $w(e+n.dir*t,n.min,i*Sw)}function Tw(e){return Number.isFinite(e)&&e>0?e:null}function Jd({which:e}){const t=Gd[e];function n(i){if(i.button!==0)return;const l=i.currentTarget,a=document.getElementById("split-view"),s=document.getElementById(t.columnId),o=l.parentElement;if(!a||!s||!o)return;i.preventDefault();const u=i.clientX,c=Math.round(s.getBoundingClientRect().width),p=o.getBoundingClientRect().width;let d=c;l.setPointerCapture(i.pointerId),l.classList.add("dragging"),document.body.classList.add("col-resizing"),G1();const f=m=>{d=Cw(c,m.clientX-u,t,p),a.style.setProperty(t.cssVar,`${d}px`)},h=()=>{l.removeEventListener("pointermove",f),l.removeEventListener("pointerup",h),l.removeEventListener("pointercancel",h),l.classList.remove("dragging"),document.body.classList.remove("col-resizing"),J1(),d!==c&&Ns(t.pref,d)};l.addEventListener("pointermove",f),l.addEventListener("pointerup",h),l.addEventListener("pointercancel",h)}return r("div",{class:`col-resize col-resize-${e}`,title:"Drag to resize · double-click to reset",onPointerDown:n,onDblClick:()=>Ns(t.pref,t.def)})}function Ew(e){return(e==null?void 0:e.agent)!=="claude"?"not a Claude pane":e.state!=="idle"&&e.state!=="done"?`pane is ${e.state||"busy"}, try again when it's idle`:e.pending_input?"the pane has unsent text in its input box":null}function Pw(e){return(e==null?void 0:e.session_effort)||(e==null?void 0:e.launch_effort)||"default"}function Aw(e){var t;return e!=null&&e.model?e.model.replace(/\s*\(.*\)/,""):e!=null&&e.session_model?((t=cr.find(n=>n.id===e.session_model))==null?void 0:t.label)||e.session_model:"model"}function Mw({w:e}){var c;const[t,n]=B({}),[i,l]=B(!1);j(()=>{n({})},[e.pid,e.session_model,e.session_effort]);const a=i?"waiting for the pane to confirm the last change":Ew(e);async function s(p,d){const f=d.currentTarget.value;if(d.currentTarget.value="",!f||i)return;const h=`pid=${encodeURIComponent(e.pid)}&setting=${p}&value=${encodeURIComponent(f)}`;l(!0);let m;try{m=await ie(`set ${p}`,`/api/pane/session-setting?${h}`,{method:"POST"})}finally{l(!1)}m&&(m.result==="applied"?n(b=>({...b,[p]:f})):m.result==="confirm"?kn("Claude is asking to confirm the model switch in the pane — answer it there","info",7e3):kn(`Sent ${m.sent}, but Claude didn't confirm it took`,"info",5e3))}const o=t.model?((c=cr.find(p=>p.id===t.model))==null?void 0:c.label)||t.model:Aw(e),u=t.effort||Pw(e);return r("span",{class:"header-session-picks",children:[r("select",{class:"header-session-pick",value:"",disabled:!!a,title:a||"change this session's model (types /model into the pane)",onChange:p=>s("model",p),children:[r("option",{value:"",hidden:!0,children:o}),cr.map(p=>r("option",{value:p.id,children:p.label},p.id))]}),r("select",{class:"header-session-pick",value:"",disabled:!!a,title:a||"change this session's effort (types /effort into the pane)",onChange:p=>s("effort",p),children:[r("option",{value:"",hidden:!0,children:`effort ${u}`}),Fa.map(p=>r("option",{value:p,children:p},p))]})]})}const Lw=2e3;function Iw(e,t,n){j(()=>{if(!n||!e)return;let i=!0,l=null;async function a(){try{const o=await(await fetch(`/api/pane/turns?${tt(e)}`)).json();if(!i)return;const u=o&&o.turns===null?[]:o.messages||[],c=(o==null?void 0:o.session_id)||null;Ft.value={...Ft.value,[t]:{messages:u,sessionId:c}},u.length&&!zr.value[t]&&(zr.value={...zr.value,[t]:!0})}catch{}i&&(l=setTimeout(a,Lw))}return a(),()=>{i=!1,l&&clearTimeout(l)}},[e,t,n])}function Ow(e){const t=e.input||{};switch(e.name){case"Bash":return t.command||"";case"Read":case"Edit":case"Write":case"MultiEdit":case"NotebookEdit":return t.file_path||t.notebook_path||"";case"Grep":return t.pattern||"";case"Glob":return t.pattern||"";case"Task":case"Agent":return t.description||"";case"TaskCreate":return t.subject||"";case"TaskUpdate":return t.taskId?`#${t.taskId}`:"";case"WebFetch":return t.url||"";case"WebSearch":return t.query||"";case"Skill":return t.skill||t.command||"";case"AskUserQuestion":{const n=t.questions||[];return n.length===1?n[0].question||n[0].header||"":n.length?`${n.length} questions`:""}default:{const n=JSON.stringify(t);return n==="{}"||n==="null"?"":n.length>120?`${n.slice(0,120)}…`:n}}}function Dw({input:e}){const t=String(e.old_string||"").split(`
+ ${wl(o)} active tokens
+ ${wl(n.cache_read_tokens)} cache reads (discounted)`;return r("div",{id:"usage",class:"usage usage-fallback",title:c,children:`5h: ${wl(o)} · ${Hd(n.reset_at)}`})}function wb({id:e,toggleClass:t,toggleLabel:n,title:i,children:l}){const[a,s]=N(!1),o=J(null),c=jt(()=>s(!1),[]);return ji(o,a,c),r("div",{class:"tb-dd",ref:o,children:[r("button",{type:"button",class:t,id:e,"aria-haspopup":"menu","aria-expanded":a?"true":"false",title:i,onClick:u=>{u.stopPropagation(),s(h=>!h)},children:n}),r("div",{class:"tb-dd-menu",role:"menu",hidden:!a,onClick:()=>s(!1),children:l})]})}function vb(){const e=ce.value,t=e.length,n=e.filter(o=>o.state==="needs-input").length,i=e.filter(o=>o.state==="working").length,l=e.filter(o=>o.state==="done").length,a=e.filter(o=>o.state==="idle").length,s=()=>r("span",{class:"count-sep",children:"·"});return r("span",{id:"counts",children:[r("span",{children:[r("b",{children:t})," windows"]}),n>0&&r(U,{children:[" ",r(s,{})," ",r("span",{class:"count-needs",children:[n," needs input"]})]})," ",r(s,{})," ",r("span",{class:"count-working",children:[i," working"]})," ",r(s,{})," ",r("span",{class:"count-done",children:[l," done"]})," ",r(s,{})," ",r("span",{class:"count-idle",children:[a," idle"]})]})}function xb(){H(()=>{function t(n){(n.metaKey||n.ctrlKey)&&n.key==="/"&&(ye("key.shortcut",{key:"cmd+/"}),n.preventDefault(),window.location.href="/history")}return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[]);const e=J(null);return H(()=>{const t=e.current;if(!t)return;const n=()=>document.documentElement.style.setProperty("--header-h",`${t.offsetHeight}px`);n();const i=new ResizeObserver(n);return i.observe(t),()=>i.disconnect()},[]),r("header",{class:"periscope-header",ref:e,"data-pin-rows":Mn()?3:2,children:[r("div",{class:"topbar",children:[r("span",{class:"brand",children:["periscope",r("i",{class:"brand-cursor"})]}),r(kb,{}),r(G1,{}),r("div",{class:"spawn-pins",children:[r(J1,{}),r(e0,{}),r(Y1,{})]}),r(Cy,{})]}),r("nav",{class:"filters",id:"filters",children:[r("a",{href:"/history",class:"filter-btn is-action",id:"history-link",title:"search conversation history (⌘/)",children:["🔍 history ",r("span",{class:"ps-kbd",style:"margin-left:4px",children:"⌘"}),r("span",{class:"ps-kbd",children:"/"})]}),r("span",{class:"filters-sep"}),r(j1,{}),r("span",{class:"filters-sep"}),r("button",{type:"button",class:"filter-btn is-action",id:"new-open-btn",title:"open a repo, worktree, or PR",onClick:()=>{var t;return(t=window.__periscopeOpenOmnibox)==null?void 0:t.call(window)},children:"+ new"}),r("button",{type:"button",class:"filter-btn is-action",id:"reviews-btn",title:"open branches, walkthroughs, review comments",onClick:Ua,children:["◉ reviews",Ws(yt.value)?r("span",{class:"rail-review-badge",children:Ws(yt.value)}):null]}),r(wb,{id:"more-dd-toggle",toggleClass:"filter-btn is-action tb-dd-toggle",toggleLabel:"⋯",title:"more actions",children:[r("button",{id:"cleanup-btn",class:"tb-dd-item",role:"menuitem",title:"archive worktrees with merged PRs, deleted branches, or idle activity",children:"🧹 cleanup"}),r("button",{id:"settings-btn",class:"tb-dd-item",role:"menuitem",title:"settings",children:"🛠 settings"}),r("button",{id:"open-commands",class:"tb-dd-item",role:"menuitem",title:"edit + claude / + shell / + ... commands",children:"⚙ commands"})]}),r("span",{class:"filters-sep"}),r(H1,{}),r("div",{class:"meta",children:r(vb,{})})]}),r(ob,{})]})}const _b=3e3;let vl=null,ei=!1,Oo=!1,Kn=!1;function Sb(){if(Oo)return;Oo=!0;const e=window.WebSocket;function t(){return{readyState:0,binaryType:"arraybuffer",send(){},close(){},onopen:null,onmessage:null,onerror:null,onclose:null}}function n(i,l){return Kn&&String(i).includes("/ws/pane")?t():l===void 0?new e(i):new e(i,l)}n.CONNECTING=e.CONNECTING,n.OPEN=e.OPEN,n.CLOSING=e.CLOSING,n.CLOSED=e.CLOSED,n.prototype=e.prototype,window.WebSocket=n}async function $b(e){var b,C;ei=!0;const t=e.settleMs||2e3,n=e.switches||20,i=(e.kind||"claude")==="claude",l=(ce.value||[]).filter(g=>g.agent==="claude"===i&&g.pid),a=Math.max(2,e.poolSize||(((b=e.pids)==null?void 0:b.length)??2)),s=((C=e.pids)==null?void 0:C.length)>=2?e.pids:l.slice(0,a).map(g=>g.pid),o=document.title;if(s.length<2){ye("memtest.abort",{nonce:e.nonce,reason:"need 2 pids"}),ei=!1;return}const c=ke.value,u=s.map(g=>Au(g)),h=e.mode||"terminal";if(!e.realClick)for(const g of s)Ql(g,h);Kn=!!e.blockWs,Kn&&Sb();const d=document.getElementById("rail")||document.querySelector(".rail, #left");ye("memtest.start",{nonce:e.nonce,n,mode:h,blockWs:Kn,pids:s,realClick:!!e.realClick,scrollRail:!!e.scrollRail,hoverStorm:!!e.hoverStorm,railScroll:d?{sh:d.scrollHeight,ch:d.clientHeight}:null,noWebgl:(()=>{try{return localStorage.getItem("periscope.noWebgl")==="1"}catch{return null}})()});const p=e.tabPath||null,f=g=>new Promise(y=>setTimeout(y,g));let m=0,k=1;function x(){const g=document.querySelectorAll(".rail-row.pane-row");if(g.length<2)return;const y=Math.min(g.length,Math.max(2,e.poolSize||g.length));m>=y&&(m=y-1);const $=g[m];if(e.scrollRail&&$.scrollIntoView({behavior:"smooth",block:"center"}),e.hoverStorm)for(const v of g)v.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0})),v.dispatchEvent(new MouseEvent("mouseout",{bubbles:!0}));$.click(),m+=k,(m>=y-1||m<=0)&&(k=-k)}for(let g=1;g<=n;g++){const y=s[g%s.length];e.realClick?x():ke.value=`pane:${y}`,document.title=`memtest ${g}/${n}`,await f(p?t/3:t),p&&(wr({path:p}),await f(t/3),qr(y,"pane"),await f(t/3)),g%5===0&&ye("memtest.progress",{nonce:e.nonce,i:g})}if(p)for(const g of s)Hc(g,p);if(Kn=!1,!e.realClick)for(const[g,y]of s.entries())Ql(y,u[g]||"terminal");ke.value=c,e.realClick&&(c!=null&&c.startsWith("pane:"))&&bt({kind:"pane",pid:c.slice(5)}),document.title=o,ye("memtest.done",{nonce:e.nonce,n,mode:h}),ei=!1}async function Do(){try{const e=await fetch("/memtest.json",{cache:"no-store"});return e.ok?await e.json():null}catch{return null}}async function Cb(){const e=await Do();e!==null&&(vl=e.nonce??null,setInterval(async()=>{if(ei)return;const t=await Do();!t||t.nonce==null||t.nonce===vl||(vl=t.nonce,$b(t))},_b))}const yn=q([]);let Tb=1;function Eb(e){return new Promise(t=>{yn.value=[...yn.value,{...e,id:Tb++,resolve:t}]})}function Bn(e,t){const n=yn.value.find(i=>i.id===e);yn.value=yn.value.filter(i=>i.id!==e),n&&n.resolve(t)}function tr(e,t={}){return Eb({type:"confirm",message:e,okLabel:t.okLabel||"OK",cancelLabel:t.cancelLabel||"Cancel",danger:!!t.danger})}function Pb(e){return String(e??"").split(`
+`).map((n,i)=>r(U,{children:[i>0?r("br",{}):null,n]}))}function Mb({req:e}){const t=J(null),n=J(null),i=e.type==="confirm"&&e.danger,l=e.type==="confirm"?!1:e.type==="prompt"?null:void 0;We(()=>Bn(e.id,l)),H(()=>{var h,d;const u=t.current;if(u&&!u.open&&u.showModal(),e.type==="prompt"){const p=n.current;p&&(p.focus(),p.select())}else i?(h=u==null?void 0:u.querySelector(".confirm-dialog-cancel"))==null||h.focus():(d=u==null?void 0:u.querySelector(".confirm-dialog-ok"))==null||d.focus()},[]);const a=()=>{var u;e.type==="prompt"?Bn(e.id,((u=n.current)==null?void 0:u.value)??""):e.type==="alert"?Bn(e.id,void 0):Bn(e.id,!0)},s=()=>Bn(e.id,l),o=u=>{u.target===t.current&&s()},c=e.type==="prompt"?"confirm-dialog prompt-dialog":"confirm-dialog";return r("dialog",{ref:t,class:c,onClick:o,children:[r("p",{class:"confirm-dialog-msg",children:Pb(e.message)}),e.type==="prompt"&&r("input",{ref:n,type:"text",class:"prompt-dialog-input",autocomplete:"off",spellcheck:!1,value:e.defaultValue,placeholder:e.placeholder||void 0,onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),a())}}),r("div",{class:"confirm-dialog-actions",children:[e.type!=="alert"&&r("button",{type:"button",class:"confirm-dialog-cancel",onClick:s,children:e.cancelLabel}),r("button",{type:"button",class:`confirm-dialog-ok${i?" is-danger":""}`,onClick:a,children:e.okLabel})]})]})}function Ab(){const e=yn.value;return r(U,{children:e.map(t=>r(Mb,{req:t},t.id))})}async function kr(e,t,n={}){let i;try{i=await fetch(t,n)}catch(a){return{error:`${e} failed: ${a.message}`,reason:a.message}}let l={};try{l=await i.json()}catch{}if(!i.ok){const a=l.detail||`HTTP ${i.status}`;return{error:l.detail||`${e} failed: ${a}`,reason:a,status:i.status}}return{data:l}}const sn=q(!1),zt=q(null);function Lb(e){return Array.isArray(e)?e.filter(Boolean):null}function Ib(e,t){return e===t?!0:!e||!t?!1:e.length===t.length&&e.every((n,i)=>n===t[i])}function Kd(e){const{paths:t}=e||{},n=Lb(t);Ib(n,zt.value)||(zt.value=n),sn.value=!0,ye("overlay.open",{which:"cleanup",scoped:!!zt.value})}function Ob(e){return e!=null&&e.length?`/api/cleanup/candidates?${e.map(t=>`paths=${encodeURIComponent(t)}`).join("&")}`:"/api/cleanup/candidates"}function zn(){sn.value=!1,zt.value=null}function Db(){We(zn,sn.value);const[e,t]=N(""),[n,i]=N(!1),[l,a]=N([]),[s,o]=N({}),[c,u]=N(!1),[h,d]=N(!1),p=J(0);H(()=>{const x=document.getElementById("cleanup-btn"),b=()=>Kd();return x&&x.addEventListener("click",b),()=>{x&&x.removeEventListener("click",b)}},[]);async function f(){const x=++p.current;t(""),i(!0),a([]),o({});const b=zt.peek();if(b&&b.length===0){i(!1);return}const{data:C,error:g}=await kr("load candidates",Ob(b));if(x!==p.current)return;if(i(!1),g){t(g),a([]);return}const y=C.candidates||[];a(y);const $={};y.forEach((v,E)=>{$[E]=!v.dirty}),o($)}H(()=>{if(!sn.value){p.current++;return}u(!1),f()},[sn.value,zt.value]);const m=Object.values(s).filter(Boolean).length;async function k(){t("");const x=[];if(l.forEach((g,y)=>{s[y]&&x.push({pinned_dir:g.pinned_dir,delete_branch:c})}),x.length===0)return;d(!0);const{data:b,error:C}=await kr("archive","/api/cleanup/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({candidates:x})});if(d(!1),C){t(C);return}if(b.failed&&b.failed.length>0){const g=`Archived ${b.archived.length}, ${b.failed.length} failed: `+b.failed.map(y=>`${y.pinned_dir.split("/").pop()}: ${y.error}`).join("; ");await f(),t(y=>y||g);return}zn()}return sn.value?r("div",{id:"cleanup-modal",class:"cleanup-modal-overlay",onClick:x=>{x.target.id==="cleanup-modal"&&zn()},children:r("div",{class:"cleanup-modal-card",children:[r("header",{class:"cleanup-modal-head",children:[r("h2",{children:"🧹 cleanup"}),r("button",{id:"cleanup-modal-close",title:"close",onClick:zn,children:"×"})]}),r("p",{class:"cleanup-modal-sub",children:"Worktrees with merged/closed PRs, deleted remote branches, or idle activity. Dirty worktrees are NOT auto-selected."}),r("div",{id:"cleanup-modal-controls",children:r("label",{class:"cleanup-delete-branches",children:[r("input",{type:"checkbox",id:"cleanup-delete-branches",checked:c,onChange:x=>u(x.currentTarget.checked)})," also delete local branches"]})}),r("div",{id:"cleanup-modal-list",children:n?r("div",{class:"cleanup-loading",children:"Walking worktrees…"}):l.length===0&&!e?r("div",{class:"cleanup-empty",children:zt.value?"Nothing to clean up here. Cleanup only offers a worktree (never a main checkout) whose PR is merged or closed, whose remote branch is gone, or that sits idle.":"No cleanup candidates. 🎉"}):l.map((x,b)=>{const C=x.project_name||`(untracked: ${x.pinned_dir.split("/").pop()})`;return r("label",{class:x.dirty?"cleanup-row cleanup-row-dirty":"cleanup-row","data-i":b,children:[r("input",{type:"checkbox",class:"cleanup-row-check",checked:!!s[b],onChange:g=>o(y=>({...y,[b]:g.currentTarget.checked}))}),r("div",{class:"cleanup-row-body",children:[r("div",{class:"cleanup-row-title",children:C}),r("div",{class:"cleanup-row-meta",children:[x.branch," ",x.dirty?r("span",{class:"cleanup-dirty",children:"⚠ dirty"}):null]}),r("div",{class:"cleanup-row-signals",children:(x.signals||[]).map((g,y)=>r("span",{class:`cleanup-badge cleanup-badge-${g.kind}`,children:g.label},y))})]})]},x.pinned_dir)})}),r("div",{id:"cleanup-modal-error",class:"cleanup-modal-error",hidden:!e,children:e}),r("div",{class:"cleanup-modal-actions",children:[r("button",{type:"button",id:"cleanup-cancel",onClick:zn,children:"cancel"}),r("button",{type:"button",id:"cleanup-submit",disabled:n||h||m===0,onClick:k,children:["archive selected (",m,")"]})]})]})}):null}const Ei=q(!1);function Ro(){Ei.value=!0,ye("overlay.open",{which:"commands"})}function xl(){Ei.value=!1}function Rb({c:e,i:t,onDragState:n}){const i=J(null);async function l(s){const o=i.current;if(!o)return;const c=o.querySelector(".commands-label").value.trim(),u=o.querySelector(".commands-exec").value;c&&await c1(e.label,{label:c,exec:u})}async function a(){await u1(e.label)}return r("div",{ref:i,class:"commands-row",draggable:!0,"data-label":e.label,"data-i":t,onDragStart:s=>{var o;n(e.label),(o=i.current)==null||o.classList.add("dragging"),s.dataTransfer.setData("text/plain",e.label),s.dataTransfer.effectAllowed="move"},onDragEnd:()=>n(null),onDragOver:s=>{s.preventDefault(),s.dataTransfer.dropEffect="move";const o=i.current.getBoundingClientRect(),c=s.clientY{var s;(s=i.current)==null||s.classList.remove("drag-over-top","drag-over-bottom")},onDrop:s=>{s.preventDefault();const o=i.current.getBoundingClientRect(),c=s.clientY{const l=document.getElementById("open-commands");return l&&l.addEventListener("click",Ro),()=>{l&&l.removeEventListener("click",Ro)}},[]);const e=J(null),t=l=>{e.current=l};t.drop=(l,a)=>{const s=e.current;if(!s||l===s)return;const o=Vr().map(d=>d.label),c=o.indexOf(s);if(c<0)return;o.splice(c,1);const u=o.indexOf(l),h=a?u:u+1;o.splice(h,0,s),d1(o)};async function n(){const l="command";let a=l,s=1;const o=new Set(Vr().map(c=>c.label));for(;o.has(a);)a=`${l}-${++s}`;await o1({label:a,exec:""})}if(!Ei.value)return null;const i=Vr();return r("div",{id:"commands-modal",class:"commands-modal-overlay",onClick:l=>{l.target.id==="commands-modal"&&xl()},children:r("div",{class:"commands-modal-card",children:[r("header",{class:"commands-modal-head",children:[r("h2",{children:"New-window commands"}),r("button",{id:"commands-modal-close",title:"close",onClick:xl,children:"×"})]}),r("p",{class:"commands-modal-sub",children:["First row is the primary button. Drag rows to reorder. Empty ",r("code",{children:"exec"})," = bare shell."]}),r("div",{id:"commands-modal-list",children:i.map((l,a)=>r(Rb,{c:l,i:a,onDragState:t},l.label))}),r("button",{id:"commands-modal-add",class:"commands-modal-add",onClick:n,children:"+ add command"})]})})}const Vd=[{id:"default",label:"default"},{id:"full",label:"full"}];function _l(e){return(e==null?void 0:e.mode)==="agent"&&(e.agent||"claude")==="claude"}function Nb(e){return!e||e==="default"?null:e}function Fo(e){var t;return((t=Vd.find(n=>n.id===e))==null?void 0:t.label)||e}const No=["shell","idle","done","working","needs-input"];function Bo(e){let t=-1;for(const n of e){const i=No.indexOf(n);i>t&&(t=i)}return t>=0?No[t]:"shell"}const Gd="";function as(e,t,n,i={},l=[]){const a=i.trackOrder||[],s=i.tabsByTrack||{},o=i.branchOrderByTrack||{},c=[],u={},h={},d={},p={};for(const v of e||[]){const E=v.track_id;if(!E)continue;const M=v.branch||Gd;u[E]||(c.push(E),u[E]=[],h[E]=[],d[E]={}),u[E].includes(v.pid)||u[E].push(v.pid),h[E].includes(M)||h[E].push(M),d[E][M]||(d[E][M]=[]),d[E][M].includes(v.pid)||d[E][M].push(v.pid),p[v.pid]=M}const f=(l||[]).filter(v=>v.id&&v.id!==v.repo).map(v=>v.id),m=new Set(f),k=new Set(c),x=a.filter(v=>k.has(v)||m.has(v)),b=new Set(x),C=[...x,...c.filter(v=>!b.has(v)),...f.filter(v=>!b.has(v)&&!k.has(v))],g={},y={},$={};for(const v of C){const E=u[v]||[],M=new Set(E),T=(s[v]||[]).filter(R=>M.has(R)),S=new Set(T);g[v]=[...T,...E.filter(R=>!S.has(R))];const L=h[v]||[],O=new Set(L),j=(o[v]||[]).filter(R=>O.has(R)),I=new Set(j),D=[...j,...L.filter(R=>!I.has(R))];if(D.length>=2){y[v]=D,$[v]={};for(const R of D)$[v][R]=[];for(const R of g[v]){const Y=p[R];$[v][Y]&&$[v][Y].push(R)}}else y[v]=[]}return{trackOrder:C,tabsByTrack:g,branchesByTrack:y,tabsByBranch:$}}function Pi(e,t,n=[]){for(const l of t||[])if(l.track_id===e&&l.track_name)return l.track_name;for(const l of n||[])if(l.id===e&&l.name)return l.name;if(e==="loose")return"loose";const i=String(e||"").split("/").filter(Boolean);return i[i.length-1]||e}function Bb(e,t,n=[]){if(e==="loose")return"loose";for(const i of t||[])if(i.track_id===e&&i.track_kind)return i.track_kind;for(const i of n||[])if(i.id===e)return i.repo===i.id?"repo":"goal";return"repo"}function zb(e){return String(e||"").replace(/^\/(?:Users|home)\/[^/]+/,"~")}function jb(e){const t=e.worktree_affiliation||{};if(t.kind==="sibling")return t.label||null;if(t.kind==="no-repo"||t.kind==="off-repo"){if(e.repo_key&&e.repo_label)return e.branch?`${e.repo_label}/${e.branch}`:e.repo_label;if(e.cwd)return zb(e.cwd)}return null}function Hb(e,t,n,i){const l={};for(const a of i||[])if(a.walkthrough){for(const s of e)if((t[s]||[]).map(c=>n[c]).find(c=>c&&c.repo_label===a.repo&&(c.branch||Gd)===a.branch)){l[s]||(l[s]={}),l[s][a.branch]||(l[s][a.branch]=[]),l[s][a.branch].push(a);break}}return l}const Vt=q(null),qe=q(null),Xe=q(null),Pt=q(""),ti=q("default"),ni=q("default"),ri=q("default"),ii=q("default");function qb(e){return(e==null?void 0:e.mode)==="agent"&&(e.agent||"claude")==="claude"}const Mi=q(null);function Jd(e,t){const n=new Map;for(const i of t||[]){if(i.track_id!==e)continue;const l=i.branch;l&&(n.has(l)||n.set(l,i.cwd||""))}return[...n.entries()].map(([i,l])=>({branch:i,cwd:l}))}function Ub(e,t,n,i){const l=[],a=new Set;for(const o of Jd(e,t))a.add(o.branch),l.push({...o,live:!0});if(!n||!i)return l;for(const o of i.worktrees||[])o.repo!==n||!o.branch||a.has(o.branch)||(a.add(o.branch),l.push({branch:o.branch,cwd:o.path,live:!1}));const s=(i.repos||[]).find(o=>o.repo===n);for(const o of(s==null?void 0:s.branches)||[])!o||a.has(o)||(a.add(o),l.push({branch:o,cwd:"",live:!1}));return l}function Wb(e,t,n=5){const i=[],l=new Set,a=s=>{!s||l.has(s.branch)||(l.add(s.branch),i.push(s))};a(e.find(s=>s.branch===t));for(const s of e)s.live&&a(s);for(const s of e){if(i.length>=n)break;a(s)}return i}function Kb(e,t){const n=String(t||"").toLowerCase().split(/[\s/]+/).filter(Boolean);return n.length?e.filter(i=>{const l=i.branch.toLowerCase();return n.every(a=>l.includes(a))}):[]}function Vb(e){const t=[{id:"claude",label:"Claude",mode:"agent",agent:"claude"},{id:"codex",label:"Codex",mode:"agent",agent:"codex"}],n=new Set(["claude","codex"]),i=(e||[]).filter(l=>!n.has((l.label||"").trim().toLowerCase())).map(l=>({id:`cmd:${l.label}`,label:l.label,mode:"shell",exec:l.exec||""}));return[...t,...i]}const Gb=Qt(()=>Ub(Vt.value,ce.value,ss(Vt.value),Mi.value));function ss(e){var t;return((t=(Ht.value||[]).find(n=>n.id===e))==null?void 0:t.repo)||null}function Jb(e){var n,i;const t=ss(e);return t&&((i=(((n=Mi.value)==null?void 0:n.repos)||[]).find(l=>l.repo===t))==null?void 0:i.default_branch)||null}function zo(e){var n,i,l;Vt.value=e;const t=Jd(e,ce.value);qe.value=t.length?t[0].branch:null,Xe.value=null,Pt.value="",ti.value=((n=dn.value)==null?void 0:n.account)||"default",ri.value=((i=dn.value)==null?void 0:i.model)||"default",ii.value=((l=dn.value)==null?void 0:l.effort)||"default",ni.value=b1(),ye("overlay.open",{which:"launcher"}),Mi.value=null,ie("open catalog","/api/open/catalog").then(a=>{Vt.value===e&&(Mi.value=a)})}function Dr(){Vt.value=null,qe.value=null,Xe.value=null,Pt.value=""}function jo(e){qe.value=e,Xe.value=null}function Qb(){qe.value=null,Xe.value=""}function Yb(){We(Dr,Vt.value!=null),H(()=>(window.__periscopeOpenLauncher=zo,()=>{window.__periscopeOpenLauncher===zo&&delete window.__periscopeOpenLauncher}),[]);const e=Vt.value;if(e==null)return null;const t=Vr(),n=Gb.value,i=ss(e),l=n.length>0||Xe.value!=null||!!i;async function a(p){const f=new URLSearchParams({session:e,agent:p.agent||"claude",mode:p.mode});p.mode==="shell"&&p.exec&&f.set("exec",p.exec),qb(p)&&f.set("account",ti.value);const m=_l(p)?Nb(ni.value):null;m&&f.set("profile",m),_l(p)&&f.set("model",ri.value),_l(p)&&f.set("effort",ii.value);const k=Xe.value;if(k!=null&&k.trim())f.set("branch",k.trim());else if(qe.value!=null){const x=n.find(b=>b.branch===qe.value);x!=null&&x.cwd?f.set("cwd",x.cwd):x&&f.set("branch",x.branch)}await ie("new window",`/api/window/new?${f.toString()}`,{method:"POST"}),Dr()}const s=Vb(t),o=s[0],c=Pt.value.trim(),u=c?Kb(n,c).slice(0,24):Wb(n,Jb(e)),h=qe.value!=null&&!u.some(p=>p.branch===qe.value)?n.find(p=>p.branch===qe.value):null,d=h?[h,...u]:u;return r("div",{id:"launcher-modal",class:"launcher-modal-overlay",onClick:p=>{p.target.id==="launcher-modal"&&Dr()},children:r("div",{class:"launcher-modal-card",children:[r("header",{class:"launcher-modal-head",children:[r("h2",{children:"+ New tab"}),r("button",{id:"launcher-close",title:"close",onClick:Dr,children:"×"})]}),r("p",{class:"launcher-modal-sub",id:"launcher-session-name",children:["Add to track: ",Pi(e,ce.value,Ht.value)]}),l&&r("div",{class:"launcher-section",children:[r("div",{class:"launcher-section-head",children:[r("div",{class:"launcher-section-label",children:"Branch"}),r("input",{class:"launcher-branch-search",type:"text",placeholder:n.length>1?`search ${n.length} branches…`:"search branches…",value:Pt.value,onInput:p=>{Pt.value=p.target.value},onKeyDown:p=>{if(p.key==="Escape"&&Pt.value)p.stopPropagation(),Pt.value="";else if(p.key==="Enter"){const f=d[0];f&&jo(f.branch)}}})]}),r("div",{class:"launcher-branches",children:[d.map(p=>r("button",{class:`launcher-branch${qe.value===p.branch?" is-active":""}${p.live?"":" is-dormant"}`,title:p.live?"running now":p.cwd||"no worktree yet",onClick:()=>jo(p.branch),children:["⎇ ",p.branch]},p.branch)),Xe.value==null?r("button",{class:"launcher-branch launcher-branch-new",onClick:Qb,children:"+ new branch…"}):r("input",{class:"launcher-branch-input is-active",type:"text",placeholder:"new-branch-name",ref:p=>p==null?void 0:p.focus(),value:Xe.value,onInput:p=>{Xe.value=p.target.value},onKeyDown:p=>{p.key==="Enter"&&o&&a(o)}})]}),c&&d.length===0&&r("div",{class:"launcher-empty",children:["No branch matches “",c,"”."]})]}),Mn()&&r("div",{class:"launcher-section",children:[r("div",{class:"launcher-section-label",children:"Account"}),r("div",{class:"launcher-branches",children:st.value.map(p=>r("button",{class:`launcher-branch${ti.value===p.id?" is-active":""}`,onClick:()=>{ti.value=p.id},children:p.label},p.id))})]}),r("div",{class:"launcher-section",children:[r("div",{class:"launcher-section-label",children:"Profile"}),r("div",{class:"launcher-branches",children:Vd.map(p=>r("button",{class:`launcher-branch${ni.value===p.id?" is-active":""}`,title:p.id==="full"?"the pipeline: superpowers, tom-workflow, codebase-health-check, plus the pipeline direction prompt":"tom-core alone, on the plugin set settings.json enables",onClick:()=>{ni.value=p.id,k1(p.id)},children:p.label},p.id))})]}),r("div",{class:"launcher-section",children:[r("div",{class:"launcher-section-label",children:"Model"}),r("div",{class:"launcher-branches",children:fr.map(p=>r("button",{class:`launcher-branch${ri.value===p.id?" is-active":""}`,title:p.id==="default"?"no override — whatever the account's settings.json picks (this launch only; the header pin is the standing default)":`spawn this launch on ${p.label} (ANTHROPIC_MODEL on the pane — a hand re-run claude there keeps it)`,onClick:()=>{ri.value=p.id},children:p.label},p.id))})]}),r("div",{class:"launcher-section",children:[r("div",{class:"launcher-section-label",children:"Effort"}),r("div",{class:"launcher-branches",children:Wa.map(p=>r("button",{class:`launcher-branch${ii.value===p?" is-active":""}`,title:p==="default"?"no override — Claude's own choice for the model; /effort works in the pane (this launch only; the header pin is the standing default)":`spawn this launch at ${p} (--effort on the pane's claude; /effort can still change it later)`,onClick:()=>{ii.value=p},children:p},p))})]}),r("div",{class:"launcher-section",children:[r("div",{class:"launcher-section-label",children:"Run"}),r("div",{id:"launcher-list",children:s.map((p,f)=>r("button",{class:`launcher-row${f===0?" is-default":""}`,"data-label":p.label,onClick:()=>a(p),children:[r("span",{class:"launcher-row-label",children:p.label}),f===0&&r("span",{class:"launcher-row-hint",children:"⏎"})]},p.id))})]})]})})}const Zb=/github\.com\/([^/]+\/[^/]+)\/pull\/(\d+)/,Xb=/^#?(\d+)$/;function ek(e){const t=e.match(Zb);if(t)return{repo:t[1],pr:Number(t[2])};const n=e.trim().match(Xb);return n?{repo:null,pr:Number(n[1])}:null}const tk=/^(~|\.{0,2}\/)/;function nk(e){const t=(e||"").trim();return!t||!tk.test(t)?null:t.replace(/\/+$/,"")||"/"}function en(e,t){return e.toLowerCase().includes(t.toLowerCase())}function rk(e,t){var s;const n=(e||"").trim(),i=[];if(!n)return i;"reviews".startsWith(n.toLowerCase())&&n.length>=2&&i.push({kind:"reviews",label:"Reviews · open branches and walkthroughs",sub:"the review queue",descriptor:null});const l=nk(n);l&&!(t.worktrees||[]).some(o=>o.path===l)&&i.push({kind:"open",label:`open path: ${l}`,sub:"register + open",descriptor:{path:l}});for(const o of t.repos||[])(en(o.label,n)||en(o.repo,n))&&i.push({kind:"worktree",label:`${o.label} · new worktree…`,sub:`off origin/${o.default_branch||"HEAD"}`,repo:o.repo,branches:o.branches,descriptor:null});for(const o of t.repos||[])(en(o.label,n)||en(o.repo,n))&&i.push({kind:"track",label:`${o.label} · new track…`,sub:"goal-scoped group",repo:o.repo,descriptor:null});for(const o of t.worktrees||[])if(en(o.path,n)||en(o.branch||"",n)){const c=((s=t.repos.find(u=>u.repo===o.repo))==null?void 0:s.label)||o.repo;i.push({kind:"open",label:`${c} · ${o.branch||"detached"}`,sub:o.path,descriptor:{path:o.path}})}const a=ek(n);return a&&i.push({kind:"pr",label:a.repo?`review PR #${a.pr} in ${a.repo}`:`review PR #${a.pr}`,sub:a.repo||"choose a repo",needsRepo:!a.repo,pr:a}),i.push({kind:"command",label:`⚡ run: ${n}`,text:n}),i}const ft=q(!1);function Ho(){ft.value=!0,ye("overlay.open",{which:"open"})}function Ct(){ft.value=!1}const qo={open:{group:"Open",icon:"▸"},worktree:{group:"New worktree",icon:"✦"},pr:{group:"Review PR",icon:"◆"},branch:{group:"Branches",icon:"⎇"},newbranch:{group:"Branches",icon:"+"},repo:{group:"Repositories",icon:"◳"},track:{group:"New track",icon:"▧"},command:{group:"Command",icon:"⚡"},reviews:{group:"Reviews",icon:"◉"}},ik=3e3;function lk(e){const[t,n]=N([]);return H(()=>{if(!e)return;let i=!0,l=null;const a=async()=>{const s=await ie("jobs","/api/command/jobs");i&&(Array.isArray(s)&&n(s),l=setTimeout(a,ik))};return a(),()=>{i=!1,l&&clearTimeout(l)}},[e]),t}function ak(e){const[t,n]=N(null);return H(()=>{if(!e){n(null);return}let i=!0;return n(null),(async()=>{const l=await ie("job-turns",`/api/command/jobs/${encodeURIComponent(e)}/turns`);i&&n((l==null?void 0:l.messages)||[])})(),()=>{i=!1}},[e]),{messages:t,pending:t===null}}function sk(e){if(e.role==="system")return"— context compacted —";const t=e.role==="user"?"❯":"⏺",n=e.tool_uses||[];if(n.length){const l=n[0],a=l.input||{},s=a.command||a.file_path||a.path||a.pattern||a.description||a.query||a.url||"",o=n.length>1?` +${n.length-1}`:"";return`${t} ${l.name||"tool"}${s?`(${s})`:""}${o}`}const i=String(e.text||"").split(`
+`).find(l=>l.trim())||"";return`${t} ${i}`}function ok(){We(Ct,ft.value);const[e,t]=N({repos:[],worktrees:[]}),[n,i]=N(""),[l,a]=N(null),[s,o]=N(!1),[c,u]=N(null),[h,d]=N(!1),[p,f]=N(""),[m,k]=N("claude");if(H(()=>{window.__periscopeOpenOmnibox=Ho;function $(v){(v.metaKey||v.ctrlKey)&&(v.key==="k"||v.key==="p")&&(v.preventDefault(),ft.value=!ft.value)}return document.addEventListener("keydown",$),()=>{document.removeEventListener("keydown",$),window.__periscopeOpenOmnibox===Ho&&delete window.__periscopeOpenOmnibox}},[]),H(()=>{ft.value&&(i(""),a(null),u(null),f(""),k("claude"),(async()=>{const $=await ie("open catalog","/api/open/catalog");$&&t($)})())},[ft.value]),!ft.value)return null;async function x($){if(h)return;d(!0),f("");const v=await ie("open","/api/open",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...$,agent:m})});if(d(!1),!v){f("open failed");return}h1(v.ui),v.agent_pid&&(ke.value=`pane:${v.agent_pid}`,bt({kind:"pane",pid:v.agent_pid})),Ct()}async function b($,v){if(!v)return;d(!0),f("");const E=await ie("create track","/api/tracks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({repo:$||null,name:v})});if(d(!1),!E){f("create track failed");return}Ct()}async function C($){d(!0),f("");const v=await ie("command","/api/command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:$})});if(d(!1),!v){f("command failed");return}u(null),o(!0)}function g($){if($.kind==="reviews"){Ua(),Ct();return}if($.kind==="open")return x($.descriptor);if($.kind==="command")return C($.text);if($.kind==="pr"&&!$.needsRepo)return x({repo:$.pr.repo,pr:$.pr.pr});a({card:$})}const y=rk(n,e).map($=>({...$,group:qo[$.kind].group,icon:qo[$.kind].icon,key:$.label}));return r("div",{id:"open-omnibox",class:"open-omnibox-overlay",onClick:$=>{$.target.id==="open-omnibox"&&Ct()},children:r("div",{class:"open-omnibox-card",children:[!s&&r("div",{class:"launcher-branches",children:["claude","codex"].map($=>r("button",{class:`launcher-branch${m===$?" is-active":""}`,onClick:()=>k($),children:$==="claude"?"Claude":"Codex"},$))}),!l&&!s&&r(rl,{value:n,onInput:i,placeholder:"repo, path, #PR…",items:y,onPick:g,onClose:Ct,empty:n?"no matches":e.roots&&!e.repos.length?`no repos found under ${e.roots.join(", ")} — add roots in ⚙ settings, or type a path`:"type a repo, path, or #PR…"}),s&&r(ck,{selectedJob:c,onSelect:u,onBack:c?()=>u(null):()=>{o(!1),i("")},onClose:Ct}),l&&l.card.kind==="worktree"&&r(dk,{card:l.card,onPick:$=>x({repo:l.card.repo,branch:$}),onBack:()=>a(null)}),l&&l.card.kind==="track"&&r(hk,{card:l.card,onPick:$=>b(l.card.repo,$),onBack:()=>a(null)}),l&&l.card.kind==="pr"&&r(fk,{repos:e.repos,onPick:$=>x({repo:$,pr:l.card.pr.pr}),onBack:()=>a(null)}),p&&r("div",{class:"open-omnibox-error",children:p}),h&&r("div",{class:"open-omnibox-busy",children:"opening…"})]})})}function ck({selectedJob:e,onSelect:t,onBack:n}){const i=lk(!e);return We(n,!0),e?r(uk,{jobId:e,onBack:n}):r("div",{class:"open-omnibox-jobs",children:[r("div",{class:"open-omnibox-jobs-head",children:"Commands"}),r("div",{class:"open-omnibox-list",children:[i.length===0&&r("div",{class:"open-omnibox-empty",children:"no commands yet"}),i.map(l=>r("button",{class:"open-omnibox-row",onClick:()=>t(l.id),children:[r("span",{class:`open-omnibox-jobdot${l.status==="running"?" is-running":""}`,children:l.status==="running"?"●":"✓"}),r("span",{class:"open-omnibox-label",children:l.text}),r("span",{class:"open-omnibox-sub",children:Pe(l.started_at)})]},l.id))]}),r("div",{class:"open-omnibox-footer",children:r("span",{children:[r("kbd",{children:"esc"})," back"]})})]})}function uk({jobId:e,onBack:t}){const{messages:n,pending:i}=ak(e);return r("div",{class:"open-omnibox-console",children:[r("div",{class:"open-omnibox-console-cmd",children:r("button",{class:"open-omnibox-jobback",onClick:t,children:"← back"})}),r("div",{class:"open-omnibox-console-log",children:[i&&r("div",{class:"open-omnibox-console-spin",children:"no transcript yet — the commander is still starting…"}),!i&&n.length===0&&r("div",{class:"open-omnibox-console-spin",children:"no transcript yet"}),!i&&n.map((l,a)=>r("div",{class:"open-omnibox-console-line",children:sk(l)},l.uuid||a))]})]})}function rl({value:e,onInput:t,placeholder:n,items:i,onPick:l,onBack:a,empty:s}){const[o,c]=N(0),u=J(null),h=J(null),d=i.length,p=Math.min(o,Math.max(0,d-1));H(()=>{const k=requestAnimationFrame(()=>{var x;return(x=h.current)==null?void 0:x.focus()});return()=>cancelAnimationFrame(k)},[]),H(()=>{c(0)},[e]),H(()=>{var k,x;(x=(k=u.current)==null?void 0:k.querySelector(".is-active"))==null||x.scrollIntoView({block:"nearest"})},[p,d]);function f(k){k.key==="ArrowDown"?(k.preventDefault(),c(Math.min(p+1,d-1))):k.key==="ArrowUp"?(k.preventDefault(),c(Math.max(p-1,0))):k.key==="Enter"?(k.preventDefault(),i[p]&&l(i[p])):k.key==="Escape"&&a&&(k.preventDefault(),k.stopPropagation(),a())}let m=null;return r(U,{children:[r("input",{class:"open-omnibox-input",ref:h,placeholder:n,value:e,onInput:k=>t(k.target.value),onKeyDown:f}),r("div",{class:"open-omnibox-list",ref:u,children:[d===0&&r("div",{class:"open-omnibox-empty",children:s}),i.map((k,x)=>{const b=k.group&&k.group!==m?r("div",{class:"open-omnibox-group",children:k.group},`g:${k.group}`):null;return m=k.group,r(U,{children:[b,r("button",{class:`open-omnibox-row${x===p?" is-active":""}`,onMouseMove:()=>c(x),onClick:()=>l(k),children:[k.icon&&r("span",{class:"open-omnibox-icon",children:k.icon}),r("span",{class:"open-omnibox-label",children:k.label}),k.sub&&r("span",{class:"open-omnibox-sub",children:k.sub})]},k.key||x)]})})]}),r("div",{class:"open-omnibox-footer",children:[r("span",{children:[r("kbd",{children:"↑"}),r("kbd",{children:"↓"})," navigate"]}),r("span",{children:[r("kbd",{children:"↵"})," ",a?"select":"open"]}),r("span",{children:[r("kbd",{children:"esc"})," ",a?"back":"close"]})]})]})}function dk({card:e,onPick:t,onBack:n}){const[i,l]=N(""),a=(e.branches||[]).filter(o=>o.toLowerCase().includes(i.toLowerCase())),s=a.map(o=>({key:o,group:"Branches",icon:"⎇",label:o,value:o}));return i&&!a.includes(i)&&s.push({key:`__new:${i}`,group:"Branches",icon:"+",label:`new branch "${i}"`,value:i}),r(rl,{value:i,onInput:l,placeholder:`branch in ${e.repo}…`,items:s,onPick:o=>t(o.value),onBack:n,empty:"type a new branch name…"})}function hk({card:e,onPick:t,onBack:n}){const[i,l]=N(""),a=i.trim(),s=a?[{key:`__tk:${a}`,group:"New track",icon:"▧",label:`create track "${a}"`,sub:e.repo,value:a}]:[];return r(rl,{value:i,onInput:l,placeholder:`name this track (repo: ${e.repo})…`,items:s,onPick:o=>t(o.value),onBack:n,empty:"type a track name…"})}function fk({repos:e,onPick:t,onBack:n}){const[i,l]=N(""),s=(e||[]).filter(o=>o.label.toLowerCase().includes(i.toLowerCase())||o.repo.toLowerCase().includes(i.toLowerCase())).map(o=>({key:o.repo,group:"Repositories",icon:"◳",label:o.label,sub:o.repo,value:o.repo}));return r(rl,{value:i,onInput:l,placeholder:"repo for this PR…",items:s,onPick:o=>t(o.value),onBack:n,empty:"no matching repo"})}function Uo({which:e,label:t,fonts:n}){return r("label",{children:[t,r("select",{name:`font-${e}`,value:hr(e).id,onChange:i=>v1(e,i.currentTarget.value),children:n.map(i=>r("option",{value:i.id,children:i.name},i.id))})]})}function pk(){return r("fieldset",{class:"font-picker",children:[r("legend",{children:"Fonts"}),r(Uo,{which:"ui",label:"Interface",fonts:yi}),r(Uo,{which:"code",label:"Code & terminal",fonts:yi.filter(e=>e.mono)})]})}const mk=[["needs_input","A session needs input"],["done","A session finishes"],["ci_failed","CI fails on a session's PR"],["pr_merged","A linked PR merges"],["usage","Usage projected past a limit"],["quiet_when_focused","Stay quiet while the dashboard is focused"],["group","Group when more than 2 arrive at once"],["badge","Dock badge counts sessions waiting on you"]];function gk(){const e=ki();return r("fieldset",{class:"notify-settings",children:[r("legend",{children:"Notifications"}),!Ve()&&r("p",{class:"settings-overrides-hint",children:"Notifications appear in the Periscope macOS app only."}),mk.map(([t,n])=>r("label",{class:"notify-option",children:[r("input",{type:"checkbox",name:`notify-${t}`,checked:e[t],onChange:i=>_1(t,i.currentTarget.checked)}),n]},t))]})}function yk({critter:e}){return r("svg",{class:"critter-preview",viewBox:e.sprite?"0 0 20 20":"-1.5 1 20 20",width:"40",height:"40","shape-rendering":"crispEdges","aria-hidden":"true",children:e.sprite?r(Zi,{sprite:e.sprite}):r(D2,{})})}function bk(){const e=Mu();return r("fieldset",{class:"tama-picker",children:[r("legend",{children:"Tamagotchi"}),r("div",{class:"tama-picker-options",children:gi.map(t=>r("label",{class:"tama-picker-option",children:[r("input",{type:"radio",name:"tama-critter",value:t.id,checked:t.id===e,onChange:()=>w1(t.id)}),r(yk,{critter:t}),r("span",{children:t.name})]},t.id))})]})}const on=q(!1);function Wo(){on.value=!0,ye("overlay.open",{which:"settings"})}function jn(){on.value=!1}function kk(){We(jn,on.value);const[e,t]=N(""),[n,i]=N(!1),[l,a]=N(14),[s,o]=N("sibling"),[c,u]=N([]),[h,d]=N(""),[p,f]=N([]),[m,k]=N("");H(()=>{const b=document.getElementById("settings-btn");return b&&b.addEventListener("click",Wo),()=>{b&&b.removeEventListener("click",Wo)}},[]),H(()=>{on.value&&(t(""),(async()=>{const{data:b,error:C}=await kr("load settings","/api/settings");if(C){t(C);return}const g=b.settings||{};a(g.cleanup_idle_days??14),o(g.worktree_layout_default??"sibling"),u(Object.entries(g.worktree_layout_overrides||{}).map(([y,$])=>({repo:y,layout:$}))),f(b.editors_available||[]),d(g.editor??""),k((g.repo_roots??["~/dev"]).join(`
+`))})())},[on.value]);async function x(b){b.preventDefault(),t("");const C=parseInt(l,10);if(!C||C<1){t("cleanup idle days must be a positive integer");return}const g={};for(const{repo:v,layout:E}of c)v&&E&&(g[v]=E);const y={cleanup_idle_days:C,worktree_layout_default:s,worktree_layout_overrides:g,editor:h||null,repo_roots:m.split(`
+`).map(v=>v.trim()).filter(Boolean)};i(!0);const{error:$}=await kr("save settings","/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(y)});if(i(!1),$){t($);return}jn()}return on.value?r("div",{id:"settings-modal",class:"settings-modal-overlay",onClick:b=>{b.target.id==="settings-modal"&&jn()},children:r("div",{class:"settings-modal-card",children:[r("header",{class:"settings-modal-head",children:[r("h2",{children:"🛠 settings"}),r("button",{id:"settings-modal-close",title:"close",onClick:jn,children:"×"})]}),r("form",{id:"settings-form",onSubmit:x,children:[r(pk,{}),r(bk,{}),r(gk,{}),r("label",{children:["Cleanup idle threshold (days)",r("input",{id:"settings-cleanup-idle-days",type:"number",min:"1",value:l,onInput:b=>a(b.currentTarget.value)})]}),r("label",{children:["Preferred editor",r("select",{id:"settings-editor",value:h,onChange:b=>d(b.currentTarget.value),children:[r("option",{value:"",children:"(none — hides the rail's ↗ action)"}),p.map(b=>r("option",{value:b,children:b},b))]})]}),r("label",{children:["Repo roots",r("textarea",{id:"settings-repo-roots",rows:3,spellcheck:!1,value:m,onInput:b=>k(b.currentTarget.value)})]}),r("p",{class:"settings-overrides-hint",children:"One directory per line. Repos one level under each are offered in ⌘K; a repo elsewhere can be opened once by typing its path there."}),r("label",{children:["Default worktree layout",r("select",{id:"settings-worktree-default",value:s,onChange:b=>o(b.currentTarget.value),children:[r("option",{value:"sibling",children:"sibling — ~/dev/worktrees//"}),r("option",{value:"inline",children:"inline — /.worktrees/"})]})]}),r("fieldset",{children:[r("legend",{children:"Per-repo overrides"}),r("div",{id:"settings-overrides-list",children:c.length===0?r("div",{class:"settings-overrides-empty",children:"(none yet)"}):c.map((b,C)=>r("div",{class:"settings-overrides-row","data-repo":b.repo,children:[r("span",{class:"settings-overrides-repo",children:b.repo}),r("select",{class:"settings-overrides-layout",value:b.layout,onChange:g=>{const y=g.currentTarget.value;u($=>$.map((v,E)=>E===C?{...v,layout:y}:v))},children:[r("option",{value:"sibling",children:"sibling"}),r("option",{value:"inline",children:"inline"})]}),r("button",{type:"button",class:"settings-overrides-remove",title:"remove override",onClick:()=>u(g=>g.filter((y,$)=>$!==C)),children:"×"})]},b.repo))}),r("p",{class:"settings-overrides-hint",children:["Auto-detected on first ",r("code",{children:"+ project"})," per repo. Edit or remove rows here."]})]}),r("div",{id:"settings-modal-error",class:"settings-modal-error",hidden:!e,children:e}),r("div",{class:"settings-modal-actions",children:[r("button",{type:"button",id:"settings-cancel",onClick:jn,children:"cancel"}),r("button",{type:"submit",id:"settings-submit",disabled:n,children:"save"})]})]})]})}):null}function wk(){return H(()=>{I1(),"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js",{scope:"/"}).catch(()=>{})},[]),r(U,{children:[r(Fb,{}),r(Db,{}),r(kk,{}),r(Yb,{}),r(ok,{}),r(yy,{})]})}const Ko=120,vk=3600,aa=e=>`${e.repo_slug||e.repo_key||""}#${e.pr}`;function Vo(e){let t=0;for(const n of e.message||"")t=t*31+n.codePointAt(0)|0;return`question:${e.pane_id||e.target}@${e.ts}:${(t>>>0).toString(36)}`}const Rr={calm:0,grumpy:1,furious:2};function xk(e,t,n){const{windows:i=[],alerts:l=[],dismissedAlertIds:a=new Set,dismissedNeedsPids:s=new Set,dismissedReadyPids:o=new Set,plan:c={}}=t,u=!e,h=(e==null?void 0:e.pass)??0,d=h+1,p=(e==null?void 0:e.seen)||{},f=new Set;for(const[T,S]of Object.entries(p))typeof S=="number"&&S<=h&&h-S<=Ko&&f.add(T);const m={},k=[],x=(T,S)=>{m[T]=d,!u&&!f.has(T)&&k.push({key:T,...S})},b=T=>{m[T]=d},C=za(i,l,a,s),g=new Set;for(const T of C)T.kind==="live"&&(g.add(T.w.pid),x(`needs:${T.w.pid}@${T.w.needs_since||0}`,{kind:"needs_input",w:T.w}));for(const T of i)T.state==="needs-input"&&s.has(T.pid)&&b(`needs:${T.pid}@${T.needs_since||0}`);for(const T of C){if(T.kind!=="event")continue;const S=Vo(T);T.w&&g.has(T.w.pid)?(u||f.has(S))&&b(S):x(S,{kind:"question",w:T.w,alert:T})}for(const T of l)T.kind==="need_human"&&a.has(T.id)&&b(Vo(T));for(const T of i){if(T.state!=="done")continue;const S=`done:${T.pid}@${T.completed_at||0}`;o.has(T.pid)?b(S):x(S,{kind:"done",w:T})}const y={};for(const[T,S]of Object.entries((e==null?void 0:e.prAt)||{}))d-S<=vk&&(y[T]=S);const $={},v={};for(const T of Object.keys(y))T in((e==null?void 0:e.ci)||{})&&($[T]=e.ci[T]),T in((e==null?void 0:e.prs)||{})&&(v[T]=e.prs[T]);const E=new Map;for(const T of i){if(!T.pr||T.pr_linked&&!T.pr_state)continue;const S=aa(T);(!E.has(S)||T.pr_state&&!E.get(S).pr_state)&&E.set(S,T)}for(const[T,S]of E){y[T]=d;const O=(!S.pr_state||S.pr_state==="open")&&S.ci||null;!u&&T in $&&$[T]!=="✗"&&O==="✗"&&k.push({key:`ci:${T}`,kind:"ci_failed",w:S}),$[T]=O,S.pr_state&&(!u&&v[T]==="open"&&S.pr_state==="merged"&&k.push({key:`merged:${T}`,kind:"pr_merged",w:S}),v[T]=S.pr_state)}const M={};for(const[T,S]of Object.entries((e==null?void 0:e.meters)||{}))Number(T.slice(T.lastIndexOf("/")+1))*60>n&&(M[T]=S);for(const[T,S]of Object.entries(c||{})){if(!(S!=null&&S.available)||!S.meters||!u&&Qa(S,n))continue;let L=null;for(const[O,j]of Object.entries(S.meters)){if(!(j!=null&&j.resets_at))continue;const I=ad(j),D=`${T}/${O}/${Math.round(j.resets_at/60)}`,R=M[D]??0;M[D]=Math.max(R,Rr[I]),!u&&Rr[I]>R&&(!L||Rr[I]>Rr[L.mood])&&(L={key:`usage:${D}:${I}`,kind:"usage",account:T,meter:O,m:j,mood:I})}L&&k.push(L)}for(const T of f)!(T in m)&&d-p[T]<=Ko&&(m[T]=p[T]);return{state:{pass:d,seen:m,ci:$,prs:v,prAt:y,meters:M},events:k}}const nr=(e,t)=>{const n=String(e||"").trim(),i=Array.from(n);return i.length>t?`${i.slice(0,t-1).join("")}…`:n},Sl=e=>nr(xe(e),26),Hn=e=>[e==null?void 0:e.session,e==null?void 0:e.branch].filter(Boolean).join(" · "),$l=e=>!!(e!=null&&e.pid&&e.agent==="claude"),Go=e=>{const t=/^mcp__(.+?)__(.+)$/.exec(e||"");return t?`${t[2]} (${t[1]})`:e||"this"};function _k(e){const t=String(e||"").replace(/\s+/g," ").trim(),n=t.match(/^.*?[.!?](?=\s[A-Z0-9]|$)/);return nr(n?n[0]:t,140)}const Jo={permission:"Waiting for your approval.",question:"Waiting for your answer.",dialog:"Waiting for your input."},Sk={failure:"✗",pending:"⟳",success:"✓"},Qd=e=>`usage_to_${e}`;function Yd(e,t={}){var l,a;const n=e.w,i={kind:e.kind,thread:e.kind,target:(n==null?void 0:n.target)||"",data:{}};switch(e.kind){case"needs_input":{const s=n.pending_permission;return s!=null&&s.request_id&&n.pid?{...i,title:`${Sl(n)} needs you`,subtitle:Hn(n),body:s.summary?`Allow ${Go(s.tool)}: ${s.summary}?`:`Allow ${Go(s.tool)}?`,category:"needs_permission",data:{open:"pane",pid:n.pid,request_id:s.request_id}}:{...i,title:`${Sl(n)} needs you`,subtitle:Hn(n),body:Jo[$u(n.waiting_for)]||Jo.dialog,category:"needs_dialog",data:{open:"pane",pid:n.pid}}}case"question":{const s=e.alert;return{...i,title:`${nr(n?xe(n):s.name||s.session||"A session",26)} asks`,subtitle:n?Hn(n):s.session||"",body:nr(s.message,180),target:s.target||i.target,...$l(n)?{category:"question"}:{},data:{open:"pane",pid:(n==null?void 0:n.pid)??null}}}case"done":return{...i,title:`${Sl(n)} is done`,subtitle:n.pr&&n.pr_linked?`${n.session} · PR #${n.pr}`:Hn(n),body:_k(n.last_reply||n.recap||n.last_line)||"Finished.",category:"done_seen",data:{open:"pane",pid:n.pid,session:n.session}};case"ci_failed":{const s=(n.ci_checks||[]).map(h=>`${Sk[h.state]||"·"} ${h.name}`).join(" · "),o=cr(n.repo_slug,n.pr),c=$l(n)?n:(t.windows||[]).find(h=>$l(h)&&aa(h)===aa(n));let u;return c!=null&&c.pid&&o?u="ci_failed":c!=null&&c.pid?u="ci_failed_fix":o&&(u="ci_failed_pr"),{...i,title:`CI failed on #${n.pr}`,subtitle:[n.session,xe(n)].filter(Boolean).join(" · "),body:s||"Checks are failing.",...u?{category:u}:{},data:{open:"url",url:o,pid:(c==null?void 0:c.pid)||n.pid,pr:n.pr,checks:(n.ci_checks||[]).filter(h=>h.state==="failure").map(h=>h.name)}}}case"pr_merged":{const s=cr(n.repo_slug,n.pr);let o;return n.cwd&&s?o="pr_merged":n.cwd?o="pr_merged_cleanup":s&&(o="pr_merged_pr"),{...i,title:`PR #${n.pr} merged`,subtitle:n.pr_base?`${n.session} · ${n.branch} → ${n.pr_base}`:Hn(n),body:"The worktree and its session can be cleaned up.",...o?{category:o}:{},data:{open:"url",url:s,pid:n.pid,cwd:n.cwd}}}case"usage":{const s=t.accounts||[],o=nr(((l=s.find(f=>f.id===e.account))==null?void 0:l.label)||e.account,16),c=s.length>1,u=Math.max(...[e.m.projected_percent,e.m.projected_recent].filter(f=>f!=null),-1),h=(t.windows||[]).filter(f=>f.state==="working"&&f.account===e.account).length,d=(a=t.moveTargets)==null?void 0:a[e.account],p=d&&d!==e.account;return{...i,target:"",title:c?`Account ${o} is running hot`:"Usage is running hot",subtitle:`${Za(e.meter)} usage ${Math.round(e.m.percent??0)}%`+(u>=0?` · →${Math.round(u)}% at reset`:""),body:c?`${Sn(h,"session")} working on ${o}.`:`${Sn(h,"session")} working.`,category:p?Qd(d):"usage",data:p?{open:"usage",spawn_to:d}:{open:"usage"}}}default:return null}}const it=(e,t,n={})=>Object.freeze({id:e,title:t,...n}),Qo=it("open_pr","Open PR"),$k=it("mark_seen","Mark seen"),Yo=it("cleanup","Clean up worktree",{foreground:!0}),Ck=it("details","Details",{foreground:!0}),Tk=it("open","Open",{foreground:!0}),Zo=it("fix","Ask agent to fix",{auth:!0});function Ek({accounts:e=[],moveTargets:t={}}={}){const n=[{id:"done_seen",actions:[$k]},{id:"ci_failed_pr",actions:[Qo]},{id:"pr_merged",actions:[Yo]},{id:"pr_merged_cleanup",actions:[Yo]},{id:"pr_merged_pr",actions:[Qo]},{id:"usage",actions:[Ck]},{id:"needs_permission",actions:[it("allow","Allow",{auth:!0})]},{id:"needs_dialog",actions:[Tk]},{id:"question",actions:[it("send","Reply",{auth:!0,reply:{button:"Send",placeholder:"Reply…"}})]},{id:"ci_failed",actions:[Zo]},{id:"ci_failed_fix",actions:[Zo]}];for(const i of[...new Set(Object.values(t||{}))].sort())n.push({id:Qd(i),actions:[it("spawn_on",`Spawn on ${vn(i,e||[])}`)]});return n}const Pk=Object.freeze({openExternal:Qi,openUsageDetails:Wd,pickSpawnAccount:Wu,openCleanupModal:Kd,markReadySeen:zu,selectPane:ot,revealPane:Ut,post:s1,toast:_n,notify:Iu}),Mk={allow:"Allow",deny:"Deny",send:"Reply",fix:"Ask agent to fix"},Ak={allow:"Couldn't allow",deny:"Couldn't deny",send:"Couldn't send your reply",fix:"Couldn't ask the agent to fix"},Lk=new Set(["allow","deny"]),Ik={"/api/pane/permission":"The dialog changed — open the pane to answer it.","/api/pane/reply":"The pane has a dialog open, or isn't running an agent — open it to see why."};function Ok(e,t){return(t==null?void 0:t.status)===404?"The pane is gone.":(t==null?void 0:t.status)===0?"Periscope isn't answering.":(t==null?void 0:t.status)===409?typeof t.detail=="string"&&t.detail!==`HTTP ${t.status}`?t.detail:Ik[e]:(t==null?void 0:t.detail)||"No answer"}const Dk=e=>{const t=e.codePointAt(0);return t!==9&&t!==10&&(t<32||t>=127&&t<=159)},Rk=e=>[...String(e)].filter(t=>!Dk(t)).join("").trim();function Fk(e,t){const n=(t||[]).map(Rk).filter(Boolean),i=n.length?`${n.join(" · ")}.`:"Checks are failing.";return`CI failed on #${e}: ${i} Please investigate and fix.`}async function Cl({target:e,show:t},n,i,l,a){let s=!1;const o=c=>{s||(s=!0,Promise.resolve().then(()=>a.notify({kind:"notice",thread:"notice",title:Ak[n],body:c,target:e,data:{open:"pane",pid:l.pid},quiet_when_focused:!0})).catch(u=>console.error("[notify] follow-up failed",u)))};try{if(!l.pid||Lk.has(n)&&!l.request_id){o("Open the pane to answer it."),t();return}const c=await a.post(i,l);if(c!=null&&c.ok)return;const u=Ok(i,c);o(u),t(),(c==null?void 0:c.status)!==409&&a.toast(`${Mk[n]} failed: ${(c==null?void 0:c.detail)||"no answer"}`,"bad",6e3)}catch(c){console.error("[notify] action failed",n,c),o((c==null?void 0:c.message)||"Periscope isn't answering.");try{t()}catch(u){console.error("[notify] reveal failed",u)}}}function Nk({target:e,action:t,text:n,data:i}={},l=Pk){i||(i={});let a;const s=()=>a?l.selectPane(a):e&&l.revealPane(e);try{switch(a=i.pid?(ce.peek()||[]).find(o=>String(o.pid)===String(i.pid)):null,t){case"open_pr":i.url?l.openExternal(i.url):s();return;case"details":l.openUsageDetails();return;case"spawn_on":i.spawn_to&&l.pickSpawnAccount(i.spawn_to);return;case"mark_seen":a&&l.markReadySeen(a);return;case"cleanup":{const o=i.cwd||(a==null?void 0:a.cwd);o?l.openCleanupModal({paths:[o]}):s();return}case"allow":case"deny":return Cl({target:e,show:s},t,"/api/pane/permission",{pid:i.pid,request_id:i.request_id,choice:t},l);case"send":{const o=String(n||"").trim();return o?Cl({target:e,show:s},t,"/api/pane/reply",{pid:i.pid,text:o},l):void 0}case"fix":return Cl({target:e,show:s},t,"/api/pane/reply",{pid:i.pid,text:Fk(i.pr,i.checks)},l);case"open":s();return;default:console.warn("[notify] unknown action",t)}}catch(o){console.error("[notify] action failed",t,o);try{s()}catch(c){console.error("[notify] reveal failed",c)}}}const sa=3e3,Bk=2,zk=new Set(["needs_input","question"]);function jk(e,t,n,i=!0){const l=t.filter(o=>n-o{var t;return e.kind==="question"?"question":$u((t=e.w)==null?void 0:t.waiting_for)==="permission"?"permission":"input"};function qk(e){var n,i;const t=new Set(e.map((l,a)=>{var s,o;return((s=l.w)==null?void 0:s.pid)??((o=l.alert)==null?void 0:o.pane_id)??a})).size;return{kind:"summary",thread:"needs_you",target:"",data:{open:"pane",pid:((i=(n=e[0])==null?void 0:n.w)==null?void 0:i.pid)??null},title:t===1?"1 more session needs you":`${t} more sessions need you`,subtitle:"",body:e.map(l=>{var a;return`● ${l.w?xe(l.w):((a=l.alert)==null?void 0:a.name)||"a session"} · ${Hk(l)}`}).join(`
+`)}}function Zd(e,t,n){if(e.length===1)try{const i=t(e[0],n);if(i)return i}catch(i){console.error("[notify] banner failed",e[0].key,i)}return qk(e)}const Xd="periscope.notify.v1",Uk=15*60*1e3;function Wk(e,t){try{const n=JSON.parse((e==null?void 0:e.getItem(Xd))||"null");if(!(n!=null&&n.state)||!(n.at<=t)||t-n.at>Uk)return null;const i=Array.isArray(n.held)?n.held:[];return{state:n.state,held:i,heldSince:i.length?n.heldSince??n.at:null}}catch{return null}}function Kk(e,t,n,i=[],l=null){try{e==null||e.setItem(Xd,JSON.stringify({at:n,state:t,held:i,heldSince:l}))}catch{}}const Vk={question:"needs_input"},Gk=(e,t)=>e[Vk[t]||t]!==!1;function Jk({target:e,data:t}={}){if(t||(t={}),t.open==="url"&&t.url){Qi(t.url);return}if(t.open==="usage"){Wd();return}const n=t.pid!=null&&(ce.value||[]).find(i=>String(i.pid)===String(t.pid));n?ot(n):Ut(e)}const Qk={sends:[],flush:[],badge:null};function Yk(e,t,n,i,l=Yd){let{state:a,recent:s,held:o,heldSince:c,lastBadge:u,lastCategories:h}=e;const d={quiet_when_focused:n.quiet_when_focused},p=[],f={accounts:t.accounts,windows:t.windows,moveTargets:t.moveTargets};o.length&&i-c>=sa&&(p.push({...Zd(o,l,f),...d}),o=[],c=null);let m=null;const k=y=>({state:a,recent:s,held:o,heldSince:c,lastBadge:u,lastCategories:h,...Qk,flush:p,categories:m,timerAt:o.length?c+sa:null,...y});if(t.alerts===null)return k();try{const y=Ek({accounts:t.accounts,moveTargets:t.moveTargets}),$=JSON.stringify(y);$!==h&&(m=y,h=$)}catch(y){console.error("[notify] category set failed",y)}const x=Fu(t.windows,t.alerts,t.dismissedAlertIds,t.dismissedNeedsPids,i/1e3),b=n.badge?x.size:0,C=b===u?null:b;if(u=b,!a&&(!t.windows.length||e.editing))return k({badge:C});const g=[];if(!e.editing){const y=xk(a,t,i/1e3);a=y.state;const $=jk(y.events.filter(v=>Gk(n,v.kind)),s,i,n.group);s=$.recent;for(const v of $.now){let E=null;try{E=l(v,f)}catch(M){console.error("[notify] banner failed",v.key,M)}E&&g.push({...E,...d})}$.held.length&&(o=[...o,...$.held],c??(c=i))}return k({sends:g,badge:C})}const Zk=2e3;function Xk(e={setNotifyCategories:L1,notify:Iu}){let t=Promise.resolve();return(n,i)=>{n&&(t=t.then(()=>Promise.race([e.setNotifyCategories(n),new Promise(l=>setTimeout(l,Zk))])).catch(l=>console.error("[notify] registration failed",l))),i.length&&(t=t.then(()=>{for(const l of i)try{e.notify(l)}catch(a){console.error("[notify] post failed",a)}}))}}let Xo=!1;function ew(){if(Xo||!Ve())return;Xo=!0;const e=typeof localStorage>"u"?null:localStorage,t=Wk(e,Date.now());let n={state:null,held:[],heldSince:null,...t,recent:[],lastBadge:void 0,lastCategories:void 0};const i=c=>Kk(e,n.state,c,n.held,n.heldSince),l=Xk();let a=null,s=null;const o=()=>{a=null,s=null;const c=n.held;if(n={...n,held:[],heldSince:null},!c.length)return;n.state&&i(Date.now());const u={accounts:st.peek(),windows:ce.peek()||[],moveTargets:hi.peek()};l(null,[{...Zd(c,Yd,u),quiet_when_focused:ki().quiet_when_focused}])};M1(Jk),A1(c=>Nk(c)),at(()=>{zc.value,Ri(()=>{var c;try{const u={windows:ce.peek()||[],alerts:ar.peek(),dismissedAlertIds:or.peek(),dismissedNeedsPids:pt.peek(),dismissedReadyPids:mt.peek(),plan:((c=zi.peek())==null?void 0:c.plan)||{},accounts:st.peek(),moveTargets:hi.peek()},h=!!(Sa.peek()||Mt.peek()),d=Date.now(),p=n,{sends:f,flush:m,badge:k,categories:x,timerAt:b,...C}=Yk({...n,editing:h},u,ki(),d);n=C,n.state&&(n.state!==p.state||n.held!==p.held)&&i(d),l(x,[...m,...f]),b==null?(a&&clearTimeout(a),a=null,s=null):b!==s&&(a&&clearTimeout(a),s=b,a=setTimeout(o,Math.max(0,b-d))),k!==null&&E1(k)}catch(u){console.error("[notify] pass failed",u)}})})}const tw=3e3,nw=2e3;let Ai=0;function eh(){return document.getElementById("connection-banner")}function th(e){try{if(ar.value=e.alerts||[],Sa.value||Mt.value)return;ce.value=e.windows||[],Ni.value=e.projects||[],Bi.value=e.workspaces||[],Ht.value=e.tracks||[],Kh(ce.value),zi.value={plan:e.usage_plan,fallback:e.usage,poke:e.poke||{}},xa.value=e.update||null,Fc.value=e.resources||null,st.value=e.accounts||[],hi.value=e.move_targets||{},Qn.value=e.spawn_account||null,Yn.value=e.spawn_model||null,Zn.value=e.spawn_effort||null,dn.value=e.launch_default||null,Nc.value=e.walls||null,_a.value=e.wall_spans||[],Bc.value=e.editor||""}finally{zc.value+=1}}function nh(){if(Ai>0){Ai=0;const e=eh();e&&(e.hidden=!0),document.body.classList.remove("disconnected")}}function rh(e){if(Ai+=1,Ai>=2){const t=eh();t&&(t.hidden=!1),document.body.classList.add("disconnected")}e&&console.warn("[periscope]",e)}async function rw(){if(!Sa.value&&!Mt.value)try{const e=await fetch("/api/state");if(!e.ok)throw new Error(`HTTP ${e.status}`);th(await e.json()),nh()}catch(e){rh(`poll failed: ${e.message}`)}}let Tl=!1,oa=!1,rr=null,Rt=null,bn=null;function iw(){if(Rt)return;const e=async()=>{await rw(),Rt!==null&&(Rt=setTimeout(e,tw))};Rt=setTimeout(e,0)}function ih(){Rt&&(clearTimeout(Rt),Rt=null)}const lw=1e4;let Ft=null,ec=0;async function il(){const e=++ec;try{const t=await fetch("/api/reviews");if(!t.ok)return;const n=await t.json();e===ec&&(yt.value=n.rows||[])}catch{}}function aw(){if(Ft)return;const e=async()=>{await il(),Ft!==null&&(Ft=setTimeout(e,lw))};Ft=setTimeout(e,0)}function sw(){Ft&&(clearTimeout(Ft),Ft=null)}function lh(){const e=location.protocol==="https:"?"wss:":"ws:",t=new WebSocket(`${e}//${location.host}/ws/state`);rr=t,t.onmessage=n=>{ih();try{th(JSON.parse(n.data)),nh()}catch(i){rh(`bad frame: ${i.message}`)}},t.onclose=()=>{oa||(rr=null,iw(),bn||(bn=setTimeout(()=>{bn=null,lh()},nw)))},t.onerror=()=>{try{t.close()}catch{}}}function ow(){return Tl?()=>{}:(Tl=!0,oa=!1,lh(),aw(),()=>{if(oa=!0,sw(),Tl=!1,rr){try{rr.close()}catch{}rr=null}ih(),bn&&(clearTimeout(bn),bn=null)})}const cw=/[A-Za-z0-9_]+|\s+|[^A-Za-z0-9_\s]/g;function tc(e){return String(e??"").match(cw)||[]}function uw(e,t){let n=0;for(;n{const k=[],x=(b,C)=>{if(!b)return;const g=k[k.length-1];g&&g.changed===C?g.text+=b:k.push({text:b,changed:C})};return x(p.slice(0,f).join(""),!1),x(p.slice(f,m).join(""),!0),x(p.slice(m).join(""),!1),k},h=u(i,a,i.length-s),d=u(l,a,l.length-s);return!h.some(p=>p.changed)&&!d.some(p=>p.changed)?null:{del:h,add:d}}function fw(e,t=.5){const n=e.map(l=>({...l}));let i=0;for(;i0&&s===o)for(let c=0;ci?a:i+1}return n}const pw=["dist/","build/","vendor/",".next/","target/debug/","target/release/"],mw=new Set(["package-lock.json","yarn.lock","pnpm-lock.yaml","uv.lock","poetry.lock","Cargo.lock","Gemfile.lock","composer.lock","go.sum"]),gw=[".min.js",".min.css",".map",".snap"];function ah(e){const t=String(e||"");if(!t)return!1;const n=t.split("/").pop()||"";if(mw.has(n)||gw.some(l=>n.endsWith(l)))return!0;const i=`${t}/`;return pw.some(l=>i.includes(`/${l}`)||i.startsWith(l))}function yw(e){const t=[],n=[];for(const i of e||[])(ah(i.path)?n:t).push(i);return t.concat(n)}const ca=q({}),bw="\0";function sh(e,t){return`${e}${bw}${t}`}function oh(e,t,n,i,l=!1){const a=e[sh(t,n)];if(!a)return{collapsed:l,viewed:!1};const s=!!a.viewedSig&&a.viewedSig===i;return{collapsed:a.collapsed===void 0?l:a.collapsed,viewed:s}}function ch(e,t,n){const i=sh(e,t),l={...ca.value},a={...l[i]||{},...n};a.collapsed===void 0&&!a.viewedSig?delete l[i]:l[i]=a,ca.value=l}function kw(e,t,n){ch(e,t,{collapsed:n})}function ww(e,t,n,i){ch(e,t,{viewedSig:i?n:void 0,collapsed:!!i})}function vw(e,t,n){return n.reduce((i,l)=>i+(oh(e,t,l.path,l.sig).viewed?1:0),0)}const xw=[["session","This session","Changes since the current Claude session started"],["branch","This branch","Changes vs where this branch forked"]],_w={js:"js",mjs:"js",cjs:"js",jsx:"jsx",ts:"ts",tsx:"tsx",py:"py",rs:"rs",json:"json",css:"css",html:"html",htm:"html",md:"md",markdown:"md"};function uh(e){const t=(e||"").split("/").pop()||"",n=t.lastIndexOf(".");return n>0&&_w[t.slice(n+1).toLowerCase()]||""}function nc({text:e,lang:t,hl:n}){if(!n||!t)return e||" ";try{return n(e,t)}catch{return e||" "}}function Sw({line:e,lang:t,hl:n}){return r("div",{class:`dl dl-${e.kind}`,children:r("span",{class:"dl-text",children:e.segs?e.segs.map((i,l)=>r("span",{class:i.changed?"dl-intra":"",children:r(nc,{text:i.text,lang:t,hl:n})},l)):r(nc,{text:e.text,lang:t,hl:n})})})}function dh({hunk:e,lang:t,hl:n,onOpen:i,title:l}){return r("div",{class:"dhunk",children:[r("button",{type:"button",class:"dhunk-head",disabled:!i,title:i?l:void 0,onClick:()=>i==null?void 0:i(e.new_start),children:[r("span",{class:"dhunk-range",children:["@@ ",e.new_start]}),e.header?r("span",{class:"dhunk-sym",children:e.header}):null]}),fw(e.lines).map((a,s)=>r(Sw,{line:a,lang:t,hl:n},s))]})}function $w({file:e,repo:t,review:n,hl:i}){const l=ah(e.path),{collapsed:a,viewed:s}=oh(n,t,e.path,e.sig,l),o=!a,c=uh(e.path),u=t&&e.status!=="deleted"&&e.status!=="binary",h=(e.additions||0)+(e.deletions||0);return r("div",{class:`dfile dfile-${e.status}${s?" is-viewed":""}${l?" is-generated":""}`,children:[r("div",{class:"dfile-head",children:[r("button",{type:"button",class:"dfile-toggle",onClick:()=>kw(t,e.path,o),children:[r("span",{class:"dfile-caret",children:o?"▾":"▸"}),r("span",{class:"dfile-path",children:e.path}),l?r("span",{class:"dfile-gen",title:"Generated artifact — folded by default and sorted last",children:"generated"}):null,r("span",{class:"dfile-status",children:e.status}),r("span",{class:"dfile-stat",children:[e.additions?r("span",{class:"dstat-add",children:["+",e.additions]}):null,e.deletions?r("span",{class:"dstat-del",children:["−",e.deletions]}):null,!h&&e.status==="binary"?r("span",{class:"dstat-bin",children:"binary"}):null]})]}),r("button",{type:"button",class:`dfile-viewed${s?" is-on":""}`,title:s?"Marked viewed — re-surfaces automatically if this file changes again":"Mark viewed (folds it away until it changes again)",onClick:()=>ww(t,e.path,e.sig,!s),children:s?"✓ viewed":"viewed"})]}),o&&e.hunks.map((d,p)=>r(dh,{hunk:d,lang:c,hl:i,onOpen:u?f=>wr({path:`${t}/${e.path}`,line:f}):null,title:`Open ${e.path}:${d.new_start}`},p)),o&&e.truncated?r("div",{class:"dfile-trunc",children:"diff truncated — open the file to see the rest"}):null]})}const Cw=[3,10,25];function Tw({target:e,active:t,gitSig:n}){var x,b,C;const[i,l]=N("session"),[a,s]=N(3),[o,c]=N({loading:!0,error:null,data:null}),[u,h]=N(null);H(()=>{if(!t||u)return;let g=!0;return nl(()=>import("./chunks/preview.js").then(y=>y.h),[]).then(y=>{g&&h(()=>y.highlightCode)}).catch(()=>{}),()=>{g=!1}},[t,u]),H(()=>{if(!t||!e)return;let g=!0;return(async()=>{try{const y=await fetch(`/api/fs/diff?${nt(e)}&scope=${i}&context=${a}`);if(!g)return;if(!y.ok){const $=await y.json().catch(()=>({}));c({loading:!1,error:$.detail||`HTTP ${y.status}`,data:null});return}c({loading:!1,error:null,data:await y.json()})}catch(y){g&&c({loading:!1,error:String(y),data:null})}})(),()=>{g=!1}},[e,i,t,n,a]);const d=yw(((x=o.data)==null?void 0:x.files)||[]),p=((b=o.data)==null?void 0:b.repo)||"",f=ca.value,m=vw(f,p,d),k=d.reduce((g,y)=>({a:g.a+(y.additions||0),d:g.d+(y.deletions||0)}),{a:0,d:0});return r("div",{class:"changes-tab",children:[r("header",{class:"changes-head",children:[r("span",{class:"changes-scope",children:xw.map(([g,y,$])=>r("button",{type:"button",class:i===g?"is-active":"",title:$,onClick:()=>l(g),children:y},g))}),r("span",{class:"changes-ctx",title:"Lines of context around each change",children:Cw.map(g=>r("button",{type:"button",class:a===g?"is-active":"",onClick:()=>s(g),children:g},g))}),!o.loading&&!o.error&&r("span",{class:"changes-summary",children:d.length?r(U,{children:[m?`${m}/${d.length} viewed · `:`${d.length} file${d.length===1?"":"s"} · `,r("span",{class:"dstat-add",children:["+",k.a]})," ",r("span",{class:"dstat-del",children:["−",k.d]})]}):"no changes"})]}),r("div",{class:"changes-body",children:[o.loading?r("div",{class:"changes-msg",children:"loading…"}):null,o.error?r("div",{class:"changes-msg changes-err",children:o.error}):null,!o.loading&&!o.error&&!d.length?r("div",{class:"changes-msg",children:i==="session"?"Nothing changed on disk since this session started.":"This branch matches its fork point."}):null,d.map(g=>r($w,{file:g,repo:p,review:f,hl:u},g.path)),(C=o.data)!=null&&C.truncated?r("div",{class:"changes-msg",children:[o.data.truncated," more file",o.data.truncated===1?"":"s"," not shown"]}):null]})]})}const Ew=new Set(["Read","Edit","Write","MultiEdit","NotebookEdit"]),Pw=new Set(["html","md"]);function Mw(e,t){const n=(t||"").trim();if(!n)return!0;const i=(e||"").toLowerCase();if(!/[*?]/.test(n))return i.includes(n.toLowerCase());const l=n.split("**").map(a=>a.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,"[^/]*").replace(/\?/g,"[^/]")).join(".*");return new RegExp(`(?:^|/)${l}$`,"i").test(i)}function Aw(e){const t=(e||"").split("/").pop()||"",n=t.lastIndexOf(".");return n>0?t.slice(n+1).toLowerCase():""}function Lw(e,t=Pw){const n=[],i=[];for(const l of e)(t.has(Aw(l.path))?n:i).push(l);return{priority:n,others:i}}function Iw(e){if(!Array.isArray(e)||e.length===0)return[];const t=new Map;for(let n=e.length-1;n>=0;n--){const i=e[n],l=i==null?void 0:i.tool_uses;if(l!=null&&l.length)for(let a=l.length-1;a>=0;a--){const s=l[a];if(!s||!Ew.has(s.name))continue;const o=s.input&&(s.input.file_path||s.input.notebook_path);o&&(t.has(o)||t.set(o,s.name))}}return[...t.entries()].map(([n,i])=>({path:n,op:i}))}function Ow(e){return e==="need_human"?"var(--s-danger)":e==="done"?"var(--s-success)":"var(--fg-3)"}function Dw(e,t){return e==="commit"?"var(--s-shell)":e==="ci"?t==="failed"?"var(--s-danger)":t==="running"?"var(--s-working)":"var(--s-success)":e==="open"?"var(--fg-3)":e==="reset"?"var(--s-working)":e==="rename"?"var(--accent)":"var(--fg-3)"}function Rw(e,t){return e==="commit"?"commit":e==="ci"?t?`ci ${t}`:"ci":e==="open"?"opened":e==="reset"?t==="compacted"?"compacted":"cleared":e==="rename"?"renamed":e}function Fw(e){return e?(e.replace(/[^A-Za-z0-9]/g,"").slice(0,2)||e.slice(0,1)).toUpperCase():"?"}const Nw={pr:"Please link the PR you're working on for this pane using the `link_pr` MCP tool. If there isn't one, ignore this.",linear:"Please link the relevant Linear ticket for this pane using the `link_linear` MCP tool. If there isn't one, ignore this."};function Bw({data:e,onLinkAsk:t}){if(!e.pr){if(e.agent!=="claude")return null;const o=!!e.channel_attached;return r("button",{class:"modal-side-link-btn",type:"button",disabled:!o,title:o?"Ask Claude to link the PR for this pane (via link_pr MCP tool)":"Channel not attached. Respawn Claude via + claude.",onClick:()=>t("pr"),children:"+ link pull request"})}const n=e.ci==="✓"?"passing":e.ci==="✗"?"failing":e.ci==="⟳"?"running":"—",i=e.ci==="✓"?"ci-passing":e.ci==="✗"?"ci-failing":e.ci==="⟳"?"ci-running":"",l=cr(e.repo_slug,e.pr),a=e.pr_additions||0,s=e.pr_deletions||0;return r("div",{class:"modal-card-inset",children:[r("div",{class:"pr-head",children:[l?r("a",{class:"pr-num",href:l,target:"_blank",rel:"noopener",onClick:o=>o.stopPropagation(),children:["#",e.pr]}):r("span",{class:"pr-num",children:["#",e.pr]}),r("span",{class:"pr-title",title:e.pr_title||"",children:e.pr_title||""})]}),r("div",{class:"pr-meta",children:[e.pr_draft?r("span",{class:"pr-mini pr-mini-draft",children:"draft"}):r("span",{class:"pr-mini pr-mini-open",children:"open"}),r("span",{class:"pr-diff",children:[r("span",{class:"diff-plus",children:["+",a]})," ",r("span",{class:"diff-minus",children:["−",s]})]}),r("span",{class:`pr-ci ${i}`,children:[r("span",{class:"ci-dot"}),"ci ",n]}),(e.pr_reviewers||[]).length>0&&r("span",{class:"pr-reviewers",children:(e.pr_reviewers||[]).map(o=>r("span",{class:"modal-avatar",title:o,children:Fw(o)}))})]})]})}function zw({data:e,onLinkAsk:t}){if(e.linked_linear){const s=e.linked_linear,o=`https://linear.app/issue/${s}`,c=e.linked_linear_title||"linear ticket";return r("div",{class:"modal-card-inset",children:[r("div",{class:"pr-head",children:[r("a",{class:"pr-num",href:o,target:"_blank",rel:"noopener",onClick:u=>u.stopPropagation(),title:`Linear ticket ${s} (linked by claude)`,children:s}),r("span",{class:"pr-title",title:c,children:c})]}),e.linked_linear_status&&r("div",{class:"pr-meta",children:r("span",{class:"pr-mini",children:e.linked_linear_status})})]})}const n=xr(e),i=n&&r("div",{class:"modal-card-inset",children:r("div",{class:"pr-head",children:[r("a",{class:"pr-num",href:n.href,target:"_blank",rel:"noopener",onClick:s=>s.stopPropagation(),title:n.tip,children:n.id}),r("span",{class:"pr-title",children:n.note})]})});if(e.agent!=="claude")return i||null;const l=!!e.channel_attached;return r(U,{children:[i,r("button",{class:"modal-side-link-btn",type:"button",disabled:!l,title:l?"Ask Claude to link a Linear ticket for this pane (via link_linear MCP tool)":"Channel not attached. Respawn Claude via + claude.",onClick:()=>t("linear"),children:"+ link Linear ticket"})]})}function jw({e}){return e.src==="alert"?r("li",{class:"timeline-row timeline-row-alert","data-kind":e.kind,children:[r("span",{class:"timeline-dot",style:`background:${Ow(e.kind)}`}),r("div",{class:"timeline-body",children:[r("div",{class:"timeline-text",children:e.text}),r("div",{class:"timeline-when",children:["claude · ",e.kind," · ",Pe(e.at)," ago"]})]})]}):e.src==="channel"?r("li",{class:"timeline-row timeline-row-channel","data-kind":e.kind,children:[r("span",{class:"timeline-dot",style:"background:var(--accent)"}),r("div",{class:"timeline-body",children:[r("div",{class:"timeline-text",children:e.text}),r("div",{class:"timeline-when",children:["periscope · ",e.kind," · ",Pe(e.at)," ago"]})]})]}):r("li",{class:"timeline-row","data-kind":e.kind,children:[r("span",{class:"timeline-dot",style:`background:${Dw(e.kind,e.state)}`}),r("div",{class:"timeline-body",children:[e.url?r("a",{class:"timeline-text timeline-link",href:e.url,target:"_blank",rel:"noopener",children:e.text}):r("div",{class:"timeline-text",children:e.text}),r("div",{class:"timeline-when",children:[Rw(e.kind,e.state)," · ",Pe(e.at)," ago"]})]})]})}function Hw({data:e,streamRef:t}){const n=e.activity||[],i=n.filter(s=>s.src==="alert").reduce((s,o)=>s&&s.at>=o.at?s:o,null),l=i&&i.kind==="need_human"?i:null,a=n.filter(s=>s!==l);return r(U,{children:[l&&r("div",{class:"activity-pinned",children:[r("div",{class:"activity-pinned-label",children:["needs you · ",Pe(l.at)," ago"]}),r("div",{class:"activity-pinned-text",children:l.text})]}),a.length?r("ol",{class:"timeline activity-stream",ref:t,children:a.map((s,o)=>r(jw,{e:s},o))}):l?null:r("div",{class:"timeline-empty",children:"no recent activity"})]})}function qw({pid:e,onRefresh:t,idPrefix:n}){const i=J(null),l=J(null),a=J(null),s=e?Mr(e):null,o=(s==null?void 0:s.tags)||[];function c(){if(!e)return;const d=Mr(e)||{tags:[]};Gr(e,{notes:i.current.value,tags:d.tags})}function u(){const d=(l.current.value||"").trim();if(!d||!e)return;const p=Mr(e)||{notes:i.current.value,tags:[]},f=d.split(/[\s,]+/).filter(Boolean);Gr(e,{notes:i.current.value,tags:[...p.tags,...f]}),l.current.value="",t==null||t()}function h(d){const p=Mr(e)||{notes:i.current.value,tags:[]};Gr(e,{notes:i.current.value,tags:p.tags.filter((f,m)=>m!==d)}),t==null||t()}return r(U,{children:[r("textarea",{ref:i,id:`${n}-notes`,class:"modal-notes",placeholder:e?"Notes — saves on blur":"Notes unavailable (no pid)",disabled:!e,defaultValue:(s==null?void 0:s.notes)||"",onInput:()=>{clearTimeout(a.current),a.current=setTimeout(c,600)},onBlur:()=>{clearTimeout(a.current),c()},onKeyDown:d=>d.stopPropagation()}),r("div",{class:"tag-row",children:[r("div",{class:"tag-chips",id:`${n}-tags`,children:o.map((d,p)=>r("span",{class:"tag-chip","data-tag-i":p,children:[d,r("button",{class:"tag-chip-x",title:"remove",onClick:()=>h(p),children:"×"})]}))}),r("input",{ref:l,id:`${n}-tag-input`,class:"modal-tag-input",type:"text",placeholder:"add tag, Enter or comma",disabled:!e,onKeyDown:d=>{d.stopPropagation(),(d.key==="Enter"||d.key===",")&&(d.preventDefault(),u())}})]})]})}function El({it:e,label:t,priority:n,pinned:i,onTogglePin:l}){return r("li",{class:`files-row${n?" files-row-priority":""}${i?" files-row-pinned":""}`,onClick:()=>wr({path:e.path,line:null}),title:`Open ${e.path} as a preview tab`,children:[r("span",{class:"files-op",children:Ww(e.op)}),r("span",{class:"files-path",children:t}),r("button",{type:"button",class:`files-pin${i?" files-pin-on":""}`,title:i?"Unpin file":"Pin file","aria-label":i?"Unpin file":"Pin file","aria-pressed":i?"true":"false",onClick:a=>{a.stopPropagation(),l()},children:i?"★":"☆"})]})}function Uw({pid:e}){me.value;const[t,n]=N("");if(!e)return null;const l=Hr.value[e]?Bt.value[e]:null,a=l!=null&&l.messages?Iw(l.messages):[],s=Eu(e);if(!a.length&&!s.length)return null;const o=new Map(a.map(y=>[y.path,y])),c=s.map(y=>o.get(y)||{path:y,op:null}),u=new Set(s),h=a.filter(y=>!u.has(y.path)),d=[...s,...h.map(y=>y.path)],p=y=>Cu(y,d),f=t.trim(),m=y=>Mw(y.path,f),k=c.filter(m),{priority:x,others:b}=Lw(h.filter(m)),C=y=>()=>f1(e,y),g=[{items:k,render:y=>r(El,{it:y,label:p(y.path),pinned:!0,onTogglePin:C(y.path)},`pin:${y.path}`)},{items:x,render:y=>r(El,{it:y,label:p(y.path),priority:!0,pinned:!1,onTogglePin:C(y.path)},`pri:${y.path}`)},{items:b,render:y=>r(El,{it:y,label:p(y.path),pinned:!1,onTogglePin:C(y.path)},`oth:${y.path}`)}].filter(y=>y.items.length>0);return r("section",{class:"modal-side-section modal-side-files",children:[r("h4",{children:"Files"}),r("input",{class:"files-filter",type:"text",placeholder:"filter files — text or glob",value:t,onInput:y=>n(y.currentTarget.value),onKeyDown:y=>{y.stopPropagation(),y.key==="Escape"&&(y.preventDefault(),n(""))}}),r("ul",{class:"files-list",children:[g.map((y,$)=>r(U,{children:[$>0&&r("li",{class:"files-divider","aria-hidden":"true"}),y.items.map(y.render)]})),f&&!g.length&&r("li",{class:"files-nomatch",children:"no files match"})]})]})}function Ww(e){switch(e){case"Read":return"👁";case"Write":return"+";case"Edit":case"MultiEdit":case"NotebookEdit":return"✎";default:return"·"}}function Kw({data:e,onRefresh:t,containerId:n,containerClass:i,idPrefix:l}){const a=J(null),s=J(0),o=(e==null?void 0:e.pid)||"";H(()=>{a.current&&s.current&&(a.current.scrollTop=s.current)});function c(u){const h=Nw[u];!h||!(e!=null&&e.pane_id)||fetch(`/api/channel/push?pane_id=${encodeURIComponent(e.pane_id)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({content:h})}).catch(()=>{})}return a.current&&(s.current=a.current.scrollTop),r("aside",{id:n,class:i,children:[r("section",{class:"modal-side-section",children:[r("h4",{children:"Linked"}),r(Bw,{data:e,onLinkAsk:c}),r(zw,{data:e,onLinkAsk:c})]}),r("section",{class:"modal-side-section modal-side-notes",children:[r("h4",{children:"Notes"}),r(qw,{pid:o,idPrefix:l,onRefresh:t},o)]}),r(Uw,{pid:o}),r("section",{class:"modal-side-section modal-side-activity",children:[r("h4",{children:"Activity"}),r(Hw,{data:e,streamRef:a})]})]})}let kn=null,Fr=null;function Vw(){return kn?Promise.resolve(kn):(Fr||(Fr=nl(()=>import("./chunks/preview.js").then(e=>e.P),[]).then(e=>(kn=e,e)).catch(e=>{throw Fr=null,e})),Fr)}function Gw({entry:e,active:t=!0}){const[n,i]=N(()=>(kn==null?void 0:kn.PreviewTabInner)||null),[l,a]=N(null);return H(()=>{if(n)return;let s=!0;return a(null),Vw().then(o=>{s&&i(()=>o.PreviewTabInner)}).catch(o=>{s&&a((o==null?void 0:o.message)||String(o))}),()=>{s=!1}},[n]),l?r("div",{class:"preview-tab-content",role:"region","aria-label":"File preview",children:[r("header",{class:"preview-header",children:r("span",{class:"preview-path",children:e.path})}),r("div",{class:"preview-body",children:r("div",{class:"preview-error",children:[r("div",{children:"Failed to load preview module:"}),r("div",{class:"preview-error-code",children:l})]})})]}):n?r(n,{entry:e,active:t}):r("div",{class:"preview-tab-content",role:"region","aria-label":"File preview",children:[r("header",{class:"preview-header",children:r("span",{class:"preview-path",children:[e.path,e.line?`:${e.line}`:""]})}),r("div",{class:"preview-body",children:r("div",{class:"preview-loading",children:"loading…"})})]})}async function Pl(e,t,n,i){i(!0);try{const l=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({repo:t.repo,branch:t.branch})}),a=await l.json().catch(()=>({}));n(l.ok?a.mode==="spawned"?a.checked_out?"checked out the PR and spawned a pane to prepare":"spawned a pane to prepare":"sent":a.detail||`HTTP ${l.status}`),il()}catch(l){n(String(l))}finally{i(!1)}}function Jw({row:e}){const t=xr(e),n=t&&r("a",{class:"rq-linear",href:t.href,target:"_blank",rel:"noopener",title:t.tip,children:t.id});if(!e.pr)return n||"—";const i=Gi(e.pr.state),l=`rq-pr-link ${i.cls}`;return r(U,{children:[e.pr.url?r("a",{class:l,href:e.pr.url,target:"_blank",rel:"noopener",children:["#",e.pr.number]}):r("span",{class:l,children:["#",e.pr.number]}),n?r(U,{children:[" · ",n]}):null,e.pr.draft?" draft":""," ",e.pr.state||""," ",e.pr.ci&&!i.cls?e.pr.ci:"",r("div",{class:"rq-repo",children:e.pr.title})]})}const rc="filter branches, PRs, people, tickets";function Qw({col:e}){const{label:t,what:n}=Ki[e],i=zl.value,l=(i==null?void 0:i.key)===e,a=Bg(i,e);return r("th",{"aria-sort":l?i.dir==="asc"?"ascending":"descending":void 0,children:r("button",{type:"button",class:`rq-sort${l?" is-active":""}`,title:a?l?"reverse the order":`sort by ${n}`:"back to the default order",onClick:()=>{zl.value=a},children:[t,l?r("span",{class:"rq-sort-dir","aria-hidden":"true",children:i.dir==="asc"?"▲":"▼"}):null]})})}function Yw({row:e}){var h,d,p;const[t,n]=N(""),[i,l]=N(!1),a=((h=e.pr)==null?void 0:h.state)==="merged",s=!!e.owner||!!e.worktree||((d=e.pr)==null?void 0:d.state)==="open",o=e.walkthrough,c=e.owner?"ask the owning pane to write the walkthrough":e.worktree?"spawn a pane in the worktree to write the walkthrough":s?`check out PR #${e.pr.number} and spawn a pane to write the walkthrough`:"open the branch first (⌘K)",u=e.unresolved>0?`${e.unresolved} unresolved comment${e.unresolved===1?"":"s"}`:e.owner?"ask the owning pane to merge":"no pane on this branch";return r("tr",{class:`rq-row rq-${e.role}${a?" is-merged":""}`,children:[r("td",{class:"rq-branch",children:[o?r("button",{type:"button",class:"rq-open",onClick:()=>Hu(e.repo,e.branch),children:e.branch}):e.branch,r("div",{class:"rq-repo",children:[e.repo," · ",e.role==="review-requested"?"review requested":e.role]})]}),r("td",{class:"rq-pr",children:r(Jw,{row:e})}),r("td",{class:"rq-wt",children:o?`${o.stops} stop${o.stops===1?"":"s"} · ${Rg(e)}`:"none"}),r("td",{class:"rq-comments",children:e.unresolved?r("b",{children:[e.unresolved," open"]}):"—"}),r("td",{class:"rq-owner",children:[e.owner?e.owner.name:(p=e.pr)!=null&&p.author?`opened by ${e.pr.author}`:"—",e.owner?null:r("div",{class:"rq-repo",children:e.worktree?"no pane":"not checked out"})]}),r("td",{class:"rq-actions",children:[r("button",{type:"button",disabled:i||!s,title:c,onClick:()=>Pl("/api/reviews/prepare",e,n,l),children:o?"re-prepare":"prepare"}),r("button",{type:"button",disabled:i||!e.owner||a||e.unresolved>0,title:u,onClick:async()=>{await tr(`Ask the owning pane to merge ${e.branch}?`,{okLabel:"Merge"})&&Pl("/api/reviews/merge",e,n,l)},children:"merge"}),(a||!e.worktree)&&(o||e.unresolved)?r("button",{type:"button",disabled:i,title:"remove this review's files",onClick:async()=>{await tr(`Remove the walkthrough and comments for ${e.branch}? This can't be undone.`,{okLabel:"Clear",danger:!0})&&Pl("/api/reviews/clear",e,n,l)},children:"clear"}):null,t?r("span",{class:"rq-note",children:t}):null]})]})}function Zw(){H(()=>{il()},[]);const e=yt.value;if(e===null)return r("div",{class:"wt-empty",children:"loading…"});const t=Ng(e,zl.value),n=_s.value,i=zg(t,n),l=`branch${t.length===1?"":"es"}`;return r("div",{class:"reviews-queue",children:[r("header",{class:"wt-head",children:[r("h2",{children:"Reviews"}),r("input",{type:"search",class:"rq-search",placeholder:rc,"aria-label":rc,spellcheck:!1,autocomplete:"off",value:n,onInput:a=>{_s.value=a.currentTarget.value}}),r("span",{class:"wt-sub","aria-live":"polite",children:n.trim()?`${i.length} of ${t.length} ${l}`:`${t.length} ${l}`})]}),t.length===0?r("div",{class:"wt-empty",children:"nothing open"}):i.length===0?r("div",{class:"wt-empty",children:['no branches match "',n.trim(),'"']}):r("table",{class:"rq-table",children:[r("thead",{children:r("tr",{children:[Object.keys(Ki).map(a=>r(Qw,{col:a},a)),r("th",{})]})}),r("tbody",{children:i.map(a=>r(Yw,{row:a},`${a.repo}/${a.branch}`))})]})]})}async function hh(e,t){const n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),i=await n.json().catch(()=>({}));return{ok:n.ok,status:n.status,data:i}}const Li=e=>typeof(e==null?void 0:e.detail)=="string"&&e.detail?e.detail:null;function Xw(e){return/Mac|iPhone|iPad/.test(e||"")?"⌘↩ to send":"Ctrl+↩ to send"}const ev=Xw(typeof navigator>"u"?"":navigator.platform);function tv(e){return e.ok?{close:!0,note:"sent to the owning pane"}:e.status===409?{close:!0,note:`saved, ${Li(e.data)||"not delivered"}`}:{close:!1,note:Li(e.data)||`HTTP ${e.status}`}}const ua=()=>typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches?"auto":"smooth",fh=e=>e.knownKind?e.kind:"other";function ic(e,t){getComputedStyle(e).overflowY!=="visible"&&e.scrollHeight>e.clientHeight?e.scrollTo({top:t.offsetTop-8,behavior:ua()}):t.scrollIntoView({block:"nearest",behavior:ua()}),t.classList.remove("is-flash"),t.getBoundingClientRect(),t.classList.add("is-flash")}function ph({list:e}){return e.length?r("ul",{class:"wt-comments",children:e.map((t,n)=>r("li",{class:t.resolved?"is-resolved":"",children:[r("span",{class:"wt-comment-ts",children:t.ts}),r("span",{class:"wt-comment-state",children:t.resolved?"resolved":"open"}),r("div",{class:"wt-comment-body",children:Cn(t.body,{demote:!0,softBreaks:"space"})})]},n))}):null}function nv({stop:e,text:t,busy:n,textRef:i,onInput:l,onSend:a,onCancel:s}){return r(U,{children:[r("textarea",{ref:i,rows:3,value:t,placeholder:"comment on this stop…","aria-label":`comment on ${e}`,onInput:o=>l(o.currentTarget.value),onKeyDown:o=>{o.key==="Enter"&&(o.metaKey||o.ctrlKey)&&a()}}),r("div",{class:"wt-comment-actions",children:[r("button",{type:"button",class:"wt-btn",disabled:n||!t.trim(),onClick:a,children:"send"}),r("button",{type:"button",class:"wt-link",disabled:n,onClick:s,children:"cancel"}),r("span",{class:"wt-hint",children:ev})]})]})}const Nr=new Map;function rv({repo:e,branch:t,stop:n,onPosted:i}){const l=`${e}
+${t}
+${n}`,[a,s]=N(()=>Nr.has(l)),[o,c]=N(()=>Nr.get(l)||""),u=g=>{g?Nr.set(l,g):Nr.delete(l),c(g)},[h,d]=N(""),[p,f]=N(!1),m=J(null),k=J(null),x=J(null),b=J(!1);H(()=>{var g;b.current&&(b.current=!1,(g=(a?k:x).current)==null||g.focus())},[a]);async function C(){var g;if(!(p||!o.trim())){f(!0);try{const y=tv(await hh("/api/reviews/comment",{repo:e,branch:t,stop:n,body:o}));if(d(y.note),y.close){const $=document.activeElement;b.current=!$||$===document.body||!!((g=m.current)!=null&&g.contains($)),u(""),s(!1)}i()}catch(y){d(String(y))}finally{f(!1)}}}return r("div",{class:`wt-comment-box${a?" is-open":""}`,ref:m,children:[a?r(nv,{stop:n,text:o,busy:p,textRef:k,onInput:u,onSend:C,onCancel:()=>{u(""),b.current=!0,s(!1)}}):r("button",{ref:x,type:"button",class:"wt-link","aria-label":`comment on ${n}`,onClick:()=>{d(""),b.current=!0,s(!0)},children:"comment"}),r("span",{class:"wt-comment-note",role:"status",children:h})]})}function iv({on:e,onToggle:t,error:n,describedBy:i}){return r("span",{class:"wt-reviewed",children:[n?r("span",{class:"wt-reviewed-err",role:"alert",children:n}):null,r("button",{type:"button",class:`wt-reviewed-btn${e?" is-on":""}`,"aria-describedby":i,"aria-pressed":e?"true":"false",onClick:t,children:[e?r("span",{"aria-hidden":"true",children:"✓ "}):null,"reviewed"]})]})}class lv extends un{shouldComponentUpdate(t){for(const n in t)if(t[n]!==this.props[n])return!0;return!1}render(t){return r(dh,{...t})}}function av({ev:e,title:t,noWorktree:n,hl:i,colRef:l,expanded:a,onGo:s,onExpand:o}){const c=Ag(e.hidden);return!e.shown.length&&!c?r("div",{class:"wt-evidence is-empty"}):r("aside",{class:"wt-evidence",ref:l,"aria-label":`files and code changes: ${t}`,children:[r("ul",{class:"wt-files",children:e.shown.map((u,h)=>{const d=r(U,{children:[r("span",{class:"wt-file-name",children:u.name}),u.ref.start!=null?r("span",{class:"wt-file-range",children:`:${u.ref.start}${u.ref.end!==u.ref.start?`-${u.ref.end}`:""}`}):null,e.noDiff?null:r("span",{class:"wt-file-count",children:`${u.hunks.length} change${u.hunks.length===1?"":"s"}`})]});return r("li",{children:e.noDiff?r("span",{class:"wt-file",title:u.ref.path,children:d}):r("button",{type:"button",class:"wt-file",title:u.ref.path,onClick:()=>s(h,u.ref.raw),children:d})},h)})}),c?r("details",{class:"wt-hidden",children:[r("summary",{children:c}),r("ul",{children:Object.entries(e.hidden).flatMap(([u,h])=>h.map((d,p)=>r("li",{children:[r("span",{class:"wt-hidden-path",children:d.raw}),` · ${Vl[u]}`]},`${u}${p}`)))})]}):null,e.noDiff?r("p",{class:"wt-nodiff",children:n?"no worktree, so code changes are unavailable":"code changes are unavailable"}):e.shown.map((u,h)=>{const d=Og(u.hunks);return r("section",{class:"wt-ev-file","data-ev":h,children:[r("div",{class:"wt-ev-path",children:u.ref.raw}),d<=Ig||a.has(u.ref.raw)?u.hunks.map((p,f)=>r(lv,{hunk:p,lang:uh(u.ref.path),hl:i,onOpen:null},f)):r("button",{type:"button",class:"wt-ev-more",onClick:()=>o(u.ref.raw),children:`show ${d} lines`})]},h)})]})}function sv({stop:e,n:t,diffFiles:n,noWorktree:i,comments:l,repo:a,branch:s,hl:o,reviewed:c,toggleError:u,onToggleReviewed:h,onPosted:d}){const[p,f]=N(!1),[m,k]=N(()=>new Set),x=J(null),b=Ma(e,c),C=b&&!p,g=lt(()=>Mg(e.refs,n),[e.refs,n]),y=jt(T=>k(S=>S.has(T)?S:new Set(S).add(T)),[]),$=jt((T,S)=>{const L=x.current,O=L==null?void 0:L.querySelector(`[data-ev="${T}"]`);O&&(O.querySelector(".wt-ev-more")?(y(S),requestAnimationFrame(()=>ic(L,O))):ic(L,O))},[y]),v=lt(()=>{const T=S=>{const L=g.noDiff?-1:Lg(g.shown,S);return r("button",{type:"button",class:`md-cite${L>=0?"":" is-inert"}`,title:L>=0?"show in the code column":"not among this stop's changes","aria-disabled":L>=0?void 0:"true",onClick:()=>{L>=0&&$(L,g.shown[L].ref.raw)},children:S.raw})};return Cn(e.bodyMarkdown,{demote:!0,softBreaks:"space",mermaid:!0,meta:!0,cite:T,zoom:!0})},[e.bodyMarkdown,g,$]),E=r(U,{children:[r("span",{class:"wt-stop-n",children:`${t}.`})," ",e.title]}),M=`stop-${e.id}__title`;return r("section",{class:`wt-stop wt-kind-${fh(e)}${C?" is-folded":""}`,id:`stop-${e.id}`,tabIndex:-1,children:[r("div",{class:"wt-stop-head",children:[r("h3",{class:"wt-stop-title",id:M,children:b?r("button",{type:"button",class:"wt-fold","aria-expanded":C?"false":"true",title:C?"show this stop":"fold this stop",onClick:()=>f(!p),children:E}):E}),e.kind?r("span",{class:"wt-kind-badge",children:e.kind}):null,C&&l.length?r("span",{class:"wt-comment-chip",children:Dg(l)}):null,r(iv,{on:b,error:u,describedBy:M,onToggle:()=>{f(!1),h(e,!b)}})]}),C?null:r(U,{children:[e.diagrams.length?r("div",{class:"wt-diagrams",children:e.diagrams.map((T,S)=>r(Td,{code:T,zoom:!0,label:`${e.title}, diagram ${S+1}`},S))}):null,r("div",{class:"wt-cols",children:[r("div",{class:"wt-prose",children:[r("div",{class:"md-doc",children:v}),r(ph,{list:l}),r(rv,{repo:a,branch:s,stop:e.title,onPosted:d})]}),r(av,{ev:g,title:e.title,noWorktree:i,hl:o,colRef:x,expanded:m,onGo:$,onExpand:y})]})]})]})}function ov({stops:e,reviewed:t}){return e.length?r("nav",{class:"wt-toc","aria-label":"stops",children:r("ol",{children:e.map((n,i)=>r("li",{children:r("button",{type:"button",class:`wt-toc-item wt-kind-${fh(n)}`,onClick:()=>{const l=document.getElementById(`stop-${n.id}`);l&&(l.scrollIntoView({block:"start",behavior:ua()}),l.focus({preventScroll:!0}))},children:[r("span",{class:"wt-toc-n",children:`${i+1}.`}),r("span",{class:"wt-toc-dot","aria-hidden":"true"}),r("span",{class:"wt-toc-title",children:n.title}),Ma(n,t)?r("span",{class:"wt-toc-done",role:"img","aria-label":"reviewed",children:"✓"}):null]})},n.id))})}):null}function cv({staleBy:e,header:t,diff:n,noWorktree:i}){return e>0?r("span",{class:"wt-badge is-warn",children:`stale: ${e} commit${e===1?"":"s"}`}):i?r("span",{class:"wt-badge",children:"no worktree"}):e==null&&t&&n?r("span",{class:"wt-badge is-warn",children:"stale: unknown"}):null}function uv({data:e,repo:t,branch:n,pr:i,hl:l,reviewed:a,toggleErrors:s,error:o,onToggleReviewed:c,onPosted:u}){var y;const{text:h,comments:d,diff:p,stale_by:f}=e,m=lt(()=>$g(h),[h]),k=new Map;for(const $ of d)(k.get($.stop)||k.set($.stop,[]).get($.stop)).push($);const x=new Set(m.stops.map($=>$.title)),b=d.filter($=>!x.has($.stop)),C=m.stops.filter($=>Ma($,a)).length,g=f==null&&!!m.header&&!p;return r("div",{class:"walkthrough",children:[r("header",{class:"wt-head",children:[r("h2",{class:"wt-title",children:m.title||n}),r("div",{class:"wt-sub",children:[r("span",{children:`${t} · ${n}`}),(y=m.header)!=null&&y.pr?i!=null&&i.url&&i.number===m.header.pr?r("a",{class:`rq-pr-link ${Gi(i.state).cls}`,href:i.url,target:"_blank",rel:"noopener",children:`PR #${m.header.pr}`}):r("span",{children:`PR #${m.header.pr}`}):null,r(cv,{staleBy:f,header:m.header,diff:p,noWorktree:g}),m.stops.length?r("span",{class:"wt-progress",children:`${C} / ${m.stops.length} reviewed`}):null]}),r("div",{class:"wt-error",role:"status",children:o?`refresh failed: ${o}`:""})]}),r("div",{class:"wt-scroll",children:[m.problemMarkdown||m.stops.length?r("div",{class:"wt-cols wt-intro",children:[m.problemMarkdown?r("div",{class:"md-doc wt-problem",children:Cn(m.problemMarkdown,{demote:!1,softBreaks:"space"})}):null,r(ov,{stops:m.stops,reviewed:a})]}):null,m.stops.length?null:r("p",{class:"wt-empty-stops",children:"no stops in this walkthrough"}),m.stops.map(($,v)=>r(sv,{stop:$,n:v+1,diffFiles:(p==null?void 0:p.files)||null,noWorktree:g,comments:k.get($.title)||[],repo:t,branch:n,hl:l,reviewed:a,toggleError:s[$.title]||null,onToggleReviewed:c,onPosted:u},$.id)),b.length?r("section",{class:"wt-stop wt-kind-other",children:[r("div",{class:"wt-stop-head",children:r("h3",{class:"wt-stop-title",children:"unattached comments"})}),r(ph,{list:b})]}):null]})]})}function dv({repo:e,branch:t,pr:n,sig:i}){const[l,a]=N({loading:!0,error:null,data:null}),[s,o]=N(null),[c,u]=N(0),[h,d]=N({}),[p,f]=N({}),m=lt(()=>Cg({post:async(b,C,g)=>{const y=await hh("/api/reviews/reviewed",{repo:e,branch:t,stop:b,sig:C,reviewed:g});if(!y.ok)throw new Error(Li(y.data)||`HTTP ${y.status}`)},show:(b,C)=>d(g=>bu(g,b,C)),fail:(b,C)=>f(g=>({...g,[b]:C}))}),[e,t]);H(()=>{let b=!0;return nl(()=>import("./chunks/preview.js").then(C=>C.h),[]).then(C=>{b&&o(()=>C.highlightCode)}).catch(()=>{}),()=>{b=!1}},[]),H(()=>{let b=!0;const C=m.settled;return(async()=>{try{const g=await fetch(`/api/reviews/walkthrough?repo=${encodeURIComponent(e)}&branch=${encodeURIComponent(t)}`),y=await g.json().catch(()=>({}));if(!b)return;if(!g.ok){a($=>({loading:!1,error:Li(y)||`HTTP ${g.status}`,data:$.data}));return}a({loading:!1,error:null,data:y}),Tg(m,C)&&(d(y.reviewed||{}),m.seed(y.reviewed||{}))}catch(g){b&&a(y=>({loading:!1,error:String(g),data:y.data}))}})(),()=>{b=!1}},[e,t,c,i,m]);const k=()=>{u(b=>b+1),il()},x=(b,C)=>m.toggle(b.title,yu(b),C);return l.loading?r("div",{class:"wt-empty",children:"loading…"}):l.data?r(uv,{data:l.data,repo:e,branch:t,pr:n,hl:s,reviewed:h,toggleErrors:p,error:l.error,onToggleReviewed:x,onPosted:k}):r("div",{class:"wt-empty",children:l.error})}function hv({target:e,agent:t,onPaste:n,class:i="modal-xterm",id:l}){const a=J(null);return H(()=>(C0(a.current,e,{agent:t,onPaste:n}),nd),[]),r("div",{ref:a,id:l,class:i})}function fv(){const e=J(null),[t,n]=N(!1),[i,l]=N("");H(()=>{function o(c){(c.metaKey||c.ctrlKey)&&c.key==="f"&&(c.preventDefault(),n(!0),requestAnimationFrame(()=>{var u;return(u=e.current)==null?void 0:u.focus()}))}return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[]);const a=jt(()=>{n(!1),l(""),$0()},[]);We(a,t);function s(o){o.preventDefault(),i&&(o.shiftKey?lo(i):io(i))}return t?r("form",{class:"term-search",onSubmit:s,children:[r("input",{ref:e,class:"term-search-input",value:i,placeholder:"find in terminal",onInput:o=>{l(o.currentTarget.value)}}),r("button",{type:"button",class:"term-search-btn",title:"Previous (Shift+Enter)",onClick:()=>i&&lo(i),children:"‹"}),r("button",{type:"button",class:"term-search-btn",title:"Next (Enter)",onClick:()=>i&&io(i),children:"›"}),r("button",{type:"button",class:"term-search-btn",title:"Close (Esc)",onClick:a,children:"✕"})]}):null}const mh={rail:{pref:"rail_width",cssVar:"--rail-w",columnId:"rail",def:320,min:180,dir:1},side:{pref:"side_width",cssVar:"--side-w",columnId:"detail-side",def:280,min:200,dir:-1}},pv=.5;function mv(e,t,n){return Math.round(Math.min(Math.max(e,t),Math.max(t,n)))}function gv(e,t,n,i){return mv(e+n.dir*t,n.min,i*pv)}function yv(e){return Number.isFinite(e)&&e>0?e:null}function gh({which:e}){const t=mh[e];function n(i){if(i.button!==0)return;const l=i.currentTarget,a=document.getElementById("split-view"),s=document.getElementById(t.columnId),o=l.parentElement;if(!a||!s||!o)return;i.preventDefault();const c=i.clientX,u=Math.round(s.getBoundingClientRect().width),h=o.getBoundingClientRect().width;let d=u;l.setPointerCapture(i.pointerId),l.classList.add("dragging"),document.body.classList.add("col-resizing"),_0();const p=m=>{d=gv(u,m.clientX-c,t,h),a.style.setProperty(t.cssVar,`${d}px`)},f=()=>{l.removeEventListener("pointermove",p),l.removeEventListener("pointerup",f),l.removeEventListener("pointercancel",f),l.classList.remove("dragging"),document.body.classList.remove("col-resizing"),S0(),d!==u&&Gs(t.pref,d)};l.addEventListener("pointermove",p),l.addEventListener("pointerup",f),l.addEventListener("pointercancel",f)}return r("div",{class:`col-resize col-resize-${e}`,title:"Drag to resize · double-click to reset",onPointerDown:n,onDblClick:()=>Gs(t.pref,t.def)})}function bv(e){return(e==null?void 0:e.agent)!=="claude"?"not a Claude pane":e.state!=="idle"&&e.state!=="done"?`pane is ${e.state||"busy"}, try again when it's idle`:e.pending_input?"the pane has unsent text in its input box":null}function kv(e){return(e==null?void 0:e.session_effort)||(e==null?void 0:e.launch_effort)||"default"}function wv(e){var t;return e!=null&&e.model?e.model.replace(/\s*\(.*\)/,""):e!=null&&e.session_model?((t=fr.find(n=>n.id===e.session_model))==null?void 0:t.label)||e.session_model:"model"}function vv({w:e}){var u;const[t,n]=N({}),[i,l]=N(!1);H(()=>{n({})},[e.pid,e.session_model,e.session_effort]);const a=i?"waiting for the pane to confirm the last change":bv(e);async function s(h,d){const p=d.currentTarget.value;if(d.currentTarget.value="",!p||i)return;const f=`pid=${encodeURIComponent(e.pid)}&setting=${h}&value=${encodeURIComponent(p)}`;l(!0);let m;try{m=await ie(`set ${h}`,`/api/pane/session-setting?${f}`,{method:"POST"})}finally{l(!1)}m&&(m.result==="applied"?n(k=>({...k,[h]:p})):m.result==="confirm"?_n("Claude is asking to confirm the model switch in the pane — answer it there","info",7e3):_n(`Sent ${m.sent}, but Claude didn't confirm it took`,"info",5e3))}const o=t.model?((u=fr.find(h=>h.id===t.model))==null?void 0:u.label)||t.model:wv(e),c=t.effort||kv(e);return r("span",{class:"header-session-picks",children:[r("select",{class:"header-session-pick",value:"",disabled:!!a,title:a||"change this session's model (types /model into the pane)",onChange:h=>s("model",h),children:[r("option",{value:"",hidden:!0,children:o}),fr.map(h=>r("option",{value:h.id,children:h.label},h.id))]}),r("select",{class:"header-session-pick",value:"",disabled:!!a,title:a||"change this session's effort (types /effort into the pane)",onChange:h=>s("effort",h),children:[r("option",{value:"",hidden:!0,children:`effort ${c}`}),Wa.map(h=>r("option",{value:h,children:h},h))]})]})}const xv=2e3;function _v(e,t,n){H(()=>{if(!n||!e)return;let i=!0,l=null;async function a(){try{const o=await(await fetch(`/api/pane/turns?${nt(e)}`)).json();if(!i)return;const c=o&&o.turns===null?[]:o.messages||[],u=(o==null?void 0:o.session_id)||null;Bt.value={...Bt.value,[t]:{messages:c,sessionId:u}},c.length&&!Hr.value[t]&&(Hr.value={...Hr.value,[t]:!0})}catch{}i&&(l=setTimeout(a,xv))}return a(),()=>{i=!1,l&&clearTimeout(l)}},[e,t,n])}function Sv(e){const t=e.input||{};switch(e.name){case"Bash":return t.command||"";case"Read":case"Edit":case"Write":case"MultiEdit":case"NotebookEdit":return t.file_path||t.notebook_path||"";case"Grep":return t.pattern||"";case"Glob":return t.pattern||"";case"Task":case"Agent":return t.description||"";case"TaskCreate":return t.subject||"";case"TaskUpdate":return t.taskId?`#${t.taskId}`:"";case"WebFetch":return t.url||"";case"WebSearch":return t.query||"";case"Skill":return t.skill||t.command||"";case"AskUserQuestion":{const n=t.questions||[];return n.length===1?n[0].question||n[0].header||"":n.length?`${n.length} questions`:""}default:{const n=JSON.stringify(t);return n==="{}"||n==="null"?"":n.length>120?`${n.slice(0,120)}…`:n}}}function $v({input:e}){const t=String(e.old_string||"").split(`
`),n=String(e.new_string||"").split(`
-`);return r("div",{class:"tc-diff",children:[t.map((i,l)=>r("div",{class:"tc-diff-del",children:i||" "},`d${l}`)),n.map((i,l)=>r("div",{class:"tc-diff-add",children:i||" "},`a${l}`))]})}function Rw(e){const t=e.input||{};switch(e.name){case"Bash":return t.command||"";case"Write":return t.content||"";default:return""}}function Fw({input:e}){const t=e.questions||[];return r("div",{class:"tc-ask",children:t.map((n,i)=>r("div",{class:"tc-ask-q",children:[r("div",{class:"tc-ask-qhead",children:[n.header&&r("span",{class:"tc-ask-chip",children:n.header}),n.multiSelect&&r("span",{class:"tc-ask-multi",children:"multi-select"})]}),r("div",{class:"tc-ask-question",children:n.question}),r("div",{class:"tc-ask-options",children:(n.options||[]).map((l,a)=>r("div",{class:"tc-ask-opt",children:[r("span",{class:"tc-ask-opt-label",children:l.label}),l.description&&r("span",{class:"tc-ask-opt-desc",children:l.description})]},a))})]},i))})}function Nw({t:e}){var f;const[t,n]=B(!1),i=e.result==null,l=e.name==="Edit",a=e.name==="AskUserQuestion",s=e.name==="Agent"||e.name==="Task",o=Rw(e),u=!i&&e.result!=null&&e.result!=="",c=l||a||!!o||u,p=Ow(e),d=s&&((f=e.input)==null?void 0:f.subagent_type)||"";return r("div",{class:`tc${s?" tc-agent":""}`,children:[r("button",{class:`tc-head${c?" expandable":""}`,onClick:c?()=>n(!t):void 0,children:[r("span",{class:"tc-dot",children:s?"⚇":"⏺"}),r("span",{class:"tc-name",children:e.name}),d&&r("span",{class:"tc-agent-type",children:d}),p&&(e.name==="Read"||e.name==="Edit"||e.name==="Write"||e.name==="MultiEdit"||e.name==="NotebookEdit"?r("span",{class:"tc-arg tc-arg-clickable",title:"Cmd+click to preview",onClick:m=>{!m.metaKey&&!m.ctrlKey||(m.stopPropagation(),kr({path:p,line:null}))},children:p}):r("span",{class:"tc-arg",children:p})),i&&r("span",{class:"tc-running",children:"running…"}),c&&r("span",{class:"tc-caret",children:t?"▾":"▸"})]}),t&&r("div",{class:"tc-detail",children:[l?r(Dw,{input:e.input||{}}):a?r(Fw,{input:e.input||{}}):o&&r("pre",{class:"tc-cmd",children:o}),u&&r("pre",{class:"tc-out",children:e.result})]})]})}function Bw({m:e,current:t}){if(e.role==="user")return r("div",{class:`turn turn-user${t?" turn-current":""}`,children:[r("span",{class:"turn-user-mark",children:"›"}),r("div",{class:"turn-user-body",children:mr(e.text)})]});const n=e.tool_uses||[];return r("div",{class:`turn turn-assistant${t?" turn-current":""}`,children:[e.text&&r("div",{class:"turn-prose",children:mr(e.text)}),n.length>0&&r("div",{class:"turn-tools",children:n.map((i,l)=>r(Nw,{t:i},i.id||l))})]})}function zw({target:e,composerRef:t}){const[n,i]=B(""),[l,a]=B(!1),s=te(null);async function o(){const d=n;if(!d.trim()||l)return;a(!0),await ie("send",`/api/send?${tt(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paste:d})})&&(await new Promise(h=>setTimeout(h,250)),await ie("send",`/api/send?${tt(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({keys:["Enter"]})}),i(""),s.current&&(s.current.style.height="")),a(!1)}function u(d){d.key==="Enter"&&!d.shiftKey&&(d.preventDefault(),o())}function c(d){const f=d.currentTarget;i(f.value),f.style.height="0px",f.style.height=`${Math.min(f.scrollHeight,140)}px`}async function p(d){var h;const f=((h=d.clipboardData)==null?void 0:h.items)||[];for(const m of f){if(m.kind!=="file"||!m.type.startsWith("image/"))continue;const b=m.getAsFile();if(!b)continue;d.preventDefault();const w=await(await fetch(`/api/paste-image?${tt(e)}&deliver=false`,{method:"POST",headers:{"Content-Type":b.type||"image/png"},body:b})).json().catch(()=>({}));w.ok&&i(C=>`${C}${C&&!C.endsWith(" ")?" ":""}@${w.path} `);return}}return r("div",{class:"transcript-composer",ref:t,children:r("textarea",{ref:s,class:"transcript-composer-input",placeholder:"Message Claude… (Enter to send · Shift+Enter for newline · paste screenshots)",value:n,rows:1,onInput:c,onKeyDown:u,onPaste:p})})}function jw({target:e,pid:t,selected:n,state:i,waitingFor:l,spinner:a}){var m;Iw(e,t,n);const s=((m=Ft.value[t])==null?void 0:m.messages)||[],o=te(null),u=te(null),c=te(!0),p=te(""),d=()=>{const b=o.current;b&&c.current&&(b.scrollTop=b.scrollHeight)};j(()=>{const b=s[s.length-1],x=`${s.length}:${b?b.uuid:""}:${b?(b.tool_uses||[]).length:0}`;x!==p.current&&(p.current=x,d())},[s]),j(()=>{const b=u.current,x=o.current;if(!b||!x)return;const w=()=>{x.style.paddingBottom=`${b.offsetHeight+14}px`,requestAnimationFrame(d)};w();const C=new ResizeObserver(w);return C.observe(b),()=>C.disconnect()},[]),j(()=>{(i==="needs-input"||i==="working")&&d()},[i]);function f(b){const x=b.currentTarget;c.current=x.scrollHeight-x.scrollTop-x.clientHeight<80}let h="";for(let b=s.length-1;b>=0;b--)if(s[b].role!=="system"){h=s[b].uuid;break}return r(K,{children:[r("div",{class:"transcript",ref:o,onScroll:f,children:[s.length===0?r("div",{class:"transcript-empty",children:"No transcript yet."}):s.map(b=>b.role==="system"&&b.kind==="compact"?r("div",{class:"transcript-compact",children:r("span",{children:"context compacted"})},b.uuid):r(Bw,{m:b,current:b.uuid===h},b.uuid)),i==="needs-input"&&r("div",{class:"transcript-status transcript-status-waiting",children:[r("span",{class:"transcript-status-dot"}),r("span",{class:"transcript-status-text",children:["Waiting for your input",l?` — ${l}`:""]})]}),i==="working"&&r("div",{class:"transcript-working",children:[r("span",{class:"transcript-working-dot"}),r("span",{class:"transcript-working-verb",children:a?`${a.toLowerCase()}…`:"working…"})]})]}),r(zw,{target:e,composerRef:u})]})}const Hw=1500;function qw(e){const t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function Uw({mode:e,onMode:t}){return r("span",{class:"detail-mode-toggle",children:[r("button",{class:e==="transcript"?"is-active":"",onClick:()=>t("transcript"),children:"Transcript"}),r("button",{class:e==="terminal"?"is-active":"",onClick:()=>t("terminal"),children:"Terminal"})]})}function Ww({pid:e,paneLabel:t}){const n=Ne.value[e]||[],i=Re.value[e]||"pane";return r("div",{class:"detail-tab-strip",role:"tablist",children:[r("button",{type:"button",role:"tab",class:`detail-tab${i==="pane"?" is-active":""}`,"aria-selected":i==="pane",onClick:()=>jr(e,"pane"),title:t,children:r("span",{class:"detail-tab-label",children:t})}),r("button",{type:"button",role:"tab",class:`detail-tab${i==="changes"?" is-active":""}`,"aria-selected":i==="changes",onClick:()=>jr(e,"changes"),title:"Changes in this worktree",children:r("span",{class:"detail-tab-label",children:"Changes"})}),n.map(l=>{const a=`file:${l.path}`,s=i===a;return r("button",{type:"button",role:"tab",class:`detail-tab${s?" is-active":""}`,"aria-selected":s,onClick:()=>jr(e,a),title:l.path,children:[r("span",{class:"detail-tab-label",children:qw(l.path)}),r("span",{class:"detail-tab-close",title:"Close tab",onClick:o=>{o.stopPropagation(),Mc(e,l.path)},children:"×"})]},a)})]})}function Go(e){return(ce.value||[]).find(t=>t.pid===e)||null}function Qd(e){return(e==null?void 0:e.agent)!=="claude"?"terminal":yu(e.pid)||"terminal"}async function Kw(e){var n;if(!rr.value)return;const t=((n=e.clipboardData)==null?void 0:n.items)||[];for(const i of t){if(i.kind!=="file"||!i.type.startsWith("image/"))continue;const l=i.getAsFile();if(l){e.preventDefault(),e.stopPropagation();try{const s=await(await fetch(`/api/paste-image?${tt(rr.value)}`,{method:"POST",headers:{"Content-Type":l.type||"image/png"},body:l})).json();s.ok||Vs(`\r
-\x1B[31m[periscope: image paste failed: ${s.error}]\x1B[0m`)}catch(a){Vs(`\r
-\x1B[31m[periscope: image paste error: ${a.message}]\x1B[0m`)}return}}}function Vw({w:e}){const t=!!e.spawned_by&&(ce.value||[]).some(l=>l.pid===e.spawned_by),n=[];if(e.session&&e.session!==e.branch&&n.push(r("span",{children:r("b",{children:e.session})})),e.cwd){const l=e.cwd.split("/").filter(Boolean),a=l[l.length-1]||"",s=e.branch?e.branch.replace(/[/\\]/g,"-"):null;let o;s&&a===s&&l.length>=2?o=l[l.length-2]:o=l.length>=2?l.slice(-2).join("/"):l[0]||e.cwd,o&&n.push(r(K,{children:[n.length>0&&r("span",{class:"hsep",children:"·"}),r("span",{class:"header-cwd-reveal",title:`Reveal ${e.cwd} in Finder`,onClick:async()=>{try{await fetch(`/api/fs/open?session=${encodeURIComponent(e.session)}&index=${e.index}&path=.&action=reveal`,{method:"POST"})}catch{}},children:o})]}))}if(e.branch&&n.push(r(K,{children:[r("span",{class:"hsep",children:"·"}),r("span",{children:e.branch})]})),e.pr){const l=lr(e.repo_slug,e.pr),a=Ui(e.pr_state),s=e.ci==="✓"?"ci-ok":e.ci==="✗"?"ci-bad":e.ci==="⟳"?"ci-running":"",o=e.ci&&!a.cls?r(K,{children:[" ",r("span",{class:`header-ci ${s}`,children:e.ci})]}):null,u=r(K,{children:["#",String(e.pr),a.suffix?r("span",{class:"header-pr-state",children:a.suffix}):null,o]}),c=l?r("a",{class:`header-pr ${a.cls}`,href:l,target:"_blank",rel:"noopener",children:u}):r("span",{class:`header-pr ${a.cls}`,children:u});n.push(r(K,{children:[r("span",{class:"hsep",children:"·"}),c]}))}const i=vr(e);if(i&&n.push(r(K,{children:[r("span",{class:"hsep",children:"·"}),r("a",{class:"header-linear",href:i.href,target:"_blank",rel:"noopener",title:i.tip,children:i.id})]})),e.git&&e.git!=="clean"&&n.push(r(K,{children:[r("span",{class:"hsep",children:"·"}),r("span",{class:"header-git",children:e.git})]})),e.agent==="claude"?n.push(r(K,{children:[r("span",{class:"hsep",children:"·"}),r(Mw,{w:e})]})):e.agent&&e.model&&n.push(r(K,{children:[r("span",{class:"hsep",children:"·"}),r("span",{children:e.model.replace(/\s*\(.*\)/,"")})]})),e.agent&&e.context_pct!=null&&n.push(r(K,{children:[r("span",{class:"hsep",children:"·"}),r("span",{children:[e.context_pct,"%"]})]})),e.agent==="claude"&&e.mem){const l=fu(e.mem);n.push(r(K,{children:[r("span",{class:"hsep",children:"·"}),r("span",{class:`header-mem ${l.cls}`,title:l.title,children:["↻ ",l.label]})]}))}return e.api_error&&n.push(r(K,{children:[r("span",{class:"hsep",children:"·"}),r("span",{class:"header-api-error",title:"Claude hit an API error and has written nothing since",children:"⚠ API error"})]})),e.res&&n.push(r(K,{children:[r("span",{class:"hsep",children:"·"}),r("span",{class:"header-res",title:"this pane's whole process tree: memory footprint, and its share of the machine's CPU (100% = every core busy)",children:`${cn(e.res.mem_mb)} mem · ${Au(e.res.cpu_pct)} cpu`})]})),r("header",{id:"detail-pane-header",class:"detail-pane-header","data-agent":e.agent||void 0,children:[n.map((l,a)=>r(K,{children:l})),e.spawner_name&&r("span",{class:`header-lineage${t?"":" lineage-gone"}`,title:t?`spawned by ${e.spawner_name} — click to reveal`:`spawned by ${e.spawner_name}, which is no longer running`,onClick:t?()=>{ke.value=`pane:${e.spawned_by}`,yt({kind:"pane",pid:e.spawned_by})}:void 0,children:["↳ launched by ",e.spawner_name]}),e.status_line&&r("span",{class:"header-status",title:e.status_at?`as of ${Pe(e.status_at)} ago`:void 0,children:e.status_line})]})}function Gw({target:e}){const[t,n]=B(null);return j(()=>{if(!e)return;let i=!0;async function l(){try{const s=await fetch(`/api/pane?${tt(e)}&lines=80`);if(!s.ok)return;const o=await s.json();i&&n(o)}catch{}}l();const a=setInterval(l,Hw);return()=>{i=!1,clearInterval(a)}},[e]),t?r(dw,{data:t,onRefresh:()=>{},containerId:"detail-side",containerClass:"detail-side",idPrefix:"detail"}):r("aside",{id:"detail-side",class:"detail-side"})}function Jw({w:e}){const t=Qd(e);j(()=>{rr.value=e.target},[e.target]),j(()=>{e.pane_id&&(e.channel_unread||0)>0&&fetch(`/api/channel/clear-unread?pane_id=${encodeURIComponent(e.pane_id)}`,{method:"POST"})},[e.pane_id,e.channel_unread]),j(()=>(qs(c=>{let p=c,d=null;const f=p.match(/^(.*?):(\d+)$/);f&&(p=f[1],d=f[2]),kr({path:p,line:d})}),()=>qs(null)),[e.target]),j(()=>{const c=document.getElementById("detail-pane-header"),p=document.getElementById("detail-tab-bar"),d=document.getElementById("detail");if(!c||!d)return;const f=()=>d.style.setProperty("--detail-header-h",`${c.offsetHeight+((p==null?void 0:p.offsetHeight)||0)}px`);f();const h=new ResizeObserver(f);return h.observe(c),p&&h.observe(p),()=>h.disconnect()},[e.target]),j(()=>{if(t!=="terminal")return;const c=requestAnimationFrame(()=>requestAnimationFrame(vi));return()=>cancelAnimationFrame(c)},[t]);const[n,i]=B(!0);j(()=>{if(t!=="terminal")return;const c=()=>i(D1());c();const p=setInterval(c,250);return()=>clearInterval(p)},[t,e.pid]);const l=te(e.state);j(()=>{const c=l.current==="working",p=e.state==="idle"||e.state==="done";if(c&&p&&e.agent){const d=document.getElementById("detail-xterm");d&&(d.classList.add("bell-pulse"),setTimeout(()=>d.classList.remove("bell-pulse"),400))}l.current=e.state},[e.state,e.agent]);const a=Ne.value[e.pid]||[],s=Re.value[e.pid]||"pane",o=s==="pane",u=e.track_name||_e(e);return r("div",{id:"detail-pane",class:"detail-pane",children:[r(Vw,{w:e}),r("div",{id:"detail-tab-bar",class:"detail-tab-bar",children:[r(Ww,{pid:e.pid,paneLabel:u}),e.agent==="claude"&&r(Uw,{mode:t,onMode:c=>{ye("view.switch",{view:c}),Ul(e.pid,c)}})]}),r("div",{class:"detail-pane-body",children:[r("div",{class:"detail-term-host",style:o&&t==="terminal"?"display:contents":"display:none",children:r(_w,{id:"detail-xterm",class:"detail-xterm",target:e.pane_id,agent:e.agent,onPaste:Kw},e.pid)}),r("div",{class:"detail-changes-host",style:s==="changes"?"display:contents":"display:none",children:r(Kk,{target:e.target,active:s==="changes",gitSig:e.git||""})}),a.map(c=>{const p=`file:${c.path}`,d=s===p;return r("div",{class:"detail-preview-host",style:d?"display:contents":"display:none",children:r(fw,{entry:c,active:d})},p)}),!bi.value&&r(Gw,{target:e.target},e.target),!bi.value&&r(Jd,{which:"side"})]}),o&&t==="terminal"&&!n&&r("button",{class:"term-scroll-bottom",title:"Scroll to latest",onClick:vi,children:"⤓"}),o&&t==="terminal"&&r(xw,{})]})}function $l(){return r("div",{id:"detail-empty",class:"detail-empty",children:r("div",{class:"detail-empty-card",children:r("p",{children:["Select a tab on the left, or"," ",r("button",{id:"detail-empty-add",onClick:()=>{var e;return(e=window.__periscopeOpenOmnibox)==null?void 0:e.call(window)},children:"+ open"})," ","to add one."]})})})}function Qw(){var d,f;const e=ke.value,t=ce.value||[],n=!!e&&e.startsWith("pane:"),i=!!e&&e.startsWith("review:"),l=e==="reviews";let a=null;if(i){const[h,m]=(()=>{const b=e.slice(7),x=b.indexOf("/");return x<0?[b,""]:[b.slice(0,x),b.slice(x+1)]})();a=(gt.value||[]).find(b=>b.repo===h&&b.slug===m)||null}j(()=>{(i||l)&&(rr.value=null)},[e]);const s=n?Go(e.slice(5)):null,o=te(new Set);n&&(s==null?void 0:s.agent)==="claude"&&o.current.add(s.pid);const u=new Set(t.map(h=>h.pid)),c=Qd(s);for(const h of[...o.current])if(!(n&&(s==null?void 0:s.pid)===h)&&!u.has(h)&&(o.current.delete(h),Ft.value[h])){const{[h]:b,...x}=Ft.value;Ft.value=x}const p=[...o.current];return r("section",{id:"detail",children:[!e&&r($l,{}),n&&(s?r(Jw,{w:s}):r($l,{})),l&&r(yw,{}),i&&(gt.value===null?r("div",{class:"wt-empty",children:"loading…"}):a?r(vw,{repo:a.repo,branch:a.branch,pr:a.pr,sig:`${(d=a.walkthrough)==null?void 0:d.head}|${(f=a.walkthrough)==null?void 0:f.stale_by}|${a.unresolved}|${a.comments}`},`${a.repo}/${a.branch}`):r($l,{})),p.map(h=>{const m=Go(h),b=n&&(s==null?void 0:s.pid)===h,x=(Re.value[h]||"pane")==="pane";return r("div",{class:"detail-transcript-host",style:b&&x&&c==="transcript"?"display:flex":"display:none",children:r(jw,{target:m==null?void 0:m.target,pid:h,selected:b,state:m==null?void 0:m.state,waitingFor:m==null?void 0:m.waiting_for,spinner:m==null?void 0:m.spinner})},`tr:${h}`)})]})}function Cl(e,t){return t==="all"?!0:t==="needs-input"?e.state==="needs-input":t==="working"?e.state==="working":t==="done"?e.state==="done":t==="idle"?e.state==="idle":t==="agents"?!!e.agent:t==="shell"?e.state==="shell":t==="ci-bad"?e.ci==="✗":!0}const ia=H(!1);function Tl(e,t,n,i=l=>l.key){const l=e||[];if(!n||!t)return l;const a=new Map(l.map(s=>[i(s),s]));return t.map(s=>a.get(i(s))||s)}function El(e,t,n,i=l=>l.key){if(!n||!t)return!1;const l=(e||[]).map(i),a=t.map(i);if(l.length!==a.length)return!0;const s=new Set(a);return l.some(o=>!s.has(o))}function Yw(e,t){return!!t&&!!(e!=null&&e.branch)}function Zw(e,t){return`open ${e!=null&&e.branch?`${e.branch} `:""}worktree in ${t}`}const Xw=900;function Xa(e){return e==="needs-input"?"dot dot-alert dot-pulse":e==="working"?"dot dot-green":e==="done"?"dot dot-blue dot-pulse-done":e==="idle"?"dot dot-grey":"dot dot-none"}function ev(e){return e==="✓"?"ok":e==="✗"?"bad":e==="⟳"?"running":"neutral"}function tv(e){return e?e.replace(/\s*\(.*$/,"").trim():null}function nv(e){return`${Math.round(e/1e3)}k`}function Nn(e){return e.context_pct!=null?`${e.context_pct}%`:e.ctx_tokens!=null?nv(e.ctx_tokens):null}function Yd({label:e,kind:t,renameable:n,onCommit:i}){const[l,a]=B(!1),s=te(null),o=te(!1);j(()=>{l&&s.current&&(s.current.focus(),s.current.select())},[l]);function u(d){n&&(d.preventDefault(),d.stopPropagation(),o.current=!1,a(!0))}function c(d){if(o.current)return;o.current=!0,a(!1);const f=(d||"").trim();f&&f!==e&&i(f)}function p(){o.current||(o.current=!0,a(!1))}return l?r("span",{class:"rail-label",children:r("input",{ref:s,type:"text",class:"rail-rename-input",defaultValue:e,spellcheck:!1,onClick:d=>d.stopPropagation(),onKeyDown:d=>{d.stopPropagation(),d.key==="Enter"?(d.preventDefault(),c(d.currentTarget.value)):d.key==="Escape"&&(d.preventDefault(),p())},onBlur:d=>c(d.currentTarget.value)})}):r("span",{class:"rail-label",onDblClick:n?u:void 0,children:t==="pane"?e:r("b",{children:e})})}function rv({w:e,chip:t,selectedKey:n,onSelect:i,onClose:l,onRename:a,dim:s,dragProps:o,dropPos:u,pinned:c,onTogglePin:p,awaitingSince:d,onMoveAccount:f,onToggleNamePin:h,editor:m,onOpenInEditor:b}){const x=`pane:${e.pid}`,w=x===n,C=w||e.state==="needs-input",y=e.agent?e.state||"idle":"shell",g=s?"":" rail-dim",$=u?" drop-target":"",v=_e(e),E=e.agent||(e.is_claude?"claude":null),M=ql[E],T=e.status_rail||e.status_line,S=e.status_at&&Math.floor(Date.now()/1e3)-e.status_at>Xw,R=tv(e.model),F=e.pr?lr(e.repo_slug,e.pr):null,q=fu(e.mem),L=d?vu(d,Math.floor(Date.now()/1e3)):null,I=Ch(e),O=Ui(e.pr_state),Q=`PR #${e.pr}${O.suffix}`,A=r(K,{children:["#",e.pr,e.ci&&!O.cls?r("span",{class:`pane-ci pane-ci-${ev(e.ci)}`,children:[" ",e.ci]}):null]}),z=e.pr&&(F?r("a",{class:`pane-pill pane-pill-pr ${O.cls}`,href:F,target:"_blank",rel:"noopener",onClick:X=>X.stopPropagation(),title:Q,children:A}):r("span",{class:`pane-pill pane-pill-pr ${O.cls}`,title:Q,children:A})),k=vr(e),W=k&&r("a",{class:"pane-pill pane-pill-linear",href:k.href,target:"_blank",rel:"noopener",onClick:X=>X.stopPropagation(),title:k.tip,children:k.id}),Z=e.account&&e.account!=="default"&&($n()||e.account==="unknown")&&r("span",{class:"pane-pill pane-pill-acct",title:`running on Claude account ${yn(e.account)} — its usage bills that subscription`,children:["@",yn(e.account)]}),_=e.profile&&e.profile!=="default"&&r("span",{class:"rail-profile",title:`running the ${To(e.profile)} profile — a different plugin set and system prompt than a normal pane`,children:To(e.profile)});return r("div",{class:`rail-row child-row pane-row pane-state-${y}${C?" pane-expanded":""}${w?" selected":""}${g}${$}`,"data-drop-pos":u||void 0,draggable:!0,onClick:()=>i(x),...o,children:[r("span",{class:"pane-stripe","aria-hidden":"true"}),r("div",{class:"pane-row-main",children:[M?r("span",{class:`rail-icon ${M.className}`,title:M.label,children:M.glyph}):r("span",{class:"rail-icon icon-shell",children:"$"}),r(Yd,{label:v,kind:"pane",renameable:!0,onCommit:a}),C?R&&r("span",{class:"pane-model",title:e.model,children:R}):Nn(e)!=null&&r("span",{class:`pane-mini-ctx${Vl(e)}`,title:e.ctx_hint||"context window used",children:Nn(e)}),q&&r("span",{class:`rail-mem ${q.cls}`,title:q.title,children:["↻",q.label]}),L&&r("span",{class:`rail-await wait-${L}`,title:`asked you something ${Pe(d)} ago and has had no reply since`,children:["⚠",Pe(d)]}),c&&r("span",{class:"pane-pin-flag",title:"pinned",children:"★"})]}),(t||T||!C&&(z||W||Z||_))&&r("div",{class:`rail-meta${S?" stale":""}`,children:[t&&r("span",{class:"rail-chip",title:e.cwd,children:["⧉ ",t]}),T&&r("span",{class:"rail-status",title:e.status_line,children:T}),!C&&(z||W||Z||_)&&r("span",{class:"rail-chips",children:[z,W,Z,_]})]}),C&&(e.pr||k||Nn(e)!=null||Z||_)&&r("div",{class:"pane-foot",children:[z,W,r("span",{class:"pane-foot-spacer"}),Z,_,Nn(e)!=null&&r("span",{class:`pane-pill pane-pill-ctx${Vl(e)}`,title:e.ctx_hint||"context window used",children:Nn(e)}),e.status_at?r("span",{class:"pane-time",children:Pe(e.status_at)}):null]}),r("div",{class:"pane-actions",children:[I&&r("button",{class:"rail-move-acct",title:`re-open this session on Claude account ${I.label} — spawns a resumed pane there and leaves this one running`,onClick:X=>{X.stopPropagation(),f==null||f(I.id)},children:["→ ",I.label]}),r("button",{class:`rail-pin${c?" pinned":""}`,title:c?"unpin":"pin",onClick:X=>{X.stopPropagation(),p==null||p()},children:c?"★":"☆"}),r("button",{class:`rail-name-pin${e.name_pinned?" pinned":""}`,title:e.name_pinned?"name pinned — click to let periscope rename this tab again":"freeze this name — periscope won't rename this tab",onClick:X=>{X.stopPropagation(),h==null||h()},children:e.name_pinned?"🔒":"🔓"}),Yw(e,m)&&r("button",{class:"rail-editor",title:Zw(e,m),onClick:X=>{X.stopPropagation(),b==null||b()},children:"↗"}),r("button",{class:"rail-close",title:"kill this tab",onClick:X=>{X.stopPropagation(),l()},children:"×"})]})]})}function iv({worktreeKey:e,onOpen:t}){return r("div",{class:"rail-row child-row newtab-row last-in-worktree",onClick:()=>t(e),children:[r("span",{class:"rail-icon",children:"+"}),r("span",{class:"rail-label",children:"New tab"})]})}function lv({label:e,collapsed:t,childCount:n,rolledUp:i,dim:l,onToggle:a,dragProps:s,dropPos:o}){return r("div",{class:`rail-row wt-row${l?"":" rail-dim"}${o?" drop-target":""}`,"data-drop-pos":o||void 0,draggable:!0,onClick:d=>{d.target.closest("button")||d.target.closest("input")||a()},...s,children:[r("span",{class:"rail-chev",children:t?"▸":"▾"}),r("span",{class:"rail-icon icon-worktree",children:"⎇"}),r("span",{class:"rail-label",children:r("b",{children:e})}),t&&n>0?r("span",{class:"rail-count",children:n}):null,r("span",{class:Xa(i)})]})}function Jo({row:e,selectedKey:t,onSelect:n}){var s;const i=`review:${e.repo}/${e.slug}`,l=i===t?" selected":"",a=((s=e.walkthrough)==null?void 0:s.stale_by)>0;return r("div",{class:`rail-row child-row rail-review${l}`,onClick:()=>n(i),children:[r("span",{class:"rail-icon icon-review",children:"◉"}),r("span",{class:"rail-label",children:["review · ",e.walkthrough.stops," stop",e.walkthrough.stops===1?"":"s",a?" · stale":""]}),e.unresolved?r("span",{class:"rail-review-badge",children:e.unresolved}):null]})}function av({kind:e,label:t,collapsed:n,rolledUp:i,dim:l,onToggle:a,onRename:s,onDissolve:o,onTeardown:u,dragProps:c,dropPos:p}){const d=n?"▸":"▾",f=l?"":" rail-dim",h=p?" drop-target":"",[m,b]=B(!1),x=e==="loose"||e==="repo",w=e==="goal"?"⧉":"🗀";return j(()=>{if(!m)return;const C=g=>{g.target.closest(".track-menu")||b(!1)},y=g=>{g.key==="Escape"&&b(!1)};return document.addEventListener("click",C,!0),document.addEventListener("keydown",y),()=>{document.removeEventListener("click",C,!0),document.removeEventListener("keydown",y)}},[m]),r("div",{class:`rail-row repo-row${f}${h}`,"data-drop-pos":p||void 0,draggable:!0,onClick:C=>{C.target.closest("button")||C.target.closest("input")||a()},...c,children:[r("span",{class:"rail-chev",children:d}),r("span",{class:"rail-icon icon-effort",title:e==="goal"?"track":"project",children:w}),r(Yd,{label:t,kind:"track",renameable:e!=="loose",onCommit:s}),r("span",{class:"repo-rule","aria-hidden":"true"}),r("span",{class:Xa(i)}),!x&&r("span",{class:"track-menu",children:[r("button",{class:"rail-track-menu-btn",title:"track actions",onClick:C=>{C.stopPropagation(),b(y=>!y)},children:"⋯"}),m&&r("div",{class:"track-menu-pop",onClick:C=>C.stopPropagation(),children:[r("button",{class:"track-menu-item",onClick:()=>{b(!1),o()},children:["Dissolve ",r("span",{class:"track-menu-hint",children:"tabs survive"})]}),r("button",{class:"track-menu-item track-menu-danger",onClick:()=>{b(!1),u()},children:["Tear down ",r("span",{class:"track-menu-hint",children:"kills tabs"})]})]})]})]})}function an({icon:e,label:t,count:n,collapsed:i,onToggle:l,tone:a}){return r("div",{class:`rail-row section-header${a==="alert"?" section-header-alert":a==="ready"?" section-header-ready":a==="working"?" section-header-working":""}`,onClick:l,children:[r("span",{class:"rail-chev",children:i?"▸":"▾"}),e?r("span",{class:"section-header-icon",children:e}):null,r("span",{class:"section-header-label",children:t}),n!=null&&n>0?r("span",{class:"section-header-count",children:n}):null]})}function $t(e,t,n,i){const l=(e==null?void 0:e.session)||t||"",a=_e(e)||n||"";return`${i?i(l):l} · ${a}`}function Zd(e){const t=[...new Set((e||[]).map(n=>n.session).filter(Boolean))];return n=>hu(n,t)}function Hn(e,t){mu(e,!t)}function Zt(e){return`${e.kind}:${e.pid??e.id}`}function sv(){var M,T,S,R,F,q;me.value;const e=ce.value||[],t=Da.value||[],n=ir.value,i=ft.value,l=sr(),a=Zd(e),s=La(e,t,n,i),o=l["sec:needs"]===!0,u=wu(e,t,n,pt.value),c=l["sec:ready"]===!0,p=Su(e),d=l["sec:running"]===!0,f=c1(Ea(),e),h=l["sec:pinned"]===!0,m=ia.value,b=te(null),x=Tl(s,(M=b.current)==null?void 0:M.needs,m,Zt),w=Tl(u,(T=b.current)==null?void 0:T.ready,m,Zt),C=Tl(p,(S=b.current)==null?void 0:S.running,m,Zt),y=El(s,(R=b.current)==null?void 0:R.needs,m,Zt)||El(u,(F=b.current)==null?void 0:F.ready,m,Zt)||El(p,(q=b.current)==null?void 0:q.running,m,Zt);j(()=>{m||(b.current={needs:s,ready:u,running:p})});function g(){b.current=null}j(()=>{const L=Bs(ft.value,e,"needs-input");L.size!==ft.value.size&&(ft.value=L);const I=Bs(pt.value,e,"done");I.size!==pt.value.size&&(pt.value=I)},[ce.value]);function $(L){g();const I=new Set(n);I.add(L),ir.value=I}function v(L){g(),$u(L)}function E(L){g(),Tu(L)}return r(K,{children:[y&&r("div",{class:"attn-frozen",title:"Move the pointer out of the rail to apply",children:"updates paused"}),x.length>0&&r(K,{children:[r(an,{icon:"⚠",label:"NEEDS YOU",tone:"alert",count:a1(x),collapsed:o,onToggle:()=>Hn("sec:needs",o)}),!o&&x.map(L=>{var I;return L.kind==="live"?r("div",{class:"rail-row attn-row attn-needs",onClick:()=>v(L.w),children:[r("span",{class:"attn-dot dot dot-alert dot-pulse"}),r("span",{class:"attn-label",children:$t(L.w,null,null,a)}),r("span",{class:"attn-reason",children:Mg((I=L.w)==null?void 0:I.waiting_for)})]},`live:${L.pid}`):r("div",{class:"rail-row attn-row attn-needs attn-event",onClick:()=>jt(L.target),children:[r("span",{class:"attn-ico",children:"⚠"}),r("span",{class:"attn-label",children:$t(L.w,L.session,L.name,a)}),r("span",{class:"attn-reason",children:["need_human · ",Pe(L.ts)]}),r("button",{class:"attn-x",title:"dismiss",onClick:O=>{O.stopPropagation(),$(L.id)},children:"×"})]},`evt:${L.id}`)})]}),w.length>0&&r(K,{children:[r(an,{icon:"✓",label:"READY",tone:"ready",count:w.length,collapsed:c,onToggle:()=>Hn("sec:ready",c)}),!c&&w.map(L=>{var I;return L.kind==="live"?r("div",{class:"rail-row attn-row attn-ready",onClick:()=>E(L.w),children:[r("span",{class:"attn-dot dot dot-blue dot-pulse-done"}),r("span",{class:"attn-label",children:$t(L.w,null,null,a)}),r("span",{class:"attn-reason",children:Pe((I=L.w)==null?void 0:I.completed_at)})]},`rlive:${L.pid}`):r("div",{class:"rail-row attn-row attn-ready attn-event",onClick:()=>jt(L.target),children:[r("span",{class:"attn-ico",children:"✓"}),r("span",{class:"attn-label",children:$t(L.w,L.session,L.name,a)}),r("span",{class:"attn-reason",children:["done · ",Pe(L.ts)]}),r("button",{class:"attn-x",title:"dismiss",onClick:O=>{O.stopPropagation(),$(L.id)},children:"×"})]},`revt:${L.id}`)})]}),C.length>0&&r(K,{children:[r(an,{icon:"⟳",label:"RUNNING",tone:"working",count:C.length,collapsed:d,onToggle:()=>Hn("sec:running",d)}),!d&&C.map(L=>{var I;return r("div",{class:"rail-row attn-row attn-running",onClick:()=>at(L.w),children:[r("span",{class:"attn-dot dot dot-green"}),r("span",{class:"attn-label",children:$t(L.w,null,null,a)}),r("span",{class:"attn-reason",children:`${((I=L.w)==null?void 0:I.spinner)||"working"}…`})]},`run:${L.pid}`)})]}),f.length>0&&r(K,{children:[r(an,{icon:"★",label:"PINNED",count:f.length,collapsed:h,onToggle:()=>Hn("sec:pinned",h)}),!h&&f.map(L=>{var I,O;return r("div",{class:"rail-row attn-row attn-pinned",onClick:()=>at(L),children:[r("span",{class:`attn-ico ${((I=ql[L.agent])==null?void 0:I.className)||""}`,children:((O=ql[L.agent])==null?void 0:O.glyph)||"$"}),r("span",{class:"attn-label",children:$t(L,null,null,a)}),r("span",{class:Xa(L.state),style:"margin-left:auto"})]},`pin:${L.pid}`)})]})]})}function ov(){me.value;const e=Da.value||[],t=sr(),n=Zd(ce.value||[]),i=u1(e),l=t["sec:activity"]!==!1;return r(K,{children:[r(an,{label:"ACTIVITY",count:i.length||null,collapsed:l,onToggle:()=>Hn("sec:activity",l)}),!l&&i.map(a=>r("div",{class:`rail-row attn-row attn-activity attn-${a.kind}`,onClick:()=>jt(a.target),children:[r("span",{class:"attn-ico",children:a.kind==="done"?"✓":"•"}),r("span",{class:"attn-label",children:$t(null,a.session,a.name,n)}),r("span",{class:"attn-reason",children:Pe(a.ts)})]},`act:${a.id}`))]})}const cv="";function uv(e){const t=window.__periscopeOpenLauncher;typeof t=="function"&&t(e)}function dv(e,t){return!t||t==="all"?e:e.filter(n=>n.track_id===t)}function hv({live:e,scope:t,onScope:n}){const i=[],l=new Set;for(const a of e)a.track_id&&!l.has(a.track_id)&&(l.add(a.track_id),i.push(a.track_id));return i.length<2?null:r("div",{class:"rail-filter-chips",role:"tablist","aria-label":"filter by track",children:[r("button",{class:`rail-filter-chip${!t||t==="all"?" is-active":""}`,onClick:()=>n("all"),children:"all"}),i.map(a=>r("button",{class:`rail-filter-chip${t===a?" is-active":""}`,onClick:()=>n(a),title:Ci(a,e),children:Ci(a,e)},a))]})}let Qo=0;function fv(){if(Date.now()-Qo<5e3)return;const e=ce.value||[];if(e.length===0)return;Qo=Date.now();const t=Ya(e,Oi.value,Di.value,{trackOrder:gi(),tabsByTrack:ar(),branchOrderByTrack:Ta()},Bt.value),n=gi(),i=ar(),l=t.trackOrder,a={};for(const u of l)a[u]=t.tabsByTrack[u]||[];if(JSON.stringify(l)===JSON.stringify(n)&&JSON.stringify(a)===JSON.stringify(i))return;const s=[...new Set(e.map(u=>u.track_id))],o=(Bt.value||[]).map(u=>u.id);$e({track_order:l,tabs_by_track:a},`sync live=${JSON.stringify(s)} registry=${JSON.stringify(o)} cached=${JSON.stringify(n)}`)}function Xd(e,t,n,i){if(t<0||n<0)return e;const[l]=e.splice(t,1);let a=n-(tA.id===i),{trackOrder:b,tabsByTrack:x,branchesByTrack:w,tabsByBranch:C}=Ya(u,Oi.value,Di.value,{trackOrder:gi(),tabsByTrack:ar(),branchOrderByTrack:Ta()},m),y=sb(b,x,d,gt.value||[]);function g(A){if(A==="reviews"){Ra();return}if(A.startsWith("review:")){const z=A.slice(7),k=z.indexOf("/"),W=(gt.value||[]).find(Z=>Z.repo===z.slice(0,k)&&Z.slug===z.slice(k+1));W&&Eu(W.repo,W.branch);return}ke.value=A,ye("pane.focus",{key:A}),A.startsWith("pane:")&&yt({kind:"pane",pid:A.slice(5)})}function $(A){const z=sr()[A]===!0;mu(A,!z)}async function v(A){await Yn(`Close tab "${_e(A)}"?
+`);return r("div",{class:"tc-diff",children:[t.map((i,l)=>r("div",{class:"tc-diff-del",children:i||" "},`d${l}`)),n.map((i,l)=>r("div",{class:"tc-diff-add",children:i||" "},`a${l}`))]})}function Cv(e){const t=e.input||{};switch(e.name){case"Bash":return t.command||"";case"Write":return t.content||"";default:return""}}function Tv({input:e}){const t=e.questions||[];return r("div",{class:"tc-ask",children:t.map((n,i)=>r("div",{class:"tc-ask-q",children:[r("div",{class:"tc-ask-qhead",children:[n.header&&r("span",{class:"tc-ask-chip",children:n.header}),n.multiSelect&&r("span",{class:"tc-ask-multi",children:"multi-select"})]}),r("div",{class:"tc-ask-question",children:n.question}),r("div",{class:"tc-ask-options",children:(n.options||[]).map((l,a)=>r("div",{class:"tc-ask-opt",children:[r("span",{class:"tc-ask-opt-label",children:l.label}),l.description&&r("span",{class:"tc-ask-opt-desc",children:l.description})]},a))})]},i))})}function Ev({t:e}){var p;const[t,n]=N(!1),i=e.result==null,l=e.name==="Edit",a=e.name==="AskUserQuestion",s=e.name==="Agent"||e.name==="Task",o=Cv(e),c=!i&&e.result!=null&&e.result!=="",u=l||a||!!o||c,h=Sv(e),d=s&&((p=e.input)==null?void 0:p.subagent_type)||"";return r("div",{class:`tc${s?" tc-agent":""}`,children:[r("button",{class:`tc-head${u?" expandable":""}`,onClick:u?()=>n(!t):void 0,children:[r("span",{class:"tc-dot",children:s?"⚇":"⏺"}),r("span",{class:"tc-name",children:e.name}),d&&r("span",{class:"tc-agent-type",children:d}),h&&(e.name==="Read"||e.name==="Edit"||e.name==="Write"||e.name==="MultiEdit"||e.name==="NotebookEdit"?r("span",{class:"tc-arg tc-arg-clickable",title:"Cmd+click to preview",onClick:m=>{!m.metaKey&&!m.ctrlKey||(m.stopPropagation(),wr({path:h,line:null}))},children:h}):r("span",{class:"tc-arg",children:h})),i&&r("span",{class:"tc-running",children:"running…"}),u&&r("span",{class:"tc-caret",children:t?"▾":"▸"})]}),t&&r("div",{class:"tc-detail",children:[l?r($v,{input:e.input||{}}):a?r(Tv,{input:e.input||{}}):o&&r("pre",{class:"tc-cmd",children:o}),c&&r("pre",{class:"tc-out",children:e.result})]})]})}function Pv({m:e,current:t}){if(e.role==="user")return r("div",{class:`turn turn-user${t?" turn-current":""}`,children:[r("span",{class:"turn-user-mark",children:"›"}),r("div",{class:"turn-user-body",children:Cn(e.text)})]});const n=e.tool_uses||[];return r("div",{class:`turn turn-assistant${t?" turn-current":""}`,children:[e.text&&r("div",{class:"turn-prose",children:Cn(e.text)}),n.length>0&&r("div",{class:"turn-tools",children:n.map((i,l)=>r(Ev,{t:i},i.id||l))})]})}function Mv({target:e,composerRef:t}){const[n,i]=N(""),[l,a]=N(!1),s=J(null);async function o(){const d=n;if(!d.trim()||l)return;a(!0),await ie("send",`/api/send?${nt(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paste:d})})&&(await new Promise(f=>setTimeout(f,250)),await ie("send",`/api/send?${nt(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({keys:["Enter"]})}),i(""),s.current&&(s.current.style.height="")),a(!1)}function c(d){d.key==="Enter"&&!d.shiftKey&&(d.preventDefault(),o())}function u(d){const p=d.currentTarget;i(p.value),p.style.height="0px",p.style.height=`${Math.min(p.scrollHeight,140)}px`}async function h(d){var f;const p=((f=d.clipboardData)==null?void 0:f.items)||[];for(const m of p){if(m.kind!=="file"||!m.type.startsWith("image/"))continue;const k=m.getAsFile();if(!k)continue;d.preventDefault();const b=await(await fetch(`/api/paste-image?${nt(e)}&deliver=false`,{method:"POST",headers:{"Content-Type":k.type||"image/png"},body:k})).json().catch(()=>({}));b.ok&&i(C=>`${C}${C&&!C.endsWith(" ")?" ":""}@${b.path} `);return}}return r("div",{class:"transcript-composer",ref:t,children:r("textarea",{ref:s,class:"transcript-composer-input",placeholder:"Message Claude… (Enter to send · Shift+Enter for newline · paste screenshots)",value:n,rows:1,onInput:u,onKeyDown:c,onPaste:h})})}function Av({target:e,pid:t,selected:n,state:i,waitingFor:l,spinner:a}){var m;_v(e,t,n);const s=((m=Bt.value[t])==null?void 0:m.messages)||[],o=J(null),c=J(null),u=J(!0),h=J(""),d=()=>{const k=o.current;k&&u.current&&(k.scrollTop=k.scrollHeight)};H(()=>{const k=s[s.length-1],x=`${s.length}:${k?k.uuid:""}:${k?(k.tool_uses||[]).length:0}`;x!==h.current&&(h.current=x,d())},[s]),H(()=>{const k=c.current,x=o.current;if(!k||!x)return;const b=()=>{x.style.paddingBottom=`${k.offsetHeight+14}px`,requestAnimationFrame(d)};b();const C=new ResizeObserver(b);return C.observe(k),()=>C.disconnect()},[]),H(()=>{(i==="needs-input"||i==="working")&&d()},[i]);function p(k){const x=k.currentTarget;u.current=x.scrollHeight-x.scrollTop-x.clientHeight<80}let f="";for(let k=s.length-1;k>=0;k--)if(s[k].role!=="system"){f=s[k].uuid;break}return r(U,{children:[r("div",{class:"transcript",ref:o,onScroll:p,children:[s.length===0?r("div",{class:"transcript-empty",children:"No transcript yet."}):s.map(k=>k.role==="system"&&k.kind==="compact"?r("div",{class:"transcript-compact",children:r("span",{children:"context compacted"})},k.uuid):r(Pv,{m:k,current:k.uuid===f},k.uuid)),i==="needs-input"&&r("div",{class:"transcript-status transcript-status-waiting",children:[r("span",{class:"transcript-status-dot"}),r("span",{class:"transcript-status-text",children:["Waiting for your input",l?` — ${l}`:""]})]}),i==="working"&&r("div",{class:"transcript-working",children:[r("span",{class:"transcript-working-dot"}),r("span",{class:"transcript-working-verb",children:a?`${a.toLowerCase()}…`:"working…"})]})]}),r(Mv,{target:e,composerRef:c})]})}const Lv=1500;function Iv(e){const t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function Ov({mode:e,onMode:t}){return r("span",{class:"detail-mode-toggle",children:[r("button",{class:e==="transcript"?"is-active":"",onClick:()=>t("transcript"),children:"Transcript"}),r("button",{class:e==="terminal"?"is-active":"",onClick:()=>t("terminal"),children:"Terminal"})]})}function Dv({pid:e,paneLabel:t}){const n=Ne.value[e]||[],i=Re.value[e]||"pane";return r("div",{class:"detail-tab-strip",role:"tablist",children:[r("button",{type:"button",role:"tab",class:`detail-tab${i==="pane"?" is-active":""}`,"aria-selected":i==="pane",onClick:()=>qr(e,"pane"),title:t,children:r("span",{class:"detail-tab-label",children:t})}),r("button",{type:"button",role:"tab",class:`detail-tab${i==="changes"?" is-active":""}`,"aria-selected":i==="changes",onClick:()=>qr(e,"changes"),title:"Changes in this worktree",children:r("span",{class:"detail-tab-label",children:"Changes"})}),n.map(l=>{const a=`file:${l.path}`,s=i===a;return r("button",{type:"button",role:"tab",class:`detail-tab${s?" is-active":""}`,"aria-selected":s,onClick:()=>qr(e,a),title:l.path,children:[r("span",{class:"detail-tab-label",children:Iv(l.path)}),r("span",{class:"detail-tab-close",title:"Close tab",onClick:o=>{o.stopPropagation(),Hc(e,l.path)},children:"×"})]},a)})]})}function lc(e){return(ce.value||[]).find(t=>t.pid===e)||null}function yh(e){return(e==null?void 0:e.agent)!=="claude"?"terminal":Au(e.pid)||"terminal"}async function Rv(e){var n;if(!sr.value)return;const t=((n=e.clipboardData)==null?void 0:n.items)||[];for(const i of t){if(i.kind!=="file"||!i.type.startsWith("image/"))continue;const l=i.getAsFile();if(l){e.preventDefault(),e.stopPropagation();try{const s=await(await fetch(`/api/paste-image?${nt(sr.value)}`,{method:"POST",headers:{"Content-Type":l.type||"image/png"},body:l})).json();s.ok||ro(`\r
+\x1B[31m[periscope: image paste failed: ${s.error}]\x1B[0m`)}catch(a){ro(`\r
+\x1B[31m[periscope: image paste error: ${a.message}]\x1B[0m`)}return}}}function Fv({w:e}){const t=!!e.spawned_by&&(ce.value||[]).some(l=>l.pid===e.spawned_by),n=[];if(e.session&&e.session!==e.branch&&n.push(r("span",{children:r("b",{children:e.session})})),e.cwd){const l=e.cwd.split("/").filter(Boolean),a=l[l.length-1]||"",s=e.branch?e.branch.replace(/[/\\]/g,"-"):null;let o;s&&a===s&&l.length>=2?o=l[l.length-2]:o=l.length>=2?l.slice(-2).join("/"):l[0]||e.cwd,o&&n.push(r(U,{children:[n.length>0&&r("span",{class:"hsep",children:"·"}),r("span",{class:"header-cwd-reveal",title:`Reveal ${e.cwd} in Finder`,onClick:async()=>{try{await fetch(`/api/fs/open?session=${encodeURIComponent(e.session)}&index=${e.index}&path=.&action=reveal`,{method:"POST"})}catch{}},children:o})]}))}if(e.branch&&n.push(r(U,{children:[r("span",{class:"hsep",children:"·"}),r("span",{children:e.branch})]})),e.pr){const l=cr(e.repo_slug,e.pr),a=Gi(e.pr_state),s=e.ci==="✓"?"ci-ok":e.ci==="✗"?"ci-bad":e.ci==="⟳"?"ci-running":"",o=e.ci&&!a.cls?r(U,{children:[" ",r("span",{class:`header-ci ${s}`,children:e.ci})]}):null,c=r(U,{children:["#",String(e.pr),a.suffix?r("span",{class:"header-pr-state",children:a.suffix}):null,o]}),u=l?r("a",{class:`header-pr ${a.cls}`,href:l,target:"_blank",rel:"noopener",children:c}):r("span",{class:`header-pr ${a.cls}`,children:c});n.push(r(U,{children:[r("span",{class:"hsep",children:"·"}),u]}))}const i=xr(e);if(i&&n.push(r(U,{children:[r("span",{class:"hsep",children:"·"}),r("a",{class:"header-linear",href:i.href,target:"_blank",rel:"noopener",title:i.tip,children:i.id})]})),e.git&&e.git!=="clean"&&n.push(r(U,{children:[r("span",{class:"hsep",children:"·"}),r("span",{class:"header-git",children:e.git})]})),e.agent==="claude"?n.push(r(U,{children:[r("span",{class:"hsep",children:"·"}),r(vv,{w:e})]})):e.agent&&e.model&&n.push(r(U,{children:[r("span",{class:"hsep",children:"·"}),r("span",{children:e.model.replace(/\s*\(.*\)/,"")})]})),e.agent&&e.context_pct!=null&&n.push(r(U,{children:[r("span",{class:"hsep",children:"·"}),r("span",{children:[e.context_pct,"%"]})]})),e.agent==="claude"&&e.mem){const l=Tu(e.mem);n.push(r(U,{children:[r("span",{class:"hsep",children:"·"}),r("span",{class:`header-mem ${l.cls}`,title:l.title,children:["↻ ",l.label]})]}))}return e.api_error&&n.push(r(U,{children:[r("span",{class:"hsep",children:"·"}),r("span",{class:"header-api-error",title:"Claude hit an API error and has written nothing since",children:"⚠ API error"})]})),e.res&&n.push(r(U,{children:[r("span",{class:"hsep",children:"·"}),r("span",{class:"header-res",title:"this pane's whole process tree: memory footprint, and its share of the machine's CPU (100% = every core busy)",children:`${fn(e.res.mem_mb)} mem · ${Uu(e.res.cpu_pct)} cpu`})]})),r("header",{id:"detail-pane-header",class:"detail-pane-header","data-agent":e.agent||void 0,children:[n.map((l,a)=>r(U,{children:l})),e.spawner_name&&r("span",{class:`header-lineage${t?"":" lineage-gone"}`,title:t?`spawned by ${e.spawner_name} — click to reveal`:`spawned by ${e.spawner_name}, which is no longer running`,onClick:t?()=>{ke.value=`pane:${e.spawned_by}`,bt({kind:"pane",pid:e.spawned_by})}:void 0,children:["↳ launched by ",e.spawner_name]}),e.status_line&&r("span",{class:"header-status",title:e.status_at?`as of ${Pe(e.status_at)} ago`:void 0,children:e.status_line})]})}function Nv({target:e}){const[t,n]=N(null);return H(()=>{if(!e)return;let i=!0;async function l(){try{const s=await fetch(`/api/pane?${nt(e)}&lines=80`);if(!s.ok)return;const o=await s.json();i&&n(o)}catch{}}l();const a=setInterval(l,Lv);return()=>{i=!1,clearInterval(a)}},[e]),t?r(Kw,{data:t,onRefresh:()=>{},containerId:"detail-side",containerClass:"detail-side",idPrefix:"detail"}):r("aside",{id:"detail-side",class:"detail-side"})}function Bv({w:e}){const t=yh(e);H(()=>{sr.value=e.target},[e.target]),H(()=>{e.pane_id&&(e.channel_unread||0)>0&&fetch(`/api/channel/clear-unread?pane_id=${encodeURIComponent(e.pane_id)}`,{method:"POST"})},[e.pane_id,e.channel_unread]),H(()=>(Xs(u=>{let h=u,d=null;const p=h.match(/^(.*?):(\d+)$/);p&&(h=p[1],d=p[2]),wr({path:h,line:d})}),()=>Xs(null)),[e.target]),H(()=>{const u=document.getElementById("detail-pane-header"),h=document.getElementById("detail-tab-bar"),d=document.getElementById("detail");if(!u||!d)return;const p=()=>d.style.setProperty("--detail-header-h",`${u.offsetHeight+((h==null?void 0:h.offsetHeight)||0)}px`);p();const f=new ResizeObserver(p);return f.observe(u),h&&f.observe(h),()=>f.disconnect()},[e.target]),H(()=>{if(t!=="terminal")return;const u=requestAnimationFrame(()=>requestAnimationFrame(_i));return()=>cancelAnimationFrame(u)},[t]);const[n,i]=N(!0);H(()=>{if(t!=="terminal")return;const u=()=>i(u0());u();const h=setInterval(u,250);return()=>clearInterval(h)},[t,e.pid]);const l=J(e.state);H(()=>{const u=l.current==="working",h=e.state==="idle"||e.state==="done";if(u&&h&&e.agent){const d=document.getElementById("detail-xterm");d&&(d.classList.add("bell-pulse"),setTimeout(()=>d.classList.remove("bell-pulse"),400))}l.current=e.state},[e.state,e.agent]);const a=Ne.value[e.pid]||[],s=Re.value[e.pid]||"pane",o=s==="pane",c=e.track_name||xe(e);return r("div",{id:"detail-pane",class:"detail-pane",children:[r(Fv,{w:e}),r("div",{id:"detail-tab-bar",class:"detail-tab-bar",children:[r(Dv,{pid:e.pid,paneLabel:c}),e.agent==="claude"&&r(Ov,{mode:t,onMode:u=>{ye("view.switch",{view:u}),Ql(e.pid,u)}})]}),r("div",{class:"detail-pane-body",children:[r("div",{class:"detail-term-host",style:o&&t==="terminal"?"display:contents":"display:none",children:r(hv,{id:"detail-xterm",class:"detail-xterm",target:e.pane_id,agent:e.agent,onPaste:Rv},e.pid)}),r("div",{class:"detail-changes-host",style:s==="changes"?"display:contents":"display:none",children:r(Tw,{target:e.target,active:s==="changes",gitSig:e.git||""})}),a.map(u=>{const h=`file:${u.path}`,d=s===h;return r("div",{class:"detail-preview-host",style:d?"display:contents":"display:none",children:r(Gw,{entry:u,active:d})},h)}),!wi.value&&r(Nv,{target:e.target},e.target),!wi.value&&r(gh,{which:"side"})]}),o&&t==="terminal"&&!n&&r("button",{class:"term-scroll-bottom",title:"Scroll to latest",onClick:_i,children:"⤓"}),o&&t==="terminal"&&r(fv,{})]})}function Ml(){return r("div",{id:"detail-empty",class:"detail-empty",children:r("div",{class:"detail-empty-card",children:r("p",{children:["Select a tab on the left, or"," ",r("button",{id:"detail-empty-add",onClick:()=>{var e;return(e=window.__periscopeOpenOmnibox)==null?void 0:e.call(window)},children:"+ open"})," ","to add one."]})})})}function zv(){var d,p;const e=ke.value,t=ce.value||[],n=!!e&&e.startsWith("pane:"),i=!!e&&e.startsWith("review:"),l=e==="reviews";let a=null;if(i){const[f,m]=(()=>{const k=e.slice(7),x=k.indexOf("/");return x<0?[k,""]:[k.slice(0,x),k.slice(x+1)]})();a=(yt.value||[]).find(k=>k.repo===f&&k.slug===m)||null}H(()=>{(i||l)&&(sr.value=null)},[e]);const s=n?lc(e.slice(5)):null,o=J(new Set);n&&(s==null?void 0:s.agent)==="claude"&&o.current.add(s.pid);const c=new Set(t.map(f=>f.pid)),u=yh(s);for(const f of[...o.current])if(!(n&&(s==null?void 0:s.pid)===f)&&!c.has(f)&&(o.current.delete(f),Bt.value[f])){const{[f]:k,...x}=Bt.value;Bt.value=x}const h=[...o.current];return r("section",{id:"detail",children:[!e&&r(Ml,{}),n&&(s?r(Bv,{w:s}):r(Ml,{})),l&&r(Zw,{}),i&&(yt.value===null?r("div",{class:"wt-empty",children:"loading…"}):a?r(dv,{repo:a.repo,branch:a.branch,pr:a.pr,sig:`${(d=a.walkthrough)==null?void 0:d.head}|${(p=a.walkthrough)==null?void 0:p.stale_by}|${a.unresolved}|${a.comments}`},`${a.repo}/${a.branch}`):r(Ml,{})),h.map(f=>{const m=lc(f),k=n&&(s==null?void 0:s.pid)===f,x=(Re.value[f]||"pane")==="pane";return r("div",{class:"detail-transcript-host",style:k&&x&&u==="transcript"?"display:flex":"display:none",children:r(Av,{target:m==null?void 0:m.target,pid:f,selected:k,state:m==null?void 0:m.state,waitingFor:m==null?void 0:m.waiting_for,spinner:m==null?void 0:m.spinner})},`tr:${f}`)})]})}function Al(e,t){return t==="all"?!0:t==="needs-input"?e.state==="needs-input":t==="working"?e.state==="working":t==="done"?e.state==="done":t==="idle"?e.state==="idle":t==="agents"?!!e.agent:t==="shell"?e.state==="shell":t==="ci-bad"?e.ci==="✗":!0}const da=q(!1);function Ll(e,t,n,i=l=>l.key){const l=e||[];if(!n||!t)return l;const a=new Map(l.map(s=>[i(s),s]));return t.map(s=>a.get(i(s))||s)}function Il(e,t,n,i=l=>l.key){if(!n||!t)return!1;const l=(e||[]).map(i),a=t.map(i);if(l.length!==a.length)return!0;const s=new Set(a);return l.some(o=>!s.has(o))}function jv(e,t){return!!t&&!!(e!=null&&e.branch)}function Hv(e,t){return`open ${e!=null&&e.branch?`${e.branch} `:""}worktree in ${t}`}const qv=900;function os(e){return e==="needs-input"?"dot dot-alert dot-pulse":e==="working"?"dot dot-green":e==="done"?"dot dot-blue dot-pulse-done":e==="idle"?"dot dot-grey":"dot dot-none"}function Uv(e){return e==="✓"?"ok":e==="✗"?"bad":e==="⟳"?"running":"neutral"}function Wv(e){return e?e.replace(/\s*\(.*$/,"").trim():null}function Kv(e){return`${Math.round(e/1e3)}k`}function qn(e){return e.context_pct!=null?`${e.context_pct}%`:e.ctx_tokens!=null?Kv(e.ctx_tokens):null}function bh({label:e,kind:t,renameable:n,onCommit:i}){const[l,a]=N(!1),s=J(null),o=J(!1);H(()=>{l&&s.current&&(s.current.focus(),s.current.select())},[l]);function c(d){n&&(d.preventDefault(),d.stopPropagation(),o.current=!1,a(!0))}function u(d){if(o.current)return;o.current=!0,a(!1);const p=(d||"").trim();p&&p!==e&&i(p)}function h(){o.current||(o.current=!0,a(!1))}return l?r("span",{class:"rail-label",children:r("input",{ref:s,type:"text",class:"rail-rename-input",defaultValue:e,spellcheck:!1,onClick:d=>d.stopPropagation(),onKeyDown:d=>{d.stopPropagation(),d.key==="Enter"?(d.preventDefault(),u(d.currentTarget.value)):d.key==="Escape"&&(d.preventDefault(),h())},onBlur:d=>u(d.currentTarget.value)})}):r("span",{class:"rail-label",onDblClick:n?c:void 0,children:t==="pane"?e:r("b",{children:e})})}function Vv({w:e,chip:t,selectedKey:n,onSelect:i,onClose:l,onRename:a,dim:s,dragProps:o,dropPos:c,pinned:u,onTogglePin:h,awaitingSince:d,onMoveAccount:p,onToggleNamePin:f,editor:m,onOpenInEditor:k}){const x=`pane:${e.pid}`,b=x===n,C=b||e.state==="needs-input",g=e.agent?e.state||"idle":"shell",y=s?"":" rail-dim",$=c?" drop-target":"",v=xe(e),E=e.agent||(e.is_claude?"claude":null),M=Jl[E],T=e.status_rail||e.status_line,S=e.status_at&&Math.floor(Date.now()/1e3)-e.status_at>qv,L=Wv(e.model),O=e.pr?cr(e.repo_slug,e.pr):null,j=Tu(e.mem),I=d?Du(d,Math.floor(Date.now()/1e3)):null,D=Vh(e),R=Gi(e.pr_state),Y=`PR #${e.pr}${R.suffix}`,A=r(U,{children:["#",e.pr,e.ci&&!R.cls?r("span",{class:`pane-ci pane-ci-${Uv(e.ci)}`,children:[" ",e.ci]}):null]}),z=e.pr&&(O?r("a",{class:`pane-pill pane-pill-pr ${R.cls}`,href:O,target:"_blank",rel:"noopener",onClick:ee=>ee.stopPropagation(),title:Y,children:A}):r("span",{class:`pane-pill pane-pill-pr ${R.cls}`,title:Y,children:A})),w=xr(e),K=w&&r("a",{class:"pane-pill pane-pill-linear",href:w.href,target:"_blank",rel:"noopener",onClick:ee=>ee.stopPropagation(),title:w.tip,children:w.id}),X=e.account&&e.account!=="default"&&(Mn()||e.account==="unknown")&&r("span",{class:"pane-pill pane-pill-acct",title:`running on Claude account ${vn(e.account)} — its usage bills that subscription`,children:["@",vn(e.account)]}),_=e.profile&&e.profile!=="default"&&r("span",{class:"rail-profile",title:`running the ${Fo(e.profile)} profile — a different plugin set and system prompt than a normal pane`,children:Fo(e.profile)});return r("div",{class:`rail-row child-row pane-row pane-state-${g}${C?" pane-expanded":""}${b?" selected":""}${y}${$}`,"data-drop-pos":c||void 0,draggable:!0,onClick:()=>i(x),...o,children:[r("span",{class:"pane-stripe","aria-hidden":"true"}),r("div",{class:"pane-row-main",children:[M?r("span",{class:`rail-icon ${M.className}`,title:M.label,children:M.glyph}):r("span",{class:"rail-icon icon-shell",children:"$"}),r(bh,{label:v,kind:"pane",renameable:!0,onCommit:a}),C?L&&r("span",{class:"pane-model",title:e.model,children:L}):qn(e)!=null&&r("span",{class:`pane-mini-ctx${Xl(e)}`,title:e.ctx_hint||"context window used",children:qn(e)}),j&&r("span",{class:`rail-mem ${j.cls}`,title:j.title,children:["↻",j.label]}),I&&r("span",{class:`rail-await wait-${I}`,title:`asked you something ${Pe(d)} ago and has had no reply since`,children:["⚠",Pe(d)]}),u&&r("span",{class:"pane-pin-flag",title:"pinned",children:"★"})]}),(t||T||!C&&(z||K||X||_))&&r("div",{class:`rail-meta${S?" stale":""}`,children:[t&&r("span",{class:"rail-chip",title:e.cwd,children:["⧉ ",t]}),T&&r("span",{class:"rail-status",title:e.status_line,children:T}),!C&&(z||K||X||_)&&r("span",{class:"rail-chips",children:[z,K,X,_]})]}),C&&(e.pr||w||qn(e)!=null||X||_)&&r("div",{class:"pane-foot",children:[z,K,r("span",{class:"pane-foot-spacer"}),X,_,qn(e)!=null&&r("span",{class:`pane-pill pane-pill-ctx${Xl(e)}`,title:e.ctx_hint||"context window used",children:qn(e)}),e.status_at?r("span",{class:"pane-time",children:Pe(e.status_at)}):null]}),r("div",{class:"pane-actions",children:[D&&r("button",{class:"rail-move-acct",title:`re-open this session on Claude account ${D.label} — spawns a resumed pane there and leaves this one running`,onClick:ee=>{ee.stopPropagation(),p==null||p(D.id)},children:["→ ",D.label]}),r("button",{class:`rail-pin${u?" pinned":""}`,title:u?"unpin":"pin",onClick:ee=>{ee.stopPropagation(),h==null||h()},children:u?"★":"☆"}),r("button",{class:`rail-name-pin${e.name_pinned?" pinned":""}`,title:e.name_pinned?"name pinned — click to let periscope rename this tab again":"freeze this name — periscope won't rename this tab",onClick:ee=>{ee.stopPropagation(),f==null||f()},children:e.name_pinned?"🔒":"🔓"}),jv(e,m)&&r("button",{class:"rail-editor",title:Hv(e,m),onClick:ee=>{ee.stopPropagation(),k==null||k()},children:"↗"}),r("button",{class:"rail-close",title:"kill this tab",onClick:ee=>{ee.stopPropagation(),l()},children:"×"})]})]})}function Gv({worktreeKey:e,onOpen:t}){return r("div",{class:"rail-row child-row newtab-row last-in-worktree",onClick:()=>t(e),children:[r("span",{class:"rail-icon",children:"+"}),r("span",{class:"rail-label",children:"New tab"})]})}function Jv({label:e,collapsed:t,childCount:n,rolledUp:i,dim:l,onToggle:a,dragProps:s,dropPos:o}){return r("div",{class:`rail-row wt-row${l?"":" rail-dim"}${o?" drop-target":""}`,"data-drop-pos":o||void 0,draggable:!0,onClick:d=>{d.target.closest("button")||d.target.closest("input")||a()},...s,children:[r("span",{class:"rail-chev",children:t?"▸":"▾"}),r("span",{class:"rail-icon icon-worktree",children:"⎇"}),r("span",{class:"rail-label",children:r("b",{children:e})}),t&&n>0?r("span",{class:"rail-count",children:n}):null,r("span",{class:os(i)})]})}function ac({row:e,selectedKey:t,onSelect:n}){var s;const i=`review:${e.repo}/${e.slug}`,l=i===t?" selected":"",a=((s=e.walkthrough)==null?void 0:s.stale_by)>0;return r("div",{class:`rail-row child-row rail-review${l}`,onClick:()=>n(i),children:[r("span",{class:"rail-icon icon-review",children:"◉"}),r("span",{class:"rail-label",children:["review · ",e.walkthrough.stops," stop",e.walkthrough.stops===1?"":"s",a?" · stale":""]}),e.unresolved?r("span",{class:"rail-review-badge",children:e.unresolved}):null]})}function Qv({kind:e,label:t,collapsed:n,rolledUp:i,dim:l,onToggle:a,onRename:s,onDissolve:o,onTeardown:c,dragProps:u,dropPos:h}){const d=n?"▸":"▾",p=l?"":" rail-dim",f=h?" drop-target":"",[m,k]=N(!1),x=e==="loose"||e==="repo",b=e==="goal"?"⧉":"🗀";return H(()=>{if(!m)return;const C=y=>{y.target.closest(".track-menu")||k(!1)},g=y=>{y.key==="Escape"&&k(!1)};return document.addEventListener("click",C,!0),document.addEventListener("keydown",g),()=>{document.removeEventListener("click",C,!0),document.removeEventListener("keydown",g)}},[m]),r("div",{class:`rail-row repo-row${p}${f}`,"data-drop-pos":h||void 0,draggable:!0,onClick:C=>{C.target.closest("button")||C.target.closest("input")||a()},...u,children:[r("span",{class:"rail-chev",children:d}),r("span",{class:"rail-icon icon-effort",title:e==="goal"?"track":"project",children:b}),r(bh,{label:t,kind:"track",renameable:e!=="loose",onCommit:s}),r("span",{class:"repo-rule","aria-hidden":"true"}),r("span",{class:os(i)}),!x&&r("span",{class:"track-menu",children:[r("button",{class:"rail-track-menu-btn",title:"track actions",onClick:C=>{C.stopPropagation(),k(g=>!g)},children:"⋯"}),m&&r("div",{class:"track-menu-pop",onClick:C=>C.stopPropagation(),children:[r("button",{class:"track-menu-item",onClick:()=>{k(!1),o()},children:["Dissolve ",r("span",{class:"track-menu-hint",children:"tabs survive"})]}),r("button",{class:"track-menu-item track-menu-danger",onClick:()=>{k(!1),c()},children:["Tear down ",r("span",{class:"track-menu-hint",children:"kills tabs"})]})]})]})]})}function cn({icon:e,label:t,count:n,collapsed:i,onToggle:l,tone:a}){return r("div",{class:`rail-row section-header${a==="alert"?" section-header-alert":a==="ready"?" section-header-ready":a==="working"?" section-header-working":""}`,onClick:l,children:[r("span",{class:"rail-chev",children:i?"▸":"▾"}),e?r("span",{class:"section-header-icon",children:e}):null,r("span",{class:"section-header-label",children:t}),n!=null&&n>0?r("span",{class:"section-header-count",children:n}):null]})}function Tt(e,t,n,i){const l=(e==null?void 0:e.session)||t||"",a=xe(e)||n||"";return`${i?i(l):l} · ${a}`}function kh(e){const t=[...new Set((e||[]).map(n=>n.session).filter(Boolean))];return n=>Cu(n,t)}function Vn(e,t){Pu(e,!t)}function tn(e){return`${e.kind}:${e.pid??e.id}`}function Yv(){var M,T,S,L,O,j;me.value;const e=ce.value||[],t=qa.value||[],n=or.value,i=pt.value,l=dr(),a=kh(e),s=za(e,t,n,i),o=l["sec:needs"]===!0,c=Ou(e,t,n,mt.value),u=l["sec:ready"]===!0,h=Nu(e),d=l["sec:running"]===!0,p=N1(Ra(),e),f=l["sec:pinned"]===!0,m=da.value,k=J(null),x=Ll(s,(M=k.current)==null?void 0:M.needs,m,tn),b=Ll(c,(T=k.current)==null?void 0:T.ready,m,tn),C=Ll(h,(S=k.current)==null?void 0:S.running,m,tn),g=Il(s,(L=k.current)==null?void 0:L.needs,m,tn)||Il(c,(O=k.current)==null?void 0:O.ready,m,tn)||Il(h,(j=k.current)==null?void 0:j.running,m,tn);H(()=>{m||(k.current={needs:s,ready:c,running:h})});function y(){k.current=null}H(()=>{const I=Js(pt.value,e,"needs-input");I.size!==pt.value.size&&(pt.value=I);const D=Js(mt.value,e,"done");D.size!==mt.value.size&&(mt.value=D)},[ce.value]);function $(I){y();const D=new Set(n);D.add(I),or.value=D}function v(I){y(),Bu(I)}function E(I){y(),ju(I)}return r(U,{children:[g&&r("div",{class:"attn-frozen",title:"Move the pointer out of the rail to apply",children:"updates paused"}),x.length>0&&r(U,{children:[r(cn,{icon:"⚠",label:"NEEDS YOU",tone:"alert",count:D1(x),collapsed:o,onToggle:()=>Vn("sec:needs",o)}),!o&&x.map(I=>{var D;return I.kind==="live"?r("div",{class:"rail-row attn-row attn-needs",onClick:()=>v(I.w),children:[r("span",{class:"attn-dot dot dot-alert dot-pulse"}),r("span",{class:"attn-label",children:Tt(I.w,null,null,a)}),r("span",{class:"attn-reason",children:a1((D=I.w)==null?void 0:D.waiting_for)})]},`live:${I.pid}`):r("div",{class:"rail-row attn-row attn-needs attn-event",onClick:()=>Ut(I.target),children:[r("span",{class:"attn-ico",children:"⚠"}),r("span",{class:"attn-label",children:Tt(I.w,I.session,I.name,a)}),r("span",{class:"attn-reason",children:["need_human · ",Pe(I.ts)]}),r("button",{class:"attn-x",title:"dismiss",onClick:R=>{R.stopPropagation(),$(I.id)},children:"×"})]},`evt:${I.id}`)})]}),b.length>0&&r(U,{children:[r(cn,{icon:"✓",label:"READY",tone:"ready",count:b.length,collapsed:u,onToggle:()=>Vn("sec:ready",u)}),!u&&b.map(I=>{var D;return I.kind==="live"?r("div",{class:"rail-row attn-row attn-ready",onClick:()=>E(I.w),children:[r("span",{class:"attn-dot dot dot-blue dot-pulse-done"}),r("span",{class:"attn-label",children:Tt(I.w,null,null,a)}),r("span",{class:"attn-reason",children:Pe((D=I.w)==null?void 0:D.completed_at)})]},`rlive:${I.pid}`):r("div",{class:"rail-row attn-row attn-ready attn-event",onClick:()=>Ut(I.target),children:[r("span",{class:"attn-ico",children:"✓"}),r("span",{class:"attn-label",children:Tt(I.w,I.session,I.name,a)}),r("span",{class:"attn-reason",children:["done · ",Pe(I.ts)]}),r("button",{class:"attn-x",title:"dismiss",onClick:R=>{R.stopPropagation(),$(I.id)},children:"×"})]},`revt:${I.id}`)})]}),C.length>0&&r(U,{children:[r(cn,{icon:"⟳",label:"RUNNING",tone:"working",count:C.length,collapsed:d,onToggle:()=>Vn("sec:running",d)}),!d&&C.map(I=>{var D;return r("div",{class:"rail-row attn-row attn-running",onClick:()=>ot(I.w),children:[r("span",{class:"attn-dot dot dot-green"}),r("span",{class:"attn-label",children:Tt(I.w,null,null,a)}),r("span",{class:"attn-reason",children:`${((D=I.w)==null?void 0:D.spinner)||"working"}…`})]},`run:${I.pid}`)})]}),p.length>0&&r(U,{children:[r(cn,{icon:"★",label:"PINNED",count:p.length,collapsed:f,onToggle:()=>Vn("sec:pinned",f)}),!f&&p.map(I=>{var D,R;return r("div",{class:"rail-row attn-row attn-pinned",onClick:()=>ot(I),children:[r("span",{class:`attn-ico ${((D=Jl[I.agent])==null?void 0:D.className)||""}`,children:((R=Jl[I.agent])==null?void 0:R.glyph)||"$"}),r("span",{class:"attn-label",children:Tt(I,null,null,a)}),r("span",{class:os(I.state),style:"margin-left:auto"})]},`pin:${I.pid}`)})]})]})}function Zv(){me.value;const e=qa.value||[],t=dr(),n=kh(ce.value||[]),i=B1(e),l=t["sec:activity"]!==!1;return r(U,{children:[r(cn,{label:"ACTIVITY",count:i.length||null,collapsed:l,onToggle:()=>Vn("sec:activity",l)}),!l&&i.map(a=>r("div",{class:`rail-row attn-row attn-activity attn-${a.kind}`,onClick:()=>Ut(a.target),children:[r("span",{class:"attn-ico",children:a.kind==="done"?"✓":"•"}),r("span",{class:"attn-label",children:Tt(null,a.session,a.name,n)}),r("span",{class:"attn-reason",children:Pe(a.ts)})]},`act:${a.id}`))]})}const Xv="";function ex(e){const t=window.__periscopeOpenLauncher;typeof t=="function"&&t(e)}function tx(e,t){return!t||t==="all"?e:e.filter(n=>n.track_id===t)}function nx({live:e,scope:t,onScope:n}){const i=[],l=new Set;for(const a of e)a.track_id&&!l.has(a.track_id)&&(l.add(a.track_id),i.push(a.track_id));return i.length<2?null:r("div",{class:"rail-filter-chips",role:"tablist","aria-label":"filter by track",children:[r("button",{class:`rail-filter-chip${!t||t==="all"?" is-active":""}`,onClick:()=>n("all"),children:"all"}),i.map(a=>r("button",{class:`rail-filter-chip${t===a?" is-active":""}`,onClick:()=>n(a),title:Pi(a,e),children:Pi(a,e)},a))]})}let sc=0;function rx(){if(Date.now()-sc<5e3)return;const e=ce.value||[];if(e.length===0)return;sc=Date.now();const t=as(e,Ni.value,Bi.value,{trackOrder:bi(),tabsByTrack:ur(),branchOrderByTrack:Da()},Ht.value),n=bi(),i=ur(),l=t.trackOrder,a={};for(const c of l)a[c]=t.tabsByTrack[c]||[];if(JSON.stringify(l)===JSON.stringify(n)&&JSON.stringify(a)===JSON.stringify(i))return;const s=[...new Set(e.map(c=>c.track_id))],o=(Ht.value||[]).map(c=>c.id);$e({track_order:l,tabs_by_track:a},`sync live=${JSON.stringify(s)} registry=${JSON.stringify(o)} cached=${JSON.stringify(n)}`)}function wh(e,t,n,i){if(t<0||n<0)return e;const[l]=e.splice(t,1);let a=n-(tA.id===i),{trackOrder:k,tabsByTrack:x,branchesByTrack:b,tabsByBranch:C}=as(c,Ni.value,Bi.value,{trackOrder:bi(),tabsByTrack:ur(),branchOrderByTrack:Da()},m),g=Hb(k,x,d,yt.value||[]);function y(A){if(A==="reviews"){Ua();return}if(A.startsWith("review:")){const z=A.slice(7),w=z.indexOf("/"),K=(yt.value||[]).find(X=>X.repo===z.slice(0,w)&&X.slug===z.slice(w+1));K&&Hu(K.repo,K.branch);return}ke.value=A,ye("pane.focus",{key:A}),A.startsWith("pane:")&&bt({kind:"pane",pid:A.slice(5)})}function $(A){const z=dr()[A]===!0;Pu(A,!z)}async function v(A){await tr(`Close tab "${xe(A)}"?
-This kills its tmux window.`,{okLabel:"Close",danger:!0})&&await ie("close tab",`/api/window?${tt(A.target)}`,{method:"DELETE"})}async function E(A,z,k=!1){const W=`/api/pane/move-account?pid=${encodeURIComponent(A.pid)}&account=${encodeURIComponent(z)}`+(k?"&force=1":""),{data:Z,error:_,reason:X,status:he}=await gr("move account",W,{method:"POST"});if(ye("api:move account",{path:W,method:"POST",ok:!!Z}),Z!=null&&Z.pid){ke.value=`pane:${Z.pid}`,yt({kind:"pane",pid:Z.pid});return}if(he===409&&!k&&(X!=null&&X.startsWith("session looks live"))){await Yn(`${_}
+This kills its tmux window.`,{okLabel:"Close",danger:!0})&&await ie("close tab",`/api/window?${nt(A.target)}`,{method:"DELETE"})}async function E(A,z,w=!1){const K=`/api/pane/move-account?pid=${encodeURIComponent(A.pid)}&account=${encodeURIComponent(z)}`+(w?"&force=1":""),{data:X,error:_,reason:ee,status:he}=await kr("move account",K,{method:"POST"});if(ye("api:move account",{path:K,method:"POST",ok:!!X}),X!=null&&X.pid){ke.value=`pane:${X.pid}`,bt({kind:"pane",pid:X.pid});return}if(he===409&&!w&&(ee!=null&&ee.startsWith("session looks live"))){await tr(`${_}
-Move anyway? The original pane stays open; if the session really is mid-turn, the two copies will interleave writes to one transcript.`,{okLabel:"Move anyway"})&&await E(A,z,!0);return}kn(`move account failed: ${X||"unknown error"}`,"bad",6e3)}async function M(A,z){A.target&&await ie("rename tab",`/api/rename?${tt(A.target)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:z})})}async function T(A){await ie("open in editor","/api/editor/open",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pid:A.pid})})}async function S(A){await ie("pin tab name","/api/name-pin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pid:A.pid,pinned:!A.name_pinned})})}async function R(A,z){await ie("rename track",`/api/tracks?track_id=${encodeURIComponent(A)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:z})})}async function F(A){await ie("dissolve track",`/api/tracks/dissolve?track_id=${encodeURIComponent(A)}`,{method:"POST"})}async function q(A,z){const k=(x[A]||[]).map(_=>d[_]).filter(Boolean).map(_=>_e(_)),W=k.length?`
+Move anyway? The original pane stays open; if the session really is mid-turn, the two copies will interleave writes to one transcript.`,{okLabel:"Move anyway"})&&await E(A,z,!0);return}_n(`move account failed: ${ee||"unknown error"}`,"bad",6e3)}async function M(A,z){A.target&&await ie("rename tab",`/api/rename?${nt(A.target)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:z})})}async function T(A){await ie("open in editor","/api/editor/open",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pid:A.pid})})}async function S(A){await ie("pin tab name","/api/name-pin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pid:A.pid,pinned:!A.name_pinned})})}async function L(A,z){await ie("rename track",`/api/tracks?track_id=${encodeURIComponent(A)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:z})})}async function O(A){await ie("dissolve track",`/api/tracks/dissolve?track_id=${encodeURIComponent(A)}`,{method:"POST"})}async function j(A,z){const w=(x[A]||[]).map(_=>d[_]).filter(Boolean).map(_=>xe(_)),K=w.length?`
-• ${k.join(`
-• `)}`:"";await Yn(`Tear down track "${z}"?
+• ${w.join(`
+• `)}`:"";await tr(`Tear down track "${z}"?
-This kills ${k.length} tab${k.length===1?"":"s"} (their tmux windows):${W}`,{okLabel:"Tear down",danger:!0})&&await ie("teardown track",`/api/tracks/teardown?track_id=${encodeURIComponent(A)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({delete_worktrees:!1})})}function L(A){return{onDragStart:z=>{e.current=A,Et.value={kind:A.kind},z.dataTransfer.effectAllowed="move",z.dataTransfer.setData("text/plain",A.key)},onDragOver:z=>{z.stopPropagation();const k=e.current;if(!k||k.key===A.key){n(null);return}if(!Zo(k,A)){n(null);return}const W=z.currentTarget.getBoundingClientRect(),Z=z.clientY-W.top>W.height/2;z.preventDefault(),z.dataTransfer.dropEffect="move",n({key:A.key,pos:Z?"after":"before"})},onDrop:async z=>{z.preventDefault(),z.stopPropagation();const k=e.current;if(n(null),Et.value=null,e.current=null,!k||k.key===A.key||!Zo(k,A))return;const W=z.currentTarget.getBoundingClientRect(),Z=z.clientY-W.top>W.height/2;if(k.kind==="track")await pv(k.key,A.key,Z);else{const _=A.kind==="track"?A.key.slice(6):A.trackKey;if(A.kind==="pane"&&k.trackKey===_)await mv(k.childKey,A.childKey,k.trackKey,Z);else{const X=d[k.childKey];X&&_&&await Yo(X,_)}}},onDragEnd:()=>{n(null),Et.value=null,e.current=null}}}function I(A){return t&&t.key===A?t.pos:void 0}function O(A){const z=`card:${A}`;return{onDragOver:k=>{const W=e.current;!W||W.kind!=="pane"||W.trackKey===A||(k.preventDefault(),k.dataTransfer.dropEffect="move",n({key:z,pos:"into"}))},onDrop:async k=>{k.preventDefault();const W=e.current;if(n(null),Et.value=null,e.current=null,!W||W.kind!=="pane"||W.trackKey===A)return;const Z=d[W.childKey];Z&&await Yo(Z,A)}}}function Q(A,z){return A.map(k=>d[k]).filter(Boolean).map(k=>r(rv,{w:k,chip:ab(k),selectedKey:o,dim:Cl(k,s),onSelect:g,onClose:()=>v(k),onRename:W=>M(k,W),onMoveAccount:W=>E(k,W),dragProps:L({kind:"pane",key:`pane:${k.pid}`,childKey:k.pid,trackKey:z}),dropPos:I(`pane:${k.pid}`),pinned:Ea().includes(k.pid),onTogglePin:()=>Qg(k.pid),onToggleNamePin:()=>S(k),editor:Ec.value,onOpenInEditor:()=>T(k),awaitingSince:f.get(k.pid)},`pane:${k.pid}`))}return b.length===0?r("aside",{id:"rail","aria-label":"tracks rail",children:[r("div",{class:"rail-head",children:r("span",{children:"Tracks"})}),r("div",{class:"rail-empty",children:["No tmux windows found. Use ",r("code",{children:"+ new"})," to start one."]})]}):r("aside",{id:"rail","aria-label":"tracks rail",onMouseEnter:()=>{ia.value=!0},onMouseLeave:()=>{ia.value=!1},children:[r(sv,{}),r(hv,{live:a,scope:i,onScope:l}),r(an,{label:"TRACKS",count:null,collapsed:p,onToggle:()=>$("sec:projects")}),!p&&b.map(A=>{const z=`track:${A}`,k=c[`repo:${A}`]===!0,W=w[A]||[],Z=W.length>=2,_=Ci(A,u,h),X=x[A]||[],he=X.map(ue=>d[ue]).filter(Boolean),fe=he.map(ue=>ue.state||"shell"),He=Po(fe),Ae=he.length===0||he.some(ue=>Cl(ue,s));return r(yv,{children:[r(av,{kind:ib(A,u,h),label:_,collapsed:k,rolledUp:He,dim:Ae,onToggle:()=>$(`repo:${A}`),onRename:ue=>R(A,ue),onDissolve:()=>F(A),onTeardown:()=>q(A,_),dragProps:L({kind:"track",key:z}),dropPos:I(z)}),!k&&r("div",{class:`rail-group rail-track-card${I(`card:${A}`)?" drop-into":""}`,...O(A),children:[Z?W.map(ue=>{var En,$r;const Me=`${A}::${ue}`,vt=c[`wt:${Me}`]===!0,Gt=((En=C[A])==null?void 0:En[ue])||[],tl=Q(Gt,A),nl=Gt.map(Ce=>d[Ce]).filter(Boolean).map(Ce=>Ce.state||"shell"),Sr=Gt.map(Ce=>d[Ce]).filter(Boolean).some(Ce=>Cl(Ce,s));return r("div",{class:"rail-subgroup",children:[r(lv,{label:ue===cv?"(no branch)":ue,collapsed:vt,childCount:Gt.length,rolledUp:Po(nl),dim:Sr,onToggle:()=>$(`wt:${Me}`),dragProps:{},dropPos:void 0}),!vt&&r("div",{class:"rail-group-body",children:[((($r=y[A])==null?void 0:$r[ue])||[]).map(Ce=>r(Jo,{row:Ce,selectedKey:o,onSelect:g},`review:${Ce.repo}/${Ce.slug}`)),tl]})]},`wt:${Me}`)}):r(K,{children:[Object.values(y[A]||{}).flat().map(ue=>r("div",{class:"rail-group-body rail-review-head",children:r(Jo,{row:ue,selectedKey:o,onSelect:g})},`review:${ue.repo}/${ue.slug}`)),r("div",{class:"rail-group-body",children:Q(X,A)})]}),r("div",{class:"rail-group-body rail-track-newtab",children:r(iv,{worktreeKey:A,onOpen:uv},`newtab:${A}`)})]})]},z)}),r(ov,{})]})}function yv({children:e}){return r(K,{children:e})}function bv(){j(()=>{Tk(),d1(),kk()},[]),j(()=>{document.body.dataset.view||(document.body.dataset.view="split")},[]);const e=te(null);return j(()=>{const t=Object.values(Gd).map(n=>{const i=Vt(()=>Tw(Yg(n.pref)));return it(()=>{var a,s;const l=i.value;l==null?(a=e.current)==null||a.style.removeProperty(n.cssVar):(s=e.current)==null||s.style.setProperty(n.cssVar,`${l}px`)})});return()=>{for(const n of t)n()}},[]),j(()=>it(()=>{var t,n;(t=e.current)==null||t.toggleAttribute("data-rail-hidden",Pu.value),(n=e.current)==null||n.toggleAttribute("data-side-hidden",bi.value)}),[]),r("div",{id:"split-view",ref:e,children:[r(gv,{}),r(Jd,{which:"rail"}),r(Qw,{})]})}function kv(){return r(K,{children:[r(j2,{}),r(bv,{}),r(Bb,{}),r(Pg,{}),r(Q2,{})]})}async function wv(){await Wi(),ye("app.open"),it(()=>{const t=document.documentElement.style;t.setProperty("--sans",or("ui").stack),t.setProperty("--mono",or("code").stack)});const e=Hg();(e==null?void 0:e.kind)==="pane"?ke.value=`pane:${e.pid}`:(e==null?void 0:e.kind)==="review"&&e.repo&&e.branch?ke.value=`review:${e.repo}/${e.branch.replace(/\//g,"--")}`:(e==null?void 0:e.kind)==="reviews"&&(ke.value="reviews"),yh(r(kv,{}),document.getElementById("app")),t0(),W2(),"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js",{scope:"/"}).catch(()=>{})}wv();var Cv=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Tv(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}let la=[],th=[];(()=>{let e="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(t=>t?parseInt(t,36):1);for(let t=0,n=0;t>1;if(e=th[i])t=i+1;else return!0;if(t==n)return!1}}function Xo(e){return e>=127462&&e<=127487}const ec=8205;function Ev(e,t,n=!0,i=!0){return(n?nh:_v)(e,t,i)}function nh(e,t,n){if(t==e.length)return t;t&&rh(e.charCodeAt(t))&&ih(e.charCodeAt(t-1))&&t--;let i=Pl(e,t);for(t+=tc(i);t=0&&Xo(Pl(e,s));)a++,s-=2;if(a%2==0)break;t+=2}else break}return t}function _v(e,t,n){for(;t>0;){let i=nh(e,t-2,n);if(i=56320&&e<57344}function ih(e){return e>=55296&&e<56320}function tc(e){return e<65536?1:2}const aa="ͼ",nc=typeof Symbol>"u"?"__"+aa:Symbol.for(aa),sa=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),rc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class Pv{constructor(t,n){this.rules=[];let{finish:i}=n||{};function l(s){return/^@/.test(s)?[s]:s.split(/,\s*/)}function a(s,o,u,c){let p=[],d=/^@(\w+)\b/.exec(s[0]),f=d&&d[1]=="keyframes";if(d&&o==null)return u.push(s[0]+";");for(let h in o){let m=o[h];if(/&/.test(h))a(h.split(/,\s*/).map(b=>s.map(x=>b.replace(/&/,x))).reduce((b,x)=>b.concat(x)),m,u);else if(m&&typeof m=="object"){if(!d)throw new RangeError("The value of a property ("+h+") should be a primitive value.");a(l(h),m,p,f)}else m!=null&&p.push(h.replace(/_.*/,"").replace(/[A-Z]/g,b=>"-"+b.toLowerCase())+": "+m+";")}(p.length||f)&&u.push((i&&!d&&!c?s.map(i):s).join(", ")+" {"+p.join(" ")+"}")}for(let s in t)a(l(s),t[s],this.rules)}getRules(){return this.rules.join(`
-`)}static newName(){let t=rc[nc]||1;return rc[nc]=t+1,aa+t.toString(36)}static mount(t,n,i){let l=t[sa],a=i&&i.nonce;l?a&&l.setNonce(a):l=new xv(t,a),l.mount(Array.isArray(n)?n:[n],t)}}let ic=new Map;class xv{constructor(t,n){let i=t.ownerDocument||t,l=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&l.CSSStyleSheet){let a=ic.get(i);if(a)return t[sa]=a;this.sheet=new l.CSSStyleSheet,ic.set(i,this)}else this.styleTag=i.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],t[sa]=this}mount(t,n){let i=this.sheet,l=0,a=0;for(let s=0;s-1&&(this.modules.splice(u,1),a--,u=-1),u==-1){if(this.modules.splice(a++,0,o),i)for(let c=0;c",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Sv=typeof navigator<"u"&&/Mac/.test(navigator.platform),$v=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var be=0;be<10;be++)Wt[48+be]=Wt[96+be]=String(be);for(var be=1;be<=24;be++)Wt[be+111]="F"+be;for(var be=65;be<=90;be++)Wt[be]=String.fromCharCode(be+32),Pi[be]=String.fromCharCode(be);for(var Al in Wt)Pi.hasOwnProperty(Al)||(Pi[Al]=Wt[Al]);function Av(e){var t=Sv&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||$v&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",n=!t&&e.key||(e.shiftKey?Pi:Wt)[e.keyCode]||e.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}export{te as A,Pv as S,Zi as _,rr as a,Wt as b,Cv as c,B as d,ms as e,Ev as f,Tv as g,K as h,Av as k,kr as o,mr as r,Pi as s,r as u,j as y};
+This kills ${w.length} tab${w.length===1?"":"s"} (their tmux windows):${K}`,{okLabel:"Tear down",danger:!0})&&await ie("teardown track",`/api/tracks/teardown?track_id=${encodeURIComponent(A)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({delete_worktrees:!1})})}function I(A){return{onDragStart:z=>{e.current=A,Mt.value={kind:A.kind},z.dataTransfer.effectAllowed="move",z.dataTransfer.setData("text/plain",A.key)},onDragOver:z=>{z.stopPropagation();const w=e.current;if(!w||w.key===A.key){n(null);return}if(!cc(w,A)){n(null);return}const K=z.currentTarget.getBoundingClientRect(),X=z.clientY-K.top>K.height/2;z.preventDefault(),z.dataTransfer.dropEffect="move",n({key:A.key,pos:X?"after":"before"})},onDrop:async z=>{z.preventDefault(),z.stopPropagation();const w=e.current;if(n(null),Mt.value=null,e.current=null,!w||w.key===A.key||!cc(w,A))return;const K=z.currentTarget.getBoundingClientRect(),X=z.clientY-K.top>K.height/2;if(w.kind==="track")await ix(w.key,A.key,X);else{const _=A.kind==="track"?A.key.slice(6):A.trackKey;if(A.kind==="pane"&&w.trackKey===_)await lx(w.childKey,A.childKey,w.trackKey,X);else{const ee=d[w.childKey];ee&&_&&await oc(ee,_)}}},onDragEnd:()=>{n(null),Mt.value=null,e.current=null}}}function D(A){return t&&t.key===A?t.pos:void 0}function R(A){const z=`card:${A}`;return{onDragOver:w=>{const K=e.current;!K||K.kind!=="pane"||K.trackKey===A||(w.preventDefault(),w.dataTransfer.dropEffect="move",n({key:z,pos:"into"}))},onDrop:async w=>{w.preventDefault();const K=e.current;if(n(null),Mt.value=null,e.current=null,!K||K.kind!=="pane"||K.trackKey===A)return;const X=d[K.childKey];X&&await oc(X,A)}}}function Y(A,z){return A.map(w=>d[w]).filter(Boolean).map(w=>r(Vv,{w,chip:jb(w),selectedKey:o,dim:Al(w,s),onSelect:y,onClose:()=>v(w),onRename:K=>M(w,K),onMoveAccount:K=>E(w,K),dragProps:I({kind:"pane",key:`pane:${w.pid}`,childKey:w.pid,trackKey:z}),dropPos:D(`pane:${w.pid}`),pinned:Ra().includes(w.pid),onTogglePin:()=>$1(w.pid),onToggleNamePin:()=>S(w),editor:Bc.value,onOpenInEditor:()=>T(w),awaitingSince:p.get(w.pid)},`pane:${w.pid}`))}return k.length===0?r("aside",{id:"rail","aria-label":"tracks rail",children:[r("div",{class:"rail-head",children:r("span",{children:"Tracks"})}),r("div",{class:"rail-empty",children:["No tmux windows found. Use ",r("code",{children:"+ new"})," to start one."]})]}):r("aside",{id:"rail","aria-label":"tracks rail",onMouseEnter:()=>{da.value=!0},onMouseLeave:()=>{da.value=!1},children:[r(Yv,{}),r(nx,{live:a,scope:i,onScope:l}),r(cn,{label:"TRACKS",count:null,collapsed:h,onToggle:()=>$("sec:projects")}),!h&&k.map(A=>{const z=`track:${A}`,w=u[`repo:${A}`]===!0,K=b[A]||[],X=K.length>=2,_=Pi(A,c,f),ee=x[A]||[],he=ee.map(ue=>d[ue]).filter(Boolean),fe=he.map(ue=>ue.state||"shell"),He=Bo(fe),Me=he.length===0||he.some(ue=>Al(ue,s));return r(sx,{children:[r(Qv,{kind:Bb(A,c,f),label:_,collapsed:w,rolledUp:He,dim:Me,onToggle:()=>$(`repo:${A}`),onRename:ue=>L(A,ue),onDissolve:()=>O(A),onTeardown:()=>j(A,_),dragProps:I({kind:"track",key:z}),dropPos:D(z)}),!w&&r("div",{class:`rail-group rail-track-card${D(`card:${A}`)?" drop-into":""}`,...R(A),children:[X?K.map(ue=>{var In,Cr;const Ae=`${A}::${ue}`,xt=u[`wt:${Ae}`]===!0,Yt=((In=C[A])==null?void 0:In[ue])||[],ll=Y(Yt,A),al=Yt.map(Ce=>d[Ce]).filter(Boolean).map(Ce=>Ce.state||"shell"),$r=Yt.map(Ce=>d[Ce]).filter(Boolean).some(Ce=>Al(Ce,s));return r("div",{class:"rail-subgroup",children:[r(Jv,{label:ue===Xv?"(no branch)":ue,collapsed:xt,childCount:Yt.length,rolledUp:Bo(al),dim:$r,onToggle:()=>$(`wt:${Ae}`),dragProps:{},dropPos:void 0}),!xt&&r("div",{class:"rail-group-body",children:[(((Cr=g[A])==null?void 0:Cr[ue])||[]).map(Ce=>r(ac,{row:Ce,selectedKey:o,onSelect:y},`review:${Ce.repo}/${Ce.slug}`)),ll]})]},`wt:${Ae}`)}):r(U,{children:[Object.values(g[A]||{}).flat().map(ue=>r("div",{class:"rail-group-body rail-review-head",children:r(ac,{row:ue,selectedKey:o,onSelect:y})},`review:${ue.repo}/${ue.slug}`)),r("div",{class:"rail-group-body",children:Y(ee,A)})]}),r("div",{class:"rail-group-body rail-track-newtab",children:r(Gv,{worktreeKey:A,onOpen:ex},`newtab:${A}`)})]})]},z)}),r(Zv,{})]})}function sx({children:e}){return r(U,{children:e})}function ox(){H(()=>{ow(),z1(),ew()},[]),H(()=>{document.body.dataset.view||(document.body.dataset.view="split")},[]);const e=J(null);return H(()=>{const t=Object.values(mh).map(n=>{const i=Qt(()=>yv(C1(n.pref)));return at(()=>{var a,s;const l=i.value;l==null?(a=e.current)==null||a.style.removeProperty(n.cssVar):(s=e.current)==null||s.style.setProperty(n.cssVar,`${l}px`)})});return()=>{for(const n of t)n()}},[]),H(()=>at(()=>{var t,n;(t=e.current)==null||t.toggleAttribute("data-rail-hidden",qu.value),(n=e.current)==null||n.toggleAttribute("data-side-hidden",wi.value)}),[]),r("div",{id:"split-view",ref:e,children:[r(ax,{}),r(gh,{which:"rail"}),r(zv,{})]})}function cx(){return r(U,{children:[r(xb,{}),r(ox,{}),r(wk,{}),r(i1,{}),r(Ab,{})]})}async function ux(){await Ji(),ye("app.open"),at(()=>{const t=document.documentElement.style;t.setProperty("--sans",hr("ui").stack),t.setProperty("--mono",hr("code").stack)});const e=y1();(e==null?void 0:e.kind)==="pane"?ke.value=`pane:${e.pid}`:(e==null?void 0:e.kind)==="review"&&e.repo&&e.branch?ke.value=`review:${e.repo}/${e.branch.replace(/\//g,"--")}`:(e==null?void 0:e.kind)==="reviews"&&(ke.value="reviews"),Nh(r(cx,{}),document.getElementById("app")),M0(),Cb(),"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js",{scope:"/"}).catch(()=>{})}ux();var gx=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function yx(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}let ha=[],xh=[];(()=>{let e="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(t=>t?parseInt(t,36):1);for(let t=0,n=0;t>1;if(e=xh[i])t=i+1;else return!0;if(t==n)return!1}}function uc(e){return e>=127462&&e<=127487}const dc=8205;function bx(e,t,n=!0,i=!0){return(n?_h:hx)(e,t,i)}function _h(e,t,n){if(t==e.length)return t;t&&Sh(e.charCodeAt(t))&&$h(e.charCodeAt(t-1))&&t--;let i=Ol(e,t);for(t+=hc(i);t=0&&uc(Ol(e,s));)a++,s-=2;if(a%2==0)break;t+=2}else break}return t}function hx(e,t,n){for(;t>0;){let i=_h(e,t-2,n);if(i=56320&&e<57344}function $h(e){return e>=55296&&e<56320}function hc(e){return e<65536?1:2}const fa="ͼ",fc=typeof Symbol>"u"?"__"+fa:Symbol.for(fa),pa=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),pc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class kx{constructor(t,n){this.rules=[];let{finish:i}=n||{};function l(s){return/^@/.test(s)?[s]:s.split(/,\s*/)}function a(s,o,c,u){let h=[],d=/^@(\w+)\b/.exec(s[0]),p=d&&d[1]=="keyframes";if(d&&o==null)return c.push(s[0]+";");for(let f in o){let m=o[f];if(/&/.test(f))a(f.split(/,\s*/).map(k=>s.map(x=>k.replace(/&/,x))).reduce((k,x)=>k.concat(x)),m,c);else if(m&&typeof m=="object"){if(!d)throw new RangeError("The value of a property ("+f+") should be a primitive value.");a(l(f),m,h,p)}else m!=null&&h.push(f.replace(/_.*/,"").replace(/[A-Z]/g,k=>"-"+k.toLowerCase())+": "+m+";")}(h.length||p)&&c.push((i&&!d&&!u?s.map(i):s).join(", ")+" {"+h.join(" ")+"}")}for(let s in t)a(l(s),t[s],this.rules)}getRules(){return this.rules.join(`
+`)}static newName(){let t=pc[fc]||1;return pc[fc]=t+1,fa+t.toString(36)}static mount(t,n,i){let l=t[pa],a=i&&i.nonce;l?a&&l.setNonce(a):l=new fx(t,a),l.mount(Array.isArray(n)?n:[n],t)}}let mc=new Map;class fx{constructor(t,n){let i=t.ownerDocument||t,l=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&l.CSSStyleSheet){let a=mc.get(i);if(a)return t[pa]=a;this.sheet=new l.CSSStyleSheet,mc.set(i,this)}else this.styleTag=i.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],t[pa]=this}mount(t,n){let i=this.sheet,l=0,a=0;for(let s=0;s-1&&(this.modules.splice(c,1),a--,c=-1),c==-1){if(this.modules.splice(a++,0,o),i)for(let u=0;u",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},px=typeof navigator<"u"&&/Mac/.test(navigator.platform),mx=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var be=0;be<10;be++)Gt[48+be]=Gt[96+be]=String(be);for(var be=1;be<=24;be++)Gt[be+111]="F"+be;for(var be=65;be<=90;be++)Gt[be]=String.fromCharCode(be+32),Ii[be]=String.fromCharCode(be);for(var Dl in Gt)Ii.hasOwnProperty(Dl)||(Ii[Dl]=Gt[Dl]);function wx(e){var t=px&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||mx&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",n=!t&&e.key||(e.shiftKey?Ii:Gt)[e.keyCode]||e.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}export{J as A,kx as S,nl as _,sr as a,Gt as b,gx as c,N as d,Ss as e,bx as f,yx as g,U as h,wx as k,wr as o,Cn as r,Ii as s,r as u,H as y};
diff --git a/static/src/overlays/Lightbox.jsx b/static/src/overlays/Lightbox.jsx
new file mode 100644
index 00000000..81fdb5ae
--- /dev/null
+++ b/static/src/overlays/Lightbox.jsx
@@ -0,0 +1,100 @@
+// Full-size view for a walkthrough diagram or image (THI-443 D4). One host,
+// mounted at the app root by Overlays.jsx, and one signal: a zoomable diagram
+// or image calls openLightbox, and the host draws it at natural size over a
+// backdrop that scrolls both ways.
+import { signal } from "@preact/signals";
+import { useEffect, useRef } from "preact/hooks";
+import { useEscape } from "../hooks/useEscape.js";
+import { renderDiagram } from "../split/mermaidRender.js";
+
+// { kind: "svg", code } | { kind: "img", src, alt }, plus `from`: the element
+// that opened it, refocused on close so keyboard users land where they were.
+// A diagram carries its source, not its drawn SVG: copying the host's
+// innerHTML duplicated the SVG's ids, so the copy's arrowheads bound to the
+// original's s and vanished once that host was hidden.
+export const lightbox = signal(null);
+
+export function openLightbox(item) {
+ lightbox.value = { ...item, from: typeof document === "undefined" ? null : document.activeElement };
+}
+
+export function closeLightbox() {
+ const from = lightbox.value?.from;
+ lightbox.value = null;
+ // Only if it's still on the page — a card or banner that opened this and
+ // was removed underneath it shouldn't yank focus onto a detached node.
+ // preventScroll: `from` can be a stop section (tabIndex -1), whose own
+ // scrollIntoView-on-focus would otherwise snap the page back to its top.
+ if (from?.isConnected) from.focus?.({ preventScroll: true });
+}
+
+// Pure Tab trap: the dialog has exactly two focusable stops (the scroller,
+// ✕); Tab always moves to the other one.
+export function nextFocus(active, body, close) {
+ return active === close ? body : close;
+}
+
+// Pure: closing on a backdrop click needs the whole gesture on the backdrop
+// — mousedown, mouseup and the click itself — or a drag starting in the
+// content (mouseup over the padding) or starting on the backdrop and ending
+// in the content (mousedown over the padding) would close the lightbox.
+export function isBackdropClose(mouseDown, mouseUp, click) {
+ return mouseDown && mouseUp && click;
+}
+
+export function LightboxHost() {
+ const item = lightbox.value;
+ const body = useRef(null);
+ const svgHost = useRef(null);
+ const closeBtn = useRef(null);
+ const down = useRef(false); // mousedown landed on the backdrop itself, not a drag out of the content
+ const up = useRef(false); // mouseup landed on the backdrop itself, not a drag in from the content
+ useEscape(closeLightbox, !!item);
+ useEffect(() => {
+ if (!item) return;
+ // The scroller, not ✕: arrow keys and Page Down then scroll a big diagram.
+ body.current?.focus();
+ if (item.kind !== "svg") return;
+ let alive = true;
+ renderDiagram(item.code)
+ .then(({ svg: markup }) => {
+ if (!alive || !svgHost.current) return;
+ // Only ever mermaid's own sanitized SVG (strict mode runs DOMPurify)
+ // — the convention #8 exception, as in Mermaid.jsx.
+ svgHost.current.innerHTML = markup;
+ const svg = svgHost.current.querySelector("svg");
+ const vb = svg?.viewBox?.baseVal;
+ if (svg && vb?.width) {
+ // Natural size: mermaid's inline max-width and width="100%" would refit it.
+ svg.style.maxWidth = "none";
+ svg.setAttribute("width", String(Math.round(vb.width)));
+ svg.setAttribute("height", String(Math.round(vb.height)));
+ }
+ })
+ .catch(() => {}); // it already drew once on the page; a re-render failure here is inert
+ return () => { alive = false; };
+ }, [item]);
+ if (!item) return null;
+ // Close only on a plain click of the backdrop: the mousedown and mouseup
+ // that bracket it must both have landed there too (see isBackdropClose).
+ const onMouseDown = (e) => { down.current = e.target === e.currentTarget; };
+ const onMouseUp = (e) => { up.current = e.target === e.currentTarget; };
+ const onBackdrop = (e) => {
+ if (isBackdropClose(down.current, up.current, e.target === e.currentTarget)) closeLightbox();
+ };
+ // aria-modal promises focus stays in here: Tab moves between the scroller and ✕.
+ const onKeyDown = (e) => {
+ if (e.key !== "Tab") return;
+ e.preventDefault();
+ nextFocus(document.activeElement, body.current, closeBtn.current)?.focus();
+ };
+ return (
+
+
✕
+
+ {item.kind === "img" ?
:
}
+
+
+ );
+}
diff --git a/static/src/overlays/Overlays.jsx b/static/src/overlays/Overlays.jsx
index 7188d7a8..7d070bc9 100644
--- a/static/src/overlays/Overlays.jsx
+++ b/static/src/overlays/Overlays.jsx
@@ -10,6 +10,7 @@ import { initExternalLinks } from "../tauri.js";
import { CleanupModal } from "./CleanupModal.jsx";
import { CommandsModal } from "./CommandsModal.jsx";
import { LauncherModal } from "./LauncherModal.jsx";
+import { LightboxHost } from "./Lightbox.jsx";
import { OpenOmnibox } from "./OpenOmnibox.jsx";
import { SettingsModal } from "./SettingsModal.jsx";
@@ -32,6 +33,9 @@ export function Overlays() {
+ {/* Here, not in the walkthrough: inside #split-view (fixed, z-index 1) the
+ sticky header (z-index 10) would paint over it, ✕ included. */}
+
>
);
}
diff --git a/static/src/overlays/__tests__/lightbox.test.jsx b/static/src/overlays/__tests__/lightbox.test.jsx
new file mode 100644
index 00000000..e2451097
--- /dev/null
+++ b/static/src/overlays/__tests__/lightbox.test.jsx
@@ -0,0 +1,125 @@
+import { options } from "preact";
+import render from "preact-render-to-string";
+import { afterEach, beforeEach, describe, expect, it } from "vitest";
+import { Mermaid } from "../../split/Mermaid.jsx";
+import { renderMarkdown } from "../../split/markdown.jsx";
+import { closeLightbox, isBackdropClose, LightboxHost, lightbox, nextFocus, openLightbox } from "../Lightbox.jsx";
+
+afterEach(() => { lightbox.value = null; });
+
+// Vnodes, not a DOM: renderMarkdown/Mermaid return preact vnode trees whose
+// children live at `props.children`. Walk that to find one by its class,
+// the same shape a real render would hand the browser.
+function findByClass(vnode, cls) {
+ if (vnode == null || typeof vnode !== "object") return null;
+ if (Array.isArray(vnode)) {
+ for (const child of vnode) {
+ const found = findByClass(child, cls);
+ if (found) return found;
+ }
+ return null;
+ }
+ if (vnode.props?.class === cls) return vnode;
+ return findByClass(vnode.props?.children, cls);
+}
+
+describe("lightbox", () => {
+ it("renders nothing while closed", () => {
+ expect(render( )).toBe("");
+ });
+ it("shows an image at natural size in a focusable scroller with a close button, and closes", () => {
+ openLightbox({ kind: "img", src: "https://example.com/a.png", alt: "chart" });
+ const html = render( );
+ expect(html).toContain('role="dialog"');
+ expect(html).toContain('aria-modal="true"');
+ expect(html).toContain(' {
+ openLightbox({ kind: "svg", code: "flowchart LR\n a --> b" });
+ expect(render( )).toContain('class="lightbox-svg"');
+ });
+});
+
+describe("closeLightbox", () => {
+ it("refocuses what opened it without scrolling, if it's still in the document", () => {
+ // preventScroll: `from` can be a stop section (tabIndex -1); a plain
+ // focus() would scroll the page back to it.
+ const from = { focus: (opts) => { from.calledWith = opts; }, isConnected: true };
+ lightbox.value = { kind: "img", src: "x", alt: "", from };
+ closeLightbox();
+ expect(from.calledWith).toEqual({ preventScroll: true });
+ expect(lightbox.value).toBeNull();
+ });
+ it("skips focus for an opener that's left the document", () => {
+ const from = { focus: () => { throw new Error("must not be called"); }, isConnected: false };
+ lightbox.value = { kind: "img", src: "x", alt: "", from };
+ closeLightbox();
+ expect(lightbox.value).toBeNull();
+ });
+});
+
+describe("nextFocus", () => {
+ it("cycles between the scroller and the close button both ways", () => {
+ const body = { name: "body" };
+ const close = { name: "close" };
+ expect(nextFocus(close, body, close)).toBe(body);
+ expect(nextFocus(body, body, close)).toBe(close);
+ });
+});
+
+describe("isBackdropClose", () => {
+ it("closes only when the mousedown, the mouseup and the click all land on the backdrop", () => {
+ expect(isBackdropClose(true, true, true)).toBe(true);
+ });
+ it("stays open for a drag that starts in the content and ends on the backdrop", () => {
+ expect(isBackdropClose(false, true, true)).toBe(false);
+ });
+ it("stays open for a drag that starts on the backdrop and ends in the content", () => {
+ expect(isBackdropClose(true, false, true)).toBe(false);
+ });
+});
+
+describe("markdown zoom -> lightbox", () => {
+ it("opens an image at its resolved src when its zoom button is pressed", () => {
+ const out = renderMarkdown("", { zoom: true, resolveUrl: (u) => `/r/${u}` });
+ const btn = findByClass(out, "md-img-zoom");
+ expect(btn).toBeTruthy();
+ btn.props.onClick();
+ expect(lightbox.value).toMatchObject({ kind: "img", src: "/r/a.png", alt: "chart" });
+ });
+});
+
+describe("Mermaid's own zoom", () => {
+ let prevVnode;
+ beforeEach(() => { prevVnode = options.vnode; });
+ afterEach(() => { options.vnode = prevVnode; });
+
+ it("opens the diagram's own source, and ignores a click on a link inside it", () => {
+ let btn;
+ let host;
+ // options.vnode fires for every vnode h() creates, render-to-string
+ // included, so this is how to reach a handler a render-to-string pass
+ // would otherwise discard. Chain to the previous hook rather than clobber it.
+ options.vnode = (v) => {
+ prevVnode?.(v);
+ if (v.props?.class === "md-mermaid-zoom") btn = v;
+ if (v.props?.class === "md-mermaid-svg is-zoomable") host = v;
+ };
+ render(b"} zoom />);
+
+ btn.props.onClick();
+ expect(lightbox.value).toMatchObject({ kind: "svg", code: "flowchart LR\n a-->b" });
+
+ lightbox.value = null;
+ host.props.onClick({ target: { closest: () => ({}) } }); // a link under the click
+ expect(lightbox.value).toBeNull();
+
+ host.props.onClick({ target: { closest: () => null } }); // no link under the click
+ expect(lightbox.value).toMatchObject({ kind: "svg", code: "flowchart LR\n a-->b" });
+ });
+});
diff --git a/static/src/review/Walkthrough.jsx b/static/src/review/Walkthrough.jsx
index a50e92af..ad4402f7 100644
--- a/static/src/review/Walkthrough.jsx
+++ b/static/src/review/Walkthrough.jsx
@@ -1,14 +1,20 @@
-// The native review walkthrough: stops as cards (structural claims), the
-// branch diff's matching hunks collapsed under each, and a comment box per
-// stop. Reads /api/reviews/walkthrough; the file is the artifact, this is a
-// lens on it (spec D2/D5). No pane target here, so hunk heads and unmatched
-// chips are inert.
-import { useEffect, useState } from "preact/hooks";
+// The native review walkthrough (THI-443): a fixed header over one scrolling
+// body. Each stop is a card: its title row, its diagrams across the full
+// width, then its prose beside its files and code changes. Reads
+// /api/reviews/walkthrough; the file is the artifact, this is a lens on it
+// (2026-10-26 spec D2). No pane target here, so hunk heads are inert. The
+// lightbox host lives in Overlays.jsx, at the app root.
+import { Component } from "preact";
+import { useCallback, useEffect, useMemo, useRef, useState } from "preact/hooks";
import { Hunk, langFor } from "../diff/ChangesTab.jsx";
import { refreshReviews } from "../poll.js";
+import { Mermaid } from "../split/Mermaid.jsx";
import { renderMarkdown } from "../split/markdown.jsx";
import { prStateMeta } from "../util.js";
-import { matchRefs, parseWalkthrough } from "./walkthrough.js";
+import {
+ appliesRefetch, COLLAPSE_LINES, commentsLabel, evidenceFor, evidenceIndex, HIDDEN_WHY, hiddenSummary, isReviewed,
+ lineCount, markQueue, parseWalkthrough, stopSig, withMark,
+} from "./walkthrough.js";
async function postJson(url, body) {
const res = await fetch(url, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) });
@@ -16,6 +22,47 @@ async function postJson(url, body) {
return { ok: res.ok, status: res.status, data };
}
+// An error's `detail`, when it is words. FastAPI's 422s carry a list of
+// objects there, which would show as "[object Object]".
+const detailText = (data) => (typeof data?.detail === "string" && data.detail ? data.detail : null);
+
+// The keys the comment box listens for, named the way this keyboard labels them.
+export function sendHint(platform) {
+ return /Mac|iPhone|iPad/.test(platform || "") ? "⌘↩ to send" : "Ctrl+↩ to send";
+}
+const SEND_HINT = sendHint(typeof navigator === "undefined" ? "" : navigator.platform);
+
+// What a comment POST's result does to the box: a delivered or saved comment
+// closes it; anything else keeps the text so nothing typed is lost.
+export function commentOutcome(r) {
+ if (r.ok) return { close: true, note: "sent to the owning pane" };
+ if (r.status === 409) return { close: true, note: `saved, ${detailText(r.data) || "not delivered"}` };
+ return { close: false, note: detailText(r.data) || `HTTP ${r.status}` };
+}
+
+// Smooth scrolling unless the viewer asked for less motion.
+const motion = () => (typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth");
+
+const kindOf = (stop) => (stop.knownKind ? stop.kind : "other");
+
+// Bring a file block into view and flash it. Wide, the column scrolls on its
+// own, so move it rather than the page. Otherwise bring the file into view only
+// if it isn't already ("nearest"), so a column that fits on screen never jumps
+// the page (D5). Narrow, the column is static; asking its overflow, not just
+// its heights, sends it down the page path every time.
+export function reveal(c, el) {
+ if (getComputedStyle(c).overflowY !== "visible" && c.scrollHeight > c.clientHeight) {
+ c.scrollTo({ top: el.offsetTop - 8, behavior: motion() });
+ } else {
+ el.scrollIntoView({ block: "nearest", behavior: motion() });
+ }
+ // Restart the flash even on a second click of the same file: the reflow
+ // between remove and add makes the browser replay the animation.
+ el.classList.remove("is-flash");
+ el.getBoundingClientRect();
+ el.classList.add("is-flash");
+}
+
function Comments({ list }) {
if (!list.length) return null;
return (
@@ -24,25 +71,74 @@ function Comments({ list }) {
- {renderMarkdown(c.body, { demote: false, softBreaks: "space" })}
+ {renderMarkdown(c.body, { demote: true, softBreaks: "space" })}
))}
);
}
+// The open box's text and buttons, pure, so a render test can see them. The
+// note lives in CommentBox, outside the open and closed states.
+export function CommentForm({ stop, text, busy, textRef, onInput, onSend, onCancel }) {
+ return (
+ <>
+