+
    8i                      a  0 t $ R t^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
t
^ RIHt ^ RIHt ^ RIHt ^ RIHtHtHtHtHtHtHtHtHtHtHtHtH t H!t!H"t"H#t#H$t$H%t% ^ RI&H't'H(t(H)t)H*t*H+t+H,t,H-t-H.t. ^ RI/H0t0 ^ R	I1H2t2H3t3H4t4H5t5 ^ R
I6H7t7H8t8H9t9H:t:H;t; ^ RI<H=t= ^ RI>H?t? ^ RI@HAtAHBtBHCtC ^ RIDHEtE ^ RIFHGtG ^ RIHHItI ^ RIJHKtK ^ RILHMtM ^ RINHOtOHPtP ^ RIQHRtR ^ RISHTtT ]'       d   ^ RIUHVtV ^ RIWHXtXHYtY  ^ RIZH[t[ Rt\. RNRNRNRNRNR NR!NR"NR#NR$NR%NR&NR'NR(NR)NR*NR+NR,NR-NR.NR/NR0NR1NR2NR3NR4NR5NR6NR7NR8NR9NR:NR;NR<NR=NR>NR?NR@NRANRBNRCNRDNRENRFNRGNRHNRINRJNRKNRLNRMNRNNRONRPNRQNRRNRSNRTNRUNRVNt^RWt_RXt`RYtaRZtbR[tcR\tdR]teR^tfR_tgR`thRatiRbtjRctkRdtlRetmRftnRgtoRhtpRitqRjtrRkts]P                  ! Rl4      P                  tv]P                  ! Rm4      P                  tx]P                  ! Rm4      P                  ty]P                  ! Rn4      P                  tz]P                  ! Ro4      P                  t{]P                  ! Rp4      P                  t|Rq Rr lt}Rs Rt lt~Ru Rv ltRw Rx ltRy Rz ltR{ R| ltR} R~ ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R lt/ ]! ]_4      ]b]! ]`4      ]b]! ]a4      ]b]! ]b4      ]b]! ]c4      ]b]! ]d4      R b]! ]e4      ]b]! ]f4      ]b]! ]g4      ]b]! ]h4      R b]! ]i4      ]b]! ]j4      ]b]! ]k4      ]b]! ]l4      ]b]! ]m4      ]b]! ]n4      ]b]! ]o4      ]b]! ]p4      ]]! ]q4      ]]! ]r4      R ]! ]s4      R /CtR]R&   ]\'       d   ERR R lltM	ERR R llt]"! R]]]3,          R7      tERR R lltERR R lltR R lt]\'       d   ][EP2                  t]P                  ! Rl4      EP4                  t]P                  ! Rm4      EP4                  t]P                  ! Rn4      EP4                  t]P                  ! Ro4      EP4                  t]P                  ! Rp4      EP4                  t];QJ d    . R ]! R4       4       F  NK  	  5M! R ]! R4       4       4      tR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R lt/ ]]b]]b]P                  ]b]9]b]]b]]b]]b]]b]]b]]b]! R4      ]b]
EP                  ]b]-]b]E]b]0]b]=]b]G]b]I]]K]]M]]O]]P]]R]]?]]P6                  ]/Ct/ t] F+  t]! ]R4      '       g   K  ]],          ]]EP                  &   K-  	  ];QJ d    . R ] 4       F  NK  	  5M! R ] 4       4      tERR R lltR R ltERR R llt]\'       d   ][EP                  t]! R4      tR]23R R llt]%ERR R ll4       t]%R R l4       tERR R lltR R lt]\'       d   ][EP                  t]%ERR R ll4       t]%R R l4       tERR R lltR R ltR R lt]\'       d   ][EP                  tR R ltR R lt]%ERER  ER ll4       t]%ER ER l4       tERER ER llt]%ERER ER ll4       t]%ER ER	 l4       tERER
 ER lltER ER lt ! ER RS]4      tER ER ltER ER lt]! ]ER4      '       d   ]EP                  ! ]ER7       R# R#   ]] d    Rt\ EL{i ; i(  a  BSON (Binary JSON) encoding and decoding.

The mapping from Python types to BSON types is as follows:

=======================================  =============  ===================
Python Type                              BSON Type      Supported Direction
=======================================  =============  ===================
None                                     null           both
bool                                     boolean        both
int [#int]_                              int32 / int64  py -> bson
:class:`bson.int64.Int64`                int64          both
float                                    number (real)  both
str                                      string         both
list                                     array          both
dict                                     object         both
:class:`~bson.son.SON`                   object         both
:py:class:`~collections.abc.Mapping`     object         py -> bson
:class:`~bson.raw_bson.RawBSONDocument`  object         both [#raw]_
datetime.datetime [#dt]_ [#dt2]_         UTC datetime   both
:class:`~bson.datetime_ms.DatetimeMS`    UTC datetime   both [#dt3]_
:class:`~bson.regex.Regex`               regex          both
compiled re [#re]_                       regex          py -> bson
:class:`~bson.binary.Binary`             binary         both
:py:class:`uuid.UUID` [#uuid]_           binary         both
:class:`~bson.objectid.ObjectId`         oid            both
:class:`~bson.dbref.DBRef`               dbref          both
:class:`~bson.dbref.DBRef`               dbpointer      bson -> py
None                                     undefined      bson -> py
:class:`~bson.code.Code`                 code           both
str                                      symbol         bson -> py
bytes [#bytes]_                          binary         both
:class:`~bson.timestamp.Timestamp`       timestamp      both
:class:`~bson.decimal128.Decimal128`     decimal128     both
:class:`~bson.min_key.MinKey`            min key        both
:class:`~bson.max_key.MaxKey`            max key        both
=======================================  =============  ===================

.. [#int] A Python int will be saved as a BSON int32 or BSON int64 depending
   on its size. A BSON int32 will always decode to a Python int. A BSON
   int64 will always decode to a :class:`~bson.int64.Int64`.
.. [#raw] Decoding a bson object to :class:`~bson.raw_bson.RawBSONDocument` can be
   optionally configured via :attr:`~bson.codec_options.CodecOptions.document_class`.
.. [#dt] datetime.datetime instances are encoded with millisecond precision so
   the microsecond field is truncated.
.. [#dt2] all datetime.datetime instances are encoded as UTC. By default, they
   are decoded as *naive* but timezone aware datetimes are also supported.
   See `Dates and Times <https://www.mongodb.com/docs/languages/python/pymongo-driver/current/data-formats/dates-and-times/#dates-and-times>`_ for examples.
.. [#dt3] To enable decoding a bson UTC datetime to a :class:`~bson.datetime_ms.DatetimeMS`
   instance see `handling out of range datetimes <https://www.mongodb.com/docs/languages/python/pymongo-driver/current/data-formats/dates-and-times/#handling-out-of-range-datetimes>`_.
.. [#uuid] For :py:class:`uuid.UUID` encoding and decoding behavior see `<https://www.mongodb.com/docs/languages/python/pymongo-driver/current/data-formats/uuid/#universally-unique-ids--uuids->`_.
.. [#re] :class:`~bson.regex.Regex` instances and regular expression
   objects from ``re.compile()`` are both saved as BSON regular expressions.
   BSON regular expressions are decoded as :class:`~bson.regex.Regex`
   instances.
.. [#bytes] The bytes type is encoded as BSON binary with
   subtype 0. It will be decoded back to bytes.
)annotationsN)utf_8_decode)utf_8_encode)abc)IOTYPE_CHECKINGAnyBinaryIOCallable	GeneratorIteratorMappingMutableMappingNoReturnOptionalSequenceTupleTypeTypeVarUnioncastoverload)ALL_UUID_SUBTYPESCSHARP_LEGACYJAVA_LEGACYOLD_UUID_SUBTYPESTANDARDUUID_SUBTYPEBinaryUuidRepresentation)Code)DEFAULT_CODEC_OPTIONSCodecOptionsDatetimeConversion_raw_document_class)EPOCH_AWAREEPOCH_NAIVE
DatetimeMS_datetime_to_millis_millis_to_datetime)DBRef)
Decimal128)InvalidBSONInvalidDocumentInvalidStringData)Int64MaxKeyMinKeyObjectId)Regex)RE_TYPESON)	Timestamp)utcRawBSONDocument)_DocumentType_ReadableBuffer)_cbsonTFr   r   r   r   r   r   r   r   r    r!   r"   r*   r+   r,   r-   r.   r/   r1   r3   r5   r6   r7   r8   r9   r:   r%   r&   BSONNUMBSONSTRBSONOBJBSONARRBSONBINBSONUNDBSONOIDBSONBOOBSONDATBSONNULBSONRGXBSONREFBSONCODBSONSYMBSONCWSBSONINTBSONTIMBSONLONBSONDECBSONMINBSONMAXget_data_and_viewgen_list_nameencodedecode
decode_alldecode_iterdecode_file_iteris_validBSONhas_cr#   r'                              	   
                                 z<dz<iz<iBz<qz<IIc                    V ^8  d   QhRRRR/# )   datar   returnzTuple[Any, memoryview] )formats   "K/var/www/html/photoedit/myenv/lib/python3.14/site-packages/bson/__init__.py__annotate__r{      s        C  $:      c                    \        V \        \        34      '       d   V \        V 4      3# \        V 4      pVP	                  4       V3# N)
