Ë
    ?—ÖjÏ  ã                   ój  — d dl Z d dlZd dlZd dlmZ d dlmZmZ d dlm	Z	  ej                  e«      Zee   dz  Zeeef   eeeef      z  dz  ZdZ G d„ ded¬	«      Z G d
„ de j(                  «      Z G d„ d«      Z e«       Zdedef   dedef   fd„Ze	 	 	 	 	 ddededededededefd„«       Zy)é    N)ÚCallable)ÚAnyÚ	TypedDict)Úmock_randomÚ_custom_id_c                   ó,   — e Zd ZU ded<   eed<   eed<   y)ÚIdSourceContextÚResourceIdentifierÚresource_identifierÚtagsÚexisting_idsN)Ú__name__Ú
__module__Ú__qualname__Ú__annotations__ÚTagsÚExistingIds© ó    úX/var/www/photos/backend/venv/lib/python3.12/site-packages/moto/utilities/id_generator.pyr	   r	      s   … Ø-Ó-Ø
ƒJØÔr   r	   F)Útotalc                   ó�   — e Zd ZU dZeed<   eed<   dededefd„Zej                  dd	e	d
e
defd„«       Zedefd„«       Zdefd„Zy)r
   av  
    Base class for resource identifiers. When implementing a new resource, it is important to set
    the service and resource as they will be used to create the unique identifier for that resource.

    It is recommended to implement the `generate` method using functions decorated with `@moto_id`.
    This will ensure that your resource can be assigned a custom id.
    ÚserviceÚresourceÚ
account_idÚregionÚnamec                 ó6   — || _         || _        |xs d| _        y )NÚ )r   r   r   )Úselfr   r   r   s       r   Ú__init__zResourceIdentifier.__init__$   s   € Ø$ˆŒØˆŒØ’J˜Bˆ�	r   Nr   r   Úreturnc                  ó   — y)z Method to generate a resource idNr   )r    r   r   s      r   ÚgeneratezResourceIdentifier.generate)   s   � r   c                 ó’   — dj                  | j                  | j                  | j                  | j                  | j
                  g«      S )Nú.)Újoinr   r   r   r   r   ©r    s    r   Úunique_identifierz$ResourceIdentifier.unique_identifier-   s5   € à�x‰xØ�_‰_˜dŸk™k¨4¯<©<¸¿¹ÈÏ	É	ÐRó
ð 	
r   c                 ó   — | j                   S ©N)r)   r(   s    r   Ú__str__zResourceIdentifier.__str__3   s   € Ø×%Ñ%Ð%r   ©NN)r   r   r   Ú__doc__Ústrr   r!   ÚabcÚabstractmethodr   r   r$   Úpropertyr)   r,   r   r   r   r
   r
      sƒ   … ñð ƒLØƒMð 3ð °ð ¸3ó ð
 	×Ññ/ [ð /¸tð /Èsò /ó ð/ð ð
 3ò 
ó ð
ð
&˜ô &r   r
   c                   ó  — e Zd ZU dZeeef   ed<   eee	gedz  f      ed<   e
j                  ed<   dd„Zdededz  fd	„Zded
eddfd„Zdeddfd„Zdee	gedz  f   ddfd„Zede	dedz  fd„«       Zde	dedz  fd„Zde	dedz  fd„Zy)ÚMotoIdManagerzoclass to manage custom ids. Do not create instance and instead
    use the `id_manager` instance created below.Ú_custom_idsNÚ_id_sourcesÚ_lockr"   c                 ó¾   — i | _         t        j                  «       | _        g | _        | j                  | j                  «       | j                  | j                  «       y r+   )r5   Ú	threadingÚRLockr7   r6   Úadd_id_sourceÚget_id_from_tagsÚget_custom_id_from_contextr(   s    r   r!   zMotoIdManager.__init__@   sH   € ØˆÔÜ—_‘_Ó&ˆŒ
