
    :Qg^                       d Z ddlmZ ddlZddlmZ ddlmZ ddlmZm	Z	 ddl
mZmZ ddlmZmZ  G d	 d
ee      Z G d de      ZddZ G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d  d!e      Z G d" d#e      Z G d$ d%e      Z G d& d'e      Z  G d( d)e      Z! G d* d+e      Z" G d, d-e      Z# G d. d/e      Z$ G d0 d1e      Z% G d2 d3e      Z& G d4 d5e      Z' G d6 d7e      Z( G d8 d9e      Z) G d: d;e      Z* G d< d=e      Z+ G d> d?e      Z, G d@ dAe      Z- G dB dCe      Z. G dD dEe      Z/ G dF dGe      Z0 G dH dIe      Z1 G dJ dKe      Z2 G dL dMe      Z3 G dN dOe      Z4 G dP dQe      Z5 G dR dSe      Z6 G dT dUe      Z7 G dV dWe      Z8 G dX dYe      Z9 G dZ d[e      Z: G d\ d]e      Z; G d^ d_e      Z< G d` dae      Z= G db dce      Z> G dd dee      Z? G df dge      Z@ G dh die      ZA G dj dke      ZB G dl dme      ZC G dn doe      ZD G dp dqe      ZE G dr dse      ZF G dt due      ZG G dv dwe      ZH G dx dye      ZI G dz d{e      ZJ G d| d}e      ZK G d~ de      ZL G d de      ZM G d de      ZN G d de      ZO G d de      ZP G d de      ZQ G d de      ZR G d de      ZS G d de      ZT G d de      ZU G d de      ZV G d de      ZW G d de      ZX G d de      ZY G d de      ZZy)af  
This file contains all classes allowed in the ontology V2.
This Type is used as intermediate representation between HTML
and Unstructured Elements.
All the processing could be done without the intermediate representation,
but it simplifies the process.
It needs to be decide whether we keep it or not.

The classes are represented as pydantic models to mimic Unstructured Elements V1 solutions.
However it results in lots of code that could be strongly simplified.

TODO (Pluto): OntologyElement is the only needed class. It could contains data about
 allowed html tags, css classes and descriptions as metadata.
    )annotationsN)copy)Enum)ListOptional)BeautifulSoupTag)	BaseModelFieldc                  D    e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZy)ElementTypeEnumLayoutTextr   TableMediaCodeMathematical	ReferenceMetadata
NavigationForm
AnnotationzSpecialized TextzDocument-SpecificN)__name__
__module____qualname__layouttextlisttablemediacodemathematical	referencemetadata
navigationform
annotationspecialized_textdocument_specific     \/var/www/html/answerous/venv/lib/python3.12/site-packages/unstructured/documents/ontology.pyr   r      sJ    FDDEED!LIHJDJ)+r+   r   c                  v    e Zd ZU  edd      Zded<    ed d      Zded	<    ed
 d      Zded<    edd      Zded<    ee	d      Z
ded<    edd      Zded<    edd      Zded<    ei d      Zded<    fdZed&d       Zd'd&dZd(d&d Zd)d!Zd*d"Zd+d#Zed,d$       Zed-d%       Z xZS ).OntologyElement zText content of the element)descriptionzOptional[str]r   c                      yNr/   r*   r*   r+   r,   <lambda>zOntologyElement.<lambda>/       r+   z%CSS class associated with the element)default_factoryr0   css_class_namec                      yr2   r*   r*   r+   r,   r3   zOntologyElement.<lambda>2   r4   r+   z)HTML Tag name associated with the elementhtml_tag_name.zType of the elementr   elementTypezList of child elementszList['OntologyElement']childrenzDescription of the elementstrr0   z%HTML tags associated with the element	List[str]allowed_tagsz*Optional HTML attributes or CSS propertieszOptional[dict]additional_attributesc                   t        |   di | | j                  dk(  r| j                  j                  | _        | j
                  dk(  r| j                  d   | _        d| j                  vr| j                         | j                  d<   y y )Nr/   r   idr*   )	super__init__r6   	__class__r   r8   r=   r>   generate_unique_id)selfkwargsrC   s     r,   rB   zOntologyElement.__init__@   s    "6""$"&.."9"9D#!%!2!21!5Dt111/3/F/F/HD&&t, 2r+   c                 \    t        t        j                               j                  dd      S )N-r/   )r;   uuiduuid4replacer*   r+   r,   rD   z"OntologyElement.generate_unique_idI   s     4::< ((b11r+   c                "   t        | j                        }|j                  dd        | j                  |      }| j                  rd| j                   dnd}| d| j                         }| j                  |      }| j                  ||      }|S )Nclasszclass=""r/    )r   r>   pop_construct_attribute_stringr6   strip_generate_children_html_generate_final_html)rE   add_childrenadditional_attrsattr_str