isinstancebytes	bytearray
memoryviewtobytes)rv   views   & rz   rU   rU      s?    $	*++Z%%%dD<<>4r|   c               $    V ^8  d   QhRRRRRR/# )ru   element_typeintelement_namestrrw   r   rx   )ry   s   "rz   r{   r{      s!      c   r|   c                f    \        RP                  \        V 4      P                  4       V4      4      h)zUnknown type helper.z\Detected unknown BSON type {!r} for fieldname '{}'. Are you using the latest driver version?)r,   ry   chrrW   )r   r   s   &&rz   _raise_unknown_typer      s/    
	//5vc,6G6N6N6PR^/_ r|   c               4    V ^8  d   QhRRRRRRRRRRRRR	R
/# )ru   rv   r   _viewpositionr   dummy0dummy1dummy2rw   Tuple[int, int]rx   )ry   s   "rz   r{   r{     sD     = =
==%(=25=?B=LO==r|   c                8    \        W4      ^ ,          V^,           3# )z"Decode a BSON int32 to python int.)_UNPACK_INT_FROMrv   r   r   r   r   r   s   &&&&&&rz   _get_intr     s     D+A.1<<r|   c          
     ,    V ^8  d   QhRRRRRRRRRR	/# )
ru   rv   r   r   r   r   optsCodecOptions[Any]rw   Tuple[str, int]rx   )ry   s   "rz   r{   r{     s8     b b b3 b# b=N bSb br|   c                x    V P                  RV4      p\        WV VP                  R4      ^ ,          V^,           3# )z'Decode a BSON 'C' string to python str.    T)index_utf_8_decodeunicode_decode_error_handler)rv   r   r   r   ends   &&&& rz   _get_c_stringr     s?    
**Wh
'Cs+T-N-NPTUVWXZ]`aZaaar|   c               4    V ^8  d   QhRRRRRRRRRRRRR	R
/# )ru   rv   r   r   r   r   r   r   r   rw   zTuple[float, int]rx   )ry   s   "rz   r{   r{     sD     ? ?
??%(?25??B?LO??r|   c                8    \        W4      ^ ,          V^,           3# )z%Decode a BSON double to python float.)_UNPACK_FLOAT_FROMr   s   &&&&&&rz   
_get_floatr     s     d-a0(Q,>>r|   c               4    V ^8  d   QhRRRRRRRRRRR	RR
R/# )ru   rv   r   r   r   r   obj_endr   r   dummyrw   r   rx   )ry   s   "rz   r{   r{     sM     b b
bb$'b25b=NbWZbbr|   c                   \        W4      ^ ,          pV^,          pV^8  g   W2,
          V8  d   \        R4      hW&,           ^,
          pW,          ^ 8w  d   \        R4      h\        WV VP                  R4      ^ ,          V^,           3# )z#Decode a BSON string to python str.zinvalid string lengthzinvalid end of stringT)r   r,   r   r   )rv   r   r   r   r   r   lengthr   s   &&&&&&  rz   _get_stringr     s     d-a0FMHzW'&0122

a
CyA~122s+T-N-NPTUVWXZ]`aZaaar|   c               (    V ^8  d   QhRRRRRRRR/# )ru   rv   r   r   r   r   rw   r   rx   )ry   s   "rz   r{   r{   (  s(      3 #   r|   c                2    \        W4      ^ ,          pY,           ^,
          pYR8  d   \        R4      hY,          ^ 8w  d   \        R4      hT^ 8X  d   Y28w  d   \        R4      hY53#   \        P                   d   p\        \	        T4      4      RhRp?ii ; i)z+Validate and return a BSON document's size.Nzinvalid object lengthbad eoo)r   structerrorr,   r   )rv   r   r   obj_sizeexcr   s   &&&   rz   _get_object_sizer   (  s    .#D3A6 

!C
~122yA~)$$1},122= << .#c(#-.s   A' 'B<BBc               4    V ^8  d   QhRRRRRRRRRRR	RR
R/# )ru   rv   r   r   r   r   r   r   r   r   rw   Tuple[Any, int]rx   )ry   s   "rz   r{   r{   9  sD      
$'25=NWZr|   c                   \        WV4      w  rg\        VP                  4      '       d$   VP                  WV^,            V4      W&,           3# \        WV^,           Wt4      pW&,          p\	        VP                  R4      \        4      '       dw   RV9   dp   \	        VP                  R4      \        \        R4      34      '       d@   \        VP                  R4      VP                  RR4      VP                  RR4      V4      V3# W3# )zEDecode a BSON subdocument to opts.document_class or bson.dbref.DBRef.z$refz$idz$dbN)
r   r$   document_class_elements_to_dictr   getr   typer*   pop)	rv   r   r   r   r   r   r   r   objs	   &&&&&&   rz   _get_objectr   9  s     %TW=MH4..//##DC!G$<dCXEXYY
D1c
@CH 	3776?C((SLswwu~T$Z'899cggfoswwud';SWWUD=QSVWYabb=r|   c               4    V ^8  d   QhRRRRRRRRRRR	R
RR/# )ru   rv   r   r   r   r   r   r   r   r   r   rw   r   rx   )ry   s   "rz   r{   r{   N  sD     '  ' 
' ' $'' 25' =N' ^a' ' r|   c                R   \        W4      ^ ,          pW&,           ^,
          pW,          ^ 8w  d   \        R4      hV^,          pV^,          p. pVP                  p	V P                  p
\        pVP
                  P                  pW'8  dd   W,          pV
! RV4      ^,           p W,          ! WW#WE4      w  rV'       d'   VP                  \        X4      4      pVe	   V! V4      pV	! X4       Ki  W'^,           8w  d   \        R4      hW^,           3#   \         d    \        Y4        Lri ; i)z#Decode a BSON array to python list.r   r   zbad array length)r   r,   appendr   _ELEMENT_GETTERtype_registry_decoder_mapKeyErrorr   r   r   )rv   r   r   r   r   r   sizer   resultr   r   getterdecoder_mapr   valuecustom_decoders   &&&&&&          rz   
_get_arrayr   N  s    D+A.D
/A
CyA~)$$MH1HCF ]]FJJEF$$11K
.~(+a/	<$2HtOE (__T%[9N)&u-u7,--a<  	<;	<s   !D D&%D&c               4    V ^8  d   QhRRRRRRRRRRR	RR
R/# )ru   rv   r   r   r   r   r   r   r   r   rw   z$Tuple[Union[Binary, uuid.UUID], int]rx   )ry   s   "rz   r{   r{   x  sD     " "
""%("36">O"Y\")"r|   c                   \        W4      w  rgV^,          pV^8X  d6   \        W4      ^ ,          pV^,          pW^,
          8w  d   \        R4      hTpW&,           p	V^ 8  g   W8  d   \        R4      hV\        9   dr   VP                  p
\        WV	 V4      pV
\        P                  8X  g-   V\        8X  d   V
\        8w  g   V\        8X  d   V
\        8X  d   W3# VP                  V
4      V	3# V^ 8X  d   WV	 pW3# \        WV	 V4      pW3# )z:Decode a BSON binary to bson.binary.Binary or python UUID.z,invalid binary (st 2) - lengths don't match!zbad binary object length)_UNPACK_LENGTH_SUBTYPE_FROMr   r,   r   uuid_representationr   r   UNSPECIFIEDr   r   r   as_uuid)rv   r   r   r   r   r   r   subtypelength2r   uuid_repbinary_valuer   s   &&&&&&       rz   _get_binaryr   x  s    2$AOFMH!|"4215Aqj LMM

CzS]455 ##++dC0':+777<'H,@++H0D$$##H-s22 !|c" : tS)73:r|   c               4    V ^8  d   QhRRRRRRRRRRRRR	R
/# )ru   rv   r   r   r   r   r   r   r   rw   zTuple[ObjectId, int]rx   )ry   s   "rz   r{   r{     sD     - -
--%(-25-?B-LO--r|   c                2    V^,           p\        WV 4      V3# )z1Decode a BSON ObjectId to bson.objectid.ObjectId.r4   rv   r   r   r   r   r   r   s   &&&&&& rz   _get_oidr     s"     R-CD#&',,r|   c               4    V ^8  d   QhRRRRRRRRRRRRR	R
/# )ru   rv   r   r   r   r   r   r   r   rw   zTuple[bool, int]rx   )ry   s   "rz   r{   r{     sM     
B 
B

B
B%(
B25
B?B
BLO
B
Br|   c                l    V^,           pWV pVR8X  d   RV3# VR8X  d   RV3# \        RV,          4      h)z.Decode a BSON true/false to python True/False.r   Fr_   Tzinvalid boolean value: %r)r,   )rv   r   r   r   r   r   r   boolean_bytes   &&&&&&  rz   _get_booleanr     sL     Q,C%Lwcz		 Sy
1L@
AAr|   c               4    V ^8  d   QhRRRRRRRRRRR	RR
R/# )ru   rv   r   r   r   r   r   r   r   r   rw   z0Tuple[Union[datetime.datetime, DatetimeMS], int]rx   )ry   s   "rz   r{   r{     sM     Y Y
YY%(Y25Y=NYX[Y5Yr|   c                L    \        \        W4      ^ ,          V4      V^,           3# )z3Decode a BSON datetime to python datetime.datetime.)r)   _UNPACK_LONG_FROM)rv   r   r   r   r   r   s   &&&&&&rz   	_get_dater     s&     0@CTJHWXLXXr|   c               4    V ^8  d   QhRRRRRRRRRRR	R
RR/# )ru   rv   r   r   r   r   r   r   r   r   r   rw   Tuple[Code, int]rx   )ry   s   "rz   r{   r{     sD        
  $' 25 =N ^a  r|   c                :    \        WW#WE4      w  rb\        V4      V3# )z%Decode a BSON code to bson.code.Code.)r   r    )rv   r   r   r   r   r   codes   &&&&&& rz   	_get_coder     s#     !XSND:xr|   c               4    V ^8  d   QhRRRRRRRRRRR	R
RR/# )ru   rv   r   r   r   r   _obj_endr   r   r   r   rw   r   rx   )ry   s   "rz   r{   r{     sD     	' 	'
	'	'$'	'36	'>O	'_b	'	'r|   c                    V\        W4      ^ ,          ,           p\        WV^,           WdV4      w  rr\        WW&WE4      w  rW&8w  d   \        R4      h\	        Wx4      V3# )z-Decode a BSON code_w_scope to bson.code.Code.z+scope outside of javascript code boundaries)r   r   r   r,   r    )	rv   r   r   r   r   r   code_endr   scopes	   &&&&&&   rz   _get_code_w_scoper     sa     *4:1==H X\8<XND!$h$UOEGHHh&&r|   c               4    V ^8  d   QhRRRRRRRRRRR	RR
R/# )ru   rv   r   r   r   r   r   r   r   r   rw   zTuple[Regex[Any], int]rx   )ry   s   "rz   r{   r{     sD      
$'14<MWZr|   c                V    \        WW$4      w  rb\        WW$4      w  rr\        Wg4      pW3# )zCDecode a BSON regex to bson.regex.Regex or a python pattern object.)r   r6   )	rv   r   r   r   r   r   pattern
bson_flagsbson_res	   &&&&&&   rz   
_get_regexr     s5     &d(AG(XDJG(Gr|   c               4    V ^8  d   QhRRRRRRRRRRR	R
RR/# )ru   rv   r   r   r   r   r   r   r   r   r   rw   zTuple[DBRef, int]rx   )ry   s   "rz   r{   r{     sD     , ,
,,$',25,=N,^a,,r|   c                X    \        WW#WE4      w  rb\        WW#WE4      w  rr\        Wg4      V3# )z7Decode (deprecated) BSON DBPointer to bson.dbref.DBRef.)r   r   r*   )rv   r   r   r   r   r   
collectionoids   &&&&&&  rz   _get_refr     s5     't8dYJTDOMC!8++r|   c               4    V ^8  d   QhRRRRRRRRRRRRR	R
/# )ru   rv   r   r   r   r   r   r   r   rw   zTuple[Timestamp, int]rx   )ry   s   "rz   r{   r{     sD     3 3
33%(3253?B3LO33r|   c                D    \        W4      w  rg\        Wv4      V^,           3# )z4Decode a BSON timestamp to bson.timestamp.Timestamp.)_UNPACK_TIMESTAMP_FROMr9   )rv   r   r   r   r   r   inc	timestamps   &&&&&&  rz   _get_timestampr     s$     ,D;NCY$hl22r|   c               4    V ^8  d   QhRRRRRRRRRRRRR	R
/# )ru   rv   r   r   r   r   r   r   r   rw   zTuple[Int64, int]rx   )ry   s   "rz   r{   r{     sM     E E
EE%(E25E?BELOEEr|   c                J    \        \        W4      ^ ,          4      V^,           3# )z(Decode a BSON int64 to bson.int64.Int64.)r/   r   r   s   &&&&&&rz   
_get_int64r    s#     "421561DDr|   c               4    V ^8  d   QhRRRRRRRRRRRRR	R
/# )ru   rv   r   r   r   r   r   r   r   rw   zTuple[Decimal128, int]rx   )ry   s   "rz   r{   r{     sD     8 8
88%(8258?B8LO88r|   c                H    V^,           p\         P                  ! WV 4      V3# )z7Decode a BSON decimal128 to bson.decimal128.Decimal128.)r+   from_bidr   s   &&&&&& rz   _get_decimal128r    s(     R-CtS12C77r|   c                
    R V3# r~   rx   uvwxyzs   &&&&&&rz   <lambda>r        D!9r|   c                
    R V3# r~   rx   r  s   &&&&&&rz   r  r    r  r|   c                    \        4       V3# r~   r2   r  s   &&&&&&rz   r  r    
    FHa=r|   c                    \        4       V3# r~   r0   r  s   &&&&&&rz   r  r    r  r|   z)dict[int, Callable[..., Tuple[Any, int]]]r   c               4    V ^8  d   QhRRRRRRRRRRR	R
RR/# ru   rv   r   r   r   r   r   r   r   	raw_arrayboolrw   Tuple[str, Any, int]rx   )ry   s   "rz   r{   r{     sN     
 


 
 	

  
 
 

r|   c           
     F    \        R \        P                  ! WW4V4      4      # )r  )r   r?   _element_to_dict)rv   r   r   r   r   r  s   &&&&&&rz   r  r    s&     "##DG9M
 	
r|   c               4    V ^8  d   QhRRRRRRRRRRR	R
RR/# r  rx   )ry   s   "rz   r{   r{   '  sN     - --- - 	-
  - - 
-r|   c                   W,          pV^,          p\        WW$4      w  rrV'       d@   V\        \        4      8X  d,   \        W\	        V 4      4      w  rWqW)^,            V	^,           3#  \
        V,          ! WW#WG4      w  rVP                  P                  '       d;   VP                  P                  P                  \        X
4      4      pVe	   V! V
4      p
VX
V3#   \         d    \        Yg4        Lsi ; i)z Decode a single key, value pair.)r   ordrC   r   lenr   r   r   r   r   r   r   )rv   r   r   r   r   r  r   r   _r   r   r   s   &&&&&&      rz   r  r  '  s     ~A!.t8!JW5%dc$i@FAhq!937BB	<-l;HtOE ***!//<<@@eMN)&u-UH,,  	<;	<s   (C C32C3_T)boundc               4    V ^8  d   QhRRRRRRRRRR	R
RRR	/# )ru   rv   r   r   r   r   r   zCodecOptions[RawBSONDocument]r   r!  r  r  rw   rx   )ry   s   "rz   r{   r{   H  sN      
  (	
   r|   c                V    \        V 4      w  r\        \        \        WWW4VR 7      4      # )r  )rU   r   r!  r   )rv   r   r   r   r   r  r   s   &&&&&& rz   _raw_to_dictr&  H  s/     #4(JD
d(TU^_ r|   c               8    V ^8  d   QhRRRRRRRRRRR	RR
RRR/# )ru   rv   r   r   r   r   r   r   r   r   r  r  rw   rx   )ry   s   "rz   r{   r{   V  sX      

  	
    	r|   c           	         Vf   VP                  4       pV^,
          pW'8  d   \        WW#WFR7      w  rpWV&   K  W#8w  d   \        R4      hV# )z#Decode a BSON document into result.r%  bad object or element length)r   r  r,   )
rv   r   r   r   r   r   r  r   keyr   s
   &&&&&&&   rz   r   r   V  s[     ~$$&
A+C
./4 
H s899Mr|   c               $    V ^8  d   QhRRRRRR/# )ru   rv   r   r   CodecOptions[_DocumentType]rw   r=   rx   )ry   s   "rz   r{   r{   m  s'     K K K#> K= Kr|   c           
        \        V 4      w  r \        VP                  4      '       d   VP                  W4      # \        V ^ \	        V 4      4      w  r4\        R\        W^WA4      4      #   \         d    h \         d>    \        P                  ! 4       w  r5p\        \        T4      4      P                  T4      Rhi ; i)z'Decode a BSON string to document_class.r=   N)rU   r$   r   r   r  r   r   r,   	Exceptionsysexc_infor   with_traceback)rv   r   r   r   r   	exc_valueexc_tbs   &&     rz   _bson_to_dictr4  m  s    "4(JD
Kt2233&&t22!$3t95O%6t1c%PQQ  K"||~f#i.)88@dJKs   +A* .A* *B=?>B=c              #  d   "   T F&  p\        V4      R ,           P                  R4      x  K(  	  R# 5i) utf8N)r   rW   ).0is   & rz   	<genexpr>r:    s&     JkSVf_,,V44ks   .0  c                   V ^8  d   QhRR/# )ru   rw   zGenerator[bytes, None, None]rx   )ry   s   "rz   r{   r{     s     ; ;3 ;r|   c               #     "   \          Rj  xL
  \        P                  ! R4      p  \        \	        V 4      4      R,           P                  R4      x  K/   LI5i)zGenerate "keys" for encoded lists in the sequence
b"0 ", b"1 ", b"2 ", ...

The first 1000 keys are returned from a pre-built cache. All
subsequent keys are generated on the fly.
Nr;  r6  r7  )_LIST_NAMES	itertoolscountr   nextrW   )counters    rz   rV   rV     sE      ood#G
4=!F*226::	 s   
AAA
Ac                    V ^8  d   QhRRRR/# ru   stringzUnion[str, bytes]rw   r   rx   )ry   s   "rz   r{   r{     s     2 2!2 2u 2r|   c                   \        V \        4      '       d*   RV 9   d   \        R4      h \        V RR4       V R,           # RV 9   d   \        R4      h\        V 4      ^ ,          R,           #   \         d    \        RT ,          4      Rhi ; i)z8Make a 'C' string, checking for embedded NUL characters.r   z;BSON keys / regex patterns must not contain a NUL characterNT,strings in documents must be valid UTF-8: %rr6  )r   r   r-   r   UnicodeErrorr.   _utf_8_encoderE  s   &rz   _make_c_string_checkrK    s    &%  f!"_``	&$-G## V!"_``V$Q''11  	#>G	s   A+ +B
c                    V ^8  d   QhRRRR/# rD  rx   )ry   s   "rz   r{   r{     s     2 2, 2 2r|   c                    \        V \        4      '       d    \        V RR4       V R,           # \        V 4      ^ ,          R,           #   \         d    \	        RT ,          4      Rhi ; i)zMake a 'C' string.NTr   rG  )r   r   r   rH  r.   rI  rJ  s   &rz   _make_c_stringrN    sk    &%  	&$-G## V$Q''11  	#>G	s   A A&c                    V ^8  d   QhRRRR/# )ru   rE  r   rw   r   rx   )ry   s   "rz   r{   r{     s     . .s .u .r|   c                X    RV 9   d   \        R4      h\        V 4      ^ ,          R,           # )z*Make a 'C' string suitable for a BSON key.r6  z*BSON keys must not contain a NUL characterr   )r-   rI  rJ  s   &rz   
_make_namerQ    s+    JKK #g--r|   c          
     ,    V ^8  d   QhRRRRRRRRRR/# )	ru   namer   r   floatr   r   r   rw   rx   )ry   s   "rz   r{   r{     s/     / / /e /S /# /% /r|   c                4    RV ,           \        V4      ,           # )zEncode a float.r_   )_PACK_FLOATrS  r   r   r   s   &&&&rz   _encode_floatrX    s    T>K...r|   c          
     ,    V ^8  d   QhRRRRRRRRRR/# )ru   rS  r   r   r   r   r   rw   rx   )ry   s   "rz   r{   r{     s6     D D De DS D# D% Dr|   c                b    RV ,           \        \        V4      4      ,           R,           V,           # )zEncode a python bytes.rc   r   )	_PACK_INTr  rW  s   &&&&rz   _encode_bytesr\    s&     T>Ic%j11G;eCCr|   c          
     ,    V ^8  d   QhRRRRRRRRR	R/# )
ru   rS  r   r   r   
check_keysr  r   r   rw   rx   )ry   s   "rz   r{   r{     s8     F F% F F FEV F[` Fr|   c                h   \        V4      '       d)   RV ,           \        \        VP                  4      ,           # RP	                  VP                  4        UUu. uF  w  rE\        WEW#4      NK  	  upp4      pRV ,           \        \        V4      ^,           4      ,           V,           R,           # u uppi )zEncode a mapping type.ra   r|   r   )	r$   r   r   rawjoinitems_element_to_bsonr[  r  )rS  r   r^  r   r*  valrv   s   &&&&   rz   _encode_mappingre    s    5!!~UEII 66688RWR]R]R_`R_hc%c
AR_`aDT>Ic$i!m44t;gEE as   B.
c          
     ,    V ^8  d   QhRRRRRRRRR	R/# )
ru   rS  r   r   r*   r^  r  r   r   rw   rx   )ry   s   "rz   r{   r{     s1       e  EV [` r|   c                   \        RV ,           R,           4      p\        V4      ^,
          pV\        RVP                  W#4      ,          pV\        RVP                  W#4      ,          pVP
                  e   V\        RVP
                  W#4      ,          pVP                  P                  4        F  w  rgV\        WgW#4      ,          pK  	  VR,          p\        \        V4      V,
          4      WEV^,           % \        V4      # )zEncode bson.dbref.DBRef.ra   s       s   $ref s   $id s   $db r   )r   r  _name_value_to_bsonr   iddatabase_DBRef__kwargsrb  rc  r[  r   )rS  r   r^  r   bufbeginr*  rd  s   &&&&    rz   _encode_dbrefrn    s    
GdN%88
9CHqLE{E,<,<jOOCz588ZFFC~~!":u~~zPP((..0*;; 1 7NC&s3x%'78C	:r|   c          
     ,    V ^8  d   QhRRRRRRRRR	R/# )
ru   rS  r   r   zSequence[Any]r^  r  r   r   rw   rx   )ry   s   "rz   r{   r{     s;     F F
F%F37F?PF
Fr|   c                    \        4       pRP                  V Uu. uF  p\        \        V4      WRV4      NK  	  up4      pRV ,           \	        \        V4      ^,           4      ,           V,           R,           # u upi )zEncode a list/tuple.r|   rb   r   )rV   ra  rh  rA  r[  r  )rS  r   r^  r   lnameitemrv   s   &&&&   rz   _encode_listrs    sf     OE88Z_`Z_RV(edMZ_`aDT>Ic$i!m44t;gEE as   A7c          
     ,    V ^8  d   QhRRRRRRRRRR/# )	ru   rS  r   r   r   r   r   r   rw   rx   )ry   s   "rz   r{   r{     s6     J Ju JS J# Js Ju Jr|   c                    \        V4      ^ ,          pRV ,           \        \        V4      ^,           4      ,           V,           R,           # )zEncode a python str.r`   r   )rI  r[  r  )rS  r   r   r   bvalues   &&&& rz   _encode_textrw    s7    5!!$FT>Ic&kAo66?'IIr|   c          
     ,    V ^8  d   QhRRRRRRRRRR/# )	ru   rS  r   r   r   r   r   r   rw   rx   )ry   s   "rz   r{   r{     s6     N N Nv Ns NC NE Nr|   c                    VP                   pV^8X  d   \        \        V4      4      V,           pRV ,           \        \        V4      V4      ,           V,           # )zEncode bson.binary.Binary.rc   )r   r[  r  _PACK_LENGTH_SUBTYPE)rS  r   r   r   r   s   &&&& rz   _encode_binaryr{    sE    mmG!|#e*%-T>0UWEEMMr|   c          
     ,    V ^8  d   QhRRRRRRRRR	R/# )
ru   rS  r   r   z	uuid.UUIDr   r   r   r   rw   rx   )ry   s   "rz   r{   r{     s1     5 5u 5Y 5s 5BS 5X] 5r|   c                `    VP                   p\        P                  ! WR7      p\        WW#4      # )zEncode uuid.UUID.)r   )r   r   	from_uuidr{  )rS  r   r   r   r   binvals   &&&&  rz   _encode_uuidr    s+    22eMF$44r|   c          
     ,    V ^8  d   QhRRRRRRRRRR/# )	ru   rS  r   r   r5   r   r   r   rw   rx   )ry   s   "rz   r{   r{      s/     ) )5 ) )# )s )u )r|   c                6    RV ,           VP                   ,           # )zEncode bson.objectid.ObjectId.re   )binary)rS  r   r   r   s   &&&&rz   _encode_objectidr     s    T>ELL((r|   c          
     ,    V ^8  d   QhRRRRRRRRRR/# )	ru   rS  r   r   r  r   r   r   rw   rx   )ry   s   "rz   r{   r{     s/     ; ;u ;T ;3 ; ; ;r|   c                J    RV ,           T;'       d    R;'       g    R,           # )z%Encode a python boolean (True/False).rf   r_   r   rx   rW  s   &&&&rz   _encode_boolr    s!    T>U..w99'::r|   c          
     ,    V ^8  d   QhRRRRRRRRRR/# )	ru   rS  r   r   zdatetime.datetimer   r   r   rw   rx   )ry   s   "rz   r{   r{   
  s2     / /5 /): /C /QT /Y^ /r|   c                J    \        V4      pRV ,           \        V4      ,           # zEncode datetime.datetime.rg   )r(   
