
    ]hm                       d Z ddlmZ ddlmZmZmZmZmZm	Z	 ddl
ZddlZddlZddlZddlZddlZddlZddlmZ ddlmZ ddlZddlmZmZmZmZmZmZmZ  ej:                  e      ZdZ g d	Z!ejD                  Z"ejF                  Z#ejH                  Z$ejJ                  Z%ejL                  Z&ejN                  Z'ejP                  Z(ejR                  Z)ejT                  Z*ejV                  Z+ejX                  Z,ejZ                  Z-ej\                  Z.ej^                  Z/ej`                  Z0ejb                  Z1ejd                  Z2ejf                  Z3ejh                  Z4ejj                  Z5ejl                  Z6ejn                  Z7ddZ8dd dZ9	 	 d	 	 	 	 	 	 	 d!dZ:	 	 d	 	 	 	 	 	 	 d!dZ;	 	 d	 	 	 	 	 	 	 d"dZ<ddZ=ddZ>ddZ?d#dZ@d#dZA G d d      ZB G d d      ZC G d d      ZD G d d      ZE G d d
      ZFy)$z Firebase Cloud Messaging module.    )annotations)AnyCallableDictListOptionalcastN)http)_auth)_http_client_messaging_encoder_messaging_utils_gapic_utils_utils
exceptionsApp
_messaging)#AndroidConfigAndroidFCMOptionsAndroidNotification
APNSConfigAPNSFCMOptionsAPNSPayloadApsApsAlertBatchResponseCriticalSound	ErrorInfo
FCMOptionsLightSettingsMessageMulticastMessageNotificationQuotaExceededErrorSenderIdMismatchErrorSendResponseThirdPartyAuthErrorTopicManagementResponseUnregisteredErrorWebpushConfigWebpushFCMOptionsWebpushNotificationWebpushNotificationActionsendsend_allsend_multicast	send_eachsend_each_asyncsend_each_for_multicastsend_each_for_multicast_asyncsubscribe_to_topicunsubscribe_from_topic_MessagingServicec                @    t        j                  | t        t              S N)r   get_app_service_MESSAGING_ATTRIBUTEr7   )apps    ^/var/www/html/Kila-kolis-project/venv/lib/python3.12/site-packages/firebase_admin/messaging.py_get_messaging_servicer>   o   s    !!#';=NOO    c                8    t        |      j                  | |      S )a  Sends the given message via Firebase Cloud Messaging (FCM).

    If the ``dry_run`` mode is enabled, the message will not be actually delivered to the
    recipients. Instead, FCM performs all the usual validations and emulates the send operation.

    Args:
        message: An instance of ``messaging.Message``.
        dry_run: A boolean indicating whether to run the operation in dry run mode (optional).
        app: An App instance (optional).

    Returns:
        string: A message ID string that uniquely identifies the sent message.

    Raises:
        FirebaseError: If an error occurs while sending the message to the FCM service.
        ValueError: If the input arguments are invalid.
    )r>   r.   )messagedry_runr<   s      r=   r.   r.   r   s    $ "#&++GW==r?   r   c                8    t        |      j                  | |      S )a  Sends each message in the given list via Firebase Cloud Messaging.

    If the ``dry_run`` mode is enabled, the message will not be actually delivered to the
    recipients. Instead, FCM performs all the usual validations and emulates the send operation.

    Args:
        messages: A list of ``messaging.Message`` instances.
        dry_run: A boolean indicating whether to run the operation in dry run mode (optional).
        app: An App instance (optional).

    Returns:
        BatchResponse: A ``messaging.BatchResponse`` instance.

    Raises:
        FirebaseError: If an error occurs while sending the message to the FCM service.
        ValueError: If the input arguments are invalid.
    )r>   r1   messagesrB   r<   s      r=   r1   r1      s    , "#&007CCr?   c                T   K   t        |      j                  | |       d{   S 7 w)a  Sends each message in the given list asynchronously via Firebase Cloud Messaging.

    If the ``dry_run`` mode is enabled, the message will not be actually delivered to the
    recipients. Instead, FCM performs all the usual validations and emulates the send operation.

    Args:
        messages: A list of ``messaging.Message`` instances.
        dry_run: A boolean indicating whether to run the operation in dry run mode (optional).
        app: An App instance (optional).

    Returns:
        BatchResponse: A ``messaging.BatchResponse`` instance.

    Raises:
        FirebaseError: If an error occurs while sending the message to the FCM service.
        ValueError: If the input arguments are invalid.
    N)r>   r2   rD   s      r=   r2   r2      s&     , (,<<XwOOOOs   (&(c                ^  K   t        | t              st        d      | j                  D cg c]P  }t	        | j
                  | j                  | j                  | j                  | j                  | j                  |      R }}t        |      j                  ||       d{   S c c}w 7 	w)a  Sends the given mutlicast message to each token asynchronously via Firebase Cloud Messaging
    (FCM).

    If the ``dry_run`` mode is enabled, the message will not be actually delivered to the
    recipients. Instead, FCM performs all the usual validations and emulates the send operation.

    Args:
        multicast_message: An instance of ``messaging.MulticastMessage``.
        dry_run: A boolean indicating whether to run the operation in dry run mode (optional).
        app: An App instance (optional).

    Returns:
        BatchResponse: A ``messaging.BatchResponse`` instance.

    Raises:
        FirebaseError: If an error occurs while sending the message to the FCM service.
        ValueError: If the input arguments are invalid.
    @Message must be an instance of messaging.MulticastMessage class.datanotificationandroidwebpushapnsfcm_optionstokenN)
