Ë
    £ehƒ!  ã                   ó.  — d dl mZ d dlZd dlmZ d dlmZmZ d dlm	Z	 d dl
mZ  G d„ de«      Z G d	„ d
e«      Z G d„ de«      ZdZ ej$                  e«      ZdZ ej$                  e«      ZdZ ej$                  e«      ZdZ ej$                  e«      Zy)é    )ÚBytesION)Ússtruct)Ú	bytesjoinÚtostr)ÚOrderedDict)ÚMutableMappingc                   ó   — e Zd Zy)ÚResourceErrorN)Ú__name__Ú
__module__Ú__qualname__© ó    úS/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/fontTools/misc/macRes.pyr
   r
   	   s   „ Ør   r
   c                   ó®   — e Zd ZdZd„ Zed„ «       Zed„ «       Zd„ Zdd„Z	d„ Z
d	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zed„ «       Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zy)ÚResourceReaderaÞ  Reader for Mac OS resource forks.

    Parses a resource fork and returns resources according to their type.
    If run on OS X, this will open the resource fork in the filesystem.
    Otherwise, it will open the file itself and attempt to read it as
    though it were a resource fork.

    The returned object can be indexed by type and iterated over,
    returning in each case a list of py:class:`Resource` objects
    representing all the resources of a certain type.

    c                 ó  — t        «       | _        t        |d«      r|| _        n(	 | j	                  |«      | _        | j                  «        y| j                  «        y# t        t        f$ r | j                  |«      | _        Y Œ8w xY w)z®Open a file

        Args:
                fileOrPath: Either an object supporting a ``read`` method, an
                        ``os.PathLike`` object, or a string.
        ÚreadN)	r   Ú
_resourcesÚhasattrÚfileÚopenResourceForkÚ	_readFiler
   ÚIOErrorÚopenDataFork)ÚselfÚ
fileOrPaths     r   Ú__init__zResourceReader.__init__   sv   € ô &›-ˆŒÜ�:˜vÔ&Ø"ˆD�Ið:à ×1Ñ1°*Ó=�”	Ø—‘Ô Øð 	�‰Õøô "¤7Ð+ò :à ×-Ñ-¨jÓ9�–	ð:ús   ¥&A Á%BÂBc                 óÊ   — t        | d«      r| j                  «       } t        | dz   d«      5 }|j                  «       }d d d «       t	        «      }| |_        |S # 1 sw Y   ŒxY w)NÚ
__fspath__z/..namedfork/rsrcÚrb)r   r    Úopenr   r   Úname)ÚpathÚresforkÚdataÚinfiles       r   r   zResourceReader.openResourceFork0   s_   € ä�4˜Ô&Ø—?‘?Ó$ˆDÜ�$Ð,Ñ,¨dÓ3ð 	"°wØ—<‘<“>ˆD÷	"ä˜“ˆØˆŒØˆ÷		"ð 	"ús   ¬AÁA"c                 óŒ   — t        | d«      5 }|j                  «       }d d d «       t        «      }| |_        |S # 1 sw Y   ŒxY w)Nr!   )r"   r   r   r#   )r$   Údataforkr&   r'   s       r   r   zResourceReader.openDataFork:   sC   € ä�$˜Óð 	# Ø—=‘=“?ˆD÷	#ä˜“ˆØˆŒØˆ÷		#ð 	#ús	   �:ºAc                 óD   — | j                  «        | j                  «        y ©N)Ú_readHeaderAndMapÚ_readTypeList©r   s    r   r   zResourceReader._readFileB   s   € Ø×ÑÔ Ø×ÑÕr   Nc                 ó\  — |�D	 | j                   j                  |«       | j                   j	                  «       |k7  rt        d«      ‚	 | j                   j                  |«      }t        |«      |k7  rt        d«      ‚|S # t        $ r t        d«      ‚w xY w# t        $ r t        d«      ‚w xY w)Nz-Failed to seek offset ('offset' is too large)z#Failed to seek offset (reached EOF)z.Cannot read resource ('numBytes' is too large)z&Cannot read resource (not enough data))r   ÚseekÚOverflowErrorr
   Útellr   Úlen)r   ÚnumBytesÚoffsetr&   s       r   Ú_readzResourceReader._readF   s³   € ØÐðUØ—	‘	—‘˜vÔ&ð �y‰y�~‰~Ó 6Ò)Ü#Ð$IÓJÐJð	RØ—9‘9—>‘> (Ó+ˆDô ˆt‹9˜Ò ÜÐ HÓIÐIØˆøô !ò UÜ#Ð$SÓTÐTðUûô ò 	RÜÐ PÓQÐQð	Rús   „A> ÁB Á>BÂB+c                 ó’  — | j                   j                  d«       | j                  t        «      }t	        j
                  t        || «       | j                  dz   }| j                  t        |«      }t	        j
                  t        || «       | j                  | j                  z   | _        | j                  | j                  z   | _        y )Nr   é   )r   r0   r6   ÚResourceForkHeaderSizer   ÚunpackÚResourceForkHeaderÚ	mapOffsetÚResourceMapHeaderSizeÚResourceMapHeaderÚtypeListOffsetÚabsTypeListOffsetÚnameListOffsetÚabsNameListOffset)r   Ú
