Ë
    Ìià5  ã            	       óÔ  — d dl Z d dlZd dlmZmZmZmZmZmZ d dl	m
Z
 d dlmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ d dlmZmZ erd dlm Z   G d„ de e«      Z!d	Z" G d
„ d«      Z# e$g «      fd„Z%dd„Z&dd„Z'dZ(e(fd„Z)ddedede*de*fd„Z+dedede*fd„Z,dd„Z-d„ Z.d„ Z/d„ Z0d„ Z1ee&fej                  e.fejd                  e/fejf                  e0fejh                  e1fgZ5d d„Z6y)!é    N)ÚTYPE_CHECKINGÚCallableÚProtocolÚAnyÚUnionÚOptional)ÚDeepHash)Ú
DELTA_VIEWÚnumbersÚstringsÚadd_to_frozen_setÚ	not_foundÚonly_numbersÚnpÚ
np_float64Útime_to_secondsÚcartesian_product_numpyÚ
np_ndarrayÚnp_array_factoryÚ,get_homogeneous_numpy_compatible_type_of_seqÚdict_ÚCannotCompareÚ
NumberType)ÚMappingÚIterable)ÚDeepDiffProtocolc            	       óŽ   — e Zd ZU eed<   eed<   ee   ed<   ee   ed<   eed<   ddedefd„Z		 	 	 dd	e
d
e
de
defd„Zdeddfd„Zy)ÚDistanceProtocolÚhashesÚdeephash_parametersÚiterable_compare_funcÚmath_epsilonÚcutoff_distance_for_pairsÚparentÚreturnc                  ó   — y ©N© )ÚselfÚitemr$   s      úR/var/www/html/strategist-ai/venv/lib/python3.12/site-packages/deepdiff/distance.pyÚ__get_item_rough_lengthz(DistanceProtocol.__get_item_rough_length   ó   € Øó    ÚdirectedÚreport_repetition_requiredÚalways_include_valuesc                  ó   — y r'   r(   )r)   r/   r0   r1   s       r+   Ú_to_delta_dictzDistanceProtocol._to_delta_dict   s   € ð r.   r*   Nc                  ó   — y r'   r(   ©r)   r*   s     r+   Ú__calculate_item_deephashz*DistanceProtocol.__calculate_item_deephash    r-   r.   ©Úroot)TTF)Ú__name__Ú
__module__Ú__qualname__ÚdictÚ__annotations__r   r   ÚfloatÚstrÚ(_DistanceProtocol__get_item_rough_lengthÚboolr3   r   Ú*_DistanceProtocol__calculate_item_deephashr(   r.   r+   r   r      s„   … Ø‹Ø!Ó!Ø'¨Ñ1Ó1Ø˜u‘oÓ%Ø#(Ó(ñ	°sð 	Àeó 	ð
 "Ø/3Ø*/ñ		àð	ð )-ð	ð $(ð		ð
 ó	ð	°#ð 	¸$ô 	r.   r   zTDistance calculation can not happen once the cache is purged. Try with _cache='keep'c                   óJ   — e Zd Zdd„Zddd„Zdddeddfd„Z	 	 dd	„Z	 	 dd
„Zy)ÚDistanceMixinr)   r   c                 ó†  — t        | j                  | j                  | j                  | j                  | j
                  ¬«      }|t        ur|S | j                  t        k(  r| n| j                  d¬«      }t        |«      }|dk(  ry| j                  | j                  «      }| j                  | j                  «      }|||z   z  S )aJ  
        Gives a numeric value for the distance of t1 and t2 based on how many operations are needed to convert
        one to the other.

        This is a similar concept to the Levenshtein Edit Distance but for the structured data and is it is designed
        to be between 0 and 1.

        A distance of zero means the objects are equal and a distance of 1 is very far.

        Note: The distance calculation formula is subject to change in future. Use the distance results only as a
        way of comparing the distances of pairs of items with other pairs rather than an absolute distance
        such as the one provided by Levenshtein edit distance.

        Info: The current algorithm is based on the number of operations that are needed to convert t1 to t2 divided
        by the number of items that make up t1 and t2.
        ©Úmax_Úuse_log_scaleÚlog_scale_similarity_thresholdF)r0   r   )Úget_numeric_types_distanceÚt1Út2r#   rH   rI   r   Úviewr
   r3   Ú_get_item_lengthÚ%_DistanceMixin__get_item_rough_length)r)   Ú	_distancer*   Údiff_lengthÚt1_lenÚt2_lens         r+   Ú_get_rough_distancez!DistanceMixin._get_rough_distance*   s¿   € ô$ /Ø�G‰G�T—W‘W 4×#AÑ#AÐQU×QcÑQcð  EI÷  Ehñ  Ehôiˆ	ð œIÑ%ØÐà—y‘y¤JÒ.‰t°D×4GÑ4GÐchÐ4GÓ4iˆÜ& tÓ,ˆà˜!ÒØà×-Ñ-¨d¯g©gÓ6ˆØ×-Ñ-¨d¯g©gÓ6ˆà˜f v™oÑ.Ð.r.   c                 óî   — t        | d«      st        t        «      ‚t        j                  | j
                  |dd¬«      }|€4| j                  |«       t        j                  | j
                  |dd¬«      }|S )a-  
        Get the rough length of an item.
        It is used as a part of calculating the rough distance between objects.

        **parameters**

        item: The item to calculate the rough length for
        parent: It is only used for DeepHash reporting purposes. Not really useful here.
        r   Né   )ÚkeyÚdefaultÚextract_index)ÚhasattrÚRuntimeErrorÚDISTANCE_CALCS_NEEDS_CACHEr	   Úget_keyr   Ú'_DistanceMixin__calculate_item_deephash)r)   r*   r$   Úlengths       r+   r,   z%DistanceMixin.__get_item_rough_lengthM   sh   € ô �t˜XÔ&ÜÔ9Ó:Ð:Ü×!Ñ! $§+¡+°4ÀÐUVÔWˆØˆ>Ø×*Ñ*¨4Ô0Ü×%Ñ% d§k¡k°tÀTÐYZÔ[ˆFØˆr.   r*   r%   Nc                 óL   — t        |f| j                  dddœ| j                  ¤Ž y )Nr8   T)r   r$   Ú