_PACK_LONGrS  r   r   r   milliss   &&&& rz   _encode_datetimer  
  s      'FT>Jv...r|   c          
     ,    V ^8  d   QhRRRRRRRRRR/# )	ru   rS  r   r   r'   r   r   r   rw   rx   )ry   s   "rz   r{   r{     s0     / /e /J / /S /UZ /r|   c                J    \        V4      pRV ,           \        V4      ,           # r  )r   r  r  s   &&&& rz   _encode_datetime_msr    s    ZFT>Jv...r|   c          
     ,    V ^8  d   QhRRRRRRRRRR/# ru   rS  r   r   r   r   r   rw   rx   )ry   s   "rz   r{   r{     s/      u c 3   r|   c                    RV ,           # )zEncode python None.rh   rx   rS  r   r   r   s   &&&&rz   _encode_noner        T>r|   c          
     ,    V ^8  d   QhRRRRRRRRRR/# )	ru   rS  r   r   z
Regex[Any]r   r   r   rw   rx   )ry   s   "rz   r{   r{     s6     M M Mj M# Ms Mu Mr|   c                ,   VP                   pV\        P                  8X  d+   RV ,           \        VP                  4      ,           R,           # V^ 8X  d+   RV ,           \        VP                  4      ,           R,           # RpV\        P
                  ,          '       d
   VR,          pV\        P                  ,          '       d
   VR,          pV\        P                  ,          '       d
   VR,          pV\        P                  ,          '       d
   VR,          pV\        P                  ,          '       d
   VR	,          pV\        P                  ,          '       d
   VR
