
    hU                        S r SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SSKJr  SSKJr  SS	KJrJr   " S
 S\
5      rg)z<Styles object, container for all objects in the styles part.    )annotations)warn)WD_STYLE_TYPE)	CT_Styles)ElementProxy)	BabelFish)LatentStyles)	BaseStyleStyleFactoryc                     ^  \ rS rSrSrSU 4S jjrS rSS jrS rS r	SS jr
SS	 jrSS
 jrS r\S 5       rSS jr      SS jr      SS jrSrU =r$ )Styles   zProvides access to the styles defined in a document.

Accessed using the :attr:`.Document.styles` property. Supports ``len()``, iteration,
and dictionary-style access by style name.
c                0   > [         TU ]  U5        Xl        g N)super__init___element)selfstyles	__class__s     D/var/www/html/env/lib/python3.13/site-packages/docx/styles/styles.pyr   Styles.__init__   s         c                   ^ [         R                  " U5      m[        U4S jU R                  R                   5       5      $ )z$Enables `in` operator on style name.c              3  @   >#    U  H  oR                   T:H  v   M     g 7fr   )name_val).0styleinternal_names     r   	<genexpr>&Styles.__contains__.<locals>.<genexpr>   s     X@Wu>>]2@Ws   )r   ui2internalanyr   	style_lst)r   namer   s     @r   __contains__Styles.__contains__   s.    !--d3X@W@WXXXr   c                   U R                   R                  [        R                  " U5      5      nUb  [	        U5      $ U R                   R                  U5      nUb  Sn[        U[        SS9  [	        U5      $ [        SU-  5      e)zEnables dictionary-style access by UI name.

Lookup by style id is deprecated, triggers a warning, and will be removed in a
near-future release.
zFstyle lookup by style_id is deprecated. Use style name as key instead.   )
stacklevelzno style with name '%s')	r   get_by_namer   r"   r   	get_by_idr   UserWarningKeyError)r   key	style_elmmsgs       r   __getitem__Styles.__getitem__   s     MM--i.C.CC.HI	 	**MM++C0	   ka0	**03677r   c                <    S U R                   R                   5       $ )Nc              3  8   #    U  H  n[        U5      v   M     g 7fr   )r   )r   r   s     r   r    "Styles.__iter__.<locals>.<genexpr>5   s     I1HU##1Hs   )r   r$   r   s    r   __iter__Styles.__iter__4   s    I1H1HIIr   c                @    [        U R                  R                  5      $ r   )lenr   r$   r7   s    r   __len__Styles.__len__7   s    4==**++r   c                    [         R                  " U5      nX@;   a  [        SU-  5      eU R                  R	                  XBU5      n[        U5      $ )zReturn a newly added style object of `style_type` and identified by `name`.

A builtin style can be defined by passing True for the optional `builtin`
argument.
z$document already contains style '%s')r   r"   
ValueErrorr   add_style_of_typer   )r   r%   
style_typebuiltin
style_namer   s         r   	add_styleStyles.add_style:   sL     **40
CdJKK//
PE""r   c                V    U R                   R                  U5      nUc  g[        U5      $ )zhReturn the default style for `style_type` or |None| if no default is defined
for that type (not common).N)r   default_forr   )r   rA   r   s      r   defaultStyles.defaultF   s+     ))*5=E""r   c                L    Uc  U R                  U5      $ U R                  X5      $ )zReturn the style of `style_type` matching `style_id`.

Returns the default for `style_type` if `style_id` is not found or is |None|, or
if the style having `style_id` is not of `style_type`.
)rH   
_get_by_id)r   style_idrA   s      r   r,   Styles.get_by_idN   s(     <<
++x44r   c                x    Uc  g[        U[        5      (       a  U R                  X5      $ U R                  X5      $ )aJ  Return the id of the style corresponding to `style_or_name`, or |None| if
`style_or_name` is |None|.

If `style_or_name` is not a style object, the style is looked up using
`style_or_name` as a style name, raising |ValueError| if no style with that name
is defined. Raises |ValueError| if the target style is not of `style_type`.
N)
isinstancer
   _get_style_id_from_style_get_style_id_from_name)r   style_or_namerA   s      r   get_style_idStyles.get_style_idX   s<      y1100KK//JJr   c                H    [        U R                  R                  5       5      $ )zA |LatentStyles| object providing access to the default behaviors for latent
styles and the collection of |_LatentStyle| objects that define overrides of
those defaults for a particular named latent style.)r	   r   get_or_add_latentStylesr7   s    r   latent_stylesStyles.latent_stylesg   s    
 DMMAACDDr   c                    U(       a  U R                   R                  U5      OSnUb  UR                  U:w  a  U R                  U5      $ [	        U5      $ )zReturn the style of `style_type` matching `style_id`.

Returns the default for `style_type` if `style_id` is not found or if the style
having `style_id` is not of `style_type`.
N)r   r,   typerH   r   )r   rL   rA   r   s       r   rK   Styles._get_by_idn   sF     6>''14=EJJ*4<<
++E""r   c                *    U R                  X   U5      $ )zReturn the id of the style of `style_type` corresponding to `style_name`.

Returns |None| if that style is the default style for `style_type`. Raises
|ValueError| if the named style is not found in the document or does not match
`style_type`.
)rP   )r   rC   rA   s      r   rQ   Styles._get_style_id_from_namey   s     ,,T-=zJJr   c                    UR                   U:w  a  [        SUR                   < SU< 35      eXR                  U5      :X  a  gUR                  $ )z{Id of `style`, or |None| if it is the default style of `style_type`.

Raises |ValueError| if style is not of `style_type`.
zassigned style is type z, need type N)rZ   r?   rH   rL   )r   r   rA   s      r   rP   Styles._get_style_id_from_style   sG     ::#=BZZT  LL,,~~r   )r   )r   r   )r/   str)F)rA   r   )rL   
str | NonerA   r   )rC   r`   rA   r   returnra   )r   r
   rA   r   rb   ra   )__name__
__module____qualname____firstlineno____doc__r   r&   r2   r8   r<   rD   rH   r,   rS   propertyrW   rK   rQ   rP   __static_attributes____classcell__)r   s   @r   r   r      s    Y
8*J,
##5K E E	#	K	K+8	K		K,9	 r   r   N)rg   
__future__r   warningsr   docx.enum.styler   docx.oxml.stylesr   docx.sharedr   docx.stylesr   docx.styles.latentr	   docx.styles.styler
   r   r    r   r   <module>rt      s.    B "  ) & $ ! + 5B\ Br   