Ë
    {�hùA  ã                   ó�   — d dl mZmZ d dlmZ d dlmZ  ej                  d«      Z	d„ Z
	 	 	 	 	 	 	 dd„Z	 	 	 	 	 	 	 	 	 	 	 	 	 	 d	d„Zy)
é    )Ú
exceptionsÚoptional_importsN)Ú
graph_objsÚnumpyc                 ó¦  — ||k\  rt        j                  d«      ‚t        |«      dk(  r1|d   }t        j                  |«      }t        j
                  |«      }|S | |k(  r1|d   }t        j                  |«      }t        j
                  |«      }|S |€�| |z
  t        ||z
  «      z  }t        |dt        |«      dz
  z  z  «      }t        j                  ||   ||dz      |t        |«      dz
  z  |z
  «      }t        j                  |«      }t        j
                  |«      }|S | |z
  t        ||z
  «      z  }d}t        t        |«      dz
  «      D ]   }||   |cxk  r||dz      k  rn n n|dz  }Œ" ||   }	||dz      }
t        j                  ||   ||dz      ||	z
  |
|	z
  z  «      }t        j                  |«      }t        j
                  |«      }|S )aN  
    Normalize facecolor values by vmin/vmax and return rgb-color strings

    This function takes a tuple color along with a colormap and a minimum
    (vmin) and maximum (vmax) range of possible mean distances for the
    given parametrized surface. It returns an rgb color based on the mean
    distance between vmin and vmax

    zmIncorrect relation between vmin and vmax. The vmin value cannot be bigger than or equal to the value of vmax.é   r   éÿÿÿÿg      ð?)
r   ÚPlotlyErrorÚlenÚclrsÚconvert_to_RGB_255Ú	label_rgbÚfloatÚintÚfind_intermediate_colorÚrange)ÚfaceÚcolormapÚscaleÚvminÚvmaxÚ
face_colorÚtÚlow_color_indexÚkÚlow_scale_valÚhigh_scale_vals              ú\/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/plotly/figure_factory/_trisurf.pyÚmap_face2colorr      s  € ð ˆt‚|Ü×$Ñ$ðó
ð 	
ô ˆ8ƒ}˜Òà˜a‘[ˆ
Ü×,Ñ,¨ZÓ8ˆ
Ü—^‘^ JÓ/ˆ
ØÐØˆt‚|à˜b‘\ˆ
Ü×,Ñ,¨ZÓ8ˆ
Ü—^‘^ JÓ/ˆ
ØÐàˆ=ð ˜‘¤ t¨d¡{Ó 4Ñ4ˆAÜ! ! s¬c°(«m¸aÑ.?Ñ'@Ñ"AÓBˆOä×5Ñ5Ø˜Ñ)Ø˜¨1Ñ,Ñ-Ø”S˜“] QÑ&Ñ'¨/Ñ9óˆJô ×0Ñ0°Ó<ˆJÜŸ™¨
Ó3ˆJð, Ðð' ˜‘¤ t¨d¡{Ó 4Ñ4ˆAàˆOÜœ3˜u›:¨™>Ó*ò %�Ø˜‘8˜qÔ/ 5¨¨Q©¡<Õ/ÙØ 1Ñ$‘ð%ð
 " /Ñ2ˆMØ" ?°QÑ#6Ñ7ˆNä×5Ñ5Ø˜Ñ)Ø˜¨1Ñ,Ñ-Ø�]Ñ" ~¸Ñ'EÑFóˆJô ×0Ñ0°Ó<ˆJÜŸ™¨
Ó3ˆJØÐó    c                 ó”
  — t         st        d«      ‚t         j                  | ||f«      j                  }t         j	                  |«      }||   }|€|dd…dd…df   j                  d«      }�nnt        |t        t         j                  f«      rßt        |«      t        |«      k7  rt        d«      ‚t        t        |«      «      D ]�  }t        ||   t        «      r7d||   v r0t        j                  ||   «      }t        j                  |«      ||<   t        ||   t         «      sŒat        j"                  ||   «      }t        j                  |«      ||<   Œ’ t         j%                  |«      }nog }|D ]S  }g }|D ]&  } ||d   |d   |d   «      }|j'                  |«       Œ( |j'                  t         j                  |«      «       ŒU t         j%                  |«      }t        |d   t        «      r|}njt         j)                  |«      }t         j+                  |«      }|€g }t        t        |«      «      D ]%  }t-        ||   ||||«      }|j'                  |«       Œ' t         j%                  |«      }|j                  \  }}}t/        j0                  | ||||||d	¬