,          pVR,          pRV ,           \        VP                  4      ,           V,           # )z*Encode a python regex or bson.regex.Regex.ri   s   u r   r|      i   l   m   s   u   x)
flagsreUNICODErK  r   
IGNORECASELOCALE	MULTILINEDOTALLVERBOSE)rS  r   r   r   r  sflagss   &&&&  rz   _encode_regexr    s   KKE

~ 4U]] CChNN	!~ 4U]] CCgMM2==  dNF299dNF2<<dNF299dNF2::dNF2::dNF'~ 4U]] CCfLLr|   c          
     ,    V ^8  d   QhRRRRRRRRR	R/# )
ru   rS  r   r   r    r   r   r   r   rw   rx   )ry   s   "rz   r{   r{   5  s8     O Ou OT O# O=N OSX Or|   c                Z   \        V4      p\        V4      pVP                  f!   RV ,           \        V4      ,           V,           # \	        VP                  RVR4      p\        ^V,           \        V4      ,           4      pRV ,           V,           \        V4      ,           V,           V,           # )zEncode bson.code.Code.rk   Frm   )rN  r  r   r[  _dict_to_bson)rS  r   r   r   cstringcstrlenr   full_lengths   &&&&    rz   _encode_coder  5  s    U#G'lG{{~	' 22W<<%++udE:EAK#e*45KT>K')G*<<wFNNr|   c          
     ,    V ^8  d   QhRRRRRRRRRR/# )	ru   rS  r   r   r   r   r   r   rw   rx   )ry   s   "rz   r{   r{   @  s6     T Te TC T Tc Te Tr|   c                    RTu;8:  d   R8:  d   M MRV ,           \        V4      ,           #  RV ,           \        V4      ,           #   \        P                   d    \	        R4      Rhi ; i)zEncode a python int.irn   rp   &BSON can only handle up to 8-byte intsNi   )r[  r  r   r   OverflowErrorrW  s   &&&&rz   _encode_intr  @  s`    e)z)~	% 000	TT>Ju$555|| 	T HItS	Ts   A "A(c          
     ,    V ^8  d   QhRRRRRRRRRR/# ru   rS  r   r   r   r   r   rw   rx   )ry   s   "rz   r{   r{   K  s6     C CE C# Cs CC CE Cr|   c                ^    RV ,           \        VP                  VP                  4      ,           # )z Encode bson.timestamp.Timestamp.ro   )_PACK_TIMESTAMPr   timerW  s   &&&&rz   _encode_timestampr  K  s     T>OEIIuzzBBBr|   c          
     ,    V ^8  d   QhRRRRRRRRRR/# r  rx   )ry   s   "rz   r{   r{   P  s6     P Pu PS P# Ps Pu Pr|   c                     RV ,           \        V4      ,           #   \        P                   d    \        R4      Rhi ; i)zEncode a bson.int64.Int64.rp   r  N)r  r   r   r  rW  s   &&&&rz   _encode_longr  P  s?    P~
