
    x7#h                     .   d Z ddlZddlZddlmZmZ ddlmZ ddlm	Z	 ddl
mZm
Z
mZmZ ddlmZ ddlmZmZ dd	lmZ dd
lmZmZmZmZmZ ddlmZ ddlmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z) ddl*m+Z+m,Z,m-Z-m.Z. ddl/m0Z0m1Z1 ee2e	e2   f   Z3eee4e5e5f   f   Z6eee
e2e7e5f   Z8ee4e5e5e2f   e4e4e5e5e2f   df   f   Z9eee4e5e5e5e5f   e4e5e5e5e5e5f   f   e4ee4e5e5e5e5f   e4e5e5e5e5e5f   f   df   f   Z:ee5e	e5   f   Z; G d de<ee2f         Z= G d de=      Z>y))DateLikeHolidayBase
HolidaySum    N)bisect_leftbisect_right)isleap)Iterable)datedatetime	timedeltatimezone)cached_property)gettexttranslation)Path)AnyLiteralOptionalUnioncast)parse)MONTUEWEDTHUFRISATSUN
_timedelta_get_nth_weekday_from_get_nth_weekday_of_monthDAYSMONTHSWEEKDAYS)HOLIDAY_NAME_DELIMITERPUBLICDEFAULT_START_YEARDEFAULT_END_YEAR)_normalize_arguments_normalize_tuple.c                       e Zd ZU dZeed<   	 eed<   	 dZeedf   ed<   	 i Ze	eef   ed<   	 e
e   ed<   	 eed	<   	 eed
<   	 dZee   ed<   	 i Ze	eeeef   f   ed<   	 dZeedf   ed<   	 eehZe
e   ed<   	 e
e   ed<   	 eZeed<   	 dZee   ed<   	  e
       Ze
e   ed<   	 efZeedf   ed<   	 dZeedf   ed<   	 eZeed<   	 e Z!eed<   	 dZ"ee#d       ed<   	 	 	 	 	 	 	 	 	 dadee$   d	ed
edee   dee   dee   dee   dee%   ddf fdZ&deed df   dd fd Z'defd!Z(d"e)defd#Z*de)defd$Z+d% Z,d"e-de.fd&Z/de	ee.f   fd'Z0d"e-defd(Z1de)defd)Z2de.dd fd*Z3deeee.df   f   f fd+Z4def fd,Z5d"ed-e.ddfd.Z6d"e-d-eddfd/Z7de	ee.f   ddfd0Z8def fd1Z9e:d2        Z;e<d3        Z=e<d4        Z>e:d5        Z?e@de	eeAf   fd6       ZBdbd7ZCdefd8ZDd9edee   fd:ZEdcd;ZFd<edefd=ZGdefd>ZHdefd?ZIdefd@ZJdefdAZKdefdBZLdefdCZMdefdDZNdE ZOdFeddfdGZPdH ZQdI ZRdJee	e-ef   eAe-   e-f   ddfdKZSdL ZTddd"e-dMeee.f   deee.f   fdNZUd"e-deAe   fdOZV	 dedPedQedRedeAe   fdSZW	 	 dfdTee-   dUeXdV   deeeef      fdWZYd"e-dXedefdYZZdZe-d[e-defd\Z[d"e-defd]Z\ddd"e-dMeee.f   deee.f   fd^Z]dgdPedQedeAe   fd_Z^dJee	e-ef   eAe-   e-f   ddfd`Z_ xZ`S )hr   a  
    A `dict`-like object containing the holidays for a specific country (and
    province or state if so initiated); inherits the `dict` class (so behaves
    similarly to a `dict`). Dates without a key in the Holiday object are not
    holidays.

    The key of the object is the date of the holiday and the value is the name
    of the holiday itself. When passing the date as a key, the date can be
    expressed as one of the following formats:

    * `datetime.datetime` type;
    * `datetime.date` types;
    * a `float` representing a Unix timestamp;
    * or a string of any format (recognized by `dateutil.parser.parse()`).

    The key is always returned as a `datetime.date` object.

    To maximize speed, the list of holidays is built as needed on the fly, one
    calendar year at a time. When you instantiate the object, it is empty, but
    the moment a key is accessed it will build that entire year's list of
    holidays. To pre-populate holidays, instantiate the class with the years
    argument:

        us_holidays = holidays.US(years=2020)

    It is generally instantiated using the
    [country_holidays()][holidays.utils.country_holidays] function.

    The key of the `dict`-like `HolidayBase` object is the
    `date` of the holiday, and the value is the name of the holiday itself.
    Dates where a key is not present are not public holidays (or, if
    **observed** is False, days when a public holiday is observed).

    When passing the `date` as a key, the `date` can be expressed in one of the
    following types:

    * `datetime.date`,
    * `datetime.datetime`,
    * a `str` of any format recognized by `dateutil.parser.parse()`,
    * or a `float` or `int` representing a POSIX timestamp.

    The key is always returned as a `datetime.date` object.

    To maximize speed, the list of public holidays is built on the fly as
    needed, one calendar year at a time. When the object is instantiated
    without a **years** parameter, it is empty, but, unless **expand** is set
    to False, as soon as a key is accessed the class will calculate that entire
    year's list of holidays and set the keys with them.

    If you need to list the holidays as opposed to querying individual dates,
    instantiate the class with the **years** parameter.

    Example usage:

        >>> from holidays import country_holidays
        >>> us_holidays = country_holidays('US')
        # For a specific subdivisions (e.g. state or province):
        >>> california_holidays = country_holidays('US', subdiv='CA')

    The below will cause 2015 holidays to be calculated on the fly:

        >>> from datetime import date
        >>> assert date(2015, 1, 1) in us_holidays

    This will be faster because 2015 holidays are already calculated:

        >>> assert date(2015, 1, 2) not in us_holidays

    The `HolidayBase` class also recognizes strings of many formats
    and numbers representing a POSIX timestamp:

        >>> assert '2014-01-01' in us_holidays
        >>> assert '1/1/2014' in us_holidays
        >>> assert 1388597445 in us_holidays

    Show the holiday's name:

        >>> us_holidays.get('2014-01-01')
        "New Year's Day"

    Check a range:

        >>> us_holidays['2014-01-01': '2014-01-03']
        [datetime.date(2014, 1, 1)]

    List all 2020 holidays:

        >>> us_holidays = country_holidays('US', years=2020)
        >>> for day in sorted(us_holidays.items()):
        ...     print(day)
        (datetime.date(2020, 1, 1), "New Year's Day")
        (datetime.date(2020, 1, 20), 'Martin Luther King Jr. Day')
        (datetime.date(2020, 2, 17), "Washington's Birthday")
        (datetime.date(2020, 5, 25), 'Memorial Day')
        (datetime.date(2020, 7, 3), 'Independence Day (observed)')
        (datetime.date(2020, 7, 4), 'Independence Day')
        (datetime.date(2020, 9, 7), 'Labor Day')
        (datetime.date(2020, 10, 12), 'Columbus Day')
        (datetime.date(2020, 11, 11), 'Veterans Day')
        (datetime.date(2020, 11, 26), 'Thanksgiving Day')
        (datetime.date(2020, 12, 25), 'Christmas Day')

    Some holidays are only present in parts of a country:

        >>> us_pr_holidays = country_holidays('US', subdiv='PR')
        >>> assert '2018-01-06' not in us_holidays
        >>> assert '2018-01-06' in us_pr_holidays

    Append custom holiday dates by passing one of:

    * a `dict` with date/name key/value pairs (e.g.
      `{'2010-07-10': 'My birthday!'}`),
    * a list of dates (as a `datetime.date`, `datetime.datetime`,
      `str`, `int`, or `float`); `'Holiday'` will be used as a description,
    * or a single date item (of one of the types above); `'Holiday'` will be
      used as a description:

    ```python
    >>> custom_holidays = country_holidays('US', years=2015)
    >>> custom_holidays.update({'2015-01-01': "New Year's Day"})
    >>> custom_holidays.update(['2015-07-01', '07/04/2015'])
    >>> custom_holidays.update(date(2015, 12, 25))
    >>> assert date(2015, 1, 1) in custom_holidays
    >>> assert date(2015, 1, 2) not in custom_holidays
    >>> assert '12/25/2015' in custom_holidays
    ```

    For special (one-off) country-wide holidays handling use
    `special_public_holidays`:

        special_public_holidays = {
            1977: ((JUN, 7, "Silver Jubilee of Elizabeth II"),),
            1981: ((JUL, 29, "Wedding of Charles and Diana"),),
            1999: ((DEC, 31, "Millennium Celebrations"),),
            2002: ((JUN, 3, "Golden Jubilee of Elizabeth II"),),
            2011: ((APR, 29, "Wedding of William and Catherine"),),
            2012: ((JUN, 5, "Diamond Jubilee of Elizabeth II"),),
            2022: (
                (JUN, 3, "Platinum Jubilee of Elizabeth II"),
                (SEP, 19, "State Funeral of Queen Elizabeth II"),
            ),
        }

        def _populate(self, year):
            super()._populate(year)

            ...

    For more complex logic, like 4th Monday of January, you can inherit the
    [HolidayBase][holidays.holiday_base.HolidayBase] class and define your own `_populate()`
    method.
    See documentation for examples.
    countrymarket .subdivisionssubdivisions_aliasesyearsexpandobservedNsubdivspecial_holidays_deprecated_subdivisionsweekendweekend_workdaysdefault_categorydefault_language