isinstancer"   
ValueErrortokensr!   rJ   rK   rL   rM   rN   rO   r>   r2   multicast_messagerB   r<   rP   rE   s        r=   r4   r4      s     . ')9:[\\ %++- ,% ##&33!))!))##%11 ,  - (,<<XwOOO- Ps   *B-AB& B-!B+"
B-c                B   t        | t              st        d      | j                  D cg c]P  }t	        | j
                  | j                  | j                  | j                  | j                  | j                  |      R }}t        |      j                  ||      S c c}w )a  Sends the given mutlicast message to each token via Firebase Cloud Messaging (FCM).

    If the ``dry_run`` mode is enabled, the message will not be actually delivered to the
    recipients. Instead, FCM performs all the usual validations and emulates the send operation.

    Args:
        multicast_message: An instance of ``messaging.MulticastMessage``.
        dry_run: A boolean indicating whether to run the operation in dry run mode (optional).
        app: An App instance (optional).

    Returns:
        BatchResponse: A ``messaging.BatchResponse`` instance.

    Raises:
        FirebaseError: If an error occurs while sending the message to the FCM service.
        ValueError: If the input arguments are invalid.
    rH   rI   )rQ   r"   rR   rS   r!   rJ   rK   rL   rM   rN   rO   r>   r1   rT   s        r=   r3   r3      s    $ ')9:[\\ %++- ,% ##&33!))!))##%11 ,  - "#&007CC-s   ABc                l    t        j                  dt               t        |      j	                  | |      S )a  Sends the given list of messages via Firebase Cloud Messaging as a single batch.

    If the ``dry_run`` mode is enabled, the message will not be actually delivered to the
    recipients. Instead, FCM performs all the usual validations and emulates the send operation.

    Args:
        messages: A list of ``messaging.Message`` instances.
        dry_run: A boolean indicating whether to run the operation in dry run mode (optional).
        app: An App instance (optional).

    Returns:
        BatchResponse: A ``messaging.BatchResponse`` instance.

    Raises:
        FirebaseError: If an error occurs while sending the message to the FCM service.
        ValueError: If the input arguments are invalid.

    send_all() is deprecated. Use send_each() instead.
    z2send_all() is deprecated. Use send_each() instead.)warningswarnDeprecationWarningr>   r/   rD   s      r=   r/   r/      s,    ( MMFHZ[!#&//'BBr?   c                v   t        j                  dt               t        | t              st        d      | j                  D cg c]P  }t        | j                  | j                  | j                  | j                  | j                  | j                  |      R }}t        |      j                  ||      S c c}w )a'  Sends the given mutlicast message to all tokens via Firebase Cloud Messaging (FCM).

    If the ``dry_run`` mode is enabled, the message will not be actually delivered to the
    recipients. Instead, FCM performs all the usual validations and emulates the send operation.

    Args:
        multicast_message: An instance of ``messaging.MulticastMessage``.
        dry_run: A boolean indicating whether to run the operation in dry run mode (optional).
        app: An App instance (optional).

    Returns:
        BatchResponse: A ``messaging.BatchResponse`` instance.

    Raises:
        FirebaseError: If an error occurs while sending the message to the FCM service.
        ValueError: If the input arguments are invalid.

    send_multicast() is deprecated. Use send_each_for_multicast() instead.
    zFsend_multicast() is deprecated. Use send_each_for_multicast() instead.rH   rI   )rX   rY   rZ   rQ   r"   rR   rS   r!   rJ   rK   rL   rM   rN   rO   r>   r/   rT   s        r=   r0   r0     s    ( MMZ$&')9:[\\ %++- ,% ##&33!))!))##%11 ,  - "#&//'BB-s   AB6c                :    t        |      j                  | |d      S )a4  Subscribes a list of registration tokens to an FCM topic.

    Args:
        tokens: A non-empty list of device registration tokens. List may not have more than 1000
            elements.
        topic: Name of the topic to subscribe to. May contain the ``/topics/`` prefix.
        app: An App instance (optional).

    Returns:
        TopicManagementResponse: A ``TopicManagementResponse`` instance.

    Raises:
        FirebaseError: If an error occurs while communicating with instance ID service.
        ValueError: If the input arguments are invalid.
    ziid/v1:batchAddr>   make_topic_management_requestrS   topicr<   s      r=   r5   r5   3  s$      "#&DD(* *r?   c                :    t        |      j                  | |d      S )a<  Unsubscribes a list of registration tokens from an FCM topic.

    Args:
        tokens: A non-empty list of device registration tokens. List may not have more than 1000
            elements.
        topic: Name of the topic to unsubscribe from. May contain the ``/topics/`` prefix.
        app: An App instance (optional).

    Returns:
        TopicManagementResponse: A ``TopicManagementResponse`` instance.

    Raises:
        FirebaseError: If an error occurs while communicating with instance ID service.
        ValueError: If the input arguments are invalid.
    ziid/v1:batchRemover]   r_   s      r=   r6   r6   F  s$      "#&DD+- -r?   c                  6    e Zd ZdZd Zed        Zed        Zy)r   zBAn error encountered when performing a topic management operation.c                     || _         || _        y r9   )_index_reason)selfindexreasons      r=   __init__zErrorInfo.__init__]  s    r?   c                    | j                   S )zBIndex of the registration token to which this error is related to.)rd   rf   s    r=   rg   zErrorInfo.indexa  s     {{r?   c                    | j                   S )z*String describing the nature of the error.)re   rk   s    r=   rh   zErrorInfo.reasonf       ||r?   N)__name__
