Ë
    ×[ÃiÅ,  ã                  óJ  — d dl mZ d dlZd dlZd dlZd dlmZ	 ddl
mZ ej                  rddlmZ  G d„ d«      Z G d„ d	«      Z G d
„ de«      Z G d„ d«      Z G d„ de«      Z G d„ d«      Zdd„Zdd„Z G d„ deee	j0                  «      Z G d„ dee	j0                  «      Zy)é    )ÚannotationsNé   )ÚQuery)Ú
SQLAlchemyc                  ó   — e Zd ZdZdd„Zy)Ú_QueryPropertyzRA class property that creates a query object for a model.

    :meta private:
    c                óX   — |j                  ||j                  j                  «       ¬«      S )N)Úsession)Úquery_classÚ__fsa__r
   )ÚselfÚobjÚclss      úN/var/www/timesheet/venv/lib/python3.12/site-packages/flask_sqlalchemy/model.pyÚ__get__z_QueryProperty.__get__   s*   € Ø�‰Ø˜Ÿ™×,Ñ,Ó.ð ó 
ð 	
ó    N)r   zModel | Noner   ztype[Model]Úreturnr   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   © r   r   r   r      s   „ ñô

r   r   c                  óP   — e Zd ZU dZded<   	 eZded<   	  e«       Zded<   	 d
d„Z	y	)ÚModela€  The base class of the :attr:`.SQLAlchemy.Model` declarative model class.

    To define models, subclass :attr:`db.Model <.SQLAlchemy.Model>`, not this. To
    customize ``db.Model``, subclass this and pass it as ``model_class`` to
    :class:`.SQLAlchemy`. To customize ``db.Model`` at the metaclass level, pass an
    already created declarative model class as ``model_class``.
    zt.ClassVar[SQLAlchemy]r   zt.ClassVar[type[Query]]r   zt.ClassVar[Query]Úqueryc                ó.  — t        j                  | «      }|€J ‚|j                  rdt        | «      › d�}nE|j                  rdt        | «      › d�}n)dj                  t        t        |j                  «      «      }dt        | «      j                  › d|› d�S )Nz(transient ú)z	(pending z, ú<ú ú>)ÚsaÚinspectÚ	transientÚidÚpendingÚjoinÚmapÚstrÚidentityÚtyper   )r   ÚstateÚpks      r   Ú__repr__zModel.__repr__8   s‡   € Ü—
