o
    ҷh                     @  s  d dl mZ ddlmZmZ d dlmZ d dlZd dlZddl	m
Z
 ddl	mZ eG dd	 d	ZeG d
d dZeG dd dZeG dd dZeG dd dZG dd dejZeG dd dZ		d*d+ddZd,d!d"Zd-d#d$Zd-d%d&Zed'eG d(d) d)ZdS ).    )annotations   )event_classT_JSON_DICT)	dataclassN)dom)pagec                   @  sJ   e Zd ZU ded< ded< ded< ded< ded< dd Zed	d
 ZdS )
CreditCardstrnumbernameexpiry_monthexpiry_yearcvcc                 C  s<   t  }| j|d< | j|d< | j|d< | j|d< | j|d< |S )Nr   r   expiryMonth
expiryYearr   )dictr   r   r   r   r   selfjson r   c/var/www/html/venv/lib/python3.10/site-packages/selenium/webdriver/common/devtools/v118/autofill.pyto_json!   s   




zCreditCard.to_jsonc                 C  s:   | t |d t |d t |d t |d t |d dS )Nr   r   r   r   r   )r   r   r   r   r   r
   clsr   r   r   r   	from_json*   s   




zCreditCard.from_jsonN__name__
__module____qualname____annotations__r   classmethodr   r   r   r   r   r	      s   
 	r	   c                   @  s2   e Zd ZU ded< ded< dd Zedd ZdS )	AddressFieldr
   r   valuec                 C  s   t  }| j|d< | j|d< |S )Nr   r$   )r   r   r$   r   r   r   r   r   =   s   

zAddressField.to_jsonc                 C  s   | t |d t |d dS )Nr   r$   )r   r$   r   r   r   r   r   r   C   s   

zAddressField.from_jsonNr   r   r   r   r   r#   5   s   
 r#   c                   @  .   e Zd ZU dZded< dd Zedd ZdS )	AddressFieldsz#
    A list of address fields.
    typing.List[AddressField]fieldsc                 C     t  }dd | jD |d< |S )Nc                 S     g | ]}|  qS r   r   .0ir   r   r   
<listcomp>T       z)AddressFields.to_json.<locals>.<listcomp>r(   r   r(   r   r   r   r   r   R      zAddressFields.to_jsonc                 C     | dd |d D dS )Nc                 S     g | ]}t |qS r   r#   r   r,   r   r   r   r/   Z       z+AddressFields.from_json.<locals>.<listcomp>r(   r(   r   r   r   r   r   r   W      zAddressFields.from_jsonNr   r   r    __doc__r!   r   r"   r   r   r   r   r   r&   K   s   
 r&   c                   @  s*   e Zd ZU ded< dd Zedd ZdS )Addressr'   r(   c                 C  r)   )Nc                 S  r*   r   r+   r,   r   r   r   r/   e   r0   z#Address.to_json.<locals>.<listcomp>r(   r1   r   r   r   r   r   c   r2   zAddress.to_jsonc                 C  r3   )Nc                 S  r4   r   r5   r,   r   r   r   r/   k   r6   z%Address.from_json.<locals>.<listcomp>r(   r7   r   r   r   r   r   r   h   r8   zAddress.from_jsonNr   r   r   r   r   r;   ^   s
   
 r;   c                   @  r%   )		AddressUIa  
    Defines how an address can be displayed like in chrome://settings/addresses.
    Address UI is a two dimensional array, each inner array is an "address information line", and when rendered in a UI surface should be displayed as such.
    The following address UI for instance:
    [[{name: "GIVE_NAME", value: "Jon"}, {name: "FAMILY_NAME", value: "Doe"}], [{name: "CITY", value: "Munich"}, {name: "ZIP", value: "81456"}]]
    should allow the receiver to render:
    Jon Doe
    Munich 81456
    ztyping.List[AddressFields]address_fieldsc                 C  r)   )Nc                 S  r*   r   r+   r,   r   r   r   r/      r0   z%AddressUI.to_json.<locals>.<listcomp>addressFields)r   r=   r   r   r   r   r   }   r2   zAddressUI.to_jsonc                 C  r3   )Nc                 S  r4   r   )r&   r   r,   r   r   r   r/      r6   z'AddressUI.from_json.<locals>.<listcomp>r>   )r=   r   r   r   r   r   r      r8   zAddressUI.from_jsonNr9   r   r   r   r   r<   o   s   
 
