+
    QV-j&2  ã                   óø   € ^ RI t ^ RIHtHt ^ RIHt ^ RIHt ^ RIH	t	H
t
HtHtHt ^ RIt^RIHt ^RIHt ^RIHt ^R	IHtHtHt ^R
IHt ]	'       d   ^ RIt^RIHt ] ! R R4      4       tR R lt R R lt!R# )é    N)Ú	dataclassÚfield)ÚBytesIO)ÚPath)ÚTYPE_CHECKINGÚAnyÚClassVarÚOptionalÚUnion)Úconfig)ÚDownloadConfig)Ú
array_cast)Úis_local_pathÚis_remote_urlÚxopen)Ústring_to_dict)ÚFeatureTypec                   ó2  a € ] tR t^t o RtRt]! RRR7      tRt]	P                  ! R]	P                  ! 4       R]	P                  ! 4       /4      t]! R RRR	7      tR
 tV 3R lR ltRV 3R lR lltV 3R lR ltV 3R lR ltRV 3R lR lltV 3R ltRtV tR# )ÚMesha‡  Mesh [`Feature`] to read 3D mesh data from a file.

Input: The Mesh feature accepts as input:
- A `str`: Absolute path to the mesh file (i.e. random access is allowed).
- A `pathlib.Path`: path to the mesh file (i.e. random access is allowed).
- A `dict` with the keys:

    - `path`: String with relative path of the mesh file to the archive file.
    - `bytes`: Bytes of the mesh file.

  This is useful for parquet or webdataset files which embed mesh files.

- A `trimesh.Trimesh` or `trimesh.Scene`: 3D mesh or scene object.

Output: The Mesh feature outputs data as `trimesh.Trimesh` or `trimesh.Scene` objects.

Args:
    decode (`bool`, defaults to `True`):
        Whether to decode the mesh data. If `False`,
        returns the underlying dictionary in the format `{"path": mesh_path, "bytes": mesh_bytes}`.
        Mesh decoding uses `trimesh` and supports `.glb`, `.ply`, and `.stl` files.
TNF)ÚdefaultÚreprútrimesh.TrimeshÚbytesÚpath)r   Úinitr   c                ó   € V P                   # ©N)Úpa_type)Úselfs   &Úg/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/datasets/features/mesh.pyÚ__call__ÚMesh.__call__6   s   € Ø�|‰|Ðó    c                óH   <€ V ^8„  d   QhRS[ S[S[S[S[RR3,          RS[/# )é   Úvaluer   útrimesh.SceneÚreturn)r   Ústrr   Ú	bytearrayÚdict)ÚformatÚ__classdict__s   "€r    Ú__annotate__ÚMesh.__annotate__9   s0   ø€ ÷  ñ  ¡E©#©u±iÁÐGXÐZiÐ*iÕ$jð  Ñosñ  r#   c                ó<  € \         P                  '       d   ^ RIpMRp\        V\        4      '       d   RVRR/# \        V\
        4      '       d   R\	        VP                  4       4      RR/# \        V\        \        34      '       d   RRRV/# Ve3   \        WP                  VP                  34      '       d   \        V4      # \        V\        4      '       dU   VP                  R4      eB   \        P                  P!                  VR,          4      '       d   RRRVP                  R4      /# \        V\        4      '       dK   VP                  R4      f   VP                  R4      e%   RVP                  R4      RVP                  R4      /# \#        RV R24      h)zÜEncode example into a format for Arrow.

Args:
    value (`str`, `bytes`, `dict`, `trimesh.Trimesh`, or `trimesh.Scene`):
        Data passed as input to Mesh feature.

Returns:
    `dict` with "path" and "bytes" fields
