Ë
    ÚŠ±jo ã                   ó2  — d Z ddlZddlZddlZddl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mZ ddlZddlmZ ddlmZ ddl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mZmZmZm Z m!Z!m"Z" ddlm#Z# ddl$m%Z% dZ&dZ'e�dRd„«       Z(d„ Z)d„ Z* e)dd¬«      	 	 	 	 �dSd„«       Z+ e ejX                  d«      jZ                  d«      Z.	 	 	 	 	 	 �dTd„Z/	 	 	 �dUd„Z0�dVd„Z1�dWd„Z2 e)dd¬«      �dXd „«       Z3	 	 �dYd!„Z4�dZd"„Z5�d[d#„Z6�d\d$„Z7 e)dd¬«      �d]d%„«       Z8	 	 �d^d&„Z9�d_d'„Z:�d`d)„Z;�dRd*„Z<�dRd+„Z=�dRd,„Z>�dad-„Z?�dbd.„Z@d/„ ZAd0„ ZBd1„ ZCd2„ ZD�dad3„ZE�dad4„ZFd5d6d7d8d9d:d;œZGd<„ ZHd=„ ZIi d>d?“d@dA“dBdC“dDdE“dFdG“dHdI“dJdK“d(dL“dMdN“dOdP“dQdR“dSdT“dUdV“dWdX“dYdZ“d[d\“d]d^“i d_d`“dadb“dcdd“dedC“dfdg“dhdi“djdk“dldm“dndo“dpdm“dqdr“dsdt“dudv“dwdx“dydz“d{d|“d}d~“¥i dd€“d�d‚“dƒd„“d…d„“d†d‡“dˆd‰“dŠd‹“dŒd�“dŽd�“d�d�“d‘d’“d“d”“d•d–“d—d˜“dd™“dšd›“dœd�“¥i dždŸ“d d¡“d¢d£“d¤d¥“d¦d§“d¨d£“d©dª“d«d¬“d­d®“d¯d°“d±d²“d³d´“dµd¶“d·d¸“d¹dº“d»d¼“d½d¾“¥i d¿dÀ“dÁdÂ“dÃdÄ“dÅdÆ“dÇdÈ“dÉdÆ“dÊdË“dÌdÍ“dÎdÏ“dÐdÑ“dÒdÓ“dÔdÓ“dÕdÖ“d×dØ“dÙdÚ“dÛdÜ“dÝdÞ“¥i dßd™“dàdá“dâdã“dädå“dædç“dèdé“dêdë“dìdí“dîdï“dðdñ“dòdó“dôdõ“död÷“dødù“dúdû“düdý“dþdÿ“¥i �d �d“�d�d“�d�d“�d�d“�d�d	“�d
�d“�d�d“�d�d“�d�d“�d�d“�d�d“�d�d“�d�d“�d�d“�d�d“�d�d“�d �d!“¥i �d"�d#“�d$�d%“�d&�d'“�d(�d)“�d*�d+“�d,�d-“�d.�d/“�d0�d1“�d2�d3“�d4�d5“�d6�d7“�d8�d9“�d:�d;“�d<�d;“�d=�d>“�d?�d@“�dA�dB“¥�dC�dD�dE�dF�dG�dH�dI�dJ�dK�dL�dM�dNœ¥ZJ	 	 	 	 	 	 	 	 �dc�dO„ZKe+e3e1e5e4e<e6e7e8e;e:e9�dPœZL�dR�dQ„ZMy(d  a   Standard serializers and utility functions for serializers.

DOES NOT belong to the public API.

The serializers are independent of the :py:class:`segno.QRCode` (and the
:py:class:`segno.encoder.Code`) class; they just need a matrix (tuple of
bytearrays).
é    N)Ú	quoteattrÚescape©Úpack)ÚchainÚrepeat)Úpartial©Úreduce)Ú
itemgetter)Úcontextmanager)Údefaultdicté   )Úconsts)Úmatrix_to_linesÚget_symbol_sizeÚ
get_borderÚcheck_valid_scaleÚcheck_valid_borderÚmatrix_iterÚmatrix_iter_verbose)Úzip_longest)Úquote)ÚwritableÚ	write_svgÚ	write_pngÚ	write_epsÚ	write_pdfÚ	write_txtÚ	write_pbmÚ	write_pamÚ	write_ppmÚ	write_xpmÚ	write_xbmÚ	write_texÚwrite_terminalz'Segno <https://pypi.org/project/segno/>c              #   ó  K  — | }d}	 | j                    |� t        j                  |«      | «      }	 |–— |r|j                  «        yy# t        $ r t	        | ||¬«      }d}Y Œ4w xY w# |r|j                  «        w w xY w­w)a      Returns a writable file-like object.

    Usage::

        with writable(file_name_or_path, 'wb') as f:
            ...


    :param file_or_path: Either a file-like object or a filename.
    :param str mode: String indicating the writing mode (i.e. ``'wb'``)
    FN©ÚencodingT)ÚwriteÚcodecsÚ	getwriterÚAttributeErrorÚopenÚclose)Úfile_or_pathÚmoder)   ÚfÚ
must_closes        úR/var/www/io.vulcan-creative.com/venv/lib/python3.12/site-packages/segno/writers.pyr   r   /   s�   è ø€ ð 	€AØ€JðØ×ÒØÐØ*”× Ñ  Ó*¨<Ó8ˆAðØŠáØ�G‰G�Ið øô ò Ü�˜t¨hÔ7ˆØŠ
ðûñ Ø�G‰G�Ið üs8   ‚Bˆ)A
 ²A) ¶BÁ
A&Á#BÁ%A&Á&BÁ)A>Á>Bc                 ó   ‡ ‡— ˆ ˆfd„}|S )zX    Decorator to inject a module type -> color mapping into the decorated function.
    c                 óh   •‡ — t        j                  ‰ «      ‰‰dddddddddddddddfˆ fd„	«       }|S )NFc                 ó”   •— t        |i d|“d|“d|“d|“d|“d|“d|	“d|
“d	|“d
|“d|“d|“d|“d|“d|“d|“d|“Ž} ‰| |||fi |¤ŽS )NÚdarkÚlightÚfinder_darkÚfinder_lightÚ	data_darkÚ
data_lightÚversion_darkÚversion_lightÚformat_darkÚformat_lightÚalignment_darkÚalignment_lightÚtiming_darkÚtiming_lightÚ	separatorÚdark_moduleÚ
quiet_zone)Ú_make_colormap)ÚmatrixÚmatrix_sizeÚoutr8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   ÚkwÚcmr2   s                         €r4   Úwrapperz+colorful.<locals>.decorate.<locals>.wrapperR   sà   ø€ ô  ¡ð P±4ð P¹uð PÑR]ð PÙ-9ðPÙENðPá+5ðPáDPðPñ /<ðPñ JUðPñ .:ð	Pñ KYð	Pñ
 1@ðPñ
 NYðPñ .:ðPñ FOðPñ -8ðPñ EOðPˆBñ �V˜[¨#¨rÑ8°RÑ8Ð8ó    )Ú	functoolsÚwraps)r2   rO   r8   r9   s   ` €€r4   Údecoratezcolorful.<locals>.decorateQ   sQ   ù€ Ü	�‰˜Ó	Ø37¸uÐRWÐfkØ#°ÀEÐY^Ø %°EÈ%ÐafØ %°EÀUÐX]Ø$ô		9ó 
ð	9ð ˆrP   © )r8   r9   rS   s   `` r4   ÚcolorfulrU   M   s   ù€ õð" €OrP   c                 óp   — t        |«       t        |«       t        | |«      }t        | ||«      \  }}|||fS )zæ"    Validates the scale and border and returns the width, height and the border.
    If the border is ``None`` the default border is returned.

    :param tuple(int, int) matrix_size: Tuple of width and height of the matrix.
    )r   r   r   r   )rK   ÚscaleÚborderÚwidthÚheights        r4   Ú_valid_width_height_and_borderr[   e   s?   € ô �eÔÜ�vÔÜ˜ VÓ,€FÜ# K°¸Ó?�M€Eˆ6Ø�&˜&Ð Ð rP   ú#000)r8   r9   c                 ó¾  ‡ ‡‡‡‡.‡/— ˆ.fd„}ˆˆˆ ˆfd„}t        ‰|‰«      \  }}Š|xs d}|r|rt        d|› d�«      ‚|du }|rd}|duxr |dk\  Š.t        t        ‰j	                  «       «      «      d	kD  }| xr ‰t
        j                     duxr | }|d
k7  xr |xs |}|r |«       }n0‰‰dz   }}‰t
        j                     Š/ˆ/fd„t        ‰ ||«      D «       }t        d„ «      }t        t        «      }|D ]8  \  } \  }!}"}#||    \  }}||    j                  |!|z
  |#|z
  |"|!z
  f«       |"|#f|| <   Œ: |rdd||z  fg|‰t
        j                     <   |s	 |d= i }$|d
k7  rd|› d�nd}%dj                  |s|%nd|sdndt        |«      › �«      }&|j                  «       D ]ˆ  \  }'}(|&}) ||'«      } | �Dd}*t!        | t"        «      r| \  } }*|)dt        | «      › �z  })|*�|)dt        t%        |*«      «      › �z  })|)dz  })|)dj'                  d„ t)        |(«      D «       «      z  })|)dz  })|)|$|'<   ŒŠ |r]‰t
        j                     }+t+        j,                  dd|$|+   j/                  dd«      j/                  dd||z  › d||z  › d�«      «      |$|+<   d},|r|,dz  },|s|,dt        |«      › �z  },|,d z  },|,d!z  },|r|,d"z  },|�|dk  r|,d#t        t%        |«      «      › �z  },|s|,d$|› |› d%|› |› d&�z  },|s|r|,d'|› d(|› d&�z  },|
r|,d)t        |
«      › �z  },|r|,dt        |«      › �z  },|,d*z  },|�|,d+t1        |«      › d,�z  },|	�|,d-t1        |	«      › d.�z  },|r	|,d/|%› d*�z  },|,dj'                  t3        |$j	                  «       t        ¬0«      «      z  },|r|,d1z  },|,d2z  },|r|,d3z  },t5        |d4|¬5«      5 }-|-j7                  |,«       ddd«       y# t        $ r Y �Œvw xY w# 1 sw Y   yxY w)6a‡      Serializes the QR code as SVG document.

    :param matrix: The matrix to serialize.
    :param tuple(int, int) matrix_size: Tuple of width and height of the matrix.
    :param out: Filename or a file-like object supporting to write bytes.
    :param scale: Indicates the size of a single module (default: 1 which
            corresponds to 1 x 1 pixel per module).
    :param int border: Integer indicating the size of the quiet zone.
            If set to ``None`` (default), the recommended border size
            will be used (``4`` for QR Codes, ``2`` for a Micro QR Codes).
    :param bool xmldecl: Inidcates if the XML declaration header should be
            written (default: ``True``)
    :param bool svgns: Indicates if the SVG namespace should be written
            (default: ``True``).
    :param str title: Optional title of the generated SVG document.
    :param str desc: Optional description of the generated SVG document.
    :param svgid: The ID of the SVG document (if set to ``None`` (default),
            the SVG element won't have an ID).
    :param svgclass: The CSS class of the SVG document
            (if set to ``None``, the SVG element won't have a class).
    :param lineclass: The CSS class of the path element (which draws the
            "black" modules (if set to ``None``, the path won't have a class).
    :param bool omitsize: Indicates if width and height attributes should be
            omitted (default: ``False``). If these attributes are omitted,
            a ``viewBox`` attribute will be added to the document.
    :param str unit: Unit for width / height and other coordinates.
            By default, the unit is unspecified and all values are
            in the user space.
            Valid values: em, ex, px, pt, pc, cm, mm, in, and percentages
    :param str encoding: Encoding of the XML document. "utf-8" by default.
    :param float svgversion: SVG version (default: None)
    :param bool nl: Indicates if the document should have a trailing newline
            (default: ``True``)
    :param bool draw_transparent: Indicates if transparent SVG paths should be
            added to the graphic (default: ``False``)
    c                 ó&   •— | �t        | ‰¬«      S d S )N)Úallow_css3_colors)Ú_color_to_webcolor)Úclrr_   s    €r4   Ú	svg_colorzwrite_svg.<locals>.svg_color�   s   ø€ ØORÈÔ! #Ð9JÔKÐhÐdhÐhrP   c               3   óÀ   •K  — d} d}t        ‰	‰
d‰¬«      D ]C  }|}d\  }}| dz  } ˆfd„|D «       D ]  }||k7  r||k7  r|||| ff–— |}|dz  }|}Œ  |||| ff–— ŒE y ­w)Ng      à¿éÿÿÿÿr   ©rW   rX   ©r   r   c              3   ó(   •K  — | ]	  }‰|   –— Œ y ­w©NrT   ©Ú.0ÚmtÚcolormaps     €r4   ú	<genexpr>z=write_svg.<locals>.matrix_to_lines_verbose.<locals>.<genexpr>§   s   øè ø€ Ò1 r�h˜r•lÑ1ùó   ƒ)r   )ÚjÚinvalid_colorÚrowÚ
last_colorÚx1Úx2ÚcrX   rl   rJ   rK   s          €€€€r4   Úmatrix_to_lines_verbosez*write_svg.<locals>.matrix_to_lines_verbose    s›   øè ø€ ØˆØˆÜ& v¨{À!ÈFÔSò 
	*ˆCØ&ˆJØ‰FˆB�Ø�‰FˆAÛ1¨SÔ1ò �Ø Ò.°:À²?Ø$ r¨2¨q kÐ1Ò1Ø�BØ�a‘�Ø‘
ðð ˜r 2 q˜kÐ)Ó)ñ
	*ùs   ƒAAÚ z