r<   c                   @  s,   e Zd ZdZdZdZdd Zedd ZdS )	FillingStrategyzw
    Specified whether a filled field was done so by using the html autocomplete attribute or autofill heuristics.
    autocompleteAttributeautofillInferredc                 C  s   | j S N)r$   )r   r   r   r   r      s   zFillingStrategy.to_jsonc                 C  s   | |S rB   r   r   r   r   r   r      s   zFillingStrategy.from_jsonN)	r   r   r    r:   AUTOCOMPLETE_ATTRIBUTEAUTOFILL_INFERREDr   r"   r   r   r   r   r   r?      s    r?   c                   @  sR   e Zd ZU ded< ded< ded< ded< ded< ded< d	d
 Zedd ZdS )FilledFieldr
   	html_typeid_r   r$   autofill_typer?   filling_strategyc                 C  sJ   t  }| j|d< | j|d< | j|d< | j|d< | j|d< | j |d< |S )NhtmlTypeidr   r$   autofillTypefillingStrategy)r   rF   rG   r   r$   rH   rI   r   r   r   r   r   r      s   




zFilledField.to_jsonc              
   C  sF   | t |d t |d t |d t |d t |d t|d dS )NrJ   rK   r   r$   rL   rM   )rF   rG   r   r$   rH   rI   )r
   r?   r   r   r   r   r   r      s   




zFilledField.from_jsonNr   r   r   r   r   rE      s   
 
rE   field_iddom.BackendNodeIdframe_idtyping.Optional[page.FrameId]cardreturn0typing.Generator[T_JSON_DICT, T_JSON_DICT, None]c                 c  sH    t  }|  |d< |dur| |d< | |d< d|d}|V }dS )a  
    Trigger autofill on a form identified by the fieldId.
    If the field and related form cannot be autofilled, returns an error.

    :param field_id: Identifies a field that serves as an anchor for autofill.
    :param frame_id: *(Optional)* Identifies the frame that field belongs to.
    :param card: Credit card information to fill out the form. Credit card data is not saved.
    fieldIdNframeIdrR   zAutofill.triggermethodparams)r   r   )rN   rP   rR   rY   cmd_dictr   r   r   r   trigger   s   
r[   	addressestyping.List[Address]c                 c  s.    t  }dd | D |d< d|d}|V }dS )zh
    Set addresses so that developers can verify their forms implementation.

    :param addresses:
    c                 S  r*   r   r+   r,   r   r   r   r/      r0   z!set_addresses.<locals>.<listcomp>r\   zAutofill.setAddressesrW   N)r   )r\   rY   rZ   r   r   r   r   set_addresses   s   
r^   c                  c      ddi} | V }dS )z1
    Disables autofill domain notifications.
    rX   zAutofill.disableNr   rZ   r   r   r   r   disable      
ra   c                  c  r_   )z0
    Enables autofill domain notifications.
    rX   zAutofill.enableNr   r`   r   r   r   enable   rb   rc   zAutofill.addressFormFilledc                   @  s0   e Zd ZU dZded< ded< edd	d
ZdS )AddressFormFilledz1
    Emitted when an address form is filled.
    ztyping.List[FilledField]filled_fieldsr<   
address_uir   r   rS   c                 C  s$   | dd |d D t |d dS )Nc                 S  r4   r   )rE   r   r,   r   r   r   r/     r6   z/AddressFormFilled.from_json.<locals>.<listcomp>filledFields	addressUi)re   rf   )r<   r   r   r   r   r   r     s   zAddressFormFilled.from_jsonN)r   r   rS   rd   )r   r   r    r:   r!   r"   r   r   r   r   r   rd      s   
 rd   )NN)rN   rO   rP   rQ   rR   r	   rS   rT   )r\   r]   rS   rT   )rS   rT   )
__future__r   utilr   r   dataclassesr   enumtyping r   r   r	   r#   r&   r;   r<   Enumr?   rE   r[   r^   ra   rc   rd   r   r   r   r   <module>   s:   $+