categoriessupported_categoriessupported_languages
start_yearend_yearparent_entityprovstatelanguagereturnc	                 N   t         |           | j                  r#| j                  | j                  vrt	        d      | j                  s|st	        d      t        t        |      xs | j                  h}|j                  | j                        x}	rt	        ddj                  |	       d      |xs |xs |x}rt        |t              rt        |      }t        t        | j                              }
t        | t              s9|| j                  |
z   | j                   z   vrt#        d| j$                   d|       |xs |x}rt'        j(                  d| d	t*               || j                   v rRt'        j(                  d
dj                  t        | j                               ddj                  |
       dt*               t-        | dd      x}r3t-        | dd      rt-        | dd      st	        d| j$                   d      || _        || _        t-        | dd      | _        || _        || _        || _        || _        t-        | dt=                     | _        t        t        |      | _         | jC                          | j@                  D ]  }| jE                  |        y)ab
  
        Args:
            years:
                The year(s) to pre-calculate public holidays for at instantiation.

            expand:
                Whether the entire year is calculated when one date from that year
                is requested.

            observed:
                Whether to include the dates when public holiday are observed
                (e.g. a holiday falling on a Sunday being observed the
                following Monday). This doesn't work for all countries.

            subdiv:
                The subdivision (e.g. state or province) as a ISO 3166-2 code
                or its alias; not implemented for all countries (see documentation).

            prov:
                *deprecated* use `subdiv` instead.

            state:
                *deprecated* use `subdiv` instead.

            language:
                Specifies the language in which holiday names are returned.

                Accepts either:

                * A two-letter ISO 639-1 language code (e.g., 'en' for English, 'fr' for French),
                    or
                * A language and entity combination using an underscore (e.g., 'en_US' for U.S.
                    English, 'pt_BR' for Brazilian Portuguese).

                !!! warning
                    The provided language or locale code must be supported by the holiday
                    entity. Unsupported values will result in names being shown in the entity's
                    original language.

                If not explicitly set (`language=None`), the system attempts to infer the
                language from the environment's locale settings. The following environment
                variables are checked, in order of precedence: LANGUAGE, LC_ALL, LC_MESSAGES, LANG.

                If none of these are set or they are empty, holiday names will default to the
                original language of the entity's holiday implementation.

                !!! warning
                    This fallback mechanism may yield inconsistent results across environments
                    (e.g., between a terminal session and a Jupyter notebook).

                To ensure consistent behavior, it is recommended to set the language parameter
                explicitly. If the specified language is not supported, holiday names will remain
                in the original language of the entity's holiday implementation.

                This behavior will be updated and formalized in v1.

            categories:
                Requested holiday categories.

        Returns:
            A `HolidayBase` object matching the **country** or **market**.
        z<The default category must be listed in supported categories.z<Categories cannot be empty if `default_category` is not set.zCategory is not supported: , .zEntity `z` does not have subdivision z5Arguments prov and state are deprecated, use subdiv='z