The unit "z:" has no effect if the size (width and height) is omitted.Núutf-8g       @é   r   ç      à?c              3   ó>   •K  — | ]  \  \  }}\  }}‰|||ff–— Œ y ­wrh   rT   )rj   rs   Úy1rt   Úy2r8   s        €r4   rm   zwrite_svg.<locals>.<genexpr>À   s)   øè ø€ Ò^Ñ*<©(¨2¨r±H°R¸�$˜˜R ˜Ô%Ñ^ùs   ƒc                   ó   — y)Nrf   rT   rT   rP   r4   ú<lambda>zwrite_svg.<locals>.<lambda>Á   s   � rP   r   z transform="scale(z)"z	<path{}{}z class=z stroke=z stroke-opacity=z d="c           	   3   ó”   K  — | ]@  \  }\  }}}d j                  |dkD  rdnd||t        |«      |k(  rt        |«      n|¬«      –— ŒB y­w)z{moveto}{x} {y}h{l}r   ÚmÚM)ÚmovetoÚxÚlÚyN)ÚformatÚint)rj   Úir„   r†   Úlengths        r4   rm   zwrite_svg.<locals>.<genexpr>ß   sZ   è ø€ ò Cñ .˜A™~  1 fð .×4Ñ4ÀAÈÂE¹SÈsØ78¸FÜBEÀaÃ&ÈAÂ+¼¸A¼ÐSTð 5÷ Wñ Cùs   ‚AAú"/>z\sclass="[^"]+"ÚstrokeÚfillÚvzh-zz"/>z<?xml version="1.0"z
 encoding=z?>
z<svgz# xmlns="http://www.w3.org/2000/svg"z	 version=z width="z
" height="ú"z viewBox="0 0 ú z id=ú>z<title>z</title>z<desc>z</desc>z<g©Úkeyz</g>z</svg>ú
Úwtr(   )r[   Ú
ValueErrorÚlenÚsetÚvaluesr   ÚTYPE_QUIET_ZONEÚTYPE_DATA_DARKr   r   ÚlistÚappendÚKeyErrorr‡   r   ÚitemsÚ
isinstanceÚtupleÚstrÚjoinÚ	enumerateÚreÚsubÚreplacer   Úsortedr   r*   )0rJ   rK   rL   rl   rW   rX   ÚxmldeclÚsvgnsÚtitleÚdescÚsvgidÚsvgclassÚ	lineclassÚomitsizeÚunitr)   Ú
svgversionÚnlÚdraw_transparentrb   rv   rY   rZ   Úomit_encodingÚis_multicolorÚneed_backgroundÚneed_svg_groupÚmiterr„   r†   ÚxyÚcoordinatesra   rs   rt   r|   ÚpathsÚ
scale_infoÚpÚcolorÚcoordÚpathÚopacityÚkÚsvgr2   r_   r8   s0   `` ` `                                        @@r4   r   r   s   s   ý€ ôTi÷*ô ;¸;ÈÈvÓVÑ€Eˆ6�6ØŠ:�2€DÙ‘Ü˜: d Vð ,:ð :ó ;ð 	;à Ð$€MÙØˆØ"¨$Ð.ÒD°:ÀÑ3DÐÜœ˜HŸO™OÓ-Ó.Ó/°!Ñ3€MØ'Ð'Òq¨H´V×5KÑ5KÑ,LÐTXÐ,XÒqÐaqÐ]q€OØ˜a‘ZÒF _Ò%E¸€NÙÙ'Ó)‰à�v ‘{ˆ1ˆØœ×-Ñ-Ñ.ˆÛ^ÄÐPVÐXYÐ[\Ó@]Ô^ˆÜ	‘^Ó	$€BÜœdÓ#€KØ"ò Ñˆ‰\ˆb�"�bØ�#‰w‰ˆˆ1Ø�CÑ×Ñ  a¡¨¨a©°°b±Ð 9Ô:Ø�b�&ˆˆ3Šðñ ð ;<¸QÀÈÁÐ9OÐ8Pˆ�HœV×3Ñ3Ñ4Ñ5Ùð	Ø˜DÐ!ð €EØ38¸A²:Ð% e W¨BÑ/À2€JØ×Ñ©^™:ÀÙ%.™2°g¼iÈ	Ó>RÐ=SÐ4Tó	V€Aà#×)Ñ)Ó+ò ‰ˆˆuØˆÙ˜ÓˆØˆ?ØˆGÜ˜#œuÔ%Ø"‘��WØ�hœy¨›~Ð.Ð/Ñ/ˆDØÐ"ØÐ*¬9´S¸³\Ó+BÐ*CÐDÑD�Ø�‰ˆØ�—‘ñ Cô 2;¸5Ó1AôCó Cñ 	Cˆð 	�‰ˆØˆˆeŠð!ñ" ð ”V×+Ñ+Ñ,ˆÜ—6‘6Ð,¨bØ ™(×*Ñ*¨8°VÓ<ß#*¡7¨5°A°fÀ±oÐ5FÀbÈÐRWÉÐHXÐX\Ð2]Ó#^ó`ˆˆa‰ð €CÙØÐ$Ñ$ˆÙØ�Z¤	¨(Ó 3Ð4Ð5Ñ5ˆCØˆv‰ˆØˆ6�M€CÙØÐ4Ñ4ˆØÐ *¨sÒ"2Ø�œ9¤S¨£_Ó5Ð6Ð7Ñ7ˆÙØ�˜%˜   j°°¸¸¸aÐ@Ñ@ˆÙ‘4Ø� ˜w a¨ x¨qÐ1Ñ1ˆÙØ�”i Ó&Ð'Ð(Ñ(ˆÙØ�œ 8Ó,Ð-Ð.Ñ.ˆØˆ3�J€CØÐØ�œ ›˜ xÐ0Ñ0ˆØÐØ�œ˜t›�~ WÐ-Ñ-ˆÙØ��J�<˜qÐ!Ñ!ˆØˆ2�7‰7”6˜%Ÿ,™,›.¬cÔ2Ó3Ñ3€CÙØˆv‰ˆØˆ8�O€CÙ	Øˆt‰ˆÜ	�#�t hÔ	/ð °1Ø	�‰�Œ÷ð øô ò 	Úð	ú÷~ð ús   ÅO Î(OÏ	OÏOÏOs   (=)"([^"]+)"s   \1'\2'c                 ó  — |st        t        d¬«      nt        t        d¬«      }t        j                  «       }t	        | ||f|||||||	|
||||||dœ|¤Ž d|sd|z   nd› d� |t        |j                  «       «      «      z   S )	aþ      Converts the matrix to a SVG data URI.

    The XML declaration is omitted by default (set ``xmldecl`` to ``True``
    to enable it), further the newline is omitted by default (set ``nl`` to
    ``True`` to enable it).

    Aside from the missing ``out`` parameter and the different ``xmldecl``
    and ``nl`` default values and the additional parameter ``encode_minimal``
    and ``omit_charset`` this function uses the same parameters as the
    usual SVG serializer.

    :param bool encode_minimal: Indicates if the resulting data URI should
                    use minimal percent encoding (disabled by default).
    :param bool omit_charset: Indicates if the ``;charset=...`` should be omitted
                    (disabled by default)
    :rtype: str
    rP   )Úsafes    :/=')rW   rX   r©   rª   r«   r¬   r®   r¯   r°   r)   r­   r±   r²   r³   zdata:image/svg+xmlz	;charset=rw   ú,)r	   r   ÚioÚBytesIOr   Ú_replace_quotesÚgetvalue)rJ   rK   rW   rX   r©   rª   r«   r¬   r­   r®   r¯   r°   r±   r)   r²   r³   Úencode_minimalÚomit_charsetrM   ÚencodeÚbuffs                        r4   Úas_svg_data_urirÐ     sŸ   € ñ0 .<ŒW”U Õ%ÄÌÐU]ÔA^€FÜ�:‰:‹<€DÜˆf�k 4ð J¨u¸VÈWØ ¨T¸HØ!¨H¸xØ °ÀñJð GIòJð  ¹| ¨xÒ!7ÐQSÐUÐUVÐWÙ”O D§M¡M£OÓ4Ó5ñ6ð 6rP   Úfuchsiac                 óV  — dddddddœ}|�|j                  |«       t        |||«      \  }	}
}|\  }}t        |d	d
¬«      5 }g }|j                  } |d«        |d|	› d|
› d�«        |d«        |d|› d�«       t	        |«      D ]b  }||z   }t	        |«      D ]M  }||z   }| |   |   }|r|dvr|j                  |||f«       |j                  ||«      } |d|› d|› d|› d�«       ŒO Œd |D ]  \  }}} |d|dz   › d|dz   › d|› d�«       Œ   |d«       ddd«       y# 1 sw Y   yxY w)aÅ      Internal SVG serializer which is useful for debugging purposes.

    This function is not exposed to the QRCode class by intention and the
    resulting SVG document is very inefficient (a lot of ``<rect/>`` elements).
    Dark modules are black and light modules are white by default. Provide
    a custom `colormap` to override these defaults.
    Unknown modules are red by default.

    :param matrix: The matrix
    :param tuple(int, int) matrix_size: Tuple of width and height of the matrix.
    :param out: binary file-like object or file name
    :param scale: Scaling factor
    :param border: Quiet zone
    :param fallback_color: Color which is used for modules which are not 0x0 or 0x1
                and for which no entry in `color_mapping` is defined.
    :param colormap: dict of module values to color mapping (optional)
    :param bool add_legend: Indicates if the bit values should be added to the
                matrix (default: True)
    ú#fffr\   ÚredÚorangeÚgoldÚgreen)r   r   ry   é   é   é   Nr•   rx   r(   z'<?xml version="1.0" encoding="utf-8"?>
z5<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 r�   z">zj<style type="text/css"><![CDATA[ text { font-size: 1px; font-family: Helvetica, Arial, sans; } ]]></style>z<g transform="scale(z)">©r   r   z	<rect x="z" y="z" width="1" height="1" fill="r‹   z	<text x="gš™™™™™É?gÍÌÌÌÌÌì?z</text>z</g></svg>
)Úupdater[   r   r*   Úranger�   Úget)rJ   rK   rL   rW   rX   Úfallback_colorrl   Ú
add_legendÚclr_mappingrY   rZ   Úmatrix_widthÚmatrix_heightr2   Úlegendr*   r‰   r†   ro   r„   Úbitr�   Úvals                          r4   Úwrite_svg_debugrç   6  s¡  € ð0 ØØØØØñ€Kð ÐØ×Ñ˜8Ô$Ü:¸;ÈÈvÓVÑ€Eˆ6�6Ø"-Ñ€L�-Ü	�#�t gÔ	.ð °!ØˆØ—‘ˆÙÐ8Ô9ÙÐEÀeÀWÈAÈfÈXÐUWÐXÔYÙð Cô 	DáÐ$ U G¨3Ð/Ô0Ü�}Ó%ò 	UˆAØ�F‘
ˆAÜ˜<Ó(ò U�Ø˜‘J�Ø˜Q‘i ‘l�Ù #¨ZÑ"7Ø—M‘M 1 a¨ +Ô.Ø"—‘ s¨NÓ;�Ù˜	 !  E¨!¨Ð,IÈ$ÈÈsÐSÕTñUð	Uð  ò 	C‰IˆAˆq�#Ù�I˜a "™f˜X U¨1¨r©6¨(°"°S°E¸ÐAÕBð	CáˆnÔ÷)÷ ñ ús   ÁCDÄD(c                 ó°  ‡— ddl Šˆfd„}d„ }t        |||«      \  }	}
}t        |«      }|r|n ||«      }t        |d«      5 }t	        ||j
                  «      } |d«        |dt        › �«        |dt        j                  d	«      › �«        |d
«        |d|	› d|
› �«        |d«        |d«       |�% | dj                   ||«      Ž «       |r |d«       |s | dj                  |Ž «       |dk7  r ||› d|› d�«        |d«       t        |dd¬«      d   |z   dz
  }t        | ||d¬«      }t        |«      \  \  }}\  }}|› d|› d||z
  › d�g}|j                  }|}|D ]3  \  \  }}\  }} |d||z
  › dt        ||z
  «      › d||z
  › d�«       ||}}Œ5  |dj                  |«      «        |d«        |d«       ddd«       y# 1 sw Y   yxY w)aç      Serializes the QR code as EPS document.

    :param matrix: The matrix to serialize.
    :param tuple(int, int) matrix_size: Tuple of width and height of the matrix.
    :param out: Filename or a file-like object supporting to write strings.
    :param scale: Indicates the size of a single module (default: 1 which
            corresponds to 1 point (1/72 inch) per module).
    :param int border: Integer indicating the size of the quiet zone.
            If set to ``None`` (default), the recommended border size
            will be used (``4`` for QR Codes, ``2`` for Micro QR Codes).
    :param dark: Color of the modules (default: black). The
            color can be provided as ``(R, G, B)`` tuple (this method
            acceppts floats as R, G, B values), as web color name (like
            "red") or in hexadecimal format (``#RGB`` or ``#RRGGBB``).
    :param light: Optional background color (default: ``None`` = no
            background color). See `color` for valid values.
    r   Nc                 óT   •— ‰j                  |d«      D ]  } | |«        | d«       Œ y)z-        Writes `content` and ``LF``.
        éþ   r”   N)Úwrap)Ú	writemethÚcontentÚlineÚtextwraps      €r4   Ú