5 111<< PDE4OPs    "=c          
     ,    V ^8  d   QhRRRRRRRRRR/# )	ru   rS  r   r   r+   r   r   r   rw   rx   )ry   s   "rz   r{   r{   X  s0     & &U &: &s &C &TY &r|   c                6    RV ,           VP                   ,           # )z"Encode bson.decimal128.Decimal128.rq   )bidrW  s   &&&&rz   _encode_decimal128r  X  s    T>EII%%r|   c          
     ,    V ^8  d   QhRRRRRRRRRR/# r  rx   )ry   s   "rz   r{   r{   ]  /        S # % r|   c                    RV ,           # )zEncode bson.min_key.MinKey.rr   rx   r  s   &&&&rz   _encode_minkeyr  ]  r  r|   c          
     ,    V ^8  d   QhRRRRRRRRRR/# r  rx   )ry   s   "rz   r{   r{   b  r  r|   c                    RV ,           # )zEncode bson.max_key.MaxKey.rs   rx   r  s   &&&&rz   _encode_maxkeyr  b  r  r|   _type_markerc              #  $   "   T F  qx  K  	  R # 5ir~   rx   )r8  ts   & rz   r:  r:    s     -9a9s   c               4    V ^8  d   QhRRRRRRRRR	RR
RRR/# )ru   rS  r   r   r   r^  r  r   r   in_custom_callin_fallback_callrw   rx   )ry   s   "rz   r{   r{     s`     AX AX
AXAX AX 	AX
 AX AX AXr|   c                   Rp \         \        V4      ,          ! WW#4      #   \         d     M)\         d    \	        T\
        4      '       g   h Rp Mi ; i\        TRR4      p\	        T\
        4      '       d4   T\        9   d)   \        T,          pT\         \        T4      &   T! YY#4      # T'       gc   TP                  P                  '       dG   TP                  P                  P                  \        T4      4      p	T	e   \        Y	! T4      Y#RR7      # \         FH  p