«      }t        |d   t        «       }|rc|du r_t        j2                  ||«      }t        j4                  |«      }t/        j6                  | dd |dd |dd dt9        dg|d¬«      dd¬«      } |	du r|r|du r| gS |gS |
||fD �cg c]  }|du ‘Œ }!}t;        |!«      rt=        |!«      st        d«      ‚g }
g }g }g d¢}"|dd…|"dd…f   }#t         j?                  |#dd…dd…df   t         jA                  d|#jB                  d   dg«      g«      }$t         j?                  |#dd…dd…df   t         jA                  d|#jB                  d   dg«      g«      }%t         j?                  |#dd…dd…df   t         jA                  d|#jB                  d   dg«      g«      }&t         j?                  |
|$jE                  ddg«      d   g«      }
t         j?                  ||%jE                  ddg«      d   g«      }t         j?                  ||&jE                  ddg«      d   g«      }t        |
«      t        |«      cxk(  rt        |«      k(  sn tG        jH                  d«      ‚t/        j6                  |
||dt.        jJ                  jM                  |d¬«      d¬«      }'|r	|du r||' gS ||'gS c c}w )z?
    Refer to FigureFactory.create_trisurf() for docstring
    z1FigureFactory._trisurf() requires numpy imported.Né   r	   zGIf color_func is a list/array, it must be the same length as simplices.ú#r   r   Ú )ÚxÚyÚzÚ	facecolorÚiÚjr   ÚnameTÚmarkersgš™™™™™¹?)ÚsizeÚcolorÚ
colorscaleÚ	showscaleÚnoneF)r%   r&   r'   ÚmodeÚmarkerÚ	hoverinfoÚ
showlegendz9If any (x_edge, y_edge, z_edge) is None, all must be None)r   r   r"   r   z:The lengths of x_edge, y_edge and z_edge are not the same.Úlinesg      ø?)r.   Úwidth)r%   r&   r'   r2   Úliner5   )'ÚnpÚImportErrorÚvstackÚTÚ
atleast_2dÚmeanÚ
isinstanceÚlistÚndarrayr   Ú
ValueErrorr   Ústrr   Ú
hex_to_rgbr   Útupler   ÚasarrayÚappendÚminÚmaxr   r   ÚMesh3dÚmake_colorscaleÚconvert_colorscale_to_rgbÚ	Scatter3dÚdictÚanyÚallÚhstackÚtileÚshapeÚreshaper   r
   Ú	scatter3dÚLine)(r%   r&   r'   Ú	simplicesÚshow_colorbarÚedges_colorr   r   Ú
color_funcÚ
plot_edgesÚx_edgeÚy_edgeÚz_edger(   Úpoints3DÚtri_verticesÚ
mean_distsÚindexÚfooÚtriangleÚdistsÚvertexÚdistÚmin_mean_distsÚmax_mean_distsr.   ÚiiÚjjÚkkÚ	trianglesÚmean_dists_are_numbersr/   ÚcolorbarÚis_noneÚixs_trianglesÚ
pull_edgesÚx_edge_pullÚy_edge_pullÚz_edge_pullr6   s(                                           r   Útrisurfrv   L   sY  € õ( ÜÐPÓQÐQÜ�y‰y˜!˜Q ˜Ó#×%Ñ%€HÜ—‘˜iÓ(€Ið ˜IÑ&€Lð Ðà!¢!¢Q¨ 'Ñ*×/Ñ/°Ó3Š
Ü	�J¤¤r§z¡zÐ 2Ô	3äˆz‹?œc )›nÒ,Üð3óð ô œ3˜z›?Ó+ò 	8ˆEÜ˜* UÑ+¬SÔ1Ø˜* UÑ+Ñ+ÜŸ/™/¨*°UÑ*;Ó<�CÜ(,¯©°sÓ(;�J˜uÑ%ä˜* UÑ+¬UÕ3Ü×-Ñ-¨j¸Ñ.?Ó@�Ü$(§N¡N°3Ó$7�
˜5Ò!ð	8ô —Z‘Z 
Ó+‰
ð ˆ
Ø$ò 	.ˆHØˆEØ"ò #�Ù! &¨¡)¨V°A©Y¸¸q¹	ÓB�Ø—‘˜TÕ"ð#ð ×ÑœbŸg™g e›nÕ-ð	.ô —Z‘Z 
Ó+ˆ
ô �*˜Q‘-¤Ô%Ø‰	äŸ™ 
Ó+ˆÜŸ™ 
Ó+ˆàÐØˆIÜœ3˜z›?Ó+ò 	$ˆEÜ"Ø˜5Ñ! 8¨U°NÀNóˆEð ×Ñ˜UÕ#ð		$ô —
‘
˜9Ó%€IØ—‘�J€BˆˆBä×!Ñ!Ø
ˆq�A ¨b°B¸"À2ô€Iô ",¨J°q©M¼3Ó!?Ð?Ðá -°4Ñ"7ä×)Ñ)¨(°EÓ:ˆ
Ü×3Ñ3°JÓ?ˆ
ä×'Ñ'Ø��ˆeØ��ˆeØ��ˆeØÜØØ% ~Ð6Ø%Øô	ð Øô
ˆð  �UÑÙ! m°tÑ&;Ø˜xÐ(Ð(à�;Ðð
 &,¨V°VÐ$<Ö=˜bˆr�TŠzÐ=€GÐ=Ü
ˆ7„|Ü�7Œ|ÜØNóð ð ˆFØˆFØˆFò !€MØša ²Ð1Ñ2€JÜ—)‘)Ø	’A’q˜!�GÑ	œbŸg™g d¨Z×-=Ñ-=¸aÑ-@À!Ð,DÓEÐFó€Kô —)‘)Ø	’A’q˜!�GÑ	œbŸg™g d¨Z×-=Ñ-=¸aÑ-@À!Ð,DÓEÐFó€Kô —)‘)Ø	’A’q˜!�GÑ	œbŸg™g d¨Z×-=Ñ-=¸aÑ-@À!Ð,DÓEÐFó€Kô
 �Y‰Y˜ × 3Ñ 3°Q¸°GÓ <¸QÑ ?Ð@ÓA€FÜ�Y‰Y˜ × 3Ñ 3°Q¸°GÓ <¸QÑ ?Ð@ÓA€FÜ�Y‰Y˜ × 3Ñ 3°Q¸°GÓ <¸QÑ ?Ð@ÓA€Fä�‹Kœ3˜v›;Ô5¬#¨f«+Ô5Ü×$Ñ$ØKó
ð 	
ô
 × Ñ Ø
Ø
Ø
ØÜ×!Ñ!×&Ñ&¨[ÀÐ&ÓDØô€Eñ  -°4Ñ"7Ø˜5 (Ð+Ð+à˜5Ð!Ð!ùò_ >s   Ì.Uc                 ór  — |€ddddœ}t        j                  |«       t        j                  |dd|¬«      \  }}t        | |||||||||	¬«
      }t	        |
|||¬«      }t        j                  |||t
        j                  j                  t        j                  j                  j                  di |¤Žt        j                  j                  j                  di |¤Žt        j                  j                  j                  di |¤Žt	        |d   |d	   |d
   ¬«      ¬«      ¬«      }t        j                  ||¬«      S )a]  
    Returns figure for a triangulated surface plot

    :param (array) x: data values of x in a 1D array
    :param (array) y: data values of y in a 1D array
    :param (array) z: data values of z in a 1D array
    :param (array) simplices: an array of shape (ntri, 3) where ntri is
        the number of triangles in the triangularization. Each row of the
        array contains the indicies of the verticies of each triangle
    :param (str|tuple|list) colormap: either a plotly scale name, an rgb
        or hex color, a color tuple or a list of colors. An rgb color is
        of the form 'rgb(x, y, z)' where x, y, z belong to the interval
        [0, 255] and a color tuple is a tuple of the form (a, b, c) where
        a, b and c belong to [0, 1]. If colormap is a list, it must
        contain the valid color types aforementioned as its members
    :param (bool) show_colorbar: determines if colorbar is visible
    :param (list|array) scale: sets the scale values to be used if a non-
        linearly interpolated colormap is desired. If left as None, a
        linear interpolation between the colors will be excecuted
    :param (function|list) color_func: The parameter that determines the
        coloring of the surface. Takes either a function with 3 arguments
        x, y, z or a list/array of color values the same length as
        simplices. If None, coloring will only depend on the z axis
    :param (str) title: title of the plot
    :param (bool) plot_edges: determines if the triangles on the trisurf
        are visible
    :param (bool) showbackground: makes background in plot visible
    :param (str) backgroundcolor: color of background. Takes a string of
        the form 'rgb(x,y,z)' x,y,z are between 0 and 255 inclusive
    :param (str) gridcolor: color of the gridlines besides the axes. Takes
        a string of the form 'rgb(x,y,z)' x,y,z are between 0 and 255
        inclusive
    :param (str) zerolinecolor: color of the axes. Takes a string of the
        form 'rgb(x,y,z)' x,y,z are between 0 and 255 inclusive
    :param (str) edges_color: color of the edges, if plot_edges is True
    :param (int|float) height: the height of the plot (in pixels)
    :param (int|float) width: the width of the plot (in pixels)
    :param (dict) aspectratio: a dictionary of the aspect ratio values for
        the x, y and z axes. 'x', 'y' and 'z' take (int|float) values

    Example 1: Sphere

    >>> # Necessary Imports for Trisurf
    >>> import numpy as np
    >>> from scipy.spatial import Delaunay

    >>> from plotly.figure_factory import create_trisurf
    >>> from plotly.graph_objs import graph_objs

    >>> # Make data for plot
    >>> u = np.linspace(0, 2*np.pi, 20)
    >>> v = np.linspace(0, np.pi, 20)
    >>> u,v = np.meshgrid(u,v)
    >>> u = u.flatten()
    >>> v = v.flatten()

    >>> x = np.sin(v)*np.cos(u)
    >>> y = np.sin(v)*np.sin(u)
    >>> z = np.cos(v)

    >>> points2D = np.vstack([u,v]).T
    >>> tri = Delaunay(points2D)
    >>> simplices = tri.simplices

    >>> # Create a figure
    >>> fig1 = create_trisurf(x=x, y=y, z=z, colormap="Rainbow",
    ...                       simplices=simplices)

    Example 2: Torus

    >>> # Necessary Imports for Trisurf
    >>> import numpy as np
    >>> from scipy.spatial import Delaunay

    >>> from plotly.figure_factory import create_trisurf
    >>> from plotly.graph_objs import graph_objs

    >>> # Make data for plot
    >>> u = np.linspace(0, 2*np.pi, 20)
    >>> v = np.linspace(0, 2*np.pi, 20)
    >>> u,v = np.meshgrid(u,v)
    >>> u = u.flatten()
    >>> v = v.flatten()

    >>> x = (3 + (np.cos(v)))*np.cos(u)
    >>> y = (3 + (np.cos(v)))*np.sin(u)
    >>> z = np.sin(v)

    >>> points2D = np.vstack([u,v]).T
    >>> tri = Delaunay(points2D)
    >>> simplices = tri.simplices

    >>> # Create a figure
    >>> fig1 = create_trisurf(x=x, y=y, z=z, colormap="Viridis",
    ...                       simplices=simplices)

    Example 3: Mobius Band

    >>> # Necessary Imports for Trisurf
    >>> import numpy as np
    >>> from scipy.spatial import Delaunay

    >>> from plotly.figure_factory import create_trisurf
    >>> from plotly.graph_objs import graph_objs

    >>> # Make data for plot
    >>> u = np.linspace(0, 2*np.pi, 24)
    >>> v = np.linspace(-1, 1, 8)
    >>> u,v = np.meshgrid(u,v)
    >>> u = u.flatten()
    >>> v = v.flatten()

    >>> tp = 1 + 0.5*v*np.cos(u/2.)
    >>> x = tp*np.cos(u)
    >>> y = tp*np.sin(u)
    >>> z = 0.5*v*np.sin(u/2.)

    >>> points2D = np.vstack([u,v]).T
    >>> tri = Delaunay(points2D)
    >>> simplices = tri.simplices

    >>> # Create a figure
    >>> fig1 = create_trisurf(x=x, y=y, z=z, colormap=[(0.2, 0.4, 0.6), (1, 1, 1)],
    ...                       simplices=simplices)

    Example 4: Using a Custom Colormap Function with Light Cone

    >>> # Necessary Imports for Trisurf
    >>> import numpy as np
    >>> from scipy.spatial import Delaunay

    >>> from plotly.figure_factory import create_trisurf
    >>> from plotly.graph_objs import graph_objs

    >>> # Make data for plot
    >>> u=np.linspace(-np.pi, np.pi, 30)
    >>> v=np.linspace(-np.pi, np.pi, 30)
    >>> u,v=np.meshgrid(u,v)
    >>> u=u.flatten()
    >>> v=v.flatten()

    >>> x = u
    >>> y = u*np.cos(v)
    >>> z = u*np.sin(v)

    >>> points2D = np.vstack([u,v]).T
    >>> tri = Delaunay(points2D)
    >>> simplices = tri.simplices

    >>> # Define distance function
    >>> def dist_origin(x, y, z):
    ...     return np.sqrt((1.0 * x)**2 + (1.0 * y)**2 + (1.0 * z)**2)

    >>> # Create a figure
    >>> fig1 = create_trisurf(x=x, y=y, z=z,
    ...                       colormap=['#FFFFFF', '#E4FFFE',
    ...                                 '#A4F6F9', '#FF99FE',
    ...                                 '#BA52ED'],
    ...                       scale=[0, 0.6, 0.71, 0.89, 1],
    ...                       simplices=simplices,
    ...                       color_func=dist_origin)

    Example 5: Enter color_func as a list of colors

    >>> # Necessary Imports for Trisurf
    >>> import numpy as np
    >>> from scipy.spatial import Delaunay
    >>> import random

    >>> from plotly.figure_factory import create_trisurf
    >>> from plotly.graph_objs import graph_objs

    >>> # Make data for plot
    >>> u=np.linspace(-np.pi, np.pi, 30)
    >>> v=np.linspace(-np.pi, np.pi, 30)
    >>> u,v=np.meshgrid(u,v)
    >>> u=u.flatten()
    >>> v=v.flatten()

    >>> x = u
    >>> y = u*np.cos(v)
    >>> z = u*np.sin(v)

    >>> points2D = np.vstack([u,v]).T
    >>> tri = Delaunay(points2D)
    >>> simplices = tri.simplices


    >>> colors = []
    >>> color_choices = ['rgb(0, 0, 0)', '#6c4774', '#d6c7dd']

    >>> for index in range(len(simplices)):
    ...     colors.append(random.choice(color_choices))

    >>> fig = create_trisurf(
    ...     x, y, z, simplices,
    ...     color_func=colors,
    ...     show_colorbar=True,
    ...     edges_color='rgb(2, 85, 180)',
    ...     title=' Modern Art'
    ... )
    r   )r%   r&   r'   rE   T)Ú	colortypeÚreturn_default_colorsr   )rX   rZ   r   r   rY   r[   )ÚshowbackgroundÚbackgroundcolorÚ	gridcolorÚzerolinecolorr%   r&   r'   )ÚxaxisÚyaxisÚzaxisÚaspectratio)Útitler7   ÚheightÚscene)ÚdataÚlayout© )r   Úvalidate_colorsÚconvert_colors_to_same_typerv   rN   r   ÚLayoutr†   ÚScener„   ÚXAxisÚYAxisÚZAxisÚFigure)r%   r&   r'   rW   r   rX   r   rZ   r‚   r[   rz   r{   r|   r}   rY   rƒ   r7   r�   Údata1Úaxisr†   s                        r   Úcreate_trisurfr’   õ   sD  € ð| ÐØ A¨AÑ.ˆô 	×Ñ˜Ô"Ü×6Ñ6Ø˜G¸4Àuô�O€Hˆeô Ø	Ø	Ø	ØØ#ØØØØØô€Eô Ø%Ø'ØØ#ô	€Dô ×ÑØØØÜ×Ñ×%Ñ%Ü×#Ñ#×)Ñ)×/Ñ/Ñ7°$Ñ7Ü×#Ñ#×)Ñ)×/Ñ/Ñ7°$Ñ7Ü×#Ñ#×)Ñ)×/Ñ/Ñ7°$Ñ7ÜØ˜cÑ" k°#Ñ&6¸+ÀcÑ:Jôð	 &ó 
ô	€Fô ×Ñ %°Ô7Ð7r    )NNFNNNN)NTNNzTrisurf PlotTTzrgb(230, 230, 230)úrgb(255, 255, 255)r“   zrgb(50, 50, 50)é   r”   N)Úplotlyr   r   Úplotly.colorsÚcolorsr   Úplotly.graph_objsr   Ú
get_moduler9   r   rv   r’   r‡   r    r   ú<module>rš      sx   ðß /Ý Ý (à Ð× Ñ  Ó)€òAðX ØØØØØØóf"ð\ ØØ
ØØ
ØØØ(Ø"Ø&Ø!ØØ
Øô%H8r    