ØˆÔà×Ñ˜4×0Ñ0Ô1Ø×Ñ˜4×:Ñ:Õ;r   r   c                 óL   — | j                   j                  |j                  «      S r+   )r5   Úgetr)   ©r    r   s     r   Úget_custom_idzMotoIdManager.get_custom_idH   s"   € ð ×Ñ×#Ñ#Ð$7×$IÑ$IÓJÐJr   Ú	custom_idc                 ó’   — |j                   sy | j                  5  || j                  |j                  <   d d d «       y # 1 sw Y   y xY wr+   )r   r7   r5   r)   )r    r   rB   s      r   Úset_custom_idzMotoIdManager.set_custom_idM   sG   € ð #×'Ò'ØØ�Z‰Zñ 	PØFOˆD×ÑÐ0×BÑBÑC÷	P÷ 	Pñ 	Pús	   š=½Ac                 ó’   — | j                   5  | j                  j                  |j                  d «       d d d «       y # 1 sw Y   y xY wr+   )r7   r5   Úpopr)   r@   s     r   Úunset_custom_idzMotoIdManager.unset_custom_idV   s?   € à�Z‰Zñ 	NØ×Ñ× Ñ Ð!4×!FÑ!FÈÔM÷	N÷ 	Nñ 	Nús	   �'=½AÚ	id_sourcec                 ó:   — | j                   j                  |«       y r+   )r6   Úappend)r    rH   s     r   r;   zMotoIdManager.add_id_source[   s   € Ø×Ñ×Ñ 	Õ*r   Úid_source_contextc                 ó¼   — | j                  d«      x}sy t        |t        «      r|j                  t        «      S t        |t        «      rt        d„ |D «       d «      S y )Nr   c              3   ón   K  — | ]-  }|j                  d «      t        k(  r|j                  d«      –— Œ/ y­w)ÚKeyÚValueN)r?   ÚTAG_KEY_CUSTOM_ID)Ú.0Útags     r   ú	<genexpr>z1MotoIdManager.get_id_from_tags.<locals>.<genexpr>h   s2   è ø€ ò àØ—w‘w˜u“~Ô):Ò:ð —G‘G˜G×$ñùs   ‚35)r?   Ú
isinstanceÚdictrP   ÚlistÚnext)rK   r   s     r   r<   zMotoIdManager.get_id_from_tags^   sc   € à)×-Ñ-¨fÓ5Ð5�Ð5Øä�dœDÔ!Ø—8‘8Ô-Ó.Ð.ä�dœDÔ!Üñà#ôð
 óð ð "r   c                 óL   — |j                  d«      x}r| j                  |«      S y )Nr   )r?   rA   )r    rK   r   s      r   r=   z(MotoIdManager.get_custom_id_from_contextp   s1   € ð #4×"7Ñ"7Ð8MÓ"NÐNÐÐNØ×%Ñ%Ð&9Ó:Ð:Ør   c                 óÂ   — |j                  d«      xs g }| j                  D ];  } ||«      x}sŒ||v r't        j                  d||j                  d«      «       Œ9|c S  y )Nr   zHFound id %s for resource %s, but a resource already exists with this id.r   )r?   r6   ÚlogÚdebug)r    rK   r   rH   Úfound_ids        r   Úfind_id_from_sourcesz"MotoIdManager.find_id_from_sourcesx   sr   € Ø(×,Ñ,¨^Ó<ÒBÀˆØ×)Ñ)ò 		$ˆIÙ$Ð%6Ó7Ð7ˆxÑ7Ø˜|Ñ+Ü—I‘IØbØ Ø)×-Ñ-Ð.CÓDõð $’Oð		$ð r   )r"   N)r   r   r   r.   rU   r/   r   rV   r   r	   r9   r:   r!   r
   rA   rD   rG   r;   Ústaticmethodr<   r=   r]   r   r   r   r4   r4   7   s  … ñ4ð �c˜3�h‘ÓØ�h Ð0°#¸±*Ð<Ñ=Ñ>Ó>à�?‰?Óó<ðKÐ1Cð KÈÈdÉ
ó Kð
PØ#5ðPØBEðPà	óPðNÐ3Eð NÈ$ó Nð
+ x°Ð0AÀ3ÈÁ:Ð0MÑ'Nð +ÐSWó +ð ð¨Oð ÀÀdÁ
ò ó ðð"Ø!0ðà	ˆt‰óð°oð È#ÐPTÉ*ô r   r4   Úfn.r"   c                 óp   ‡ — 	 	 ddt         dt        dt        dt        t        t
        f   dt        f
ˆ fd„}|S )aŒ  
    Decorator for helping in creation of static ids.

    The decorated function should accept the following parameters

    :param resource_identifier
    :param existing_ids
        If provided, we will omit returning a custom id if it is already on the list
    :param tags
        If provided will look for a tag named `_custom_id_`. This will take precedence over registered custom ids
    r   r   r   Úkwargsr"   c                 ój   •— | r%t         j                  t        | ||¬«      «      x}r|S  ‰d| ||dœ|¤ŽS )N)r   r   r   r   )Úmoto_id_managerr]   r	   )r   r   r   ra   r\   r_   s        €r   Ú_wrapperzmoto_id.<locals>._wrapper˜   s_   ø€ ñ Ü'×<Ñ<ÜØ(;Ø!-Øôóð ˆHð ð ˆOáð 
Ø 3Ø%Øñ
ð ñ	
ð 	
r   r-   )r
   r   r   rU   r/   r   )r_   rd   s   ` r   Úmoto_idre   ‹   sM   ø€ ð %)Øñ
Ü/ð
ä!ð
ô ð
ô ”sœC�x‘.ð	
ô
 
õ
ð0 €Or   r   r   r   ÚlengthÚinclude_digitsÚ
lower_casec                 ó0   — t        j                  |||«      S r+   )r   Úget_random_string)r   r   r   rf   rg   rh   s         r   Úgenerate_str_idrk   ³   s   € ô ×(Ñ(¨°ÀÓLÐLr   )NNé   TF)r0   Úloggingr9   Úcollections.abcr   Útypingr   r   Úmoto.moto_api._internalr   Ú	getLoggerr   rZ   rV   r/   r   rU   r   rP   r	   ÚABCr
   r4   rc   re   ÚintÚboolrk   r   r   r   ú<module>ru      s-  ðÛ 
Û Û Ý $ß !å /à€g×Ñ˜Ó!€à�3‰i˜$Ñ€ØˆC�ˆH�~˜˜T # s (™^Ñ,Ñ,¨tÑ3€ð "Ð ô�i uõ ô&˜Ÿ™ô &÷>Nñ Nñb  “/€ð%�˜˜c˜Ñ"ð % x°°S°Ñ'9ó %ðP 	ð !%ØØØØñMØ+ðMàðMð ðMð ð	Mð
 ðMð ðMð 	òMó 	ñMr   