+
    4O|j¨  ã                  ó  a € 0 t $ R t^ RIHt ^ RIHtHtHtHtH	t	 ^ RI
HtHt ^ RIHtHt ^ RIHt RR R llt ! R R	]]]3,          4      t ! R
 R]4      t]P,                  ! ]R7      tR]R&   ]P,                  ! ]R7      tR]R&   R# )a  Tools for representing raw BSON documents.

Inserting and Retrieving RawBSONDocuments
=========================================

Example: Moving a document between different databases/collections

.. doctest::

  >>> import bson
  >>> from pymongo import MongoClient
  >>> from bson.raw_bson import RawBSONDocument
  >>> client = MongoClient(document_class=RawBSONDocument)
  >>> client.drop_database("db")
  >>> client.drop_database("replica_db")
  >>> db = client.db
  >>> result = db.test.insert_many(
  ...     [{"_id": 1, "a": 1}, {"_id": 2, "b": 1}, {"_id": 3, "c": 1}, {"_id": 4, "d": 1}]
  ... )
  >>> replica_db = client.replica_db
  >>> for doc in db.test.find():
  ...     print(f"raw document: {doc.raw}")
  ...     print(f"decoded document: {bson.decode(doc.raw)}")
  ...     result = replica_db.test.insert_one(doc)
  ...
  raw document: b'...'
  decoded document: {'_id': 1, 'a': 1}
  raw document: b'...'
  decoded document: {'_id': 2, 'b': 1}
  raw document: b'...'
  decoded document: {'_id': 3, 'c': 1}
  raw document: b'...'
  decoded document: {'_id': 4, 'd': 1}

For use cases like moving documents across different databases or writing binary
blobs to disk, using raw BSON documents provides better speed and avoids the
overhead of decoding or encoding BSON.
)Úannotations)ÚAnyÚ	ItemsViewÚIteratorÚMappingÚOptional)Ú_get_object_sizeÚ_raw_to_dict)Ú_RAW_BSON_DOCUMENT_MARKERÚCodecOptions)ÚDEFAULT_CODEC_OPTIONSc               ó(   € V ^8„  d   QhRRRRRRRR/# )	é   Ú
bson_bytesúbytes | memoryviewÚcodec_optionsúCodecOptions[RawBSONDocument]Ú	raw_arrayÚboolÚreturnzdict[str, Any]© )Úformats   "ÚFC:\Users\alokc\chatbot\backend\venv\Lib\site-packages\bson/raw_bson.pyÚ__annotate__r   >   s6   € ÷ dñ dØ"ðdà0ðdð ðdð ñ	dó    c           	     óD   € \        V ^\        V 4      ^,
          V/ VR7      # )a  Inflates the top level fields of a BSON document.

:param bson_bytes: the BSON bytes that compose this document
:param codec_options: An instance of
    :class:`~bson.codec_options.CodecOptions` whose ``document_class``
    must be :class:`RawBSONDocument`.
©r   )r	   Úlen)r   r   r   s   &&&r   Ú_inflate_bsonr   >   s#   € ô ˜
 A¤s¨:£¸Õ':¸MÈ2ÐYbÔcÐcr   c                  óÈ   € ] tR t^Mt$ RtRt]tR]R&   RR R llt	]
R R l4       tR	 R
 lt]
R R l4       t]R R l4       tR R ltR R ltR R ltR R ltR R ltRtR# )ÚRawBSONDocumentzÈRepresentation for a MongoDB document that provides access to the raw
BSON bytes that compose it.

Only when a field is accessed or modified within the document does
RawBSONDocument decode its bytes.
r   Ú_RawBSONDocument__codec_optionsNc               ó$   € V ^8„  d   QhRRRRRR/# )r   r   r   r   z'Optional[CodecOptions[RawBSONDocument]]r   ÚNoner   )r   s   "r   r   ÚRawBSONDocument.__annotate__Y   s(   € ÷ 29ñ 29à&ð29ð ?ð29ð 
ñ	29r   c                óÞ   € Wn         RV n        Vf   \        pM8\        VP                  \
        4      '       g   \        RVP                   24      hW n        \        V^ \        V4      4       R# )aS  Create a new :class:`RawBSONDocument`