write_linezwrite_eps.<locals>.write_line…  s-   ø€ ð
 —M‘M '¨3Ó/ò 	ˆDÙ�dŒOÙ�d�Oñ	rP   c                 ób   — d„ }t        t        | «      D �cg c]
  } ||«      ‘Œ c}«      S c c}w )zp        Converts the provided color into an acceptable format for Postscript's
         ``setrgbcolor``
        c                 óv   — t        | t        «      rd| cxk  rdk  sn t        d| › d�«      ‚| S | dk7  rd| z  S | S ©Nç        ç      ð?zInvalid color "z". Not in range 0 .. 1r   gp?©r    Úfloatr–   ©ru   s    r4   Úto_floatz2write_eps.<locals>.rgb_to_floats.<locals>.to_float“  óF   € Ü˜!œUÔ#Ø˜a” 3”Ü$ °q°cÐ9OÐ%PÓQÐQØ�Ø$%¨¢F�9˜q‘=Ð1°Ð1rP   ©r¡   Ú_color_to_rgb©ra   rù   r‰   s      r4   Úrgb_to_floatsz write_eps.<locals>.rgb_to_floatsŽ  s+   € ò
	2ô ¬=¸Ó+=Ö> a‘h˜q•kÒ>Ó?Ð?ùÒ>ó   –,r•   z%!PS-Adobe-3.0 EPSF-3.0z%%Creator: z%%CreationDate: z%Y-%m-%d %H:%M:%Sz%%DocumentData: Clean7Bitz%%BoundingBox: 0 0 r�   z/m { rmoveto } bind defz/l { rlineto } bind defz+{0:f} {1:f} {2:f} setrgbcolor clippath fillz0 0 0 setrgbcolorz{0:f} {1:f} {2:f} setrgbcolorr   z scaleÚnewpathre   rz   rd   ©Úincbyz moveto z 0 lú m rw   rŒ   z%%EOF)rï   r[   Ú_color_is_blackr   r	   r*   ÚCREATORÚtimeÚstrftimer‡   r   r   Únextr�   rˆ   r£   )rJ   rK   rL   rW   rX   r8   r9   rð   rþ   rY   rZ   Ústroke_color_is_blackÚstroke_colorr2   Ú	writeliner†   Ú	line_iterrs   r|   rt   r}   rÀ   Úappend_coordr„   rï   s                           @r4   r   r   p  s0  ø€ ó& ôò@ô ;¸;ÈÈvÓVÑ€Eˆ6�6Ü+¨DÓ1ÐÙ0‘4±mÀDÓ6I€LÜ	�#�tÓ	ð % Ü˜J¨¯©Ó0ˆ	ÙÐ+Ô,Ù�K¤˜yÐ)Ô*ÙÐ$¤T§]¡]Ð3FÓ%GÐ$HÐIÔJÙÐ-Ô.ÙÐ'¨ w¨a°¨xÐ8Ô9áÐ+Ô,ÙÐ+Ô,ØÐÙÐJÐC×JÑJÉMÐZ_ÓL`ÐaÔbÙ$ñ Ð-Ô.Ù$ÙÐ<Ð5×<Ñ<¸lÐKÔLØ�AŠ:Ù˜˜˜q   vÐ.Ô/Ù�)Ôô ˜K¨q¸Ô;¸AÑ>ÀÑGÈ"ÑLˆÜ# F¨F°A¸RÔ@ˆ	ô " )›_Ñ‰ˆˆR‘(�2�rØ�4�q˜˜˜H R¨"¡W I¨TÐ2Ð3ˆØ—|‘|ˆØˆØ"+ò 	Ñ‰HˆR�‘h�r˜2Ù˜1˜R !™V˜H A¤c¨"¨q©&£k ]°#°b¸2±g°Y¸dÐCÔDØ�rˆq‰Að	ñ 	�"—'‘'˜%“.Ô!Ù�(ÔÙ�'Ô÷K%÷ %ñ %ús   ÁFGÇGc                 ó¸   — t        j                  «       }t        | ||f|||dœ|¤Ž dt        j                  |j                  «       «      j                  d«      › �S )z‘    Converts the provided matrix into a PNG data URI.

    See :func:`write_png` for a description of supported parameters.

    :rtype: str
    )rW   rX   Úcompresslevelzdata:image/png;base64,Úascii)rÈ   rÉ   r   Úbase64Ú	b64encoderË   Údecode)rJ   rK   rW   rX   r  rM   rÏ   s          r4   Úas_png_data_urir  Ç  sU   € ô �:‰:‹<€DÜˆf�k 4Ðg¨u¸VÐS`ÑgÐdfÒgØ#¤F×$4Ñ$4°T·]±]³_Ó$E×$LÑ$LÈWÓ$UÐ#VÐWÐWrP   rÓ   c                 óš  ‡‡#‡$‡%‡&‡'‡(— ˆ'fd„}d„ }	d+ˆ&fd„	}
t        ‰«      Št        |‰|«      \  }}}|r)t        |«      }|dk  rt        d«      ‚t        |dz  «      }dŠ#dŠ(d	Š't        j                  }t        j
                  }|D �ci c]  }| |||   «      “Œ }}t        t        |j                  «       «      t        dd
d«      ¬«      Š%‰'‰%v }t        ‰%«      }|dk(  xr t        ˆ#ˆ'ˆ(fd„‰%D «       «      }|rdnd}d
Š&d}|s»|dkD  r	|dk  rdndŠ&‰%j                  t        d¬«       |r¯d}t        ‰%d
   «      dk(  rt        j                  «       nd„ t        j                  «       D «       }t        ˆ%fd„|D «       «      }|‰%d<   |j                  |j!                  «       D ��ci c]  \  }}|‰'k(  r||“Œ c}}«       n|r‰#‰%v r‰#‰'gŠ%‰%j#                  ‰'«      }|dkD  rCt%        | |d
d¬«      }|j!                  «       D ��ci c]  \  }}|‰%j#                  |«      “Œ c}}Š$nJt'        | «      }|‰%j#                  ||   «      iŠ$‰$j                  ‰$|   ‰%j#                  ||   «      dœ«       ˆ$fd„|D «       }d}d}|dkD  r&‰$|   } |
t)        ||«      «      |z  ‰z  }|g|z  ‰z  }d}‰d
kD  r% |
t)        d|«      d¬«      ‰d
z
  z  }ˆfd„|D «       }t+        |«      }|D ]  } | |
t-        || |«      «      z  }||z  }Œ ||z  }t/        |d«      5 }!|!j0                  }" |"d«        |" |	dt3        d ||‰&|ddd«      «      «       |r |" |	d!t3        d"||d
«      «      «       |sx |" |	d#dj5                  d$„ ‰%D «       «      «      «       t        ‰%d   «      dkD  r& |" |	d%dj5                  d&„ ‰%D «       «      «      «       n7|r5 |" |	d%t3        d'|«      «      «       n|r |" |	d%t3        d(|«      «      «        |" |	d)t7        j8                  ||«      «      «        |" |	d*d«      «       ddd«       yc c}w c c}}w c c}}w # 1 sw Y   yxY w),a¤      Serializes the QR code as PNG image.

    By default, the generated PNG will be a greyscale image (black / white)
    with a bit depth of 1. If different colors are provided, an indexed-color
    image with the same bit depth is generated unless more than two colors
    are provided. This may require a bit depth of of 2 or 4.

    :param matrix: The matrix to serialize.
    :param tuple(int, int) matrix_size: Tuple of width and height of the matrix.
    :param out: Filename or a file-like object supporting to write bytes.
    :param scale: Indicates the size of a single module (default: 1 which
            corresponds to 1 x 1 pixel per module).
    :param int border: Integer indicating the size of the quiet zone.
            If set to ``None`` (default), the recommended border size
            will be used (``4`` for QR Codes, ``2`` for Micro QR Codes).
    :param int dpi: Optional DPI setting. By default (``None``), the PNG won't
            have any DPI information. Note that the DPI value is converted into
            meters since PNG does not support any DPI information.
    :param int compresslevel: Integer indicating the compression level
            (default: 9). 1 is fastest and produces the least
            compression, 9 is slowest and produces the most.
            0 is no compression.
    :param dict colormap: Optional module type -> color mapping. If provided, the
            `color` and `background` arguments are ignored. All undefined module
            types will have the default colors (light: white, dark: black).
            See `color` for valid color values. ``None`` is accepted as valid
            color value as well (becomes transparent).
    c                 ó&   •— | �t        | d¬«      S ‰S )NF©Úalpha_float)Ú_color_to_rgb_or_rgba)ra   Útransparents    €r4   Ú	png_colorzwrite_png.<locals>.png_colorô  s   ø€ Ø@CÀÔ$ S°eÔ<Ð`ÐU`Ð`rP   c                 ó|   — | |z   }t        dt        |«      «      |z   t        dt        j                  |«      «      z   S )z3        Returns a PNG chunk with checksum.
        s   >I)r   r—   ÚzlibÚcrc32)ÚnameÚdataÚ
chunk_heads      r4   Úchunkzwrite_png.<locals>.chunk÷  s8   € ð ˜D‘[ˆ
Ü�Eœ3˜t›9Ó%¨
Ñ2´T¸%ÄÇÁÈJÓAWÓ5XÑXÐXrP   c                 ór   •— t        t        |ˆfd„t        t        | «      gd‰z  z  ddiŽD «       «      «      S )z+        Returns a single scanline.
        c              3   ó<   •K  — | ]  }t        ˆfd „|«      –— Œ y­w)c                 ó   •— | ‰z  |z   S rh   rT   )r„   r†   Úpng_bit_depths     €r4   r   z7write_png.<locals>.scanline.<locals>.<genexpr>.<lambda>  s   ø€ °Q¸-Ñ5GÈ1Ñ4L€ rP   Nr
   )rj   Úer&  s     €r4   rm   z.write_png.<locals>.scanline.<locals>.<genexpr>  s#   øè ø€ ò  jØ$%ô !'Ó'LÈa× Pñ  jùó   ƒé   Ú	fillvaluer   )Ú	bytearrayr   r   Úiter)rq   Úfilter_typer&  s     €r4   Úscanlinezwrite_png.<locals>.scanlineþ  sH   ø€ ô œ˜{ó jÜ)4´t¸C³y°kÀQÈ-ÑEWÑ6XÐ)hÐdgÑ)hô jókó lð 	lrP   r   zDPI value must not be negativeg¦
F%uš?©r   r   r   ©éÿ   r1  r1  )rd   rd   rd   rd   r   ry   r’   c              3   ó,   •K  — | ]  }|‰‰‰fv –— Œ y ­wrh   rT   )rj   ra   Úblackr  Úwhites     €€€r4   rm   zwrite_png.<locals>.<genexpr>  s   øè ø€ Ò0gÐX[°¸ÀeÈUÐ8SÔ1SÑ0gùs   ƒrØ   NrÚ   rÙ   T)r“   Úreversec              3   ó*   K  — | ]  }g |¢d ‘­–— Œ y­w)r   NrT   ©rj   ra   s     r4   rm   zwrite_png.<locals>.<genexpr>'  s   è ø€ ÒIrÐX[È)ÈCÈ)ÐQRÍ)ÑIrùs   ‚c              3   ó,   •K  — | ]  }|‰vsŒ|–— Œ y ­wrh   rT   )rj   ra   Úpalettes     €r4   rm   zwrite_png.<locals>.<genexpr>)  s   øè ø€ Ò$U¨SÀ#ÈWÒBT¤SÑ$Uùs   ƒ	�re   rÛ   c              3   ó4   •K  — | ]  }ˆfd „|D «       –— Œ y­w)c              3   ó(   •K  — | ]	  }‰|   –— Œ y ­wrh   rT   )rj   ÚbÚcolor_indexs     €r4   rm   z&write_png.<locals>.<genexpr>.<genexpr>>  s   øè ø€ Ò( ˆk˜!�nÑ(ùrn   NrT   )rj   Úrr=  s     €r4   rm   zwrite_png.<locals>.<genexpr>>  s   øè ø€ Ò8¨QÓ( a×(Ð(Ñ8ùs   ƒrP   ó   )r-  c              3   ó@   •K  — | ]  }t        ˆfd „|D «       Ž –— Œ y­w)c              3   ó6   •K  — | ]  }t        |‰«      –— Œ y ­wrh   )r   )rj   r<  rW   s     €r4   rm   z&write_png.<locals>.<genexpr>.<genexpr>M  s   øè ø€ Ò7¨aœ  5×)Ñ7ùs   ƒN)r   )rj   rq   rW   s     €r4   rm   zwrite_png.<locals>.<genexpr>M  s   øè ø€ ÒJ¸S”Ó7°3Ô7Ô8ÑJùs   ƒÚwbs   ‰PNG

