import { f as fallback } from './async-Djx13DAD.js';
import { d as attr_class, e as ensure_array_like, g as attr_style, j as stringify, a as attr, c as bind_props, b as spread_props } from './index-B7gr0Dsc.js';
import './2-CeYbpaU1.js';
import { g } from './utils.svelte-D8Xdzglu.js';
import { c } from './BlockTitle-CMSrY_fB.js';
import { w } from './IconButton-7VBZdgpA.js';
import './MarkdownCode.svelte_svelte_type_style_lang-DJRtJayx.js';
import { e as e$1 } from './Check-THd8EJll.js';
import { h } from './Copy-DNPvPwdp.js';
import { M } from './Send-DqNOmoCe.js';
import { r } from './Trash-D-m4iX81.js';
import { y } from './IconButtonWrapper-DlgTGGi-.js';
import { S } from './Dropdown-DGqyxorx.js';
import { G } from './Block-2-03Azgw.js';
import { R } from './index3-DONAw0dG.js';
export { default as BaseExample } from './Example15-D_izSv7J.js';
import { e as escape_html } from './escaping-CBnpiEl5.js';
import './context-BZS6UlnY.js';
import './uneval-DjLoL4oF.js';
import './clone-BLo8hHdj.js';
import './index5-BoOEKc6P.js';
import './dev-fallback-Bc5Ork7Y.js';
import './Info-D8EmJbKn.js';
import './MarkdownCode-zMHESTz4.js';
import './index35-D6cyUa2I.js';
import 'path';
import 'url';
import 'fs';
import './prism-python-BaDPvmdn.js';
import './spring-DyDQVd5U.js';
import './Clear-CiR-WD8W.js';

function e(o){o.push('<svg width="100%" height="100%" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6 12H12M18 12H12M12 12V6M12 12V18" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg>');}

