---
title: "API Documentation"
description: "Application scaffold: an API reference in the style of the big developer portals - guides, resources with their object schemas, one page per endpoint with parameters, responses and code samples in curl, JavaScript and Python, a Try it form answered by an in-browser sandbox, a defuss-rpc reference generated from the API's source with calls to the page or a live server, every page as Markdown and JSON, and a search over every endpoint with defuss-search - keywords at once, by meaning once a small model has loaded; routed with defuss-dom-router and in English and German with defuss-i18n."
slug: "scaffold-api-docs"
---

import { DocPage, PageHeader, DocText, DocLink } from "../../lib/components/index";

<DocPage meta={meta}>

<PageHeader slug="scaffold-api-docs" title="API Documentation" introStyle="max-width:44rem;">
  The API reference of "Acme", the fictional workspace product of the <DocLink href="website-docs-help.html">Docs & Help</DocLink> template: guides, resources and one page per endpoint. Fill in a <strong>Try it</strong> form and send it - an in-browser sandbox answers, and the code samples follow every value you type. Press <kbd class="kbd">⌘K</kbd> to search every endpoint, parameter and guide. The same workspace also comes as a <a class="link" href="https://github.com/kyr0/defuss-rpc" target="_blank" rel="noopener">defuss-rpc</a> API whose reference is generated from its source: <strong>Call it</strong> answers from that API in the page or from a running defuss-rpc server, with the answer in a <DocLink href="property-tree.html">Property Tree</DocLink>. Every page also exists as Markdown and as JSON (<a class="link" href="../api-docs/llms.txt">api-docs/llms.txt</a> lists them). Part of the <DocLink href="application-scaffolds.html">Application Scaffolds</DocLink>.
</PageHeader>

<div class="flex flex-wrap items-center gap-2 mb-6">
  <a class="btn" href="app-api-docs.html" target="_blank" rel="noopener"><i data-lucide="maximize-2"></i> Open full screen</a>
  <a class="btn" data-variant="outline" href="#how-it-works">How it works</a>
</div>

