
    Mip                       S r SSKJr  SSKrSSKJrJrJr  SSKJ	r	  SSK
JrJr  SSKJrJrJr  SSKJr  SS	KJr  SS
KJr  SSKJr  \" 5       \" \R4                  5      \	    S           SS jj5       5       5       rg)a  Provides `partition_ndjson()`.

Note this does not partition arbitrary NDJSON. Its only use-case is to "rehydrate" unstructured
document elements serialized to JSON, essentially the same function as `elements_from_json()`, but
this allows a document of already-partitioned elements to be combined transparently with other
documents in a partitioning run. It also allows multiple (low-cost) chunking runs to be performed on
a document while only incurring partitioning cost once.
    )annotationsN)IOAnyOptional)add_chunking_strategy)Elementprocess_metadata)FileTypeadd_metadata_with_filetypeis_ndjson_processable)loads)exactly_one)get_last_modified_date)elements_from_dictsc                   Ub$  UR                  5       S:X  a  U(       d	  U (       d  / $ [        XUS9  U (       a  [        U 5      OSnSnU b$  [        U SS9 nUR	                  5       nSSS5        OZUbI  UR	                  5       n[        U[        5      (       a  UOUR                  5       nUR                  S5        OUb  [        U5      n[        US9(       d  [        S5      e [        U5      n	[        U	5      n
[        U	5      S:  a  [        U
5      S:X  a  [        S	5      eU
 H  nU=(       d    UUR                   l        M     U
$ ! , (       d  f       N= f! [        R                   a    [        S
5      ef = f)aV  Partitions serialized Unstructured output into its constituent elements.

Parameters
----------
filename
    A string defining the target filename path.
file
    A file-like object as bytes --> open(filename, "rb").
text
    The string representation of the .json document.
metadata_last_modified
    The last modified date for the document.
N )filenamefiletextutf8)encodingr   )	file_textzLNDJSON cannot be partitioned. Schema does not match the Unstructured schema.zJJSON cannot be partitioned. Schema does not match the Unstructured schema.zNot a valid ndjson)stripr   r   openread
isinstancestrdecodeseekr   
ValueErrorndjson_loadsr   lenjsonJSONDecodeErrormetadatalast_modified)r   r   r   metadata_last_modifiedkwargsr&   r   ffile_contentelement_dictselementselements               w/var/www/eduai.edurigo.com/storigo/production/storigo_env/lib/python3.13/site-packages/unstructured/partition/ndjson.pypartition_ndjsonr/      sV   . DJJLB.tH	488@*84dMI(V,I -, 
	yy{$.|S$A$AL|GZGZG\			!		I	 95Z
 	
	/$Y/&}5}!c(mq&8\  )?)P=&  O= -,0  /-../s   E#?E 
E E8)NNNN)r   Optional[str]r   zOptional[IO[bytes]]r   r0   r'   r0   r(   r   returnzlist[Element])__doc__
__future__r   r#   typingr   r   r   unstructured.chunkingr   unstructured.documents.elementsr   r	    unstructured.file_utils.filetyper
   r   r   unstructured.file_utils.ndjsonr   r!   $unstructured.partition.common.commonr   &unstructured.partition.common.metadatar   unstructured.staging.baser   NDJSONr/        r.   <module>r?      s    #  $ $ 7 E 
 A < I 9 HOO," $,0	::
: : *	:
 : :  - :r>   