T'       d   K  \	        Y4      '       g   K   \         T
,          pT\         \        T4      &   T! YY#4      u # 	  TP                  P                  pT'       g   Te   \        Y! T4      Y#RR7      # T'       d   \        R4      h\        RT: R	\        T4      : 24      h)
z!Encode a single name, value pair.FTr  N)r  )r  r  zcannot encode object: z, of type: )	_ENCODERSr   r   r  r   r   getattr_MARKERSr   _encoder_mapr   rh  _BUILT_IN_TYPES_fallback_encoderr-   )rS  r   r^  r   r  r  was_integer_overflowmarkerfunccustom_encoderbasefallback_encoders   &&&&&&      rz   rh  rh    s    !	$e%d:DD  $%%%  $$ UND1F&#6X#5!%	$u+D22 d00===++88<<T%[I%&nU+Zd   ##
5(?(?T?D%)Id5k"Z66   ));; 0 <""5):d
 	
 DEE
25);tE{oV
WWs   ! AAAAc          
     ,    V ^8  d   QhRRRRRRRRRR	/# )
ru   r*  r   r   r^  r  r   r   rw   r   rx   )ry   s   "rz   r{   r{     s1     > ># >c >t >CT >Y^ >r|   c                   \        V \        4      '       g   \        RV : 24      hV'       d?   V P                  R4      '       d   \        RV : R24      hRV 9   d   \        RV : R24      h\	        V 4      p\        WAW#4      # )z Encode a single key, value pair.z.documents must have only string keys, key was $zkey z must not start with '$'.z must not contain '.')r   r   r-   
startswithrQ  rh  )r*  r   r^  r   rS  s   &&&& rz   rc  rc    s{    c3 NsgVWW>>#!D/G"HII#:!D/D"EFFc?DtJ==r|   c          
     ,    V ^8  d   QhRRRRRRRRRR	/# )
ru   docr   r^  r  r   r   	top_levelrw   r   rx   )ry   s   "rz   r{   r{     s4     ; ;	;;&7;DH;
;r|   c           	     F   \        V 4      '       d   \        \        V P                  4      #  . pV'       d+   RV 9   d$   VP	                  \        RV R,          W4      4       V P                  4        F2  w  rVV'       d
   VR8w  g   K   VP	                  \        WVW4      4       K4  	  RP                  T4      p\        \        T4      ^,           4      T,           R,           #   \         d   p\        RT 2T 4      ThRp?ii ; i  \         d    \        RT : 24      Rhi ; i)zEncode a document to BSON._ids   _id zInvalid document: Nz)encoder expected a mapping type but got: r|   r   )r$   r   r   r`  r   rh  rb  rc  r-   AttributeError	TypeErrorra  r[  r  )	r  r^  r   r  elementsr*  r   errencodeds	   &&&&     rz   r  r    s    3E377##W#OO/
CJ
YZ))+JCuTOO$4S$RS & hhx GS\A%&07:: ' T),>se*DcJPSST WCC7KLRVVWs5   	D AD C!#D !D,C<<DD D z1codec_options must be an instance of CodecOptionsc               (    V ^8  d   QhRRRRRRRR/# )	ru   documentMapping[str, Any]r^  r  codec_optionsr   rw   r   rx   )ry   s   "rz   r{   r{     s0     > >>> %> 	>r|   c                R    \        V\        4      '       g   \        h\        WV4      # )aV  Encode a document to BSON.

A document can be any mapping type (like :class:`dict`).

Raises :class:`TypeError` if `document` is not a mapping type,
or contains keys that are not instances of :class:`str`. Raises
:class:`~bson.errors.InvalidDocument` if `document` cannot be
converted to :class:`BSON`.

:param document: mapping type representing a document
:param check_keys: check if keys start with '$' or
    contain '.', raising :class:`~bson.errors.InvalidDocument` in
    either case
:param codec_options: An instance of
    :class:`~bson.codec_options.CodecOptions`.