Nr   r   zSA mesh sample should have one of 'path' or 'bytes' but they are missing or None in Ú.)r   ÚTRIMESH_AVAILABLEÚtrimeshÚ
isinstancer)   r   Úabsoluter   r*   ÚTrimeshÚSceneÚencode_trimesh_meshr+   ÚgetÚosr   ÚisfileÚ
ValueError)r   r&   r3   s   && r    Úencode_exampleÚMesh.encode_example9   sX  € ô ×#×#Ð#ÜàˆGä�eœS×!Ò!Ø˜E 7¨DÐ1Ð1Ü˜œt×$Ò$ØœC §¡Ó 0Ó1°7¸DÐAÐAÜ˜¤¤yÐ1×2Ò2Ø˜D '¨5Ð1Ð1ØÒ ¤Z°¿¹ÈÏÉÐ7W×%XÒ%XÜ& uÓ-Ð-Ü˜œt×$Ò$¨¯©°6Ó):Ò)FÌ2Ï7É7Ï>É>ÐZ_Ð`fÕZg×KhÒKhà˜T 6¨5¯9©9°VÓ+<Ð=Ð=Ü˜œt×$Ò$¨%¯)©)°GÓ*<Ò*HÈEÏIÉIÐV\ÓL]ÒLià˜UŸY™Y wÓ/°¸¿¹À6Ó9JÐKÐKäØeÐfkÐelÐlmÐnóð r#   c                ó4   <€ V ^8„  d   QhRS[ RS[R,          /# )r%   r&   r(   ©r   r'   )r+   r   )r,   r-   s   "€r    r.   r/   [   s%   ø€ ÷ 5Bñ 5B¡Dð 5BÁUÐKmÕEnñ 5Br#   c                óx  € V P                   '       g   \        R4      h\        P                  '       d   ^ RIpM\        R4      hVf   / pVR,          VR,          rTVEf   Vf   \        RV R24      h\        V4      '       d.   \        V4      pVf   \        R4      hVP                  ! WFR	7      # VP                  R
4      R,          pVP                  \        P                  4      '       d   \        P                  M\        P                  p\        Wx4      p	V	e   VP!                  V	R,          4      MRp
\#        V
R7      p\%        VRVR7      ;_uu_ 4       pVP'                  4       pRRR4       \        V4      pVf   \        R4      hVP                  ! \)        V4      VR	7      #   + '       g   i     LG; i)aË  Decode example mesh file.

Args:
    value (`dict`):
        A dictionary with keys:

        - `path`: String with absolute or relative mesh file path.
        - `bytes`: The bytes of the mesh file.
    token_per_repo_id (`dict`, *optional*):
        To access and decode
        mesh files from private repositories on the Hub, you can pass
        a dictionary repo_id (`str`) -> token (`bool` or `str`).

Returns:
    `trimesh.Trimesh` or `trimesh.Scene`
zLDecoding is disabled for this feature. Please use Mesh(decode=True) instead.Nz5To support decoding meshes, please install 'trimesh'.r   r   zAA mesh should have one of 'path' or 'bytes' but both are None in r1   z8A mesh path should have a .glb, .ply, or .stl extension.©Ú	file_typeú::Úrepo_id©ÚtokenÚrb©Údownload_configzmDecoding mesh bytes requires a 'path' value with a .glb, .ply, or .stl extension to infer the mesh file type.éÿÿÿÿ)ÚdecodeÚRuntimeErrorr   r2   r3   ÚImportErrorr<   r   Ú_infer_mesh_file_typeÚloadÚsplitÚ
startswithÚHF_ENDPOINTÚHUB_DATASETS_URLÚHUB_DATASETS_HFFS_URLr   r9   r   r   Úreadr   )r   r&   Útoken_per_repo_idr3   r   Úbytes_rC   Ú
source_urlÚpatternÚsource_url_fieldsrG   rJ   Úfs   &&&          r    Údecode_exampleÚMesh.decode_example[   s„  € ð" �{�{ˆ{ÜÐmÓnÐnä×#×#Ð#ÜäÐUÓVÐVàÒ$Ø "Ðà˜V•} e¨G¥nˆfØ‹>ØŠ|Ü Ð#dÐejÐdkÐklÐ!mÓnÐnÜ˜T×"Ò"Ü1°$Ó7�	ØÒ$Ü$Ð%_Ó`Ð`Ø—|’| DÔ>Ð>ØŸ™ DÓ)¨"Õ-ˆJà+5×+@Ñ+@Ä×ASÑAS×+TÒ+T”×'Ò'ÔZ`×ZvÑZvð ô !/¨zÓ CÐØK\ÒKhÐ%×)Ñ)Ð*;¸IÕ*FÔGÐnrˆEÜ,°5Ô9ˆOÜ�t˜T°?×CÕCÀqØŸ™›�÷ Dô *¨$Ó/ˆ	ØÒÜð/óð ð �|Š|œG F›O°yÔAÐA÷ D×Cús   ÅF)Æ)F9	c                óH   <€ V ^8„  d   QhRS[ RS[S[R3,          3,          /# )r%   r(   r   )r   r+   r)   )r,   r-   s   "€r    r.   r/   ’   s(   ø€ ÷ 
ñ 
™˜}©d±3¸Ð3EÕ.FÐFÕGñ 
r#   c                óZ   € ^RI Hp V P                  '       d   V # RV! R4      RV! R4      /# )zfIf in the decodable state, return the feature itself, otherwise flatten the feature into a dictionary.)ÚValuer   Úbinaryr   Ústring)Úfeaturesra   rL   )r   ra   s   & r    ÚflattenÚMesh.flatten’   s8   € å#ð �{�{ˆ{ð ð	
ð ™˜x›Ø™˜h›ðð	
r#   c                óx   <€ V ^8„  d   QhRS[ S[P                  S[P                  3,          RS[P                  /# )r%   Ústorager(   )r   ÚpaÚStringArrayÚStructArray)r,   r-   s   "€r    r.   r/   Ÿ   s1   ø€ ÷ 31ñ 31¡E©"¯.©.¹"¿.¹.Ð*HÕ$Ið 31ÉbÏnÉnñ 31r#   c                ó¨  € \         P                  P                  VP                  4      '       d&    VP	                  \         P
                  ! 4       4      p\         P                  P                  VP                  4      '       dr   \         P                  ! R.\        V4      ,          \         P                  ! 4       R7      p\         P                  P                  W1.RR.VP                  4       R7      pEMž\         P                  P                  VP                  4      '       d‘   \!        V\         P                  ! 4       4      p\         P                  ! R.\        V4      ,          \         P
                  ! 4       R7      p\         P                  P                  W.RR.VP                  4       R7      pEMß\         P                  P#                  VP                  4      '       dr   \         P                  ! R.\        V4      ,          \         P
                  ! 4       R7      p\         P                  P                  W.RR.VP                  4       R7      pEM?\         P                  P%                  VP                  4      '       Ed   VP                  P'                  R4      ^ 8¼  d   VP)                  R4      pM<\         P                  ! R.\        V4      ,          \         P                  ! 4       R7      pVP                  P'                  R4      ^ 8¼  d   VP)                  R4      pM<\         P                  ! R.\        V4      ,          \         P
                  ! 4       R7      p\         P                  P                  W4.RR.VP                  4       R7      p\!        WP*                  4      #   \         P                   d   p\        RT 24      ThRp?ii ; i)aÌ  Cast an Arrow array to the Mesh arrow storage type.