s   IHDRs   >2I5Bs   pHYss   >LLBs   PLTEc              3   ó:   K  — | ]  }t        d g|dd ¢­Ž –— Œ y­w)ó   >3BNrØ   r   r7  s     r4   rm   zwrite_png.<locals>.<genexpr>]  s    è ø€ Ò)TÀS¬$¨vÐ*@¸¸B¸Q¸Ö*@Ñ)Tùs   ‚s   tRNSc              3   óX   K  — | ]"  }t        |«      d kD  sŒt        d|d    «      –— Œ$ y­w)rØ   ó   >BN)r—   r   r7  s     r4   rm   zwrite_png.<locals>.<genexpr>`  s*   è ø€ Ò-eÀcÔX[Ð\_ÓX`ÐcdÓXd¬d°5¸#¸a¹&×.AÑ-eùs   ‚*–*rF  s   >1Hs   IDATs   IEND)ó    )rˆ   r[   r–   r   ÚTYPE_FINDER_PATTERN_DARKrš   r¨   r˜   r™   r   r—   ÚallÚsortÚ	_NAME2RGBr  rÜ   rŸ   Úindexr   r,  r   r+  r   r   r*   r   r£   r  Úcompress))rJ   rK   rL   rl   rW   rX   r  Údpir  r"  r.  rY   rZ   Údark_idxÚqz_idxrÃ   Úclr_mapÚis_transparentÚnumber_of_colorsÚis_greyscaleÚpng_color_typeÚpng_trans_idxÚ
rgb_valuesÚtransparent_colorÚmodule_typera   r¹   Úhorizontal_borderÚvertical_borderÚqz_valueÚsame_as_aboveÚidatrq   r2   r*   r3  r=  r9  r&  r  r4  s)       `                              @@@@@@r4   r   r   Ô  s‚  þ€ ô@aòYõlô �‹J€EÜ:¸;ÈÈvÓVÑ€Eˆ6�6Ù
Ü�#‹hˆØ�Š7ÜÐ=Ó>Ð>Ü�#˜‘-Ó ˆà€EØ€EØ"€KÜ×.Ñ.€HÜ×#Ñ#€FØ2:Ö;¨Qˆq‘)˜H Q™KÓ(Ñ(Ð;€GÐ;ä”S˜Ÿ™Ó)Ó*´
¸1¸aÀÓ0CÔD€GØ  GÐ+€NÜ˜7“|Ðà# qÑ(Òg¬SÕ0gÐ_fÔ0gÓ-g€LÙ&‘Q¨A€NØ€MØ€MÙØ˜aÒð "2°AÒ!5™A¸1ˆMØ�‰œ dˆÔ+ÙØˆMÜ/2°7¸1±:«À!Ò/Cœ×)Ñ)Ô+ÑIrÔ_h×_oÑ_oÓ_qÔIrˆJä $Ó$U°JÔ$UÓ UÐØ*ˆG�A‰Jà�N‰NØ4;·M±M³O÷[Ù 0 ¨SÀsÈkÒGYð (Ð):Ñ:ó [õ \á	Ø�GÑà˜kÐ*ˆGØŸ™ kÓ2ˆØ˜!Òä# F¨K¸qÈÔKˆØOVÏ}É}Ë×_Ñ;K¸;È�{ G§M¡M°#Ó$6Ñ6Ó_‰ô �V“ˆà˜wŸ}™}¨W°V©_Ó=Ð>ˆØ×Ñ˜{¨6Ñ2Ø&Ÿ}™}¨W°XÑ->Ó?ñAô 	Bã8°%Ô8€EØÐØ€OØ�‚zà˜vÑ&ˆÙ$¤V¨H°eÓ%<Ó=ÀÑFÈÑNÐØ#˜* vÑ-°Ñ5ˆð €MØˆq‚yá ¤¨¨UÓ!3ÀÔGÈ5ÐSTÉ9ÑUˆÛJÀEÔJˆÜÐ&Ó'€DØò ˆà‘œ˜°°_ÓEÓFÑFˆØ�Ñ‰ðð 	ÐÑ€DÜ	�#�tÓ	ð # Ø—‘ˆÙÐ"Ô#ñ 	‰e�GœT (¨E°6¸=È.ÐZ[Ð]^Ð`aÓbÓcÔdÙÙ‘%˜¤ g¨s°C¸Ó!;Ó<Ô=ÙÙ‘%˜ §¡Ñ)TÈGÔ)TÓ!TÓUÔVä�7˜1‘:‹ Ò"Ù‘e˜G S§X¡XÑ-eÈWÔ-eÓ%eÓfÕgÙÙ‘e˜G¤T¨%°Ó%?Ó@ÕAÙñ ‘%˜¤ f¨mÓ!<Ó=Ô>Ù‰e�GœTŸ]™]¨4°Ó?Ó@ÔAÙ‰e�G˜SÓ!Ô"÷+#ð #ùò <ùó.[ùó `÷<#ð #ús   ÂP0Æ#P5
È P;ÌDQÑQ
c                 óŒ  — d„ }d„ }	t        |||«      \  }
}}t        j                  d«      › t        j                  dz  d›dt	        t        j                  «      dz  d›d�}g }|j
                  }|�2 | d
j                   |	|«      Ž «        |d|
› d|› d�«        |d«       t        |«      s | dj                   |	|«      Ž «       |dkD  r ||› d|› d�«       t        |dd¬«      d   |z   dz
  } |d|› d|› d�«       t        | ddd¬«      }|j                  d„ |D «       «        |d«       t        j                  dj                  |«      j                  d«      |«      }t        |d«      5 }|j                   }t#        ||«      }g } |d«       dd d!|
› d|› d"�d#t%        |«      › d$�fD ]7  }|j                  |j'                  «       «        |t%        |«      › d%|› �«       Œ9  ||«        |d&«       |j                  |j'                  «       «        |t%        |«      › d'|› d(t(        › d)t(        › d*�«       |j                  |j'                  «       «        |d+t%        |«      › d,�«       |d	d D ]  } ||d-›ddd.›d/�«       Œ  |d0t%        |«      › d1�«       |d   } |d2|› d3�«       d	d	d	«       y	# 1 sw Y   y	xY w)4a„      Serializes the QR code as PDF document.

    :param matrix: The matrix to serialize.
    :param tuple(int, int) matrix_size: Tuple of width and height of the matrix.
    :param out: Filename or a file-like object supporting to write bytes.
    :param scale: Indicates the size of a single module (default: 1 which
            corresponds to 1 x 1 pixel per module).
    :param int border: Integer indicating the size of the quiet zone.
            If set to ``None`` (default), the recommended border size
            will be used (``4`` for QR Codes, ``2`` for Micro QR Codes).
    :param dark: Color of the modules (default: black). The
            color can be provided as ``(R, G, B)`` tuple, as web color name
            (like "red") or in hexadecimal format (``#RGB`` or ``#RRGGBB``).
    :param light: Optional background color (default: ``None`` = no
            background color). See `color` for valid values.
    :param int compresslevel: Integer indicating the compression level
            (default: 9). 1 is fastest and produces the least
            compression, 9 is slowest and produces the most.
            0 is no compression.
    c                 ó2   —  | |j                  d«      «       y )Nr  )rÎ   )rì   Úss     r4   Úwrite_stringzwrite_pdf.<locals>.write_string„  s   € Ù�!—(‘(˜7Ó#Õ$rP   c                 ób   — d„ }t        t        | «      D �cg c]
  } ||«      ‘Œ c}«      S c c}w )zq        Converts the provided color into an acceptable format for PDF's
        "DeviceRGB" color space.
        c                 óv   — t        | t        «      rd| cxk  rdk  sn t        d| › d�«      ‚| S | dk7  rd| z  S | S ró   rö   rø   s    r4   rù   z1write_pdf.<locals>.to_pdf_color.<locals>.to_floatŒ  rú   rP   rû   rý   s      r4   Úto_pdf_colorzwrite_pdf.<locals>.to_pdf_color‡  s+   € ò
	2ô ¬=¸Ó+=Ö> a‘h˜q•kÒ>Ó?Ð?ùÒ>rÿ   z%Y%m%d%H%M%Si  z+03dú'é<   Ú02dNz{} {} {} rgz0 0 r�   z rezf qz{} {} {} RGr   z 0 0 z 0 0 cmr   re   rz   z1 0 0 1 z cmrd   r  c           	   3   óJ   K  — | ]  \  \  }}\  }}|› d |› d|› d |› d�–— Œ y­w)r�   r  z lNrT   )rj   rs   r|   rt   r}   s        r4   rm   zwrite_pdf.<locals>.<genexpr>©  s6   è ø€ ÒKÑ/A©x°°B¹¸"¸b�2�$�a˜�t˜3˜r˜d ! B 4 rÔ*ÑKùs   ‚!#ÚSr  rB  s   %PDF-1.4%âãÏÓ
z-obj <</Type /Catalog /Pages 2 0 R>>
endobj
z5obj <</Type /Pages /Kids [3 0 R] /Count 1>>
endobj
z/obj <</Type /Page /Parent 2 0 R /MediaBox [0 0 z] /Contents 4 0 R>>
endobj
zobj <</Length z! /Filter /FlateDecode>>
stream
z 0 s   
endstream
endobj
z 0 obj <</CreationDate(D:z)/Producer(z
)/Creator(z)
>>
endobj
zxref
0 z
0000000000 65535 f
Ú010dÚ05dz n
ztrailer <</Size z/Root 1 0 R/Info 5 0 R>>
zstartxref
z	
%%EOF
)r[   r  r  ÚtimezoneÚabsr�   r‡   r  r   r   Úextendr  rM  r£   rÎ   r   r*   r	   r—   Útellr  )rJ   rK   rL   rW   rX   r8   r9   r  rb  re  rY   rZ   Úcreation_dateÚcmdsÚ
append_cmdr†   r¹   Úgraphicr2   r*   ÚwritestrÚ
object_posÚobjÚposÚxref_locations                            r4   r   r   l  s
  € ò0%ò@ô ;¸;ÈÈvÓVÑ€Eˆ6�6Ü—}‘} ^Ó4Ð5´t·}±}ÈÑ7LÈdÐ5SÐSTÔVYÔZ^×ZgÑZgÓVhÐkmÑVmÐorÐTsÐstÐu€MØ€DØ—‘€JØÐáÐ'�=×'Ñ'©°eÓ)<Ð=Ô>Ù�T˜%˜  & ¨Ð-Ô.Ù�5Ôä˜4Ô ÙÐ'�=×'Ñ'©°dÓ);Ð<Ô=Øˆq‚yÙ�e�W˜E % ¨Ð0Ô1ô 	˜¨1°QÔ7¸Ñ:¸VÑCÀbÑH€Aá�˜&˜  1 # SÐ)Ô*Ü˜F A q°Ô3€Eà‡K�KÑKÀUÔKÔKÙˆs„OÜ�m‰m˜SŸX™X d›^×3Ñ3°GÓ<¸mÓL€GÜ	�#�tÓ	ð ? Ø—‘ˆÜ˜<¨Ó/ˆØˆ
ÙÐ0Ô1ØGØOØEÀeÀWÈAÈfÈXÐUvÐwØ$¤S¨£\ NÐ2WÐXðZò 	3ˆCð ×Ñ˜aŸf™f›hÔ'Ùœ˜J›Ð(¨¨C¨5Ð1Õ2ð	3ñ 	ˆgŒÙÐ,Ô-Ø×Ñ˜!Ÿ&™&›(Ô#Ù”C˜
“OÐ$Ð$=¸m¸_ð MÜ%˜Y j´°	Ð9NðPô 	Qà×Ñ˜!Ÿ&™&›(Ô#Ù�:œc *›oÐ.Ð.HÐIÔJØ˜c˜r�?ò 	2ˆCÙ˜˜D�z  1 S '¨Ð0Õ1ð	2áÐ#¤C¨
£OÐ#4Ð4PÐQÔRØ" 2™ˆÙ�=  ¨}Ð=Ô>÷-?÷ ?ñ ?ús   Å2D?J:Ê:Kc                 ó
  ‡
— t        | |d|¬«      }t        |«      t        |«      fŠ
t        |d«      5 }|j                  }|D ]*  }	 |dj	                  ˆ
fd„|	D «       «      «        |d«       Œ, 	 ddd«       y# 1 sw Y   yxY w)aX      Serializes QR code in a text format.

    :param matrix: The matrix to serialize.
    :param tuple(int, int) matrix_size: Tuple of width and height of the matrix.
    :param out: Filename or a file-like object supporting to write text.
    :param int border: Integer indicating the size of the quiet zone.
            If set to ``None`` (default), the recommended border size
            will be used (``4`` for QR Codes, ``2`` for Micro QR Codes).
    :param dark: Character to use for the black modules (default: '1')
    :param light: Character to use for the white modules (default: '0')
    r   re   r•   rw   c              3   ó(   •K  — | ]	  }‰|   –— Œ y ­wrh   rT   )rj   r‰   Úcolourss     €r4   rm   zwrite_txt.<locals>.<genexpr>×  s   øè ø€ Ò2¨˜' !�*Ñ2ùrn   r”   N)r   r¢   r   r*   r£   )rJ   rK   rL   rX   r8   r9   Úrow_iterr2   r*   rq   r|  s             @r4   r   r   Å  s~   ø€ ô ˜6 ;°aÀÔG€HÜ�5‹zœ3˜t›9Ð%€GÜ	�#�tÓ	ð  Ø—‘ˆØò 	ˆCÙ�"—'‘'Ó2¨cÔ2Ó2Ô3Ù�$�Kñ	÷÷ ñ ús   ³<A9Á9Bc                 ó”  — d„ }t        |||«      \  }}}t        | |||«      }	t        |d«      5 }