class_attrcombined_attr_strchildren_htmlresult_htmls           r,   to_htmlzOntologyElement.to_htmlM   s     : :;Wd+334DE9=9L9Lwt22315RT
)l!H:6<<>44\B//0A=Qr+   c                ~   | j                   r)r'dj                  fd| j                   D              }|S t        | j                         d      j	                         j                         }r?| j                  dk(  r0d| j                  v r"|d| j                  j                  dd       z  }|j                         S )aK  
        Returns the text representation of the element.

        Args:
            add_children: If True, the text of the children will be included.
                            Otherwise, element is represented as single self-closing tag.
            add_img_alt_text: If True, the alt text of the image will be included.
        rO   c              3  ^   K   | ]$  }|j                        j                          & y wN)to_textrR   ).0childrU   add_img_alt_texts     r,   	<genexpr>z*OntologyElement.to_text.<locals>.<genexpr>f   s+      %JOl,<=CCE%s   *-html.parserimgaltr/   )	r:   joinr   r\   get_textrR   r8   r>   get)rE   rU   rc   children_textr   s    ``  r,   r`   zOntologyElement.to_text\   s     ==\HH %SWS`S`% M ! T\\^];DDFLLN 2 2e ;IcIc@ca2266ubABCCDzz|r+   c                N    dj                  d |j                         D              S )NrO   c              3  <   K   | ]  \  }}|r| d | dn|   yw)z="rN   Nr*   )ra   keyvalues      r,   rd   z>OntologyElement._construct_attribute_string.<locals>.<genexpr>s   s/      
:D#u%se2eWAu5
   )rh   items)rE   
attributess     r,   rQ   z+OntologyElement._construct_attribute_stringr   s)    xx 
HRHXHXHZ
 
 	
r+   c                d    |r| j                   sydj                  d | j                   D              S )Nr/   c              3  <   K   | ]  }|j                           y wr_   )r\   )ra   rb   s     r,   rd   z:OntologyElement._generate_children_html.<locals>.<genexpr>z   s     B5u}}Brp   )r:   rh   )rE   rU   s     r,   rS   z'OntologyElement._generate_children_htmlw   s'    4==wwBDMMBBBr+   c                    | j                   xs d}|s|r&d| j                   d| d| d| d| j                   dS d| j                   d| dS )Nr/   <rO   >z</z />)r   r8   )rE   rW   rZ   r   s       r,   rT   z$OntologyElement._generate_final_html|   sf    yyB=t))*!H:QtfAm_BtOaOaNbbcddt))*!H:S99r+   c                :    | j                   j                  dd       S )Nr@   )r>   rj   rE   s    r,   r@   zOntologyElement.id   s    ))--dD99r+   c                    d| j                   v r%	 t        | j                   j                  d            S y # t        $ r Y y w xY w)Nzdata-page-number)r>   intrj   
ValueErrorry   s    r,   page_numberzOntologyElement.page_number   sK    !;!;;45599:LMNN   s   #5 	A Areturnr;   TTT)rr   dictr   r;   )rU   boolr   r;   )rW   r;   rZ   r;   r   r;   )r   z
str | None)r   z
int | None)r   r   r   r   r   __annotations__r6   r8   r9   r   r:   r0   r=   r>   rB   staticmethodrD   r\   r`   rQ   rS   rT   propertyr@   r}   __classcell__rC   s   @r,   r.   r.   ,   s   0MND-N$)"0W%NM  $)"0[$M=  $):O#PKP(-*B)H%  S.JKKK#C5\]L)],1
D-> I 2 2,