__module____qualname____doc__ri   propertyrg   rh    r?   r=   r   r   Z  s2    L    r?   r   c                  F    e Zd ZdZd Zed        Zed        Zed        Zy)r(   z8The response received from a topic management operation.c                d   t        |t              rd|vrt        dj                  |            d| _        d| _        g | _        t        |d         D ]\  \  }}d|v r>| xj
                  dz  c_        | j                  j                  t        ||d                H| xj                  dz  c_        ^ y )Nresultsz*Unexpected topic management response: {0}.r   error   )
rQ   dictrR   format_success_count_failure_count_errors	enumerateappendr   )rf   resprg   results       r=   ri   z TopicManagementResponse.__init__o  s    $%$)>IPPQUVWW&tI7ME6& ##q(###IeVG_$EF##q(# 8r?   c                    | j                   S )zCNumber of tokens that were successfully subscribed or unsubscribed.r{   rk   s    r=   success_countz%TopicManagementResponse.success_count|       """r?   c                    | j                   S )zLNumber of tokens that could not be subscribed or unsubscribed due to errors.)r|   rk   s    r=   failure_countz%TopicManagementResponse.failure_count  r   r?   c                    | j                   S )z;A list of ``messaging.ErrorInfo`` objects (possibly empty).)r}   rk   s    r=   errorszTopicManagementResponse.errors  rm   r?   N)	rn   ro   rp   rq   ri   rr   r   r   r   rs   r?   r=   r(   r(   l  sF    B) # # # #  r?   r(   c                  N    e Zd ZdZddZedd       Zed	d       Zed	d       Zy)
r   z:The response received from a batch request to the FCM API.c                @    || _         t        d |D              | _        y )Nc              3  :   K   | ]  }|j                   sd   yw)rx   N)success).0r   s     r=   	<genexpr>z)BatchResponse.__init__.<locals>.<genexpr>  s     !J	T\\!	s   )
_responsessumr{   )rf   	responsess     r=   ri   zBatchResponse.__init__  s    #!!J	!JJr?   c                    | j                   S )z>A list of ``messaging.SendResponse`` objects (possibly empty).)r   rk   s    r=   r   zBatchResponse.responses       r?   c                    | j                   S r9   r   rk   s    r=   r   zBatchResponse.success_count  s    """r?   c                F    t        | j                        | j                  z
  S r9   )lenr   r   rk   s    r=   r   zBatchResponse.failure_count  s    4>>"T%7%777r?   N)r   List[SendResponse]returnNone)r   r   )r   int)	rn   ro   rp   rq   ri   rr   r   r   r   rs   r?   r=   r   r     sG    DK   # # 8 8r?   c                  F    e Zd ZdZd Zed        Zed        Zed        Zy)r&   zHThe response received from an individual batched request to the FCM API.c                T    || _         d | _        |r|j                  dd       | _        y y )Nname)
