Ë
    èlÖi€  ã                   ó0   — d dl mZ d dlmZ d dlmZ dd„Zy)é    )Úutils)ÚRow)Ú
TypeTesterNc           
      ó  ‡— ddl m} g }t        j                  |«      s|g}t        j                  |«      s|g}|||gz   }g }	| j                  D ]  Št        ˆfd„|D «       «      }
t        |
«      }t        |
«      dk(  r|	j                  |
d   «       n|	j                  |
«       |D ]%  }|j                  t        ||‰|   gz   |«      «       Œ' Œ� |D �cg c]*  }| j                  | j                  j                  |«         ‘Œ, }}|�t        |t        «      rX|€
t        «       n|}t        t!        ||«      «      }|j#                  |j$                  «       ||_        |j'                  ||«      }n|t        |«      z   } ||||«      S c c}w )a.  
    Create a new table with columns converted into rows values.

    For example:

    +---------+----------+--------+-------+
    |  name   | gender   | race   | age   |
    +=========+==========+========+=======+
    |  Jane   | female   | black  | 24    |
    +---------+----------+--------+-------+
    |  Jack   | male     | white  | 35    |
    +---------+----------+--------+-------+
    |  Joe    | male     | black  | 28    |
    +---------+----------+--------+-------+

    can be normalized on columns 'gender', 'race' and 'age':

    +---------+-----------+---------+
    |  name   | property  | value   |
    +=========+===========+=========+
    |  Jane   | gender    | female  |
    +---------+-----------+---------+
    |  Jane   | race      | black   |
    +---------+-----------+---------+
    |  Jane   | age       | 24      |
    +---------+-----------+---------+
    |  ...    |  ...      |  ...    |
    +---------+-----------+---------+

    This is the opposite of :meth:`.Table.denormalize`.

    :param key:
        A column name or a sequence of column names that should be
        maintained as they are in the normalized self. Typically these
        are the tables unique identifiers and any metadata about them.
    :param properties:
        A column name or a sequence of column names that should be
        converted to properties in the new self.
    :param property_column:
        The name to use for the column containing the property names.
    :param value_column:
        The name to use for the column containing the property values.
    :param column_types:
        A sequence of two column types for the property and value column in
        that order or an instance of :class:`.TypeTester`. Defaults to a
        generic :class:`.TypeTester`.
    :returns:
        A new :class:`.Table`.
    r   )ÚTablec              3   ó(   •K  — | ]	  }‰|   –— Œ y ­w)N© )Ú.0ÚnÚrows     €úZ/var/www/html/strategist-ai/venv_dbt/lib/python3.12/site-packages/agate/table/normalize.pyú	<genexpr>znormalize.<locals>.<genexpr>G   s   øè ø€ Ò&˜Q�#�a•&Ñ&ùs   ƒé   )Úagate.tabler   r   Ú
issequenceÚ_rowsÚtupleÚlistÚlenÚappendr   Ú_column_typesÚ_column_namesÚindexÚ
isinstancer   ÚdictÚzipÚupdateÚ_forceÚrun)ÚselfÚkeyÚ
propertiesÚproperty_columnÚvalue_columnÚcolumn_typesr   Únew_rowsÚnew_column_namesÚ	row_namesÚkÚleft_rowÚfÚnameÚkey_column_typesÚtesterÚforce_updateÚnew_column_typesr   s                     @r   Ú	normalizer1      s�  ø€ õd "à€Hä×Ñ˜CÔ Øˆeˆä×Ñ˜JÔ'Ø �\ˆ
à˜o¨|Ð<Ñ<Ðà€Ià�z‰zò 
MˆÜÓ& #Ô&Ó&ˆÜ˜“7ˆäˆq‹6�QŠ;Ø×Ñ˜Q˜q™TÕ"à×Ñ˜QÔàò 	MˆAØ�O‰OœC ¨Q°°A±¨KÑ!7Ð:JÓKÕLñ	Mð
Mð X[Ö[Èt˜×*Ñ*¨4×+=Ñ+=×+CÑ+CÀDÓ+IÓJÐ[ÐÐ[àÐœz¨,¼
ÔCØ!-Ð!5””¸<ˆÜœC Ð%5Ó6Ó7ˆØ×Ñ˜FŸM™MÔ*Ø$ˆŒà!Ÿ:™: hÐ0@ÓAÑà+¬d°<Ó.@Ñ@Ðá�Ð+Ð-=Ó>Ð>ùò \s   Ã/F)ÚpropertyÚvalueN)Úagater   Ú
agate.rowsr   Úagate.type_testerr   r1   r	   ó    r   ú<module>r8      s   ðÝ Ý Ý (ôX?r7   