.. versionadded:: 3.9
)r   r"   _CODEC_OPTIONS_TYPE_ERRORr  )r  r^  r  s   &&&rz   rW   rW     s$    . m\22''}==r|   c               $    V ^8  d   QhRRRRRR/# )ru   rv   r>   r  Nonerw   dict[str, Any]rx   )ry   s   "rz   r{   r{   !  s!         r|   c                    R # r~   rx   rv   r  s   &&rz   rX   rX          r|   c               $    V ^8  d   QhRRRRRR/# )ru   rv   r>   r  r,  rw   r=   rx   )ry   s   "rz   r{   r{   &  s#       1L Q^ r|   c                    R # r~   rx   r  s   &&rz   rX   rX   %  r  r|   c               $    V ^8  d   QhRRRRRR/# )ru   rv   r>   r  %Optional[CodecOptions[_DocumentType]]rw   $Union[dict[str, Any], _DocumentType]rx   )ry   s   "rz   r{   r{   *  s)     S S
S*OS)Sr|   c                    T;'       g    \         p\        V\        4      '       g   \        h\	        R\        W4      4      # )aG  Decode BSON to a document.

By default, returns a BSON document represented as a Python
:class:`dict`. To use a different :class:`MutableMapping` class,
configure a :class:`~bson.codec_options.CodecOptions`::

    >>> import collections  # From Python standard library.
    >>> import bson
    >>> from bson.codec_options import CodecOptions
    >>> data = bson.encode({'a': 1})
    >>> decoded_doc = bson.decode(data)
    <type 'dict'>
    >>> options = CodecOptions(document_class=collections.OrderedDict)
    >>> decoded_doc = bson.decode(data, codec_options=options)
    >>> type(decoded_doc)
    <class 'collections.OrderedDict'>

:param data: the BSON to decode. Any bytes-like object that implements
    the buffer protocol.
:param codec_options: An instance of
    :class:`~bson.codec_options.CodecOptions`.

.. versionadded:: 3.9
r  )r!   r   r"   r  r   r4  )rv   r  r   s   && rz   rX   rX   *  s8    6 ,DD/DDdL))''6d8QRRr|   c               $    V ^8  d   QhRRRRRR/# )ru   rv   r>   r   r,  rw   list[_DocumentType]rx   )ry   s   "rz   r{   r{   L  s(     K Ko K-H KM` Kr|   c           	        \        V 4      w  r\        V 4      p. p^ pV^,
          p\        VP                  4      p WV8  d   \	        W4      ^ ,          pW5,
          V8  d   \        RV RW5,
           24      hWX,           ^,
          p	W	,          ^ 8w  d   \        R4      hV'       d,   VP                  VP                  WV	^,            V4      4       M#VP                  \        WV^,           W4      4       WX,          pK  V#   \
         d    h \         d>    \        P                  ! 4       w  rp\        \        T4      4      P                  T4      Rhi ; i)z)Decode a BSON data to multiple documents.zinvalid object size: expected z, got r   N)rU   r  r$   r   r   r,   r   r   r.  r/  r0  r   r1  )rv   r   r   data_lendocsr   r   use_rawr   r   r   r2  r3  s   &&           rz   _decode_allr  L  s8   "4(JD4yH "DH
Q,C!$"5"56GKn'7:H"X-!4XJfXEXDYZ  )A-G}!!),,D//!0LdST-d(Q,VW H  K"||~f#i.)88@dJKs   A*D 'AD E>Ec               $    V ^8  d   QhRRRRRR/# )ru   rv   r>   r  r  rw   zlist[dict[str, Any]]rx   )ry   s   "rz   r{   r{   q  s"      _ T EY r|   c                    R # r~   rx   r  s   &&rz   rY   rY   p  r  r|   c               $    V ^8  d   QhRRRRRR/# )ru   rv   r>   r  r,  rw   r  rx   )ry   s   "rz   r{   r{   v  s$      
*Er|   c                    R # r~   rx   r  s   &&rz   rY   rY   u       r|   c               $    V ^8  d   QhRRRRRR/# )ru   rv   r>   r  r  rw   z0Union[list[dict[str, Any]], list[_DocumentType]]rx   )ry   s   "rz   r{   r{   |  s$     , ,
,*O,5,r|   c                x    Vf   \        V \        4      # \        V\        4      '       g   \        h\        W4      # )a  Decode BSON data to multiple documents.

`data` must be a bytes-like object implementing the buffer protocol that
provides concatenated, valid, BSON-encoded documents.

:param data: BSON data
:param codec_options: An instance of
    :class:`~bson.codec_options.CodecOptions`.

.. versionchanged:: 3.9
   Supports bytes-like objects that implement the buffer protocol.

.. versionchanged:: 3.0
   Removed `compile_re` option: PyMongo now always represents BSON regular
   expressions as :class:`~bson.regex.Regex` objects. Use
   :meth:`~bson.regex.Regex.try_compile` to attempt to convert from a
   BSON regular expression to a Python regular expression object.

   Replaced `as_class`, `tz_aware`, and `uuid_subtype` options with
   `codec_options`.
)r  r!   r   r"   r  r  s   &&rz   rY   rY   |  s6    0 4!677m\22''t++r|   c               (    V ^8  d   QhRRRRRRRR/# )ru   rawdocr   fieldsr  r,  rw   r=   rx   )ry   s   "rz   r{   r{     s,      -Hr|   c                2   \        VP                  4      '       d   / pMVP                  4       pV P                  4        FT  w  rEWA9   dF   W,          ^8X  d"   \        V P                  V4      V,          W4&   K9  \        WQV,          V4      W4&   KP  WSV&   KV  	  V# )   )r$   r   rb  r4  r`  _decode_selective)r  r  r  r  r*  r   s   &&&   rz   r  r    s     =7788   **,lln
={a(]CCH,#; H % Jr|   c                    V ^8  d   QhRRRR/# )ru   rv   zUnion[memoryview, bytes]rw   r   rx   )ry   s   "rz   r{   r{     s      (@ U r|   c                h   ^ p\        V 4      p\        W!\        V4      4      w  r4V^,          p. pVP                  pW^,
          8  dJ   W!,          ^ 8w  d   V^,          pK  V^,          p\        W!V4      w  rsV! W!W,            4       W,          pKV  W8w  d   \	        R4      hRP                  V4      # )    r)  r|   )r   r   r  r   r,   ra  )rv   r   r   r   r   buffersr   r   s   &       rz   _array_of_documents_to_bufferr    s    HdDdc$i8FAMH "G^^F
1W
n!MHA&ts;tx23489988Gr|   c                    V ^8  d   QhRRRR/# )ru   r  r   rw   r  rx   )ry   s   "rz   r{   r{     s      S T r|   c                    V P                  R4      pV'       g   R# R F<  pVP                  V4      pV'       g   K  \        V4      pV'       d   V.W&   K8  . W&   K>  	  R# )z=Convert raw array of documents to a stream of BSON documents.cursorN)
firstBatch	nextBatch)r   r  )r  r  r*  batchrv   s   &    rz   &_convert_raw_document_lists_to_streamsr    sP    \\(#F*

3,U3&FKFK +r|   c               (    V ^8  d   QhRRRRRRRR/# )ru   rv   r   r  r,  r  rw   r  rx   )ry   s   "rz   r{   r{     s,     * *
*9*CF**r|   c                    VP                   P                  '       g   \        W4      # V'       g   \        WP                  RR7      4      # ^ RIHp VP                  VRR7      p\        W4      p\        VVV4      .# )a  Decode BSON data to a single document while using user-provided
custom decoding logic.

`data` must be a string representing a valid, BSON-encoded document.

:param data: BSON data
:param codec_options: An instance of
    :class:`~bson.codec_options.CodecOptions` with user-specified type
    decoders. If no decoders are found, this method is the same as
    ``decode_all``.
:param fields: Map of document namespaces where data that needs
    to be custom decoded lives or None. For example, to custom decode a
    list of objects in 'field1.subfield1', the specified value should be
    ``{'field1': {'subfield1': 1}}``. If ``fields``  is an empty map or
    None, this method is the same as ``decode_all``.

:return: Single-member list containing the decoded document.

.. versionadded:: 3.8
N)r   r;   )r   r   )r   r   rY   with_optionsbson.raw_bsonr<   r4  r  )rv   r  r  r<   internal_codec_options_docs   &&&   rz   _decode_all_selectiver$    s    . &&333$..$ : : : NOO .<I<V<V&d =W = 6D	
 r|   c               $    V ^8  d   QhRRRRRR/# )ru   rv   r   r  r  rw   Iterator[dict[str, Any]]rx   )ry   s   "rz   r{   r{     s"      e D <T r|   c                    R # r~   rx   r  s   &&rz   rZ   rZ   
  r  r|   c               $    V ^8  d   QhRRRRRR/# )ru   rv   r   r  r,  rw   Iterator[_DocumentType]rx   )ry   s   "rz   r{   r{     s#      e ,G Lc r|   c                    R # r~   rx   r  s   &&rz   rZ   rZ     r  r|   c               $    V ^8  d   QhRRRRRR/# )ru   rv   r   r  r  rw   8Union[Iterator[dict[str, Any]], Iterator[_DocumentType]]rx   )ry   s   "rz   r{   r{     s$      ,  ,
 , E ,= ,r|   c              #     "   T;'       g    \         p\        V\        4      '       g   \        h^ p\	        V 4      ^,
          pW48  d4   \        W4      ^ ,          pWW5,            pW5,          p\        Wb4      x  K9  R# 5i)a  Decode BSON data to multiple documents as a generator.

Works similarly to the decode_all function, but yields one document at a
time.

`data` must be a string of concatenated, valid, BSON-encoded
documents.

:param data: BSON data
:param codec_options: An instance of
    :class:`~bson.codec_options.CodecOptions`.

.. versionchanged:: 3.0
   Replaced `as_class`, `tz_aware`, and `uuid_subtype` options with
   `codec_options`.

.. versionadded:: 2.8
N)r!   r   r"   r  r  r   r4  )rv   r  r   r   r   r   r  s   &&     rz   rZ   rZ     ss     * 111DdL))''H
d)a-C
.#D3A68#67H++ s   A<A>c               $    V ^8  d   QhRRRRRR/# )ru   file_objUnion[BinaryIO, IO[bytes]]r  r  rw   r&  rx   )ry   s   "rz   r{   r{   8  s$      (9=r|   c                    R # r~   rx   r/  r  s   &&rz   r[   r[   7  r	  r|   c               $    V ^8  d   QhRRRRRR/# )ru   r/  r0  r  r,  rw   r)  rx   )ry   s   "rz   r{   r{   ?  s$      (9Tr|   c                    R # r~   rx   r2  s   &&rz   r[   r[   >  r	  r|   c               $    V ^8  d   QhRRRRRR/# )ru   r/  r0  r  r  rw   r,  rx   )ry   s   "rz   r{   r{   E  s&     , ,(,8, >,r|   c              #  ,  "   T;'       g    \         p V P                  ^4      pV'       g   R# \        V4      ^8w  d   \        R4      h\	        V^ 4      ^ ,          ^,
          pW0P                  \        ^ V4      4      ,           p\        WR4      x  K  5i)a  Decode bson data from a file to multiple documents as a generator.

