+
    	i"                     `    R t ^ RIt^RIHt  ! R R4      t ! R R4      tR t ! R R	4      tR# )
zHandle target-counter, target-counters and target-text.

The TargetCollector is a structure providing required targets' counter_values
and stuff needed to build pending targets later, when the layout of all
targeted anchors has been done.

N)LOGGERc                   .   a  ] tR t^t o RtRR ltRtV tR# )TargetLookupItemzItem controlling pending targets and page based target counters.

Collected in the TargetCollector's ``target_lookup_items``.

c                J    Wn         R V n        / V n        R V n        / V n        R # )N)state
target_boxparse_again_functionspage_maker_indexcached_page_counter_values)selfr   s   &&\/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/weasyprint/css/targets.py__init__TargetLookupItem.__init__   s.    

  &(" !% +-'    )r
   r	   r   r   r   N)pending__name__
__module____qualname____firstlineno____doc__r   __static_attributes____classdictcell____classdict__s   @r   r   r      s     
- -r   r   c                   *   a  ] tR t^'t o RtR tRtV tR# )CounterLookupItemzeItem controlling page based counters.

Collected in the TargetCollector's ``counter_lookup_items``.

c                T    Wn         W n        W0n        R V n        RV n        / V n        R # )NF)parse_againmissing_countersmissing_target_countersr	   r   r
   )r   r   r   r    s   &&&&r   r   CounterLookupItem.__init__-   s3    & !1'>$ !%  +-'r   )r
   r   r    r	   r   r   Nr   r   s   @r   r   r   '   s     
- -r   r   c                    V ^ ,          R8X  d/   V ^,          P                  R4      '       d   V ^,          R,          # V ^ ,          R8X  d(   V ^,          ^ ,          R8X  d   V ^,          ^,          # R# R# )z)Get anchor name from string or uri token.string#:   NNurlinternalN)
startswith)anchor_tokens   &r   anchor_name_from_tokenr*   ?   se    A("|A'A'A#'F'FAr""	aE	!l1oa&8J&FAq!! 'G	!r   c                   N   a  ] tR t^Gt o RtR tR tR tR tR t	R t
R tR	tV tR
# )TargetCollectorz@Collector of HTML targets used by CSS content with ``target-*``.c                >    / V n         / V n        R V n        RV n        R# )TFN)target_lookup_itemscounter_lookup_items
collectinghad_pending_targets)r   s   &r   r   TargetCollector.__init__J   s%    #% $&! 
 $) r   c                    \        V\        4      '       d]   V P                  P                  V4      e   \        P
                  ! RV4       R# V P                  P                  V\        4       4       R# R# )z7Create a TargetLookupItem for the given `anchor_name``.NzAnchor defined twice: %r)
isinstancestrr.   getr   warning
setdefaultr   )r   anchor_names   &&r   collect_anchorTargetCollector.collect_anchorZ   sW    k3''''++K8D9;G((33!1!35	 (r   c                    \        V4      pV P                  P                  V\        R4      4      pVP                  R8X  d%   RV n        VP                  P                  W#3V4       VP                  R8X  d   \        P                  ! RV4       V# )zGet a TargetLookupItem corresponding to ``anchor_token``.

If it is already filled by a previous anchor-element, the status is
'up-to-date'. Otherwise, it is 'pending', we must parse the whole
tree again.

	undefinedr   Tz7Content discarded: target points to undefined anchor %r)
r*   r.   r6   r   r   r1   r   r8   r   error)r   r)   
source_box	css_tokenr   r9   items   &&&&&  r   lookup_targetTargetCollector.lookup_targetc   s     -\:''++)+68 ::"'+D$&&11'6 ::$LLI r   c                *   V P                   P                  V4      pV'       dj   VP                  R8X  dW   RVn        W4n        VP                  f:   VP                  4        UUu/ uF  w  rVWVP                  4       bK  	  uppVn        R# R# R# R# u uppi )zStore a target called ``anchor_name``.

If there is a pending TargetLookupItem, it is updated. Only previously
collected anchors are stored.

r   
up-to-dateN)r.   r6   r   r   cached_counter_valuesitemscopy)r   r9   target_counter_valuesr   rA   keyvalues   &&&&   r   store_targetTargetCollector.store_target{   s     ''++K8DJJ)+%DJ(O //7 -224464 +5#C%446
0 8 ,446s   #Bc                    V P                   '       g   R# V'       g	   V'       d@   VP                  f   Wn        \        W4V4      pV P                  P	                  W3V4       R# R# )a  Collect missing (probably page-based) counters during formatting.

The ``missing_counters`` are re-used during pagination.

The ``missing_link`` attribute added to the parent_box is required to
connect the paginated boxes to their originating ``parent_box``.

N)r0   missing_linkr   r/   r8   )r   
parent_boxr@   parse_again_functionr   r    counter_lookup_items   &&&&&& r   collect_missing_counters(TargetCollector.collect_missing_counters   s_      6&&.*4'"3$'#) %%00')<>  7r   c                    V P                   '       dQ   V P                  P                  4        F+  pVP                  P                  4        F
  pV! 4        K  	  K-  	  RV n         RV n        R# )z Check pending targets if needed.FN)r1   r.   valuesr   r0   )r   rA   functions   &  r   check_pending_targets%TargetCollector.check_pending_targets   sW    ###00779 $ : : A A CHJ !D : (-D$r   c                   V P                   '       d   R# V P                  P                  V4      pV'       Ed&   VP                  R8X  Ed   W5n        VP
                  V8w  d   \        P                  ! V4      Vn        V P                  P                  4        F  w  w  rgpVR8w  d   K  VP                  P                  V4      pVf   K2  VP                  e   VP                  \        V4      8  d
   RVn        Kc  V FT  p	VP                  V	4      p
V
f   K  WEP                  ,          R,          pRVR&   VP                  VP
                  4        K  	  K  	  R# R# R# R# )zuStore target's current ``page_maker_index`` and page counter values.

Eventually update associated targeting boxes.

NrE   contentTcontent_changed)r0   r.   r6   r   r	   r
   rH   deepcopyr/   rG   r    lenr   r   )r   r9   page_counter_valuesr	   
page_makerrA   _r@   r   counter_namecounter_valueremake_states   &&&&&       r   cache_target_page_counters*TargetCollector.cache_target_page_counters   sC    ???''++K84DJJ,.$4!..2EE26--'3)/
 -1,E,E,K,K,M(NQD I-  (,'C'C'G'G#(%$'/  --5 11S_D'+ 
 )9(;(?(?(M(4 *+@+@ A" E )>BL):; ,,T-L-LM! )9) -N F /4r   )r0   r/   r1   r.   N)r   r   r   r   r   r   r:   rB   rL   rS   rX   rf   r   r   r   s   @r   r,   r,   G   s0     J) 506$>2 /" /"r   r,   )r   rH   loggerr   r   r   r*   r,    r   r   <module>rj      s7     - -2- -0"X" X"r   