The Arrow types that can be converted to the Mesh pyarrow storage type are:

- `pa.string()` - it must contain the "path" data
- `pa.large_string()` - it must contain the "path" data (will be cast to string if possible)
- `pa.binary()` - it must contain the mesh bytes
- `pa.struct({"bytes": pa.binary()})`
- `pa.struct({"path": pa.string()})`
- `pa.struct({"bytes": pa.binary(), "path": pa.string()})`  - order doesn't matter

Args:
    storage (`Union[pa.StringArray, pa.StructArray]`):
        PyArrow array to cast.

Returns:
    `pa.StructArray`: Array in the Mesh arrow storage type, that is
        `pa.struct({"bytes": pa.binary(), "path": pa.string()})`.
zuFailed to cast large_string to string for Mesh feature. This can happen if string values exceed 2GB. Original error: N©Útyper   r   ©Úmask)ri   ÚtypesÚis_large_stringrn   Úcastrc   ÚArrowInvalidr<   Ú	is_stringÚarrayÚlenrb   rk   Úfrom_arraysÚis_nullÚis_large_binaryr   Ú	is_binaryÚ	is_structÚget_field_indexr   r   )r   rh   ÚeÚbytes_arrayÚ
path_arrays   &&   r    Úcast_storageÚMesh.cast_storageŸ   s   € ô& �8‰8×#Ñ# G§L¡L×1Ò1ðØ!Ÿ,™,¤r§y¢y£{Ó3�ô �8‰8×Ñ˜gŸl™l×+Ò+ÜŸ(š( D 6¬C°«LÕ#8¼r¿yºy»{ÔKˆKÜ—n‘n×0Ñ0°+Ð1GÈ'ÐSYÐIZÐah×apÑapÓarÐ0ÓsŠGÜ�X‰X×%Ñ% g§l¡l×3Ò3Ü ØœŸš›óˆGô Ÿš 4 &¬3¨w«<Õ"7¼b¿iºi»kÔJˆJÜ—n‘n×0Ñ0°'Ð1FÈÐRXÐHYÐ`g×`oÑ`oÓ`qÐ0ÓrŠGÜ�X‰X×Ñ §¡×-Ò-ÜŸš 4 &¬3¨w«<Õ"7¼b¿iºi»kÔJˆJÜ—n‘n×0Ñ0°'Ð1FÈÐRXÐHYÐ`g×`oÑ`oÓ`qÐ0ÓrŠGÜ�X‰X×Ñ §¡×-Ó-Ø�|‰|×+Ñ+¨GÓ4¸Ô9Ø%Ÿm™m¨GÓ4‘ä Ÿhšh¨ v´°G³Õ'<Ä2Ç9Â9Ã;ÔO�Ø�|‰|×+Ñ+¨FÓ3°qÔ8Ø$Ÿ]™]¨6Ó2‘
äŸXšX t f¬s°7«|Õ&;Ä"Ç)Â)Ã+ÔN�
Ü—n‘n×0Ñ0°+Ð1JÈWÐV\ÐL]Ðdk×dsÑdsÓduÐ0ÓvˆGä˜'§<¡<Ó0Ð0øô; —?‘?ô Ü ð'à'( cð+óð ð	ûðús   ±$N( Î(OÎ=OÏOc                óZ   <€ V ^8„  d   QhRS[ P                  RS[RS[RS[ P                  /# )r%   rh   Úlocal_filesÚremote_filesr(   )ri   rk   Úbool)r,   r-   s   "€r    r.   r/   Ô   s5   ø€ ÷ ?1ñ ?1Ù—~‘~ð?1ÙLPð?1Ùgkð?1á	�‰ñ?1r#   c           	     ó~  a€ Sf   / oV3R lp\         P                  ! VP                  4        Uu. uFl  pVed   VR,          fP   V'       d   \        VR,          4      '       g!   V'       d(   \	        VR,          4      '       d   V! VR,          4      M
VR,          MRNKn  	  up\         P
                  ! 4       R7      p\         P                  ! VP                  R4      P                  4        Uu. uF\  pVeT   V'       d   \        V4      '       g   V'       d1   \	        V4      '       d    \        P                  P                  V4      MTMRNK^  	  up\         P                  ! 4       R7      p	\         P                  P                  Wy.RR.VP                  4       R7      p\        WP                  4      # u upi u upi )a4  Embed mesh files into the Arrow array.

Args:
    storage (`pa.StructArray`):
        PyArrow array to embed.
    token_per_repo_id (`dict`, optional):
        Dictionary repo_id -> token to fetch the files bytes.
    local_files (`bool`, defaults to `True`):
        Whether to embed local files data in the array.
    remote_files (`bool`, defaults to `True`):
        Whether to embed remote files data in the array.

Returns:
    `pa.StructArray`: Array in the Mesh arrow storage type, that is
        `pa.struct({"bytes": pa.binary(), "path": pa.string()})`.
Nc                 ó¾  <€ V f   R # V P                  R4      R,          pVP                  \        P                  4      '       d   \        P                  M\        P
                  p\        W4      pVe   SP                  VR,          4      MR p\        VR7      p\        V RVR7      ;_uu_ 4       pVP                  4       uuR R R 4       #   + '       g   i     R # ; i)NrD   rE   rF   rH   rI   rK   )rQ   rR   r   rS   rT   rU   r   r9   r   r   rV   )r   rY   rZ   r[   rG   rJ   r\   rW   s   &      €r    Úpath_to_bytesÚ)Mesh.embed_storage.<locals>.path_to_bytesê   s«   ø€ ØŠ|ÙØŸ™ DÓ)¨"Õ-ˆJà+5×+@Ñ+@Ä×ASÑAS×+TÒ+T”×'Ò'ÔZ`×ZvÑZvð ô !/¨zÓ CÐØK\ÒKhÐ%×)Ñ)Ð*;¸IÕ*FÔGÐnrˆEÜ,°5Ô9ˆOÜ�t˜T°?×CÕCÀqØ—v‘v“x÷ D×C×CÓCús   Â0CÃC	r   r   rm   ro   )ri   rv   Ú	to_pylistr   r   rb   r   r:   r   Úbasenamerc   rk   rx   ry   r   r   )
r   rh   rW   r„   r…   r‰   Úxr   r   r€   s
   &&f&&     r    Úembed_storageÚMesh.embed_storageÔ   s‡  ø€ ð& Ò$Ø "Ðõ	 ô —h’hð !×*Ñ*Ô,ó
ñ -�Að ’=ð	 ˜•zÒ)ß%¬-¸¸&½	×*BÒ*BÏÔYfÐghÐioÕgp×YqÒYqñ " ! F¥)Ô,ð ˜7žð òñ -ñ
ô —’“ô
ˆô —X’Xð $ŸM™M¨&Ó1×;Ñ;Ô=ó	ñ >�Dð Ò#÷ $¬°d×(;Ò(;ÇÔR_Ð`d×ReÒReô —G‘G×$Ñ$ TÔ*áð òñ >ñ	ô —’“ô
ˆ
ô —.‘.×,Ñ,¨kÐ-FÈÐRXÐHYÐ`g×`oÑ`oÓ`qÐ,ÓrˆÜ˜'§<¡<Ó0Ð0ùò7
ùò	s#   °F5ÁF5Á,6F5Ã/F:Ä F:Ä8F:c                ó†   <€ V ^8„  d   Qh/ S[ ;R&   S[S[,          ;R&   S[S[,          ;R&   S[S[,          ;R&   S[;R&   # )r%   rL   ÚidÚdtyper   Ú_type)r†   r
   r)   r	   r   )r,   r-   s   "€r    r.   r/      sR   ø‡ ‚ ñ2 Ññ3 ñ4 	‘�Ñ7ñ5 ñ8 ‘C�=Ñ,ñ9 ñ: ‘c�]ÑSñ; ñ< Ñ>ò= r#   © r   )NTT)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rL   r   r‘   r’   ri   Ústructrb   rc   r   r“   r!   r=   r]   re   r�   rŽ   Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__)r-   s   @r    r   r      s—   ø‡ € ñð. €FÙ d°Ô7€Bà,€EØŸYšY¨°·²³¸fÀbÇiÂiÃkÐ'RÓS€GÙ˜v¨E¸Ô>€Eò÷ ð  ÷D5Bò 5B÷n
