Ë
    R/jç  ã                  ó    — d Z ddlmZ ddlZddlmZ ddlmZ ddlm	Z	m
Z
 dd	lmZmZmZmZ ej                   Zerdd
lmZ eZeZ G d„ d«      Zy)a‡  Multicast DNS Service Discovery for Python, v0.14-wmcbrine
Copyright 2003 Paul Scott-Murphy, 2014 William McBrine

This module provides a framework for the use of DNS Service Discovery
using IP multicast.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
é    )ÚannotationsN)Údeque)ÚTYPE_CHECKINGé   )Úcurrent_time_millisÚmillis_to_secondsé   )ÚMULTICAST_DELAY_RANDOM_INTERVALÚAnswerGroupÚ_AnswerWithAdditionalsTypeÚ$construct_outgoing_multicast_answers)ÚZeroconfc                  ó4   — e Zd ZdZdZdd„Zd	d„Zd
d„Zdd„Zy)ÚMulticastOutgoingQueuez8An outgoing queue used to aggregate multicast responses.)Ú_additional_delayÚ_aggregation_delayÚ_multicast_delay_random_maxÚ_multicast_delay_random_minÚqueueÚzcc                ó„   — || _         t        «       | _        t        d   | _        t        d   | _        || _        || _        y )Nr   r	   )r   r   r   r
   r   r   r   r   )ÚselfÚzeroconfÚadditional_delayÚmax_aggregation_delays       ú]/home/josh/.local/lib/python3.12/site-packages/zeroconf/_handlers/multicast_outgoing_queue.pyÚ__init__zMulticastOutgoingQueue.__init__:   s?   € ØˆŒÜ).«ˆŒ
ô ,KÈ1Ñ+MˆÔ(Ü+JÈ1Ñ+MˆÔ(Ø!1ˆÔØ"7ˆÕó    c                ó:  — | j                   j                  }t        r|€J ‚t        | j                  | j
                  «      }|| j                  z   }||z   }|| j                  z   | j                  z   }t        | j                  «      r:| j                  d   }||j                  k  rR|j                  j                  |«       y|j                  |j                  «       t        |«      z   | j                   «       | j                  j#                  t%        |||«      «       y)z>Add a group of answers with additionals to the outgoing queue.Néÿÿÿÿ)r   Úloopr   ÚRAND_INTr   r   r   r   Úlenr   Ú
send_afterÚanswersÚupdateÚcall_atÚtimer   Úasync_readyÚappendr   )	r   Únowr%   r!   Ú
random_intÚrandom_delayr$   Úsend_beforeÚ
last_groups	            r   Ú	async_addz MulticastOutgoingQueue.async_addE   sê   € à�w‰w�|‰|ˆÝØÐ#Ð#Ð#Ü˜d×>Ñ>À×@`Ñ@`Óaˆ
Ø! D×$:Ñ$:Ñ:ˆØ˜<Ñ'ˆ
Ø˜D×3Ñ3Ñ3°d×6LÑ6LÑLˆÜˆt�z‰zŒ?ð
 Ÿ™ B™ˆJØ˜Z×2Ñ2Ò2Ø×"Ñ"×)Ñ)¨'Ô2Øà�L‰L˜Ÿ™›Ô'8¸Ó'FÑFÈ×HXÑHXÔYØ�
‰
×Ñœ+ j°+¸wÓGÕHr   c                ól   — | j                   D ]%  }|D ]  }|j                  j                  |d«       Œ  Œ' y)z0Remove a set of answers from the outgoing queue.N)r   r%   Úpop)r   r%   ÚpendingÚrecords       r   Ú_remove_answers_from_queuez1MulticastOutgoingQueue._remove_answers_from_queue[   s8   € à—z‘zò 	2ˆGØ!ò 2�Ø—‘×#Ñ# F¨DÕ1ñ2ñ	2r   c                ó¼  — | j                   }|j                  }t        r|€J ‚t        «       }t	        | j
                  «      dkD  rm| j
                  d   j                  |kD  rQ|j                  |j                  «       t        | j
                  d   j                  |z
  «      z   | j                  «       yi }t	        | j
                  «      r�| j
                  d   j                  |k  re|j                  | j
                  j                  «       j                  «       t	        | j
                  «      r| j
                  d   j                  |k  rŒet	        | j
                  «      rP|j                  |j                  «       t        | j
                  d   j                  |z
  «      z   | j                  «       |r,| j                  |«       |j!                  t#        |«      «       yy)z,Process anything in the queue that is ready.Nr	   r   )r   r!   r   r   r#   r   r.   r'   r(   r   r)   r$   r&   Úpopleftr%   r5   Ú
async_sendr   )r   r   r!   r+   r%   s        r   r)   z"MulticastOutgoingQueue.async_readya   sn  € à�W‰WˆØ�w‰wˆÝØÐ#Ð#Ð#Ü!Ó#ˆäˆt�z‰z‹?˜QÒ 4§:¡:¨a¡=×#<Ñ#<¸sÒ#Bð �L‰LØ—	‘	“Ô/°·
±
¸1±×0IÑ0IÈCÑ0OÓPÑPØ× Ñ ôð à.0ˆä�$—*‘*Œo $§*¡*¨Q¡-×":Ñ":¸cÒ"AØ�N‰N˜4Ÿ:™:×-Ñ-Ó/×7Ñ7Ô8ô �$—*‘*Œo $§*¡*¨Q¡-×":Ñ":¸cÓ"Aô ˆt�z‰zŒ?ð �L‰LØ—	‘	“Ô/°·
±
¸1±×0HÑ0HÈ3Ñ0NÓOÑOØ× Ñ ôñ
 à×+Ñ+¨GÔ4Ø�M‰MÔ>¸wÓGÕHð r   N)r   r   r   Ú_intr   r9   ÚreturnÚNone)r+   Ú_floatr%   r   r:   r;   )r%   r   r:   r;   )r:   r;   )	Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   r0   r5   r)   © r   r   r   r   .   s"   „ ÙBð€Ió	8óIó,2ô!Ir   r   )r@   Ú
__future__r   ÚrandomÚcollectionsr   Útypingr   Ú_utils.timer   r   r%   r
   r   r   r   Úrandintr"   Ú_corer   Úfloatr<   Úintr9   r   rB   r   r   ú<module>rL      sN   ðñõ, #ã Ý Ý  ç @÷ó ð �>‰>€áÝ à	€Ø
€÷TIò TIr   