|
j                  } ||sdnd› dt        › d|› d|› d�j                  d«      «       |s|	D ]  } |t         ||«      «      «       Œ n-|	D ](  } |d	j                  d
„ |D «       «      «        |d«       Œ* ddd«       y# 1 sw Y   yxY w)a      Serializes the matrix as `PBM <http://netpbm.sourceforge.net/doc/pbm.html>`_
    image.

    :param matrix: The matrix to serialize.
    :param tuple(int, int) matrix_size: Tuple of width and height of the matrix.
    :param out: Filename or a file-like object supporting to write binary data.
    :param scale: Indicates the size of a single module (default: 1 which
            corresponds to 1 x 1 pixel per module).
    :param int border: Integer indicating the size of the quiet zone.
            If set to ``None`` (default), the recommended border size
            will be used (``4`` for QR Codes, ``2`` for Micro QR Codes).
    :param bool plain: Indicates if a P1 (ASCII encoding) image should be
            created (default: False). By default a (binary) P4 image is created.
    c                 ó@   — d„ t        t        | «      gdz  ddiŽD «       S )z0        Packs eight bits into one byte.
        c              3   ó6   K  — | ]  }t        d „ |«      –— Œ y­w)c                 ó   — | dz  |z   S ©Nr   rT   ©r„   r†   s     r4   r   z7write_pbm.<locals>.pack_row.<locals>.<genexpr>.<lambda>ï  s   €  Q¨!¡V¨q¡L€ rP   Nr
   )rj   r'  s     r4   rm   z.write_pbm.<locals>.pack_row.<locals>.<genexpr>ï  s"   è ø€ ò LØô Ñ0°!×4ñ Lùs   ‚r)  r*  r   )r   r,  )Úiterables    r4   Úpack_rowzwrite_pbm.<locals>.pack_rowë  s-   € ñLÜ$¤t¨H£~Ð&6¸Ñ&:ÐJÀcÑJôLð 	LrP   rB  ÚP4ÚP1z
# Created by r”   r�   r  rP   c              3   óP   K  — | ]  }t        |«      j                  d «      –— Œ  y­w)r  N)r¢   rÎ   )rj   r‰   s     r4   rm   zwrite_pbm.<locals>.<genexpr>þ  s   è ø€ ÒC¸!œs 1›vŸ}™}¨W×5ÑCùs   ‚$&ó   
N)r[   r   r   r*   r  rÎ   r+  r£   )rJ   rK   rL   rW   rX   Úplainr…  rY   rZ   r}  r2   r*   rq   s                r4   r    r    Û  så   € ò Lô ;¸;ÈÈvÓVÑ€Eˆ6�6Ü˜6 ;°°vÓ>€HÜ	�#�tÓ	ð  Ø—‘ˆÙ™e‘$¨Ð/ð 0Ü%˜Y bØ��q˜˜ ð$ç$*¡F¨7£Oô	5ñ Øò 0�Ù”i¡¨£Ó.Õ/ñ0ð  ò �Ù�c—h‘hÑC¸sÔCÓCÔDÙ�e•ð÷÷ ñ ús   ¯BB>Â>Cc                 óT  — d„ }d„ }|st        d|› d�«      ‚t        |||«      \  }	}
}t        | |||«      }d\  }}}d}t        |d¬«      }|�t        |d¬«      nd}t	        |«      xs t        |«       }|€/|sd	nd
}d}t        |dd «      }|dz  }t        |«      dk7  r |dz  }n|st	        |«      st        |«      sd}|j                  d«      }d}|s|rd}d}nJ|rHt        t        ||«      «      }|sdnd}d|› d�j                  d«      }t        |g|¢­Ž t        |g|¢­Ž f}|€|nt        ||¬«      }t        |d«      5 }|j                  } |dt         › d|	› d|
› d|› d|› d|› d�j                  d«      «       |D ]  } | ||«      «       Œ 	 ddd«       y# 1 sw Y   yxY w)a      Serializes the matrix as `PAM <http://netpbm.sourceforge.net/doc/pam.html>`_
    image.

    :param matrix: The matrix to serialize.
    :param tuple(int, int) matrix_size: Tuple of width and height of the matrix.
    :param out: Filename or a file-like object supporting to write binary data.
    :param scale: Indicates the size of a single module (default: 1 which
            corresponds to 1 x 1 pixel per module).
    :param int border: Integer indicating the size of the quiet zone.
            If set to ``None`` (default), the recommended border size
            will be used (``4`` for QR Codes, ``2`` for Micro QR Codes).
    :param dark: Color of the modules (default: black). The
            color can be provided as ``(R, G, B)`` tuple, as web color name
            (like "red") or in hexadecimal format (``#RGB`` or ``#RRGGBB``).
    :param light: Optional background color (default: white).
            See `color` for valid values. In addition, ``None`` is
            accepted which indicates a transparent background.
    c                 óD   — t        | D �cg c]  }|dz  ‘Œ	 c}«      S c c}w )z4        Inverts the row bits 0 -> 1, 1 -> 0
        r   )r+  )rq   r<  s     r4   Úinvert_row_bitsz"write_pam.<locals>.invert_row_bits  s!   € ô ¨3Ö/ a˜!˜c›'Ò/Ó0Ð0ùÒ/ó   Šc                 ó8   ‡— dj                  ˆfd„| D «       «      S )NrP   c              3   ó(   •K  — | ]	  }‰|   –— Œ y ­wrh   rT   )rj   r<  r|  s     €r4   rm   z9write_pam.<locals>.row_to_color_values.<locals>.<genexpr>  s   øè ø€ Ò0 q˜ �
Ñ0ùrn   )r£   )rq   r|  s    `r4   Úrow_to_color_valuesz&write_pam.<locals>.row_to_color_values  s   ø€ Ø�x‰xÓ0¨CÔ0Ó0Ð0rP   zInvalid stroke color "r�   )r   r   ÚBLACKANDWHITEFr  NÚGRAYSCALE_ALPHAÚ	RGB_ALPHATrØ   )r   rÙ   ©r1  ÚRGBry   )s    s    r‘   ÚBr  )r|  rB  zP7
# Created by z
WIDTH z
HEIGHT z
DEPTH z
MAXVAL z

TUPLTYPE z
ENDHDR
)r–   r[   r   r  r  Ú_color_is_whiteÚ_invert_colorr—   Ú
startswithÚmaxr   rÎ   r   r	   r   r*   r  )rJ   rK   rL   rW   rX   r8   r9   r�  r‘  rY   rZ   r}  ÚdepthÚmaxvalÚ
tuple_typeÚtransparencyr
  Úbg_colorÚcolored_strokeÚis_rgbr|  ÚfmtÚ
row_filterr2   r*   rq   s                             r4   r!   r!     s  € ò(1ò1ñ ÜÐ1°$°°qÐ9Ó:Ð:Ü:¸;ÈÈvÓVÑ€Eˆ6�6Ü˜6 ;°°vÓ>€HØ 5Ñ€Eˆ6�:Ø€LÜ(¨¸5ÔA€LØBGÐBSÔ$ U¸Õ>ÐY]€HÜ)¨,Ó7ÒX¼?È<Ó;XÐY€NØÐÙ.<Ñ&À+ˆ
ØˆÜ  ¨b¨qÐ!1Ó2ˆØ�DÑˆÜˆ|Ó Ò!Ø˜FÑ"‰LÙ	¤°Ô 9¼_ÈXÔ=VØˆ
Ø×"Ñ" 5Ó)€FØ€GÙ‘lØˆØ,‰Ù	Ü”U˜<¨Ó2Ó3ˆÙ%‘¨1ˆØ�%�˜ˆl×!Ñ! 'Ó*ˆÜ˜Ð'˜hÒ'¬¨cÐ)A°LÒ)AÐBˆØ$+ O‘¼ÐATÐ^eÔ9f€JÜ	�#�tÓ	ð # Ø—‘ˆÙð Ü%˜Yð 'Ø�gð Ø�xð  Ø�gð Ø�xð  Ø$˜ð &ð÷  ™ ›ô	*ð ò 	#ˆCÙ‘*˜S“/Õ"ñ	#÷#÷ #ñ #ús   ÅAFÆF'c           
      óÔ  ‡— t        |«      }t        |||«      \  }}}d‰j                  «       v rt        d«      ‚‰j	                  «       D ]  \  }}	t        |	«      ‰|<   Œ t        | |||«      }
t        |d«      5 }|j                  } |dt        › d|› d|› d�j                  d«      «       |
D ]"  } |d	j                  ˆfd
„|D «       «      «       Œ$ 	 ddd«       y# 1 sw Y   yxY w)a�      Serializes the matrix as `PPM <http://netpbm.sourceforge.net/doc/ppm.html>`_
    image.

    :param matrix: The matrix to serialize.
    :param tuple(int, int) matrix_size: Tuple of width and height of the matrix.
    :param out: Filename or a file-like object supporting to write binary data.
    :param scale: Indicates the size of a single module (default: 1 which
            corresponds to 1 x 1 pixel per module).
    :param int border: Integer indicating the size of the quiet zone.
            If set to ``None`` (default), the recommended border size
            will be used (``4`` for QR Codes, ``2`` for Micro QR Codes).
    NzTransparency is not supportedrB  zP6 # Created by r”   r�   z 255
r  rP   c              3   ó<   •K  — | ]  }t        d g‰|   ¢­Ž –— Œ y­w)rD  Nr   ri   s     €r4   rm   zwrite_ppm.<locals>.<genexpr>d  s   øè ø€ ÒE¸2œ4 Ð6¨°"©Ö6ÑEùr(  )rˆ   r[   r™   r–   rŸ   rü   r   r   r*   r  rÎ   r£   )rJ   rK   rL   rl   rW   rX   rY   rZ   rk   ra   r}  r2   r*   rq   s      `          r4   r"   r"   J  sõ   ø€ ô �‹J€EÜ:¸;ÈÈvÓVÑ€Eˆ6�6Øˆx�‰Ó Ñ ÜÐ8Ó9Ð9Ø—>‘>Ó#ò *‰ˆˆCÜ$ SÓ)ˆ�Šð*ä" 6¨;¸¸vÓF€HÜ	�#�tÓ	ð G Ø—‘ˆÙÐ ¤ 	¨¨E¨7°!°F°8¸6ÐB×IÑIÈ'ÓRÔSØò 	GˆCÙ�#—(‘(ÓEÀÔEÓEÕFñ	G÷G÷ Gñ Gús   Á;ACÃC'c                 ó°  — t        |||«      \  }}	}t        | |||«      }
|�t        |«      nd}|�t        |«      nd}t        |d«      5 }|j                  } |d|› d|› d|	› d|› d|› d	�«       t        |
«      D ]>  \  }} |d
j                  t        dgd„ |D «       d||	dz
  k  rdnd
› d�g«      «      «       Œ@  |d«       ddd«       y# 1 sw Y   yxY w)aR      Serializes the matrix as `XPM <https://en.wikipedia.org/wiki/X_PixMap>`_ image.

    :param matrix: The matrix to serialize.
    :param tuple(int, int) matrix_size: Tuple of width and height of the matrix.
    :param out: Filename or a file-like object supporting to write binary data.
    :param scale: Indicates the size of a single module (default: 1 which
            corresponds to 1 x 1 pixel per module).
    :param int border: Integer indicating the size of the quiet zone.
            If set to ``None`` (default), the recommended border size
            will be used (``4`` for QR Codes, ``2`` for Micro QR Codes).
    :param dark: Color of the modules (default: black). The
            color can be provided as ``(R, G, B)`` tuple, as web color name
            (like "red") or in hexadecimal format (``#RGB`` or ``#RRGGBB``).
    :param light: Optional background color (default: white).
            See `color` for valid values. ``None`` indicates a transparent
            background.
    :param str name: Name of the image (must be a valid C-identifier).
            Default: "img".
    NÚNoner•   z/* XPM */
static char *z[] = {
"r�   z 2 1",
"  c z",
"X c z",
rw   r�   c              3   ó(   K  — | ]
  }|sd nd–— Œ y­w)r�   ÚXNrT   )rj   r<  s     r4   rm   zwrite_xpm.<locals>.<genexpr>‰  s   è ø€ Ò'KÀ!±1©¸#Ó(=Ñ'Kùs   ‚r   rÇ   r”   ú};
)r[   r   Úcolor_to_rgb_hexr   r*   r¤   r£   r   )rJ   rK   rL   rW   rX   r8   r9   r  rY   rZ   r}  r
  r   r2   r*   r‰   rq   s                    r4   r#   r#   g  s  € ô, ;¸;ÈÈvÓVÑ€Eˆ6�6Ü˜6 ;°°vÓ>€HØ-1Ð-=Ô# DÔ)À6€LØ*/Ð*;Ô Ô&À€HÜ	�#�tÓ	ð 
 Ø—‘ˆÙð Ø"˜Vð $Ø�˜˜&˜ð "Ø�Zð  Ø"�^ 4ð	)ô 	*ô
   Ó)ò 	M‰FˆAˆsÙ�"—'‘'œ%  Ñ'KÀsÔ'KØ#$¨Q°¸!±ª^¡cÀÐ$EÀRÐ!HÐ IóKó Lõ Mð	Mñ 	ˆfŒ÷
÷ 
ñ 
ús   Á
A9CÃCc                 óæ  — t        |||«      \  }}}t        | |||«      }t        |d«      5 }	|	j                  }
 |
d|› d|› d|› d|› d|› d�«       t	        |d¬	«      D ]p  \  }}t        t        |«      gd
z  ddiŽ}|D �cg c]  }dt        d„ |ddd…   «      d›�‘Œ c}} |
d«        |
dj                  |«      «        |
||k  rdnd«       Œr  |
d«       ddd«       yc c}w # 1 sw Y   yxY w)ad      Serializes the matrix as `XBM <https://en.wikipedia.org/wiki/X_BitMap>`_ image.

    :param matrix: The matrix to serialize.
    :param tuple(int, int) matrix_size: Tuple of width and height of the matrix.
    :param out: Filename or a file-like object supporting to write text data.
    :param scale: Indicates the size of a single module (default: 1 which
            corresponds to 1 x 1 in the provided unit per module).
    :param int border: Integer indicating the size of the quiet zone.
            If set to ``None`` (default), the recommended border size
            will be used (``4`` for QR Codes, ``2`` for Micro QR Codes).
    :param name: Prefix for the variable names. Default: "img".
                 The prefix is used to construct the variable names:
                 ```#define <prefix>_width``` ```static unsigned char <prefix>_bits[]```
    r•   z#define z_width z	