' instead.zjThis subdivision is deprecated and will be removed after Dec, 1 2023. The list of supported subdivisions: z.; the list of supported subdivisions aliases: has_substituted_holidaysFsubstituted_labelNsubstituted_date_formatzS` class must have `substituted_label` and `substituted_date_format` attributes set.has_special_holidaysr8   )#super__init__r9   r<   
ValueErrorr)   str
differencejoin
isinstanceinttuplesortedr0   r   r/   r6   NotImplementedError_entity_codewarningswarnDeprecationWarninggetattrr;   r2   rK   rH   rC   r3   r4   setr8   r1   _init_translation	_populate)selfr1   r2   r3   r4   rA   rB   rC   r;   unknown_categoriesr0   
prov_staterH   year	__class__s                 U/var/www/api/v1/venv_getwork_v1/lib/python3.12/site-packages/holidays/holiday_base.pyrM   zHolidayBase.__init__  s   R 	   T%:%:$B[B[%[[\\$$Z[\\)#z:Ut?T?T>U
!+!6!6%%"
 
 
 :499EW;X:YYZ[\\ ,t,u,6,&#&V#(0I0I)J#K dJ/F!!$884;X;XX5 *t0011MfXV 
 "]U*z*KJ<Wab& 666Hyy(9(9!:;< =Cyy!567q	:
 ' )06PRW(XX$X1484!:DA4,,- .@ @ 
 %$+D2H%$P!(@%   '.@#% H)#u5
 	  JJDNN4      otherr   c                     t        |t              r|dk(  r| S t        |t        t        f      st	        d      t        | |      S )aG  Add another dictionary of public holidays creating a
        [HolidaySum][holidays.holiday_base.HolidaySum] object.

        Args:
            other:
                The dictionary of public holiday to be added.

        Returns:
            A `HolidayBase` object unless the other object cannot be added, then `self`.
        r   z<Holiday objects can only be added with other Holiday objects)rR   rS   r   r   	TypeErrorr_   rf   s     rd   __add__zHolidayBase.__add__  sC     eS!eqj K%+z!:;Z[[$&&re   c                     t        |       dkD  S )Nr   )lenr_   s    rd   __bool__zHolidayBase.__bool__  s    4y1}re   keyc                     t        |t        t        t        t        t
        f      st        dt        |       d      t        j                  t        d|       | j                  |            S )a  Check if a given date is a holiday.

        The method supports the following input types:

        * `datetime.date`,
        * `datetime.datetime`,
        * a `str` of any format recognized by `dateutil.parser.parse()`,
        * or a `float` or `int` representing a POSIX timestamp.

        Args:
            key:
                The date to check.

        Returns:
            `True` if the date is a holiday, `False` otherwise.
        Cannot convert type '
' to date.dict[Any, Any])rR   r
   r   floatrS   rO   rh   typedict__contains__r   __keytransform__)r_   ro   s     rd   rw   zHolidayBase.__contains__  sY    $ #hsC@A3DI;jIJJ  &6!=t?T?TUX?YZZre   c                     t        |t              sy| j                  D ]  }t        | |d       t        ||d       k7  s y t        j                  t        d|       |      S )NFrs   )rR   r   _HolidayBase__attribute_namesr[   rv   __eq__r   r_   rf   attribute_names      rd   r{   zHolidayBase.__eq__  sX    %-"44Nt^T2ge^UY6ZZ 5 {{4 0$7??re   c           	         	
 	  j                  |      S # t        $ r}d}|d t        |       |k7  r||j                  d      }t        |      dk(  r$|^ }
t        v r
t
        v r
 fdcY d }~S |t        |      dk(  r|^ }}|dk(  r5dk(  sd   j                         rt        v rt        v r fd	cY d }~S |^ }}}|d
v r3dv r/|dk(  r*t              dk  rj                         r fdcY d }~S |t        |      dk(  ro|^ }}}|d
v r^dv rZ|dk(  rUt              dk  rGj                         r7dk(  sd   j                         rt        v rt        v r fdcY d }~S |t        |      dk(  rG|^ }	
	dv r:d   j                         r't        v rt        v r
t
        v r	
 fdcY d }~S |d }~ww xY w)N_add_holiday__   c           
      r    j                  | t        j                  t           t	                          S N)_add_holidayr
   _yearr#   rS   )namedaymonthr_   s    rd   <lambda>z)HolidayBase.__getattr__.<locals>.<lambda>  s*    (9(9d4::ve}c#hG)re      oflastr   c           	          j                  | t        dk(  rdnt        d         t           t           j
                              S )Nr   r   )r   r!   rS   r$   r#   r   )r   r   numberr_   weekdays    rd   r   z)HolidayBase.__getattr__.<locals>.<lambda>  sE    (9(91"(F"2BF1I$W-"5M JJ	)re   >   r   days>   pastprioreaster   c           	          j                  | t        j                  dk(  rt                          S t                           S )Nr   )r   r   _easter_sundayrS   )r   r   delta_directionr_   s    rd   r   z)HolidayBase.__getattr__.<locals>.<lambda>  sK    (9(9" //*9V*CSYJ) KNd))re   
   c                     j                  | t        t        dk(  rdnt        d         t           t
           j                        dk(  rt                          S t                           S )Nr   r   r   r   )r   r   r!   rS   r$   r#   r   )r   r   r   r   r   r_   r   s    rd   r   z)HolidayBase.__getattr__.<locals>.<lambda>  sv    (9(9"5&,&6Cq	N ( 1 &u $

	 +:V*CSYJ) KNd))re      >   frombeforec                     j                  | t        dk(  rt        d          nt        d         t           t	        j
                  t           t                                S )Nr   r   )r   r    rS   r$   r
   r   r#   )r   date_directionr   r   r   r_   r   s    rd   r   z)HolidayBase.__getattr__.<locals>.<lambda>0  s`    (9(9-/=/IS^OPSTZ[\T]P^$W- VE]CHE)re   )__getattribute__AttributeErrorrl   splitr#   r"   isdigitr$   )r_   r   eadd_holiday_prefixtokensr   r   unitr   r   r   r   r   r   r   r   s   `        @@@@@@@rd   __getattr__zHolidayBase.__getattr__  s1   j	((.. h	!0-c,-.2DDZZ_F 6{a!'E3F?sd{ v Go V! 28.FGR$J6)VAY->->-@8+  ;A7D$O+'+<<(*D	A p G[ V"NTKD$"eO+'+<<d
