
    +#hl                     l    d dl mZmZ deeeef   defdZdeeeef   defdZdeeef   dee   fdZy)	    )OptionalUnionpassagesreturnc                    t        | t              r| S t        |       t        t        fv sJ t        |       dk(  ryt        |       dk(  r	d| d    dS dj                  t        |       D cg c]  \  }}d|dz    d| d c}}      S c c}}w )	GFormats the given one or more passages into a single structured string.r   N/A      «   »
[u   ] «
isinstancestrtypelisttuplelenjoin	enumerate)r   idxtxts      P/var/www/html/sandstorm/venv/lib/python3.12/site-packages/dsp/templates/utils.pypassages2textr      s    (C >dE]***
8}
8}HQK=##99Yx=PQc#a%SE,QRRQs   +B	
c                 2   t        | t              r| S t        |       t        t        fv sJ d }t        |       dk(  ryt        |       dk(  r || d         S dj                  t        |       D cg c]  \  }}d|dz    d ||        c}}      S c c}}w )r   c                     	 | j                  dd      \  }}d|j                          d|j                          dS # t        $ r Y nw xY wd|  dS )N|r
   zTitle: u    | Snippet: «r   r   )splitstrip	Exception)psgtitlesnippets      r   psg2textz!passages2textV2.<locals>.psg2text   s_    	 YYsA.NE7U[[]O>'--/9J"MM 		 C5|s   9< 	AAr   r	   r
   r   r   z] r   )r   r%   r   r   s       r   passages2textV2r&      s    (C >dE]*** 8}
8}$$999XCVWxsC#a%8C=/2WXXWs   0B
answersc                     t        | t              rDt        |       dk\  rt        | d         j	                         S t        |       dk(  rt        d      yt        | t              r| S t        dt        |              )a>  Parses the given answers and returns the appropriate answer string.

    Args:
        answers (Union[str, list]): The answers to parse.

    Raises:
        ValueError: when instance is of type list and has no answers
        ValueError: when is not of type list or str

    Returns:
        _type_: Optiona[str]
    r
   r   zNo answers foundz Unable to parse answers of type N)r   r   r   r   r    
ValueErrorr   )r'   s    r   format_answersr*   -   st     '4 w<1wqz?((**w<1/00 	GS	!;DM?KLL    N)	typingr   r   r   r   r   r   r&   r*    r+   r   <module>r.      so    "SE#tU"23 S S YeCu$45 Y# Y2ME#t), M# Mr+   