#define z_height z
static unsigned char z_bits[] = {
r   )Ústartr)  r*  r   Ú0xc                 ó   — | dz  |z   S r‚  rT   rƒ  s     r4   r   zwrite_xbm.<locals>.<lambda>¨  s   € ¨a°1©f¸©\€ rP   Nrd   Ú02xz    z, z,
r”   r«  )	r[   r   r   r*   r¤   r   r,  r   r£   )rJ   rK   rL   rW   rX   r  rY   rZ   r}  r2   r*   r‰   rq   Úiter_Úbitss                  r4   r$   r$   Ž  s#  € ô  ;¸;ÈÈvÓVÑ€Eˆ6�6Ü˜6 ;°°vÓ>€HÜ	�#�tÓ	ð  Ø—‘ˆÙ�˜˜˜g e Wð -Ø˜˜h v hð /&Ø&* V¨>ð;ô 	<ô   °Ô2ò 	1‰FˆAˆsÜ¤$ s£) ¨q¡Ð@¸CÑ@ˆEàY^Ö_ÐQU�bœÑ 9¸4ÁÀ"À¹:ÓFÀsÐKÒLÒ_ˆDÙ�&ŒMÙ�$—)‘)˜D“/Ô"Ù˜1˜vš:‘%¨4Õ0ð	1ñ 	ˆfŒ÷ð ùò `÷ð ús   ¬AC'Â C"Â;C'Ã"C'Ã'C0r3  c           
      óR  ‡— ˆfd„}t        |«       t        |«       t        ||«      }d}	t        |d«      5 }