D	A6)VAY->->-@8+  B G% V!BH?FG^UC"&88q	))+8+t   GQh	sT    
G'AG"5G';AG"G'9G"G'A7G"G'	AG"G' G""G'c                 H   t        |t              rm|j                  r|j                  st	        d      | j                  |j                        }| j                  |j                        }|j                  d}nzt        |j                  t              r|j                  j                  }nIt        |j                  t              r|j                  }n"t        dt        |j                         d      |dk(  rt	        d      ||z
  }|j                  dcxk  r|k  sn |j                  dcxk\  r|kD  rn n|dz  }g }t        d|j                  |      D ]$  }t        ||      }|| v s|j                  |       & |S t        j!                  | | j                  |            S )Nz"Both start and stop must be given.   rq   z	' to int.r   zStep value must not be zero.r   )rR   slicestartstoprN   rx   stepr   r   rS   rh   ru   ranger   appendrv   __getitem__)	r_   ro   r   r   r   	date_diffdays_in_range
delta_daysr   s	            rd   r   zHolidayBase.__getitem__;  sU   c5!99CHH !EFF))#))4E((2DxxCHHi0xx}}CHHc*xx"7SXX7Gy QRRqy !?@@uI~~)T)Y^^q-G4-G
M#Ay~~t<
 
3$;!((- =
 ! d&;&;C&@AAre   c                 ^    | j                   j                         }|j                  dd       |S )z,Return the object's state for serialization.trN)__dict__copypopr_   rB   s     rd   __getstate__zHolidayBase.__getstate__]  s'    ""$		$re   c                 (   d}t        |      t        u r|}nt        |t              r@t	        |      dv r	 t        j
                  |      }|	 t        |      j                         }nt        |t              r|j                         }ntt        |t              r|}nat        |t        t        f      r3t        j                  |t        j                        j                         }nt        dt        |       d      | j                   rX|j"                  | j$                  vr@| j$                  j'                  |j"                         | j)                  |j"                         |S # t        $ r Y $w xY w# t        t        f$ r t        d| d      w xY w)a  Convert various date-like formats to `datetime.date`.

        The method supports the following input types:
        * `datetime.date`,
        * `datetime.datetime`,
        * a `str` of any format recognized by `dateutil.parser.parse()`,
        * or a `float` or `int` representing a POSIX timestamp

        Args:
            key:
                The date-like object to convert.

        Returns:
            The corresponding `datetime.date` representation.
        N>   r   r   zCannot parse date from string ''rq   rr   )ru   r
   rR   rO   rl   fromisoformatrN   r   OverflowErrorr   rt   rS   fromtimestampr   utcrh   r2   rb   r1   addr^   r_   ro   dts      rd   rx   zHolidayBase.__keytransform__c  sY   " " 9B S!3x7"++C0B zOs*B
 X&B T"B eS\*''X\\:??AB 3DI;jIJJ ;;277$**4JJNN277#NN277#	; " 
 &z2 O$'Fse1%MNNOs   E" E2 "	E/.E/2Fc                     t        |t              sy| j                  D ]  }t        | |d       t        ||d       k7  s y t        j                  | |      S )NT)rR   r   rz   r[   rv   __ne__r|   s      rd   r   zHolidayBase.__ne__  sP    %-"44Nt^T2ge^UY6ZZ 5 {{4''re   c                 $    | j                  |      S r   )rj   ri   s     rd   __radd__zHolidayBase.__radd__  s    ||E""re   c                      t         |          S r   )rL   
__reduce__)r_   rc   s    rd   r   zHolidayBase.__reduce__  s    w!##re   c                    | rt         |          S g }t        | d      r0|j                  d| j                         |j                  d       nwt        | d      rZ|j                  d| j
                         | j                  r|j                  d| j                         |j                  d       n|j                  d       dj                  |      S )	Nr-   zholidays.financial_holidays()r,   zholidays.country_holidays(z	, subdiv=zholidays.HolidayBase() )rL   __repr__hasattrr   r-   r,   r4   rQ   r_   partsrc   s     rd   r   zHolidayBase.__repr__  s    7#%%4"LL7GHLLT9%LL5dll5EFG{{y89LLLL12wwu~re   valuec                     t         j                  | ||       | r8|dv r3| j                          | j                  D ]  }| j	                  |        y y y )N>   r3   r;   )rv   __setattr__clearr1   r^   )r_   ro   r   rb   s       rd   r   zHolidayBase.__setattr__  sI    sE*C55JJL

t$ # 64re   c                    || v rct        | |   j                  t                    }|j                  |j                  t                     t        j                  t        |            }t        j                  | | j                  |      |       y r   )	r\   r   r%   updaterQ   rU   rv   __setitem__rx   )r_   ro   r   holiday_namess       rd   r   zHolidayBase.__setitem__  sm    $;  S	0F GHM  -C!DE*//}0EFEt44S95Are   c                 Z    | j                   j                  |       | j                          y)z1Restore the object's state after deserialization.N)r   r   r]   r   s     rd   __setstate__zHolidayBase.__setstate__  s     U# re   c                 z      rt                   S  fd j                  D        }ddj                  |       dS )Nc           	   3   D   K   | ]  }d | dt        |d         yw)r   z': Nr[   ).0r}   r_   s     rd   	<genexpr>z&HolidayBase.__str__.<locals>.<genexpr>  s1      
"8 s74#F"GH"8s    {rF   })rL   __str__rz   rQ   r   s   ` rd   r   zHolidayBase.__str__  sC    7?$$
"&"8"8

 DIIe$%R((re   c                      y)N)r,   r2   rC   r-   r3   r4   r1   r.   rm   s    rd   __attribute_nameszHolidayBase.__attribute_names  s    Yre   c           	      2    t        | dt        | dd             S )Nr,   r-   r   rm   s    rd   rW   zHolidayBase._entity_code  s    tYh(EFFre   c                     | j                   j                  | j                  | j                        j                  t        j                  ddd            j                         S )Nr   )- )r0   getr4   	translaterO   	maketranslowerrm   s    rd   _normalized_subdivzHolidayBase._normalized_subdiv  sQ     %%))$++t{{CY   UW	
re   c                     | j                   | j                  v r1| j                   gt        | j                  | j                   hz
        z   S t        | j                        S r   )r9   r;   rU   rm   s    rd   _sorted_categorieszHolidayBase._sorted_categories  sX     $$7 ""#fT__@U@U?V-V&WW	
 (	
re   c                     | j                   D ci c]  }|g  }}| j                  j                         D ]  \  }}||   j                  |        |S c c}w )zGet subdivision aliases.

        Returns:
            A dictionary mapping subdivision aliases to their official ISO 3166-2 codes.
        )r/   r0   itemsr   )clsssubdivision_aliasesaliassubdivisions        rd   get_subdivision_aliasesz#HolidayBase.get_subdivision_aliases  sg     EHDTDT4UDTqQUDT4U"%":":"@"@"BE;,33E: #C #"	 5Vs   