‘
˜4Ó ˆØÐ Ð Ð à�?Š?Øœr $›x˜j¨Ð*‰BØ�]Š]ØœR ›X˜J aÐ(‰Bà—‘œ3œs E§N¡NÓ3Ó4ˆBà”4˜“:×&Ñ&Ð' q¨¨¨AÐ.Ð.r   N)r   r(   )
r   r   r   r   Ú__annotations__r   r   r   r   r-   r   r   r   r   r      s@   … ñð $Ó#ðð
 ,1€KÐ(Ó0ðñ  .Ó/€EÐÓ/ðô/r   r   c                  óN   ‡ — e Zd ZU dZded<   ded<   	 	 	 	 	 	 	 	 	 	 dˆ fd„Zˆ xZS )ÚBindMetaMixina  Metaclass mixin that sets a model's ``metadata`` based on its ``__bind_key__``.

    If the model sets ``metadata`` or ``__table__`` directly, ``__bind_key__`` is
    ignored. If the ``metadata`` is the same as the parent model, it will not be set
    directly on the child model.
    r   r   úsa.MetaDataÚmetadatac                óâ   •— d| j                   v sNd| j                   v s@t        | dd «      }t        | dd «      }| j                  j                  |«      }||ur|| _        t        ‰| �  |||fi |¤Ž y )Nr2   Ú	__table__Ú__bind_key__)Ú__dict__Úgetattrr   Ú_make_metadatar2   ÚsuperÚ__init__)	r   ÚnameÚbasesÚdÚkwargsÚbind_keyÚparent_metadatar2   Ú	__class__s	           €r   r:   zBindMetaMixin.__init__Q   sq   ø€ ð ˜cŸl™lÑ*¨k¸S¿\¹\Ñ.IÜ˜s N°DÓ9ˆHÜ% c¨:°tÓ<ˆOØ—{‘{×1Ñ1°(Ó;ˆHà˜Ñ.Ø'�”ä‰Ñ˜˜u aÑ2¨6Ó2r   ©
r;   r(   r<   ztuple[type, ...]r=   zdict[str, t.Any]r>   út.Anyr   ÚNone)r   r   r   r   r.   r:   Ú__classcell__©rA   s   @r   r0   r0   F   sH   ø… ñð ÓØÓð3Øð3Ø/ð3Ø4Dð3ØPUð3à	÷3ñ 3r   r0   c                  óD   ‡ — e Zd ZU dZded<   ded<   edˆ fd„«       Zˆ xZS )Ú	BindMixina  DeclarativeBase mixin to set a model's ``metadata`` based on ``__bind_key__``.

    If no ``__bind_key__`` is specified, the model will use the default metadata
    provided by ``DeclarativeBase`` or ``DeclarativeBaseNoMeta``.
    If the model doesn't set ``metadata`` or ``__table__`` directly
    and does set ``__bind_key__``, the model will use the metadata
    for the specified bind key.
    If the ``metadata`` is the same as the parent model, it will not be set
    directly on the child model.

    .. versionchanged:: 3.1.0
    r   r   r1   r2   c                óô   •— d| j                   v sZd| j                   v sLt        | d«      r@t        | dd «      }t        | dd «      }| j                  j	                  |«      }||ur|| _        t        ‰| �  di |¤Ž y )Nr2   r4   r5   r   )r6   Úhasattrr7   r   r8   r2   r9   Ú__init_subclass__)r   r>   r?   r@   r2   rA   s        €r   rK   zBindMixin.__init_subclass__p   sx   ø€ à˜cŸl™lÑ*¨k¸S¿\¹\Ñ.IÌwØ�ôP