Works similarly to the decode_all function, but reads from the file object
in chunks and parses bson in chunks, yielding one document at a time.

:param file_obj: A file object containing BSON data.
:param codec_options: An instance of
    :class:`~bson.codec_options.CodecOptions`.

.. versionchanged:: 3.0
   Replaced `as_class`, `tz_aware`, and `uuid_subtype` options with
   `codec_options`.

.. versionadded:: 2.8
zcut off in middle of objsizeN)r!   readr  r,   r   maxr4  )r/  r  r   	size_datar   r  s   &&    rz   r[   r[   E  s}     & 111D
!q)	^q <==#Iq1!4q8}}SH-=>>H++s   *BA'Bc                    V ^8  d   QhRRRR/# )ru   bsonr   rw   r  rx   )ry   s   "rz   r{   r{   e  s      5 T r|   c                    \        V \        4      '       g   \        R\        V 4       24      h \	        V \
        4       R#   \         d     R# i ; i)zCheck that the given string represents valid :class:`BSON` data.

Raises :class:`TypeError` if `bson` is not an instance of
:class:`bytes`. Returns ``True``
if `bson` is valid :class:`BSON`, ``False`` otherwise.

:param bson: the data to be validated
z:BSON data must be an instance of a subclass of bytes, not TF)r   r   r  r   r4  r!   r.  )r;  s   &rz   r\   r\   e  sQ     dE""TUYZ^U_T`abbd12 s   A AAc                  J    ] tR tRtRt]R]3R R ll4       t]3R R lltRt	R	# )
r]   ix  zBSON (Binary JSON) data.

.. warning:: Using this class to encode and decode BSON adds a performance
   cost. For better performance use the module level functions
   :func:`encode` and :func:`decode` instead.
Fc          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )ru   clsz
Type[BSON]r  r  r^  r  r  r   rw   r]   rx   )ry   s   "rz   r{   BSON.__annotate__  sA     @ @@#@ @ )	@
 
@r|   c                &    V ! \        WV4      4      # )a  Encode a document to a new :class:`BSON` instance.

A document can be any mapping type (like :class:`dict`).

Raises :class:`TypeError` if `document` is not a mapping type,
or contains keys that are not instances of
:class:`str'. Raises :class:`~bson.errors.InvalidDocument`
if `document` cannot be converted to :class:`BSON`.

:param document: mapping type representing a document
:param check_keys: check if keys start with '$' or
    contain '.', raising :class:`~bson.errors.InvalidDocument` in
    either case
:param codec_options: An instance of
    :class:`~bson.codec_options.CodecOptions`.

.. versionchanged:: 3.0
   Replaced `uuid_subtype` option with `codec_options`.
)rW   )r?  r  r^  r  s   &&&&rz   rW   BSON.encode  s    4 6(>??r|   c                    V ^8  d   QhRRRR/# )ru   r  r   rw   r  rx   )ry   s   "rz   r{   r@    s      +  +. +	 +r|   c                    \        W4      # )a\  Decode this BSON data.

By default, returns a BSON document represented as a Python
:class:`dict`. To use a different :class:`MutableMapping` class,
configure a :class:`~bson.codec_options.CodecOptions`::

    >>> import collections  # From Python standard library.
    >>> import bson
    >>> from bson.codec_options import CodecOptions
    >>> data = bson.BSON.encode({'a': 1})
    >>> decoded_doc = bson.BSON(data).decode()
    <type 'dict'>
    >>> options = CodecOptions(document_class=collections.OrderedDict)
    >>> decoded_doc = bson.BSON(data).decode(codec_options=options)
    >>> type(decoded_doc)
    <class 'collections.OrderedDict'>

:param codec_options: An instance of
    :class:`~bson.codec_options.CodecOptions`.

.. versionchanged:: 3.0
   Removed `compile_re` option: PyMongo now always represents BSON
   regular expressions as :class:`~bson.regex.Regex` objects. Use
   :meth:`~bson.regex.Regex.try_compile` to attempt to convert from a
   BSON regular expression to a Python regular expression object.

   Replaced `as_class`, `tz_aware`, and `uuid_subtype` options with
   `codec_options`.
)rX   )selfr  s   &&rz   rX   BSON.decode  s    @ d**r|   rx   N)
__name__
__module____qualname____firstlineno____doc__classmethodr!   rW   rX   __static_attributes__rx   r|   rz   r]   r]   x  s5      !+@	@ @8 2G +  +r|   c                   V ^8  d   QhRR/# )ru   rw   r  rx   )ry   s   "rz   r{   r{     s      t r|   c                     \         # )zIs the C extension installed?)_USE_Crx   r|   rz   r^   r^     s    Mr|   c                   V ^8  d   QhRR/# )ru   rw   r  rx   )ry   s   "rz   r{   r{     s     % %T %r|   c                     \         P                  P                  4       '       d!   \         P                  P                  4        R# R# )z!Releases the ObjectID lock child.N)r5   	_inc_locklockedreleaserx   r|   rz   _after_forkrV    s.      """"$ #r|   register_at_fork)after_in_child)F)NF)FF)Tr~   )__conditional_annotations__rK  
__future__r   datetimer?  osr  r   r/  uuidcodecsr   r   r   rI  collectionsr   _abctypingr   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   bson.binaryr   r   r   r   r   r   r   r   	bson.coder    bson.codec_optionsr!   r"   r#   r$   bson.datetime_msr%   r&   r'   r(   r)   
bson.dbrefr*   bson.decimal128r+   bson.errorsr,   r-   r.   
bson.int64r/   bson.max_keyr1   bson.min_keyr3   bson.objectidr5   
bson.regexr6   bson.sonr7   r8   bson.timestampr9   bson.tz_utilr:   r!  r<   bson.typingsr=   r>   r;  r?   rP  ImportError__all__r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   Structunpack_fromr   unpack_UNPACK_INTr   r   r   r   rU   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r   __annotations__r  r   r!  r&  r   r4  packrV  r[  rz  r  r  tupleranger>  rV   rK  rN  rQ  rX  r\  re  rn  rs  rw  r{  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   dictrT  r   listr   UUIDr  r  _typhasattrr  r  rh  rc  r  r  r  rW   rX   r  rY   r  r  r  r$  rZ   r[   r\   r]   r^   rV  rW  )rY  s   @rz   <module>r     st
  8r #   	 	  
  0 0 #    *	 	 	     & G G    "  ! $  -;F=== = 	=
 = = = = = = = = = = =  !=" #=$ %=& '=( )=* +=, -=. 
/=0 1=2 
3=4 5=6 7=8 9=: ;=< ==> ?=@ A=B C=D E=F G=H I=J K=L M=N O=P Q=R S=T U=V W=X Y=Z [=\ ]=^ _=` a=b c=d e=f g=h i=j k=l m=n o=p q=r s=t u=v w=x y=~ 



















 ]]4(44 mmD!((==&22 $mmE2>> MM$'33 u-99  =b?b"*' T"J-
BY 	',3E8>L*>L+> L+> L*	>
 L+> L4> L(> L,> L)> L4> L*> L(> L)> L+> L#>  L(!>" L.#>$ L*L/L8L8+>: 2 

 
- -< TS12  .K  
((M mmD!&&MM$$$	}}U+00 ]]4 %%
--&++eJeDkJeeJeDkJJ;2$2./
DF"FJN5)
;
//
M4OTC
P&

,	= ' #	
 	/ 
=  	,  
< 	J 	II| N 
< 	,  
=!" N#$ N	=] "LL/5	< Dt^$$&/o""# 
 %-9-%%-9--AX AXH>; ;. 
((M &&YZ 
 '<>: 
 
 
 
S SDK@ 
$$K 
 
 
 
, ,B.* 
$*$H$H! *Z 
  
 
 
 ,  ,F 
  
 
 
, ,@&D+5 D+N
% 2!"" {33	 #i)  Fs   6]- -	]:9]: