"""Full-document table extraction with ONLY the page-furniture (running header) exclusion changed in the locator prompt. Scratch harness; production untouched."""
import json, time
from pathlib import Path
from quber.agents import grid_locator as gl
S=Path('/tmp/claude-1000/-home-mande-repo-quber/bc2f817a-5c6c-4515-9621-2302b82f7f68/scratchpad')
BASE=gl.build_prompt(gl.DEFAULT_ROWS, gl.DEFAULT_COLS)
B="Exclude page furniture (running header timestamp, page number, document URL)"
assert B in BASE
HDR=("Exclude page furniture (running header timestamp, page number, document URL,\n"
     "and the running header block repeated at the top of every page: the company\n"
     "name, the statement title and a page-level units line). A region never\n"
     "extends up into that header block, even when it looks like a title")
gl.build_prompt=lambda r,c: BASE.replace(B, HDR)
from quber.core.extractors.set_of_mark import SetOfMarkExtractor
from quber.agents.llm_client import get_llm_client
ext=SetOfMarkExtractor(dpi=200, llm=get_llm_client("api"))
t0=time.time()
tables=ext.extract_tables_sync(Path('data/playground/998c8ed06c0be22d.pdf'))
json.dump([t.model_dump(mode='json') for t in tables], open(S/'furniture-full.tables.json','w'))
print(f"done: {len(tables)} tables in {time.time()-t0:.0f}s")