Ac                    t        | j                        }| j                  | j                  |v}| j                  |v r| j                  gnd}t	        t        t              j                  d            }t        | j                  |||      }| j                  x}r6|j                  t        |j                  xs |j                  |||             |j                  | _        yt        | _        y)z;Initialize translation function based on language settings.Nlocale)fallback	languages	localedir)r\   r=   rW   rC   rO   r   __file__	with_namer   r@   add_fallbackr,   r-   r   r   )r_   r=   r   r   locale_directoryentity_translationr@   s          rd   r]   zHolidayBase._init_translation  s    !$":":;(}},??H+/==<O+OUYI"4>#;#;H#EF "-!!!#*	" !% 2 22}2"//%--E1E1E!)"+"2	 )00DGDGre   c                 ,    t        | j                        S )zL
        Returns True if the year is leap. Returns False otherwise.
        )r   r   rm   s    rd   _is_leap_yearzHolidayBase._is_leap_year-  s     djj!!re   r   c                     |st        d      t        |      dkD  r|n|d   }t        |t              r|nt        | j                  g| }|j
                  | j                  k7  ry| j                  |      | |<   |S )zAdd a holiday.zIncorrect number of arguments.r   r   N)rh   rl   rR   r
   r   rb   r   )r_   r   argsr   s       rd   r   zHolidayBase._add_holiday3  sm    <==Y]TQb$'RT$**-Br-B77djj 774=R	re   c           
      ~   |D ]7  }t        t        | |i       j                  | j                  d            D ]   }t	        |      dk(  rX|\  }}}| j                  |r-| j                  | j                        | j                  |      z  n| j                  |      ||       j|^}}	}
}}t        |r|d   n| j                  |
|      }| j                  | j                  | j                        |j                  | j                  | j                              z  ||	       | j                  j                  |        : y)zAdd special holidays.r.   r   r   N)r*   r[   r   r   rl   r   r   observed_labelr
   rI   strftimerJ   r8   r   )r_   mapping_namesr3   mapping_namedatar   r   r   to_monthto_day
from_monthfrom_dayoptional	from_dates                 rd   _add_special_holidaysz!HolidayBase._add_special_holidaysA  s   )L(|R)H)L)LTZZY[)\]t9>'+$E3%%#  3 34twwt}D!WWT] IMEHfj(X $HXa[$**jZb cI%% 6 67#,,TWWT5Q5Q-RST 	 ))--i8' ^ *re   r   c                     t        |      dkD  r|n|d   }t        |t              r|nt        | j                  g| }|j	                         |k(  S )zk
        Returns True if `weekday` equals to the date's week day.
        Returns False otherwise.
        r   r   )rl   rR   r
   r   r   )r_   r   r  r   s       rd   _check_weekdayzHolidayBase._check_weekdayY  sH    
 Y]TQb$'RT$**-Br-Bzz|w&&re   c                 0     | j                   t        g| S r   )r  r   r_   r  s     rd   
_is_mondayzHolidayBase._is_mondayb      "t""3...re   c                 0     | j                   t        g| S r   )r  r   r  s     rd   _is_tuesdayzHolidayBase._is_tuesdaye  r  re   c                 0     | j                   t        g| S r   )r  r   r  s     rd   _is_wednesdayzHolidayBase._is_wednesdayh  r  re   c                 0     | j                   t        g| S r   )r  r   r  s     rd   _is_thursdayzHolidayBase._is_thursdayk  r  re   c                 0     | j                   t        g| S r   )r  r   r  s     rd   
_is_fridayzHolidayBase._is_fridayn  r  re   c                 0     | j                   t        g| S r   )r  r   r  s     rd   _is_saturdayzHolidayBase._is_saturdayq  r  re   c                 0     | j                   t        g| S r   )r  r   r  s     rd   
_is_sundayzHolidayBase._is_sundayt  r  re   c                     t        |      dkD  r|n|d   }t        |t              r|nt        | j                  g| }|j	                         | j
                  v S )zd
        Returns True if date's week day is a weekend day.
        Returns False otherwise.
        r   r   )rl   rR   r
   r   r   r7   )r_   r  r   s      rd   _is_weekendzHolidayBase._is_weekendw  sL    
 Y]TQb$'RT$**-Br-Bzz|t||++re   rb   c                     || j                   k  s|| j                  kD  ry|| _        | j                          | j	                          y)a  This is a private class that populates (generates and adds) holidays
        for a given year. To keep things fast, it assumes that no holidays for
        the year have already been populated. It is required to be called
        internally by any country populate() method, while should not be called
        directly from outside.
        To add holidays to an object, use the update() method.

        Args:
            year: The year to populate with holidays.

            >>> from holidays import country_holidays
            >>> us_holidays = country_holidays('US', years=2020)
            # to add new holidays to the object:
            >>> us_holidays.update(country_holidays('US', years=2021))
        N)r>   r?   r   _populate_common_holidays_populate_subdiv_holidays)r_   rb   s     rd   r^   zHolidayBase._populate  s=    " $//!TDMM%9
&&(&&(re   c                     | j                   D ]+  }t        | d|j                          dd      x}s% |        - | j                  r#| j	                  d | j                   D               yy)z Populate entity common holidays.
_populate_	_holidaysNc              3   (   K   | ]
  }d | d  yw)special_r-  Nr.   )r   categorys     rd   r   z8HolidayBase._populate_common_holidays.<locals>.<genexpr>  s      '?V8(8*I.?Vs   )r   r[   r   rK   r  )r_   r0  
