
    xiA#                     d    d Z ddlZddlmZ dadefdZdedefdZdedej                  fd	Z
d
Zy)aT  
Help content module for Gradio UI.

Provides a reusable inline help button + modal component that displays
i18n-sourced Markdown documentation within the Gradio interface.

The button is rendered as a pure-HTML ``<span>`` so it takes zero layout
space and can be placed inside any existing row or header without
creating extra blank rows.
    N)treturnc                  2    t         dz  a t        t               S )z;Return a unique DOM id suffix for each help modal instance.   )_help_counterstr     =/mnt/workspace/ACE-Step-1.5/acestep/ui/gradio/help_content.py_next_idr      s     QM}r
   md_textc                    ddl }| j                  d      }g }d}d}|D ]  }|j                         j                  d      r*|r|j	                  d       d}n|j	                  d       d}M|r|j	                  |       a|j                         }|r6|j                  d	      s%|j                  d
|      s|j	                  d       d}|j                  d      r,|j                  dd|dd       }|j	                  d| d       |j                  d      r-|j                  dd|dd       }|j	                  d| d       $|j                  d      rB|dd }	|j                  dd|	      }	|j                  dd|	      }	|j	                  d|	 d       w|j                  d	      s|j                  d|      r|s|j	                  d       d}|j                  dd|      }	|j                  dd|	      }	|j                  d d!|	      }	|j                  d"d#|	      }	|j                  dd|	      }	|j	                  d$|	 d%       %|s(|r|j	                  d       d}|j	                  d&       O|}
|j                  dd|
      }
|j                  d d!|
      }
|j                  d"d#|
      }
|j                  dd|
      }
|j	                  d'|
 d(        |r|j	                  d       |r|j	                  d       dj                  |      S ))a?  Convert Markdown to HTML with basic formatting.

    Handles headings, bold, italic, code blocks, lists, blockquotes,
    and paragraphs.  Intentionally lightweight so we avoid adding an
    external ``markdown`` dependency.

    Args:
        md_text: Markdown-formatted string.

    Returns:
        HTML string.
    r   N
Fz```z</code></pre>z<pre><code>Tz- z^\d+\.z</ul>z### z\[([^\]]+)\]\(([^)]+)\)zN<a href="\2" target="_blank" style="color:var(--color-accent,#4a9eff);">\1</a>   z<h4>z</h4>z##    z<h3>z</h3>z>    z\*\*(.+?)\*\*z<strong>\1</strong>zM<blockquote style="border-left:3px solid #888;padding-left:10px;color:#aaa;">z</blockquote>z^\d+\.\sz<ul style='padding-left:20px;'>z^-\s|^\d+\.\s z	\*(.+?)\*z<em>\1</em>z	`([^`]+)`z<code>\1</code>z<li>z</li>z<br/>z<p style='margin:4px 0;'>z</p>)resplitstrip
startswithappendmatchsubjoin)r   r   lines
html_partsin_codein_listlinestrippedheadingcontentps              r   _md_to_htmlr%      sB    MM$EJGG::<""5)!!/2!!-0d#::< 8..t4RXXiQY=Zg&G v&ff*aG
 WIU34u%ff*aG
 WIU34 t$qrlGff-/EwOGff*aG
 229-I  t$h(G!!"CDff-r8<Gff-/EwOGff\>7CGff\+=wGGff*aG
 WIU34 !!'*g& FF#%;Q?FF<3FF<!3Q7FF&]

 	5aS=>s v '"/*99Z  r
   section_keyc                     t               }d| }d| }t        d|        }t        |      }t        d      }t        j                  d| d| d| d| d	| d
| ddg      }|S )a  Create an inline (?) help button that opens a modal with documentation.

    The entire widget (button + hidden modal) is a single ``gr.HTML``
    component so it takes minimal layout space and can be placed inside
    any existing ``gr.Row`` without creating extra blank areas.

    Args:
        section_key: The i18n sub-key under ``help.`` (e.g. ``"generation_simple"``).

    Returns:
        The ``gr.HTML`` instance.
    zhelp-modal-z	help-btn-zhelp.zhelp.close_labelzB
        <span class="help-inline-wrapper">
          <button id="zN" class="help-inline-btn"
                  onclick="document.getElementById('zd').style.display='flex'"
                  title="Help">?</button>
        </span>
        <div id="a
  " class="help-modal-overlay" style="display:none;"
             onclick="if(event.target===this)this.style.display='none'">
          <div class="help-modal-content">
            <button class="help-modal-close"
                    onclick="document.getElementById('z(').style.display='none'">
              zO
            </button>
            <div class="help-modal-body">
              z<
            </div>
          </div>
        </div>
        zhelp-inline-container)valueelem_classes)r   r   r%   grHTML)r&   uidmodal_idbtn_id
md_contenthtml_contentclose_labelhtmls           r   create_help_buttonr3      s     *CSE"HFU;-()Jz*L&'K77h 55=J ?  7 8@j Am  n 	& ..)D. Kr
   a	  
/* ---- Inline help button container ---- */
.help-inline-container {
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    flex-shrink: 0 !important;
    max-width: 32px !important;
    min-width: 32px !important;
    overflow: visible !important;
}

.help-inline-wrapper {
    display: inline-flex;
    align-items: center;
    line-height: 1;
}

/* ---- Inline help button ---- */
.help-inline-btn {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1.5px solid var(--border-color-primary, #555);
    background: transparent;
    color: var(--body-text-color-subdued, #888);
    font-size: 12px;
    font-weight: 600;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    padding: 0;
    transition: all 0.15s ease;
    flex-shrink: 0;
}
.help-inline-btn:hover {
    background: var(--color-accent, #4a9eff);
    color: #fff;
    border-color: var(--color-accent, #4a9eff);
    transform: scale(1.1);
}

/* ---- Modal overlay ---- */
.help-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 100000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.help-modal-content {
    background: var(--background-fill-primary, #fff);
    color: var(--body-text-color, #222);
    border-radius: 12px;
    max-width: 640px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    position: relative;
}

.help-modal-close {
    position: absolute;
    top: 12px; right: 16px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--body-text-color, #222);
    z-index: 1;
    opacity: 0.6;
}
.help-modal-close:hover { opacity: 1; }

.help-modal-body {
    padding: 28px 32px;
    overflow-y: auto;
    line-height: 1.7;
    font-size: 0.92rem;
}
.help-modal-body h3 { margin: 16px 0 8px; font-size: 1.15rem; }
.help-modal-body h4 { margin: 12px 0 6px; font-size: 1.0rem; }
.help-modal-body pre {
    background: var(--background-fill-secondary, #f5f5f5);
    padding: 10px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 0.85rem;
}
.help-modal-body code {
    background: var(--background-fill-secondary, #f5f5f5);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.88em;
}
.help-modal-body ul { margin: 6px 0; }
.help-modal-body li { margin: 3px 0; }
)__doc__gradior*   acestep.ui.gradio.i18nr   r   r   r   r%   r+   r3   HELP_MODAL_CSSr	   r
   r   <module>r8      s\   	  $ # t! t! t!n+C +BGG +bhr
   