headerDatar<   ÚresourceMapDatas       r   r,   z ResourceReader._readHeaderAndMapV   s�   € Ø�	‰	�‰�qÔØ—Z‘ZÔ 6Ó7ˆ
Ü�‰Ô)¨:°tÔ<à—N‘N RÑ'ˆ	ØŸ*™*Ô%:¸IÓFˆÜ�‰Ô(¨/¸4Ô@Ø!%§¡°$×2EÑ2EÑ!EˆÔØ!%§¡°$×2EÑ2EÑ!EˆÕr   c                 óº  — | j                   }| j                  d|«      }t        j                  d|«      \  | _        |dz   }t        | j                  dz   «      D ]€  }|t        |z  z   }| j                  t        |«      }t        j                  t        |«      }t        |d   d¬«      }||d   z   }	|d   dz   }
| j                  ||	|
«      }|| j                  |<   Œ‚ y )	Né   z>Hé   Útypeú	mac-roman©ÚencodingÚrefListOffsetÚnumRes)r@   r6   Ústructr:   ÚnumTypesÚrangeÚResourceTypeItemSizer   ÚResourceTypeItemr   Ú_readReferenceListr   )r   r@   ÚnumTypesDataÚabsTypeListOffset2ÚiÚresTypeItemOffsetÚresTypeItemDataÚitemÚresTyperL   rM   Ú	resourcess               r   r-   zResourceReader._readTypeLista   sß   € Ø ×2Ñ2ÐØ—z‘z !Ð%6Ó7ˆÜ!Ÿ=™=¨¨|Ó<ÑˆŒØ.°Ñ2ÐÜ�t—}‘} qÑ(Ó)ò 	1ˆAØ 2Ô5IÈAÑ5MÑ MÐØ"Ÿj™jÔ)=Ð?PÓQˆOÜ—>‘>Ô"2°OÓDˆDÜ˜D ™L°;Ô?ˆGØ-°°_Ñ0EÑEˆMØ˜(‘^ aÑ'ˆFØ×/Ñ/°¸ÈÓOˆIØ'0ˆD�O‰O˜GÒ$ñ	1r   c                 óÊ   — g }t        |«      D ]R  }|t        |z  z   }| j                  t        |«      }t        |«      }|j	                  || «       |j                  |«       ŒT |S r+   )rP   ÚResourceRefItemSizer6   ÚResourceÚ	decompileÚappend)	r   rZ   rL   rM   r[   rV   Ú	refOffsetÚrefDataÚress	            r   rS   z!ResourceReader._readReferenceListp   si   € Øˆ	Ü�v“ò 	"ˆAØ%Ô(;¸aÑ(?Ñ?ˆIØ—j‘jÔ!4°iÓ@ˆGÜ˜7Ó#ˆCØ�M‰M˜' 4Ô(Ø×Ñ˜SÕ!ð	"ð Ðr   c                 ó    — | j                   |   S r+   ©r   ©r   rZ   s     r   Ú__getitem__zResourceReader.__getitem__z   s   € Ø�‰˜wÑ'Ð'r   c                 ó   — | j                   |= y r+   re   rf   s     r   Ú__delitem__zResourceReader.__delitem__}   s   € Ø�O‰O˜GÑ$r   c                 ó"   — || j                   |<   y r+   re   )r   rZ   r[   s      r   Ú__setitem__zResourceReader.__setitem__€   s   € Ø#,ˆ�‰˜Ò r   c                 ó,   — t        | j                  «      S r+   )r3   r   r.   s    r   Ú__len__zResourceReader.__len__ƒ   s   € Ü�4—?‘?Ó#Ð#r   c                 ó,   — t        | j                  «      S r+   )Úiterr   r.   s    r   Ú__iter__zResourceReader.__iter__†   s   € Ü�D—O‘OÓ$Ð$r   c                 ó6   — | j                   j                  «       S r+   )r   Úkeysr.   s    r   rr   zResourceReader.keys‰   s   € Ø�‰×#Ñ#Ó%Ð%r   c                 óH   — t        | j                  j                  «       «      S )z6A list of the types of resources in the resource fork.)Úlistr   rr   r.   s    r   ÚtypeszResourceReader.typesŒ   s   € ô �D—O‘O×(Ñ(Ó*Ó+Ð+r   c                 ó>   — 	 t        | |   «      S # t        $ r Y yw xY w)z/Return the number of resources of a given type.r   )r3   ÚKeyErrorrf   s     r   ÚcountResourceszResourceReader.countResources‘   s(   € ð	Ü�t˜G‘}Ó%Ð%øÜò 	Ùð	ús   ‚ �	›c                 ó\   — | j                  |«      }|rt        t        d|dz   «      «      S g S )z7Returns a list of indices of resources of a given type.rG   )rx   rt   rP   )r   rZ   rM   s      r   Ú
getIndiceszResourceReader.getIndices˜   s0   € à×$Ñ$ WÓ-ˆÙÜœ˜a ¨!¡Ó,Ó-Ð-àˆIr   c                 óz   — | j                  |g «      D �cg c]  }|j                  €Œ|j                  ‘Œ c}S c c}w )z6Return list of names of all resources of a given type.)Úgetr#   )r   rZ   rc   s      r   ÚgetNameszResourceReader.getNames    s.   € à$(§H¡H¨W°bÓ$9ÖR˜S¸S¿X¹XÑ=Q�—“ÒRÐRùÒRs   •8§8c                 óT   — |dk  ry	 | |   |dz
     }|S # t         t        f$ r Y yw xY w)z‘Return resource of given type located at an index ranging from 1
        to the number of resources for that type, or None if not found.
        rG   N)rw   Ú