pch_methods      rd   r)  z%HolidayBase._populate_common_holidays  sn    //H$TZ8H7I+SUYZZzZ 0 $$&& '?C?V?V'  %re   c           	           j                   y j                  D ]8  }t         d j                   d|j	                          dd      x}s2 |        :  j
                  r% j                   fd j                  D               yy)z%Populate entity subdivision holidays.N_populate_subdiv_r   r-  c              3   `   K   | ]%  }d j                    d|j                          d ' yw)r/  r   r-  N)r   r   )r   r0  r_   s     rd   r   z8HolidayBase._populate_subdiv_holidays.<locals>.<genexpr>  s7      ' 7H 42231X^^5E4FiP 7s   +.)r4   r   r[   r   r   rK   r  )r_   r0  asch_methods   `  rd   r*  z%HolidayBase._populate_subdiv_holidays  s    ;;//H%#D$;$;#<Ahnn>N=OyY { 
  0 $$&& ' $ 7 7'  %re   r  c                       | j                   | S )a=  Alias for [update()][holidays.holiday_base.HolidayBase.update] to mimic list type.

        Args:
            args:
                Holiday data to add. Can be:

                * A dictionary mapping dates to holiday names.
                * A list of dates (without names).
                * A single date.
        )r   r  s     rd   r   zHolidayBase.append  s     t{{D!!re   c                 ,    t        j                   |       S )zReturn a copy of the object.)r   rm   s    rd   r   zHolidayBase.copy  s    yyre   defaultc                 N    t         j                  | | j                  |      |      S )aj  Retrieve the holiday name(s) for a given date.

        If the date is a holiday, returns the holiday name as a string.
        If multiple holidays fall on the same date, their names are joined by a semicolon (`;`).
        If the date is not a holiday, returns the provided `default` value (defaults to `None`).

        Args:
            key:
                The date expressed in one of the following types:

                * `datetime.date`,
                * `datetime.datetime`,
                * a `str` of any format recognized by `dateutil.parser.parse()`,
                * or a `float` or `int` representing a POSIX timestamp.

            default:
                The default value to return if no value is found.

        Returns:
            The holiday name(s) as a string if the date is a holiday,
                or the `default` value otherwise.
        )rv   r   rx   r_   ro   r8  s      rd   r   zHolidayBase.get  s"    . xxd33C8'BBre   c                 x    | j                  |d      j                  t              D cg c]  }|s|	 c}S c c}w )a  Retrieve all holiday names for a given date.

        Args:
            key:
                The date expressed in one of the following types:

                * `datetime.date`,
                * `datetime.datetime`,
                * a `str` of any format recognized by `dateutil.parser.parse()`,
                * or a `float` or `int` representing a POSIX timestamp.

        Returns:
            A list of holiday names if the date is a holiday, otherwise an empty list.
        r   )r   r   r%   )r_   ro   r   s      rd   get_listzHolidayBase.get_list  s8     "&#r!2!8!89O!PY!PTX!PYYYs   77holiday_namelookupsplit_multiple_namesc           
      $   |rd | j                         D        nd | j                         D        }|dk(  r8|j                         }|D cg c]  \  }}||j                         v s| c}}S |dk(  r|D cg c]  \  }}||k(  s| c}}S |dk(  r|D cg c]  \  }}||v s| c}}S |dk(  r'|D cg c]  \  }}||dt        |       k(  s| c}}S |dk(  r9|j                         }|D cg c]  \  }}||j                         k(  s| c}}S |d	k(  rD|j                         }|D cg c]&  \  }}||dt        |       j                         k(  r|( c}}S t        d
|       c c}}w c c}}w c c}}w c c}}w c c}}w c c}}w )a  Find all holiday dates matching a given name.

        The search by default is case-insensitive and includes partial matches.

        Args:
            holiday_name:
                The holiday's name to try to match.

            lookup:
                The holiday name lookup type:

                * contains - case sensitive contains match;
                * exact - case sensitive exact match;
                * startswith - case sensitive starts with match;
                * icontains - case insensitive contains match;
                * iexact - case insensitive exact match;
                * istartswith - case insensitive starts with match;

            split_multiple_names:
                Either use the exact name for each date or split it by holiday
                name delimiter.

        Returns:
            A list of all holiday dates matching the provided holiday name.
        c              3   ^   K   | ]%  \  }}|j                  t              D ]  }||f 
 ' y wr   )r   r%   )r   kvr   s       rd   r   z(HolidayBase.get_named.<locals>.<genexpr>  s,     \<41aAGGDZ<[DaY<[Y<s   +-c              3   *   K   | ]  \  }}||f  y wr   r.   )r   rB  rC  s      rd   r   z(HolidayBase.get_named.<locals>.<genexpr>  s     2\TQ1a&\s   	icontainsexactcontains
