ó
    uÕgjy	  ã                  ó–   • S r SSKJr  SSKJrJr  SSKJr  SSKJ	r	  SSK
Jr  SSKJr  \\\\\4   r\\\\\4   rSS jrSS	 jrSS
 jrg)a  Boxes, in the three frames the scan workflow has to speak.

A scan returns a box as `{left, top, right, bottom}`, each 0..1 with the page's
top-left as origin. The page it scanned was the real page, so that box is already
a source coordinate and needs no mapping back.

The parse states a box in PDF points, usually with the page's bottom-left as
origin. The table pipeline states a box in PDF points bottom-left too, and states
a region normalized top-left.

These convert between them so no caller writes the arithmetic twice.
é    )Úannotations)ÚOptionalÚTuple)ÚCoordOrigin)ÚDocItem)Úcamelot_bbox_to_norm)ÚBoxc                ó²   • U (       d  g U S   U S   U S   U S   4u  pp4[        X5      [        X$5      [        X5      [        X$5      4$ ! [          a     gf = f)zOA returned box (0..1, top-left origin, keyed left/top/right/bottom) as a tuple.NÚleftÚtopÚrightÚbottom)ÚKeyErrorÚminÚmax)Úboxr   r   r   r   s        Ú9/home/mande/repo/quber/src/quber/core/figures/geometry.pyÚnorm_boxr      si   € æØðØ#& v¡;°°E±
¸CÀ¹LÈ#ÈhÉ-Ð#WÑ ˆ�5ô �Óœc #Ó.´°DÓ0@Ä#ÀcÓBRÐSÐSøô ó Ùðús   ŠA	 Á	
AÁAc                óV   • [        U 5      nUc  gUu  pEpgXA-  SU-
  U-  Xa-  SU-
  U-  4$ )zÆA returned box as PDF points with the page's bottom-left as origin.

That is the frame the table pipeline measures in, so a cell box read off a
scan lands in the same frame as one Camelot measured.
Ng      ð?)r   )r   ÚwidthÚheightÚ
normalizedÚx1Úy1Úx2Úy2s           r   Ú	point_boxr   *   sD   € ô ˜#“€JØÑØØ�N€BˆBØ‰J˜˜r™ VÑ+¨R©Z¸#À¹(ÀfÑ9LÐMÐMó    c                óx  • U R                   (       d  gU R                   S   R                  nUR                  [        R                  :X  a:  UR
                  U-  UR                  U-  UR                  U-  UR                  U-  4$ [        UR
                  UR                  UR                  UR                  4X5      $ )z=An element's provenance box in the normalized top-left frame.Nr   )
ÚprovÚbboxÚcoord_originr   ÚTOPLEFTÚlÚtÚrÚbr   )Úitemr   r   r!   s       r   Úprov_boxr)   7   sˆ   € à�9�9ØØ�9‰9�Q‰<×Ñ€DØ×ÑœK×/Ñ/Ó/Ø—‘˜‘ §¡¨¡°·±¸%±ÀÇÁÈ&ÁÐQÐQÜ §¡¨¯©°·±¸¿¹Ð @À%ÓPÐPr   N)r   úOptional[Box]ÚreturnúOptional[NormBox])r   r*   r   Úfloatr   r-   r+   zOptional[PointBox])r(   r   r   r-   r   r-   r+   r,   )Ú__doc__Ú
__future__r   Útypingr   r   Údocling_core.types.doc.baser   Údocling_core.types.doc.documentr   Ú5quber.core.extractors.camelot.correspondence.geometryr   Úquber.core.figures.modelsr	   r-   ÚNormBoxÚPointBoxr   r   r)   © r   r   Ú<module>r8      sZ   ðñõ #ç "å 3Ý 3å VÝ )ð ��u˜e UÐ*Ñ
+€ð �˜˜u eÐ+Ñ,€ôTô
NõQr   