|
j                  } |dt
        › d�«        |dt        j                  d«      › d�«       |r |d|› d	�«       d
}	 |d«        |d|› ‰› d�«       |r|dk7  r |d|› d�«       || }}t        | ||d¬«      D ]=  \  \  }}\  }} |d |||z  ||z  «      › d�«        |d |||z  ||z  «      › d�«       Œ?  |d«        |d|	› d�«       ddd«       y# 1 sw Y   yxY w)a`      Serializes the matrix as LaTeX PGF picture.

    Requires the `PGF/TikZ <https://en.wikipedia.org/wiki/PGF/TikZ>`_ package
    (i.e. ``\usepackage{pgf}``) in the LaTeX source.

    :param matrix: The matrix to serialize.
    :param tuple(int, int) matrix_size: Tuple of width and height of the matrix.
    :param out: Filename or a file-like object supporting to write text data.
    :param scale: Indicates the size of a single module (default: 1 which
            corresponds to 1 x 1 in the provided unit per module).
    :param int border: Integer indicating the size of the quiet zone.
            If set to ``None`` (default), the recommended border size
            will be used (``4`` for QR Codes, ``2`` for Micro QR Codes).
    :param str dark: LaTeX color name. The color name is taken at it is, so
            ensure that it refers either to a default color name or that the
            color was defined previously.
    :param unit: Unit of the drawing (default: ``pt``)
    :param url: Optional URL where the QR code should point to. Requires the
            "hyperref" package. Default: ``None``.
    c                 ó   •— d| › ‰› d|› ‰› d�S )Nz\pgfqpoint{ú}{ú}rT   )r„   r†   r±   s     €r4   Úpointzwrite_tex.<locals>.pointÅ  s    ø€ Ø˜q˜c $  t¨A¨3¨t¨f°BÐ7Ð7rP   rw   r•   z% Creator:  r”   z% Date:     z%Y-%m-%dT%H:%M:%Sz\href{r¶  r·  z\begin{pgfpicture}
z  \pgfsetlinewidth{z}
r3  z	  \color{rd   r  z  \pgfpathmoveto{z  \pgfpathlineto{z  \pgfusepath{stroke}
z\end{pgfpicture}N)	r   r   r   r   r*   r  r  r  r   )rJ   rK   rL   rW   rX   r8   r±   Úurlr¸  Ú
end_markerr2   r*   r„   r†   rs   r|   rt   r}   s         `           r4   r%   r%   ¯  si  ø€ ô,8ô �eÔÜ�vÔÜ˜ VÓ,€FØ€JÜ	�#�tÓ	ð 4 Ø—‘ˆÙ�œW˜I RÐ(Ô)Ù�œTŸ]™]Ð+>Ó?Ð@ÀÐCÔDÙÙ�H˜S˜E Ð&Ô'ØˆJÙÐ%Ô&ÙÐ% e W¨T¨F°$Ð7Ô8Ù�D˜G’OÙ�K ˜v TÐ*Ô+Ø˜�wˆ1ˆÜ"1°&¸!¸QÀbÔ"Iò 	MÑ‰HˆR�‘h�r˜2ÙÐ'©¨b°5©j¸"¸u¹*Ó(EÐ'FÀdÐKÔLÙÐ'©¨b°5©j¸"¸u¹*Ó(EÐ'FÀdÐKÕLð	Mñ 	Ð(Ô)ÙÐ# J <¨rÐ2Ô3÷!4÷ 4ñ 4ús   ·CDÄD&c                 ó|  — t        |d«      5 }|j                  }dD �cg c]  }d|› d�‘Œ
 }}t        | |d|¬«      D ]d  }d}	d}
|D ]1  }||	k(  r|
dz  }
Œ|
r |||	   «        |d	|
z  «        |d
«       |}	d}
Œ3 |
r |||	   «        |d	|
z  «        |d
«        |d«       Œf 	 ddd«       yc c}w # 1 sw Y   yxY w)aæ      Function to write to a terminal which supports ANSI escape codes.

    :param matrix: The matrix to serialize.
    :param tuple(int, int) matrix_size: Tuple of width and height of the matrix.
    :param out: Filename or a file-like object supporting to write text.
    :param int border: Integer indicating the size of the quiet zone.
            If set to ``None`` (default), the recommended border size
            will be used (``4`` for QR Codes, ``2`` for Micro QR Codes).
    r•   )é   é1   z[r�   r   re   rd   r   ú  z[0mr”   N)r   r*   r   )rJ   rK   rL   rX   r2   r*   r‰   r|  rq   Úprev_bitÚcntrå   s               r4   r&   r&   ß  sï   € ô 
�#�tÓ	ð  Ø—‘ˆØ)0Ö1 A�U˜1˜#˜Q’<Ð1ˆÐ1Ü˜v {¸!ÀFÔKò 	ˆCØˆHØˆCØò 	�Ø˜(’?Ø˜1‘H‘CáÙ˜g hÑ/Ô0Ù˜d S™jÔ)Ù˜iÔ(Ø"�HØ‘Cð	ñ Ù�g˜hÑ'Ô(Ù�d˜S‘jÔ!Ù�iÔ Ù�$�Kñ#	÷ð ùâ1÷ð ús   �B2žB-«A8B2Â-B2Â2B;c                 ó�  — ddl }ddl}ddl}|j                  j                  }|j
                  j                  j                  d«      }|j                  d«      }|j
                  j                  j                  ||«      }	|	st        d«      ‚|j                  d|j                  «      d   }
t        |j
                  j                  j                  |«      }d|
f}t        | |d	|¬
«      D ]\  }d}d}|D ])  }||k(  r|d	z  }Œ|r |||   «        |d|z  «       |}d	}Œ+ |r |||   «        |d|z  «        ||
«        |d«       Œ^ y)a‘      Function to write a QR code to a MS Windows terminal.

    :param matrix: The matrix to serialize.
    :param tuple(int, int) matrix_size: Tuple of width and height of the matrix.
    :param int border: Integer indicating the size of the quiet zone.
            If set to ``None`` (default), the recommended border size
            will be used (``4`` for QR Codes, ``2`` for Micro QR Codes).
    r   Niõÿÿÿé   zKCannot find information about the console. Not running on the command line?s   hhhhHhhhhhhrÙ   éð   r   re   rd   r¾  r”   )ÚsysÚstructÚctypesÚstdoutr*   ÚwindllÚkernel32ÚGetStdHandleÚcreate_string_bufferÚGetConsoleScreenBufferInfoÚOSErrorÚunpackÚrawr	   ÚSetConsoleTextAttributer   )rJ   rK   rX   rÄ  rÅ  rÆ  r*   Ústd_outÚcsbiÚresÚdefault_colorÚ	set_colorr|  rq   r¿  rÀ  rå   s                    r4   Úwrite_terminal_winrÖ    sL  € ó ÛÛØ�J‰J×Ñ€EØ�m‰m×$Ñ$×1Ñ1°#Ó6€GØ×&Ñ& rÓ*€DØ
�-‰-×
 Ñ
 ×
;Ñ
;¸GÀTÓ
J€CÙÜð 9ó :ð 	:à—M‘M .°$·(±(Ó;¸AÑ>€MÜ˜Ÿ™×.Ñ.×FÑFÈÓP€IØ�MÐ"€GÜ˜6 ;°aÀÔGò ˆØˆØˆØò 	ˆCØ�hŠØ�q‘‘áÙ˜g hÑ/Ô0Ù˜$ ™*Ô%Ø�Ø‘ð	ñ Ù�g˜hÑ'Ô(Ù�$˜‘*ÔÙ�-Ô Ùˆd�ñ!rP   c                 ó2  ‡	— dddddœŠ	t        | |d|¬«      gdz  }t        |d	«      5 }|j                  }t        |d
t	        d«      iŽD ]7  \  }} |dj                  ˆ	fd„t        ||«      D «       «      «        |d«       Œ9 	 ddd«       y# 1 sw Y   yxY w)a      Function to write a QR code to a terminal using unicode half-block characters.
    Custom colors are not used.

    :param matrix: The matrix to serialize.
    :param tuple(int, int) matrix_size: Tuple of width and height of the matrix.
    :param out: Filename or a file-like object supporting to write text.
    :param int border: Integer indicating the size of the quiet zone.
            If set to ``None`` (default), the recommended border size
            will be used (``4`` for QR Codes, ``2`` for Micro QR Codes).
    r�   u   â–€u   â–„u   â–ˆ))r   r   rÛ   )r   r   rf   r   re   ry   r•   r*  rw   c              3   ó(   •K  — | ]	  }‰|   –— Œ y ­wrh   rT   )rj   ÚpairÚblockss     €r4   rm   z)write_terminal_compact.<locals>.<genexpr>@  s   øè ø€ ÒL¨4˜& �,ÑLùrn   r”   N)r   r   r*   r   r   r£   Úzip)
rJ   rK   rL   rX   Úitr2   r*   Útop_rowÚ
bottom_rowrÚ  s
            @r4   Úwrite_terminal_compactrß  +  s£   ø€ ð ØØØñ€Fô
 �f˜k°¸6Ô
BÐ	CÀaÑ	G€BÜ	�#�tÓ	ð  Ø—‘ˆÜ#.°Ð#H¼fÀQ»iÑ#Hò 	ÑˆG�ZÙ�"—'‘'ÓL´3°wÀ
Ó3KÔLÓLÔMÙ�$�Kñ	÷÷ ñ ús   ¨ABÂBc                 ó8   — t        | |¬«      }|d   dv r|dd S |S )a<      Returns the provided color as ``(R, G, B)`` or ``(R, G, B, A)`` tuple.

    If the alpha value is opaque, an RGB tuple is returned, otherwise an RGBA
    tuple.

    :param color: A web color name (i.e. ``darkblue``) or a hexadecimal value
            (``#RGB`` or ``#RRGGBB``) or a RGB(A) tuple (i.e. ``(R, G, B)`` or
            ``(R, G, B, A)``)
    :param bool alpha_float: Indicates if the alpha value should be returned as
            float value. If ``False``, the alpha value is an integer value in
            the range of ``0 .. 254``.
    :rtype: tuple
    r  rØ   )rõ   r1  N)Ú_color_to_rgba)r¿   r  Úrgbas      r4   r  r  D  s,   € ô ˜%¨[Ô9€DØˆA�w�*ÑØ�B�QˆxˆØ€KrP   c                 óV  — t        | «      ryt        | «      ryt        | «      }d}t        |«      dk(  r|r dj                  |Ž S |d   }|dd } dj                  |Ž }|rC|dk(  rd	}n;|d
k(  rd}n3|d   |d   k(  r(|d   |d   k(  r|d   |d   k(  rd|d   › |d   › |d   › �}|€|S ||fS )a{      Returns either a hexadecimal code or a color name.

    :param color: A web color name (i.e. ``darkblue``) or a hexadecimal value
            (``#RGB`` or ``#RRGGBB``) or a RGB(A) tuple (i.e. ``(R, G, B)`` or
            ``(R, G, B, A)``)
    :param bool allow_css3_colors: Indicates if a CSS3 color value like
            rgba(R G, B, A) is an acceptable result.
    :param bool optimize: Inidcates if the shortest possible color value should
            be returned (default: ``True``).
    :rtype: str
    :return: The provided color as web color: ``#RGB``, ``#RRGGBB``,
            ``rgba(R, G, B, A)``, or web color name.
    r\   rÓ   NrÙ   zrgba({0},{1},{2},{3})rØ   ú#{0:02x}{1:02x}{2:02x}z#d2b48cÚtanz#ff0000rÔ   r   ry   rÚ   é   ú#)r  r˜  r  r—   r‡   )r¿   r_   Úoptimizera   Úalpha_channelÚhxs         r4   r`   r`   Y  sí   € ô �uÔØÜ	˜Ô	ØÜ
 Ó
&€CØ€MÜ
ˆ3ƒx�1‚}ÙØ1Ð*×1Ñ1°3Ð7Ð7Ø˜A™ˆØ�"�1ˆgˆØ	(Ð	!×	(Ñ	(¨#Ð	.€BÙØ�Š?Ø‰BØ�9Š_Ø‰BØ�‰U�b˜‘eŠ^  1¡¨¨A©¢°2°a±5¸B¸q¹E²>Ø�R˜‘U�G˜B˜q™E˜7 2 a¡5 'Ð*ˆBØÐ&ˆ2Ð?¨R°Ð,?Ð?rP   c                 ó2   —  dj                   t        | «      Ž S )a      Returns the provided color in hexadecimal representation.

    :param color: A web color name (i.e. ``darkblue``) or a hexadecimal value
            (``#RGB`` or ``#RRGGBB``) or a RGB(A) tuple (i.e. ``(R, G, B)`` or
            ``(R, G, B, A)``)
    :returns: ``#RRGGBB``.
    rä  )r‡   rü   ©r¿   s    r4   r¬  r¬  ~  s   € ð +Ð#×*Ñ*¬M¸%Ó,@ÐAÐArP   c                 óP   — 	 | j                  «       } | dv S # t        $ r Y | dv S w xY w)a?      Returns if the provided color represents "black".

    :param color: A web color name (i.e. ``darkblue``) or a hexadecimal value
            (``#RGB`` or ``#RRGGBB``) or a RGB(A) tuple (i.e. ``(R, G, B)`` or
            ``(R, G, B, A)``)
    :return: ``True`` if color is represents black, otherwise ``False``.
    )r\   z#000000r3  r/  )r   r   r   r1  )r   r   r   rõ   ©Úlowerr-   rì  s    r4   r  r  Š  sL   € ðØ—‘“ˆð ð %ð %ð %øô ò ØØð %ð %ð %ðúó   ‚ –	%¤%c                 óP   — 	 | j                  «       } | dv S # t        $ r Y | dv S w xY w)a?      Returns if the provided color represents "black".

    :param color: A web color name (i.e. ``darkblue``) or a hexadecimal value
            (``#RGB`` or ``#RRGGBB``) or a RGB(A) tuple (i.e. ``(R, G, B)`` or
            ``(R, G, B, A)``)
    :return: ``True`` if color is represents white, otherwise ``False``.
    )rÓ   z#ffffffr4  r0  )r1  r1  r1  r1  )r1  r1  r1  rõ   rî  rì  s    r4   r˜  r˜  ›  sR   € ðØ—‘“ˆð ð Að Að Aøô ò ØØð Að Að Aðúrð  c                 ób   — t        | «      }t        |«      dk7  rt        d|d   › d| › d�«      ‚|S )aX      Converts web color names like "red" or hexadecimal values like "#36c",
    "#FFFFFF" and RGB tuples like ``(255, 255 255)`` into a (R, G, B) tuple.

    :param color: A web color name (i.e. ``darkblue``) or a hexadecimal value
            (``#RGB`` or ``#RRGGBB``) or a RGB tuple (i.e. ``(R, G, B)``))
    :return: ``(R, G, B)`` tuple.
    rØ   zThe alpha channel z in color "z" cannot be converted to RGB)r  r—   r–   )r¿   Úrgbs     r4   rü   rü   ¬  sG   € ô   Ó
&€CÜ
ˆ3ƒx�1‚}ÜÐ-¨c°!©f¨X°[ÀÀð H,ð ,ó -ð 	-à€JrP   c                 ój  — g }|rdnd}t        | t        «      r±t        | «      }d}d|cxk  rdk  r}n nzt        | dd «      D ]/  \  }}d|cxk  xr dk  nc }|j	                  |«       |r|d	k(  sŒ/ n |r8|dk(  r|j	                  t        | d   |«      «       n|j	                  |d   «       |rt        |«      S t        d
| › d�«      ‚	 t        | j                  «          |z   S # t        $ rD 	 t        | |¬«      }t        |«      dk(  r|cY S ||z   cY S # t        $ r t        d
| › d�«      ‚w xY ww xY w)aÌ      Returns a (R, G, B, A) tuple.

    :param color: A web color name (i.e. ``darkblue``) or a hexadecimal value
            (``#RGB`` or ``#RRGGBB``) or a RGB(A) tuple (i.e. ``(R, G, B)`` or
            ``(R, G, B, A)``)
    :param bool alpha_float: Indicates if the alpha value should be returned as
            float value. If ``False``, the alpha value is an integer value in
            the range of ``0 .. 254``.
    :return: ``(R, G, B, A)`` tuple.
    )rõ   r•  FrØ   rÙ   Nr   r1  ry   zUnsupported color "r�   r  zD". Neither a known web color name nor a color in hexadecimal format.)r    r¡   r—   r¤   r�   Ú_alpha_valuer–   rK  rï  rž   Ú_hex_to_rgb_or_rgba)	r¿   r  rÓ  ré  Ú
col_lengthÚis_validr‰   Úpartra   s	            r4   rá  rá  ¼  s_  € ð €CÙ)‘F¨v€MÜ�%œÔÜ˜“Zˆ
ØˆØ�
Ô˜aÕÜ$ U¨2¨A YÓ/ò ‘��4Ø Ö+¨Ô+�Ø—
‘
˜4Ô Ù 1¨£6Ùð	ñ
 Ø ’?Ø—J‘Jœ|¨E°!©H°kÓBÕCà—J‘J˜}¨QÑ/Ô0ÙÜ˜“:ÐÜÐ.¨u¨g°QÐ7Ó8Ð8ðNÜ˜Ÿ™›Ñ'¨-Ñ7Ð7øÜò 	Nð	NÜ% e¸ÔEˆCÜ�3‹x˜1Š}Ø’
à˜]Ñ*Ò*øÜò 	NÜÐ2°5°'ð :Mð Mó Nð Nð	Núð	Nús0   ÃC% Ã%	D2Ã/DÄD2ÄDÄD2ÄD.Ä.D2c                 ó®  — | d   dk(  r| dd } dt        | «      cxk  rdk  r:n n7dj                  t        t        | «      «      D �cg c]
  }| |   dz  ‘Œ c}«      } t        | «      }|dvrt        d	| › d
�«      ‚t	        t        d|d«      D �cg c]  }t        | ||dz    d«      ‘Œ c}«      }|r|dk(  r|dd t        |d   |«      fz   }|S c c}w c c}w )a9      Helper function to convert a color provided in hexadecimal format (``#RGB``
    or ``#RRGGBB``) to a RGB(A) tuple.

    :param str color: Hexadecimal color name.
    :param bool alpha_float: Indicates if the alpha value should be returned as
            float value. If ``False``, the alpha value is an integer value in
            the range of ``0 .. 254``.
    :return: Tuple of integer values representing a RGB(A) color.
    :rtype: tuple
    :raises: :py:exc:`ValueError` in case the provided string could not
                converted into a RGB(A) tuple
    r   rç  r   Nry   rÚ   rw   )ræ  r)  zInput #z* is not in #RRGGBB nor in #RRGGBBAA formaté   r)  rØ   )r—   r£   rÝ   r–   r¡   rˆ   rõ  )r¿   r  r‰   Ú	color_lenrÓ  s        r4   rö  rö  é  sâ   € ð ˆQ�x�3‚Ø�a�b�	ˆØŒ3ˆu‹:Ô˜Õà—‘¬u´S¸³ZÓ/@ÖA¨!˜˜q™ A›ÒAÓBˆÜ�E“
€IØ˜ÑÜ˜7 5 'Ð)SÐTÓUÐUÜ
´%¸¸9ÀaÓ2HÖI¨Q”�U˜1˜Q ™U�^ RÕ(ÒIÓ
J€CÙ�y A’~Ø�"�1ˆgœ c¨!¡f¨kÓ:Ð<Ñ<ˆØ€Jùò Bùò Js   ÁCÂCrõ   rz   g      Ð?g      À?g      ä?rô   )r1  é€   é@   é    rû  r   c                 ó&  — |rRt        | t        «      s3d| cxk  rdk  rgn ndt        j                  | t        d| dz  z  «      «      S d| cxk  rdk  r4| S  n0t        | t        «      sd| cxk  rdk  r| S  nd| cxk  r	dk  r| dz  S  t	        d| › �«      ‚)Nr   r1  z%.02fg     ào@rõ   zInvalid alpha channel value: )r    r÷   Ú_ALPHA_COMMONSrÞ   r–   )r¿   r  s     r4   rõ  rõ    s¨   € ÙÜ˜%¤Ô'Ø�EÔ ˜SÕ Ü%×)Ñ)¨%´°wÀ%È%Á-Ñ7PÓ1QÓRÐRà�EÔ ˜SÒ Ø�ñ !ô ˜%¤Ô'Ø�EÔ ˜SÒ Ø�ñ !ð �EÔ ˜SÒ Ø˜u‘}Ð$ð !ä
Ð4°U°GÐ<Ó
=Ð=rP   c                 óD   — t        | D �cg c]  }d|z
  ‘Œ	 c}«      S c c}w )z¸    Returns the inverse color for the provided color.

    This function does not check if the color is a valid RGB / RGBA color.

    :param rgb: (R, G, B) or (R, G, B, A) tuple.
    r1  )r¡   )Úrgb_or_rgbaru   s     r4   r™  r™    s!   € ô  ;Ö/˜a�#˜“'Ò/Ó0Ð0ùÒ/rŽ  Ú	aliceblue)rÃ  éø   r1  Úantiquewhite)éú   éë   é×   Úaqua)r   r1  r1  Ú
aquamarine)é   r1  éÔ   Úazure)rÃ  r1  r1  Úbeige)éõ   r  éÜ   Úbisque)r1  éä   éÄ   r/  Úblanchedalmond)r1  r  éÍ   Úblue)r   r   r1  Ú
blueviolet)éŠ   é+   éâ   Úbrown)é¥   é*   r  Ú	burlywood)éÞ   é¸   é‡   Ú	cadetblue)é_   éž   é    Ú
chartreuse)r  r1  r   Ú	chocolate)éÒ   éi   é   Úcoral)r1  r  éP   Úcornflowerblue)éd   é•   éí   Úcornsilk)r1  r  r  Úcrimson)r  é   rg  ÚcyanÚdarkblue)r   r   é‹   Údarkcyan)r   r7  r7  Údarkgoldenrod)r!  é†   é   Údarkgray)é©   r=  r=  Ú	darkgreen)r   r/  r   ÚdarkgreyÚ	darkkhaki)é½   é·   ék   Údarkmagenta)r7  r   r7  Údarkolivegreen)éU   rC  é/   Ú
darkorange)r1  éŒ   r   Ú
darkorchid)é™   é2   éÌ   Údarkred)r7  r   r   Ú
darksalmon)éé   é–   éz   Údarkseagreen)é�   é¼   rT  Údarkslateblue)éH   é=   r7  Údarkslategray)rG  éO   rZ  ÚdarkslategreyÚdarkturquoise)r   éÎ   éÑ   Ú
darkviolet)é”   r   éÓ   Údeeppink)r1  r4  é“   Údeepskyblue)r   é¿   r1  Údimgray)r*  r*  r*  ÚdimgreyÚ
dodgerblue)r+  é�   r1  Ú	firebrick)é²   é"   rl  Úfloralwhite)r1  r  rÃ  Úforestgreen)rl  r7  rl  )r1  r   r1  Ú	gainsboro)r  r  r  Ú
ghostwhite)r  r  r1  rÖ   )r1  r	  r   Ú	goldenrod)éÚ   r  rÿ  Úgray)rý  rý  rý  r×   )r   rý  r   Úgreenyellow)é­   r1  rG  ÚgreyÚhoneydew)rÃ  r1  rÃ  Úhotpink)r1  r*  é´   Ú	indianred)r  é\   r{  Úindigo)éK   r   é‚   Úivory)r1  r1  rÃ  Úkhaki)rÃ  éæ   rI  Úlavender)r�  r�  r  Úlavenderblush)r1  rÃ  r  Ú	lawngreen)é|   éü   r   Úlemonchiffon)r1  r  r  Ú	lightblue)ru  éØ   r�  Ú
lightcoral)rÃ  rý  rý  Ú	lightcyan)éà   r1  r1  Úlightgoldenrodyellow)r  r  r)  Ú	lightgray)ra  ra  ra  Ú
lightgreen)ri  éî   ri  Ú	lightgreyÚ	lightpink)r1  é¶   éÁ   Úlightsalmon)r1  r&  rR  Úlightseagreen)rÿ  rk  éª   Úlightskyblue)r"  r]  r  Úlightslategray)éw   éˆ   rK  ÚlightslategreyÚlightsteelblue)é°   r  r   Úlightyellow)r1  r1  rŒ  Úlime)r   r1  r   Ú	limegreen)rL  r  rL  Úlinen)r  rÃ  r�  ÚmagentaÚmaroon)rý  r   r   Úmediumaquamarine)éf   r  r—  Ú
mediumblue)r   r   r  Úmediumorchid)éº   rF  ra  Úmediumpurple)rc  ép   éÛ   Úmediumseagreen)rg  é³   éq   Úmediumslateblue)é{   éh   r�  Úmediumspringgreen)r   r  éš   Úmediumturquoise)rW  r^  rM  Úmediumvioletred)éÇ   é   é…   Úmidnightblue)é   r»  r«  Ú	mintcream)r  r1  r  Ú	mistyrose)r1  r  éá   Úmoccasin)r1  r  éµ   Únavajowhite)r1  r   ru  Únavy)r   r   rý  Úoldlace)éý   r  r�  Úolive)rý  rý  r   Ú	olivedrab)rC  éŽ   é#   rÕ   )r1  r  r   Ú	orangered)r1  éE   r   Úorchid)rr  r«  éÖ   Úpalegoldenrod)r�  éè   r—  Ú	palegreen)é˜   éû   rÐ  Úpaleturquoise)é¯   r�  r�  Úpalevioletred)r¬  r«  rc  Ú
papayawhip)r1  éï   éÕ   Ú	peachpuff)r1  rr  é¹   Úperu)r  r¹  é?   Úpink)r1  éÀ   éË   Úplum)éÝ   r&  rà  Ú
powderblue)rž  rŒ  r�  Úpurple)rý  r   rý  rÔ   )r1  r   r   Ú	rosybrown)rU  rT  rT  Ú	royalblue)éA   r*  r¾  Úsaddlebrown)r7  rÊ  é   Úsalmon)r  rý  ér   Ú
sandybrown)éô   é¤   é`   Úseagreen)é.   r7  éW   Úseashell)r1  r  r�  Úsienna)r&  éR   é-   Úsilver)rÝ  rÝ  rÝ  Úskyblue)r"  r]  r  Ú	slateblue)éj   éZ   r  Ú	slategray)r«  rý  ri  Ú	slategreyÚsnow)r1  r  r  Úspringgreen)r   r1  r  Ú	steelblue)éF   r~  ry  )r)  ry  rI  )r   rý  rý  )r‰  re  r‰  )r1  éc   éG   )rþ  rŒ  éÐ   )r�  r~  r�  )r  r   r®  r0  )r  r  r  )r1  r1  r   )r´  r  rL  )rå  ÚtealÚthistleÚtomatoÚ	turquoiseÚvioletÚwheatr4  Ú
whitesmokeÚyellowÚyellowgreenc                 ó¢  — d}| |k(  }|sdt         j                  t         j                  t         j                  g}| dk  r˜|j	                  t         j
                  t         j                  f«       nh| dk  rct         j                  t         j                  g}| dk  r>|j	                  t         j                  t         j
                  t         j                  g«       t         j                  |dur|n|t         j                  |dur|n|t         j                  |dur|n|t         j                  |dur|n|t         j                  |dur|n|t         j                  |	dur|	n|t         j
                  |dur|n|t         j                  |dur|n|t         j                  |dur|n|t         j                  |dur|n|t         j                  |