ð 
÷31ð 31÷j?1ò ?1÷} ƒ r#   r   c                ó\   € V ^8„  d   QhR\         \        ,          R\         \        ,          /# )r%   r   r(   )r
   r)   )r,   s   "r    r.   r.     s&   € ÷ Dñ D¤¬¥ð D´(¼3µ-ñ Dr#   c                 ó  € 0 RmpV f   R# V P                  R^4      ^ ,          pVP                  R^4      ^ ,          p\        P                  P                  V4      ^,          P	                  4       P                  R4      pWA9   d   V# R# )ÚglbNrD   Ú?r1   >   r    ÚplyÚstl)rQ   r:   r   ÚsplitextÚlowerÚlstrip)r   Úsupported_file_typesÚpath_without_archiveÚpath_without_queryÚ	extensions   &    r    rO   rO     s|   € Ú0ÐØ‚|ÙØŸ:™: d¨AÓ.¨qÕ1ÐØ-×3Ñ3°C¸Ó;¸AÕ>ÐÜ—‘× Ñ Ð!3Ó4°QÕ7×=Ñ=Ó?×FÑFÀsÓK€IØ!Ô9ˆ9ÐC¸tÐCr#   c                óŒ   € V ^8„  d   QhR\         R,          R\        \        \        \        \        ,          ,          3,          /# )r%   Úmeshr(   r@   )r   r+   r)   r
   r   )r,   s   "r    r.   r.      s<   € ÷ Uñ UœeÐ$FÕGð UÌDÔQTÔV^Ô_dÔgjÕ_jÕVkÐQkÕLlñ Ur#   c                ó–  € \        V RR4      ;'       g    / p\        V\        4      '       d+   VP                  R4      ;'       g    VP                  R4      MRpVe,   \        P
                  P                  V4      '       d   RVRR/# V P                  RR7      pRV'       d#   \        P
                  P                  V4      RV/# R	RV/# )