C
: : :  r+   r.   c                   | j                  d      D ]x  }|j                  dk7  r8|j                  j                  dd        |j                  j                  dd        |j                  dv sYdj	                  |j
                        |_        z | S )NTr   rM   r@   )tdthrO   )find_allnameattrsrP   rh   stripped_stringsstring)souptags     r,   remove_ids_and_class_from_tabler      ss    }}T" 888wIIMM'4(IIMM$%88|##"6"67CJ8 Kr+   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)DocumentzRoot element of the documentTfrozenr;   r0   r   r9   bodyr<   r=   N
r   r   r   r   r0   r   r   r   r9   r=   r*   r+   r,   r   r      s>    ;DIKI#()?)?#MKM#VHT:L):r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)Sectionz,A distinct part or subdivision of a documentTr   r;   r0   r   r9   sectionr<   r=   Nr   r*   r+   r,   r   r      s?    KTXYKY#()?)?#MKM#YK=L)=r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)Pagez&A single side of a paper in a documentTr   r;   r0   r   r9   divr<   r=   Nr   r*   r+   r,   r   r      s>    EdSKS#()?)?#MKM#UGD9L)9r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)ColumnzA vertical section of a pageTr   r;   r0   r   r9   r   r<   r=   Nr   r*   r+   r,   r   r      s>    ;DIKI#()?)?#MKM#UGD9L)9r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)	Paragraphz-A self-contained unit of discourse in writingTr   r;   r0   r   r9   pr<   r=   N
r   r   r   r   r0   r   r   r   r9   r=   r*   r+   r,   r   r      s?    LUYZKZ#()=)=d#KKK#SE$7L)7r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)HeaderzThe top section of a pageTr   r;   r0   r   r9   headerr<   r=   Nr   r*   r+   r,   r   r      s>    8FKF#()?)?#MKM#XJt<L)<r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)FooterzThe bottom section of a pageTr   r;   r0   r   r9   footerr<   r=   Nr   r*   r+   r,   r   r      s>    ;DIKI#()?)?#MKM#XJt<L)<r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)SidebarzA side section of a pageTr   r;   r0   r   r9   asider<   r=   Nr   r*   r+   r,   r   r      s>    7EKE#()?)?#MKM#WId;L);r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)	PageBreakzA break between pagesTr   r;   r0   r   r9   hrr<   r=   Nr   r*   r+   r,   r   r      s>    4TBKB#()?)?#MKM#TF48L)8r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)Titlez%Main heading of a document or sectionTr   r;   r0   r   r9   h1r<   r=   Nr   r*   r+   r,   r   r      >    DTRKR#()=)=d#KKK#TF48L)8r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)Subtitlez(Secondary title of a document or sectionTr   r;   r0   r   r9   h2r<   r=   Nr   r*   r+   r,   r   r      s?    GPTUKU#()=)=d#KKK#TF48L)8r+   r   c                      e Zd ZU  edd      Zded<    eej                  d      Zded<    eg dd      Z	d	ed
<   y)HeadingzSection headings (levels 1-6)Tr   r;   r0   r   r9   )r   r   h3h4h5h6r<   r=   Nr   r*   r+   r,   r   r      s>    <TJKJ#()=)=d#KKK#$HQUVL)Vr+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)NarrativeTextzMain content textTr   r;   r0   r   r9   r   r<   r=   Nr   r*   r+   r,   r   r      s>    0>K>#()=)=d#KKK#SE$7L)7r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)Quotez(A repetition of someone else's statementTr   r;   r0   r   r9   
blockquoter<   r=   Nr   r*   r+   r,   r   r      s?    GPTUKU#()=)=d#KKK#\N4@L)@r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)FootnotezA note at the bottom of a pageTr   r;   r0   r   r9   r   r<   r=   Nr   r*   r+   r,   r   r      s>    =dKKK#()=)=d#KKK#UGD9L)9r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)Captionz!Text describing a figure or imageTr   r;   r0   r   r9   
figcaptionr<   r=   Nr   r*   r+   r,   r   r      s>    @NKN#()=)=d#KKK#\N4@L)@r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)
PageNumberzThe number of a pageTr   r;   r0   r   r9   spanr<   r=   Nr   r*   r+   r,   r   r      s>    3DAKA#()=)=d#KKK#VHT:L):r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)UncategorizedTextzMiscellaneous textTr   r;   r0   r   r9   r   r<   r=   Nr   r*   r+   r,   r   r     s>    1$?K?#()=)=d#KKK#VHT:L):r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)OrderedListzA list with a specific sequenceTr   r;   r0   r   r9   olr<   r=   N
r   r   r   r   r0   r   r   r   r9   r=   r*   r+   r,   r   r   	  s>    >tLKL#()=)=d#KKK#TF48L)8r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)UnorderedListz"A list without a specific sequenceTr   r;   r0   r   r9   ulr<   r=   Nr   r*   r+   r,   r   r     s>    A$OKO#()=)=d#KKK#TF48L)8r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)DefinitionList%A list of terms and their definitionsTr   r;   r0   r   r9   dlr<   r=   Nr   r*   r+   r,   r   r     r   r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)ListItemzAn item in a listTr   r;   r0   r   r9   lir<   r=   Nr   r*   r+   r,   r   r     s>    0>K>#()=)=d#KKK#TF48L)8r+   r   c                       e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   dd fdZ
 xZS )r   zA structured set of dataTr   r;   r0   r   r9   r   r<   r=   c                b    t        t        | 	  |      d      }t        |      }t	        |      S Nre   r   rA   r\   r   r;   rE   rU   r   rC   s      r,   r\   zTable.to_html&  ,    UW_\:MJ.t44yr+   r   r~   r   r   r   r   r0   r   r   r   r9   r=   r\   r   r   s   @r,   r   r   !  sI    7EKE#()>)>t#LKL#WId;L); r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)	TableBodyzA body of the tableTr   r;   r0   r   r9   tbodyr<   r=   N