```html example label="API reference" schema="none" height="50" mode="desktop" sandbox="links" hint="The whole reference in one source. Guides, resources and endpoints are routes (#/guides/errors, #/ref/tasks, #/ref/tasks/create) of defuss-dom-router, written from one data block in English and German; the language switch translates the frame with defuss-i18n. The search (also ⌘K) ranks every endpoint, parameter and guide with defuss-search in the language shown: BM25 at once, fused with a ColBERT model once it has loaded in the background. Try it sends the form to a sandbox in the page; the curl, JavaScript and Python samples follow the form. The defuss-rpc reference (#/rpc) is written from rpc.docs.json, which defuss-rpc schema generated from the API's source; Call it answers from that API in the page or from a running defuss-rpc server." previewStyle="align-items:stretch;padding:0;"
<!-- the search model's modules import packages by name - this map names their pinned builds -->
<script type="importmap">
  {
    "imports": {
      "defuss-db": "https://cdn.jsdelivr.net/npm/defuss-db@2.0.2/dist/index.mjs",
      "defuss-db/client.js": "https://cdn.jsdelivr.net/npm/defuss-db@2.0.2/dist/client.mjs",
      "@huggingface/tokenizers": "https://cdn.jsdelivr.net/npm/@huggingface/tokenizers@0.2.0/dist/tokenizers.min.mjs",
      "onnxruntime-web/webgpu": "https://cdn.jsdelivr.net/npm/onnxruntime-web@1.30.0/dist/ort.wasm.bundle.min.mjs",
      "defuss-vectorsearch/turboquant.js": "https://cdn.jsdelivr.net/npm/defuss-vectorsearch@0.4.0/dist/turboquant.mjs",
      "defuss-lexicalsearch": "https://cdn.jsdelivr.net/npm/defuss-lexicalsearch@0.4.0/dist/index.js"
    }
  }
</script>
<style>
  /* Acme API: the scaffold's own glue - a three-column reference (navigation, the page, its code) in the system
     tokens, so a theme or dark mode restyles it. Methods carry a hue each; the code panels stay dark in both modes. */
  .ad {
    --ad-code: oklch(0.18 0.012 260);
    --ad-code-line: oklch(0.3 0.012 260);
    container-type: inline-size;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-columns: minmax(0, 1fr);
    height: var(--scaffold-height, 50rem);
    overflow: hidden;
    background: var(--background);
    color: var(--foreground);
    font-family: var(--font-sans);
  }
  .ad [hidden] {
    display: none !important;
  }
  .ad-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 3.5rem;
    padding-inline: 1rem;
    border-block-end: 1px solid var(--border);
    background: var(--card);
  }
  .ad-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: inherit;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    & svg {
      width: 1.25rem;
      height: 1.25rem;
      color: var(--primary);
    }
    & small {
      color: var(--muted-foreground);
      font-weight: 500;
    }
  }
  .ad-bar .select {
    width: auto;
  }
  .ad-search {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 0.5rem;
    max-width: 24rem;
    margin-inline-start: auto;
    padding: 0.375rem 0.5rem 0.375rem 0.75rem;
    border: 1px solid var(--input);
    border-radius: var(--radius-md);
    background: var(--background);
    color: var(--muted-foreground);
    font: inherit;
    font-size: 0.875rem;
    cursor: pointer;
    & svg {
      width: 1rem;
      height: 1rem;
    }
    & span {
      flex: 1;
      text-align: start;
    }
  }
  .ad-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
  .ad-menu {
    display: none;
  }
  .ad-body {
    position: relative;
    display: grid;
    grid-template-columns: 16rem minmax(0, 1fr);
    min-height: 0;
  }
  .ad-side {
    overflow: auto;
    overscroll-behavior: contain;
    padding: 1rem 0.75rem 1.5rem;
    border-inline-end: 1px solid var(--border);
    background: var(--card);
  }
  .ad-side .mk-docs-navigation {
    font-size: 0.875rem;
  }
  .ad-side .mk-docs-navigation a {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
  }
  .ad-key-state {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-block-start: 1.25rem;
    padding: 0.625rem 0.75rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    color: var(--muted-foreground);
    font-size: 0.8125rem;
    & i,
    & svg {
      width: 0.875rem;
      height: 0.875rem;
    }
  }
  .ad-main {
    container: ad-main / inline-size;
    overflow: auto;
    overscroll-behavior: contain;
    scroll-padding-block-start: 1rem;
  }
  .ad-page {
    max-width: 76rem;
    padding: 1.75rem clamp(1rem, 3cqi, 2.5rem) 3rem;
  }
  .ad-version-note {
    margin-block-end: 1.25rem;
  }
  /* the method tag: one hue per method, readable on the page and on the code panel */
  .ad-method {
    --ad-h: 150;
    display: inline-flex;
    flex: none;
    align-items: center;
    align-self: center;
    justify-content: center;
    min-width: 3.25rem;
    padding: 0.0625rem 0.375rem;
    border-radius: var(--radius-sm);
    background: oklch(0.6 0.13 var(--ad-h) / 0.14);
    color: oklch(0.45 0.13 var(--ad-h));
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    &[data-method='POST'] {
      --ad-h: 255;
    }
    &[data-method='PATCH'] {
      --ad-h: 70;
    }
    &[data-method='DELETE'] {
      --ad-h: 25;
    }
  }
  .dark .ad .ad-method,
  .ad .ad-code-panel .ad-method {
    background: oklch(0.7 0.12 var(--ad-h) / 0.18);
    color: oklch(0.82 0.12 var(--ad-h));
  }
  .ad-side .ad-method {
    min-width: 2.75rem;
    font-size: 0.625rem;
  }
  .ad-article {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 27rem);
    gap: 2rem 2.5rem;
    align-items: start;
  }
  .ad-article > .mk-docs-content {
    max-width: none;
  }
  /* sticky, and never taller than the app below its bar: a long answer scrolls inside the aside, not out of reach */
  .ad-aside {
    position: sticky;
    top: 0;
    display: grid;
    align-content: start;
    gap: 1rem;
    max-block-size: calc(var(--scaffold-height, 50rem) - 3.5rem - 2rem);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .ad-endpoint-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-block: 0.5rem 1rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    & code {
      flex: 1;
      background: none;
      overflow-wrap: anywhere;
    }
  }
  .ad-params {
    display: grid;
    margin: 0 0 1.5rem;
    padding: 0;
    list-style: none;
    border-block-start: 1px solid var(--border);
    & > li {
      display: grid;
      gap: 0.25rem;
      padding-block: 0.75rem;
      border-block-end: 1px solid var(--border);
    }
    & p {
      margin: 0;
      color: var(--muted-foreground);
      font-size: 0.875rem;
    }
  }
  .ad-param-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem;
    font-size: 0.875rem;
    & code {
      font-weight: 600;
    }
    & .ad-type {
      color: var(--muted-foreground);
      font-family: var(--font-mono);
      font-size: 0.75rem;
    }
    & .ad-required {
      color: var(--destructive);
      font-size: 0.75rem;
      font-weight: 500;
    }
  }
  .ad-enum {
    color: var(--muted-foreground);
    font-size: 0.8125rem;
    & code {
      font-size: 0.75rem;
    }
  }
  .ad-responses {
    display: grid;
    gap: 0.5rem;
    margin: 0 0 1.5rem;
    padding: 0;
    list-style: none;
    & li {
      display: flex;
      gap: 0.75rem;
      align-items: baseline;
      font-size: 0.875rem;
    }
  }
  .ad-status {
    --ad-h: 150;
    min-width: 2.5rem;
    color: oklch(0.5 0.13 var(--ad-h));
    font-family: var(--font-mono);
    font-weight: 600;
    &[data-class='4'] {
      --ad-h: 40;
    }
    &[data-class='5'] {
      --ad-h: 25;
    }
  }
  .dark .ad .ad-status,
  .ad .ad-code-panel .ad-status {
    color: oklch(0.8 0.13 var(--ad-h));
  }
  /* the try-it form */
  .ad-try {
    margin-block-end: 1.5rem;
  }
  .ad-try .card-content {
    display: grid;
    gap: 0.875rem;
  }
  .ad-try-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
    gap: 0.75rem 1rem;
  }
  .ad-field {
    display: grid;
    gap: 0.375rem;
    & .label {
      font-family: var(--font-mono);
      font-size: 0.8125rem;
    }
  }
  .ad-try-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
  }
  /* code panels: the request samples (a Code Example block) and the live response */
  .ad-aside .mk-code-block {
    margin: 0;
  }
  .ad .mk-code-block:has(input[value='curl']:checked) [data-tab='curl'],
  .ad .mk-code-block:has(input[value='js']:checked) [data-tab='js'],
  .ad .mk-code-block:has(input[value='python']:checked) [data-tab='python'] {
    display: block;
  }
  /* an empty painted line keeps its height */
  .ad .mk-code-block code > span:empty::before {
    content: ' ';
  }
  .ad .mk-code-block pre {
    max-height: 22rem;
    overflow: auto;
  }
  .ad-code-panel {
    overflow: hidden;
    border-radius: var(--radius-lg);
    background: var(--ad-code);
    color: oklch(0.92 0 0);
    font-size: 0.8125rem;
  }
  .ad-code-head {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    min-height: 2.5rem;
    padding-inline: 1rem;
    border-block-end: 1px solid var(--ad-code-line);
    color: oklch(0.75 0 0);
    font-size: 0.75rem;
    & strong {
      margin-inline-end: auto;
      color: oklch(0.92 0 0);
      font-weight: 600;
    }
    & .ad-meta {
      font-family: var(--font-mono);
    }
  }
  .ad-code-panel pre {
    max-height: 22rem;
    margin: 0;
    padding: 0.875rem 1rem;
    overflow: auto;
    background: none;
    color: inherit;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.6;
    white-space: pre;
  }
  .ad-code-panel .ad-empty {
    margin: 0;
    padding: 1rem;
    color: oklch(0.72 0 0);
    font-size: 0.8125rem;
  }
  /* defuss-rpc: every call is POST /rpc - the tag says RPC, or STREAM for a generator */
  .ad-method[data-method='RPC'] {
    --ad-h: 300;
  }
  .ad-method[data-method='STREAM'] {
    --ad-h: 200;
  }
  /* each page as Markdown and JSON, for readers that do not run the app */
  .ad-doc-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem 0.75rem;
    margin: -0.5rem 0 1.25rem;
    color: var(--muted-foreground);
    font-size: 0.8125rem;
    & a {
      display: inline-flex;
      align-items: center;
      gap: 0.25rem;
      color: inherit;
      text-underline-offset: 3px;
    }
    & svg {
      width: 0.875rem;
      height: 0.875rem;
    }
  }
  .ad-signature {
    margin: 0 0 1.25rem;
    padding: 0.75rem 1rem;
    overflow-x: auto;
    border-radius: var(--radius-lg);
    background: var(--ad-code);
    color: oklch(0.92 0 0);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    white-space: pre;
  }
  .ad-badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
    margin-block-end: 1rem;
  }
  .ad-rpc-wide {
    grid-column: 1 / -1;
  }
  /* trees as high as their rows (rpcFit), one row a fixed height */
  .ad-rpc-tree,
  .ad-rpc-result .property-tree {
    --property-tree-row-height: 1.75rem;
  }
  /* a listing Shiki has not painted (offline, or still loading) keeps the inset of a painted line */
  .ad .mk-code-block code:not(:has(> span)) {
    padding-inline: 1rem;
    white-space: pre;
  }
  .ad-rpc-frames {
    display: grid;
    gap: 0.25rem;
    max-block-size: 10rem;
    margin: 0 0 0.75rem;
    padding: 0;
    overflow: auto;
    list-style: none;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    & li {
      padding: 0.25rem 0.5rem;
      border-radius: var(--radius-sm);
      background: var(--muted);
      overflow-wrap: anywhere;
    }
  }
  .ad-rpc-error {
    margin: 0 0 0.75rem;
    color: var(--destructive);
    font-size: 0.8125rem;
  }
  .ad .mk-code-block:has(input[value='ts']:checked) [data-tab='ts'],
  .ad .mk-code-block:has(input[value='fetch']:checked) [data-tab='fetch'],
  .ad .mk-code-block:has(input[value='rcurl']:checked) [data-tab='rcurl'] {
    display: block;
  }
  /* the resource and home pages */
  .ad-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: 1rem;
    margin-block: 1rem 2rem;
  }
  .ad-cards .card {
    color: inherit;
    text-decoration: none;
    transition: border-color 0.15s;
    &:hover {
      border-color: var(--ring);
    }
  }
  .ad-ops {
    display: grid;
    margin: 0 0 1.5rem;
    padding: 0;
    list-style: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    & li + li {
      border-block-start: 1px solid var(--border);
    }
    & a {
      display: grid;
      grid-template-columns: auto minmax(0, 1fr) auto;
      gap: 0.75rem;
      align-items: center;
      padding: 0.625rem 0.875rem;
      color: inherit;
      text-decoration: none;
      &:hover {
        background: var(--muted);
      }
    }
    & code {
      color: var(--muted-foreground);
      font-size: 0.8125rem;
      overflow-wrap: anywhere;
    }
  }
  .ad .mk-docs-content-prose pre {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    background: var(--ad-code);
    color: oklch(0.92 0 0);
    overflow: auto;
  }
  .ad .mk-docs-content-prose pre code {
    background: none;
    color: inherit;
  }
  /* the search palette: a method and a path beside each hit, the timing below */
  .ad .command .command-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    color: inherit;
    text-decoration: none;
    & .ad-hit-path {
      margin-inline-start: auto;
      color: var(--muted-foreground);
      font-family: var(--font-mono);
      font-size: 0.75rem;
    }
  }
  .ad-find-status {
    margin: 0;
    padding: 0.5rem 0.875rem;
    border-block-start: 1px solid var(--border);
    color: var(--muted-foreground);
    font-size: 0.75rem;
  }
  /* narrower: the code column goes under the page, then the navigation becomes a drawer behind the menu button */
  @container ad-main (width < 56rem) {
    .ad-article {
      grid-template-columns: minmax(0, 1fr);
    }
    .ad-aside {
      position: static;
    }
  }
  @container (width < 48rem) {
    .ad-menu {
      display: inline-flex;
    }
    .ad-search kbd,
    .ad-brand small,
    .ad-bar .select {
      display: none;
    }
    /* the search and Authorize shrink to their icons; their labels stay the accessible names */
    .ad-search {
      flex: none;
      padding: 0.5rem;
    }
    .ad-search span,
    .ad-controls [data-ad-authorize] span {
      position: absolute;
      width: 1px;
      height: 1px;
      overflow: hidden;
      clip-path: inset(50%);
      white-space: nowrap;
    }
    .ad-bar {
      gap: 0.375rem;
      padding-inline: 0.5rem;
    }
    .ad-body {
      grid-template-columns: minmax(0, 1fr);
    }
    .ad-side {
      position: absolute;
      inset: 0 auto 0 0;
      z-index: 5;
      width: min(18rem, 85%);
      box-shadow: var(--shadow-lg);
      translate: -100% 0;
      visibility: hidden;
      transition:
        translate 0.2s,
        visibility 0.2s;
    }
    .ad[data-menu-open] .ad-side {
      translate: 0 0;
      visibility: visible;
    }
  }
  @media (prefers-reduced-motion: reduce) {
    .ad-side {
      transition: none;
    }
  }
</style>
<div class="ad" data-ad data-i18n-component>
  <header class="ad-bar">
    <button
      class="btn ad-menu"
      type="button"
      data-variant="ghost"
      data-size="icon"
      data-ad-menu
      aria-expanded="false"
      aria-label="Menu"
      data-i18n-aria-label-en="Menu"
      data-i18n-aria-label-de="Menü"
    >
      <i data-lucide="menu"></i>
    </button>
    <a class="ad-brand" href="#/" data-router-link
      ><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
        <path d="m18 16 4-4-4-4" />
        <path d="m6 8-4 4 4 4" />
        <path d="m14.5 4-5 16" /></svg
      >Acme API <small data-i18n-target="brand-sub">reference</small></a
    >
    <select
      class="select"
      data-size="sm"
      data-ad-version
      aria-label="API version"
      data-i18n-aria-label-en="API version"
      data-i18n-aria-label-de="API-Version"
    >
      <option value="v4" data-i18n-target="version-latest">v4 (latest)</option>
      <option value="v3">v3</option>
    </select>
    <button class="ad-search" type="button" data-command-trigger="ad-find">
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
        <circle cx="11" cy="11" r="8" />
        <path d="m21 21-4.3-4.3" /></svg
      ><span data-i18n-target="search">Search the API</span
      ><kbd class="kbd-group"><kbd class="kbd">⌘</kbd><kbd class="kbd">K</kbd></kbd>
    </button>
    <div class="ad-controls">
      <button class="btn" type="button" data-variant="outline" data-size="sm" data-ad-authorize>
        <i data-lucide="key-round"></i><span data-i18n-target="authorize" data-ad-key-off>Authorize</span
        ><span data-i18n-target="authorized" data-ad-key-on hidden>Authorized</span>
      </button>
      <div
        class="language-switcher"
        data-app-locale
        role="group"
        aria-label="Language"
        data-i18n-aria-label-en="Language"
        data-i18n-aria-label-de="Sprache"
        data-languages="en de"
        data-value="en"
        data-size="sm"
        data-display="code"
        data-align="end"
      ></div>
      <label class="swap" data-variant="rotate" data-size="sm">
        <input
          type="checkbox"
          data-ad-mode
          aria-label="Dark mode"
          data-i18n-aria-label-en="Dark mode"
          data-i18n-aria-label-de="Dunkler Modus"
        />
        <span class="swap-on" aria-hidden="true"><i data-lucide="moon"></i></span>
        <span class="swap-off" aria-hidden="true"><i data-lucide="sun"></i></span>
      </label>
    </div>
  </header>
  <div class="ad-body">
    <aside class="ad-side">
      <!-- the navigation is written from the data block: the guides, then each resource and its endpoints -->
      <nav
        class="mk-docs-navigation"
        data-ad-nav
        aria-label="API reference"
        data-i18n-aria-label-en="API reference"
        data-i18n-aria-label-de="API-Referenz"
      ></nav>
      <p class="ad-key-state">
        <span class="badge" data-variant="secondary" data-i18n-target="sandbox">Sandbox</span
        ><span data-i18n-target="sandbox-note">Requests go to the sandbox in this page</span>
      </p>
    </aside>
    <main class="ad-main" data-ad-main>
      <div class="ad-page">
        <div class="alert ad-version-note" data-variant="destructive" role="status" data-ad-v3 hidden>
          <i class="alert-icon" data-lucide="triangle-alert"></i>
          <div class="alert-content">
            <h2 class="alert-title" data-i18n-target="v3-title">You are reading v3</h2>
            <p class="alert-description" data-i18n-target="v3-text">
              v3 stops answering on 31 March 2027. The samples call /v3 - switch to v4 for new work.
            </p>
          </div>
        </div>
        <!-- the guides and the home page -->
        <section data-ad-view="guide" hidden>
          <article class="mk-docs-content" aria-labelledby="ad-guide-title">
            <nav class="breadcrumb" aria-label="Breadcrumb">
              <ol class="breadcrumb-list">
                <li class="breadcrumb-item"><a class="breadcrumb-link" href="#/" data-router-link>Acme API</a></li>
                <li class="breadcrumb-separator" aria-hidden="true">/</li>
                <li class="breadcrumb-item">
                  <span class="breadcrumb-page" aria-current="page" data-ad-guide-crumb></span>
                </li>
              </ol>
            </nav>
            <h1 class="mk-docs-content-title" id="ad-guide-title" data-ad-guide-title></h1>
            <p class="ad-doc-links" data-ad-doc-links></p>
            <p class="mk-docs-content-lead" data-ad-guide-lead></p>
            <div class="mk-docs-content-prose" data-ad-guide-body></div>
            <div class="ad-cards" data-ad-home-cards></div>
            <nav class="mk-docs-content-pager" aria-label="Pagination" data-ad-pager></nav>
          </article>
        </section>
        <!-- a resource: its object and its endpoints -->
        <section data-ad-view="resource" hidden>
          <div class="ad-article">
            <article class="mk-docs-content" aria-labelledby="ad-res-title">
              <nav class="breadcrumb" aria-label="Breadcrumb">
                <ol class="breadcrumb-list">
                  <li class="breadcrumb-item">
                    <a class="breadcrumb-link" href="#/" data-router-link data-i18n-target="crumb-reference"
                      >API reference</a
                    >
                  </li>
                  <li class="breadcrumb-separator" aria-hidden="true">/</li>
                  <li class="breadcrumb-item">
                    <span class="breadcrumb-page" aria-current="page" data-ad-res-crumb></span>
                  </li>
                </ol>
              </nav>
              <h1 class="mk-docs-content-title" id="ad-res-title" data-ad-res-title></h1>
              <p class="ad-doc-links" data-ad-doc-links></p>
              <p class="mk-docs-content-lead" data-ad-res-lead></p>
              <h2 class="text-lg font-semibold mt-6 mb-3" data-i18n-target="h-endpoints">Endpoints</h2>
              <ul class="ad-ops" data-ad-res-ops></ul>
              <h2 class="text-lg font-semibold mb-3" data-ad-res-object></h2>
              <ul class="ad-params" data-ad-res-fields></ul>
              <nav class="mk-docs-content-pager" aria-label="Pagination" data-ad-pager></nav>
            </article>
            <aside class="ad-aside">
              <div class="ad-code-panel">
                <div class="ad-code-head"><strong data-ad-res-example></strong><span class="ad-meta">JSON</span></div>
                <pre data-lang="json" data-ad-res-json></pre>
              </div>
            </aside>
          </div>
        </section>
        <!-- an endpoint: parameters, responses, the try-it form, the samples and the live response -->
        <section data-ad-view="endpoint" hidden>
          <div class="ad-article">
            <article class="mk-docs-content" aria-labelledby="ad-ep-title">
              <nav class="breadcrumb" aria-label="Breadcrumb">
                <ol class="breadcrumb-list">
                  <li class="breadcrumb-item">
                    <a class="breadcrumb-link" href="#/" data-router-link data-i18n-target="crumb-reference-2"
                      >API reference</a
                    >
                  </li>
                  <li class="breadcrumb-separator" aria-hidden="true">/</li>
                  <li class="breadcrumb-item">
                    <a class="breadcrumb-link" href="#/" data-router-link data-ad-ep-crumb></a>
                  </li>
                  <li class="breadcrumb-separator" aria-hidden="true">/</li>
                  <li class="breadcrumb-item">
                    <span class="breadcrumb-page" aria-current="page" data-ad-ep-crumb-page></span>
                  </li>
                </ol>
              </nav>
              <h1 class="mk-docs-content-title" id="ad-ep-title" data-ad-ep-title></h1>
              <p class="ad-doc-links" data-ad-doc-links></p>
              <div class="ad-endpoint-line">
                <span class="ad-method" data-ad-ep-method></span><code data-ad-ep-path></code
                ><button
                  class="btn"
                  type="button"
                  data-variant="ghost"
                  data-size="icon"
                  data-ad-copy-path
                  aria-label="Copy the URL"
                  data-i18n-aria-label-en="Copy the URL"
                  data-i18n-aria-label-de="URL kopieren"
                >
                  <i data-lucide="copy"></i>
                </button>
              </div>
              <p class="mk-docs-content-lead" data-ad-ep-lead></p>
              <div data-ad-ep-params></div>
              <h2 class="text-lg font-semibold mb-3" data-i18n-target="h-responses">Responses</h2>
              <ul class="ad-responses" data-ad-ep-responses></ul>
              <form class="card ad-try" data-ad-try novalidate>
                <div class="card-header">
                  <h2 class="card-title" data-i18n-target="h-try">Try it</h2>
                  <p class="card-description" data-i18n-target="try-text">
                    Change a value - the samples follow. Send runs the request against the sandbox.
                  </p>
                </div>
                <div class="card-content">
                  <div class="ad-try-grid" data-ad-try-fields></div>
                  <div class="ad-try-actions">
                    <button class="btn" type="submit"
                      ><i data-lucide="send"></i><span data-i18n-target="send">Send request</span></button
                    >
                    <button class="btn" type="reset" data-variant="outline" data-i18n-target="reset">Reset</button>
                  </div>
                </div>
              </form>
              <nav class="mk-docs-content-pager" aria-label="Pagination" data-ad-pager></nav>
            </article>
            <aside class="ad-aside">
              <figure class="mk-code-block" data-ad-samples>
                <div class="mk-code-block-head">
                  <div
                    class="mk-code-block-tabs"
                    role="radiogroup"
                    aria-label="Language"
                    data-i18n-aria-label-en="Language"
                    data-i18n-aria-label-de="Sprache"
                  >
                    <label><input type="radio" name="ad-lang" value="curl" checked />curl</label
                    ><label><input type="radio" name="ad-lang" value="js" />JavaScript</label
                    ><label><input type="radio" name="ad-lang" value="python" />Python</label>
                  </div>
                  <button
                    class="mk-code-block-copy"
                    type="button"
                    data-ad-copy
                    aria-label="Copy code"
                    data-i18n-aria-label-en="Copy code"
                    data-i18n-aria-label-de="Code kopieren"
                  >
                    <i data-lucide="copy"></i>
                  </button>
                </div>
                <pre data-tab="curl" data-lang="bash"><code data-ad-sample="curl"></code></pre>
                <pre data-tab="js" data-lang="js"><code data-ad-sample="js"></code></pre>
                <pre data-tab="python" data-lang="python"><code data-ad-sample="python"></code></pre>
                <span class="mk-code-block-status" role="status"></span>
              </figure>
              <div class="ad-code-panel" data-ad-response aria-live="polite">
                <div class="ad-code-head">
                  <strong data-i18n-target="h-response">Response</strong
                  ><span class="ad-status" data-ad-res-status></span><span class="ad-meta" data-ad-res-time></span>
                </div>
                <p class="ad-empty" data-ad-res-empty data-i18n-target="response-empty">
                  Send the request to see the sandbox's answer.
                </p>
                <pre data-lang="json" data-ad-res-body hidden></pre>
              </div>
            </aside>
          </div>
        </section>
        <!-- defuss-rpc: the overview and a namespace - written from rpc.docs.json, which defuss-rpc schema generated -->
        <section data-ad-view="rpc-ns" hidden>
          <article class="mk-docs-content" aria-labelledby="ad-rn-title">
            <nav class="breadcrumb" aria-label="Breadcrumb">
              <ol class="breadcrumb-list">
                <li class="breadcrumb-item">
                  <a class="breadcrumb-link" href="#/rpc" data-router-link data-i18n-target="crumb-rpc"
                    >defuss-rpc API</a
                  >
                </li>
                <li class="breadcrumb-separator" aria-hidden="true" data-ad-rn-sep>/</li>
                <li class="breadcrumb-item">
                  <span class="breadcrumb-page" aria-current="page" data-ad-rn-crumb></span>
                </li>
              </ol>
            </nav>
            <h1 class="mk-docs-content-title" id="ad-rn-title" data-ad-rn-title></h1>
            <p class="ad-doc-links" data-ad-doc-links></p>
            <p class="mk-docs-content-lead" data-ad-rn-lead></p>
            <div class="mk-docs-content-prose" data-ad-rn-body></div>
            <div class="ad-cards" data-ad-rn-cards></div>
            <ul class="ad-ops" data-ad-rn-ops></ul>
            <nav class="mk-docs-content-pager" aria-label="Pagination" data-ad-pager></nav>
          </article>
        </section>
        <!-- defuss-rpc: a method - its signature, parameters, return value, a call from the form and its samples -->
        <section data-ad-view="rpc-method" hidden>
          <div class="ad-article">
            <article class="mk-docs-content" aria-labelledby="ad-rm-title">
              <nav class="breadcrumb" aria-label="Breadcrumb">
                <ol class="breadcrumb-list">
                  <li class="breadcrumb-item">
                    <a class="breadcrumb-link" href="#/rpc" data-router-link data-i18n-target="crumb-rpc-2"
                      >defuss-rpc API</a
                    >
                  </li>
                  <li class="breadcrumb-separator" aria-hidden="true">/</li>
                  <li class="breadcrumb-item">
                    <a class="breadcrumb-link" href="#/rpc" data-router-link data-ad-rm-crumb></a>
                  </li>
                  <li class="breadcrumb-separator" aria-hidden="true">/</li>
                  <li class="breadcrumb-item">
                    <span class="breadcrumb-page" aria-current="page" data-ad-rm-crumb-page></span>
                  </li>
                </ol>
              </nav>
              <h1 class="mk-docs-content-title" id="ad-rm-title" data-ad-rm-title></h1>
              <p class="ad-doc-links" data-ad-doc-links></p>
              <div class="ad-badges" data-ad-rm-badges></div>
              <pre class="ad-signature" data-lang="ts" data-ad-rm-signature></pre>
              <p class="mk-docs-content-lead" data-ad-rm-lead></p>
              <div data-ad-rm-docs></div>
              <form class="card ad-try" data-ad-rpc-try novalidate>
                <div class="card-header">
                  <h2 class="card-title" data-i18n-target="h-call">Call it</h2>
                  <p class="card-description" data-i18n-target="call-text">
                    Change an argument - the samples follow. Send calls the example in this page, or a defuss-rpc
                    server.
                  </p>
                </div>
                <div class="card-content">
                  <div class="ad-try-grid">
                    <div class="ad-field">
                      <label class="label" for="ad-rpc-target" data-i18n-target="target">Target</label>
                      <select class="select" id="ad-rpc-target" data-size="sm" data-ad-rpc-target>
                        <option value="page" data-i18n-target="target-page">The example in this page</option>
                        <option value="server" data-i18n-target="target-server">A defuss-rpc server</option>
                      </select>
                    </div>
                    <div class="ad-field" data-ad-rpc-server hidden>
                      <label class="label" for="ad-rpc-url" data-i18n-target="server-url">Server URL</label>
                      <input
                        class="input"
                        id="ad-rpc-url"
                        type="url"
                        data-size="sm"
                        value="http://localhost:63920"
                        autocomplete="off"
                        spellcheck="false"
                        data-ad-rpc-url
                      />
                    </div>
                    <p class="ad-meta ad-rpc-wide" role="status" data-ad-rpc-conn></p>
                  </div>
                  <div class="ad-try-grid" data-ad-rpc-fields></div>
                  <div class="ad-try-actions">
                    <button class="btn" type="submit"
                      ><i data-lucide="send"></i><span data-i18n-target="call">Send call</span></button
                    >
                    <button class="btn" type="reset" data-variant="outline" data-i18n-target="reset-call">Reset</button>
                  </div>
                </div>
              </form>
              <nav class="mk-docs-content-pager" aria-label="Pagination" data-ad-pager></nav>
            </article>
            <aside class="ad-aside">
              <figure class="mk-code-block" data-ad-rpc-samples>
                <div class="mk-code-block-head">
                  <div
                    class="mk-code-block-tabs"
                    role="radiogroup"
                    aria-label="Language"
                    data-i18n-aria-label-en="Language"
                    data-i18n-aria-label-de="Sprache"
                  >
                    <label><input type="radio" name="ad-rpc-lang" value="ts" checked />TypeScript</label
                    ><label><input type="radio" name="ad-rpc-lang" value="rcurl" />curl</label
                    ><label><input type="radio" name="ad-rpc-lang" value="fetch" />fetch</label>
                  </div>
                  <button
                    class="mk-code-block-copy"
                    type="button"
                    data-ad-rpc-copy
                    aria-label="Copy code"
                    data-i18n-aria-label-en="Copy code"
                    data-i18n-aria-label-de="Code kopieren"
                  >
                    <i data-lucide="copy"></i>
                  </button>
                </div>
                <pre data-tab="ts" data-lang="ts"><code data-ad-rsample="ts"></code></pre>
                <pre data-tab="rcurl" data-lang="bash"><code data-ad-rsample="curl"></code></pre>
                <pre data-tab="fetch" data-lang="js"><code data-ad-rsample="js"></code></pre>
                <span class="mk-code-block-status" role="status"></span>
              </figure>
              <div class="card ad-rpc-result" data-ad-rpc-response aria-live="polite">
                <div class="card-header">
                  <h2 class="card-title" data-i18n-target="h-answer">Answer</h2>
                  <p class="card-description">
                    <span class="ad-status" data-ad-rpc-status></span> <span class="ad-meta" data-ad-rpc-time></span>
                  </p>
                </div>
                <div class="card-content">
                  <p class="ad-empty" data-ad-rpc-empty data-i18n-target="answer-empty"
                    >Send the call to see its answer.</p
                  >
                  <p class="ad-rpc-error" data-ad-rpc-error hidden></p>
                  <ol class="ad-rpc-frames" data-ad-rpc-frames hidden></ol>
                  <div
                    class="property-tree"
                    data-readonly
                    data-ad-rpc-result
                    aria-label="Answer"
                    data-i18n-aria-label-en="Answer"
                    data-i18n-aria-label-de="Antwort"
                    hidden
                  ></div>
                </div>
              </div>
            </aside>
          </div>
        </section>
      </div>
    </main>
  </div>
  <!-- the search: a Command palette (also ⌘K) whose hits defuss-search ranks -->
  <dialog
    id="ad-find"
    class="command"
    data-filter="none"
    role="dialog"
    aria-modal="true"
    aria-label="Search the API"
    data-i18n-aria-label-en="Search the API"
    data-i18n-aria-label-de="API durchsuchen"
  >
    <div class="command-content">
      <div class="command-input-wrapper">
        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
          <circle cx="11" cy="11" r="8" />
          <path d="m21 21-4.3-4.3" />
        </svg>
        <input
          class="command-input"
          type="text"
          data-ad-query
          placeholder="Endpoints, parameters, guides..."
          data-i18n-placeholder-en="Endpoints, parameters, guides..."
          data-i18n-placeholder-de="Endpunkte, Parameter, Anleitungen..."
          aria-label="Search"
          data-i18n-aria-label-en="Search"
          data-i18n-aria-label-de="Suchen"
          autocomplete="off"
          spellcheck="false"
        />
      </div>
      <div class="command-list" data-ad-hits></div>
      <div class="command-empty" data-i18n-target="find-empty" hidden>Nothing found.</div>
      <p class="ad-find-status" data-ad-find-status></p>
    </div>
  </dialog>
  <!-- the API key: kept in the page only, written into every sample -->
  <dialog id="ad-key" class="dialog" role="dialog" aria-modal="true" aria-labelledby="ad-key-title">
    <form class="dialog-content" method="dialog" data-ad-key-form>
      <div class="dialog-header">
        <h2 class="dialog-title" id="ad-key-title" data-i18n-target="key-title">Authorize</h2>
        <p class="dialog-description" data-i18n-target="key-text">
          Requests carry the key as a bearer token. The sandbox takes any test key that starts with acme_test_.
        </p>
      </div>
      <div class="dialog-body ad-field">
        <label class="label" for="ad-key-input" data-i18n-target="key-label">API key</label>
        <input
          class="input"
          id="ad-key-input"
          type="text"
          autocomplete="off"
          spellcheck="false"
          value="acme_test_51Nq7Kx2aLpVd9"
        />
      </div>
      <div class="dialog-footer">
        <button class="btn" type="submit" value="clear" data-variant="outline" data-i18n-target="key-clear"
          >Remove key</button
        >
        <button class="btn" type="submit" value="save" data-i18n-target="key-save">Save key</button>
      </div>
    </form>
  </dialog>
  <!-- the reference: guides, resources and endpoints in English and German. A body line is a paragraph;
       "## " starts a heading, "$ " a command, "> " a note -->
  <script type="application/json" id="ad-data">
    {
      "base": "https://api.acme.example",
      "words": {
        "en": {
          "guides": "Getting started",
          "reference": "API reference",
          "path": "Path parameters",
          "query": "Query parameters",
          "body": "Body parameters",
          "required": "required",
          "oneOf": "One of",
          "object": "The %s object",
          "example": "Example %s",
          "endpoints": "%n endpoints",
          "prev": "Previous",
          "next": "Next",
          "copied": "Copied to the clipboard",
          "copyHint": "Selected - press ⌘C to copy",
          "results": "%n results in %t ms - defuss-search, BM25",
          "resultsMeaning": "%n results in %t ms - defuss-search, BM25 + ColBERT",
          "meaning-loading": "Keywords now - search by meaning loads in the background (4.6 MB)",
          "meaning-semantic": "Keywords and meaning - BM25 fused with the Winzling-reranker ColBERT model",
          "meaning-failed": "Search by meaning did not load - keywords only",
          "meaning-saver": "Data saver on - keywords only",
          "rpcGroup": "defuss-rpc API",
          "rpcOverview": "Overview",
          "rpcTitle": "defuss-rpc API",
          "rpcLead": "The same Acme workspace as a defuss-rpc API: namespaces of typed methods instead of URLs. Every call is one POST /rpc; arguments and results travel as DSON, so a Date, a Map or a Set arrives as itself, and an async generator streams its values.",
          "rpcBody": [
            "This reference is generated: defuss-rpc schema reads the API's TypeScript source, follows createRpcServer() to the classes and objects it registers and writes each method's JSDoc, parameters and types into rpc.docs.json - the pages here, their Markdown and JSON, and the samples are made from that file.",
            "$ bunx defuss-rpc schema \"src/**/*.ts\" --out rpc.docs.json --endpoint http://localhost:63920",
            "> Call it sends to the same API running in this page; pick A defuss-rpc server and start one with bun src/documentation/runtime/api-docs/server.ts to call it over the network."
          ],
          "rpcCard": "Namespaces of typed methods, generated from the source with defuss-rpc schema.",
          "classNote": "A class: the server makes a fresh instance for every call.",
          "moduleNote": "A module: one object, shared by every call.",
          "methods": "%n methods",
          "stream": "Streams NDJSON",
          "once": "Answers once",
          "deprecated": "Deprecated",
          "params": "Parameters",
          "noParams": "This method takes no parameters.",
          "returns": "Returns",
          "yields": "Yields",
          "throws": "Throws",
          "examples": "Examples",
          "optional": "optional",
          "asMarkdown": "Markdown",
          "asJson": "JSON",
          "pageAs": "This page as",
          "connChecking": "Asking %s for its schema...",
          "connOk": "%s serves %n namespaces",
          "connMissing": "%s serves no %m",
          "connFail": "%s does not answer (%e) - start it with bun src/documentation/runtime/api-docs/server.ts",
          "inPage": "in this page",
          "framesNote": "%n values streamed, then the return value",
          "badJson": "Not valid JSON: %s",
          "loading": "Loading the search index...",
          "plain": "The search index is not loaded - matching names",
          "guidesGroup": "Guides",
          "endpointsGroup": "Endpoints",
          "resourcesGroup": "Resources",
          "ms": "%t ms",
          "codes": {
            "200": "The object, or a page of the list",
            "201": "Created - the new object",
            "400": "A parameter is missing or wrong",
            "401": "No valid API key",
            "404": "No object with that id",
            "429": "Too many requests - wait for the reset"
          }
        },
        "de": {
          "guides": "Erste Schritte",
          "reference": "API-Referenz",
          "path": "Pfadparameter",
          "query": "Query-Parameter",
          "body": "Body-Parameter",
          "required": "Pflicht",
          "oneOf": "Einer von",
          "object": "Das Objekt %s",
          "example": "Beispiel: %s",
          "endpoints": "%n Endpunkte",
          "prev": "Zurück",
          "next": "Weiter",
          "copied": "In die Zwischenablage kopiert",
          "copyHint": "Markiert - mit ⌘C kopieren",
          "results": "%n Treffer in %t ms - defuss-search, BM25",
          "resultsMeaning": "%n Treffer in %t ms - defuss-search, BM25 + ColBERT",
          "meaning-loading": "Stichwörter jetzt - die Suche nach Bedeutung lädt im Hintergrund (4,6 MB)",
          "meaning-semantic": "Stichwörter und Bedeutung - BM25 verschmolzen mit dem ColBERT-Modell Winzling-reranker",
          "meaning-failed": "Die Suche nach Bedeutung hat nicht geladen - nur Stichwörter",
          "meaning-saver": "Datensparmodus an - nur Stichwörter",
          "rpcGroup": "defuss-rpc-API",
          "rpcOverview": "Überblick",
          "rpcTitle": "defuss-rpc-API",
          "rpcLead": "Derselbe Acme-Workspace als defuss-rpc-API: Namensräume typisierter Methoden statt URLs. Jeder Aufruf ist ein POST /rpc; Argumente und Ergebnisse reisen als DSON, also kommen Date, Map und Set als sie selbst an, und ein Async-Generator streamt seine Werte.",
          "rpcBody": [
            "Diese Referenz ist erzeugt: defuss-rpc schema liest den TypeScript-Quelltext der API, folgt createRpcServer() zu den Klassen und Objekten, die es registriert, und schreibt JSDoc, Parameter und Typen jeder Methode nach rpc.docs.json - die Seiten hier, ihr Markdown und JSON und die Beispiele entstehen aus dieser Datei.",
            "$ bunx defuss-rpc schema \"src/**/*.ts\" --out rpc.docs.json --endpoint http://localhost:63920",
            "> Aufrufen sendet an dieselbe API in dieser Seite; wähle Ein defuss-rpc-Server und starte einen mit bun src/documentation/runtime/api-docs/server.ts, um ihn über das Netz aufzurufen."
          ],
          "rpcCard": "Namensräume typisierter Methoden, mit defuss-rpc schema aus dem Quelltext erzeugt.",
          "classNote": "Eine Klasse: der Server legt für jeden Aufruf eine neue Instanz an.",
          "moduleNote": "Ein Modul: ein Objekt für alle Aufrufe.",
          "methods": "%n Methoden",
          "stream": "Streamt NDJSON",
          "once": "Antwortet einmal",
          "deprecated": "Veraltet",
          "params": "Parameter",
          "noParams": "Diese Methode nimmt keine Parameter.",
          "returns": "Rückgabe",
          "yields": "Liefert",
          "throws": "Fehler",
          "examples": "Beispiele",
          "optional": "optional",
          "asMarkdown": "Markdown",
          "asJson": "JSON",
          "pageAs": "Diese Seite als",
          "connChecking": "Frage %s nach seinem Schema...",
          "connOk": "%s bietet %n Namensräume",
          "connMissing": "%s bietet kein %m",
          "connFail": "%s antwortet nicht (%e) - starte ihn mit bun src/documentation/runtime/api-docs/server.ts",
          "inPage": "in dieser Seite",
          "framesNote": "%n Werte gestreamt, dann der Rückgabewert",
          "badJson": "Kein gültiges JSON: %s",
          "loading": "Suchindex wird geladen...",
          "plain": "Der Suchindex ist nicht geladen - Namen werden verglichen",
          "guidesGroup": "Anleitungen",
          "endpointsGroup": "Endpunkte",
          "resourcesGroup": "Ressourcen",
          "ms": "%t ms",
          "codes": {
            "200": "Das Objekt oder eine Seite der Liste",
            "201": "Angelegt - das neue Objekt",
            "400": "Ein Parameter fehlt oder ist falsch",
            "401": "Kein gültiger API-Schlüssel",
            "404": "Kein Objekt mit dieser ID",
            "429": "Zu viele Anfragen - bis zum Reset warten"
          }
        }
      },
      "guides": [
        {
          "id": "introduction",
          "en": {
            "title": "Introduction",
            "lead": "The Acme API is organized around REST: resource URLs, JSON bodies and the usual HTTP verbs and status codes.",
            "body": [
              "Every request goes to one base URL and names the version in its path. A response is always JSON - an object, a list with a cursor, or an error.",
              "$ curl https://api.acme.example/v4/tasks -H \"Authorization: Bearer acme_test_51Nq7Kx2aLpVd9\"",
              "> Test keys start with acme_test_ and only ever touch test data. Live keys start with acme_live_.",
              "## Resources",
              "Tasks, docs, members and webhooks - pick one to see its object and its endpoints."
            ]
          },
          "de": {
            "title": "Einführung",
            "lead": "Die Acme-API folgt REST: Ressourcen-URLs, JSON-Bodys und die üblichen HTTP-Verben und Statuscodes.",
            "body": [
              "Jede Anfrage geht an eine Basis-URL und nennt die Version im Pfad. Eine Antwort ist immer JSON - ein Objekt, eine Liste mit Cursor oder ein Fehler.",
              "$ curl https://api.acme.example/v4/tasks -H \"Authorization: Bearer acme_test_51Nq7Kx2aLpVd9\"",
              "> Testschlüssel beginnen mit acme_test_ und berühren nur Testdaten. Live-Schlüssel beginnen mit acme_live_.",
              "## Ressourcen",
              "Aufgaben, Dokumente, Mitglieder und Webhooks - wählen Sie eine für ihr Objekt und ihre Endpunkte."
            ]
          }
        },
        {
          "id": "authentication",
          "en": {
            "title": "Authentication",
            "lead": "Send your API key as a bearer token in the Authorization header of every request.",
            "body": [
              "Keys belong to a workspace and carry its permissions. Create and revoke them under Settings - API keys.",
              "$ curl https://api.acme.example/v4/docs -H \"Authorization: Bearer $ACME_KEY\"",
              "A request without a key, or with a revoked one, answers 401 with an authentication_error.",
              "> Keep live keys on the server. A key in a browser bundle is a key anyone can read."
            ]
          },
          "de": {
            "title": "Authentifizierung",
            "lead": "Senden Sie Ihren API-Schlüssel als Bearer-Token im Authorization-Header jeder Anfrage.",
            "body": [
              "Schlüssel gehören zu einem Workspace und tragen dessen Rechte. Sie werden unter Einstellungen - API-Schlüssel angelegt und widerrufen.",
              "$ curl https://api.acme.example/v4/docs -H \"Authorization: Bearer $ACME_KEY\"",
              "Eine Anfrage ohne Schlüssel oder mit einem widerrufenen antwortet 401 mit einem authentication_error.",
              "> Live-Schlüssel bleiben auf dem Server. Ein Schlüssel in einem Browser-Bundle kann jeder lesen."
            ]
          }
        },
        {
          "id": "errors",
          "en": {
            "title": "Errors",
            "lead": "Failed requests answer with a 4xx or 5xx status and an error object that names what went wrong.",
            "body": [
              "The error's type groups the cause, its message is written for people, and param names the field when one parameter is at fault.",
              "$ { \"error\": { \"type\": \"invalid_request_error\", \"message\": \"Missing required parameter: title.\", \"param\": \"title\" } }",
              "## Types",
              "authentication_error - no key or a wrong one. invalid_request_error - a parameter is missing or malformed. resource_missing - no object with that id. rate_limit_error - too many requests."
            ]
          },
          "de": {
            "title": "Fehler",
            "lead": "Fehlgeschlagene Anfragen antworten mit einem 4xx- oder 5xx-Status und einem Fehlerobjekt, das die Ursache nennt.",
            "body": [
              "Der type des Fehlers ordnet die Ursache ein, message ist für Menschen geschrieben, und param nennt das Feld, wenn ein Parameter schuld ist.",
              "$ { \"error\": { \"type\": \"invalid_request_error\", \"message\": \"Missing required parameter: title.\", \"param\": \"title\" } }",
              "## Typen",
              "authentication_error - kein oder ein falscher Schlüssel. invalid_request_error - ein Parameter fehlt oder ist fehlerhaft. resource_missing - kein Objekt mit dieser ID. rate_limit_error - zu viele Anfragen."
            ]
          }
        },
        {
          "id": "pagination",
          "en": {
            "title": "Pagination",
            "lead": "List endpoints return a page of objects and a cursor to the next one.",
            "body": [
              "Pass limit (1 to 100, default 10) to size a page. When has_more is true, send next_cursor as cursor to get the following page.",
              "$ curl \"https://api.acme.example/v4/tasks?limit=2&cursor=t_102\" -H \"Authorization: Bearer $ACME_KEY\"",
              "> A cursor stays valid while objects are added - a page never repeats or skips an object."
            ]
          },
          "de": {
            "title": "Paginierung",
            "lead": "Listen-Endpunkte liefern eine Seite von Objekten und einen Cursor zur nächsten.",
            "body": [
              "limit (1 bis 100, Standard 10) bestimmt die Größe einer Seite. Ist has_more wahr, liefert next_cursor als cursor die folgende Seite.",
              "$ curl \"https://api.acme.example/v4/tasks?limit=2&cursor=t_102\" -H \"Authorization: Bearer $ACME_KEY\"",
              "> Ein Cursor bleibt gültig, während Objekte hinzukommen - keine Seite wiederholt oder überspringt ein Objekt."
            ]
          }
        },
        {
          "id": "rate-limits",
          "en": {
            "title": "Rate limits",
            "lead": "Each key may send 100 requests a minute; the response headers count down.",
            "body": [
              "X-RateLimit-Remaining tells how many requests the minute has left, X-RateLimit-Reset when it starts again. Past the limit the API answers 429.",
              "> Retry a 429 after the reset with an exponential backoff, never in a tight loop."
            ]
          },
          "de": {
            "title": "Ratenlimits",
            "lead": "Jeder Schlüssel darf 100 Anfragen pro Minute senden; die Antwort-Header zählen herunter.",
            "body": [
              "X-RateLimit-Remaining sagt, wie viele Anfragen die Minute noch erlaubt, X-RateLimit-Reset, wann sie neu beginnt. Über dem Limit antwortet die API mit 429.",
              "> Wiederholen Sie eine 429 nach dem Reset mit exponentiellem Backoff, nie in einer engen Schleife."
            ]
          }
        }
      ],
      "resources": [
        {
          "id": "tasks",
          "object": "task",
          "en": {
            "title": "Tasks",
            "lead": "A task is a piece of work in a workspace with a status, an assignee and a due date."
          },
          "de": {
            "title": "Aufgaben",
            "lead": "Eine Aufgabe ist ein Stück Arbeit in einem Workspace mit Status, zuständiger Person und Fälligkeit."
          },
          "fields": [
            ["id", "string", "Unique identifier, starting with t_.", "Eindeutige Kennung, beginnt mit t_."],
            ["title", "string", "What has to be done.", "Was zu tun ist."],
            ["status", "enum", "todo, doing or done.", "todo, doing oder done."],
            ["assignee", "string | null", "The member who does it, or null.", "Das zuständige Mitglied oder null."],
            ["due_on", "date | null", "The day it is due, as YYYY-MM-DD.", "Der Fälligkeitstag als JJJJ-MM-TT."],
            ["workspace", "string", "The workspace it belongs to.", "Der Workspace, zu dem sie gehört."],
            ["created_at", "timestamp", "When it was created, in UTC.", "Wann sie angelegt wurde, in UTC."]
          ]
        },
        {
          "id": "docs",
          "object": "doc",
          "en": { "title": "Docs", "lead": "A doc is a page of text in a workspace, written in Markdown." },
          "de": {
            "title": "Dokumente",
            "lead": "Ein Dokument ist eine Textseite in einem Workspace, geschrieben in Markdown."
          },
          "fields": [
            ["id", "string", "Unique identifier, starting with d_.", "Eindeutige Kennung, beginnt mit d_."],
            ["title", "string", "The doc's title.", "Der Titel des Dokuments."],
            ["body", "string", "The text, in Markdown.", "Der Text in Markdown."],
            ["workspace", "string", "The workspace it belongs to.", "Der Workspace, zu dem es gehört."],
            ["updated_at", "timestamp", "When it last changed, in UTC.", "Wann es zuletzt geändert wurde, in UTC."]
          ]
        },
        {
          "id": "members",
          "object": "member",
          "en": {
            "title": "Members",
            "lead": "A member is a person in a workspace, with a role that sets what they may do."
          },
          "de": {
            "title": "Mitglieder",
            "lead": "Ein Mitglied ist eine Person in einem Workspace mit einer Rolle, die ihre Rechte bestimmt."
          },
          "fields": [
            ["id", "string", "Unique identifier, starting with m_.", "Eindeutige Kennung, beginnt mit m_."],
            ["email", "string", "The address the invitation went to.", "Die Adresse, an die die Einladung ging."],
            ["role", "enum", "admin, member or guest.", "admin, member oder guest."],
            ["status", "enum", "invited or active.", "invited oder active."]
          ]
        },
        {
          "id": "webhooks",
          "object": "webhook",
          "en": {
            "title": "Webhooks",
            "lead": "A webhook endpoint receives a signed POST for every event it subscribes to."
          },
          "de": {
            "title": "Webhooks",
            "lead": "Ein Webhook-Endpunkt erhält für jedes abonnierte Ereignis einen signierten POST."
          },
          "fields": [
            ["id", "string", "Unique identifier, starting with wh_.", "Eindeutige Kennung, beginnt mit wh_."],
            ["url", "string", "Where the events are sent, over HTTPS.", "Wohin die Ereignisse gehen, über HTTPS."],
            [
              "events",
              "string[]",
              "The events it receives, such as task.created.",
              "Die Ereignisse, die er erhält, etwa task.created."
            ],
            [
              "secret",
              "string",
              "Signs every delivery - shown once, on creation.",
              "Signiert jede Zustellung - nur beim Anlegen sichtbar."
            ]
          ]
        }
      ],
      "endpoints": [
        {
          "id": "list",
          "resource": "tasks",
          "method": "GET",
          "path": "/tasks",
          "codes": ["200", "400", "401"],
          "en": { "title": "List tasks", "lead": "Returns the tasks of a workspace, newest first, a page at a time." },
          "de": {
            "title": "Aufgaben auflisten",
            "lead": "Liefert die Aufgaben eines Workspace, die neuesten zuerst, seitenweise."
          },
          "params": [
            {
              "name": "workspace",
              "in": "query",
              "type": "string",
              "required": true,
              "example": "ws_acme",
              "en": "The workspace to list.",
              "de": "Der aufzulistende Workspace."
            },
            {
              "name": "status",
              "in": "query",
              "type": "enum",
              "values": ["todo", "doing", "done"],
              "en": "Only tasks with this status.",
              "de": "Nur Aufgaben mit diesem Status."
            },
            {
              "name": "limit",
              "in": "query",
              "type": "integer",
              "example": "3",
              "en": "Objects per page, 1 to 100.",
              "de": "Objekte pro Seite, 1 bis 100."
            },
            {
              "name": "cursor",
              "in": "query",
              "type": "string",
              "en": "The next_cursor of the previous page.",
              "de": "Der next_cursor der vorigen Seite."
            }
          ]
        },
        {
          "id": "create",
          "resource": "tasks",
          "method": "POST",
          "path": "/tasks",
          "codes": ["201", "400", "401"],
          "en": { "title": "Create a task", "lead": "Creates a task in a workspace and returns it." },
          "de": {
            "title": "Aufgabe anlegen",
            "lead": "Legt eine Aufgabe in einem Workspace an und liefert sie zurück."
          },
          "params": [
            {
              "name": "workspace",
              "in": "body",
              "type": "string",
              "required": true,
              "example": "ws_acme",
              "en": "The workspace the task belongs to.",
              "de": "Der Workspace der Aufgabe."
            },
            {
              "name": "title",
              "in": "body",
              "type": "string",
              "required": true,
              "example": "Ship the onboarding emails",
              "en": "What has to be done.",
              "de": "Was zu tun ist."
            },
            {
              "name": "assignee",
              "in": "body",
              "type": "string",
              "example": "m_ana",
              "en": "The member who does it.",
              "de": "Das zuständige Mitglied."
            },
            {
              "name": "due_on",
              "in": "body",
              "type": "date",
              "example": "2026-12-01",
              "en": "The day it is due, YYYY-MM-DD.",
              "de": "Der Fälligkeitstag, JJJJ-MM-TT."
            },
            {
              "name": "status",
              "in": "body",
              "type": "enum",
              "values": ["todo", "doing", "done"],
              "en": "Starts as todo when left out.",
              "de": "Beginnt als todo, wenn nicht angegeben."
            }
          ]
        },
        {
          "id": "retrieve",
          "resource": "tasks",
          "method": "GET",
          "path": "/tasks/{id}",
          "codes": ["200", "401", "404"],
          "en": { "title": "Retrieve a task", "lead": "Returns one task by its id." },
          "de": { "title": "Aufgabe abrufen", "lead": "Liefert eine Aufgabe anhand ihrer ID." },
          "params": [
            {
              "name": "id",
              "in": "path",
              "type": "string",
              "required": true,
              "example": "t_101",
              "en": "The task's id.",
              "de": "Die ID der Aufgabe."
            }
          ]
        },
        {
          "id": "update",
          "resource": "tasks",
          "method": "PATCH",
          "path": "/tasks/{id}",
          "codes": ["200", "400", "401", "404"],
          "en": { "title": "Update a task", "lead": "Changes the fields you send and leaves the rest as they are." },
          "de": { "title": "Aufgabe ändern", "lead": "Ändert die gesendeten Felder und lässt den Rest, wie er ist." },
          "params": [
            {
              "name": "id",
              "in": "path",
              "type": "string",
              "required": true,
              "example": "t_101",
              "en": "The task's id.",
              "de": "Die ID der Aufgabe."
            },
            { "name": "title", "in": "body", "type": "string", "en": "A new title.", "de": "Ein neuer Titel." },
            {
              "name": "status",
              "in": "body",
              "type": "enum",
              "values": ["todo", "doing", "done"],
              "example": "done",
              "en": "A new status.",
              "de": "Ein neuer Status."
            },
            {
              "name": "assignee",
              "in": "body",
              "type": "string",
              "en": "Another member, or none to unassign.",
              "de": "Ein anderes Mitglied, oder none zum Entfernen."
            }
          ]
        },
        {
          "id": "delete",
          "resource": "tasks",
          "method": "DELETE",
          "path": "/tasks/{id}",
          "codes": ["200", "401", "404"],
          "en": { "title": "Delete a task", "lead": "Deletes a task for good. Its comments go with it." },
          "de": { "title": "Aufgabe löschen", "lead": "Löscht eine Aufgabe endgültig, samt ihren Kommentaren." },
          "params": [
            {
              "name": "id",
              "in": "path",
              "type": "string",
              "required": true,
              "example": "t_103",
              "en": "The task's id.",
              "de": "Die ID der Aufgabe."
            }
          ]
        },
        {
          "id": "list",
          "resource": "docs",
          "method": "GET",
          "path": "/docs",
          "codes": ["200", "400", "401"],
          "en": { "title": "List docs", "lead": "Returns the docs of a workspace, the most recently changed first." },
          "de": {
            "title": "Dokumente auflisten",
            "lead": "Liefert die Dokumente eines Workspace, die zuletzt geänderten zuerst."
          },
          "params": [
            {
              "name": "workspace",
              "in": "query",
              "type": "string",
              "required": true,
              "example": "ws_acme",
              "en": "The workspace to list.",
              "de": "Der aufzulistende Workspace."
            },
            {
              "name": "limit",
              "in": "query",
              "type": "integer",
              "en": "Objects per page, 1 to 100.",
              "de": "Objekte pro Seite, 1 bis 100."
            }
          ]
        },
        {
          "id": "create",
          "resource": "docs",
          "method": "POST",
          "path": "/docs",
          "codes": ["201", "400", "401"],
          "en": { "title": "Create a doc", "lead": "Creates a doc from a title and a Markdown body." },
          "de": { "title": "Dokument anlegen", "lead": "Legt ein Dokument aus Titel und Markdown-Text an." },
          "params": [
            {
              "name": "workspace",
              "in": "body",
              "type": "string",
              "required": true,
              "example": "ws_acme",
              "en": "The workspace the doc belongs to.",
              "de": "Der Workspace des Dokuments."
            },
            {
              "name": "title",
              "in": "body",
              "type": "string",
              "required": true,
              "example": "Release checklist",
              "en": "The doc's title.",
              "de": "Der Titel des Dokuments."
            },
            {
              "name": "body",
              "in": "body",
              "type": "string",
              "example": "- [ ] Changelog",
              "en": "The text, in Markdown.",
              "de": "Der Text in Markdown."
            }
          ]
        },
        {
          "id": "retrieve",
          "resource": "docs",
          "method": "GET",
          "path": "/docs/{id}",
          "codes": ["200", "401", "404"],
          "en": { "title": "Retrieve a doc", "lead": "Returns one doc with its whole body." },
          "de": { "title": "Dokument abrufen", "lead": "Liefert ein Dokument mit seinem ganzen Text." },
          "params": [
            {
              "name": "id",
              "in": "path",
              "type": "string",
              "required": true,
              "example": "d_201",
              "en": "The doc's id.",
              "de": "Die ID des Dokuments."
            }
          ]
        },
        {
          "id": "list",
          "resource": "members",
          "method": "GET",
          "path": "/workspaces/{workspace}/members",
          "codes": ["200", "401", "404"],
          "en": { "title": "List members", "lead": "Returns everyone in a workspace, with their role and status." },
          "de": {
            "title": "Mitglieder auflisten",
            "lead": "Liefert alle Personen eines Workspace mit Rolle und Status."
          },
          "params": [
            {
              "name": "workspace",
              "in": "path",
              "type": "string",
              "required": true,
              "example": "ws_acme",
              "en": "The workspace.",
              "de": "Der Workspace."
            },
            {
              "name": "role",
              "in": "query",
              "type": "enum",
              "values": ["admin", "member", "guest"],
              "en": "Only members with this role.",
              "de": "Nur Mitglieder mit dieser Rolle."
            }
          ]
        },
        {
          "id": "invite",
          "resource": "members",
          "method": "POST",
          "path": "/workspaces/{workspace}/members",
          "codes": ["201", "400", "401", "404"],
          "en": {
            "title": "Invite a member",
            "lead": "Sends an invitation by email. The member is invited until they accept."
          },
          "de": {
            "title": "Mitglied einladen",
            "lead": "Verschickt eine Einladung per E-Mail. Bis zur Annahme ist das Mitglied eingeladen."
          },
          "params": [
            {
              "name": "workspace",
              "in": "path",
              "type": "string",
              "required": true,
              "example": "ws_acme",
              "en": "The workspace.",
              "de": "Der Workspace."
            },
            {
              "name": "email",
              "in": "body",
              "type": "string",
              "required": true,
              "example": "sam@acme.example",
              "en": "Where the invitation goes.",
              "de": "Wohin die Einladung geht."
            },
            {
              "name": "role",
              "in": "body",
              "type": "enum",
              "values": ["admin", "member", "guest"],
              "en": "member when left out.",
              "de": "member, wenn nicht angegeben."
            }
          ]
        },
        {
          "id": "list",
          "resource": "webhooks",
          "method": "GET",
          "path": "/webhooks",
          "codes": ["200", "401"],
          "en": { "title": "List webhooks", "lead": "Returns every webhook endpoint of the key's workspace." },
          "de": {
            "title": "Webhooks auflisten",
            "lead": "Liefert alle Webhook-Endpunkte des Workspace des Schlüssels."
          },
          "params": []
        },
        {
          "id": "create",
          "resource": "webhooks",
          "method": "POST",
          "path": "/webhooks",
          "codes": ["201", "400", "401"],
          "en": {
            "title": "Create a webhook",
            "lead": "Registers a URL for events. The answer carries the signing secret - the only time it is shown."
          },
          "de": {
            "title": "Webhook anlegen",
            "lead": "Registriert eine URL für Ereignisse. Die Antwort enthält das Signatur-Geheimnis - das einzige Mal."
          },
          "params": [
            {
              "name": "url",
              "in": "body",
              "type": "string",
              "required": true,
              "example": "https://hooks.acme.example/tasks",
              "en": "An HTTPS URL that answers 2xx.",
              "de": "Eine HTTPS-URL, die 2xx antwortet."
            },
            {
              "name": "events",
              "in": "body",
              "type": "string[]",
              "required": true,
              "example": "task.created, task.updated",
              "en": "The events, separated by commas.",
              "de": "Die Ereignisse, durch Kommas getrennt."
            }
          ]
        },
        {
          "id": "delete",
          "resource": "webhooks",
          "method": "DELETE",
          "path": "/webhooks/{id}",
          "codes": ["200", "401", "404"],
          "en": { "title": "Delete a webhook", "lead": "Stops the deliveries to an endpoint at once." },
          "de": { "title": "Webhook löschen", "lead": "Beendet die Zustellungen an einen Endpunkt sofort." },
          "params": [
            {
              "name": "id",
              "in": "path",
              "type": "string",
              "required": true,
              "example": "wh_301",
              "en": "The webhook's id.",
              "de": "Die ID des Webhooks."
            }
          ]
        }
      ]
    }
  </script>
  <!-- the translations of the frame -->
  <template data-i18n-for="brand-sub" data-i18n-locale="en">reference</template>
  <template data-i18n-for="brand-sub" data-i18n-locale="de">Referenz</template>
  <template data-i18n-for="version-latest" data-i18n-locale="en">v4 (latest)</template>
  <template data-i18n-for="version-latest" data-i18n-locale="de">v4 (aktuell)</template>
  <template data-i18n-for="search" data-i18n-locale="en">Search the API</template>
  <template data-i18n-for="search" data-i18n-locale="de">API durchsuchen</template>
  <template data-i18n-for="authorize" data-i18n-locale="en">Authorize</template>
  <template data-i18n-for="authorize" data-i18n-locale="de">Autorisieren</template>
  <template data-i18n-for="authorized" data-i18n-locale="en">Authorized</template>
  <template data-i18n-for="authorized" data-i18n-locale="de">Autorisiert</template>
  <template data-i18n-for="sandbox" data-i18n-locale="en">Sandbox</template>
  <template data-i18n-for="sandbox" data-i18n-locale="de">Sandbox</template>
  <template data-i18n-for="sandbox-note" data-i18n-locale="en">Requests go to the sandbox in this page</template>
  <template data-i18n-for="sandbox-note" data-i18n-locale="de">Anfragen gehen an die Sandbox in dieser Seite</template>
  <template data-i18n-for="v3-title" data-i18n-locale="en">You are reading v3</template>
  <template data-i18n-for="v3-title" data-i18n-locale="de">Sie lesen v3</template>
  <template data-i18n-for="v3-text" data-i18n-locale="en"
    >v3 stops answering on 31 March 2027. The samples call /v3 - switch to v4 for new work.</template
  >
  <template data-i18n-for="v3-text" data-i18n-locale="de"
    >v3 antwortet ab dem 31. März 2027 nicht mehr. Die Beispiele rufen /v3 auf - nutzen Sie v4 für Neues.</template
  >
  <template data-i18n-for="crumb-reference" data-i18n-locale="en">API reference</template>
  <template data-i18n-for="crumb-reference" data-i18n-locale="de">API-Referenz</template>
  <template data-i18n-for="crumb-reference-2" data-i18n-locale="en">API reference</template>
  <template data-i18n-for="crumb-reference-2" data-i18n-locale="de">API-Referenz</template>
  <template data-i18n-for="h-endpoints" data-i18n-locale="en">Endpoints</template>
  <template data-i18n-for="h-endpoints" data-i18n-locale="de">Endpunkte</template>
  <template data-i18n-for="h-responses" data-i18n-locale="en">Responses</template>
  <template data-i18n-for="h-responses" data-i18n-locale="de">Antworten</template>
  <template data-i18n-for="h-try" data-i18n-locale="en">Try it</template>
  <template data-i18n-for="h-try" data-i18n-locale="de">Ausprobieren</template>
  <template data-i18n-for="try-text" data-i18n-locale="en"
    >Change a value - the samples follow. Send runs the request against the sandbox.</template
  >
  <template data-i18n-for="try-text" data-i18n-locale="de"
    >Ändern Sie einen Wert - die Beispiele folgen. Senden schickt die Anfrage an die Sandbox.</template
  >
  <template data-i18n-for="send" data-i18n-locale="en">Send request</template>
  <template data-i18n-for="send" data-i18n-locale="de">Anfrage senden</template>
  <template data-i18n-for="reset" data-i18n-locale="en">Reset</template>
  <template data-i18n-for="reset" data-i18n-locale="de">Zurücksetzen</template>
  <template data-i18n-for="h-response" data-i18n-locale="en">Response</template>
  <template data-i18n-for="h-response" data-i18n-locale="de">Antwort</template>
  <template data-i18n-for="response-empty" data-i18n-locale="en"
    >Send the request to see the sandbox's answer.</template
  >
  <template data-i18n-for="response-empty" data-i18n-locale="de"
    >Senden Sie die Anfrage, um die Antwort der Sandbox zu sehen.</template
  >
  <template data-i18n-for="find-empty" data-i18n-locale="en">Nothing found.</template>
  <template data-i18n-for="find-empty" data-i18n-locale="de">Nichts gefunden.</template>
  <template data-i18n-for="key-title" data-i18n-locale="en">Authorize</template>
  <template data-i18n-for="key-title" data-i18n-locale="de">Autorisieren</template>
  <template data-i18n-for="key-text" data-i18n-locale="en"
    >Requests carry the key as a bearer token. The sandbox takes any test key that starts with acme_test_.</template
  >
  <template data-i18n-for="key-text" data-i18n-locale="de"
    >Anfragen tragen den Schlüssel als Bearer-Token. Die Sandbox nimmt jeden Testschlüssel, der mit acme_test_
    beginnt.</template
  >
  <template data-i18n-for="key-label" data-i18n-locale="en">API key</template>
  <template data-i18n-for="key-label" data-i18n-locale="de">API-Schlüssel</template>
  <template data-i18n-for="key-clear" data-i18n-locale="en">Remove key</template>
  <template data-i18n-for="key-clear" data-i18n-locale="de">Schlüssel entfernen</template>
  <template data-i18n-for="crumb-rpc" data-i18n-locale="en">defuss-rpc API</template>
  <template data-i18n-for="crumb-rpc" data-i18n-locale="de">defuss-rpc-API</template>
  <template data-i18n-for="crumb-rpc-2" data-i18n-locale="en">defuss-rpc API</template>
  <template data-i18n-for="crumb-rpc-2" data-i18n-locale="de">defuss-rpc-API</template>
  <template data-i18n-for="h-call" data-i18n-locale="en">Call it</template>
  <template data-i18n-for="h-call" data-i18n-locale="de">Aufrufen</template>
  <template data-i18n-for="call-text" data-i18n-locale="en"
    >Change an argument - the samples follow. Send calls the example in this page, or a defuss-rpc server.</template
  >
  <template data-i18n-for="call-text" data-i18n-locale="de"
    >Ändere ein Argument - die Beispiele folgen. Senden ruft das Beispiel in dieser Seite auf oder einen
    defuss-rpc-Server.</template
  >
  <template data-i18n-for="target" data-i18n-locale="en">Target</template>
  <template data-i18n-for="target" data-i18n-locale="de">Ziel</template>
  <template data-i18n-for="target-page" data-i18n-locale="en">The example in this page</template>
  <template data-i18n-for="target-page" data-i18n-locale="de">Das Beispiel in dieser Seite</template>
  <template data-i18n-for="target-server" data-i18n-locale="en">A defuss-rpc server</template>
  <template data-i18n-for="target-server" data-i18n-locale="de">Ein defuss-rpc-Server</template>
  <template data-i18n-for="server-url" data-i18n-locale="en">Server URL</template>
  <template data-i18n-for="server-url" data-i18n-locale="de">Server-URL</template>
  <template data-i18n-for="call" data-i18n-locale="en">Send call</template>
  <template data-i18n-for="call" data-i18n-locale="de">Aufruf senden</template>
  <template data-i18n-for="reset-call" data-i18n-locale="en">Reset</template>
  <template data-i18n-for="reset-call" data-i18n-locale="de">Zurücksetzen</template>
  <template data-i18n-for="h-answer" data-i18n-locale="en">Answer</template>
  <template data-i18n-for="h-answer" data-i18n-locale="de">Antwort</template>
  <template data-i18n-for="answer-empty" data-i18n-locale="en">Send the call to see its answer.</template>
  <template data-i18n-for="answer-empty" data-i18n-locale="de">Sende den Aufruf, um die Antwort zu sehen.</template>
  <template data-i18n-for="key-save" data-i18n-locale="en">Save key</template>
  <template data-i18n-for="key-save" data-i18n-locale="de">Schlüssel speichern</template>
</div>
<script type="module">
  // routing and translation: defuss-dom-router owns the address, defuss-i18n the language
  import { createRouter } from 'https://cdn.jsdelivr.net/npm/defuss-dom-router@0.1.1/dist/index.js';
  import { createDomI18n, createI18n } from 'https://cdn.jsdelivr.net/npm/defuss-i18n@0.2.0/dist/core.js';

  // the search: defuss-search over defuss-lexicalsearch - BM25 (prefix and fuzzy on the last word) answers as soon as
  // its modules are there (until then, and if they never come, the palette compares names), and BM25 fused with a
  // ColBERT scan (Winzling-reranker, 2.28 MB, on ONNX Runtime's 2.3 MB WASM build) once that model has loaded in the background
  const SEARCH = Promise.all([
    import('https://cdn.jsdelivr.net/npm/defuss-lexicalsearch@0.4.0/dist/index.js'),
    import('https://cdn.jsdelivr.net/npm/defuss-lexicalsearch@0.4.0/dist/en.js'),
    import('https://cdn.jsdelivr.net/npm/defuss-lexicalsearch@0.4.0/dist/de.js'),
    import('https://cdn.jsdelivr.net/npm/defuss-search@0.5.0/dist/strategies.js'),
  ]);
  const MODEL = () =>
    Promise.all([
      import('https://cdn.jsdelivr.net/npm/defuss-vectorsearch@0.4.0/dist/onnx.mjs'),
      import('https://cdn.jsdelivr.net/npm/defuss-brotli@0.3.0/dist/decompressor-slim.js'),
    ]);
  const BROTLI_WASM = 'https://cdn.jsdelivr.net/npm/defuss-brotli@0.3.0/dist/decompressor.wasm';

  // defuss-search's createProgressiveSearch (defuss-search/strategies), copied until its release: the lexical-only
  // search answers until semantic(index) has built another one, then that one; a failed build keeps BM25 answering
  const progressiveSearch = (strategies, index, { semantic, lexical }) => {
    const plain = strategies.createLexicalOnlySearch(index, { lexical });
    const listeners = new Set();
    let state = 'lexical';
    let built = null;
    let pending = null;
    const move = (next) => {
      state = next;
      for (const listener of listeners) listener(next);
    };
    const load = () =>
      (pending ??= (async () => {
        move('loading');
        try {
          built = await semantic(index);
          move('semantic');
        } catch (e) {
          pending = null;
          move('failed');
          throw e;
        }
      })());
    const searchWithStats = async (input, options) => {
      const current = built;
      return {
        ...(await (current ?? plain).searchWithStats(input, options)),
        source: current ? 'semantic' : 'lexical',
      };
    };
    return {
      get state() {
        return state;
      },
      load,
      searchWithStats,
      search: async (input, options) => (await searchWithStats(input, options)).hits,
      subscribe: (listener) => (listeners.add(listener), () => listeners.delete(listener)),
    };
  };

  // the model's pinned files, downloaded as <file>.br from Hugging Face, decoded with defuss-brotli, checked against
  // their SHA-256 and kept decoded in the Cache API where the page has one (a docs card's sandbox has none)
  const sha256 = async (bytes) =>
    [...new Uint8Array(await crypto.subtle.digest('SHA-256', bytes))]
      .map((x) => x.toString(16).padStart(2, '0'))
      .join('');
  const modelCache = (async () => {
    try {
      return await caches.open('acme-api-search');
    } catch {
      return null;
    }
  })();
  const modelFile = (brotli, id, revision, pins) => async (path) => {
    const sha = pins[path];
    if (!sha) throw new Error(path + ' is not pinned');
    const cache = await modelCache;
    const key = 'https://models.invalid/' + sha;
    const kept = await cache?.match(key).catch(() => null);
    if (kept) {
      const bytes = new Uint8Array(await kept.arrayBuffer());
      if ((await sha256(bytes)) === sha) return bytes;
    }
    const res = await fetch('https://huggingface.co/' + id + '/resolve/' + revision + '/' + path + '.br');
    if (!res.ok) throw new Error(path + ': HTTP ' + res.status);
    const raw = new Uint8Array(await res.arrayBuffer());
    let bytes;
    try {
      bytes = brotli.decompress(raw);
    } catch {
      bytes = raw; // sent with Content-Encoding: br - the browser decoded it already
    }
    if ((await sha256(bytes)) !== sha) throw new Error(path + ': SHA-256 differs from the pinned release');
    await cache?.put(key, new Response(bytes)).catch(() => {});
    return bytes;
  };
  // one model for both languages, loaded and warmed up once
  let colbert = null;
  const loadColbert = () =>
    (colbert ??= (async () => {
      const [onnx, brotli] = await MODEL();
      await brotli.init(BROTLI_WASM);
      const pin = onnx.MOEDERNCOLBERT_MODELS['1.5m'];
      const model = onnx.createColbertReranker({
        model: '1.5m',
        precision: 'q8',
        device: 'wasm',
        numThreads: 1,
        truncate: true,
        loadFile: modelFile(brotli, pin.id, pin.revision, pin.files),
      });
      await model.encodeQueries(['Acme']);
      return model;
    })().catch((e) => {
      colbert = null;
      throw e;
    }));

  // df$ comes with the component bundle - a full-screen page loads it after this module
  addEventListener('DOMContentLoaded', async () => {
    const app = df$('[data-ad]').get(0);
    const DATA = JSON.parse(df$('#ad-data').text());
    // the defuss-rpc reference: rpc.docs.json, the example API as the in-page mock and a wire client, one bundle
    // (scripts/build-rpc.ts) at the docs root - without it the REST reference works alone
    const RPC_MODULE = 'js/api-docs/client.js';
    const RPC = await import(new URL(RPC_MODULE, document.baseURI).href).catch(() => null);
    const RPC_NS = RPC ? RPC.schema.map((ns) => ({ name: RPC.namespaceName(ns), ns })) : [];
    // each page as Markdown and JSON (scripts/build-docs.ts writes api-docs/ from the same data)
    const DOC_FILES = 'api-docs/';

    // -- translation: the markup is the frame's catalog; the reference itself comes from the data block
    const locale = createI18n({ locale: 'en' }); // the demos start in English; the language switch offers German
    createDomI18n(df$).bind(app, locale);
    df$.shadcn.languageSwitcher.bind(df$('[data-app-locale]').get(0), locale);
    const lang = () => (locale.locale === 'de' ? 'de' : 'en');
    const words = () => DATA.words[lang()];
    const tr = (item) => item[lang()] ?? item.en;
    const fmt = (text, values) => text.replace(/%(\w)/g, (_m, k) => String(values[k] ?? ''));

    // -- the reference as one flat order: the guides, then each resource followed by its endpoints (the pager walks it)
    const href = {
      guide: (g) => (g.id === 'introduction' ? '#/' : '#/guides/' + g.id),
      resource: (r) => '#/ref/' + r.id,
      endpoint: (e) => '#/ref/' + e.resource + '/' + e.id,
      rpc: () => '#/rpc',
      namespace: (name) => '#/rpc/' + name,
      method: (name, m) => '#/rpc/' + name + '/' + m,
    };
    // an RPC page in ORDER: titles in both languages (the JSDoc is English), a tag and a path for the palette
    const rpcItem = (title, lead, extra = {}) => ({ en: { title, lead }, ...extra });
    const ORDER = [
      ...DATA.guides.map((g) => ({ kind: 'guide', item: g, href: href.guide(g) })),
      ...DATA.resources.flatMap((r) => [
        { kind: 'resource', item: r, href: href.resource(r) },
        ...DATA.endpoints
          .filter((e) => e.resource === r.id)
          .map((e) => ({ kind: 'endpoint', item: e, href: href.endpoint(e) })),
      ]),
      ...(RPC
        ? [
            {
              kind: 'rpc',
              item: { en: { title: DATA.words.en.rpcTitle }, de: { title: DATA.words.de.rpcTitle } },
              href: href.rpc(),
            },
            ...RPC_NS.flatMap(({ name, ns }) => [
              { kind: 'namespace', item: rpcItem(name, ns.description ?? ''), name, ns, href: href.namespace(name) },
              ...Object.entries(ns.methods).map(([m, doc]) => ({
                kind: 'method',
                item: rpcItem(name + '.' + m, doc.description ?? '', {
                  method: doc.generator ? 'STREAM' : 'RPC',
                  path: RPC.signature(m, doc),
                }),
                name,
                ns,
                m,
                doc,
                href: href.method(name, m),
              })),
            ]),
          ]
        : []),
    ];
    const resourceOf = (id) => DATA.resources.find((r) => r.id === id);
    const endpointOf = (resource, id) => DATA.endpoints.find((e) => e.resource === resource && e.id === id);

    const el = (tag, attrs = {}, text) => {
      const node = df$('<' + tag + '></' + tag + '>');
      for (const [k, v] of Object.entries(attrs)) node.attr(k, v);
      if (text !== undefined) node.text(text);
      return node;
    };
    const method = (m) => el('span', { class: 'ad-method', 'data-method': m }, m);
    const icons = () => globalThis.lucide?.createIcons();

    // -- state: the version, the API key, the try-it values per endpoint (kept while you browse)
    let version = 'v4';
    let apiKey = '';
    const values = new Map();
    const base = () => DATA.base + '/' + version;

    // -- the navigation
    const nav = df$('[data-ad-nav]');
    const writeNav = () => {
      nav.html('');
      nav.append(el('p', { class: 'mk-docs-navigation-heading' }, words().guides));
      const guides = el('ul');
      for (const g of DATA.guides)
        guides.append(el('li').append(el('a', { href: href.guide(g), 'data-router-link': '' }, tr(g).title)));
      nav.append(guides);
      for (const r of DATA.resources) {
        const group = el('details', { open: '', 'data-ad-group': r.id });
        group.append(el('summary', { class: 'mk-docs-navigation-heading' }, tr(r).title));
        const list = el('ul');
        list.append(
          el('li').append(
            el('a', { href: href.resource(r), 'data-router-link': '' }, fmt(words().object, { s: r.object })),
          ),
        );
        for (const e of DATA.endpoints.filter((x) => x.resource === r.id)) {
          const link = el('a', { href: href.endpoint(e), 'data-router-link': '' });
          link.append(method(e.method)).append(el('span', {}, tr(e).title));
          list.append(el('li').append(link));
        }
        group.append(list);
        nav.append(group);
      }
      if (!RPC) return;
      nav.append(el('p', { class: 'mk-docs-navigation-heading' }, words().rpcGroup));
      const overview = el('ul');
      overview.append(el('li').append(el('a', { href: href.rpc(), 'data-router-link': '' }, words().rpcOverview)));
      nav.append(overview);
      for (const { name, ns } of RPC_NS) {
        const group = el('details', { open: '', 'data-ad-group': 'rpc-' + name });
        group.append(el('summary', { class: 'mk-docs-navigation-heading' }, name));
        const list = el('ul');
        list.append(el('li').append(el('a', { href: href.namespace(name), 'data-router-link': '' }, name)));
        for (const [m, doc] of Object.entries(ns.methods)) {
          const link = el('a', { href: href.method(name, m), 'data-router-link': '' });
          link.append(method(doc.generator ? 'STREAM' : 'RPC')).append(el('span', {}, m));
          list.append(el('li').append(link));
        }
        group.append(list);
        nav.append(group);
      }
    };
    const markCurrent = (target) => {
      nav.find('a').each((_i, a) => {
        if (a.getAttribute('href') === target) a.setAttribute('aria-current', 'page');
        else a.removeAttribute('aria-current');
      });
    };

    // -- prose from a body: paragraphs; "## " a heading, "$ " a command, "> " a note
    const prose = (box, lines) => {
      box.html('');
      for (const line of lines) {
        if (line.startsWith('## ')) box.append(el('h2', {}, line.slice(3)));
        else if (line.startsWith('$ '))
          box.append(
            el('pre', { 'data-lang': line.startsWith('$ {') ? 'json' : 'bash' }).append(el('code', {}, line.slice(2))),
          );
        else if (line.startsWith('> ')) {
          const note = el('aside', { class: 'mk-docs-content-callout', role: 'note' });
          note.append(el('i', { 'data-lucide': 'info' })).append(el('p', {}, line.slice(2)));
          box.append(note);
        } else box.append(el('p', {}, line));
      }
    };
    const pager = (view, at) => {
      const box = df$(view).find('[data-ad-pager]');
      box.html('');
      const label = (o) => tr(o.item).title;
      const prev = ORDER[at - 1];
      const next = ORDER[at + 1];
      if (prev)
        box.append(
          el('a', { href: prev.href, 'data-router-link': '', rel: 'prev' })
            .append(el('small', {}, words().prev))
            .append(el('strong', {}, '← ' + label(prev))),
        );
      if (next)
        box.append(
          el('a', { href: next.href, 'data-router-link': '', rel: 'next' })
            .append(el('small', {}, words().next))
            .append(el('strong', {}, label(next) + ' →')),
        );
    };
    const view = (name) => df$('[data-ad-view="' + name + '"]').get(0);

    // -- the sandbox: an in-memory Acme that answers like the API (statuses, errors, cursors, rate-limit headers)
    const db = {
      tasks: [
        {
          id: 't_105',
          object: 'task',
          title: 'Write the v4 migration guide',
          status: 'doing',
          assignee: 'm_ana',
          due_on: '2026-11-20',
          workspace: 'ws_acme',
          created_at: '2026-11-12T09:30:00Z',
        },
        {
          id: 't_104',
          object: 'task',
          title: 'Rotate the webhook secrets',
          status: 'todo',
          assignee: null,
          due_on: '2026-11-28',
          workspace: 'ws_acme',
          created_at: '2026-11-10T14:05:00Z',
        },
        {
          id: 't_103',
          object: 'task',
          title: 'Archive the v2 changelog',
          status: 'todo',
          assignee: 'm_lea',
          due_on: null,
          workspace: 'ws_acme',
          created_at: '2026-11-04T08:12:00Z',
        },
        {
          id: 't_102',
          object: 'task',
          title: 'Rate limit dashboard',
          status: 'done',
          assignee: 'm_ana',
          due_on: '2026-10-30',
          workspace: 'ws_acme',
          created_at: '2026-10-21T16:40:00Z',
        },
        {
          id: 't_101',
          object: 'task',
          title: 'Publish the OpenAPI file',
          status: 'done',
          assignee: 'm_jon',
          due_on: '2026-10-15',
          workspace: 'ws_acme',
          created_at: '2026-10-02T10:00:00Z',
        },
      ],
      docs: [
        {
          id: 'd_202',
          object: 'doc',
          title: 'Webhook signatures',
          body: 'Every delivery carries an Acme-Signature header ...',
          workspace: 'ws_acme',
          updated_at: '2026-11-11T11:00:00Z',
        },
        {
          id: 'd_201',
          object: 'doc',
          title: 'API style guide',
          body: '# Naming\n\nResources are plural nouns ...',
          workspace: 'ws_acme',
          updated_at: '2026-11-02T09:20:00Z',
        },
      ],
      members: [
        { id: 'm_ana', object: 'member', email: 'ana@acme.example', role: 'admin', status: 'active' },
        { id: 'm_jon', object: 'member', email: 'jon@acme.example', role: 'member', status: 'active' },
        { id: 'm_lea', object: 'member', email: 'lea@acme.example', role: 'guest', status: 'active' },
      ],
      webhooks: [{ id: 'wh_301', object: 'webhook', url: 'https://hooks.acme.example/ci', events: ['task.updated'] }],
    };
    const EXAMPLE = {
      tasks: db.tasks[0],
      docs: db.docs[0],
      members: db.members[0],
      webhooks: { ...db.webhooks[0], secret: 'whsec_9fK2mQ7xL4' },
    };
    const seq = { tasks: 106, docs: 203, members: 1, webhooks: 302 };
    // 100 requests a minute, counted from the minute's first request
    let remaining = 100;
    let windowStart = 0;
    const fail = (status, type, message, param) => ({
      status,
      body: { error: { type, message, ...(param ? { param } : {}) } },
    });
    const page = (rows, limit, cursor) => {
      const from = cursor ? rows.findIndex((r) => r.id === cursor) + 1 : 0;
      if (cursor && !from) return fail(400, 'invalid_request_error', 'Invalid cursor: ' + cursor + '.', 'cursor');
      const size = Math.min(100, Math.max(1, Number(limit) || 10));
      const data = rows.slice(from, from + size);
      const more = from + size < rows.length;
      return { status: 200, body: { object: 'list', data, has_more: more, next_cursor: more ? data.at(-1).id : null } };
    };
    const sandbox = (ep, v) => {
      if (!apiKey) return fail(401, 'authentication_error', 'No API key provided. Send it as a bearer token.');
      if (!/^acme_test_\w{6,}$/.test(apiKey))
        return fail(401, 'authentication_error', 'Invalid API key. Test keys start with acme_test_.');
      if (Date.now() - windowStart > 60_000) {
        windowStart = Date.now();
        remaining = 100;
      }
      if (remaining === 0) return fail(429, 'rate_limit_error', 'Too many requests. Wait for X-RateLimit-Reset.');
      remaining--;
      for (const p of ep.params) {
        if (p.required && !v[p.name])
          return fail(400, 'invalid_request_error', 'Missing required parameter: ' + p.name + '.', p.name);
        if (v[p.name] && p.type === 'enum' && !p.values.includes(v[p.name]))
          return fail(
            400,
            'invalid_request_error',
            'Invalid ' + p.name + ': must be one of ' + p.values.join(', ') + '.',
            p.name,
          );
        if (v[p.name] && p.type === 'integer' && !/^\d+$/.test(v[p.name]))
          return fail(400, 'invalid_request_error', 'Invalid integer: ' + p.name + '.', p.name);
        if (v[p.name] && p.type === 'date' && !/^\d{4}-\d{2}-\d{2}$/.test(v[p.name]))
          return fail(400, 'invalid_request_error', 'Invalid date: ' + p.name + ' must be YYYY-MM-DD.', p.name);
      }
      const rows = db[ep.resource];
      const missing = (what, id) => fail(404, 'resource_missing', 'No such ' + what + ': ' + id + '.', 'id');
      const workspace = (id) =>
        id === 'ws_acme' ? null : fail(404, 'resource_missing', 'No such workspace: ' + id + '.', 'workspace');
      const now = new Date().toISOString().replace(/\.\d+Z$/, 'Z');
      const object = EXAMPLE[ep.resource].object;
      const find = () => rows.find((r) => r.id === v.id);
      switch (ep.method + ' ' + ep.id) {
        case 'GET list': {
          if (v.workspace && workspace(v.workspace)) return workspace(v.workspace);
          const filtered = rows.filter((r) => (!v.status || r.status === v.status) && (!v.role || r.role === v.role));
          return page(filtered, v.limit, v.cursor);
        }
        case 'POST create': {
          if (v.workspace && workspace(v.workspace)) return workspace(v.workspace);
          if (ep.resource === 'webhooks' && !/^https:\/\//.test(v.url))
            return fail(400, 'invalid_request_error', 'Invalid url: webhooks need HTTPS.', 'url');
          const id = { tasks: 't_', docs: 'd_', webhooks: 'wh_' }[ep.resource] + seq[ep.resource]++;
          const made =
            ep.resource === 'tasks'
              ? {
                  id,
                  object,
                  title: v.title,
                  status: v.status || 'todo',
                  assignee: v.assignee || null,
                  due_on: v.due_on || null,
                  workspace: v.workspace,
                  created_at: now,
                }
              : ep.resource === 'docs'
                ? { id, object, title: v.title, body: v.body || '', workspace: v.workspace, updated_at: now }
                : {
                    id,
                    object,
                    url: v.url,
                    events: v.events
                      .split(',')
                      .map((s) => s.trim())
                      .filter(Boolean),
                    secret: 'whsec_' + id.slice(3) + 'Qe7',
                  };
          rows.unshift(made);
          return { status: 201, body: made };
        }
        case 'POST invite': {
          if (workspace(v.workspace)) return workspace(v.workspace);
          if (!/^[^@\s]+@[^@\s]+\.\w+$/.test(v.email))
            return fail(400, 'invalid_request_error', 'Invalid email.', 'email');
          const made = {
            id: 'm_' + v.email.split('@')[0].replace(/\W/g, ''),
            object,
            email: v.email,
            role: v.role || 'member',
            status: 'invited',
          };
          rows.push(made);
          return { status: 201, body: made };
        }
        case 'GET retrieve':
          return find() ? { status: 200, body: find() } : missing(object, v.id);
        case 'PATCH update': {
          const row = find();
          if (!row) return missing(object, v.id);
          for (const key of ['title', 'status']) if (v[key]) row[key] = v[key];
          if (v.assignee) row.assignee = v.assignee === 'none' ? null : v.assignee;
          return { status: 200, body: row };
        }
        case 'DELETE delete': {
          const row = find();
          if (!row) return missing(object, v.id);
          rows.splice(rows.indexOf(row), 1);
          return { status: 200, body: { id: row.id, object, deleted: true } };
        }
      }
      return fail(400, 'invalid_request_error', 'Unknown endpoint.');
    };

    // -- the samples: curl, JavaScript and Python from the endpoint and the values in the form
    const request = (ep, v) => {
      let path = ep.path;
      const query = [];
      const body = {};
      for (const p of ep.params) {
        const value = v[p.name];
        if (p.in === 'path')
          path = path.replace('{' + p.name + '}', value ? encodeURIComponent(value) : '{' + p.name + '}');
        else if (!value) continue;
        else if (p.in === 'query') query.push(p.name + '=' + encodeURIComponent(value));
        else
          body[p.name] =
            p.type === 'string[]'
              ? value
                  .split(',')
                  .map((s) => s.trim())
                  .filter(Boolean)
              : p.type === 'integer'
                ? Number(value)
                : value;
      }
      return {
        url: base() + path + (query.length ? '?' + query.join('&') : ''),
        body: Object.keys(body).length ? body : null,
      };
    };
    const indent = (text, by) => text.replace(/\n/g, '\n' + by);
    const python = (value) =>
      JSON.stringify(value, null, 4)
        .replace(/\btrue\b/g, 'True')
        .replace(/\bfalse\b/g, 'False')
        .replace(/\bnull\b/g, 'None');
    const samples = (ep, v) => {
      const { url, body } = request(ep, v);
      const key = apiKey || 'YOUR_API_KEY';
      const curl = [
        'curl' + (ep.method === 'GET' ? '' : ' -X ' + ep.method) + " '" + url + "'",
        '  -H "Authorization: Bearer ' + key + '"',
      ];
      if (body)
        curl.push(
          '  -H "Content-Type: application/json"',
          "  -d '" + JSON.stringify(body).replace(/'/g, "'\\''") + "'",
        ); // a ' closes the shell quote: '\''
      const js = [
        "const res = await fetch('" + url + "', {",
        ...(ep.method === 'GET' ? [] : ["  method: '" + ep.method + "',"]),
        '  headers: {',
        "    Authorization: 'Bearer " + key + "',",
        ...(body ? ["    'Content-Type': 'application/json',"] : []),
        '  },',
        ...(body ? ['  body: JSON.stringify(' + indent(JSON.stringify(body, null, 2), '  ') + '),'] : []),
        '});',
        'const data = await res.json();',
      ];
      const py = [
        'import requests',
        '',
        'res = requests.' + ep.method.toLowerCase() + '(',
        "    '" + url + "',",
        "    headers={'Authorization': 'Bearer " + key + "'},",
        ...(body ? ['    json=' + indent(python(body), '    ') + ','] : []),
        ')',
        'print(res.json())',
      ];
      return { curl: curl.join(' \\\n'), js: js.join('\n'), python: py.join('\n') };
    };

    // -- code in colours: Shiki (pinned, loaded on first use) paints each listing in GitHub's dark theme - the panels
    // stay dark in both modes. Offline the code stays plain.
    let shiki = null;
    let painting = Promise.resolve();
    const paint = () =>
      (painting = painting.then(async () => {
        const listings = df$('.ad [data-lang]:not([data-painted])').toArray();
        if (!listings.length) return;
        try {
          shiki ??= await import('https://esm.sh/shiki@3.0.0');
        } catch {
          return;
        }
        for (const listing of listings) {
          const code = df$(listing).find('code').get(0) ?? listing;
          const text = code.textContent;
          const { tokens } = await shiki.codeToTokens(text, { lang: listing.dataset.lang, theme: 'github-dark' });
          // a listing written again while Shiki worked keeps its new text
          if (code.textContent !== text) continue;
          // one span per line: a Code Example block lays its lines out as block spans, a plain listing keeps the newlines
          const blocks = !!listing.closest('.mk-code-block');
          df$(code).html('');
          tokens.forEach((row, r) => {
            if (r && !blocks) df$(code).append(document.createTextNode('\n'));
            const line = el('span');
            for (const token of row) line.append(el('span', { style: 'color:' + token.color }, token.content));
            df$(code).append(line);
          });
          listing.dataset.painted = '';
        }
      }));
    const write = (node, text) => {
      df$(node).text(text);
      node.removeAttribute('data-painted');
      const parent = node.closest('[data-lang]');
      if (parent) parent.removeAttribute('data-painted');
    };

    // -- the pages
    let shown = null;
    const guide = (g) => {
      const box = view('guide');
      const t = tr(g);
      df$(box).find('[data-ad-guide-crumb]').text(t.title);
      df$(box).find('[data-ad-guide-title]').text(t.title);
      df$(box).find('[data-ad-guide-lead]').text(t.lead);
      prose(df$(box).find('[data-ad-guide-body]'), t.body);
      const cards = df$(box).find('[data-ad-home-cards]');
      cards.html('');
      cards.prop('hidden', g.id !== 'introduction');
      if (g.id === 'introduction')
        for (const r of DATA.resources) {
          const card = el('a', { class: 'card', href: href.resource(r), 'data-router-link': '' });
          const head = el('div', { class: 'card-header' });
          head
            .append(el('h3', { class: 'card-title' }, tr(r).title))
            .append(el('p', { class: 'card-description' }, tr(r).lead));
          const count = DATA.endpoints.filter((e) => e.resource === r.id).length;
          card
            .append(head)
            .append(
              el('div', { class: 'card-footer' }).append(
                el('span', { class: 'badge', 'data-variant': 'secondary' }, fmt(words().endpoints, { n: count })),
              ),
            );
          cards.append(card);
        }
      if (g.id === 'introduction' && RPC) {
        const card = el('a', { class: 'card', href: href.rpc(), 'data-router-link': '' });
        const head = el('div', { class: 'card-header' });
        head
          .append(el('h3', { class: 'card-title' }, words().rpcTitle))
          .append(el('p', { class: 'card-description' }, words().rpcCard));
        card
          .append(head)
          .append(
            el('div', { class: 'card-footer' }).append(
              el(
                'span',
                { class: 'badge', 'data-variant': 'secondary' },
                fmt(words().methods, { n: ORDER.filter((o) => o.kind === 'method').length }),
              ),
            ),
          );
        cards.append(card);
      }
      return box;
    };
    const resource = (r) => {
      const box = view('resource');
      const t = tr(r);
      df$(box).find('[data-ad-res-crumb]').text(t.title);
      df$(box).find('[data-ad-res-title]').text(t.title);
      df$(box).find('[data-ad-res-lead]').text(t.lead);
      const ops = df$(box).find('[data-ad-res-ops]');
      ops.html('');
      for (const e of DATA.endpoints.filter((x) => x.resource === r.id)) {
        const link = el('a', { href: href.endpoint(e), 'data-router-link': '' });
        link
          .append(method(e.method))
          .append(el('span', {}, tr(e).title))
          .append(el('code', {}, e.path));
        ops.append(el('li').append(link));
      }
      df$(box)
        .find('[data-ad-res-object]')
        .text(fmt(words().object, { s: r.object }));
      const fields = df$(box).find('[data-ad-res-fields]');
      fields.html('');
      for (const [name, type, en, de] of r.fields) {
        const head = el('div', { class: 'ad-param-head' })
          .append(el('code', {}, name))
          .append(el('span', { class: 'ad-type' }, type));
        fields.append(
          el('li')
            .append(head)
            .append(el('p', {}, lang() === 'de' ? de : en)),
        );
      }
      df$(box)
        .find('[data-ad-res-example]')
        .text(fmt(words().example, { s: r.object }));
      write(df$(box).find('[data-ad-res-json]').get(0), JSON.stringify(EXAMPLE[r.id], null, 2));
      return box;
    };
    let current = null;
    const valuesOf = (ep) => {
      const key = ep.resource + '/' + ep.id;
      if (!values.has(key)) values.set(key, Object.fromEntries(ep.params.map((p) => [p.name, p.example ?? ''])));
      return values.get(key);
    };
    let shownSamples = {};
    const writeSamples = () => {
      if (!current) return;
      const s = (shownSamples = samples(current, valuesOf(current)));
      df$('[data-ad-sample]').each((_i, code) => {
        write(code, s[code.dataset.adSample]);
      });
      df$('[data-ad-ep-path]').text(request(current, valuesOf(current)).url.replace(/\?.*$/, ''));
      paint();
    };
    const endpoint = (ep) => {
      const box = view('endpoint');
      const t = tr(ep);
      const r = resourceOf(ep.resource);
      const changed = current !== ep;
      current = ep;
      df$(box).find('[data-ad-ep-crumb]').attr('href', href.resource(r)).text(tr(r).title);
      df$(box).find('[data-ad-ep-crumb-page]').text(t.title);
      df$(box).find('[data-ad-ep-title]').text(t.title);
      df$(box).find('[data-ad-ep-method]').attr('data-method', ep.method).text(ep.method);
      df$(box).find('[data-ad-ep-lead]').text(t.lead);
      // the parameters, grouped by where they go
      const params = df$(box).find('[data-ad-ep-params]');
      params.html('');
      for (const where of ['path', 'query', 'body']) {
        const list = ep.params.filter((p) => p.in === where);
        if (!list.length) continue;
        params.append(el('h2', { class: 'text-lg font-semibold mb-3' }, words()[where]));
        const ul = el('ul', { class: 'ad-params' });
        for (const p of list) {
          const head = el('div', { class: 'ad-param-head' })
            .append(el('code', {}, p.name))
            .append(el('span', { class: 'ad-type' }, p.type));
          if (p.required) head.append(el('span', { class: 'ad-required' }, words().required));
          const li = el('li', { 'data-param': p.name })
            .append(head)
            .append(el('p', {}, p[lang()] ?? p.en));
          if (p.values) {
            const one = el('p', { class: 'ad-enum' }, words().oneOf + ' ');
            p.values.forEach((value, i) =>
              one.append(el('code', {}, value)).append(document.createTextNode(i < p.values.length - 1 ? ', ' : '')),
            );
            li.append(one);
          }
          ul.append(li);
        }
        params.append(ul);
      }
      const responses = df$(box).find('[data-ad-ep-responses]');
      responses.html('');
      for (const code of ep.codes)
        responses.append(
          el('li')
            .append(el('span', { class: 'ad-status', 'data-class': code[0] }, code))
            .append(el('span', {}, words().codes[code])),
        );
      // the try-it form: one field per parameter, the values kept per endpoint
      const fields = df$(box).find('[data-ad-try-fields]');
      fields.html('');
      const v = valuesOf(ep);
      for (const p of ep.params) {
        const id = 'ad-try-' + p.name;
        const field = el('div', { class: 'ad-field' }).append(
          el('label', { class: 'label', for: id }, p.name + (p.required ? ' *' : '')),
        );
        let input;
        if (p.values) {
          input = el('select', { class: 'select', id, name: p.name, 'data-size': 'sm' });
          input.append(el('option', { value: '' }, '-'));
          for (const value of p.values) input.append(el('option', { value }, value));
        } else
          input = el('input', {
            class: 'input',
            id,
            name: p.name,
            type: 'text',
            autocomplete: 'off',
            spellcheck: 'false',
            'data-size': 'sm',
            placeholder: p.example ?? p.type,
          });
        input.val(v[p.name] ?? '');
        fields.append(field.append(input));
      }
      if (changed) {
        df$('[data-ad-res-status]').text('');
        df$('[data-ad-res-time]').text('');
        df$('[data-ad-res-empty]').prop('hidden', false);
        df$('[data-ad-res-body]').prop('hidden', true);
      }
      writeSamples();
      return box;
    };

    // -- defuss-rpc: the overview, a namespace, a method
    const rpcNamespace = (entry) => {
      const box = view('rpc-ns');
      df$(box)
        .find('[data-ad-rn-crumb]')
        .text(entry ? entry.name : '');
      df$(box).find('[data-ad-rn-sep]').prop('hidden', !entry);
      df$(box)
        .find('[data-ad-rn-title]')
        .text(entry ? entry.name : words().rpcTitle);
      df$(box)
        .find('[data-ad-rn-lead]')
        .text(
          entry
            ? (entry.ns.description ?? '') + ' ' + (entry.ns.kind === 'class' ? words().classNote : words().moduleNote)
            : words().rpcLead,
        );
      prose(df$(box).find('[data-ad-rn-body]'), entry ? [] : words().rpcBody);
      const cards = df$(box).find('[data-ad-rn-cards]');
      cards.html('');
      const ops = df$(box).find('[data-ad-rn-ops]');
      ops.html('');
      if (!entry)
        for (const { name, ns } of RPC_NS) {
          const card = el('a', { class: 'card', href: href.namespace(name), 'data-router-link': '' });
          const head = el('div', { class: 'card-header' });
          head
            .append(el('h3', { class: 'card-title' }, name))
            .append(el('p', { class: 'card-description' }, ns.description ?? ''));
          card
            .append(head)
            .append(
              el('div', { class: 'card-footer' }).append(
                el(
                  'span',
                  { class: 'badge', 'data-variant': 'secondary' },
                  fmt(words().methods, { n: Object.keys(ns.methods).length }),
                ),
              ),
            );
          cards.append(card);
        }
      else
        for (const [m, doc] of Object.entries(entry.ns.methods)) {
          const link = el('a', { href: href.method(entry.name, m), 'data-router-link': '' });
          link
            .append(method(doc.generator ? 'STREAM' : 'RPC'))
            .append(el('span', {}, doc.description ?? m))
            .append(el('code', {}, RPC.signature(m, doc)));
          ops.append(el('li').append(link));
        }
      return box;
    };

    // a value in a line: JSON, with a Map as an object, a Set as a list and a BigInt as its digits
    const line = (value) =>
      JSON.stringify(value, (_k, v) =>
        v instanceof Map ? Object.fromEntries(v) : v instanceof Set ? [...v] : typeof v === 'bigint' ? String(v) : v,
      ) ?? 'undefined';
    // a field's text, or a tree's value, as the argument the method declares: a date string becomes a Date, a list a
    // Set where the schema says x-dson set - what the generated client would send
    const revive = (value, schema) => {
      if (!schema || value === null || value === undefined) return value;
      if (Array.isArray(schema.anyOf))
        return revive(value, schema.anyOf.find((x) => x.type !== 'null') ?? schema.anyOf[0]);
      const kind = schema['x-dson'];
      if (kind === 'date' && typeof value === 'string') return new Date(value);
      if (kind === 'bigint' && (typeof value === 'string' || typeof value === 'number')) return BigInt(value);
      if (kind === 'set' && Array.isArray(value)) return new Set(value.map((x) => revive(x, schema.items)));
      if (kind === 'map' && value && typeof value === 'object' && !(value instanceof Map))
        return new Map(Object.entries(value).map(([k, x]) => [k, revive(x, schema.additionalProperties)]));
      if (Array.isArray(value)) return value.map((x) => revive(x, schema.items));
      if (typeof value === 'object' && schema.properties)
        return Object.fromEntries(Object.entries(value).map(([k, x]) => [k, revive(x, schema.properties[k])]));
      return value;
    };
    // how a parameter is edited: a select for an enum or a boolean, a number field, a text field, else a Property Tree
    const fieldKind = (schema = {}) => {
      if (Array.isArray(schema.enum)) return 'enum';
      const type = Array.isArray(schema.type) ? schema.type[0] : schema.type;
      if (type === 'boolean') return 'boolean';
      if (type === 'number' || type === 'integer') return schema['x-dson'] === 'bigint' ? 'text' : 'number';
      if (type === 'string') return 'text';
      return 'tree';
    };
    // a tree as high as the rows it shows open: the root and its entries (at least `min`, at most 14)
    const openRows = (value, expanded) => {
      let n = 1;
      const walk = (v, ptr) => {
        if (!v || typeof v !== 'object' || (ptr !== '' && !expanded.has(ptr))) return;
        const entries = v instanceof Map ? [...v] : v instanceof Set ? [...v].map((x, i) => [i, x]) : Object.entries(v);
        for (const [k, x] of entries) {
          n++;
          if (n > 14) return;
          walk(x, ptr + '/' + String(k).replace(/~/g, '~0').replace(/\//g, '~1'));
        }
      };
      walk(value, '');
      return n;
    };
    const rpcFit = (tree, value, min = 1) => {
      const size = () => {
        const expanded = new Set(tree.api?.getState().config.expanded ?? []);
        const rows = openRows(df$.shadcn.propertyTree.value(tree) ?? value, expanded);
        tree.style.blockSize = 'calc(' + Math.min(Math.max(rows, min), 14) + ' * 1.75rem + 2px)';
      };
      size();
      // opening a row grows the tree (VERIFIED: a 4-row answer held 35 rows in 140px after three rows opened)
      if (tree.store && !tree.dataset.adFit) {
        tree.dataset.adFit = '';
        tree.store.subscribe(size);
      }
    };
    let call = null; // the method shown: { name, m, doc }
    const rpcValues = new Map(); // "Namespace.method" -> the form's values, one per parameter
    const rpcValuesOf = (c) => {
      const key = c.name + '.' + c.m;
      if (!rpcValues.has(key)) {
        const args = RPC.exampleArgs(c.doc);
        rpcValues.set(
          key,
          (c.doc.params ?? []).map((p, i) => {
            const v = i < args.length ? args[i] : p.optional ? undefined : RPC.exampleValue(p.schema, p.name);
            return fieldKind(p.schema) === 'tree'
              ? (v ?? RPC.exampleValue(p.schema, p.name))
              : v === undefined
                ? ''
                : String(v);
          }),
        );
      }
      return rpcValues.get(key);
    };
    // the arguments as JSON values (the samples) and as the values the method takes (the call)
    const rpcArgs = (c) => {
      const params = c.doc.params ?? [];
      const raw = rpcValuesOf(c);
      const json = params.map((p, i) => {
        const v = raw[i];
        const kind = fieldKind(p.schema);
        if (kind === 'tree') return v;
        if (v === '') return undefined;
        if (kind === 'number') return Number(v);
        if (kind === 'boolean') return v === 'true';
        return v;
      });
      while (json.length && json[json.length - 1] === undefined && params[json.length - 1]?.optional) json.pop();
      return { json, values: json.map((v, i) => revive(v, params[i].schema)) };
    };
    const rpcTarget = () =>
      df$('[data-ad-rpc-target]').val() === 'server'
        ? { kind: 'server', url: df$('[data-ad-rpc-url]').val().trim() }
        : { kind: 'page' };
    let rpcShownSamples = {};
    const writeRpcSamples = () => {
      if (!call) return;
      const t = rpcTarget();
      const s = (rpcShownSamples = RPC.rpcSamples(
        call.name,
        call.m,
        call.doc,
        rpcArgs(call).json,
        t.kind === 'server' ? t.url : RPC.RPC_SERVER,
      ));
      df$('[data-ad-rsample]').each((_i, code) => {
        write(code, s[code.dataset.adRsample]);
      });
      paint();
    };
    const resetAnswer = () => {
      df$('[data-ad-rpc-status]').text('').attr('data-class', '');
      df$('[data-ad-rpc-time]').text('');
      df$('[data-ad-rpc-empty]').prop('hidden', false);
      df$('[data-ad-rpc-error]').prop('hidden', true).text('');
      df$('[data-ad-rpc-frames]').prop('hidden', true).html('');
      df$('[data-ad-rpc-result]').prop('hidden', true);
    };
    const rpcMethod = (entry, m) => {
      const box = view('rpc-method');
      const doc = entry.ns.methods[m];
      const changed = !call || call.name !== entry.name || call.m !== m;
      call = { name: entry.name, m, doc };
      df$(box).find('[data-ad-rm-crumb]').attr('href', href.namespace(entry.name)).text(entry.name);
      df$(box).find('[data-ad-rm-crumb-page]').text(m);
      df$(box)
        .find('[data-ad-rm-title]')
        .text(entry.name + '.' + m);
      const badges = df$(box).find('[data-ad-rm-badges]');
      badges.html('');
      badges.append(method(doc.generator ? 'STREAM' : 'RPC'));
      badges.append(
        el('span', { class: 'badge', 'data-variant': 'secondary' }, doc.generator ? words().stream : words().once),
      );
      if (doc.deprecated)
        badges.append(el('span', { class: 'badge', 'data-variant': 'destructive' }, words().deprecated));
      write(df$(box).find('[data-ad-rm-signature]').get(0), RPC.signature(m, doc));
      df$(box)
        .find('[data-ad-rm-lead]')
        .text(doc.description ?? '');
      // the documentation: parameters, the value (and a stream's values), errors, examples
      const docs = df$(box).find('[data-ad-rm-docs]');
      docs.html('');
      if (typeof doc.deprecated === 'string')
        docs.append(el('p', { class: 'ad-rpc-error' }, words().deprecated + ': ' + doc.deprecated));
      docs.append(el('h2', { class: 'text-lg font-semibold mb-3' }, words().params));
      const params = doc.params ?? [];
      if (!params.length) docs.append(el('p', { class: 'mb-4' }, words().noParams));
      else {
        const ul = el('ul', { class: 'ad-params' });
        for (const p of params) {
          const head = el('div', { class: 'ad-param-head' })
            .append(el('code', {}, (p.rest ? '...' : '') + p.name))
            .append(el('span', { class: 'ad-type' }, p.type ?? ''));
          head.append(
            el(
              'span',
              { class: p.optional ? 'ad-type' : 'ad-required' },
              p.optional ? words().optional : words().required,
            ),
          );
          ul.append(
            el('li', { 'data-param': p.name })
              .append(head)
              .append(el('p', {}, p.description ?? '')),
          );
        }
        docs.append(ul);
      }
      for (const [label, value] of [
        [doc.generator ? words().yields : words().returns, doc.generator ? doc.yields : doc.returns],
        ...(doc.generator ? [[words().returns, doc.returns]] : []),
      ]) {
        if (!value) continue;
        docs.append(el('h2', { class: 'text-lg font-semibold mb-3' }, label));
        const ul = el('ul', { class: 'ad-params' });
        ul.append(
          el('li', { 'data-returns': label })
            .append(el('div', { class: 'ad-param-head' }).append(el('span', { class: 'ad-type' }, value.type ?? '')))
            .append(el('p', {}, value.description ?? '')),
        );
        docs.append(ul);
      }
      if (doc.throws?.length) {
        docs.append(el('h2', { class: 'text-lg font-semibold mb-3' }, words().throws));
        const ul = el('ul', { class: 'ad-params' });
        for (const text of doc.throws) ul.append(el('li').append(el('p', {}, text)));
        docs.append(ul);
      }
      if (doc.examples?.length) {
        docs.append(el('h2', { class: 'text-lg font-semibold mb-3' }, words().examples));
        for (const text of doc.examples)
          docs.append(el('pre', { class: 'ad-signature', 'data-lang': 'ts', 'data-ad-rm-example': '' }, text));
      }
      // the form: one field per parameter, the values kept per method
      const fields = df$(box).find('[data-ad-rpc-fields]');
      fields.html('');
      const v = rpcValuesOf(call);
      params.forEach((p, i) => {
        const id = 'ad-rpc-arg-' + p.name;
        const kind = fieldKind(p.schema);
        const field = el('div', {
          class: 'ad-field' + (kind === 'tree' ? ' ad-rpc-wide' : ''),
          'data-ad-rpc-arg': p.name,
        });
        field.append(el('label', { class: 'label', for: id }, p.name + (p.optional ? '' : ' *')));
        if (kind === 'tree') {
          const tree = el('div', {
            class: 'property-tree ad-rpc-tree',
            id,
            'data-ad-rpc-index': String(i),
            'aria-label': p.name,
          });
          field.append(tree);
          fields.append(field);
          df$.shadcn.propertyTree.configure(tree.get(0), { value: structuredClone(v[i]) });
          rpcFit(tree.get(0), v[i], 4);
          return;
        }
        let input;
        if (kind === 'enum' || kind === 'boolean') {
          input = el('select', { class: 'select', id, 'data-ad-rpc-index': String(i), 'data-size': 'sm' });
          if (p.optional) input.append(el('option', { value: '' }, '-'));
          for (const value of kind === 'enum' ? p.schema.enum : [true, false])
            input.append(el('option', { value: String(value) }, String(value)));
        } else
          input = el('input', {
            class: 'input',
            id,
            'data-ad-rpc-index': String(i),
            type: kind === 'number' ? 'number' : 'text',
            autocomplete: 'off',
            spellcheck: 'false',
            'data-size': 'sm',
            placeholder: p.type ?? '',
          });
        input.val(v[i]);
        fields.append(field.append(input));
      });
      if (changed) resetAnswer();
      writeRpcSamples();
      return box;
    };
    const rpcForm = df$('[data-ad-rpc-try]');
    const takeField = (event) => {
      const i = event.target.dataset?.adRpcIndex;
      if (!call || i === undefined || event.target.classList.contains('property-tree')) return;
      rpcValuesOf(call)[Number(i)] = event.target.value;
      writeRpcSamples();
    };
    rpcForm.on('input', takeField);
    rpcForm.on('change', takeField);
    rpcForm.on('property-tree-change', (event) => {
      const tree = event.target.closest('.property-tree');
      if (!call || !tree?.dataset.adRpcIndex) return;
      rpcValuesOf(call)[Number(tree.dataset.adRpcIndex)] = df$.shadcn.propertyTree.value(tree);
      rpcFit(tree, df$.shadcn.propertyTree.value(tree), 4);
      writeRpcSamples();
    });
    // the target: the example in the page, or a server - asked for its schema first, so a wrong URL says so at once
    const conn = df$('[data-ad-rpc-conn]');
    let checked = '';
    const checkServer = async () => {
      const t = rpcTarget();
      if (t.kind !== 'server') {
        conn.text('');
        return true;
      }
      conn.text(fmt(words().connChecking, { s: t.url }));
      try {
        const served = await RPC.served(t.url);
        const names = new Map(served.map((e) => [e.className ?? e.moduleName, e]));
        const missing = call && !names.get(call.name)?.methods?.[call.m];
        conn.text(
          missing
            ? fmt(words().connMissing, { s: t.url, m: call.name + '.' + call.m })
            : fmt(words().connOk, { s: t.url, n: served.length }),
        );
        app.setAttribute('data-rpc-server', missing ? 'missing' : 'ok');
        checked = t.url;
        return !missing;
      } catch (e) {
        conn.text(fmt(words().connFail, { s: t.url, e: e?.message ?? String(e) }));
        app.setAttribute('data-rpc-server', 'failed');
        checked = '';
        return false;
      }
    };
    df$('[data-ad-rpc-target]').on('change', () => {
      df$('[data-ad-rpc-server]').prop('hidden', rpcTarget().kind !== 'server');
      writeRpcSamples();
      checkServer();
    });
    df$('[data-ad-rpc-url]').on('change', () => {
      writeRpcSamples();
      checkServer();
    });
    rpcForm.on('reset', (event) => {
      event.preventDefault();
      if (!call) return;
      rpcValues.delete(call.name + '.' + call.m);
      // the example's data starts over too
      RPC.reset();
      const { name, m } = call;
      call = null;
      rpcMethod(
        RPC_NS.find((x) => x.name === name),
        m,
      );
    });
    rpcForm.on('submit', async (event) => {
      event.preventDefault();
      if (!call) return;
      const t = rpcTarget();
      if (t.kind === 'server' && checked !== t.url && !(await checkServer())) return;
      resetAnswer();
      df$('[data-ad-rpc-empty]').prop('hidden', true);
      const frames = df$('[data-ad-rpc-frames]');
      const answer = await RPC.call(t, call.name, call.m, rpcArgs(call).values, (value) => {
        frames.prop('hidden', false).append(el('li', {}, line(value)));
      });
      df$('[data-ad-rpc-status]')
        .attr('data-class', String(answer.status || 5)[0])
        .text(answer.status ? String(answer.status) : 'network');
      df$('[data-ad-rpc-time]').text(
        fmt(words().ms, { t: answer.ms }) + ' · ' + (t.kind === 'server' ? t.url : words().inPage),
      );
      if (answer.error) df$('[data-ad-rpc-error]').prop('hidden', false).text(answer.error);
      if ('value' in answer) {
        const tree = df$('[data-ad-rpc-result]').prop('hidden', false).get(0);
        df$.shadcn.propertyTree.configure(tree, { value: answer.value });
        rpcFit(tree, answer.value);
      }
      app.dispatchEvent(
        new CustomEvent('ad-rpc-answer', {
          detail: { status: answer.status, target: t.kind, frames: answer.frames?.length ?? 0 },
        }),
      );
    });
    df$('[data-ad-rpc-copy]').on('click', () => {
      const tab = df$('[data-ad-rpc-samples] input:checked').val();
      const key = tab === 'rcurl' ? 'curl' : tab === 'fetch' ? 'js' : 'ts';
      copy(
        rpcShownSamples[key],
        df$('[data-ad-rsample="' + key + '"]').get(0),
        df$('[data-ad-rpc-samples] .mk-code-block-status'),
      );
    });

    // each page as Markdown and JSON: the route's file under api-docs/
    const docPath = (route) =>
      route === '#/' ? 'guides/introduction' : route === '#/rpc' ? 'rpc/index' : route.slice(2);
    const docLinks = (box, route) => {
      const links = df$(box).find('[data-ad-doc-links]');
      links.html('');
      const path = DOC_FILES + docPath(route);
      links.append(el('span', {}, words().pageAs));
      links.append(
        el('a', { href: path + '.md', target: '_blank', rel: 'noopener', 'data-ad-doc-md': '' })
          .append(el('i', { 'data-lucide': 'file-text' }))
          .append(el('span', {}, words().asMarkdown)),
      );
      links.append(
        el('a', { href: path + '.json', target: '_blank', rel: 'noopener', 'data-ad-doc-json': '' })
          .append(el('i', { 'data-lucide': 'braces' }))
          .append(el('span', {}, words().asJson)),
      );
    };

    // the try-it form: typing updates the samples, Send asks the sandbox, Reset brings the examples back
    const form = df$('[data-ad-try]');
    form.on('input', (event) => {
      if (!current || !event.target.name) return;
      valuesOf(current)[event.target.name] = event.target.value.trim();
      writeSamples();
    });
    form.on('change', (event) => {
      if (!current || !event.target.name) return;
      valuesOf(current)[event.target.name] = event.target.value.trim();
      writeSamples();
    });
    form.on('reset', (event) => {
      event.preventDefault();
      values.delete(current.resource + '/' + current.id);
      endpoint(current);
    });
    form.on('submit', (event) => {
      event.preventDefault();
      if (!current) return;
      const answer = sandbox(current, valuesOf(current));
      const json = JSON.stringify(answer.body, null, 2);
      // a sandbox answer takes a believable, stable time: the size of what it sent
      const time = 18 + (json.length % 47);
      df$('[data-ad-res-status]').attr('data-class', String(answer.status)[0]).text(String(answer.status));
      df$('[data-ad-res-time]').text(fmt(words().ms, { t: time }) + ' · X-RateLimit-Remaining: ' + remaining);
      df$('[data-ad-res-empty]').prop('hidden', true);
      const out = df$('[data-ad-res-body]').prop('hidden', false).get(0);
      write(out, json);
      paint();
      app.dispatchEvent(new CustomEvent('ad-response', { detail: { status: answer.status } }));
    });

    // -- copying: the sample shown, or the endpoint's URL (the Clipboard API; where a frame may not write to the
    // clipboard, the text is selected)
    const copy = (text, node, status) => {
      const select = () => {
        getSelection().selectAllChildren(node);
        if (status) status.text(words().copyHint);
      };
      if (!navigator.clipboard) return select();
      navigator.clipboard.writeText(text).then(() => {
        if (status) status.text(words().copied);
        df$.shadcn.toast.show({ title: words().copied, duration: 1800 });
      }, select);
    };
    df$('[data-ad-copy]').on('click', () => {
      const tab = df$('[data-ad-samples] input:checked').val();
      const code = df$('[data-ad-sample="' + tab + '"]').get(0);
      // the text as generated: painted lines are block spans without newlines between them
      copy(shownSamples[tab], code, df$('[data-ad-samples] .mk-code-block-status'));
    });
    df$('[data-ad-copy-path]').on('click', () => {
      const code = df$('[data-ad-ep-path]').get(0);
      copy(current.method + ' ' + code.textContent, code);
    });

    // -- the API key: the dialog saves or removes it; the samples and the sandbox read it
    const keyDialog = df$('#ad-key').get(0);
    df$('[data-ad-authorize]').on('click', () => keyDialog.showModal());
    df$(keyDialog).on('close', () => {
      if (keyDialog.returnValue === 'save') apiKey = df$('#ad-key-input').val().trim();
      if (keyDialog.returnValue === 'clear') apiKey = '';
      keyDialog.returnValue = '';
      df$('[data-ad-key-on]').prop('hidden', !apiKey);
      df$('[data-ad-key-off]').prop('hidden', !!apiKey);
      writeSamples();
    });

    // -- the version: v3 shows its sunset note and the samples call /v3
    df$('[data-ad-version]').on('change', (event) => {
      version = event.target.value;
      df$('[data-ad-v3]').prop('hidden', version !== 'v3');
      writeSamples();
    });

    // -- dark mode: the Swap sets <html class="dark"> and follows it when something else sets it
    const mode = df$('[data-ad-mode]');
    const root = document.documentElement;
    mode.prop('checked', root.classList.contains('dark'));
    mode.on('change', () => {
      root.classList.toggle('dark', mode.prop('checked'));
      document.dispatchEvent(new CustomEvent('defuss-theme-change'));
    });
    new MutationObserver(() => mode.prop('checked', root.classList.contains('dark'))).observe(root, {
      attributes: true,
      attributeFilter: ['class'],
    });

    // -- the menu: below 48rem the navigation is a drawer; a pick closes it
    const menu = df$('[data-ad-menu]');
    const openMenu = (open) => {
      app.toggleAttribute('data-menu-open', open);
      menu.attr('aria-expanded', String(open));
    };
    menu.on('click', () => openMenu(!app.hasAttribute('data-menu-open')));
    nav.on('click', (event) => {
      if (event.target.closest('a')) openMenu(false);
    });

    // -- the search: two BM25 indexes (English and German analyzers) over every guide, resource, endpoint and
    // parameter; the palette asks the one of the language shown
    const documents = (l) => {
      const pick = (item) => item[l] ?? item.en;
      return ORDER.map((o, i) => {
        const t = pick(o.item);
        if (o.kind === 'guide')
          return { id: String(i), fields: { title: t.title, path: '', body: t.lead + ' ' + t.body.join(' ') } };
        if (o.kind === 'resource')
          return {
            id: String(i),
            fields: {
              title: t.title,
              path: o.item.object,
              body: t.lead + ' ' + o.item.fields.map((f) => f[0] + ' ' + (l === 'de' ? f[3] : f[2])).join(' '),
            },
          };
        if (o.kind === 'rpc')
          return { id: String(i), fields: { title: t.title, path: 'defuss-rpc', body: DATA.words[l].rpcLead } };
        if (o.kind === 'namespace')
          return {
            id: String(i),
            fields: {
              title: t.title,
              path: o.name,
              body: (o.ns.description ?? '') + ' ' + Object.keys(o.ns.methods).join(' '),
            },
          };
        if (o.kind === 'method')
          return {
            id: String(i),
            fields: {
              title: t.title + ' ' + o.m,
              path: o.item.path,
              body:
                (o.doc.description ?? '') +
                ' ' +
                (o.doc.params ?? []).map((p) => p.name + ' ' + (p.description ?? '')).join(' ') +
                ' ' +
                (o.doc.returns?.description ?? ''),
            },
          };
        return {
          id: String(i),
          fields: {
            title: t.title,
            path: o.item.method + ' ' + o.item.path,
            body: t.lead + ' ' + o.item.params.map((p) => p.name + ' ' + (p[l] ?? p.en)).join(' '),
          },
        };
      });
    };
    let searches = null;
    // search by meaning: the state the palette's status line names, on the app root for the tests too
    const meaning = () => {
      if (!searches) return 'off';
      const states = Object.values(searches).map((x) => x.state);
      return states.includes('failed') ? 'failed' : states.every((x) => x === 'semantic') ? 'semantic' : 'loading';
    };
    SEARCH.then(([lexical, en, de, strategies]) => {
      searches = {};
      for (const [l, analyzer] of [
        ['en', en.default],
        ['de', de.default],
      ]) {
        const index = new lexical.LexicalSearch({
          analyzer,
          fields: { title: { weight: 3 }, path: { weight: 2 }, body: {} },
        });
        const docs = documents(l);
        index.addAll(docs);
        // the tiny strategy: ColBERT encodes this language's documents once and scans their tokens for each query
        const texts = docs.map((d) => ({
          id: d.id,
          text: (d.fields.title + '. ' + d.fields.path + ' ' + d.fields.body).trim(),
        }));
        searches[l] = progressiveSearch(strategies, index, {
          lexical: { search: { prefix: true, fuzzy: true } },
          semantic: async (built) =>
            strategies.createLexicalSemanticTinySearch(built, {
              documents: texts,
              colbert: await loadColbert(),
              lexical: { search: { prefix: true, fuzzy: true } },
            }),
        });
        searches[l].subscribe(() => {
          app.setAttribute('data-semantic', meaning());
          if (df$('#ad-find').get(0).open) find();
        });
      }
      app.setAttribute('data-search', 'ready');
      // the model loads in the background once the page is idle - not under the data saver
      if (navigator.connection?.saveData) app.setAttribute('data-semantic', 'saver');
      else
        (globalThis.requestIdleCallback ?? ((fn) => setTimeout(fn, 200)))(() => {
          for (const x of Object.values(searches)) x.load().catch(() => {});
        });
      if (df$('#ad-find').get(0).open) find();
    }).catch(() => app.setAttribute('data-search', 'plain'));

    const query = df$('[data-ad-query]');
    const hits = df$('[data-ad-hits]');
    const status = df$('[data-ad-find-status]');
    const hit = (o) => {
      const item = el('a', { class: 'command-item', href: o.href, 'data-router-link': '' });
      if (o.item.method) item.append(method(o.item.method));
      else item.append(el('i', { 'data-lucide': o.kind === 'guide' || o.kind === 'rpc' ? 'book-open' : 'box' }));
      item.append(el('span', {}, tr(o.item).title));
      if (o.item.path) item.append(el('span', { class: 'ad-hit-path' }, o.item.path));
      return item;
    };
    const group = (heading, list) => {
      if (!list.length) return;
      const box = el('div', { class: 'command-group' });
      if (heading) box.append(el('p', { class: 'command-group-heading' }, heading));
      for (const o of list) box.append(hit(o));
      hits.append(box);
    };
    let asked = 0;
    const find = async () => {
      const text = query.val().trim();
      const ask = ++asked;
      let list;
      if (!text) {
        // no query: the guides and the resources, to browse
        list = ORDER.filter((o) => o.kind !== 'endpoint');
        const state = app.getAttribute('data-semantic');
        status.text(!searches ? words().loading : (words()['meaning-' + state] ?? words()['meaning-loading']));
      } else if (searches) {
        const t0 = performance.now();
        const found = await searches[lang()].searchWithStats({ text }, { limit: 12 });
        if (ask !== asked) return;
        list = found.hits.map((h) => ORDER[Number(h.id)]);
        const line = found.source === 'semantic' ? words().resultsMeaning : words().results;
        status.text(fmt(line, { n: list.length, t: (performance.now() - t0).toFixed(1) }));
      } else {
        const needle = text.toLowerCase();
        list = ORDER.filter((o) => (tr(o.item).title + ' ' + (o.item.path ?? '')).toLowerCase().includes(needle));
        status.text(words().plain);
      }
      hits.html('');
      if (text) group(null, list);
      else {
        group(
          words().guidesGroup,
          list.filter((o) => o.kind === 'guide'),
        );
        group(
          words().resourcesGroup,
          list.filter((o) => o.kind === 'resource'),
        );
      }
      icons();
    };
    query.on('input', find);
    df$('#ad-find').on('toggle', find);
    df$('[data-command-trigger="ad-find"]').on('click', () => {
      query.val('');
      find();
    });

    // -- routing: a guide, a resource or an endpoint per address; anything unknown shows the introduction
    const routes = [
      { id: 'home', path: '/' },
      { id: 'guide', path: '/guides/:guide' },
      { id: 'resource', path: '/ref/:resource' },
      { id: 'endpoint', path: '/ref/:resource/:op' },
      { id: 'rpc', path: '/rpc' },
      { id: 'namespace', path: '/rpc/:ns' },
      { id: 'method', path: '/rpc/:ns/:method' },
      { id: 'missing', path: '*' },
    ];
    let shownPath = null;
    const show = (to) => {
      shown = to;
      const p = to.params ?? {};
      const g = to.routeId === 'guide' ? DATA.guides.find((x) => x.id === p.guide) : null;
      const r = to.routeId === 'resource' ? resourceOf(p.resource) : null;
      const e = to.routeId === 'endpoint' ? endpointOf(p.resource, p.op) : null;
      const rns =
        RPC && (to.routeId === 'namespace' || to.routeId === 'method') ? RPC_NS.find((x) => x.name === p.ns) : null;
      const rm = rns && to.routeId === 'method' && rns.ns.methods[p.method] ? p.method : null;
      let box;
      let target;
      if (rm) {
        box = rpcMethod(rns, rm);
        target = href.method(rns.name, rm);
      } else if (rns) {
        box = rpcNamespace(rns);
        target = href.namespace(rns.name);
      } else if (RPC && to.routeId === 'rpc') {
        box = rpcNamespace(null);
        target = href.rpc();
      } else if (e) {
        box = endpoint(e);
        target = href.endpoint(e);
      } else if (r) {
        box = resource(r);
        target = href.resource(r);
      } else {
        const item = g ?? DATA.guides[0];
        box = guide(item);
        target = href.guide(item);
      }
      df$('[data-ad-view]').each((_i, section) => {
        section.hidden = section !== box;
      });
      docLinks(box, target);
      pager(
        box,
        ORDER.findIndex((o) => o.href === target),
      );
      markCurrent(target);
      icons();
      paint();
      // a new page opens at its start - the first view stays where the reader is
      if (shownPath !== null && shownPath !== to.path)
        df$('[data-ad-main]').get(0).scrollTo({ top: 0, behavior: 'instant' });
      shownPath = to.path;
      app.setAttribute('data-route', target);
    };
    // a language change: the navigation, the page shown and the palette come in the new language
    app.addEventListener('defuss-i18n:change', () => {
      writeNav();
      if (shown) show(shown);
      if (df$('#ad-find').get(0).open) find();
    });
    writeNav();
    find();
    const router = createRouter({
      mode: 'hash',
      routes,
      scroll: 'manual',
      prepare: ({ to }) => ({ commit: () => show(to) }),
    });
    router.attachLinks(app);
    if ((await router.start()).status === 'rejected') {
      // no address the router may own - a docs preview is an about:srcdoc frame: the same routes match its hash
      const preview = createRouter({ mode: 'hash', routes, baseUrl: 'https://preview.invalid/' });
      const follow = () => show(preview.resolve(location.hash.startsWith('#/') ? location.hash : '#/'));
      addEventListener('hashchange', follow);
      follow();
    }
  });
</script>
```

