+
    Qi.&  c                   s    R t RtRtRtRtRt^ RIt^ RIt^ RIH	t	 ^ RI
t
]
P                  ! RR	4       ^ R
IHt ^ RIHt ^RIHt ^RIHt  ! R R4      tR# )NUtilities for obtaining information about accessible hypertext and hyperlinks.z$Id$z
$Revision$z$Date$zCopyright (c) 2024 Igalia, S.L.ZLGPLN)urlparseAtspiz2.0)r   )GLib)debug)AXObjectc                   s`  a  ] tR t^+t o Rt]V 3R lR l4       t]V 3R lR l4       t]V 3R lR l4       t]V 3R lR	 l4       t	]RV 3R
 lR ll4       t
]V 3R lR l4       t]V 3R lR l4       t]RV 3R lR ll4       t]V 3R lR l4       t]V 3R lR l4       t]V 3R lR l4       tRtV tR# )AXHypertextr    c                :   < V ^8  d   QhRS[ P                  RS[/#    objreturnr   
AccessibleintZformat__classdict__   "6/usr/lib/python3.14/site-packages/orca/ax_hypertext.py__annotate__AXHypertext.__annotate__/   s!      U-- #     c                s|   \         P                  ! V 4      '       g   ^ #  \        P                  P	                  V 4      pRT RT R2.p\        P                  ! \        P                  TR4       T#   \
        P                   d7   pRT 2p\        P                  ! \        P                  TR4        Rp?^ # Rp?ii ; i)z(Returns the number of hyperlinks in obj.z+AXHypertext: Exception in _get_link_count: TNzAXHypertext:zreports z hyperlinks)r   supports_hypertextr   	HypertextZget_n_linksr   GErrorr   print_message
LEVEL_INFOprint_tokens)r
   Zcounterrormsgtokens   &    r   _get_link_countZAXHypertext._get_link_count.   s     **3//	OO//4E !#%'DE5++VT: {{ 	?wGC 0 0#t<	s   A0 0B;+B66B;c                sb   < V ^8  d   QhRS[ P                  RS[RS[ P                  R,          /# )r	   r
   indexr   N)r   r   r   	Hyperlinkr   r   r   r   r   A   s2       0 0  SWAW r   c                s   \         P                  ! V 4      '       g   R#  \        P                  P	                  W4      pV#   \
        P                   d7   pRT 2p\        P                  ! \        P                  TR4        Rp?R# Rp?ii ; i)z4Returns the hyperlink object at the specified index.Nz.AXHypertext: Exception in _get_link_at_index: T)
r   r   r   r   Zget_linkr   r   r   r   r   )r
   r!   linkr   r   s   &&   r   _get_link_at_indexZAXHypertext._get_link_at_index@   su     **3//	??++C7D  {{ 	B5'JC 0 0#t<	s   A B+BBc          	      sj   < V ^8  d   QhRS[ P                  RS[RS[RS[S[ P                  ,          /# )r	   r
   start_offset
end_offsetr   )r   r   r   listr"   r   r   r   r   r   Q   s<      -0>A	eoo	r   c                s   . p\        \        P                  V 4      4       Fu  p\        P                  W4      pV\        P	                  V4      u;8:  d   V8  g+   M V\        P                  V4      u;8  d
   V8:  g   K`  M Kd  VP                  V4       Kw  	  R\        V4       R2V RV RV 2.p\        P                  ! \        P                  VR4       V# )zIReturns all the hyperlinks in obj who started within the specified range.AXHypertext:  hyperlinks found inzbetween start: z
 and end: T)ranger   r    r$   get_link_start_offsetget_link_end_offsetappendlenr   r   r   )r
   r%   r&   linksir#   r      &&&    r   get_all_links_in_rangeZ"AXHypertext.get_all_links_in_rangeP   s     {22378A11#9D{@@FSS!@!@!FT*TTT"	 9 "#e*-ABC#L>J<HJ5++VT:r   c                s^   < V ^8  d   QhRS[ P                  RS[S[ P                  ,          /# r   )r   r   r'   r"   r   r   r   r   r   c   s*      5++ U__0E r   c                s   . p\        \        P                  V 4      4       F/  p\        P                  W4      pVf   K  VP	                  V4       K1  	  R\        V4       R2V .p\        P                  ! \        P                  VR4       V# )z,Returns a list of all the hyperlinks in obj.r(   r)   T)	r*   r   r    r$   r-   r.   r   r   r   )r
   r/   r0   r#   r   r   r   get_all_linksZAXHypertext.get_all_linksb   s|     {22378A11#9DT" 9
 "#e*-ABCH5++VT:r   c                s@   < V ^8  d   QhRS[ P                  RS[RS[/# )r	   r
   r!   r   )r   r   r   strr   r   r   r   r   q   s(      %** 3 s r   c                s    \         P                  P                  V 4      p\         P                  P	                  W!4      pRT RT RT 2.p\        P                  ! \        P                  TR4       T#   \
        P                   d7   pRT 2p\        P                  ! \        P                  TR4        Rp?R# Rp?ii ; i)z;Returns the URI associated with obj at the specified index.z(AXHypertext: Exception in get_link_uri: TN zAXHypertext: URI ofz	at index z is )r   r   get_hyperlinkr"   Zget_urir   r   r   r   r   r   )r
   r!   r#   urir   r   r      &&     r   get_link_uriZAXHypertext.get_link_urip   s    	##11#6D//))$6C (	%SE.JK5++VT:
 {{ 	<UGDC 0 0#t<	s   >A3 3B>+B99B>c                r   r   r   r   r   r   r   r      s!      5#3#3  r   c                d   \        V \        P                  4      '       d$   T p\        P                  P                  V^ 4      p M\        P                  P                  V 4      pVf-   RV .p\        P                  ! \        P                  VR4       R#  \        P                  P                  V4      pRT RT 2.p\        P                  ! \        P                  TR4       T#   \        P                   d8   pRT 2p\        P                  ! \        P                  TR4       Ru Rp?# Rp?ii ; i)z7Returns the start offset of obj in the associated text.N'AXHypertext: Couldn't get hyperlink forTz1AXHypertext: Exception in get_link_start_offset: zAXHypertext: Start offset ofis )
isinstancer   r"   
get_objectr   r6   r   r   r   Zget_start_indexr   r   r   r
   r#   r   offsetr   r      &     r   r+   Z!AXHypertext.get_link_start_offset   s     c5??++D//,,T15C##11#6D<?EFu//>I	__44T:F 1#VH~F5++VT: {{ 	EeWMC 0 0#t<I	   C# #D/8,D*$D/*D/c                r   r   r   r   r   r   r   r      s!      !1!1 c r   c                r:   )z5Returns the end offset of obj in the associated text.Nr;   Tz/AXHypertext: Exception in get_link_end_offset: zAXHypertext: End offset ofr<   r=   )r>   r   r"   r?   r   r6   r   r   r   Zget_end_indexr   r   r   r@   rB   r   r,   ZAXHypertext.get_link_end_offset   s     c5??++D//,,T15C##11#6D<?EFu//>I	__2248F /s6(^D5++VT: {{ 	CE7KC 0 0#t<I	rC   c                sF   < V ^8  d   QhRS[ P                  RS[RS[RS[/# )r	   r
   r!   remove_extensionr   )r   r   r   Zboolr4   r   r   r   r   r      s3      &)AE	r   c                s   \         P                  W4      pV'       g   R# \        V4      p\        P                  P                  VP                  4      pV'       d?   \        P                  P                  V4      ^ ,          p\        P                  ! RRV4      pRV RV R2.p\        P                  ! \        P                  VR4       V# )z>Strip directory and suffix off of the URL associated with obj.r5   z[-_]Z zAXHypertext: Basename for linkzis 'Z'T)r   r9   r   osZpathbasenameZsplitextreZsubr   r   r   )r
   r!   rD   r7   Z
parsed_urirF   r   r1   r   get_link_basenameZAXHypertext.get_link_basename   s     &&s2c]
GG$$Z__5ww''1!4HvvgsH5H2C4z9KL5++VT:r   c                b   < V ^8  d   QhRS[ P                  RS[RS[ P                  R,          /# r	   r
   rA   r   Nr   r   r   r   r   r      s4      %"2"2 C EDTDTW[D[ r   c                s4   \         P                  W4      ;p'       d   V# \         P                  W^,
          4      ;p'       dY   \         P                  V4      pWA8X  d>   RV R2V RVRV^,
           2.p\        P                  ! \        P
                  VR4       V# \         P                  W^,           4      ;p'       dY   \         P                  V4      pWA8X  d>   RV R2V RVRV^,            2.p\        P                  ! \        P
                  VR4       V# R# )z@Attempts to correct for off-by-one brokenness in implementationsz'AXHypertext: Corrected child at offset  inisz
at offset TN)r   get_child_at_offsetget_character_offset_in_parentr   r   r   )r
   rA   childZchild_beforeZoffset_in_parentr   Zchild_afterr8   r   find_child_at_offsetZ AXHypertext.find_child_at_offset   s     33C@@5@L&::3
KK<K*II,W)CF83OQTVZ&*VaZL(AC""5#3#3VTB##%99#zJJ;J*II+V)CF83OQTVZ%FQJ<'@B""5#3#3VTB""r   c                rI   rJ   r   r   r   r   r   r      s4      !1!1 3 5CSCSVZCZ r   c                s   \         P                  ! V 4      '       g   R#  \        P                  P	                  W4      pT^ 8  d   R# \        P                  Y4      pTf   R#  \        P                  P                  T^ 4      pRT R2T RT.p\        P                  ! \        P                  TR4       T#   \
        P                   d7   pRT 2p\        P                  ! \        P                  TR4        Rp?R# Rp?ii ; i  \
        P                   d7   pRT 2p\        P                  ! \        P                  TR4        Rp?R# Rp?ii ; i)zAReturns the embedded-object child of obj at the specified offset.Nz/AXHypertext: Exception in get_child_at_offset: TzAXHypertext: Child at offset rK   rL   )r   r   r   r   Zget_link_indexr   r   r   r   r   r   r$   r"   r?   r   )r
   rA   r!   r   r   r#   rO   r   s   &&      r   rM   ZAXHypertext.get_child_at_offset   s    **3//	OO223?E 19--c9<	OO..tQ7E 2&=sD%P5++VT:+ {{ 	CE7KC 0 0#t<	 {{ 	CE7KC 0 0#t<	s/   B6 $ D 6D+C<<DE+E

Ec                r   r   r   r   r   r   r   r     s!     6 6E,<,< 6 6r   c                s    \         P                  ! \         P                  ! V 4      4      '       g   R# \        P	                  V 4      # )zHReturns the offset of the embedded-object obj in the text of its parent.r=   )r   Zsupports_textZ
get_parentr   r+   )r
   s   &r   rN   Z*AXHypertext.get_character_offset_in_parent  s6     %%h&9&9#&>??I0055r    N)    )rR   F)Z__name__Z
__module__Z__qualname__Z__firstlineno____doc__Zstaticmethodr    r$   r2   r3   r9   r+   r,   rH   rP   rM   rN   Z__static_attributes__Z__classdictcell__)r   s   @r   r   r   +   s     X "    "       2  2   &  0  > 6 6r   r   )rS   Z__id__Z__version__Z__date__Z__copyright__Z__license__rE   rG   Zurllib.parser   ZgiZrequire_versionZgi.repositoryr   r   r5   r   Z	ax_objectr   r   rQ   r   r   <module>rT      sX   . U1 	 	 ! 	   7E "    ]6 ]6r   