dur|
n|t         j                  |dur|n|t         j                  |dur|n|t         j                  |dur|n|t         j                   |dur|n|i}|j#                  «       D ��ci c]  \  }}||vsŒ||“Œ c}}S c c}}w )a‘      Creates and returns a module type -> color map.

    The result can be used for serializers which support more than two colors.

    Examples

    .. code-block:: python

        # All dark modules (data, version, ...) will be dark red, the dark
        # modules of the finder patterns will be blue
        # The light modules will be rendered in the serializer's default color
        # (usually white)
        cm = colormap(dark='darkred', finder_dark='blue')

        # Use the serializer's default colors for dark / light modules
        # (usually black and white) but the dark modules of the timing patterns
        # will be brown
        cm = colormap(timing_dark=(165, 42, 42))

    :param int matrix_width: Matrix width
    :param int matrix_height: Matrix height
    :param dark: Default color of dark modules
    :param light: Default color of light modules
    :param finder_dark: Color of the dark modules of the finder patterns.
    :param finder_light: Color of the light modules of the finder patterns.
    :param data_dark: Color of the dark data modules.
    :param data_light: Color of the light data modules.
    :param version_dark: Color of the dark modules of the version information.
    :param version_light: Color of the light modules of the version information.
    :param format_dark: Color of the dark modules of the format information.
    :param format_light: Color of the light modules of the format information.
    :param alignment_dark: Color of the dark modules of the alignment patterns.
    :param alignment_light: Color of the light modules of the alignment patterns.
    :param timing_dark: Color of the dark modules of the timing patterns.
    :param timing_light: Color of the light modules of the timing patterns.
    :param separator: Color of the separator.
    :param dark_module: Color of the dark module.
    :param quiet_zone: Color of the quiet zone / border.
    :rtype: dict
    rT   r  rô  r¸  F)r   ÚTYPE_DARKMODULEÚTYPE_VERSION_DARKÚTYPE_VERSION_LIGHTro  ÚTYPE_ALIGNMENT_PATTERN_DARKÚTYPE_ALIGNMENT_PATTERN_LIGHTrH  ÚTYPE_FINDER_PATTERN_LIGHTr›   ÚTYPE_DATA_LIGHTÚTYPE_TIMING_DARKÚTYPE_TIMING_LIGHTÚTYPE_FORMAT_DARKÚTYPE_FORMAT_LIGHTÚTYPE_SEPARATORrš   rŸ   )râ   rã   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   ÚunsupportedÚ	is_squareÚmt2colorrk   ræ   s                           r4   rI   rI   ½  s  € ðd €KØ Ñ-€IÙÜ×-Ñ-¬v×/GÑ/GÌ×IbÑIbÐcˆØ˜"ÒØ×Ñ¤× BÑ BÄF×DgÑDgÐhÕiØ	˜Ò	Ü×/Ñ/´×1JÑ1JÐKˆØ˜"ÒØ×Ñ¤× 6Ñ 6Ü &× BÑ BÜ &× CÑ Cð Eô Fô 	×'Ñ'¸È5Ñ8P©ÐVZÜ×(Ñ(¸,ÈeÑ:S©,ÐY^Ü×Ñ¨I¸UÑ,B™yÈÜ×Ñ¨jÀÑ.E¡
È5Ü× Ñ °,ÀeÑ2K¡,ÐQUÜ×!Ñ!°MÈÑ4N¡=ÐTYÜ×*Ñ*¸nÐTYÑ>Y©NÐ_cÜ×+Ñ+ÀÐW\Ñ@\©_ÐbgÜ×Ñ°À5Ñ0H¡ÈdÜ× Ñ °,ÀeÑ2K¡,ÐQVÜ×Ñ°À5Ñ0H¡ÈdÜ× Ñ °,ÀeÑ2K¡,ÐQVÜ×Ñ¨I¸UÑ,B™yÈÜ×Ñ¨{À%Ñ/G¡ÈTÜ×Ñ¨jÀÑ.E¡
È5ð€Hð" $,§>¡>Ó#3×M™˜˜C°rÀÒ7LˆB�‰GÓMÐMùÓMs   È5IÉI)rÄ   ÚpngÚepsÚtxtÚpdfÚansÚpbmÚpamÚppmÚtexÚxbmÚxpmc                 óÌ  — d}|€5	 |j                   }d}||j                  d«      dz   d j                  «       }n|j                  «       }| xr |dk(  }	 t        |s|nd   }	|r=t        j                  |d
|j                  dd«      ¬«      5 }
 |	| ||
fi |¤Ž ddd«       y |	| ||fi |¤Ž y# t        $ r |}Y Œ¦w xY w# t
        $ r t        d|› d	�«      ‚w xY w# 1 sw Y   yxY w)a"      Serializes the matrix in any of the supported formats.

    :param matrix: The matrix to serialize.
    :param tuple(int, int) matrix_size: Tuple of width and height of the matrix.
    :param out: A filename or a writable file-like object with a
            ``name`` attribute. If a stream like :py:class:`io.ByteIO` or
            :py:class:`io.StringIO` object without a ``name`` attribute is
            provided, use the `kind` parameter to specify the serialization
            format.
    :param kind: If the desired output format cannot be extracted from
            the filename, this parameter can be used to indicate the
            serialization format (i.e. "svg" to enforce SVG output)
    :param kw: Any of the supported keywords by the specific serialization
            method.
    FNTú.r   ÚsvgzrÄ   zUnknown file extension ".r�   rB  r  é	   )r  )
r  r-   Úrfindrï  Ú_VALID_SERIALIZERSrž   r–   Úgzipr.   Úpop)rJ   rK   rL   ÚkindrM   Ú	is_streamÚfnameÚextÚis_svgzÚ
serializerr2   s              r4   Úsaver5    s  € ð" €IØ€|ð	Ø—H‘HˆEØˆIð �E—K‘K Ó$ qÑ(Ð)Ð*×0Ñ0Ó2‰à�j‰j‹lˆØˆmÒ-  v¡€Gð=Ü'±7©ÀÑFˆ
ñ Ü�Y‰Y�s˜D°·±°ÈÓ0JÔKð 	5ÈqÙ�v˜{¨AÑ4°Ò4÷	5ð 	5ñ 	�6˜;¨Ñ2¨rÓ2øô ò 	ØŠEð	ûô ò =ÜÐ4°S°E¸Ð;Ó<Ð<ð=ú÷	5ð 	5ús)   †B- ÁB> ÂCÂ-B;Â:B;Â>CÃC#rh   )r   NTTNNNÚsegnoÚqrlineFNrx   NTF)r   NFTNNNr6  r7  Frw   rx   NFFF)é   NrÑ   NT)r   Nr\   N)r   Nr*  )r   Nr*  N)r   Nr\   Nr*  )NÚ1Ú0)r   NF)r   Nr\   rÓ   )r   N)r   Nr\   rÓ   Úimg)r   Nr;  )r   Nr3  ÚptN)T)TT)FFFFFFFFFFFFFFF)NÚ__doc__rÈ   r¥   r  r+   r  r-  Úxml.sax.saxutilsr   r   rÅ  r   Ú	itertoolsr   r   rQ   r	   r   Úoperatorr   Ú
contextlibr   Úcollectionsr   r  rw   r   Úutilsr   r   r   r   r   r   r   r   Úurllib.parser   Ú__all__r  r   rU   r[   r   Úcompiler¦   rÊ   rÐ   rç   r   r  r   r   r   r    r!   r"   r#   r$   r%   r&   rÖ  rß  r  r`   r¬  r  r˜  rü   rá  rö  r  rõ  r™  rK  rI   r,  r5  rT   rP   r4   ú<module>rG     s
  ðñó 
Û 	Û Û Û Û ß .Ý ß #Û Ý Ý Ý Ý %Ý #Û Ý ÷L÷ Lñ Lå !Ý ð7€ð
 4€ð óó ðò:ò0!ñ 
ˆv˜TÔ"ØPTØFMØFMØ9>óZó #ðZñz ˜*˜"Ÿ*™*Ð%5Ó6×:Ñ:¸JÓG€ð :>Ø59Ø4;Ø=?Ø:?Ø7<ô6ðD @DØ7;Ø#ô7ôtTôn
Xñ 
ˆv˜VÔ$óT#ó %ðT#ðn DJØ()ôV?ôrô,$ôNE#ñP 
ˆv˜VÔ$óGó %ðGð8 DJØ!&ô$ôNôB-4ô`ôD'ôTô2ô*"@òJ	Bò%ò"Aò"ô *NôZð8  ¨°$¸DÀSÑI€ò>ò$1ðTØ�ðTà�OðTð ˆMðTð �/ð	Tð
 ˆ_ðTð ˆ_ðTð ˆoðTð ˆYðTð �oðTð ˆKðTð �.ðTð ˆ]ðTð �ðTð �ðTð �-ðTð  �ð!Tð" ˆ^ñ#Tð$ �oð%Tð& �ð'Tð( ˆ}ð)Tð* ˆMð+Tð, �ð-Tð. �ð/Tð0 �^ð1Tð2 �ð3Tð4 �ð5Tð6 �ð7Tð8 �ð9Tð: �=ð;Tð< �mð=Tð> �-ð?Tð@ �.ðATðB ˆ{ðCTðD �/òETðF �OðGTðH �]ðITðJ �\ðKTðL �\ðMTðN �]ðOTðP �-ðQTðR �ðSTðT �=ðUTðV ˆðWTðX ˆðYTðZ �.ð[Tð\ �ð]Tð^ �?ð_Tð` �=ðaTðb ˆ}ðcTðd �ðeTðf �/ògTðh ˆMðiTðj �ðkTðl ˆOðmTðn ˆ[ðoTðp �>ðqTðr ˆOðsTðt �ðuTðv ˆðwTðx �ðyTðz ˆlð{Tð| ˆ_ð}Tð~ ˆ_ðTð@ �ðATðB �_ðCTðD �ðETðF �OðGTðH �òITðJ �/ðKTðL �ðMTðN ˜OðOTðP �ðQTðR �/ðSTðT �ðUTðV �ðWTðX �?ðYTðZ �^ð[Tð\ �Oð]Tð^ �oð_Tð` �oðaTðb �oðcTðd �?ðeTðf ˆKðgTðh �ðiTðj ˆ_òkTðl ˆ}ðmTðn ˆkðoTðp ˜ðqTðr �+ðsTðt �NðuTðv �OðwTðx �nðyTðz �ð{Tð| ˜ð}Tð~ �~ðTð@ �~ðATðB �MðCTðD �ðETðF �ðGTðH �ðITðJ �?ðKTðL ˆKòMTñN ‰ðOTñP ‰]ðQTñR ‘ðSTñT ‰mðUTñV ‘ðWTñX ‰oðYTñZ ‘_ð[Tñ\ ‘ð]Tñ^ ‘_ð_Tñ` ‘_ðaTñb ‘/ðcTñd ‘ðeTñf ‰NðgTñh ‰OðiTñj ‰OðkTñl ‘/ðmTñn ‰mòoTñp 
‰;ðqTñr ‘ðsTñt ‘ðuTñv ‘=ðwTñx ‰oðyTñz ‘.ð{Tñ| ‘ð}Tñ~ ‘ðTñ@ ‰mðATñB ‰oðCTñD ‰ðETñF ‘ðGTñH ‘ðITñJ ‘ðKTñL ‰OðMTñN ‘=ðOTñP ‘ñQTñR ÙÙÙÙÙÙÙÙ!ÙÙ!ógT€	ðp 49Ø/4Ø5:Ø38Ø9>Ø38Ø05Ø#õONðf ØØØØØØØØØØØòÐ ö $3rP   