<h2 id="how-it-works" class="h2-display">How it works</h2>

<DocText>A page, not a component: it composes the library and keeps its own glue small.</DocText>

<ul class="text-sm" style="display:grid;gap:0.5rem;max-width:46rem;padding-inline-start:1.25rem">
  <li><strong>One data block</strong> - the guides, the resources with their object fields and every endpoint with its parameters and status codes sit in one JSON block, in English and German. The navigation, the pages, the pager, the samples and the search index are all written from it, so a new endpoint is one entry.</li>
  <li><strong>Routing</strong> - <a href="https://dom-router.defuss.org" target="_blank" rel="noopener">defuss-dom-router</a> in hash mode: the introduction (<code>#/</code>), a guide (<code>#/guides/errors</code>), a resource (<code>#/ref/tasks</code>) and an endpoint (<code>#/ref/tasks/create</code>). The current link, the breadcrumb and the pager follow the address; a new page opens at its start. See <DocLink href="routing.html">Client-side Routing</DocLink>.</li>
  <li><strong>Translation</strong> - <a href="https://i18n.defuss.org" target="_blank" rel="noopener">defuss-i18n</a> translates the frame (the header, the headings, the dialogs, the palette); on its change event the script writes the navigation and the page shown again from the data block's other language. See <DocLink href="translation.html">Translation</DocLink>.</li>
  <li><strong>Search</strong> - <a href="https://search.defuss.org" target="_blank" rel="noopener">defuss-search</a> over defuss-lexicalsearch, in two steps. Keywords work at once: two BM25 indexes (an English and a German analyzer; the title weighs 3, the method and path 2, the text and parameters 1) with prefix and fuzzy matching on the last word. Meanwhile the page loads the Winzling-reranker model in the background (MoEdernColBERT 1.5M, 2.28 MB as Brotli from its pinned Hugging Face revision, checked against its SHA-256; ONNX Runtime's WASM build, 2.3 MB, comes from jsDelivr) and switches to defuss-search's tiny strategy: ColBERT encodes each language's documents once, and a query is BM25 fused with a scan over their tokens, so "how do I log in", which no keyword of the reference matches, finds the Authentication guide. The switch is defuss-search's progressive search (<code>createProgressiveSearch</code>, copied into the page until its release): a query asked before the model is there runs on BM25, a model that never loads leaves BM25 answering. The full-screen page keeps the decoded model in the Cache API, so a later visit downloads nothing; the data saver keeps the search on keywords. The <DocLink href="command.html">Command</DocLink> palette (<code>data-filter="none"</code>) shows the ranked hits, how long they took and which search answered. Until the modules arrive the palette compares names.</li>
  <li><strong>Try it</strong> - a form per endpoint, its fields made from the parameters (an enum becomes a <DocLink href="select.html">Select</DocLink>). Every keystroke writes the curl, JavaScript and Python samples again (the <DocLink href="code-block.html">Code Example</DocLink> block's tabs and copy button); Send asks a sandbox in the page that answers like the API - 401 without a key, 400 naming the missing parameter, 404, cursors and a counting rate limit. Creating, changing and deleting change what the next request sees.</li>
  <li><strong>Authorize and versions</strong> - a <DocLink href="dialog.html">Dialog</DocLink> keeps the test key in the page; the version Select switches the samples to <code>/v3</code> and shows its sunset <DocLink href="alert.html">Alert</DocLink>. A <DocLink href="swap.html">Swap</DocLink> switches dark mode; Shiki paints the code panels.</li>
  <li><strong>defuss-rpc reference</strong> - <code>src/documentation/runtime/api-docs/api.ts</code> is the same Acme workspace as a <a href="https://github.com/kyr0/defuss-rpc" target="_blank" rel="noopener">defuss-rpc</a> API (a class of tasks, modules of members, a stream of activity and figures with a <code>Map</code> and a <code>Date</code>), documented with JSDoc. <code>bunx defuss-rpc schema "src/documentation/runtime/api-docs/*.ts" --out rpc.docs.json</code> reads it - starting at <code>createRpcServer()</code> in <code>server.ts</code>, so the unregistered <code>resetExample()</code> stays out - and writes each method's description, parameters, return and yield types with their JSON Schemas. The navigation, the pages (<code>#/rpc</code>, <code>#/rpc/Tasks</code>, <code>#/rpc/Tasks/create</code>), the signatures and the samples (the typed client, curl, fetch) are written from that file.</li>
  <li><strong>Call it</strong> - one field per parameter, made from its JSON Schema (a <DocLink href="select.html">Select</DocLink> for an enum or a boolean, a number or text field, a <DocLink href="property-tree.html">Property Tree</DocLink> for an object); a date string becomes a <code>Date</code> and a list a <code>Set</code> where the schema says so. The call goes to the same <code>api.ts</code> bundled into the page (<code>js/api-docs/client.js</code>, the arguments and the answer passed through DSON as over the wire), or to a defuss-rpc server: the form asks it for <code>/rpc/schema</code> first and says when it does not answer or lacks the method. A stream shows every value as it arrives, the answer opens in a Property Tree. <code>bun src/documentation/runtime/api-docs/server.ts</code> runs the example as a real server (rpcRoute in <code>Bun.serve</code>, CORS for the page's origin); the e2e test starts it and calls it.</li>
  <li><strong>Markdown and JSON</strong> - the app writes its pages in the browser, which a crawler or an agent that runs no JavaScript never sees. The docs build writes every page of both references once more as <code>api-docs/&lt;page&gt;.md</code> and <code>.json</code> (<code>runtime/api-docs/pages.ts</code>), with <code>index.md</code>, <code>index.json</code> and <code>llms.txt</code>; each page links its two files under its title.</li>
  <li><strong>Built on Docs & Help</strong> - the <DocLink href="docs-navigation.html">Docs Navigation</DocLink> and <DocLink href="docs-content.html">Docs Content</DocLink> blocks of the <DocLink href="website-docs-help.html">Docs & Help</DocLink> template, in the system's tokens: a theme from the Theme Designer restyles it. Where the page is narrower than 56rem the code goes under it, below 48rem the navigation becomes a drawer.</li>
  <li><strong>Full screen</strong> - <DocLink href="app-api-docs.html">app-api-docs.html</DocLink> is generated from this page's example at build time, on its own bundle.</li>
</ul>

</DocPage>
