"use client";
import { useEffect, useState } from "react";
import { createPortal } from "react-dom";
/** The 409 extraction_running line (owner phrasing, node interlude):
* the server's error names the extraction; the ACTIVITY DOCK is the
* surface the user actually watches drain. Exported pure for pins. */
export const EXTRACTION_RETRY_LINE = "An extraction is running — try again when the activity dock drains.";
/**
* Node deletion (node interlude, Platform's 50bfcba engine) — the
* confirm surface, portaled z-50 like the session-delete dialog whose
* tone it follows. FULL DEATH by owner ruling: the node, every edge
* touching it, every event naming it, its position.
*
* MINIMAL BY OWNER RULING (2026-09-30): NO pre-flight impact read —
* what full death takes is obvious (the edges die with the node), the
* fetch flickered the dialog open-closed, and richer facts would only
* grow more confusing as deletion semantics evolve (rewiring talk is
* on the table). The screen is: title, names, one permanence line,
* Cancel / Delete. The 409 extraction_running still gets the dock
* phrasing with a Try-again — the run is never aborted server-side,
* it clears on its own; other failures state themselves plainly.
*
* WORDING: "node"/"nodes" — THE UI word for graph objects (owner
* ruling, same day, standardized everywhere in the UI).
*/
/** The dialog's pure body — exported for SSR pins (the settings-dialog
* body pattern). The wrapper owns state + effects + the portal. */
export function DeleteNodeBody({
nodes,
busy,
failure,
onClose,
onRun,
}: {
/** One node (the canvas context menu) or many (the chain table's
* selection). One names it alone; many pluralize the title and
* list the names. */
nodes: { id: string; name: string }[];
busy: boolean;
failure: { code: string; error: string } | null;
onClose: () => void;
onRun: () => void;
}) {
return (
{/* The node name(s) below the title in JetBrains Mono (owner,
2026-09-24): the name is the payload — mono suits it, and
NO code-block chrome (the font already says code). Owner,
2026-10-13 polish: title loses the serif display look for the
abort-turn look (text-sm font-semibold mono, red kept), and
the names drop the sized-up text-lg for normal text-sm —
still white, still mono. Same shape as the session dialog.
A multi-selection lists its names (capped at 8 + "and K
more" — the count in the title carries the full number). */}
{nodes.length === 1
? "This permanently deletes the node — this cannot be undone."
: `This permanently deletes all ${nodes.length} nodes — this cannot be undone.`}