---
// One line of agent-prompt text: `code` runs and highlighted `<placeholders>`.
// `<agent>` is the reader's picked agent (command in code, name in prose),
// filled in on copy.
import { AGENT_PLACEHOLDER } from '../lib/agents';
import { promptRuns, promptWords, type PromptPart } from '../lib/examples';
import Agent from './Agent.astro';
interface Props {
text: string;
}
const runs = promptRuns(Astro.props.text);
const isAgent = (p: PromptPart) => p.placeholder && p.text === AGENT_PLACEHOLDER;
---
{
runs.map((run) =>
run.code ? (
<code>
{promptWords(run.parts).map((w) =>
'space' in w ? (
w.space
) : (
<span class="prompt-word">{w.parts.map((p) => (isAgent(p) ? <Agent cmd /> : p.placeholder ? <mark>{p.text}</mark> : p.text))}</span>
),
)}
</code>
) : (
run.parts.map((p) => (isAgent(p) ? <Agent /> : p.placeholder ? <mark>{p.text}</mark> : p.text))
),
)
}