IndexError)r   rZ   Úindexrc   s       r   ÚgetIndResourcezResourceReader.getIndResource¤   sE   € ð �1Š9Øð	Ø�w‘- ¨¡	Ñ*ˆCð ˆ
øô œ*Ð%ò 	Ùð	ús   ˆ •'¦'c                 ór   — t        |d¬«      }| j                  |g «      D ]  }|j                  |k(  sŒ|c S  y)z:Return the named resource of given type, else return None.rI   rJ   N)r   r|   r#   )r   rZ   r#   rc   s       r   ÚgetNamedResourcezResourceReader.getNamedResource°   s>   € ä�T KÔ0ˆØ—8‘8˜G RÓ(ò 	ˆCØ�x‰x˜4ÓØ’
ð	ð r   c                 óf   — | j                   j                  s| j                   j                  «        y y r+   )r   ÚclosedÚcloser.   s    r   r†   zResourceReader.close¸   s"   € Ø�y‰y×ÒØ�I‰I�O‰OÕð  r   r+   )r   r   r   Ú__doc__r   Ústaticmethodr   r   r   r6   r,   r-   rS   rg   ri   rk   rm   rp   rr   Úpropertyru   rx   rz   r}   r�   rƒ   r†   r   r   r   r   r      sŸ   „ ñòð* ñó ðð ñó ðòóò 	Fò1òò(ò%ò-ò$ò%ò&ð ñ,ó ð,òòòSò
òór   r   c                   ó    — e Zd ZdZ	 dd„Zd„ Zy)r^   zßRepresents a resource stored within a resource fork.

    Attributes:
            type: resource type.
            data: resource data.
            id: ID.
            name: resource name.
            attr: attributes.
    Nc                 óJ   — || _         || _        || _        || _        || _        y r+   )rH   r&   Úidr#   Úattr)r   rZ   ÚresDataÚresIDÚresNameÚresAttrs         r   r   zResource.__init__È   s'   € ð ˆŒ	ØˆŒ	ØˆŒØˆŒ	Øˆ�	r   c                 óf  — t        j                  t        || «       t        j                  dt	        d| j
                  g«      «      \  | _        |j
                  | j
                  z   }t        j                  d|j                  d|«      «      \  }|j                  |«      | _        | j                  dk(  ry |j                  | j                  z   }t        j                  d|j                  d|«      «      \  }t        j                  d|z  |j                  |«      «      \  }t        |d¬	«      | _        y )