r   r   r   r   r0   r   r   r   r9   r=   r*   r+   r,   r   r   ,  s>    24@K@#()>)>t#LKL#WId;L);r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)TableHeaderzA header of the tableTr   r;   r0   r   r9   theadr<   r=   Nr   r*   r+   r,   r   r   2  s>    4TBKB#()>)>t#LKL#WId;L);r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)TableRowzA row in a tableTr   r;   r0   r   r9   trr<   r=   Nr   r*   r+   r,   r   r   8  s>    /=K=#()>)>t#LKL#TF48L)8r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)	TableCellzA cell in a tableTr   r;   r0   r   r9   r   r<   r=   Nr   r*   r+   r,   r   r   >  s>    0>K>#()>)>t#LKL#TF48L)8r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)TableCellHeaderzA header cell in a tableTr   r;   r0   r   r9   r   r<   r=   Nr   r*   r+   r,   r   r   E  s>    7EKE#()>)>t#LKL#TF48L)8r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)ImagezA visual representationTr   r;   r0   r   r9   rf   r<   r=   N
r   r   r   r   r0   r   r   r    r9   r=   r*   r+   r,   r   r   K  s>    6tDKD#()>)>t#LKL#UGD9L)9r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)Figurez(An illustration or diagram in a documentTr   r;   r0   r   r9   figurer<   r=   Nr   r*   r+   r,   r   r   Q  s?    GPTUKU#()>)>t#LKL#XJt<L)<r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)VideozA moving visual media elementTr   r;   r0   r   r9   videor<   r=   Nr   r*   r+   r,   r   r   W  s>    <TJKJ#()>)>t#LKL#WId;L);r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)AudiozA sound or music elementTr   r;   r0   r   r9   audior<   r=   Nr   r*   r+   r,   r   r   ]  s>    7EKE#()>)>t#LKL#WId;L);r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)Barcodez)A machine-readable representation of dataTr   r;   r0   r   r9   rf   r<   r=   Nr   r*   r+   r,   r   r   c  s?    HQUVKV#()>)>t#LKL#UGD9L)9r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)QRCodezA two-dimensional barcodeTr   r;   r0   r   r9   rf   r<   r=   Nr   r*   r+   r,   r   r   i  s>    8FKF#()>)>t#LKL#UGD9L)9r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)Logoz0A graphical representation of a company or brandTr   r;   r0   r   r9   rf   r<   r=   Nr   r*   r+   r,   r  r  o  s?    OX\]K]#()>)>t#LKL#UGD9L)9r+   r  c                      e Zd ZU  edd      Zded<    eej                  d      Zded<    edd	gd      Z	d
ed<   y)	CodeBlockzA block of programming codeTr   r;   r0   r   r9   prer!   r<   r=   N
r   r   r   r   r0   r   r   r!   r9   r=   r*   r+   r,   r  r  u  s@    :4HKH#()=)=d#KKK#UFODAL)Ar+   r  c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)
InlineCodezCode within a line of textTr   r;   r0   r   r9   r!   r<   r=   Nr  r*   r+   r,   r  r  {  s>    9$GKG#()=)=d#KKK#VHT:L):r+   r  c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)FormulazA mathematical formulaTr   r;   r0   r   r9   mathr<   r=   N
r   r   r   r   r0   r   r   r"   r9   r=   r*   r+   r,   r
  r
    s>    5dCKC#()E)Ed#SKS#VHT:L):r+   r
  c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)EquationzA mathematical equationTr   r;   r0   r   r9   r  r<   r=   Nr  r*   r+   r,   r  r    s>    6tDKD#()E)Ed#SKS#VHT:L):r+   r  c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)FootnoteReferencez9A subscripted reference to a note at the bottom of a pageTr   r;   r0   r   r9   subr<   r=   N
