a
    oDf                     @   sD   d dl mZmZ G dd deZG dd deZG dd deZdS )	    )	Parameter
_is_numberc                       s4   e Zd ZdZd
 fdd	Zdd Zddd	Z  ZS )Alignz
    A Parameter type to validate alignment options. Supports 'auto', 'start',
    'center', 'end' or a two-tuple of these values corresponding
    to the (vertical, horizontal) alignment.
    startc                    s$   t  jf d|i| | | d S )Ndefaultsuper__init__	_validate)selfr   params	__class__ Y/nfs/NAS7/SABIOD/METHODE/ermites/ermites_venv/lib/python3.9/site-packages/panel/_param.pyr	      s    zAlign.__init__c                 C   s   |  || j d S N_validate_value
allow_Noner   valr   r   r   r
      s    zAlign._validateautor   centerendc                    s`   |d u r|s@| v s@t |trDt|dkrDt fdd|D rDd S td| jd|dd S )N   c                 3   s   | ]}| v V  qd S r   r   ).0vvalidr   r   	<genexpr>       z(Align._validate_value.<locals>.<genexpr>zAlign parameter z| must be one of 'start', 'center', 'end' or a two-tuple specifying the (vertical, horizontal) values for the alignment, not .)
isinstancetuplelenall
ValueErrorname)r   r   r   r   r   r   r   r      s    

zAlign._validate_value)r   )r   __name__
__module____qualname____doc__r	   r
   r   __classcell__r   r   r   r   r      s   r   c                       s2   e Zd ZdZd
 fdd	Zdd Zdd	 Z  ZS )Aspectz[
    A Parameter type to validate aspect ratios. Supports numeric values
    and auto.
    NTc                    s&   t  jf ||d| | | d S N)r   r   r   r   r   r   r   r   r   r   r	   #   s    zAspect.__init__c                 C   s   |  || j d S r   r   r   r   r   r   r
   '   s    zAspect._validatec                 C   s6   |d u r|s|dkst |r d S td| jdd S )Nr   zAspect parameter z1 only takes numeric values or the literal 'auto'.)r   r'   r(   r   r   r   r   r   r   r   *   s
    zAspect._validate_value)NTr)   r   r   r   r   r/      s   r/   c                       sR   e Zd ZdZd fdd	Zdd Zdd	 Zd
d Zedd Z	edd Z
  ZS )Marginz
    A Parameter type to validate margins. Following CSS conventions
    the parameter supports numeric values and tuples of length 2 and 4
    corresponding to (vertical, horizontal) margins and (top, right,
    bottom, left) margins.
    NTc                    s&   t  jf ||d| | | d S r0   r   r1   r   r   r   r	   ;   s    zMargin.__init__c                 C   s>   |d u r|rd S t |ttfs:td| jdt|dd S )NMargin parameter z8 only takes integer and tuple values, not values of not r"   )r#   r$   intr'   r(   typer2   r   r   r   r   ?   s    
zMargin._validate_valuec                 C   s0   t |trt|dv rd S td| jdd S )N)r      r4   zh only takes integer and tuple values of length 2 (vertical, horizontal) or 4 (top, right, bottom, left).)r#   r$   r%   r'   r(   r   r   r   r   _validate_lengthH   s
    zMargin._validate_lengthc                 C   s   |  || j | | d S r   )r   r   r8   r   r   r   r   r
   Q   s    zMargin._validatec                 C   s"   |d u rdS t |trt|S |S Nnull)r#   r$   listclsvaluer   r   r   	serializeU   s    zMargin.serializec                 C   s"   |dkrd S t |trt|S |S r9   )r#   r;   r$   r<   r   r   r   deserialize[   s    zMargin.deserialize)NT)r*   r+   r,   r-   r	   r   r8   r
   classmethodr?   r@   r.   r   r   r   r   r3   3   s   		
r3   N)paramr   r   r   r/   r3   r   r   r   r   <module>   s   