apply_hash)r	   r   r    r5   s     r+   r6   z'DistanceMixin.__calculate_item_deephash_   s/   € ÜØð	
à—;‘;ØØñ		
ð
 ×&Ñ&ó	
r.   c                 ó  — t        «       }|D ]`  }|D ]Y  }	 | j                  ||   j                  ||   j                  «      }	|	r| j                  xs d}
nd}
|
|dj	                  ||«      <   Œ[ Œb |S # t
        $ r Y Œkw xY w)Ng�íµ ÷Æ°>rV   ú{}--{})r   r!   r*   r"   Úformatr   )r)   Úhashes_addedÚhashes_removedÚt1_hashtableÚt2_hashtableÚ_original_typeÚpre_calced_distancesÚ
added_hashÚremoved_hashÚis_close_distanceÚdistances              r+   Ú-_precalculate_distance_by_custom_compare_funcz;DistanceMixin._precalculate_distance_by_custom_compare_funch   sµ   € ä$›wÐØ&ò 	_ˆJØ .ò _�ð
_Ø(,×(BÑ(BÀ<ÐPZÑC[×C`ÑC`ÐbnÐo{Ñb|÷  cBñ  cBó  )CÐ%ñ )à#'×#4Ñ#4Ò#@¸™à#$˜ØV^Ð(¨¯©¸À\Ó)RÒSñ_ð	_ð $Ð#øô %ò Ùðús   –,A2Á2	A>Á=A>c                 óx  — t        |t        t        |«      «         j                  t        t
        f«      ry t        «       }|D �cg c]  }||   j                  ‘Œ }}|D �cg c]  }||   j                  ‘Œ }	}|€t        |«      }
t        |	«      }|
r|
|k(  r|
}|€y t        ||¬«      }t        |	|¬«      }	t        ||	«      }|j                  }t        |d   |d   | j                  | j                  | j                  ¬«      }d}|D ]&  }|D ]  }||   |dj                  ||«      <   |dz  }Œ! Œ( |S c c}w c c}w )N)Údtyper   rV   rF   rc   )Ú
isinstanceÚnextÚiterr*   r   Úlistr   r   r   r   ÚTÚ_get_numpy_array_distancer#   rH   rI   rd   )r)   re   rf   rg   rh   ri   rj   ÚkÚaddedÚremovedÚadded_numpy_compatible_typeÚremoved_numpy_compatible_typeÚpairsÚpairs_transposedÚ	distancesÚirk   rl   s                     r+   Ú#_precalculate_numpy_arrays_distancez1DistanceMixin._precalculate_numpy_arrays_distance{   sc  € ô �l¤4¬¨\Ó(:Ó#;Ñ<×AÑAÄJÔPTÐCUÔVØä$›wÐØ/;Ö<¨!�˜a‘×%Ó%Ð<ˆÐ<Ø1?Ö@¨A�< ‘?×'Ó'Ð@ˆÐ@àÐ!Ü*VÐW\Ó*]Ð'Ü,XÐY`Ó,aÐ)Ù*Ð/JÐNkÒ/kØ!<�ØÐ!Øä  ¨nÔ=ˆÜ" 7°.ÔAˆä'¨¨wÓ7ˆà Ÿ7™7Ðä-Ø˜QÑÐ!1°!Ñ!4Ø×/Ñ/Ø×,Ñ,Ø+/×+NÑ+Nô	
ˆ	ð ˆØ&ò 	ˆJØ .ò �ØR[Ð\]ÑR^Ð$ X§_¡_°ZÀÓ%NÑOØ�Q‘‘ñð	ð $Ð#ùò= =ùÚ@s   ÁD2Á!D7)r)   r   r7   )	r9   r:   r;   rT   rO   r   r^   ro   r�   r(   r.   r+   rD   rD   (   sB   „ ó!/ôFð$
Ð(:ð 
À#ð 
È$ó 
ð$Ø$ó$ð&&$Ø$ô&$r.   rD   c                 ó˜  — d}t        | t        «      rò| j                  «       D ]Ý  \  }}|dv r{t        «       }|j                  «       D ]\  \  }}t	        «       }t        «       }	|j                  «       D ]+  \  }
}t        |«      }||vsŒ|j                  |«       ||	|
<   Œ- |	||<   Œ^ |}t        |t        «      r|j                  d«      s
|dk(  s|dk(  rŒ±t        |«      }|r||v rŒÃt        ||«      }|t        ||«      z  }Œß |S t        | t        «      rd}|S t        | t        «      rd}|S t        | t        «      r6| D ]/  }t        |«      }|r||v rŒt        ||«      }|t        ||«      z  }Œ1 |S t        | t        «      rd}|S t        | d«      r7| j                  D ](  }t        |«      }t        ||«      }|t        ||«      z  }Œ* |S )z±
    Get the number of operations in a diff object.
    It is designed mainly for the delta view output
    but can be used with other dictionary types of view outputs too.
    r   >   Úiterable_items_added_at_indexesÚ!iterable_items_removed_at_indexesÚ_Údeep_distanceÚnew_pathrV   Ú__dict__)rr   r   Úitemsr   ÚsetÚidÚaddr   Ú