r   r   r   r   r0   r   r   r#   r9   r=   r*   r+   r,   r  r    sD    CDK  $))B)B4#PKP#UGD9L)9r+   r  c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)CitationzA reference to a sourceTr   r;   r0   r   r9   citer<   r=   Nr  r*   r+   r,   r  r    s>    6tDKD#()B)B4#PKP#VHT:L):r+   r  c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)BibliographyzA list of sourcesTr   r;   r0   r   r9   r   r<   r=   Nr  r*   r+   r,   r  r    s>    0>K>#()B)B4#PKP#TF48L)8r+   r  c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)Glossaryr   Tr   r;   r0   r   r9   r   r<   r=   Nr  r*   r+   r,   r  r    s>    DTRKR#()B)B4#PKP#TF48L)8r+   r  c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)AuthorzThe creator of the documentTr   r;   r0   r   r9   metar<   r=   N
r   r   r   r   r0   r   r   r$   r9   r=   r*   r+   r,   r  r    s>    :4HKH#()A)A$#OKO#VHT:L):r+   r  c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)MetaDatez%The date associated with the documentTr   r;   r0   r   r9   r  r<   r=   Nr  r*   r+   r,   r  r    s>    DTRKR#()A)A$#OKO#VHT:L):r+   r  c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)Keywordsz&Key terms associated with the documentTr   r;   r0   r   r9   r  r<   r=   Nr  r*   r+   r,   r!  r!    s>    EdSKS#()A)A$#OKO#VHT:L):r+   r!  c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)AbstractzA summary of the documentTr   r;   r0   r   r9   r   r<   r=   Nr  r*   r+   r,   r#  r#    s>    8FKF#()A)A$#OKO#YK=L)=r+   r#  c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)	Hyperlinkz1A reference to data that can be directly followedTr   r;   r0   r   r9   ar<   r=   N
r   r   r   r   r0   r   r   r%   r9   r=   r*   r+   r,   r%  r%    s?    PY]^K^#()C)CD#QKQ#SE$7L)7r+   r%  c                       e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   dd fdZ
 xZS )TableOfContentszA list of the document's contents. Total table columns will be equal to the degree of hierarchy (n) plus 1 for the target value. Header Row: L1,L2,...Ln,ValueTr   r;   r0   r   r9   r   r<   r=   c                b    t        t        | 	  |      d      }t        |      }t	        |      S r   r   r   s      r,   r\   zTableOfContents.to_html  r   r+   r   r~   r   r   s   @r,   r)  r)    sT    	( 	K  $))>)>t#LKL#WId;L); r+   r)  c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)Indexz4An alphabetical list of terms and their page numbersTr   r;   r0   r   r9   navr<   r=   Nr'  r*   r+   r,   r,  r,    s?    S\`aKa#()C)CD#QKQ#UGD9L)9r+   r,  c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)r   z,A document section with interactive controlsTr   r;   r0   r   r9   r&   r<   r=   N
r   r   r   r   r0   r   r   r&   r9   r=   r*   r+   r,   r   r     s?    KTXYKY#()=)=d#KKK#VHT:L):r+   r   c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)	FormFieldzA property value of a formTr   r;   r0   r   r9   labelr<   r=   Nr/  r*   r+   r,   r1  r1    s>    9$GKG#()=)=d#KKK#WId;L);r+   r1  c                       e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   dd fdZ
 xZS )FormFieldValuezA field for user inputTr   r;   r0   r   r9   inputr<   r=   c                    t         |   ||      }| j                  j                  dd      }|s|S | d| j	                         S )Nro   r/   rO   )rA   r`   r>   rj   rR   )rE   rU   rc   r   ro   rC   s        r,   r`   zFormFieldValue.to_text  sN    w|-=>**..w;Kq &&((r+   r   r~   )r   r   r   r   r0   r   r   r&   r9   r=   r`   r   r   s   @r,   r4  r4    sI    5dCKC#()=)=d#KKK#WId;L);) )r+   r4  c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)Checkboxz,A small box that can be checked or uncheckedTr   r;   r0   r   r9   r5  r<   r=   Nr/  r*   r+   r,   r8  r8    s?    KTXYKY#()=)=d#KKK#WId;L);r+   r8  c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)RadioButtonz&A circular button that can be selectedTr   r;   r0   r   r9   r5  r<   r=   Nr/  r*   r+   r,   r:  r:    s>    EdSKS#()=)=d#KKK#WId;L);r+   r:  c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)ButtonzAn interactive button elementTr   r;   r0   r   r9   buttonr<   r=   Nr/  r*   r+   r,   r<  r<     s>    <TJKJ#()=)=d#KKK#XJt<L)<r+   r<  c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)CommentzA note or remarkTr   r;   r0   r   r9   r   r<   r=   N