startswithNiexactistartswithzUnknown lookup type: )r   r   rl   r   )r_   r=  r>  r?  holiday_name_datesholiday_name_lowerr   r   s           rd   	get_namedzHolidayBase.get_named  s   < $ ]4::<\2TZZ\2 	 [ !-!3!3!5'9`'982t=OSWS]S]S_=_B'9``w'9R'982t\T=QB'9RRz!'9R'982t\T=QB'9RR|##5#5xr4NaPST`PaIb9b#5  x!-!3!3!5'9`'982t=OSWS]S]S_=_B'9``}$!-!3!3!5 !3 2HB%.AL0A)B)H)H)JJ  2  4VH=>>) aRR
 asB   E.&E.8E4E4E:%E:7F F 3FF1+Ftarget_date	direction)forwardbackwardc                    |dvrt        d|       | j                  |xs" t        j                         j	                               }|dk(  r/|j
                  dz   x}| j                  vr| j                  |       n3|dk(  r.|j
                  dz
  x}| j                  vr| j                  |       t        | j                               }|dk(  rt        ||      nt        ||      dz
  }d|cxk  rt        |      k  rn y||   }|| |   fS y)a  Find the closest holiday relative to a given date.

        If `direction` is "forward", returns the next holiday after `target_date`.
        If `direction` is "backward", returns the previous holiday before `target_date`.
        If `target_date` is not provided, the current date is used.

        Args:
            target_date:
                The reference date. If None, defaults to today.

            direction:
                Search direction, either "forward" (next holiday) or
                "backward" (previous holiday).

        Returns:
            A tuple containing the holiday date and its name, or None if no holiday is found.
        >   rP  rQ  zUnknown direction: rP  r   rQ  r   N)r   rx   r   nowr
   rb   r1   r^   rU   keysr   r   rl   )r_   rN  rO  r   	next_yearprevious_yearsorted_datespositions           rd   get_closest_holidayzHolidayBase.get_closest_holiday+  s   , 33 #6yk!BCC"";#G(,,.2E2E2GH	!BGGaK'?y

&RNN9%*$277Q;*F-tzz)YNN=)diik* I% r*\2.2 	
 ,3|,,  h'BtBx<re   nc                     |dkD  rdnd}| j                  |      }t        t        |            D ]>  }t        ||      }| j	                  |      r!t        ||      }| j	                  |      s@ |S )a  Find the n-th working day from a given date.

        Moves forward if n is positive, or backward if n is negative.

        Args:
            key:
                The starting date.

            n:
                The number of working days to move. Positive values move forward,
                negative values move backward.

        Returns:
            The calculated working day after shifting by n working days.
        r   r   r   )rx   r   absr   is_working_day)r_   ro   rZ  rO  r   r   s         rd   get_nth_working_dayzHolidayBase.get_nth_working_dayV  sp      a%BR	""3's1vAB	*B))"-I. ))"-  	re   r   endc                       j                  |       j                  |      }|kD  r|c}|z
  j                  dz   }t         fdt        |      D              S )a  Calculate the number of working days between two dates.

        The date range works in a closed interval fashion [start, end] so both
        endpoints are included.

        Args:
            start:
                The range start date.

            end:
                The range end date.

        Returns:
            The total count of working days between the given dates.
        r   c              3   T   K   | ]  }j                  t        |             ! y wr   )r]  r   )r   rZ  dt1r_   s     rd   r   z5HolidayBase.get_working_days_count.<locals>.<genexpr>  s$     PKq4&&z#q'9:Ks   %()rx   r   sumr   )r_   r   r_  dt2r   rb  s   `    @rd   get_working_days_countz"HolidayBase.get_working_days_countn  s`      ##E*##C(9CHCc	!#PE$KPPPre   c                 j    | j                  |      }| j                  |      r|| j                  v S || vS )zCheck if the given date is considered a working day.

        Args:
            key:
                The date to check.

        Returns:
            True if the date is a working day, False if it is a holiday or weekend.
        )rx   r'  r8   r   s      rd   r]  zHolidayBase.is_working_day  s<     ""3'.2.>.>r.BrT***VRVVre   c                     |%t         j                  | | j                  |            S t         j                  | | j                  |      |      S )a  Remove a holiday for a given date and return its name.

        If the specified date is a holiday, it will be removed, and its name will
        be returned. If the date is not a holiday, the provided `default` value
        will be returned instead.

        Args:
            key:
                The date expressed in one of the following types:

                * `datetime.date`,
                * `datetime.datetime`,
                * a `str` of any format recognized by `dateutil.parser.parse()`,
                * or a `float` or `int` representing a POSIX timestamp.

            default:
                The default value to return if no match is found.

        Returns:
            The name of the removed holiday if the date was a holiday, otherwise
                the provided `default` value.

        Raises:
            KeyError: if date is not a holiday and default is not given.
        )rv   r   rx   r:  s      rd   r   zHolidayBase.pop  sC    4 ?88D$"7"7"<==xxd33C8'BBre   c           
      t   t         |v }| j                  |||       x}st        |      g }|D ]g  }| |   j                  t               }| j	                  |       |j                  |       |rA|dk(  r3|j                         }|D 	cg c]  }	||	j                         vs|	 }}	n|dk(  r4|j                         }|D 	cg c]  }	||	j                         k7  s|	 }}	n|dk(  r?|j                         }|D 	cg c]#  }	||	dt        |       j                         k7  r|	% }}	nV|dk(  r|D 	cg c]	  }	||	vs|	 }}	n<|dk(  r|D 	cg c]
  }	||	k7  s	|	 }}	n!|D 	cg c]  }	||	dt        |       k7  s|	 }}	|sPt        j                  |      | |<   j |S c c}	w c c}	w c c}	w c c}	w c c}	w c c}	w )a  Remove all holidays matching the given name.

        This method removes all dates associated with a holiday name, so they are
        no longer considered holidays. The search by default is case-insensitive and
        includes partial matches.

        Args:
            holiday_name:
                The holiday's name to try to match.

            lookup:
                The holiday name lookup type:

                * contains - case sensitive contains match;
                * exact - case sensitive exact match;
                * startswith - case sensitive starts with match;
                * icontains - case insensitive contains match;
                * iexact - case insensitive exact match;
                * istartswith - case insensitive starts with match;

        Returns:
            A list of dates removed.

        Raises:
            KeyError: if date is not a holiday.
        )r>  r?  rE  rI  rJ  NrG  rF  )	r%   rM  KeyErrorr   r   r   r   rl   rQ   )
r_   r=  r>  use_exact_namedtspoppedr   r   rL  r   s
             rd   	pop_namedzHolidayBase.pop_named  s    6 0<?>>VnBT "  C  <((B HNN+ABMHHRLMM" $%1%7%7%9"%2!%2T6HPTPZPZP\6\D]  ! 8#%1%7%7%9"%2!%2T6HDJJL6XD]  ! =(%1%7%7%9" !.! -)T2EC4E-F-L-L-NN  -  !
 :%2? \-$<W[C[- \7"2? X-$<SWCW- X &3!%2TldK^SQ]M^F_6_D]  ! 166}ERE H 5!
!
! !] X!sB   	F!FF!F!:(F&.	F+8F+
F0F0F55F5c                     |D ]R  }t        |t              r|j                         D ]
  \  }}|| |<    1t        |t              r|D ]  }d| |<   	 Nd| |<   T y)ac  Update the object, overwriting existing dates.

        Args:
            args:
                Either another dictionary object where keys are dates and values
                are holiday names, or a single date (or a list of dates) for which
                the value will be set to "Holiday".

                Dates can be expressed in one or more of the following types:

                * `datetime.date`,
                * `datetime.datetime`,
                * a `str` of any format recognized by `dateutil.parser.parse()`,
                * or a `float` or `int` representing a POSIX timestamp.
        HolidayN)rR   rv   r   list)r_   r  argro   r   items         rd   r   zHolidayBase.update  s]    $ C#t$"%))+JC %DI #.C&D!*DJ   &S	 re   )NTTNNNNN)rD   N)Fr   )rE  T)NrP  )rE  )a__name__
