
    _f                        d Z ddlZddlZddlmZmZ ddlmZ ddlm	Z	 ddl
Z
ddlmZ ddlmZ ddlmZmZ dd	lmZ dd
lmZ  ee          ddededefd            Z ee          ddedededefd            Z ee          	 	 	 	 ddededededdez  ddez  defd            Z	 	 	 	 ddededededdez  ddez  defdZddedededefdZdedefdZdS )zHTools for generating QR codes. This module depends on the Segno library.    N)MappingAny)escape)	mark_safe)validate_call)PYDANTIC_CONFIG)DEFAULT_CACHE_ENABLEDDEFAULT_URL_SIGNATURE_ENABLED)make_qr_code_url)QRCodeOptions)configTdataqr_code_options
force_textc                     |r5t          j        t          |           fi |                                ddiS t          j        | fi |                                S )aa  Creates a QR code that encodes the given `data` with the given `qr_code_options`.

    :param str data: The data to encode
    :param qr_code_options: Options to create and serialize the QR code.
    :param bool force_text: Tells whether we want to force the `data` to be considered as text string and encoded in byte mode.
    :rtype: segno.QRCode
    modebyte)segnomakestrkw_make)r   r   r   s      F/var/www/html/env/lib/python3.11/site-packages/qr_code/qrcode/maker.pymake_qrr      sf      Oz#d))NN'>'>'@'@NNvNNNN:d88o5577888    returnc                     t          | ||          }t          j                    } |j        |fi |                                 |                                S )aZ  
    Creates a bytes object representing a QR code image for the provided `data`.

    :param str data: The data to encode
    :param qr_code_options: Options to create and serialize the QR code.
    :param bool force_text: Tells whether we want to force the `data` to be considered as text string and encoded in byte mode.
    :rtype: bytes
    r   )r   ioBytesIOsavekw_savegetvalue)r   r   r   qrouts        r   make_qr_code_imager%   !   sW     
:	>	>	>B
*,,CBGC--?**,,---<<>>r   Fuse_data_uri_for_svgalt_textclass_namesc           	         t          | ||          }|                                }|                    d           ||s|j        dk    rt	          | t
                    rod}g d}|j        r5|                    |j                  }	|	dk    r|d         ||	<   |j        |d<   |D ])}
	 |                     |
          } n# t          $ r Y &w xY wn't	          | t                    st          |           }n| }|rd| d	}nd}|j        dk    r1t          d
 |j        di | dt          |           d	| d          S |rt          j                    } |j        |fi |                                 |                                }t%          j        |                              d          }d| dt          |           d	| d}t          |          S t           |j        di |          S )a  
    Generates a <svg> or <img> tag representing the QR code for the given `data`.
    This tag can be embedded into an HTML document.

    When `image_format` is SVG and `use_data_uri_for_svg` it True, a base64 encoded image data URI is produced instead
    of inline SVG path.

    The `alt_text` argument indicates the value of the alternative text embedded in the `alt` attribute of the returned
    image tag. When set to `None`, the alternative text is set to the string representation of data. The alternative
    text is automatically escaped. You may use an empty string to explicitly set an empty alternative text.

    The `class_names` argument indicates the value of the `class` attribute of the returned
    image tag. When set to `None` or empty, the class attribute is not set.
    r   kindNpng )utf-8z
iso-8859-1z	shift-jisr   z class=""z
<img src="z" alt=">r-   z$<img src="data:image/svg+xml;base64, )r   r!   popimage_format
isinstancebytesencodingindexdecodeUnicodeDecodeErrorr   r   png_data_urir   r   r   r    r"   base64	b64encode
svg_inline)r   r   r   r&   r'   r(   r#   kw	encodingseie
class_attrr$   svg_pathsvg_b64_datahtmls                   r   make_embedded_qr_coderE   1   sP   0 
:	>	>	>B		 	 	"	"B FF6NNN1_5QUZ5Z5ZdE"" 	H<<<I' <___%=>>66$-aLIbM#2#;IaL  #{{1~~HE)   DD#&& 	4yyHHH ....


#u,,dobo&;&;&;&;ddF8DTDTddWadddeee .jll11..00111<<>>'1188AAklkk6RZK[K[kk^hkkk,,,,---s   'B>>
C
Cqr_code_argsc                 J    t          |          }t          | |||||          S )N)r   r&   r'   r(   )_options_from_argsrE   )r   rF   r   r&   r'   r(   optionss          r   make_qr_code_with_argsrJ   u   s<     !..G g*CWbj  yD   r   c                 $   |                     dt                    }t          |t                    s|dk     }|                     dt                    }t          |t                    s|dk     }t          |          }t          | ||||          S )Ncache_enabledFalseurl_signature_enabled)r   rL   rN   )r1   r	   r3   boolr
   rH   r   )r   rF   r   rL   rN   rI   s         r   make_qr_code_url_with_argsrP      s     $$_6KLLMmT** 5)W44(,,-DFcdd+T22 E$9W$D D ..GD'jP]  vK  L  L  L  Lr   argsc                     |                      d          }|r%t          |t                    st          d          n*d |                                 D             }t          di |}|S )z=Returns a QRCodeOptions instance from the provided arguments.rI   z3The options argument must be of type QRCodeOptions.c                 *    i | ]\  }}||d k    r|ndS )NoneNr0   ).0kvs      r   
<dictcomp>z&_options_from_args.<locals>.<dictcomp>   s*    EEE1aa6kktEEEr   r0   )getr3   r   	TypeErroritems)rQ   rI   r=   s      r   rH   rH      sy    hhy!!G &'=11 	SQRRR	S FE

EEE%%"%%Nr   )T)TFNN) __doc__r:   r   typingr   r   django.utils.htmlr   django.utils.safestringr   r   pydanticr   qr_code.qrcoder   qr_code.qrcode.constantsr	   r
   qr_code.qrcode.server   qr_code.qrcode.utilsr   rO   r   r4   r%   r   rE   dictrJ   rP   rH   r0   r   r   <module>rf      s   N N  				         $ $ $ $ $ $ - - - - - -  " " " " " " * * * * * * Y Y Y Y Y Y Y Y 1 1 1 1 1 1 . . . . . . o&&&9 9# 9 94 9 9 9 '&9 o&&& S = d ^c    '& o&&& !&"@. @.
@."@. @. 	@.
 Sj@. @. 	@. @. @. '&@.L !&" 
  	
 Sj  	   L LS L L$ LZ] L L L L
W 
 
 
 
 
 
 
r   