_exception_message_idget)rf   r   	exceptions      r=   ri   zSendResponse.__init__  s,    ##xx5D r?   c                    | j                   S )z9A message ID string that uniquely identifies the message.)r   rk   s    r=   
message_idzSendResponse.message_id  s     r?   c                <    | j                   duxr | j                   S )z3A boolean indicating if the request was successful.N)r   r   rk   s    r=   r   zSendResponse.success  s!     t+CDOO0CCr?   c                    | j                   S )zTA ``FirebaseError`` if an error occurs while sending the message to the FCM service.)r   rk   s    r=   r   zSendResponse.exception  r   r?   N)	rn   ro   rp   rq   ri   rr   r   r   r   rs   r?   r=   r&   r&     sH    R6     D D  r?   r&   c                  $   e Zd ZdZdZdZdZddiZ ej                         Z
eeeeedZddZed	        Zddd
ZdddZdddZddZd Zd Zd Zd Zd dZd Zd Zd!dZed        Ze	 	 	 	 	 	 	 	 d"d       Z ed        Z!e	 	 	 	 d#d       Z"y)$r7   zKService class that implements Firebase Cloud Messaging (FCM) functionality.z8https://fcm.googleapis.com/v1/projects/{0}/messages:sendz https://fcm.googleapis.com/batchzhttps://iid.googleapis.comaccess_token_authtrue)APNS_AUTH_ERRORQUOTA_EXCEEDEDSENDER_ID_MISMATCHTHIRD_PARTY_AUTH_ERRORUNREGISTEREDc                    |j                   }|st        d      t        j                  j	                  |      | _        ddj	                  t        j                        d| _        |j                  j                  dt        j                        }|j                  j                         | _        t        j                   | j                  |      | _        t        j$                  | j                  |      | _        t(        j*                  | _        y )NzProject ID is required to access Cloud Messaging service. Either set the projectId option, or use service account credentials. Alternatively, set the GOOGLE_CLOUD_PROJECT environment variable.2zfire-admin-python/{0})zX-GOOG-API-FORMAT-VERSIONzX-FIREBASE-CLIENThttpTimeout)
credentialtimeout)
project_idrR   r7   FCM_URLrz   _fcm_urlfirebase_admin__version___fcm_headersoptionsr   r   DEFAULT_TIMEOUT_SECONDSr   get_credential_credentialJsonHttpClient_clientHttpxAsyncClient_async_clientr   authorized_http_build_transport)rf   r<   r   r   s       r=   ri   z_MessagingService.__init__  s    ^^
=> > *1188D),!8!?!?@Z@Z![
 ++//-1U1UV>>88:#22d>N>NX_`)::'': % 5 5r?   c                n    t        |t              st        d      | j                  j	                  |      S )Nz7Message must be an instance of messaging.Message class.)rQ   r!   rR   JSON_ENCODERdefault)clsrA   s     r=   encode_messagez _MessagingService.encode_message  s/    '7+VWW''00r?   c                    | j                  ||      }	 | j                  j                  d| j                  | j                  |      }t        t        |d         S # t        j                  j                  $ r}| j                  |      d}~ww xY w)z2Sends the given message to FCM via the FCM v1 API.posturlheadersjsonr   N)_message_datar   bodyr   r   r	   strrequestsr   RequestException_handle_fcm_error)rf   rA   rB   rJ   r   rw   s         r=   r.   z_MessagingService.send  s    !!'73
	+<<$$MM))	 % D T&\** ""33 	0((//	0s   3A B7BBc                
    t        |t              st        d      t        |      dkD  rt        d       fd}|D cg c]  } j	                  ||       }}	 t
        j                  j                  t        |            5 }|j                  ||      D cg c]  }| }}t        |      cddd       S c c}w c c}w # 1 sw Y   yxY w# t        $ r+}	t        j                  dj                  |	      |	      d}	~	ww xY w)	3Sends the given messages to FCM via the FCM v1 API.7messages must be a list of messaging.Message instances.  1messages must not contain more than 500 elements.c                   	 j                   j                  dj                  j                  |       }t	        |d       S # t
        j                  j                  $ r&}t	        d j                  |            cY d }~S d }~ww xY wNr   r   )r   )r   r   )	r   r   r   r   r&   r   r   r   r   rJ   r   r   rf   s      r=   	send_dataz._MessagingService.send_each.<locals>.send_data  s    	:||(( --	 )  $DD99 &&77 \#9O9OPY9Z[[\s   3A B B;BB)max_workersN4Unknown error while making remote service calls: {0}rA   cause)rQ   listrR   r   r   
concurrentfuturesThreadPoolExecutormapr   	Exceptionr   UnknownErrorrz   )
rf   rE   rB   r   rA   message_dataexecutorr   r   rw   s
   `         r=   r1   z_MessagingService.send_each  s    (D)VWWx=3PQQ
	: MUUH**7G<HU	##663|CT6UYa.6ll9l.ST.SdT.S	T$Y/ VU V U VU  	))NUUV[\ 	sM   B8)C C	B="C.	C =CCC C 	D&C==Dc                   K   t        |t              st        d      t        |      dkD  rt        d       fd}|D cg c]  } j	                  ||       }}	 t        j                  |D cg c]
  } ||       c}  d{   }t        |      S c c}w c c}w 7 # t        $ r+}t        j                  dj                  |      |      d}~ww xY ww)r   r   r   r   c                  K   	 j                   j                  dj                  j                  |        d {   }t	        |j                         d       S 7 # t        j                  $ r&}t	        d j                  |            cY d }~S d }~wt        j                  j                  $ r&}t	        d j                  |            cY d }~S d }~ww xY wwr   )r   requestr   r   r&   r   httpx	HTTPError_handle_fcm_httpx_errorr   r   r   r   r   s      r=   r   z4_MessagingService.send_each_async.<locals>.send_data  s     A!//77 --	 8   $DIIK4@@
 ?? b#9U9UV_9`aa&&77 \#9O9OPY9Z[[\s\   C6A AA  CA C0BCC C1CCCCCNr   r   )rQ   r   rR   r   r   asynciogatherr   r   r   r   rz   )rf   rE   rB   r   rA   r   r   rw   s   `       r=   r2   z!_MessagingService.send_each_async  s     (D)VWWx=3PQQ	A MUUH**7G<HU	%nnQ].^Q]gy/AQ].^__I ++ V.^_ 	))NUUV[\ 	sS   >CBCB" 0B?B" B B" CB" "	C+&CCCc           	     f   
 t        |t              st        d      t        |      dkD  rt        d      g 

 fd}t	        j
                  |t        j                        } j                   j                        }|D ]q  }t        j                   j                  ||            }t	        j                  | j                   j                  d| j                         }|j#                  |       s 	 |j%                          t'        
      S # t(        $ r}	 j+                  |	      d}	~	ww xY w)	z2Sends the given messages to FCM via the batch API.r   r   r   c                j    d }|rj                  |      }t        ||      }j                  |       y r9   )_handle_batch_errorr&   r   )_responserw   r   send_responser   rf   s        r=   batch_callbackz2_MessagingService.send_all.<locals>.batch_callback8  s5    I 44U;	(9=M]+r?   )callback	batch_uriPOST)r
   postprocurimethodr   r   N)rQ   r   rR   r   r
   BatchHttpRequestr7   FCM_BATCH_URLr   r   r   dumpsr   HttpRequest	_postprocr   r   addexecuter   r   r   )rf   rE   rB   r   batch	transportrA   r   reqrw   r   s   `         @r=   r/   z_MessagingService.send_all/  s   (D)VWWx=3PQQ		, %%#/@/N/NP))$*:*:;	G::d00'BCD""MM))C IIcN  	,MMO !++  	2**511	2s   6D 	D0D++D0c                p   t        |t              r|g}t        |t              r|st        d      |D cg c]  }t        |t              r|r| }}|rt        d      t        |t              r|st        d      |j	                  d      sdj                  |      }||d}dj                  t        j                  |      }	 | j                  j                  d||t        j                  	      }t        |      S c c}w # t        j                  j                  $ r}	| j                  |	      d
}	~	ww xY w)z;Invokes the IID service for topic management functionality.z7Tokens must be a string or a non-empty list of strings.z!Tokens must be non-empty strings.z!Topic must be a non-empty string.z/topics/z/topics/{0})toregistration_tokensz{0}/{1}r   )r   r   r   N)rQ   r   r   rR   
startswithrz   r7   IID_URLr   r   IID_HEADERSr(   r   r   r   _handle_iid_error)
rf   rS   r`   	operationtinvalid_strrJ   r   r   rw   s
             r=   r^   z/_MessagingService.make_topic_management_requestU  s)   fc"XF&$'vVWW"(L&Q
1c0B!q&L@AA%%U@AA
+!((/E#)
 088)D
	1<<$$)55	 % D +400/ M( ""33 	0((//	0s#   C=C=-D D5D00D5c                B    dt         j                  |      i}|rd|d<   |S )NrA   Tvalidate_only)r7   r   )rf   rA   rB   rJ   s       r=   r   z_MessagingService._message_datat  s*    ,;;GDE$(D!r?   c                H    t        j                  |j                               S )z'Handle response from batch API request.)r   loadsdecode)rf   r   r   s      r=   r  z_MessagingService._postprocz  s     zz$++-((r?   c                J    t        j                  |t        j                        S z)Handles errors received from the FCM API.)r   #handle_platform_error_from_requestsr7   _build_fcm_error_requestsrf   rw   s     r=   r   z#_MessagingService._handle_fcm_error  s#    99$>>@ 	@r?   c                J    t        j                  |t        j                        S r  )r    handle_platform_error_from_httpxr7   _build_fcm_error_httpxr  s     r=   r   z)_MessagingService._handle_fcm_httpx_error  s!    66$;;= 	=r?   c                   |j                   t        j                  |      i }	 |j                   j                         }t	        |t
              r|}|j                  d      }d}|rdj                  |      }nHdj                  |j                   j                  |j                   j                  j                               }t        j                  ||      S # t        $ r Y w xY w)z1Handles errors received from the Instance ID API.Nrw   z(Error while calling the IID service: {0}z4Unexpected HTTP response with status: {0}; body: {1})r   r   handle_requests_errorr   rQ   ry   rR   r   rz   status_codecontentr  )rf   rw   rJ   parsed_bodycodemsgs         r=   r  z#_MessagingService._handle_iid_error  s    >>!..u55	..--/K+t,"
 xx <CCDICHOO**ENN,B,B,I,I,KMC ++E377  		s   ,C 	C"!C"c                J    t        j                  |t        j                        S )zMHandles errors received from the googleapiclient while making batch requests.)r   *handle_platform_error_from_googleapiclientr7    _build_fcm_error_googleapiclientr  s     r=   r   z%_MessagingService._handle_batch_error  s#    FF$EEG 	Gr?   c                ^    t        j                  | j                  j                                y r9   )r   runr   acloserk   s    r=   closez_MessagingService.close  s    D&&--/0r?   c                V    | j                  |      }|r ||||j                        S dS zfParses an error response from the FCM API and creates a FCM-specific exception if
        appropriate.r   http_responseN)_build_fcm_errorr   r   rw   rA   
