/**
 * Minimal, theme-free HTML rendering of a session trace (header + entries +
 * leaf id). Used as a canonical fallback when the full styled export pipeline
 * is unavailable.
 */
const ShortcutXLTraceTitlePrefix = 'ShortcutXL Trace: ';
function escapeHtml(value) {
    return value
        .replaceAll('&', '&amp;')
        .replaceAll('<', '&lt;')
        .replaceAll('>', '&gt;')
        .replaceAll('"', '&quot;')
        .replaceAll("'", '&#39;');
}
function createTraceTitle(fileName) {
    return `${ShortcutXLTraceTitlePrefix}${fileName}`;
}
/** Render a session trace as a self-contained HTML document with the JSONL and structured view. */
export function renderCanonicalTraceHtml(source, options) {
    const title = options.title ?? createTraceTitle(options.defaultFileName);
    const jsonl = [source.header, ...source.entries]
        .filter((entry) => entry != null)
        .map((entry) => JSON.stringify(entry))
        .join('\n');
    const sessionData = JSON.stringify(source, null, 2);
    return `<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>${escapeHtml(title)}</title>
    <style>
      :root {
        color-scheme: light;
        font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
      }
      body {
        margin: 0;
        padding: 24px;
        background: #f6f4ee;
        color: #1f1b16;
      }
      main {
        max-width: 1500px;
        margin: 0 auto;
      }
      h1 {
        font-size: 20px;
        margin: 0 0 12px;
      }
      p {
        margin: 0 0 16px;
        line-height: 1.5;
      }
      .meta {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        gap: 12px;
        margin-bottom: 20px;
      }
      .card {
        background: #fffdf8;
        border: 1px solid #d9d1c7;
        border-radius: 12px;
        padding: 12px 14px;
      }
      .label {
        display: block;
        font-size: 11px;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: #6a5f54;
        margin-bottom: 6px;
      }
      pre {
        overflow: auto;
        white-space: pre-wrap;
        word-break: break-word;
        background: #fffdf8;
        border: 1px solid #d9d1c7;
        border-radius: 12px;
        padding: 16px;
        margin: 0 0 20px;
      }
    </style>
  </head>
  <body>
    <main>
      <h1>${escapeHtml(title)}</h1>
      <p>${escapeHtml(options.summary ?? 'ShortcutXL trace export.')}</p>
      <section class="meta">
        <div class="card">
          <span class="label">Session ID</span>
          <div>${escapeHtml(source.header?.id ?? 'unknown')}</div>
        </div>
        <div class="card">
          <span class="label">Entries</span>
          <div>${source.entries.length}</div>
        </div>
        <div class="card">
          <span class="label">Leaf ID</span>
          <div>${escapeHtml(source.leafId ?? 'none')}</div>
        </div>
      </section>
      <h2>JSONL</h2>
      <pre>${escapeHtml(jsonl)}</pre>
      <h2>Structured Trace</h2>
      <pre>${escapeHtml(sessionData)}</pre>
    </main>
  </body>
</html>`;
}
//# sourceMappingURL=canonical-trace-html.js.map