z5Encode a trimesh mesh or scene object into GLB bytes.ÚmetadataNÚ	file_pathÚ	file_namer   r   r    rB   zmesh.glb)	Úgetattrr4   r+   r9   r:   r   r;   ÚexportrŒ   )r¬   r®   r   rX   s   &   r    r8   r8      s¬   € ä�t˜Z¨Ó.×4Ð4°"€HÜEOÐPXÔZ^×E_ÒE_ˆ8�<‰<˜Ó$×AÐA¨¯©°[Ó(AøÐei€DØÒœBŸG™GŸN™N¨4×0Ò0Ø˜˜g tÐ,Ð,Ø�[‰[ 5ˆ[Ó)€FØ¯d”B—G‘G×$Ñ$ TÓ*ÀGÈVÐTÐT¸
ÀGÈVÐTÐTr#   )"r:   Údataclassesr   r   Úior   Úpathlibr   Útypingr   r   r	   r
   r   Úpyarrowri   Ú r   Údownload.download_configr   Útabler   Úutils.file_utilsr   r   r   Úutils.py_utilsr   r3   rd   r   r   rO   r8   r”   r#   r    Ú<module>r½      s`   ðÛ 	ß (Ý Ý ß @Õ @ã å Ý 5Ý ß BÑ BÝ +÷ Ûå%ð ÷|1ð |1ó ð|1õ~D÷Ur#   