Nz>Ló    é   éÿÿÿÿÚBrG   z>%ssrI   rJ   )r   r:   ÚResourceRefItemrN   r   Ú
dataOffsetr6   r&   Ú
nameOffsetrB   r   r#   )r   rb   ÚreaderÚabsDataOffsetÚ
dataLengthÚabsNameOffsetÚ
nameLengthr#   s           r   r_   zResource.decompileÑ   sä   € Ü�‰”¨°Ô6ä#Ÿ]™]¨4´¸EÀ4Ç?Á?Ð;SÓ1TÓUÑˆŒØ×)Ñ)¨D¯O©OÑ;ˆÜŸ™ d¨F¯L©L¸¸MÓ,JÓK‰ˆØ—L‘L Ó,ˆŒ	Ø�?‰?˜bÒ ØØ×0Ñ0°4·?±?ÑBˆÜŸ™ c¨6¯<©<¸¸=Ó+IÓJ‰ˆÜ—-‘- ¨Ñ 3°V·\±\À*Ó5MÓN‰ˆÜ˜$¨Ô5ˆ�	r   )NNNNN)r   r   r   r‡   r   r_   r   r   r   r^   r^   ½   s   „ ñð MQóó6r   r^   zb
		> # big endian
		dataOffset:     L
		mapOffset:      L
		dataLen:        L
		mapLen:         L
zW
		> # big endian
		attr:              H
		typeListOffset:    H
		nameListOffset:    H
zX
		> # big endian
		type:              4s
		numRes:            H
		refListOffset:     H
z†
		> # big endian
		id:                h
		nameOffset:        h
		attr:              B
		dataOffset:        3s
		reserved:          L
)Úior   rN   ÚfontTools.miscr   ÚfontTools.misc.textToolsr   r   Úcollectionsr   Úcollections.abcr   Ú	Exceptionr
   r   Úobjectr^   r;   Úcalcsizer9   r>   r=   rR   rQ   r—   r]   r   r   r   ú<module>r§      sµ   ðÝ Û Ý "ß 5Ý #Ý *ô	�Iô 	ôm�^ô mô` 6ˆvô  6ðFÐ ð *˜×)Ñ)Ð*<Ó=Ð ðÐ ð )˜×(Ñ(Ð):Ó;Ð ðÐ ð (�w×'Ñ'Ð(8Ó9Ð ð€ð '�g×&Ñ& Ó7Ñ r   