function X(n,e){n.component(c=>{let m=e.label,d=fallback(e.checked,false),h=fallback(e.disabled,false);c.push(`<div class="s s--slider svelte-1io85vl" style="font-size:var(--font-size-sm)px"><button role="switch"${attr("aria-checked",d)}${attr("disabled",h,true)} class="svelte-1io85vl"></button> <span>${escape_html(m)}</span></div>`),bind_props(e,{label:m,checked:d,disabled:h});});}function Y(n,e$2){n.component(c$1=>{const{$$slots:m,$$events:d,...h$1}=e$2,t=h$1.gradio;let i=false,p=!t.shared.interactive,v=[],f=t.props.buttons||["copy"],I=s=>{t.dispatch("custom_button_click",{id:s});};t.props.value;let b=false,g,_="",S$1=null,y$1=false,D=false;const C=["red","green","blue","yellow","purple","teal","orange","cyan","lime","pink"],E={red:"rgba(254, 202, 202, 0.7)",green:"rgba(209, 250, 229, 0.7)",blue:"rgba(219, 234, 254, 0.7)",yellow:"rgba(254, 243, 199, 0.7)",purple:"rgba(233, 213, 255, 0.7)",teal:"rgba(204, 251, 241, 0.7)",orange:"rgba(254, 215, 170, 0.7)",cyan:"rgba(207, 250, 254, 0.7)",lime:"rgba(217, 249, 157, 0.7)",pink:"rgba(252, 231, 243, 0.7)"};let N=(()=>{let s={};return t.props.color_map?s={...t.props.color_map}:(s={},t.props.speakers.forEach((o,l)=>{const x=C[l%C.length];s[o]=E[x];})),s})();function P(s,o,l){v[s][o]=l,v=[...v],t.props.value=[...v];}async function B(s){return typeof s=="string"?s:await t.shared.server.format(s)}async function z(){if("clipboard"in navigator){const s=await B(t.props.value);await navigator.clipboard.writeText(s),G();}}function G(){b=true,g&&clearTimeout(g),g=setTimeout(()=>{b=false;},1e3);}let k=true,w$1;function A(s$1){if(s$1.push(`<div${attr_class("svelte-1p54cvv",void 0,{container:t.shared.container})}>`),t.shared.show_label&&(f.some(o=>typeof o=="string"&&o==="copy")||f.some(o=>typeof o!="string"))?(s$1.push("<!--[-->"),y(s$1,{buttons:f,on_custom_button_click:I,children:o=>{f.some(l=>typeof l=="string"&&l==="copy")?(o.push("<!--[-->"),w(o,{Icon:b?e$1:h,onclick:z,label:b?"Copied":"Copy"})):o.push("<!--[!-->"),o.push("<!--]-->");}})):s$1.push("<!--[!-->"),s$1.push("<!--]--> "),c(s$1,{show_label:t.shared.show_label,info:t.props.info,children:o=>{o.push(`<!---->${escape_html(t.shared.label||"Dialogue")}`);},$$slots:{default:true}}),s$1.push("<!----> "),t.props.ui_mode==="both"?(s$1.push("<!--[-->"),s$1.push(`<div${attr_class("switch-container top-switch svelte-1p54cvv",void 0,{"switch-disabled":y$1})}>`),X(s$1,{label:"Plain Text",disabled:y$1,get checked(){return i},set checked(o){i=o,k=false;}}),s$1.push("<!----></div>")):s$1.push("<!--[!-->"),s$1.push("<!--]--> "),!i&&t.props.ui_mode!=="text"){s$1.push("<!--[-->"),s$1.push(`<div${attr_class("dialogue-container svelte-1p54cvv",void 0,{loading:y$1})}>`),s$1.push("<!--[!-->"),s$1.push("<!--]--> <!--[-->");const o=ensure_array_like(v);for(let l=0,x=o.length;l<x;l++){let r$1=o[l];if(s$1.push(`<div class="dialogue-line svelte-1p54cvv"${attr_style(`--speaker-bg-color: ${stringify(p&&S$1===null&&N[r$1.speaker]||"transparent")}`)}><div class="speaker-column svelte-1p54cvv" role="button" tabindex="0">`),p){s$1.push("<!--[-->"),s$1.push(`<textarea${attr("disabled",p,true)} rows="1" readonly class="svelte-1p54cvv">`);const u=escape_html(r$1.speaker);u&&s$1.push(`${u}`),s$1.push("</textarea>");}else s$1.push("<!--[!-->"),S(s$1,{label:"",show_label:false,container:true,interactive:true,value:r$1.speaker,choices:t.props.speakers.map(u=>[u,u]),on_change:u=>P(l,"speaker",u)});s$1.push(`<!--]--></div> <div class="text-column svelte-1p54cvv"><div class="input-container svelte-1p54cvv"><textarea${attr("placeholder",t.props.placeholder)}${attr("disabled",p,true)} rows="1" class="svelte-1p54cvv">`);const T=escape_html(r$1.text);T&&s$1.push(`${T}`),s$1.push("</textarea> "),s$1.push("<!--[!-->"),s$1.push("<!--]--></div></div> "),t.props.max_lines==null||t.props.max_lines&&l<t.props.max_lines-1?(s$1.push("<!--[-->"),s$1.push(`<div${attr_class("svelte-1p54cvv",void 0,{"action-column":l==0,hidden:p})}><button class="add-button svelte-1p54cvv" aria-label="Add new line"${attr("disabled",p,true)}>`),e(s$1),s$1.push("<!----></button></div>")):s$1.push("<!--[!-->"),s$1.push(`<!--]--> <div${attr_class("action-column svelte-1p54cvv",void 0,{hidden:p||l==0})}><button class="delete-button svelte-1p54cvv" aria-label="Remove current line"${attr("disabled",p,true)}>`),r(s$1),s$1.push("<!----></button></div></div>");}s$1.push("<!--]--></div>");}else {if(s$1.push("<!--[!-->"),i||t.props.ui_mode!=="dialogue"){s$1.push("<!--[-->"),s$1.push(`<div${attr_class("textarea-container svelte-1p54cvv",void 0,{loading:D})}>`),s$1.push("<!--[!-->"),s$1.push(`<!--]--> <textarea data-testid="textbox"${attr("placeholder",t.props.placeholder)}${attr("rows",5)}${attr("disabled",p,true)} class="svelte-1p54cvv">`);const o=escape_html(_);o&&s$1.push(`${o}`),s$1.push("</textarea> "),s$1.push("<!--[!-->"),s$1.push("<!--]--></div>");}else s$1.push("<!--[!-->");s$1.push("<!--]-->");}s$1.push("<!--]--> "),t.props.submit_btn&&!p?(s$1.push("<!--[-->"),s$1.push(`<div class="submit-container svelte-1p54cvv"><button class="submit-button svelte-1p54cvv"${attr("disabled",p,true)}>`),typeof t.props.submit_btn=="string"?(s$1.push("<!--[-->"),s$1.push(`${escape_html(t.props.submit_btn)}`)):(s$1.push("<!--[!-->"),M(s$1)),s$1.push("<!--]--></button></div>")):s$1.push("<!--[!-->"),s$1.push("<!--]--></div>");}do k=true,w$1=c$1.copy(),A(w$1);while(!k);c$1.subsume(w$1);});}function gs(n,e){n.component(c=>{const{$$slots:m,$$events:d,...h}=e,t=new g(h);G(c,{visible:t.shared.visible,elem_id:t.shared.elem_id,elem_classes:t.shared.elem_classes,scale:t.shared.scale,min_width:t.shared.min_width,allow_overflow:true,padding:t.shared.container,children:i=>{t.shared.loading_status?(i.push("<!--[-->"),R(i,spread_props([{autoscroll:t.shared.autoscroll,i18n:t.i18n},t.shared.loading_status,{on_clear_status:()=>t.dispatch("clear_status",t.shared.loading_status)}]))):i.push("<!--[!-->"),i.push("<!--]--> "),Y(i,{gradio:t}),i.push("<!---->");},$$slots:{default:true}});});}

export { Y as BaseDialogue, gs as default };
//# sourceMappingURL=Index50-IYMBgMuk.js.map