r   r   r   r   r0   r   r   r'   r9   r=   r*   r+   r,   r?  r?    s>    /=K=#()C)CD#QKQ#VHT:L):r+   r?  c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)	HighlightzEmphasized text or sectionTr   r;   r0   r   r9   markr<   r=   Nr@  r*   r+   r,   rB  rB    s>    9$GKG#()C)CD#QKQ#VHT:L):r+   rB  c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)RevisionInsertionA changed or edited elementTr   r;   r0   r   r9   insr<   r=   Nr@  r*   r+   r,   rE  rE    >    :4HKH#()C)CD#QKQ#UGD9L)9r+   rE  c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)RevisionDeletionrF  Tr   r;   r0   r   r9   delr<   r=   Nr@  r*   r+   r,   rJ  rJ    rH  r+   rJ  c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)AddresszA physical locationTr   r;   r0   r   r9   addressr<   r=   N
r   r   r   r   r0   r   r   r(   r9   r=   r*   r+   r,   rM  rM    s?    24@K@#()I)IRV#WKW#YK=L)=r+   rM  c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)EmailAddresszAn email addressTr   r;   r0   r   r9   r&  r<   r=   NrO  r*   r+   r,   rQ  rQ  $  s?    /=K=#()I)IRV#WKW#SE$7L)7r+   rQ  c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)PhoneNumberzA telephone numberTr   r;   r0   r   r9   r   r<   r=   NrO  r*   r+   r,   rS  rS  *  s?    1$?K?#()I)IRV#WKW#VHT:L):r+   rS  c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)CalendarDatezA calendar dateTr   r;   r0   r   r9   timer<   r=   NrO  r*   r+   r,   rU  rU  0  ?    .t<K<#()I)IRV#WKW#VHT:L):r+   rU  c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)TimezA specific timeTr   r;   r0   r   r9   rV  r<   r=   NrO  r*   r+   r,   rY  rY  6  rW  r+   rY  c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)CurrencyzA monetary valueTr   r;   r0   r   r9   r   r<   r=   NrO  r*   r+   r,   r[  r[  <  s?    /=K=#()I)IRV#WKW#VHT:L):r+   r[  c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)MeasurementzA quantitative value with unitsTr   r;   r0   r   r9   r   r<   r=   NrO  r*   r+   r,   r]  r]  B  s?    >tLKL#()I)IRV#WKW#VHT:L):r+   r]  c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)
Letterheadz"The heading at the top of a letterTr   r;   r0   r   r9   r   r<   r=   N
r   r   r   r   r0   r   r   r)   r9   r=   r*   r+   r,   r_  r_  H  s?    A$OKO#()J)JSW#XKX#XJt<L)<r+   r_  c                      e Zd ZU  edd      Zded<    eej                  d      Zded<    edd	gd      Z	d
ed<   y)	Signaturez,A person's name written in a distinctive wayTr   r;   r0   r   r9   rf   svgr<   r=   Nr`  r*   r+   r,   rb  rb  N  sB    KTXYKY#()J)JSW#XKX#UEN4@L)@r+   rb  c                  ~    e Zd ZU  edd      Zded<    eej                  d      Zded<    edgd      Z	d	ed
<   y)	Watermarkz/A faint design made in paper during manufactureTr   r;   r0   r   r9   r   r<   r=   Nr`  r*   r+   r,   re  re  T  s@    NW[\K\#()J)JSW#XKX#UGD9L)9r+   re  c                      e Zd ZU  edd      Zded<    eej                  d      Zded<    edd	gd      Z	d
ed<   y)StampzAn official mark or sealTr   r;   r0   r   r9   rf   rc  r<   r=   Nr`  r*   r+   r,   rg  rg  Z  sA    7EKE#()J)JSW#XKX#UEN4@L)@r+   rg  )r   r	   )[__doc__
__future__r   rI   r   enumr   typingr   r   bs4r   r	   pydanticr
   r   r;   r   r.   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r
  r  r  r  r  r  r  r  r!  r#  r%  r)  r,  r   r1  r4  r8  r:  r<  r?  rB  rE  rJ  rM  rQ  rS  rU  rY  r[  r]  r_  rb  re  rg  r*   r+   r,   <module>rn     s   #    ! " %,c4 ,"ci cL; ;>o >:? ::_ :8 8=_ ==_ =<o <9 99O 99 9Wo W8O 8AO A: :Ao A; ;; ;9/ 99O 99_ 99 9O < <</ <9 99 99o 9:O :=_ =<O <<O <:o ::_ ::? :B B; ;;o ;; ;: :; ;9? 99 9;_ ;; ;; ;> >8 8o  :O :;? ;< <
)_ 
)< <</ <=_ =;o ;; ;: :: :>o >8? 8;/ ;;? ;;? ;; ;;/ ;= =A A: :AO Ar+   