�
J�gy_ � � � d Z dZdZdZddlZddlZddlZddlZddlZddl m
Z
ddlmZ dd l
mZ d
� Zd� Z G d� d
� � Z G d� de� � ZdS )z PDF Template Helpers for fpdf.pyz%Mariano Reingart <reingart@gmail.com>z#Copyright (C) 2010 Mariano ReingartzLGPL 3.0� N� )�get_stack_level)�
FPDFException)�FPDFc �$ � | dz | dz dz | dz fS )Ni � � )�cols �]/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/fpdf/template.py�_rgbr s � ��5�L�C�3�J��,��c� �:�:� c � � t | � � \ }}}|dk r|dk r|dk s|dk r |dz d�d�S |dz d�d|dz d�d|dz d�d�S )Nr ������� z.3fz g� z rg)r )r
�r�g�bs r �_rgb_as_strr s~ � ��3�i�i�G�A�q�!� �Q���1��6�6�a�1�f�f��b����c�'�!�!�!�!�!��#�g�:�:�:�A��G�:�:�:�!�c�'�:�:�:�:�:r
c � � e Zd ZdZd/d�Zd� Zed� � � Zed� � � Zd0de j
d efd
�Z d1de j
d
eded efd�Z
d� ZeZd� Zd� Zd� Zddddddddddddddddd�d�Zdddddddd�d�Zddddddddd�d �Zddddddddd�d!�Zdddddd"�d#�Zdddddd$d%ddd&� d'�Zddddd(ddddddd)�d*�Zdddddddddddddd+�
d,�Zd2d.�ZdS )3�FlexTemplatez�
A flexible templating class.
Allows to apply one or several template definitions to any page of
a document in any combination.
Nc � � t |t � � st d� � �|| _ d| _ |r| � |� � | j | j | j | j | j
| j | j | j
d�| _ i | _ dS )a=
Arguments: pdf (fpdf.FPDF() instance): All content will be added to this object.
elements (list of dicts): A template definition in a list of dicts.
If you omit this, then you need to call either load_elements()
or parse_csv() before doing anything else.
z('pdf' must be an instance of fpdf.FPDF()N)�T�L�I�B�E�BC�C39�W)�
isinstancer � TypeError�pdf�
splitting_pdf�
load_elements�_text�_line�_image�_rect�_ellipse�_barcode�_code39�_write�handlers�texts)�selfr# �elementss r �__init__zFlexTemplate.__init__! s� � � �#�t�$�$� H��F�G�G�G����!���� )����x�(�(�(������������-��<���
�
��
� ��
�
�
r
c
� � i dt t d� � f�dt t d� � f�dt t f�dt t f�dt t f�dt t f�dt t d� � f�d t t f�d
t �dt �dt �d
t �dt �dt t d� � f�dt t d� � f�dt �dt
t d� � f�t t ft t d� � fd��}|| _ g | _ |D �]�}d|vrd|d<