__module____qualname____doc__rO   __annotations__r/   rT   r0   rv   r\   rS   boolr4   r   r5   r   SpecialHolidaySubstitutedHolidayr6   r   r   r7   r
   r&   r9   r:   r;   r<   r=   r'   r>   r(   r?   r@   ru   YearArgCategoryArgrM   rj   rn   objectrw   r{   r   r   r   r   r   rx   r   r   r   r   r   r   r   r   propertyrz   r   rW   r   r   classmethodrp  r   r]   r  r   r  r  r  r  r  r  r!  r#  r%  r'  r^   r)  r*  r   r   r   r<  rM  r   rY  r^  re  r]  r   rm  r   __classcell__)rc   s   @rd   r   r   9   s;   Xt L0K/$&L%S/&J+-$sCx.-2s8OLNF FHSM HMOd3n6H&H IIJO02eCHo2c
GSX"$i)"c".&*hsm*.5JC '-3I%S/5:+-sCx-1(J(:$Hc$837M8D/078 $( $"#"&,0R! R! R! 	R!
 R! smR! }R! 3-R! [)R! 
R!h'U3|#CD ' '*$ [ [4 [.@F @t @kZ Bx  BC  BDd38n ;H ; ;z(F (t (#c #m #$E#uS#X"67 $# $%s %3 %4 %Bx B B B!$sCx. !T !
	) 	) Z Z G G 
 
 
 
 
#S$Y 
# 
#:"t "  90'c 'T '/4 //D //d //T //4 //T //4 /,)c )d )0	&"E$x}"5tH~x"OP "UY "Cx C%S/ CU3PS8_ C2ZH Zc Z$ Z^8?8?),8?RV8?	d8?x +/4=)h') 01) 
%c	"	#	)Vx C D 0QH Q8 Q Q.W( Wt WCx C%S/ CU3PS8_ C>Hc H3 Hd HT&4#.XHI&	&re   r   c                       e Zd ZU dZeeee   f   ed<   	 eeee   f   ed<   	 eeeee   f      ed<   	 ee	   ed<   	 e
e   ed<   	 dee	d f   dee	d f   d	d
fdZd Zy
)r   a  
    Returns a `dict`-like object resulting from the addition of two or
    more individual dictionaries of public holidays. The original dictionaries
    are available as a `list` in the attribute `holidays,` and
    `country` and `subdiv` attributes are added
    together and could become `list` s. Holiday names, when different,
    are merged. All years are calculated (expanded) for all operands.
    r,   r-   r4   holidaysr1   h1h2rD   Nc                    g | _         ||fD ]S  }t        |t              r&| j                   j                  |j                          9| j                   j	                  |       U i }|j
                  |j
                  z  |d<   |j                  xs |j                  |d<   |j                  xs |j                  |d<   dD ]  }t        ||d      rt        ||d      rt        ||      t        ||      k7  rlt        t        ||      t              rt        ||      nt        ||      g}t        t        ||      t              rt        ||      nt        ||      g}||z   }nt        ||d      xs t        ||d      }|dk(  r|||<   t        | ||        |j                  xs |j                  }	|j                  xs |j                  }
t        |	t              r
|	|
k(  r|	|d<   t        j                  | fi | |	r	|	f| _        yd| _        y)	u  
        Args:
            h1:
                The first HolidayBase object to add.

            h2:
                The other HolidayBase object to add.

        Example:

            >>> from holidays import country_holidays
            >>> nafta_holidays = country_holidays('US', years=2020) +     country_holidays('CA') + country_holidays('MX')
            >>> dates = sorted(nafta_holidays.items(), key=lambda x: x[0])
            >>> from pprint import pprint
            >>> pprint(dates[:10], width=72)
            [(datetime.date(2020, 1, 1), "Año Nuevo; New Year's Day"),
             (datetime.date(2020, 1, 20), 'Martin Luther King Jr. Day'),
             (datetime.date(2020, 2, 3), 'Día de la Constitución'),
             (datetime.date(2020, 2, 17), "Washington's Birthday"),
             (datetime.date(2020, 3, 16), 'Natalicio de Benito Juárez'),
             (datetime.date(2020, 4, 10), 'Good Friday'),
             (datetime.date(2020, 5, 1), 'Día del Trabajo'),
             (datetime.date(2020, 5, 25), 'Memorial Day'),
             (datetime.date(2020, 7, 1), 'Canada Day'),
             (datetime.date(2020, 7, 3), 'Independence Day (observed)')]
        r1   r2   r3   )r,   r-   r4   Nr4   rC   r.   )r  rR   r   extendr   r1   r2   r3   r[   rp  setattrrC   r:   rO   r   rM   r=   )r_   r  r  operandkwargsattra1a2r   h1_languageh2_languages              rd   rM   zHolidaySum.__init__-  s   > BxG':.$$W%5%56$$W-	   "$((RXX-w991		x[[7BKKz 4DD$'Bd+B%T):: "'"d"3T: B%!"d+,  "'"d"3T: B%!"d+, 
 RD$/J72tT3Jx$tdE*/ 46 kk8R%8%8kk8R%8%8k3'K;,F!,F:T,V, 6AK> b re   c                 ~    | j                   D ].  }|j                  |       | j                  t        d|             0 y )Nzdict[DateLike, str])r  r^   r   r   )r_   rb   r  s      rd   r^   zHolidaySum._populate  s2    }}Gd#KK2G<= %re   )rs  rt  ru  rv  r   rO   rp  rw  r   r   r\   rS   rM   r^   r.   re   rd   r   r     s     3S	>""-#tCy.!!+U3S	>*++0;Ds8OVI\12VI8=k<>W8XVI	VIp>re   r   )?__all__r   rX   bisectr   r   calendarr   collections.abcr	   r   r
   r   r   	functoolsr   r   r   pathlibr   typingr   r   r   r   r   dateutil.parserr   holidays.calendars.gregorianr   r   r   r   r   r   r   r   r    r!   r"   r#   r$   holidays.constantsr%   r&   r'   r(   holidays.helpersr)   r*   rO   r|  rT   rS   DateArgrt   r   ry  rz  r{  rv   r   r   r.   re   rd   <module>r     sl   4   ,  $ 8 8 % (  6 6 !    d c CC#&'
eCHo%
&xeS01uS#s]+U5c33G3L-MMN	%S#s"
#U3S#s+B%C
CD	%c3S()5c3S1H+II
JC
OPR  Xc]"
#\&$tSy/ \&~&p> p>re   