"""The dpt-3 track: digest a v2 scan response, graft it, resolve its footnotes.

The figure workflow's dpt-2 path reads a response as a flat chunks list. The
dpt-3 models return a different shape — one long text and a tree pointing into
it — and this package is the code that reads it. The orchestrator selects the
track by model name; the dpt-2 path is untouched.

Four modules, in the order the orchestrator uses them:

- `digest` turns one page's raw response into the track's records and projects
  them to the `PageScan` every downstream consumer already reads. What the
  projection leaves out — figure kind, structured value tables, per-value
  provenance — stays in the `models` records.
- `graft` writes the records into the document. Its figure graft is the shared
  `quber.core.figures.graft.graft_figures`, called so that footnote- and
  caption-labelled text under a read picture stays. It also inserts captured
  tables over regions the parse holds nothing for (`insert_orphan_tables`) and
  flags scanned tables that found no home (`unhomed_tables`).
- `footnotes` resolves each figure's markers against two sources — the
  correction agent's image read and the page text the graft preserved —
  inserts the resolved notes after the picture, and attaches each note to the
  value its label matches.
- `blocks` groups the parse's floating text by the scan's block partition, so
  a stat panel's label and value travel as one unit instead of as unrelated
  records.

Nomination upstream and the consumers of projected records — table capture, the
correction sweep, value reconciliation — are shared with the dpt-2 path. The
track differs in two places. The page list gains every page whose dpt-3
response is already stored in a local output directory, and table capture runs with
`orphans=True`, so it also captures grids over regions the parse holds nothing
for.
"""

from quber.core.figures.dpt3.blocks import SCAN_BLOCK, group_scanned_text
from quber.core.figures.dpt3.digest import (
    UnrecognizedResponse,
    digest_page,
    project_scan,
    response_generation,
)
from quber.core.figures.dpt3.footnotes import resolve_figure_footnotes
from quber.core.figures.dpt3.graft import graft_figures, insert_orphan_tables, unhomed_tables
from quber.core.figures.dpt3.models import PageDigest

__all__ = [
    "PageDigest",
    "SCAN_BLOCK",
    "UnrecognizedResponse",
    "digest_page",
    "graft_figures",
    "group_scanned_text",
    "insert_orphan_tables",
    "project_scan",
    "resolve_figure_footnotes",
    "response_generation",
    "unhomed_tables",
]
