
    ri                         d dl Z d dlZd dlZd dlZd dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ d Zd Zed	        Zd
 Z G d dee      Zy)    N)UserDict)	lru_cache)quote)	docscrape)ReprHTMLMixinc                     | j                   }t        j                  | d|xs d      }|y|j                  d      }t	        |       dt	        |       }| d| S )zURL to the relevant section of the docstring using a Text Fragment

    https://developer.mozilla.org/en-US/docs/Web/URI/Reference/Fragment/Text_fragments
    z	 : (.+)\n N   z,-z	#:~:text=)__doc__researchgroupr   )estimator_class
param_namedoc_link	docstringm
param_typetext_fragments          ]/var/www/auto_recruiter/arenv/lib/python3.12/site-packages/sklearn/utils/_repr_html/params.py_generate_link_to_param_docr      sp    
  ''I
		ZL
+Y_"=Ay  JZ()E*,=+>?MZy00    c                     t        j                  |       } t        j                         }d|_        d|_        d|_        t        j                  |j                  |            }| |v rdnd}|| |dS )zCategorizes parameters as 'default' or 'user-set' and formats their values.
    Escapes or truncates parameter values for display safety and readability.
       r
   2   zuser-setdefault)r   r   param_value)htmlescapereprlibReprmaxlistmaxtuple	maxstringrepr)namevaluenon_default_paramsrcleaned_valuer   s         r   _read_paramsr+   &   sd     ;;tDAAIAJAKKKu.M#'99yJ$DWWr   c                 ,    t        j                  |       S N)r   NumpyDocString)r   s    r   _scrape_estimator_docstringr/   6   s    ##I..r   c           	         d}d}d}t        j                  | j                        }|r+t        |      x}r|d   D ci c]  }|j                  | }}ni }g }| D ]  }	t        |	| |	   | j                        }
t        | j                  |	| j                        }|j                  |	d      x}r8|j                   d|j                   ddj                  |j                         }nd}| j                  r|r|r|j                  ||
d	   |
      }n|
d	   }|j                   |j                  di |
d|i        |j                  dj                  |            S c c}w )a   Generate HTML representation of estimator parameters.

    Creates an HTML table with parameter names and values, wrapped in a
    collapsible details element. Parameters are styled differently based
    on whether they are default or user-set values.
    a/  
        <div class="estimator-table">
            <details>
                <summary>Parameters</summary>
                <table class="parameters-table">
                  <tbody>
                    {rows}
                  </tbody>
                </table>
            </details>
        </div>
    aW  
        <tr class="{param_type}">
            <td><i class="copy-paste-icon"
                 onclick="copyToClipboard('{param_name}',
                          this.parentElement.nextElementSibling)"
            ></i></td>
            <td class="param">{param_display}</td>
            <td class="value">{param_value}</td>
        </tr>
    z
        <a class="param-doc-link"
            rel="noreferrer" target="_blank" href="{link}">
            {param_name}
            <span class="param-doc-description">{param_description}</span>
        </a>
    
ParametersNz: z<br><br>z<br>r   )linkr   param_descriptionparam_display
)rows )inspectgetdocr   r/   r&   r+   non_defaultr   r   gettypejoindescformatappend)paramsPARAMS_TABLE_TEMPLATEPARAM_ROW_TEMPLATE!PARAM_AVAILABLE_DOC_LINK_TEMPLATEestimator_class_docsstructured_docstringparam_docstring	param_mapr6   rowparamr2   param_numpydocr3   r4   s                  r   _params_html_reprrL   ;   s   	)% #>>&*@*@A ;<P QQQ $8#E
   /1
	 

 	D US&+v/A/AB*6+A+A3X&]]355>5!&&'r.*=*=)>h;;~22346 
 !%??t(9=DD ."3 E M ",/M-&--SS]ST-U0 !''TYYt_'==?
s   Ec                   <     e Zd ZdZeZd e       ddd fd
Z xZS )
ParamsDictaQ  Dictionary-like class to store and provide an HTML representation.

    It builds an HTML structure to be used with Jupyter notebooks or similar
    environments. It allows storing metadata to track non-default parameters.

    Parameters
    ----------
    params : dict, default=None
        The original dictionary of parameters and their values.

    non_default : tuple, default=(,)
        The list of non-default parameters.

    estimator_class : type, default=None
        The class of the estimator. It allows to find the online documentation
        link for each parameter.

    doc_link : str, default=""
        The base URL to the online documentation for the estimator class.
        Used to generate parameter-specific documentation links in the HTML
        representation. If empty, documentation links will not be generated.
    Nr	   )rA   r:   r   r   c                V    t         |   |xs i        || _        || _        || _        y r-   )super__init__r:   r   r   )selfrA   r:   r   r   	__class__s        r   rQ   zParamsDict.__init__   s-     	2&&. r   )	__name__
__module____qualname__r   rL   
_html_reprtuplerQ   __classcell__)rS   s   @r   rN   rN      s'    . #J %'4RT! !r   rN   )r   r8   r   r    collectionsr   	functoolsr   urllib.parser   sklearn.externals._numpydocr   sklearn.utils._repr_html.baser   r   r+   r/   rL   rN   r7   r   r   <module>r_      sV      	      1 71,X  / /I>X !  !r   