ô ˜s N°DÓ9ˆHÜ% c¨:°tÓ<ˆOØ—{‘{×1Ñ1°(Ó;ˆHà˜Ñ.Ø'�”ä‰Ñ!Ñ+ FÓ+r   )r   zt.Type[BindMixin]r>   út.Dict[str, t.Any]r   rD   )r   r   r   r   r.   ÚclassmethodrK   rE   rF   s   @r   rH   rH   _   s(   ø… ñð ÓØÓàô,ó ô,r   rH   c                  ó`   ‡ — e Zd ZU dZded<   ded<   ded<   	 	 	 	 	 	 	 	 	 	 d
ˆ fd„Zdd	„Zˆ xZS )ÚNameMetaMixinaP  Metaclass mixin that sets a model's ``__tablename__`` by converting the
    ``CamelCase`` class name to ``snake_case``. A name is set for non-abstract models
    that do not otherwise define ``__tablename__``. If a model does not define a primary
    key, it will not generate a name or ``__table__``, for single-table inheritance.
    r1   r2   r(   Ú__tablename__úsa.Tabler4   c                óÔ   •— t        | «      rt        | j                  «      | _        t	        ‰| �  |||fi |¤Ž d| j                  vr"d| j                  v r| j                  d   €| `y y y y )NrP   r4   )Úshould_set_tablenameÚcamel_to_snake_caser   rP   r9   r:   r6   r4   )r   r;   r<   r=   r>   rA   s        €r   r:   zNameMetaMixin.__init__Š   sq   ø€ ô   Ô$Ü 3°C·L±LÓ AˆCÔä‰Ñ˜˜u aÑ2¨6Ò2ð  3§<¡<Ñ/Ø˜sŸ|™|Ñ+Ø—‘˜[Ñ)Ð1à‘ð 2ð ,ð 0r   c                óò  — |j                  d«      }|€|d   }n
|› d|d   › �}|| j                  j                  v rt        j                  |i |¤ŽS |D ]Y  }t        |t        j                  «      r|j                  st        |t        j                  «      sŒDt        j                  |i |¤Žc S  | j                  dd D ]  }d|j                  v sŒ n t        j                  |i |¤ŽS d| j                  v r| `y©	a  This is called by SQLAlchemy during mapper setup. It determines the final
        table object that the model will use.

        If no primary key is found, that indicates single-table inheritance, so no table
        will be created and ``__tablename__`` will be unset.
        ÚschemaNr   ú.r   éÿÿÿÿr4   rP   ©Úgetr2   Útablesr!   ÚTableÚ
isinstanceÚColumnÚprimary_keyÚPrimaryKeyConstraintÚ__mro__r6   rP   ©r   Úargsr>   rW   ÚkeyÚargÚbases          r   Ú__table_cls__zNameMetaMixin.__table_cls__š   s  € ð —‘˜HÓ%ˆàˆ>Ø�q‘'‰Cà�H˜A˜d 1™g˜YÐ'ˆCð �#—,‘,×%Ñ%Ñ%Ü—8‘8˜TÐ, VÑ,Ð,ð ò 	1ˆCÜ˜3¤§	¡	Ô*¨s¯ªÄ:Ø”R×,Ñ,õDô —x‘x Ð0¨Ñ0Ò0ð		1ð —K‘K  "Ð%ò 	-ˆDØ˜dŸm™mÒ+Ùð	-ô —8‘8˜TÐ, VÑ,Ð,ð ˜cŸl™lÑ*ØÐ!àr   rB   ©rd   rC   r>   rC   r   zsa.Table | None)r   r   r   r   r.   r:   rh   rE   rF   s   @r   rO   rO      sN   ø… ñð ÓØÓØÓðØðØ/ðØ4DðØPUðà	õ÷ 'r   rO   c                  ó`   ‡ — e Zd ZU dZded<   ded<   ded<   ed
ˆ fd„«       Zedd	„«       Zˆ xZS )Ú	NameMixinau  DeclarativeBase mixin that sets a model's ``__tablename__`` by converting the
    ``CamelCase`` class name to ``snake_case``. A name is set for non-abstract models
    that do not otherwise define ``__tablename__``. If a model does not define a primary
    key, it will not generate a name or ``__table__``, for single-table inheritance.

    .. versionchanged:: 3.1.0
    r1   r2   r(   rP   rQ   r4   c                óÎ   •— t        | «      rt        | j                  «      | _        t	        ‰| �  di |¤Ž d| j                  vr"d| j                  v r| j                  d   €| `y y y y )NrP   r4   r   )rS   rT   r   rP   r9   rK   r6   r4   )r   r>   rA   s     €r   rK   zNameMixin.__init_subclass__Ñ   si   ø€ ä Ô$Ü 3°C·L±LÓ AˆCÔä‰Ñ!Ñ+ FÒ+ð  3§<¡<Ñ/Ø˜sŸ|™|Ñ+Ø—‘˜[Ñ)Ð1à‘ð 2ð ,ð 0r   c                óò  — |j                  d«      }|€|d   }n
|› d|d   › �}|| j                  j                  v rt        j                  |i |¤ŽS |D ]Y  }t        |t        j                  «      r|j                  st        |t        j                  «      sŒDt        j                  |i |¤Žc S  | j                  dd D ]  }d|j                  v sŒ n t        j                  |i |¤ŽS d| j                  v r| `yrV   rZ   rc   s          r   rh   zNameMixin.__table_cls__à   s  € ð —‘˜HÓ%ˆàˆ>Ø�q‘'‰Cà�H˜A˜d 1™g˜YÐ'ˆCð �#—,‘,×%Ñ%Ñ%Ü—8‘8˜TÐ, VÑ,Ð,ð ò 	1ˆCÜ˜3¤§	¡	Ô*¨s¯ªÄ:Ø”R×,Ñ,õDô —x‘x Ð0¨Ñ0Ò0ð		1ð —K‘K  "Ð%ò 	-ˆDØ˜dŸm™mÒ+Ùð	-ô —8‘8˜TÐ, VÑ,Ð,ð ˜cŸl™lÑ*ØÐ!àr   )r   zt.Type[NameMixin]r>   rL   r   rD   ri   )	r   r   r   r   r.   rM   rK   rh   rE   rF   s   @r   rk   rk   Ä   sB   ø… ñð ÓØÓØÓàôó ðð ò'ó ô'r   rk   c                ó   — | j                   j                  dd«      set        | t        j                  t        j
                  f«      st        d„ | j                  dd D «       «      rt        d„ | j                  D «       «      ry| j                  D ]½  }d|j                   vrŒt        |j                   d   t        j                  «      r y|| u xs{ |j                   j                  dd«      xs] t        |t        j                  «      xs@ t        |t        j                  j                  «      xs t        |t        j
                  «        c S  y)	a  Determine whether ``__tablename__`` should be generated for a model.

    -   If no class in the MRO sets a name, one should be generated.
    -   If a declared attr is found, it should be used instead.
    -   If a name is found, it should be used if the class is a mixin, otherwise one
        should be generated.
    -   Abstract models should not have one generated.

    Later, ``__table_cls__`` will determine if the model looks like single or
    joined-table inheritance. If no primary key is found, the name will be unset.
    Ú__abstract__Fc              3  óP   K  — | ]  }t        |t        j                  «      –— Œ  y ­w©N)r^   Úsa_ormÚDeclarativeMeta©Ú.0Úbs     r   ú	<genexpr>z'should_set_tablename.<locals>.<genexpr>  s   è ø€ ÒWÀ!œ
 1¤f×&<Ñ&<×=ÑWùs   ‚$&r   Nc              3  óh   K  — | ]*  }|t         j                  u xs |t         j                  u –— Œ, y ­wrq   )rr   ÚDeclarativeBaseÚDeclarativeBaseNoMetart   s     r   rw   z'should_set_tablename.<locals>.<genexpr>  s6   è ø€ ò 
àð ”&×(Ñ(Ð(ÒM¨A´×1MÑ1MÐ,MÓMñ
ùs   ‚02rP   T)r6   r[   Ú
issubclassrr   ry   rz   Úanyrb   Ú	__bases__r^   Údeclared_attrrs   Údecl_apiÚDeclarativeAttributeIntercept)r   rg   s     r   rS   rS     s(  € ð 	�‰×Ñ˜¨Ô/ä˜3¤×!7Ñ!7¼×9UÑ9UÐ VÔWÜÑWÀsÇ{Á{ÐSTÐSUÀÔWÔWäñ 
à—]‘]ô
ô 
ð
 à—‘ò 
ˆØ $§-¡-Ñ/Øä�d—m‘m OÑ4´f×6JÑ6JÔKÙð �CˆKò 	Ø�}‰}× Ñ  °Ó7ò	ô ˜4¤×!7Ñ!7Ó8ò Bä˜d¤F§O¡O×$QÑ$QÓRòBô ˜d¤F×$@Ñ$@ÓAðð
ò 	
ð
ð( r   c                ón   — t        j                  dd| «      } | j                  «       j                  d«      S )z/Convert a ``CamelCase`` name to ``snake_case``.z(((?<=[a-z0-9])[A-Z]|(?!^)[A-Z](?=[a-z]))z_\1Ú_)ÚreÚsubÚlowerÚlstrip)r;   s    r   rT   rT   ;  s,   € ä�6‰6Ð=¸vÀtÓL€DØ�:‰:‹<×Ñ˜sÓ#Ð#r   c                  ó   — e Zd ZdZy)ÚDefaultMetaúgSQLAlchemy declarative metaclass that provides ``__bind_key__`` and
    ``__tablename__`` support.
    N©r   r   r   r   r   r   r   rˆ   rˆ   A  ó   „ òr   rˆ   c                  ó   — e Zd ZdZy)ÚDefaultMetaNoNamer‰   NrŠ   r   r   r   r�   r�   G  r‹   r   r�   )r   r*   r   Úbool)r;   r(   r   r(   )Ú
__future__r   rƒ   ÚtypingÚtÚ
sqlalchemyr!   Úsqlalchemy.ormÚormrr   r   r   ÚTYPE_CHECKINGÚ	extensionr   r   r   r*   r0   rH   rO   rk   rS   rT   rs   rˆ   r�   r   r   r   ú<module>r—      sž   ðÝ "ã 	Û ã Ý å à‡?‚?Ý%÷	
ñ 	
÷(/ñ (/ôV3�Dô 3÷2,ñ ,ô@B�Dô B÷JDñ DóN-ó`$ô�- °×0FÑ0Fô ô˜ v×'=Ñ'=õ r   