error_dictexc_types        r=   r  z+_MessagingService._build_fcm_error_requests  s/     ''
3OWxuENNKa]aar?   c                    | j                  |      }t        |t        j                        r|r ||||j                        S dS |r
 |||      S dS )zkParses a httpx error response from the FCM API and creates a FCM-specific exception if
        appropriate.r1  N)r   )r3  rQ   r   HTTPStatusErrorr   r4  s        r=   r   z(_MessagingService._build_fcm_error_httpx  s`     ''
3eU223GO uENND ZUYZ19xu-CtCr?   c                B    | j                  |      }|r ||||      S dS r0  )r3  )r   rw   rA   r5  r2  r6  s         r=   r*  z2_MessagingService._build_fcm_error_googleapiclient  s+     ''
3NVxuMJ`\``r?   c                    |syd}|j                  dg       D ])  }|j                  d      dk(  s|j                  d      } n |rt        j                  j                  |      S dS )zNParses an error response to determine the appropriate FCM-specific error type.Ndetailsz@typez3type.googleapis.com/google.firebase.fcm.v1.FcmError	errorCode)r   r7   FCM_ERROR_TYPES)r   r5  fcm_codedetails       r=   r3  z"_MessagingService._build_fcm_error  sk      nnY3Fzz'"&[[!::k2 4 CK 0044X>TPTTr?   N)r<   r   r   r   )F)rA   r!   rB   boolr   r   )rE   List[Message]rB   r@  r   r   )T)rw   httpx.HTTPErrorr   zexceptions.FirebaseError)r   r   )rw   rB  rA   r   r5  Optional[Dict[str, Any]]r   z"Optional[exceptions.FirebaseError])r5  rC  r   z1Optional[Callable[..., exceptions.FirebaseError]])#rn   ro   rp   rq   r   r  r  r  r   MessageEncoderr   r'   r$   r%   r)   r=  ri   classmethodr   r.   r1   r2   r/   r^   r   r  r   r   r  r   r.  r  r   r*  r3  rs   r?   r=   r7   r7     s6   UHG6M*G&/K4%446L /,3"5)O6& 1 1
+:@$,L1>)
@
=
80G
1 b b D"D D 1	D
 0D D a a U0U ?U Ur?   )r<   Optional[App]r   r7   )FN)rA   r!   rB   r@  r<   rF  r   r   )rE   rA  rB   r@  r<   rF  r   r   )rU   r"   rB   r@  r<   rF  r   r   r9   )Grq   
__future__r   typingr   r   r   r   r   r	   concurrent.futuresr   r   rX   r   loggingr   r   googleapiclientr
   r   r   r   r   r   r   r   r   r   	getLoggerrn   loggerr;   __all__r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r*   r+   r,   r-   r$   r%   r'   r)   r>   r.   r1   r2   r4   r3   r/   r0   r5   r6   r   r(   r   r&   r7   rs   r?   r=   <module>rO     sb   ' " < <          !    
		8	$# %P !..$66 &:: ((
!00**$$ ..((
 ..

$
$%66 ,, ..$66 &:: ,FF %88 (>> &:: $66 P>, !DDD D 
	D4 !PPP P 
	P4 !"P+"P"P "P 
	"PHD>C.!CF*&-( $ @8 8* 0[U [Ur?   