
    sOi	                     p    d dl Z d dlmZ d dlmZmZ  G d de      Zdee   dee   fdZ	d	eez  defd
Z
y)    N)Path)	BaseModelFieldc                   R    e Zd ZU eed<    ed      Zed    dz  ed<   dee   fdZy)	FieldPathcurrentN)defaulttailreturnc                 T    ddt         dt        dt        t           ffd |       S )z
        >>> FieldPath(current='a', tail=[FieldPath(current='b', tail=[FieldPath(current='c'), FieldPath(current='d')])]).as_str_list()
        ['a.b.c', 'a.b.d']
        pathprefixr   c                     || j                   z   }| j                  s|gS g }| j                  D ]  }|j                   ||dz                 |S )N.)r   r
   extend)r   r   current_pathpathssub_pathcollect_pathss        `/volume1/homes/robertsu/coba/app/.venv/lib/python3.12/site-packages/qdrant_client/embed/utils.pyr   z,FieldPath.as_str_list.<locals>.collect_paths   sP    !DLL0L99$~% $		HLLx9K!LM !*    ) )r   strlist)selfr   s    @r   as_str_listzFieldPath.as_str_list   s.    		 	3 	S	 	 T""r   )	__name__
__module____qualname__r   __annotations__r   r
   r   r    r   r   r   r      s0    L%*4%8D${
d
"8#T#Y #r   r   r   r   c                    t        |       }d}g }|D ]  }|j                  d      }|d   }||k7  r|j                  t        |             |}|d   }|dd D ]w  }|j                  g |_        d}	|j                  D ]  }
|
j
                  |k(  s|
}d}	 n |	rAt        |      }|j                  J |j                  j                  |       |}y  |S )	zConvert string paths into FieldPath objects

    Paths which share the same root are grouped together.

    Args:
        paths: List[str]: List of str paths containing "." as separator

    Returns:
        List[FieldPath]: List of FieldPath objects
    Nr   r   )r      FT)sortedsplitappendr   r
   r   )r   sorted_paths	prev_rootconverted_pathsr   partsrootr   partfoundr
   new_tails               r   convert_pathsr0       s     %=LIO

3Qx9""9T#:;I!"%!"ID||#!E<<4'"G E	 %
 $T2||///##H-"  * r   	file_pathc                    t        |       }|j                         st        d| d      t        |d      5 }|j	                         }t        j                  |      j                  d      cddd       S # 1 sw Y   yxY w)z/Convert a file path to a base64 encoded string.z	The file z does not exist.rbzutf-8N)r   existsFileNotFoundErroropenreadbase64	b64encodedecode)r1   r   filefile_contents       r   read_base64r=   F   se    	?D;;=)D61A BCC	dD	Tyy{-44W= 
		s   4A55A>)r8   pathlibr   pydanticr   r   r   r   r   r0   r=   r!   r   r   <module>r@      sM      %#	 #2#c #tI #L>3: ># >r   