
    Gi                        d Z ddlZddlmZmZmZmZ ddlmZm	Z	m
Z
  G d de      Z G d de      Z G d	 d
e      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      ZdedefdZy)a	  Pydantic schemas for identities.json validation.

Provides a single source of truth for the structure of servers, accounts, option profiles,
and the top-level identities object. Used for validation on load and for
constructing new objects with all required fields.
    N)AnyDictListOptional)	BaseModel
ConfigDictfield_validatorc                   <    e Zd ZU  ed      ZdZeed<   dZeed<   y)AudioOptionsignoreextra   music_volumeambience_volumeN)	__name__
__module____qualname__r   model_configr   int__annotations__r        =C:\Users\dbart\PlayPalace11\clients\desktop\config_schemas.pyr   r      s     H-LL#OSr   r   c                       e Zd Z ed      Zy)SocialOptionsr   r   Nr   r   r   r   r   r   r   r   r   r          H-Lr   r   c                   <    e Zd ZU  ed      ZdZeed<   dZeed<   y)InterfaceOptionsr   r   Finvert_multiline_enter_behaviorTplay_typing_soundsN)	r   r   r   r   r   r!   boolr   r"   r   r   r   r    r       s"    H-L,1#T1##r   r    c                       e Zd Z ed      Zy)LocalTableOptionsr   r   Nr   r   r   r   r%   r%       r   r   r%   c                       e Zd ZU  ed      Z e       Zeed<    e       Z	eed<    e
       Ze
ed<    e       Zeed<   y)OptionsProfiler   r   local_tablesocialaudio	interfaceN)r   r   r   r   r   r%   r(   r   r   r)   r   r*   r    r+   r   r   r   r'   r'   $   s@    H-L%6%8K"8)OFM+&.E<("2"4I4r   r'   c                       e Zd ZU  ed      ZdZeed<   dZeed<   dZ	eed<   dZ
eed<   dZedz  ed	<   dZeed
<   dZeed<   deddfdZy)UserAccountr   r    
account_idusernamepasswordrefresh_tokenNrefresh_expires_atemailnotes_UserAccount__contextreturnc                 b    | j                   s#t        t        j                               | _         y y N)r/   struuiduuid4)selfr6   s     r   model_post_initzUserAccount.model_post_init8   s     !$**,/DO r   )r   r   r   r   r   r/   r:   r   r0   r1   r2   r3   r   r4   r5   r   r>   r   r   r   r-   r-   -   sh    H-LJHcHcM3%)d
)E3OE3O0 0 0r   r-   c                      e Zd ZU  ed      ZdZeed<   dZeed<   dZ	eed<   dZ
eed<   dZeed	<   i Zeeef   ed
<   dZee   ed<    e       Zeed<   dZeeeef      ed<   deddfdZ edd      ededefd              Zy)Serverr   r   r.   	server_idnamehosti@  portr5   accountsNlast_account_idoptions_profiletrusted_certificate_Server__contextr7   c                 b    | j                   s#t        t        j                               | _         y y r9   )rA   r:   r;   r<   )r=   rI   s     r   r>   zServer.model_post_initJ   s     ~~ .DN r   beforemodevc                 <    t        |t              rt        |      S |S r9   )
isinstancer:   r   clsrN   s     r   coerce_portzServer.coerce_portN   s     aq6Mr   )r   r   r   r   r   rA   r:   r   rB   rC   rD   r   r5   rE   r   r-   rF   r   r'   rG   rH   r   r>   r	   classmethodrS   r   r   r   r@   r@   =   s    H-LIsD#ND#ND#E3O')Hd3#$)%)OXc])&4&6O^648$sCx.18/ / / V(+C C   ,r   r@   c                   d    e Zd ZU  ed      ZdZee   ed<    e	       Z
e	ed<   i Zeeef   ed<   y)
Identitiesr   r   Nlast_server_iddefault_options_profileservers)r   r   r   r   r   rW   r   r:   r   r'   rX   rY   r   r@   r   r   r   rV   rV   V   s;    H-L$(NHSM(.<.>^>!#GT#v+#r   rV   c                       e Zd ZU dZ ed      Zeed<   eed<   e	e
   ed<    edd      ed	ed
efd              Z edd      ed	ed
efd              Zy)ExportedIdentitiesz6Schema for the exported/imported identities JSON file.r   r   description	timestamprY   rK   rL   rN   r7   c                 \    t        |t              r|j                         st        d      |S )Nzdescription cannot be empty)rP   r:   strip
ValueErrorrQ   s     r   description_not_emptyz(ExportedIdentities.description_not_emptyg   s'     !S!:;;r   c                      |st        d      |S )Nzservers cannot be empty)r`   rQ   s     r   servers_not_emptyz$ExportedIdentities.servers_not_emptyn   s     677r   N)r   r   r   __doc__r   r   r:   r   r   r   r@   r	   rT   r   ra   listrc   r   r   r   r[   r[   ^   s    @H-LN&\]2c c   3
 YX.# $   /r   r[   raw_datar7   c                     	 t         j                  |       }|j                         S # t        $ r t               j                         cY S w xY w)zParse raw data through the Identities schema and return a plain dict.

    On validation failure, returns default identities.
    )rV   model_validate
model_dump	Exception)rf   models     r   validate_identitiesrl   v   sF    
)))(3!! )|&&(()s   $' !A
A)rd   r;   typingr   r   r   r   pydanticr   r   r	   r   r   r    r%   r'   r-   r@   rV   r[   dictrl   r   r   r   <module>rp      s     , , ; ;9 .I .$y $.	 .5Y 50) 0 Y 2$ $ 0	)$ 	)4 	)r   