startswithr   rN   r   r   ÚtyperZ   rˆ   )r*   Úparents_idsr_   rW   ÚsubitemÚnew_subitemÚpath_Úindexes_to_itemsÚused_value_idsÚnew_indexes_to_itemsrx   ÚvÚv_idÚitem_idÚparents_ids_addeds                  r+   rN   rN   ¤   s  € ð €FÜ�$œÔ Ø ŸJ™J›Lò 	C‰LˆC�àÐ^Ñ^Ü#›g�Ø/6¯}©}«ò >Ñ+�EÐ+Ü%(£U�NÜ+0«7Ð(Ø 0× 6Ñ 6Ó 8ò 8™˜˜1Ü! !›u˜Ø ~Ò5Ø*×.Ñ.¨tÔ4Ø67Ð0°Ò3ð	8ð
 *>�K Ò&ð>ð &�ô ˜#œwÔ'¨S¯^©^¸CÔ-@ÀCÈ?ÒDZÐ^aÐeoÒ^oØä˜“kˆGÙ˜w¨+Ñ5ØÜ 1°+¸wÓ GÐØÔ& wÐ0AÓBÑB‰Fð/	CðV €Mô' 
�Dœ'Ô	"Øˆð$ €Mô# 
�Dœ'Ô	"Øˆð  €Mô 
�Dœ(Ô	#Øò 	CˆGÜ˜“kˆGÙ˜w¨+Ñ5ØÜ 1°+¸wÓ GÐØÔ& wÐ0AÓBÑB‰Fð	Cð €Mô 
�Dœ$Ô	Øˆð €Mô �4˜Ô$ØŸ=™=ò G�Ü˜W›+�Ü$5°kÀ7Ó$KÐ!ØÔ*¨7Ð4EÓFÑF‘ðGð €Mr.   c                 ó  — | |k(  ry|rt        | |«      }|dk  ry|S t        | t        «      st        | «      } t        |t        «      st        |«      }| |z   |z  }|dk(  r|S 	 t        |t	        | |z
  |z  «      «      S # t
        $ r |cY S w xY w)úÄ
    Get the distance of 2 numbers. The output is a number between 0 to the max.
    The reason is the
    When max is returned means the 2 numbers are really far, and 0 means they are equal.
    r   )Úlogarithmic_distancerr   r>   ÚminÚabsÚ	Exception)Únum1Únum2rG   rH   rI   rn   Údivisors          r+   Ú_get_numbers_distancer£   Ú   s¢   € ð ˆt‚|ØÙÜ'¨¨dÓ3ˆØ�aŠ<ØØˆÜ�dœEÔ"Ü�T‹{ˆÜ�dœEÔ"Ü�T‹{ˆð
 �d‰{˜dÑ"€GØ�!‚|ØˆðÜ�4œ˜d T™k¨WÑ4Ó5Ó6Ð6øÜò ØŠðús   Á#A> Á>BÂBc                 ó¤   — t        j                  | j                  |t        ¬«      }t        j                  | |||dk7  t        ¬«      }d|| |k(  <   |S )N)ÚshapeÚ
fill_valuerq   r   )ÚoutÚwhererq   )r   Úfullr¥   r   Údivide)ÚaÚbÚreplace_inf_withÚ	max_arrayÚresults        r+   Ú
_numpy_divr°   ø   sE   € Ü—‘˜aŸg™gÐ2BÌ*ÔU€IÜ�Y‰Y�q˜! °!°q±&Ä
ÔK€Fà€Fˆ1�‰6�NØ€Mr.   g»½×Ùß|Û=c                 óŒ   — t        j                  | «      |z   }t        j                  |«      }t        j                  || «      }|S r'   )r   rž   ÚlogÚcopysign)ÚarrayÚoffsetÚabs_plus_offsetÚ
log_valuesÚsigned_log_valuess        r+   Únumpy_apply_log_keep_signr¹     s=   € ä—f‘f˜U“m fÑ,€Oô —‘˜Ó(€Jô Ÿ™ J°Ó6ÐàÐr.   r«   r¬   Ú	thresholdr%   c                 ó    — t        | |«      |k  S )zº
    A threshold of 0.1 translates to about 10.5% difference.
    A threshold of 0.5 translates to about 65% difference.
    A threshold of 0.05 translates to about 5.1% difference.
    )rœ   )r«   r¬   rº   s      r+   Úlogarithmic_similarityr¼     s   € ô    1Ó%¨	Ñ1Ð1r.   c                 ó.  — t        | «      } t        |«      }t        j                  t        j                  t	        | «      t
        z   «      | «      }t        j                  t        j                  t	        |«      t
        z   «      |«      }t	        ||z
  «      S r'   )r>   Úmathr³   r²   rž   ÚMATH_LOG_OFFSET)r«   r¬   Úlog_aÚlog_bs       r+   rœ   rœ     sg   € äˆa‹€AÜˆa‹€AÜ�M‰Mœ$Ÿ(™(¤3 q£6¬OÑ#;Ó<¸aÓ@€EÜ�M‰Mœ$Ÿ(™(¤3 q£6¬OÑ#;Ó<¸aÓ@€Eäˆu�u‰}ÓÐr.   c                 óÐ   — |rt        | «      } t        |«      }| |z   |z  }t        | |z
  ||¬«      }t        j                  t        j                  |«      d|«      }|rd|||k  <   |S )r›   )r­   r   )r¹   r°   r   ÚclipÚabsolute)r    r¡   rG   rH   rI   r¢   r¯   Údistance_arrays           r+   rw   rw   "  so   € ñ Ü(¨Ó.ˆÜ(¨Ó.ˆà�d‰{˜dÑ"€GÜ˜ ™ wÀÔF€Fä—W‘WœRŸ[™[¨Ó0°!°TÓ:€NÙØJKˆ�~Ð(FÑFÑGØÐr.   c                 óT   — t        | j                  «       |j                  «       |«      S r'   )r£   Ú	timestamp©Údate1Údate2rG   rH   rI   s        r+   Ú_get_datetime_distancerË   9  ó   € Ü  §¡Ó!2°E·O±OÓ4EÀtÓLÐLr.   c                 óT   — t        | j                  «       |j                  «       |«      S r'   )r£   Ú	toordinalrÈ   s        r+   Ú_get_date_distancerÏ   =  rÌ   r.   c                 óT   — t        | j                  «       |j                  «       |«      S r'   )r£   Útotal_seconds)Ú
timedelta1Ú
timedelta2rG   rH   rI   s        r+   Ú_get_timedelta_distancerÔ   A  s$   € Ü  ×!9Ñ!9Ó!;¸Z×=UÑ=UÓ=WÐY]Ó^Ð^r.   c                 ó@   — t        t        | «      t        |«      |«      S r'   )r£   r   )Útime1Útime2rG   rH   rI   s        r+   Ú_get_time_distancerØ   E  s   € Ü ¤°Ó!7¼ÈÓ9OÐQUÓVÐVr.   c                 óx   — t         D ],  \  }}t        | |«      sŒt        ||«      sŒ  || ||||«      c S  t        S r'   )ÚTYPES_TO_DIST_FUNCrr   r   )r    r¡   rG   rH   rI   Útype_Úfuncs          r+   rJ   rJ   R  sF   € Ü)ò Y‰ˆˆtÜ�d˜EÕ"¤z°$¸Õ'>Ù˜˜d D¨-Ð9WÓXÒXðYô Ðr.   )rV   Fçš™™™™™¹?)rV   )rÝ   )FrÝ   )7r¾   ÚdatetimeÚtypingr   r   r   r   r   r   Údeepdiff.deephashr	   Údeepdiff.helperr
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Úcollections.abcr   r   Údeepdiff.diffr   r   r\   rD   Ú	frozensetrN   r£   r°   r¿   r¹   r>   r¼   rœ   rw   rË   rÏ   rÔ   rØ   ÚdateÚ	timedeltaÚtimerÚ   rJ   r(   r.   r+   ú<module>rè      s.  ðÛ Û ß J× JÝ &÷÷ ÷ ÷ ó ÷ .áÝ.ôÐ+¨Xô ð. tÐ ÷y$ñ y$ñx (1°£}ó 3óló<ð €à,;ó 
ñ2˜jð 2¨Zð 2ÀEð 2ÐRWó 2ð˜Jð ¨:ð ¸%ó óò.MòMò_òWð
 Ð(Ð)Ø×ÑÐ.Ð/Ø‡]�]Ð&Ð'Ø×ÑÐ0Ð1Ø‡]�]Ð&Ð'ðÐ ôr.   