:class:`RawBSONDocument` is a representation of a BSON document that
provides access to the underlying raw BSON bytes. Only when a field is
accessed or modified within the document does RawBSONDocument decode
its bytes.

:class:`RawBSONDocument` implements the ``Mapping`` abstract base
class from the standard library so it can be used like a read-only
``dict``::

    >>> from bson import encode
    >>> raw_doc = RawBSONDocument(encode({'_id': 'my_doc'}))
    >>> raw_doc.raw
    b'...'
    >>> raw_doc['_id']
    'my_doc'

:param bson_bytes: the BSON bytes that compose this document
:param codec_options: An instance of
    :class:`~bson.codec_options.CodecOptions` whose ``document_class``
    must be :class:`RawBSONDocument`. The default is
    :attr:`DEFAULT_RAW_BSON_OPTIONS`.

.. versionchanged:: 3.8
  :class:`RawBSONDocument` now validates that the ``bson_bytes``
  passed in represent a single bson document.

.. versionchanged:: 3.5
  If a :class:`~bson.codec_options.CodecOptions` is passed in, its
  `document_class` must be :class:`RawBSONDocument`.
Nz<RawBSONDocument cannot use CodecOptions with document class )
Ú_RawBSONDocument__rawÚ_RawBSONDocument__inflated_docÚDEFAULT_RAW_BSON_OPTIONSÚ
issubclassÚdocument_classr    Ú	TypeErrorr!   r   r   )Úselfr   r   s   &&&r   Ú__init__ÚRawBSONDocument.__init__Y   sm   € ðJ  Œ
Ø;?ˆÔð Ò Ü4‰MÜ˜M×8Ñ8¼/×JÒJÜðØ&×5Ñ5Ð6ð8óð ð  -Ôä˜ Q¬¨J«Ö8r   c               ó   € V ^8„  d   QhRR/# )r   r   r   r   )r   s   "r   r   r$   Ž   s   € ÷ ñ Ð'ñ r   c                ó   € V P                   # )z+The raw BSON bytes composing this document.)r&   ©r,   s   &r   ÚrawÚRawBSONDocument.raw�   s   € ð �z‰zÐr   c               ó   € V ^8„  d   QhRR/# )r   r   zItemsView[str, Any]r   )r   s   "r   r   r$   ’   s   € ÷ 'ñ 'Ð*ñ 'r   c                ó6   € V P                   P                  4       # )z4Lazily decode and iterate elements in this document.)Ú_RawBSONDocument__inflatedÚitemsr1   s   &r   r7   ÚRawBSONDocument.items’   s   € à�‰×$Ñ$Ó&Ð&r   c               ó   € V ^8„  d   QhRR/# )r   r   úMapping[str, Any]r   )r   s   "r   r   r$   —   s   € ÷ #ñ #Ð-ñ #r   c                	óŒ   € V P                   f,   V P                  V P                  V P                  4      V n         V P                   # ©N)r'   r   r&   r!   r1   s   &r   Ú
__inflatedÚRawBSONDocument.__inflated–   s;   € à×ÑÒ&ð #'×"4Ñ"4°T·Z±ZÀ×AUÑAUÓ"VˆDÔØ×"Ñ"Ð"r   c               ó$   € V ^8„  d   QhRRRRRR/# ©r   r   r   r   r   r   r:   r   )r   s   "r   r   r$   Ÿ   s$   € ÷ 8ñ 8Ø&ð8Ø7Tð8à	ñ8r   c                	ó   € \        W4      # r<   ©r   ©r   r   s   &&r   r   ÚRawBSONDocument._inflate_bsonž   s   € ô ˜ZÓ7Ð7r   c               ó    € V ^8„  d   QhRRRR/# )r   ÚitemÚstrr   r   r   )r   s   "r   r   r$   ¤   s   € ÷ %ñ % ð %¨ñ %r   c                	ó(   € V P                   V,          # r<   )r6   )r,   rF   s   &&r   Ú__getitem__ÚRawBSONDocument.__getitem__¤   s   € Ø�‰˜tÕ$Ð$r   c               ó   € V ^8„  d   QhRR/# )r   r   zIterator[str]r   )r   s   "r   r   r$   §   s   € ÷ %ñ %˜-ñ %r   c                	ó,   € \        V P                  4      # r<   )Úiterr6   r1   s   &r   Ú__iter__ÚRawBSONDocument.__iter__§   s   € Ü�D—O‘OÓ$Ð$r   c               ó   € V ^8„  d   QhRR/# )r   r   Úintr   )r   s   "r   r   r$   ª   s   € ÷ $ñ $˜ñ $r   c                	ó,   € \        V P                  4      # r<   )r   r6   r1   s   &r   Ú__len__ÚRawBSONDocument.__len__ª   s   € Ü�4—?‘?Ó#Ð#r   c               ó    € V ^8„  d   QhRRRR/# )r   Úotherr   r   r   r   )r   s   "r   r   r$   ­   s   € ÷ ñ ˜Cð  Dñ r   c                	ól   € \        V\        4      '       d   V P                  VP                  8H  # \        # r<   )Ú
isinstancer    r&   r2   ÚNotImplemented)r,   rV   s   &&r   Ú__eq__ÚRawBSONDocument.__eq__­   s(   € Ü�eœ_×-Ò-Ø—:‘: §¡Ñ*Ð*ÜÐr   c               ó   € V ^8„  d   QhRR/# )r   r   rG   r   )r   s   "r   r   r$   ²   s   € ÷ bñ b˜#ñ br   c                	ól   € V P                   P                   R V P                  : RV P                  : R2# )Ú(z, codec_options=Ú))Ú	__class__Ú__name__r2   r!   r1   s   &r   Ú__repr__ÚRawBSONDocument.__repr__²   s3   € Ø—.‘.×)Ñ)Ð*¨!¨D¯H©H©<Ð7GÈ×H\ÑH\ÑG_Ð_`ÐaÐar   )Ú__codec_optionsÚ__inflated_docÚ__raw)rf   re   rd   r<   )ra   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú	__slots__r
   Ú_type_markerÚ__annotations__r-   Úpropertyr2   r7   r6   Ústaticmethodr   rI   rN   rS   rZ   rb   Ú__static_attributes__r   r   r   r    r    M   s€   ‡ ñð ?€IØ,€LØ2Ó2÷29ðh ôó ðõ'ð ô#ó ð#ð ô8ó ð8õ
%õ%õ$õ÷
bñ br   r    c                  ó0   € ] tR t^¶tRt]R R l4       tRtR# )Ú_RawArrayBSONDocumentzKA RawBSONDocument that only expands sub-documents and arrays when accessed.c               ó$   € V ^8„  d   QhRRRRRR/# r@   r   )r   s   "r   r   Ú"_RawArrayBSONDocument.__annotate__º   s)   € ÷ Hñ HØ&ðHØ7TðHà	ñHr   c                	ó   € \        WR R7      # )Tr   rB   rC   s   &&r   r   Ú#_RawArrayBSONDocument._inflate_bson¹   s   € ô ˜ZÀ$ÔGÐGr   r   N)ra   rg   rh   ri   rj   ro   r   rp   r   r   r   rr   rr   ¶   s   † ÙUàôHó ôHr   rr   )r*   r   r(   z#CodecOptions[_RawArrayBSONDocument]Ú_RAW_ARRAY_BSON_OPTIONSN)F)Ú__conditional_annotations__rj   Ú
__future__r   Útypingr   r   r   r   r   Úbsonr   r	   Úbson.codec_optionsr
   r   r   ÚDEFAULTr   rG   r    rr   Úwith_optionsr(   rm   rw   )rx   s   @r   Ú<module>r      s“   øðô%õL #ç >Õ >ç /ß FÝ ?÷dôfb�g˜c 3˜hÕ'ô fbôRH˜Oô Hð ;B×:NÒ:NØ"ô;Ð Ð7ó ð @G×?SÒ?SØ(ô@Ð Ð<ó ñr   