import"./IconButtonWrapper.svelte_svelte_type_style_lang-BOpxTcdu.js";import{u as gl,S as po,a as vo}from"./utils-BsGrhMNe.js";import{I as Yt}from"./Image-CsmDAdIf.js";import"./MarkdownCode.svelte_svelte_type_style_lang-3tofWDHK.js";/* empty css *//* empty css */import{I as le}from"./IconButton-B-aAVSzy.js";import{C as Jt}from"./Check-BiRlaMNo.js";import{C as rn}from"./Copy-CxQ9EyK2.js";import{C as $o}from"./Clear-By3xiIwg.js";import{E as Co}from"./Edit-BpRIf5rU.js";import{U as yo}from"./Undo-DCjBnnSO.js";import{I as Ki}from"./IconButtonWrapper-Cg16aIPK.js";import{F as tl}from"./File-BQ_9P3Ye.js";import{M as nl}from"./MarkdownCode-DJM7o_VY.js";import{s as bl}from"./index-CvpmwOJi.js";import{d as zo}from"./index-CnqicUFC.js";import{C as So}from"./Community-Dw1micSV.js";import{T as Ho}from"./Trash-RbZEwH-j.js";import{M as Qi}from"./Music-CDm0RGMk.js";import{B as qo}from"./Block-DZqtZLFP.js";import{B as Lo}from"./BlockLabel-DqHge3FF.js";import{S as jo}from"./index-B1gfMDT9.js";import"./StreamingBar.svelte_svelte_type_style_lang-CDNxkBIr.js";import"./file-url-DgijyRSD.js";import"./context-TgWPFwN2.js";import"./prism-python-qapVsvY8.js";import"./index-C7PS0jJm.js";import"./svelte/svelte.js";const{SvelteComponent:Mo,append:wl,attr:fe,detach:No,init:Vo,insert:Do,noop:jn,safe_not_equal:Io,svg_element:Mn}=window.__gradio__svelte__internal;function Bo(l){let e,t,n;return{c(){e=Mn("svg"),t=Mn("path"),n=Mn("path"),fe(t,"fill","currentColor"),fe(t,"d","M17.74 30L16 29l4-7h6a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h9v2H6a4 4 0 0 1-4-4V8a4 4 0 0 1 4-4h20a4 4 0 0 1 4 4v12a4 4 0 0 1-4 4h-4.84Z"),fe(n,"fill","currentColor"),fe(n,"d","M8 10h16v2H8zm0 6h10v2H8z"),fe(e,"xmlns","http://www.w3.org/2000/svg"),fe(e,"xmlns:xlink","http://www.w3.org/1999/xlink"),fe(e,"aria-hidden","true"),fe(e,"role","img"),fe(e,"class","iconify iconify--carbon"),fe(e,"width","100%"),fe(e,"height","100%"),fe(e,"preserveAspectRatio","xMidYMid meet"),fe(e,"viewBox","0 0 32 32")},m(i,s){Do(i,e,s),wl(e,t),wl(e,n)},p:jn,i:jn,o:jn,d(i){i&&No(e)}}}class Eo extends Mo{constructor(e){super(),Vo(this,e,null,Bo,Io,{})}}const{SvelteComponent:Ao,append:kl,attr:He,detach:To,init:Fo,insert:Zo,noop:Nn,safe_not_equal:Uo,svg_element:Vn}=window.__gradio__svelte__internal;function Po(l){let e,t,n;return{c(){e=Vn("svg"),t=Vn("circle"),n=Vn("path"),He(t,"cx","9"),He(t,"cy","9"),He(t,"r","8"),He(t,"class","circle svelte-1m886t3"),He(n,"d","M5 8l4 4 4-4z"),He(e,"class","dropdown-arrow svelte-1m886t3"),He(e,"xmlns","http://www.w3.org/2000/svg"),He(e,"width","100%"),He(e,"height","100%"),He(e,"viewBox","0 0 18 18")},m(i,s){Zo(i,e,s),kl(e,t),kl(e,n)},p:Nn,i:Nn,o:Nn,d(i){i&&To(e)}}}class Ro extends Ao{constructor(e){super(),Fo(this,e,null,Po,Uo,{})}}const{SvelteComponent:Oo,append:tn,attr:V,detach:Jo,init:Wo,insert:Go,noop:Dn,safe_not_equal:Yo,svg_element:Rt}=window.__gradio__svelte__internal;function Ko(l){let e,t,n,i,s;return{c(){e=Rt("svg"),t=Rt("path"),n=Rt("path"),i=Rt("path"),s=Rt("path"),V(t,"d","M19.1679 9C18.0247 6.46819 15.3006 4.5 11.9999 4.5C8.31459 4.5 5.05104 7.44668 4.54932 11"),V(t,"stroke","currentColor"),V(t,"stroke-width","1.5"),V(t,"stroke-linecap","round"),V(t,"stroke-linejoin","round"),V(n,"d","M16 9H19.4C19.7314 9 20 8.73137 20 8.4V5"),V(n,"stroke","currentColor"),V(n,"stroke-width","1.5"),V(n,"stroke-linecap","round"),V(n,"stroke-linejoin","round"),V(i,"d","M4.88146 15C5.92458 17.5318 8.64874 19.5 12.0494 19.5C15.7347 19.5 18.9983 16.5533 19.5 13"),V(i,"stroke","currentColor"),V(i,"stroke-width","1.5"),V(i,"stroke-linecap","round"),V(i,"stroke-linejoin","round"),V(s,"d","M8.04932 15H4.64932C4.31795 15 4.04932 15.2686 4.04932 15.6V19"),V(s,"stroke","currentColor"),V(s,"stroke-width","1.5"),V(s,"stroke-linecap","round"),V(s,"stroke-linejoin","round"),V(e,"width","100%"),V(e,"height","100%"),V(e,"stroke-width","1.5"),V(e,"viewBox","0 0 24 24"),V(e,"fill","none"),V(e,"xmlns","http://www.w3.org/2000/svg"),V(e,"color","currentColor")},m(o,r){Go(o,e,r),tn(e,t),tn(e,n),tn(e,i),tn(e,s)},p:Dn,i:Dn,o:Dn,d(o){o&&Jo(e)}}}class Qo extends Oo{constructor(e){super(),Wo(this,e,null,Ko,Yo,{})}}const{SvelteComponent:Xo,append:xo,attr:qe,detach:es,init:ts,insert:ns,noop:In,safe_not_equal:ls,svg_element:pl}=window.__gradio__svelte__internal;function is(l){let e,t;return{c(){e=pl("svg"),t=pl("path"),qe(t,"d","M12 20L12 4M12 20L7 15M12 20L17 15"),qe(t,"stroke","currentColor"),qe(t,"stroke-width","2"),qe(t,"stroke-linecap","round"),qe(t,"stroke-linejoin","round"),qe(e,"width","100%"),qe(e,"height","100%"),qe(e,"viewBox","0 0 24 24"),qe(e,"fill","none"),qe(e,"xmlns","http://www.w3.org/2000/svg")},m(n,i){ns(n,e,i),xo(e,t)},p:In,i:In,o:In,d(n){n&&es(e)}}}class os extends Xo{constructor(e){super(),ts(this,e,null,is,ls,{})}}const ss=async(l,e=1800)=>{let t=[...l],n=await Bn(t);if(n.length>e&&t.length>2){const i=t[0],s=t[t.length-1];t=[i,s],n=await Bn(t)}return n.length>e&&t.length>0&&(t=t.map(s=>{if(s.type==="text"){const o=Math.floor(e/t.length)-20;if(s.content.length>o)return{...s,content:s.content.substring(0,o)+"..."}}return s}),n=await Bn(t)),n},Bn=async l=>(await Promise.all(l.map(async t=>{if(t.role==="system")return"";let n=t.role==="user"?"😃":"🤖",i="";if(t.type==="text"){const s={audio:/|!\[.*?\]\((\/file=.*?)\)/g};i=t.content;for(let[o,r]of Object.entries(s)){let a;for(;(a=r.exec(t.content))!==null;){const _=a[1]||a[2],u=await gl(_);i=i.replace(_,u)}}}else{if(!t.content.value)return"";const s=t.content.component==="video"?t.content.value?.video.path:t.content.value,o=await gl(s);t.content.component==="audio"?i=``:t.content.component==="video"?i=o:t.content.component==="image"&&(i=`
`)}return`${n}: ${i}`}))).filter(t=>t!=="").join(`
`),Xi=(l,e)=>l.replace('src="/file',`src="${e}file`);function as(l){return l?l.includes("audio")?"audio":l.includes("video")?"video":l.includes("image")?"image":"file":"file"}function xi(l){const e=Array.isArray(l.file)?l.file[0]:l.file;return{component:as(e?.mime_type),value:l.file,alt_text:l.alt_text,constructor_args:{},props:{}}}function rs(l,e){if(l===null)return l;const t=new Map;return l.map((n,i)=>{let s=typeof n.content=="string"?{role:n.role,metadata:n.metadata,content:Xi(n.content,e),type:"text",index:i,options:n.options}:"file"in n.content?{content:xi(n.content),metadata:n.metadata,role:n.role,type:"component",index:i,options:n.options}:{type:"component",...n};const{id:o,title:r,parent_id:a}=n.metadata||{};if(a){const _=t.get(String(a));if(_){const u={...s,children:[]};return _.children.push(u),o&&r&&t.set(String(o),u),null}}if(o&&r){const _={...s,children:[]};return t.set(String(o),_),_}return s}).filter(n=>n!==null)}function _s(l,e){return l===null?l:l.flatMap((n,i)=>n.map((s,o)=>{if(s==null)return null;const r=o==0?"user":"assistant";return typeof s=="string"?{role:r,type:"text",content:Xi(s,e),metadata:{title:null},index:[i,o]}:"file"in s?{content:xi(s),role:r,type:"component",index:[i,o]}:{role:r,content:s,type:"component",index:[i,o]}})).filter(n=>n!=null)}function vl(l){return l.type==="component"}function nn(l,e){const t=l[l.length-1].role==="assistant",n=l[l.length-1].index;return JSON.stringify(n)===JSON.stringify(e[e.length-1].index)&&t}function us(l,e){const t=[];let n=[],i=null;for(const s of l)(s.role==="assistant"||s.role==="user")&&(s.role===i?n.push(s):(n.length>0&&t.push(n),n=[s],i=s.role));return n.length>0&&t.push(n),t}async function fs(l,e,t){let n=[],i=[];return l.forEach(o=>{if(e[o]||o==="file")return;const r=o==="dataframe"?"component":"base",{name:a,component:_}=t(o,r);n.push(a),i.push(_)}),(await Promise.all(i)).forEach((o,r)=>{e[n[r]]=o.default}),e}function cs(l){if(!l)return[];let e=new Set;return l.forEach(t=>{t.type==="component"&&e.add(t.content.component)}),Array.from(e)}function Wn(l,e=0){let t="";const n=" ".repeat(e);l.metadata?.title&&(t+=`${n}${e>0?"- ":""}${l.metadata.title}
`),typeof l.content=="string"&&(t+=`${n} ${l.content}
`);const i=l;return i.children?.length>0&&(t+=i.children.map(s=>Wn(s,e+1)).join("")),t}function ms(l){return Array.isArray(l)?l.map(e=>e.metadata?.title?Wn(e):e.content).join(`
`):l.metadata?.title?Wn(l):l.content}function $l(l){return Array.isArray(l)&&l.every(e=>typeof e.content=="string")||!Array.isArray(l)&&typeof l.content=="string"}const{SvelteComponent:hs,append:ds,attr:vt,detach:gs,init:bs,insert:ws,noop:En,safe_not_equal:ks,svg_element:Cl}=window.__gradio__svelte__internal;function ps(l){let e,t;return{c(){e=Cl("svg"),t=Cl("path"),vt(t,"d","M11.25 6.61523H9.375V1.36523H11.25V6.61523ZM3.375 1.36523H8.625V6.91636L7.48425 8.62748L7.16737 10.8464C7.14108 11.0248 7.05166 11.1879 6.91535 11.3061C6.77904 11.4242 6.60488 11.4896 6.4245 11.4902H6.375C6.07672 11.4899 5.79075 11.3713 5.57983 11.1604C5.36892 10.9495 5.2503 10.6635 5.25 10.3652V8.11523H2.25C1.85233 8.11474 1.47109 7.95654 1.18989 7.67535C0.908691 7.39415 0.750496 7.01291 0.75 6.61523V3.99023C0.750992 3.29435 1.02787 2.62724 1.51994 2.13517C2.01201 1.64311 2.67911 1.36623 3.375 1.36523Z"),vt(t,"fill","currentColor"),vt(e,"width","100%"),vt(e,"height","100%"),vt(e,"viewBox","0 0 12 12"),vt(e,"fill","none"),vt(e,"xmlns","http://www.w3.org/2000/svg")},m(n,i){ws(n,e,i),ds(e,t)},p:En,i:En,o:En,d(n){n&&gs(e)}}}class yl extends hs{constructor(e){super(),bs(this,e,null,ps,ks,{})}}const{SvelteComponent:vs,append:$s,attr:$t,detach:Cs,init:ys,insert:zs,noop:An,safe_not_equal:Ss,svg_element:zl}=window.__gradio__svelte__internal;function Hs(l){let e,t;return{c(){e=zl("svg"),t=zl("path"),$t(t,"d","M2.25 8.11523H4.5V10.3652C4.5003 10.6635 4.61892 10.9495 4.82983 11.1604C5.04075 11.3713 5.32672 11.4899 5.625 11.4902H6.42488C6.60519 11.4895 6.77926 11.4241 6.91549 11.3059C7.05172 11.1878 7.14109 11.0248 7.16737 10.8464L7.48425 8.62748L8.82562 6.61523H11.25V1.36523H3.375C2.67911 1.36623 2.01201 1.64311 1.51994 2.13517C1.02787 2.62724 0.750992 3.29435 0.75 3.99023V6.61523C0.750496 7.01291 0.908691 7.39415 1.18989 7.67535C1.47109 7.95654 1.85233 8.11474 2.25 8.11523ZM9 2.11523H10.5V5.86523H9V2.11523ZM1.5 3.99023C1.5006 3.49314 1.69833 3.01657 2.04983 2.66507C2.40133 2.31356 2.8779 2.11583 3.375 2.11523H8.25V6.12661L6.76575 8.35298L6.4245 10.7402H5.625C5.52554 10.7402 5.43016 10.7007 5.35983 10.6304C5.28951 10.5601 5.25 10.4647 5.25 10.3652V7.36523H2.25C2.05118 7.36494 1.86059 7.28582 1.72 7.14524C1.57941 7.00465 1.5003 6.81406 1.5 6.61523V3.99023Z"),$t(t,"fill","currentColor"),$t(e,"width","100%"),$t(e,"height","100%"),$t(e,"viewBox","0 0 12 12"),$t(e,"fill","none"),$t(e,"xmlns","http://www.w3.org/2000/svg")},m(n,i){zs(n,e,i),$s(e,t)},p:An,i:An,o:An,d(n){n&&Cs(e)}}}class Sl extends vs{constructor(e){super(),ys(this,e,null,Hs,Ss,{})}}const{SvelteComponent:qs,append:Ls,attr:Ct,detach:js,init:Ms,insert:Ns,noop:Tn,safe_not_equal:Vs,svg_element:Hl}=window.__gradio__svelte__internal;function Ds(l){let e,t;return{c(){e=Hl("svg"),t=Hl("path"),Ct(t,"d","M0.75 6.24023H2.625V11.4902H0.75V6.24023ZM8.625 11.4902H3.375V5.93911L4.51575 4.22798L4.83263 2.00911C4.85892 1.83065 4.94834 1.66754 5.08465 1.5494C5.22096 1.43125 5.39512 1.36591 5.5755 1.36523H5.625C5.92328 1.36553 6.20925 1.48415 6.42017 1.69507C6.63108 1.90598 6.7497 2.19196 6.75 2.49023V4.74023H9.75C10.1477 4.74073 10.5289 4.89893 10.8101 5.18012C11.0913 5.46132 11.2495 5.84256 11.25 6.24023V8.86523C11.249 9.56112 10.9721 10.2282 10.4801 10.7203C9.98799 11.2124 9.32089 11.4892 8.625 11.4902Z"),Ct(t,"fill","currentColor"),Ct(e,"width","100%"),Ct(e,"height","100%"),Ct(e,"viewBox","0 0 12 12"),Ct(e,"fill","none"),Ct(e,"xmlns","http://www.w3.org/2000/svg")},m(n,i){Ns(n,e,i),Ls(e,t)},p:Tn,i:Tn,o:Tn,d(n){n&&js(e)}}}class ql extends qs{constructor(e){super(),Ms(this,e,null,Ds,Vs,{})}}const{SvelteComponent:Is,append:Bs,attr:yt,detach:Es,init:As,insert:Ts,noop:Fn,safe_not_equal:Fs,svg_element:Ll}=window.__gradio__svelte__internal;function Zs(l){let e,t;return{c(){e=Ll("svg"),t=Ll("path"),yt(t,"d","M9.75 4.74023H7.5V2.49023C7.4997 2.19196 7.38108 1.90598 7.17017 1.69507C6.95925 1.48415 6.67328 1.36553 6.375 1.36523H5.57512C5.39481 1.366 5.22074 1.43138 5.08451 1.54952C4.94828 1.66766 4.85891 1.83072 4.83262 2.00911L4.51575 4.22798L3.17438 6.24023H0.75V11.4902H8.625C9.32089 11.4892 9.98799 11.2124 10.4801 10.7203C10.9721 10.2282 11.249 9.56112 11.25 8.86523V6.24023C11.2495 5.84256 11.0913 5.46132 10.8101 5.18012C10.5289 4.89893 10.1477 4.74073 9.75 4.74023ZM3 10.7402H1.5V6.99023H3V10.7402ZM10.5 8.86523C10.4994 9.36233 10.3017 9.8389 9.95017 10.1904C9.59867 10.5419 9.1221 10.7396 8.625 10.7402H3.75V6.72886L5.23425 4.50248L5.5755 2.11523H6.375C6.47446 2.11523 6.56984 2.15474 6.64017 2.22507C6.71049 2.2954 6.75 2.39078 6.75 2.49023V5.49023H9.75C9.94882 5.49053 10.1394 5.56965 10.28 5.71023C10.4206 5.85082 10.4997 6.04141 10.5 6.24023V8.86523Z"),yt(t,"fill","currentColor"),yt(e,"width","100%"),yt(e,"height","100%"),yt(e,"viewBox","0 0 12 12"),yt(e,"fill","none"),yt(e,"xmlns","http://www.w3.org/2000/svg")},m(n,i){Ts(n,e,i),Bs(e,t)},p:Fn,i:Fn,o:Fn,d(n){n&&Es(e)}}}class jl extends Is{constructor(e){super(),As(this,e,null,Zs,Fs,{})}}const{SvelteComponent:Us,append:Ps,attr:Bt,detach:Rs,init:Os,insert:Js,noop:Zn,safe_not_equal:Ws,svg_element:Ml}=window.__gradio__svelte__internal;function Gs(l){let e,t;return{c(){e=Ml("svg"),t=Ml("path"),Bt(t,"fill","currentColor"),Bt(t,"d","M6,30H4V2H28l-5.8,9L28,20H6ZM6,18H24.33L19.8,11l4.53-7H6Z"),Bt(e,"id","icon"),Bt(e,"xmlns","http://www.w3.org/2000/svg"),Bt(e,"viewBox","0 0 32 32"),Bt(e,"fill","none")},m(n,i){Js(n,e,i),Ps(e,t)},p:Zn,i:Zn,o:Zn,d(n){n&&Rs(e)}}}class Nl extends Us{constructor(e){super(),Os(this,e,null,Gs,Ws,{})}}const{SvelteComponent:Ys,append:Ks,attr:Et,detach:Qs,init:Xs,insert:xs,noop:Un,safe_not_equal:ea,svg_element:Vl}=window.__gradio__svelte__internal;function ta(l){let e,t;return{c(){e=Vl("svg"),t=Vl("path"),Et(t,"fill","currentColor"),Et(t,"d","M4,2H28l-5.8,9L28,20H6v10H4V2z"),Et(e,"id","icon"),Et(e,"xmlns","http://www.w3.org/2000/svg"),Et(e,"viewBox","0 0 32 32"),Et(e,"fill","none")},m(n,i){xs(n,e,i),Ks(e,t)},p:Un,i:Un,o:Un,d(n){n&&Qs(e)}}}class Dl extends Ys{constructor(e){super(),Xs(this,e,null,ta,ea,{})}}const{SvelteComponent:na,append:Gn,attr:Yn,check_outros:_n,create_component:ll,destroy_component:il,destroy_each:la,detach:Zt,element:Kn,empty:eo,ensure_array_like:Il,flush:Pn,group_outros:un,init:ia,insert:Ut,listen:oa,mount_component:ol,safe_not_equal:sa,set_data:aa,set_style:Bl,space:sl,text:ra,transition_in:te,transition_out:ye}=window.__gradio__svelte__internal;function El(l,e,t){const n=l.slice();return n[8]=e[t],n}function Al(l){let e=l[2].includes("Dislike"),t,n=l[2].includes("Like"),i,s,o=e&&Tl(l),r=n&&Fl(l);return{c(){o&&o.c(),t=sl(),r&&r.c(),i=eo()},m(a,_){o&&o.m(a,_),Ut(a,t,_),r&&r.m(a,_),Ut(a,i,_),s=!0},p(a,_){_&4&&(e=a[2].includes("Dislike")),e?o?(o.p(a,_),_&4&&te(o,1)):(o=Tl(a),o.c(),te(o,1),o.m(t.parentNode,t)):o&&(un(),ye(o,1,1,()=>{o=null}),_n()),_&4&&(n=a[2].includes("Like")),n?r?(r.p(a,_),_&4&&te(r,1)):(r=Fl(a),r.c(),te(r,1),r.m(i.parentNode,i)):r&&(un(),ye(r,1,1,()=>{r=null}),_n())},i(a){s||(te(o),te(r),s=!0)},o(a){ye(o),ye(r),s=!1},d(a){a&&(Zt(t),Zt(i)),o&&o.d(a),r&&r.d(a)}}}function Tl(l){let e,t;return e=new le({props:{Icon:l[0]==="Dislike"?yl:Sl,label:l[0]==="Dislike"?"clicked dislike":"dislike",color:l[0]==="Dislike"?"var(--color-accent)":"var(--block-label-text-color)"}}),e.$on("click",l[5]),{c(){ll(e.$$.fragment)},m(n,i){ol(e,n,i),t=!0},p(n,i){const s={};i&1&&(s.Icon=n[0]==="Dislike"?yl:Sl),i&1&&(s.label=n[0]==="Dislike"?"clicked dislike":"dislike"),i&1&&(s.color=n[0]==="Dislike"?"var(--color-accent)":"var(--block-label-text-color)"),e.$set(s)},i(n){t||(te(e.$$.fragment,n),t=!0)},o(n){ye(e.$$.fragment,n),t=!1},d(n){il(e,n)}}}function Fl(l){let e,t;return e=new le({props:{Icon:l[0]==="Like"?ql:jl,label:l[0]==="Like"?"clicked like":"like",color:l[0]==="Like"?"var(--color-accent)":"var(--block-label-text-color)"}}),e.$on("click",l[6]),{c(){ll(e.$$.fragment)},m(n,i){ol(e,n,i),t=!0},p(n,i){const s={};i&1&&(s.Icon=n[0]==="Like"?ql:jl),i&1&&(s.label=n[0]==="Like"?"clicked like":"like"),i&1&&(s.color=n[0]==="Like"?"var(--color-accent)":"var(--block-label-text-color)"),e.$set(s)},i(n){t||(te(e.$$.fragment,n),t=!0)},o(n){ye(e.$$.fragment,n),t=!1},d(n){il(e,n)}}}function Zl(l){let e,t,n,i,s;t=new le({props:{Icon:l[0]&&l[3].includes(l[0])?Dl:Nl,label:"Feedback",color:l[0]&&l[3].includes(l[0])?"var(--color-accent)":"var(--block-label-text-color)"}});let o=Il(l[3]),r=[];for(let a=0;a0&&Zl(l);return{c(){s&&s.c(),t=sl(),o&&o.c(),n=eo()},m(r,a){s&&s.m(r,a),Ut(r,t,a),o&&o.m(r,a),Ut(r,n,a),i=!0},p(r,[a]){a&4&&(e=r[2].includes("Like")||r[2].includes("Dislike")),e?s?(s.p(r,a),a&4&&te(s,1)):(s=Al(r),s.c(),te(s,1),s.m(t.parentNode,t)):s&&(un(),ye(s,1,1,()=>{s=null}),_n()),r[3].length>0?o?(o.p(r,a),a&8&&te(o,1)):(o=Zl(r),o.c(),te(o,1),o.m(n.parentNode,n)):o&&(un(),ye(o,1,1,()=>{o=null}),_n())},i(r){i||(te(s),te(o),i=!0)},o(r){ye(s),ye(o),i=!1},d(r){r&&(Zt(t),Zt(n)),s&&s.d(r),o&&o.d(r)}}}function ua(l,e,t){let n,{handle_action:i}=e,{feedback_options:s}=e,{selected:o=null}=e;function r(f){t(0,o=o===f?null:f),i(o)}const a=()=>r("Dislike"),_=()=>r("Like"),u=f=>{r(f),i(o||null)};return l.$$set=f=>{"handle_action"in f&&t(1,i=f.handle_action),"feedback_options"in f&&t(2,s=f.feedback_options),"selected"in f&&t(0,o=f.selected)},l.$$.update=()=>{l.$$.dirty&4&&t(3,n=s.filter(f=>f!=="Like"&&f!=="Dislike"))},[o,i,s,n,r,a,_,u]}class fa extends na{constructor(e){super(),ia(this,e,ua,_a,sa,{handle_action:1,feedback_options:2,selected:0})}get handle_action(){return this.$$.ctx[1]}set handle_action(e){this.$$set({handle_action:e}),Pn()}get feedback_options(){return this.$$.ctx[2]}set feedback_options(e){this.$$set({feedback_options:e}),Pn()}get selected(){return this.$$.ctx[0]}set selected(e){this.$$set({selected:e}),Pn()}}const{SvelteComponent:ca,create_component:ma,destroy_component:ha,flush:da,init:ga,mount_component:ba,safe_not_equal:wa,transition_in:ka,transition_out:pa}=window.__gradio__svelte__internal,{createEventDispatcher:va}=window.__gradio__svelte__internal,{onDestroy:$a}=window.__gradio__svelte__internal;function Ca(l){let e,t;return e=new le({props:{label:l[0]?"Copied message":"Copy message",Icon:l[0]?Jt:rn}}),e.$on("click",l[1]),{c(){ma(e.$$.fragment)},m(n,i){ba(e,n,i),t=!0},p(n,[i]){const s={};i&1&&(s.label=n[0]?"Copied message":"Copy message"),i&1&&(s.Icon=n[0]?Jt:rn),e.$set(s)},i(n){t||(ka(e.$$.fragment,n),t=!0)},o(n){pa(e.$$.fragment,n),t=!1},d(n){ha(e,n)}}}function ya(l,e,t){const n=va();let i=!1,{value:s}=e,o;function r(){t(0,i=!0),o&&clearTimeout(o),o=setTimeout(()=>{t(0,i=!1)},2e3)}async function a(){if("clipboard"in navigator)n("copy",{value:s}),await navigator.clipboard.writeText(s),r();else{const _=document.createElement("textarea");_.value=s,_.style.position="absolute",_.style.left="-999999px",document.body.prepend(_),_.select();try{document.execCommand("copy"),r()}catch(u){console.error(u)}finally{_.remove()}}}return $a(()=>{o&&clearTimeout(o)}),l.$$set=_=>{"value"in _&&t(2,s=_.value)},[i,a,s]}class za extends ca{constructor(e){super(),ga(this,e,ya,Ca,wa,{value:2})}get value(){return this.$$.ctx[2]}set value(e){this.$$set({value:e}),da()}}const{SvelteComponent:Sa,attr:Pl,check_outros:Ht,create_component:ut,destroy_component:ft,detach:Fe,element:Ha,empty:al,flush:ee,group_outros:qt,init:qa,insert:Ze,mount_component:ct,safe_not_equal:La,space:Ot,transition_in:M,transition_out:F}=window.__gradio__svelte__internal;function Rl(l){let e,t,n,i;return t=new Ki({props:{top_panel:!1,$$slots:{default:[Na]},$$scope:{ctx:l}}}),{c(){e=Ha("div"),ut(t.$$.fragment),Pl(e,"class",n="message-buttons-"+l[6]+" "+l[11]+" message-buttons "+(l[7]!==null&&"with-avatar")+" svelte-j7nkv7")},m(s,o){Ze(s,e,o),ct(t,e,null),i=!0},p(s,o){const r={};o&8419135&&(r.$$scope={dirty:o,ctx:s}),t.$set(r),(!i||o&2240&&n!==(n="message-buttons-"+s[6]+" "+s[11]+" message-buttons "+(s[7]!==null&&"with-avatar")+" svelte-j7nkv7"))&&Pl(e,"class",n)},i(s){i||(M(t.$$.fragment,s),i=!0)},o(s){F(t.$$.fragment,s),i=!1},d(s){s&&Fe(e),ft(t)}}}function ja(l){let e,t,n,i,s,o,r=l[13]&&Ol(l),a=l[2]&&Jl(l),_=l[3]&&Wl(l),u=l[4]&&Gl(l),f=l[0]&&Yl(l);return{c(){r&&r.c(),e=Ot(),a&&a.c(),t=Ot(),_&&_.c(),n=Ot(),u&&u.c(),i=Ot(),f&&f.c(),s=al()},m(c,b){r&&r.m(c,b),Ze(c,e,b),a&&a.m(c,b),Ze(c,t,b),_&&_.m(c,b),Ze(c,n,b),u&&u.m(c,b),Ze(c,i,b),f&&f.m(c,b),Ze(c,s,b),o=!0},p(c,b){c[13]?r?(r.p(c,b),b&8192&&M(r,1)):(r=Ol(c),r.c(),M(r,1),r.m(e.parentNode,e)):r&&(qt(),F(r,1,1,()=>{r=null}),Ht()),c[2]?a?(a.p(c,b),b&4&&M(a,1)):(a=Jl(c),a.c(),M(a,1),a.m(t.parentNode,t)):a&&(qt(),F(a,1,1,()=>{a=null}),Ht()),c[3]?_?(_.p(c,b),b&8&&M(_,1)):(_=Wl(c),_.c(),M(_,1),_.m(n.parentNode,n)):_&&(qt(),F(_,1,1,()=>{_=null}),Ht()),c[4]?u?(u.p(c,b),b&16&&M(u,1)):(u=Gl(c),u.c(),M(u,1),u.m(i.parentNode,i)):u&&(qt(),F(u,1,1,()=>{u=null}),Ht()),c[0]?f?(f.p(c,b),b&1&&M(f,1)):(f=Yl(c),f.c(),M(f,1),f.m(s.parentNode,s)):f&&(qt(),F(f,1,1,()=>{f=null}),Ht())},i(c){o||(M(r),M(a),M(_),M(u),M(f),o=!0)},o(c){F(r),F(a),F(_),F(u),F(f),o=!1},d(c){c&&(Fe(e),Fe(t),Fe(n),Fe(i),Fe(s)),r&&r.d(c),a&&a.d(c),_&&_.d(c),u&&u.d(c),f&&f.d(c)}}}function Ma(l){let e,t,n,i;return e=new le({props:{label:"Submit",Icon:Jt,disabled:l[8]}}),e.$on("click",l[17]),n=new le({props:{label:"Cancel",Icon:$o,disabled:l[8]}}),n.$on("click",l[18]),{c(){ut(e.$$.fragment),t=Ot(),ut(n.$$.fragment)},m(s,o){ct(e,s,o),Ze(s,t,o),ct(n,s,o),i=!0},p(s,o){const r={};o&256&&(r.disabled=s[8]),e.$set(r);const a={};o&256&&(a.disabled=s[8]),n.$set(a)},i(s){i||(M(e.$$.fragment,s),M(n.$$.fragment,s),i=!0)},o(s){F(e.$$.fragment,s),F(n.$$.fragment,s),i=!1},d(s){s&&Fe(t),ft(e,s),ft(n,s)}}}function Ol(l){let e,t;return e=new za({props:{value:l[14]}}),e.$on("copy",l[19]),{c(){ut(e.$$.fragment)},m(n,i){ct(e,n,i),t=!0},p(n,i){const s={};i&16384&&(s.value=n[14]),e.$set(s)},i(n){t||(M(e.$$.fragment,n),t=!0)},o(n){F(e.$$.fragment,n),t=!1},d(n){ft(e,n)}}}function Jl(l){let e,t;return e=new le({props:{Icon:Qo,label:"Retry",disabled:l[8]}}),e.$on("click",l[20]),{c(){ut(e.$$.fragment)},m(n,i){ct(e,n,i),t=!0},p(n,i){const s={};i&256&&(s.disabled=n[8]),e.$set(s)},i(n){t||(M(e.$$.fragment,n),t=!0)},o(n){F(e.$$.fragment,n),t=!1},d(n){ft(e,n)}}}function Wl(l){let e,t;return e=new le({props:{label:"Undo",Icon:yo,disabled:l[8]}}),e.$on("click",l[21]),{c(){ut(e.$$.fragment)},m(n,i){ct(e,n,i),t=!0},p(n,i){const s={};i&256&&(s.disabled=n[8]),e.$set(s)},i(n){t||(M(e.$$.fragment,n),t=!0)},o(n){F(e.$$.fragment,n),t=!1},d(n){ft(e,n)}}}function Gl(l){let e,t;return e=new le({props:{label:"Edit",Icon:Co,disabled:l[8]}}),e.$on("click",l[22]),{c(){ut(e.$$.fragment)},m(n,i){ct(e,n,i),t=!0},p(n,i){const s={};i&256&&(s.disabled=n[8]),e.$set(s)},i(n){t||(M(e.$$.fragment,n),t=!0)},o(n){F(e.$$.fragment,n),t=!1},d(n){ft(e,n)}}}function Yl(l){let e,t;return e=new fa({props:{handle_action:l[10],feedback_options:l[1],selected:l[9]}}),{c(){ut(e.$$.fragment)},m(n,i){ct(e,n,i),t=!0},p(n,i){const s={};i&1024&&(s.handle_action=n[10]),i&2&&(s.feedback_options=n[1]),i&512&&(s.selected=n[9]),e.$set(s)},i(n){t||(M(e.$$.fragment,n),t=!0)},o(n){F(e.$$.fragment,n),t=!1},d(n){ft(e,n)}}}function Na(l){let e,t,n,i;const s=[Ma,ja],o=[];function r(a,_){return a[5]?0:1}return e=r(l),t=o[e]=s[e](l),{c(){t.c(),n=al()},m(a,_){o[e].m(a,_),Ze(a,n,_),i=!0},p(a,_){let u=e;e=r(a),e===u?o[e].p(a,_):(qt(),F(o[u],1,1,()=>{o[u]=null}),Ht(),t=o[e],t?t.p(a,_):(t=o[e]=s[e](a),t.c()),M(t,1),t.m(n.parentNode,n))},i(a){i||(M(t),i=!0)},o(a){F(t),i=!1},d(a){a&&Fe(n),o[e].d(a)}}}function Va(l){let e,t,n=(l[13]||l[2]||l[3]||l[4]||l[0])&&Rl(l);return{c(){n&&n.c(),e=al()},m(i,s){n&&n.m(i,s),Ze(i,e,s),t=!0},p(i,[s]){i[13]||i[2]||i[3]||i[4]||i[0]?n?(n.p(i,s),s&8221&&M(n,1)):(n=Rl(i),n.c(),M(n,1),n.m(e.parentNode,e)):n&&(qt(),F(n,1,1,()=>{n=null}),Ht())},i(i){t||(M(n),t=!0)},o(i){F(n),t=!1},d(i){i&&Fe(e),n&&n.d(i)}}}function Da(l,e,t){let n,i,{likeable:s}=e,{feedback_options:o}=e,{show_retry:r}=e,{show_undo:a}=e,{show_edit:_}=e,{in_edit_mode:u}=e,{show_copy_button:f}=e,{message:c}=e,{position:b}=e,{avatar:m}=e,{generating:h}=e,{current_feedback:w}=e,{handle_action:d}=e,{layout:$}=e,{dispatch:z}=e;const I=()=>d("edit_submit"),p=()=>d("edit_cancel"),x=S=>z("copy",S.detail),ne=()=>d("retry"),y=()=>d("undo"),ge=()=>d("edit");return l.$$set=S=>{"likeable"in S&&t(0,s=S.likeable),"feedback_options"in S&&t(1,o=S.feedback_options),"show_retry"in S&&t(2,r=S.show_retry),"show_undo"in S&&t(3,a=S.show_undo),"show_edit"in S&&t(4,_=S.show_edit),"in_edit_mode"in S&&t(5,u=S.in_edit_mode),"show_copy_button"in S&&t(15,f=S.show_copy_button),"message"in S&&t(16,c=S.message),"position"in S&&t(6,b=S.position),"avatar"in S&&t(7,m=S.avatar),"generating"in S&&t(8,h=S.generating),"current_feedback"in S&&t(9,w=S.current_feedback),"handle_action"in S&&t(10,d=S.handle_action),"layout"in S&&t(11,$=S.layout),"dispatch"in S&&t(12,z=S.dispatch)},l.$$.update=()=>{l.$$.dirty&65536&&t(14,n=$l(c)?ms(c):""),l.$$.dirty&98304&&t(13,i=f&&c&&$l(c))},[s,o,r,a,_,u,b,m,h,w,d,$,z,i,n,f,c,I,p,x,ne,y,ge]}class to extends Sa{constructor(e){super(),qa(this,e,Da,Va,La,{likeable:0,feedback_options:1,show_retry:2,show_undo:3,show_edit:4,in_edit_mode:5,show_copy_button:15,message:16,position:6,avatar:7,generating:8,current_feedback:9,handle_action:10,layout:11,dispatch:12})}get likeable(){return this.$$.ctx[0]}set likeable(e){this.$$set({likeable:e}),ee()}get feedback_options(){return this.$$.ctx[1]}set feedback_options(e){this.$$set({feedback_options:e}),ee()}get show_retry(){return this.$$.ctx[2]}set show_retry(e){this.$$set({show_retry:e}),ee()}get show_undo(){return this.$$.ctx[3]}set show_undo(e){this.$$set({show_undo:e}),ee()}get show_edit(){return this.$$.ctx[4]}set show_edit(e){this.$$set({show_edit:e}),ee()}get in_edit_mode(){return this.$$.ctx[5]}set in_edit_mode(e){this.$$set({in_edit_mode:e}),ee()}get show_copy_button(){return this.$$.ctx[15]}set show_copy_button(e){this.$$set({show_copy_button:e}),ee()}get message(){return this.$$.ctx[16]}set message(e){this.$$set({message:e}),ee()}get position(){return this.$$.ctx[6]}set position(e){this.$$set({position:e}),ee()}get avatar(){return this.$$.ctx[7]}set avatar(e){this.$$set({avatar:e}),ee()}get generating(){return this.$$.ctx[8]}set generating(e){this.$$set({generating:e}),ee()}get current_feedback(){return this.$$.ctx[9]}set current_feedback(e){this.$$set({current_feedback:e}),ee()}get handle_action(){return this.$$.ctx[10]}set handle_action(e){this.$$set({handle_action:e}),ee()}get layout(){return this.$$.ctx[11]}set layout(e){this.$$set({layout:e}),ee()}get dispatch(){return this.$$.ctx[12]}set dispatch(e){this.$$set({dispatch:e}),ee()}}const{SvelteComponent:Ia,attr:Ba,bubble:zt,check_outros:dt,construct_svelte_component:ie,create_component:oe,destroy_component:se,detach:We,element:no,empty:Dt,flush:$e,group_outros:gt,init:Ea,insert:Ge,mount_component:ae,noop:Aa,safe_not_equal:Ta,set_style:Fa,transition_in:Q,transition_out:X}=window.__gradio__svelte__internal;function Za(l){let e,t,n;var i=l[1][l[0]];function s(o,r){return{props:{value:o[2],show_label:!1,label:"chatbot-image",show_share_button:!0,i18n:o[6],gradio:{dispatch:Qa}}}}return i&&(e=ie(i,s(l)),e.$on("load",l[17])),{c(){e&&oe(e.$$.fragment),t=Dt()},m(o,r){e&&ae(e,o,r),Ge(o,t,r),n=!0},p(o,r){if(r&3&&i!==(i=o[1][o[0]])){if(e){gt();const a=e;X(a.$$.fragment,1,0,()=>{se(a,1)}),dt()}i?(e=ie(i,s(o)),e.$on("load",o[17]),oe(e.$$.fragment),Q(e.$$.fragment,1),ae(e,t.parentNode,t)):e=null}else if(i){const a={};r&4&&(a.value=o[2]),r&64&&(a.i18n=o[6]),e.$set(a)}},i(o){n||(e&&Q(e.$$.fragment,o),n=!0)},o(o){e&&X(e.$$.fragment,o),n=!1},d(o){o&&We(t),e&&se(e,o)}}}function Ua(l){let e,t,n;var i=l[1][l[0]];function s(o,r){return{props:{value:o[2],show_label:!1,label:"chatbot-image",show_download_button:o[9],display_icon_button_wrapper_top_corner:o[10],i18n:o[6]}}}return i&&(e=ie(i,s(l)),e.$on("load",l[16])),{c(){e&&oe(e.$$.fragment),t=Dt()},m(o,r){e&&ae(e,o,r),Ge(o,t,r),n=!0},p(o,r){if(r&3&&i!==(i=o[1][o[0]])){if(e){gt();const a=e;X(a.$$.fragment,1,0,()=>{se(a,1)}),dt()}i?(e=ie(i,s(o)),e.$on("load",o[16]),oe(e.$$.fragment),Q(e.$$.fragment,1),ae(e,t.parentNode,t)):e=null}else if(i){const a={};r&4&&(a.value=o[2]),r&512&&(a.show_download_button=o[9]),r&1024&&(a.display_icon_button_wrapper_top_corner=o[10]),r&64&&(a.i18n=o[6]),e.$set(a)}},i(o){n||(e&&Q(e.$$.fragment,o),n=!0)},o(o){e&&X(e.$$.fragment,o),n=!1},d(o){o&&We(t),e&&se(e,o)}}}function Pa(l){let e,t,n;var i=l[1][l[0]];function s(o,r){return{props:{autoplay:o[5].autoplay,value:o[2].video||o[2],show_label:!1,show_share_button:!0,i18n:o[6],upload:o[7],display_icon_button_wrapper_top_corner:o[10],show_download_button:o[9],$$slots:{default:[Ga]},$$scope:{ctx:o}}}}return i&&(e=ie(i,s(l)),e.$on("load",l[15])),{c(){e&&oe(e.$$.fragment),t=Dt()},m(o,r){e&&ae(e,o,r),Ge(o,t,r),n=!0},p(o,r){if(r&3&&i!==(i=o[1][o[0]])){if(e){gt();const a=e;X(a.$$.fragment,1,0,()=>{se(a,1)}),dt()}i?(e=ie(i,s(o)),e.$on("load",o[15]),oe(e.$$.fragment),Q(e.$$.fragment,1),ae(e,t.parentNode,t)):e=null}else if(i){const a={};r&32&&(a.autoplay=o[5].autoplay),r&4&&(a.value=o[2].video||o[2]),r&64&&(a.i18n=o[6]),r&128&&(a.upload=o[7]),r&1024&&(a.display_icon_button_wrapper_top_corner=o[10]),r&512&&(a.show_download_button=o[9]),r&262144&&(a.$$scope={dirty:r,ctx:o}),e.$set(a)}},i(o){n||(e&&Q(e.$$.fragment,o),n=!0)},o(o){e&&X(e.$$.fragment,o),n=!1},d(o){o&&We(t),e&&se(e,o)}}}function Ra(l){let e,t,n;var i=l[1][l[0]];function s(o,r){return{props:{value:o[2],show_label:!1,show_share_button:!0,i18n:o[6],label:"",waveform_settings:{autoplay:o[5].autoplay},show_download_button:o[9],display_icon_button_wrapper_top_corner:o[10]}}}return i&&(t=ie(i,s(l)),t.$on("load",l[14])),{c(){e=no("div"),t&&oe(t.$$.fragment),Fa(e,"position","relative")},m(o,r){Ge(o,e,r),t&&ae(t,e,null),n=!0},p(o,r){if(r&3&&i!==(i=o[1][o[0]])){if(t){gt();const a=t;X(a.$$.fragment,1,0,()=>{se(a,1)}),dt()}i?(t=ie(i,s(o)),t.$on("load",o[14]),oe(t.$$.fragment),Q(t.$$.fragment,1),ae(t,e,null)):t=null}else if(i){const a={};r&4&&(a.value=o[2]),r&64&&(a.i18n=o[6]),r&32&&(a.waveform_settings={autoplay:o[5].autoplay}),r&512&&(a.show_download_button=o[9]),r&1024&&(a.display_icon_button_wrapper_top_corner=o[10]),t.$set(a)}},i(o){n||(t&&Q(t.$$.fragment,o),n=!0)},o(o){t&&X(t.$$.fragment,o),n=!1},d(o){o&&We(e),t&&se(t)}}}function Oa(l){let e,t,n;var i=l[1][l[0]];function s(o,r){return{props:{value:o[2],target:o[3],theme_mode:o[4],bokeh_version:o[5].bokeh_version,caption:"",show_actions_button:!0}}}return i&&(e=ie(i,s(l)),e.$on("load",l[13])),{c(){e&&oe(e.$$.fragment),t=Dt()},m(o,r){e&&ae(e,o,r),Ge(o,t,r),n=!0},p(o,r){if(r&3&&i!==(i=o[1][o[0]])){if(e){gt();const a=e;X(a.$$.fragment,1,0,()=>{se(a,1)}),dt()}i?(e=ie(i,s(o)),e.$on("load",o[13]),oe(e.$$.fragment),Q(e.$$.fragment,1),ae(e,t.parentNode,t)):e=null}else if(i){const a={};r&4&&(a.value=o[2]),r&8&&(a.target=o[3]),r&16&&(a.theme_mode=o[4]),r&32&&(a.bokeh_version=o[5].bokeh_version),e.$set(a)}},i(o){n||(e&&Q(e.$$.fragment,o),n=!0)},o(o){e&&X(e.$$.fragment,o),n=!1},d(o){o&&We(t),e&&se(e,o)}}}function Ja(l){let e,t,n;var i=l[1][l[0]];function s(o,r){return{props:{value:o[2],show_label:!1,i18n:o[6],label:"",interactive:!1,line_breaks:o[5].line_breaks,wrap:!0,root:"",gradio:{dispatch:Ka},datatype:o[5].datatype,latex_delimiters:o[5].latex_delimiters,col_count:o[5].col_count,row_count:o[5].row_count}}}return i&&(e=ie(i,s(l)),e.$on("load",l[12])),{c(){e&&oe(e.$$.fragment),t=Dt()},m(o,r){e&&ae(e,o,r),Ge(o,t,r),n=!0},p(o,r){if(r&3&&i!==(i=o[1][o[0]])){if(e){gt();const a=e;X(a.$$.fragment,1,0,()=>{se(a,1)}),dt()}i?(e=ie(i,s(o)),e.$on("load",o[12]),oe(e.$$.fragment),Q(e.$$.fragment,1),ae(e,t.parentNode,t)):e=null}else if(i){const a={};r&4&&(a.value=o[2]),r&64&&(a.i18n=o[6]),r&32&&(a.line_breaks=o[5].line_breaks),r&32&&(a.datatype=o[5].datatype),r&32&&(a.latex_delimiters=o[5].latex_delimiters),r&32&&(a.col_count=o[5].col_count),r&32&&(a.row_count=o[5].row_count),e.$set(a)}},i(o){n||(e&&Q(e.$$.fragment,o),n=!0)},o(o){e&&X(e.$$.fragment,o),n=!1},d(o){o&&We(t),e&&se(e,o)}}}function Wa(l){let e,t,n;var i=l[1][l[0]];function s(o,r){return{props:{value:o[2],display_icon_button_wrapper_top_corner:o[10],show_label:!1,i18n:o[6],label:"",_fetch:o[8],allow_preview:!1,interactive:!1,mode:"minimal",fixed_height:1}}}return i&&(e=ie(i,s(l)),e.$on("load",l[11])),{c(){e&&oe(e.$$.fragment),t=Dt()},m(o,r){e&&ae(e,o,r),Ge(o,t,r),n=!0},p(o,r){if(r&3&&i!==(i=o[1][o[0]])){if(e){gt();const a=e;X(a.$$.fragment,1,0,()=>{se(a,1)}),dt()}i?(e=ie(i,s(o)),e.$on("load",o[11]),oe(e.$$.fragment),Q(e.$$.fragment,1),ae(e,t.parentNode,t)):e=null}else if(i){const a={};r&4&&(a.value=o[2]),r&1024&&(a.display_icon_button_wrapper_top_corner=o[10]),r&64&&(a.i18n=o[6]),r&256&&(a._fetch=o[8]),e.$set(a)}},i(o){n||(e&&Q(e.$$.fragment,o),n=!0)},o(o){e&&X(e.$$.fragment,o),n=!1},d(o){o&&We(t),e&&se(e,o)}}}function Ga(l){let e;return{c(){e=no("track"),Ba(e,"kind","captions")},m(t,n){Ge(t,e,n)},p:Aa,d(t){t&&We(e)}}}function Ya(l){let e,t,n,i;const s=[Wa,Ja,Oa,Ra,Pa,Ua,Za],o=[];function r(a,_){return a[0]==="gallery"?0:a[0]==="dataframe"?1:a[0]==="plot"?2:a[0]==="audio"?3:a[0]==="video"?4:a[0]==="image"?5:a[0]==="html"?6:-1}return~(e=r(l))&&(t=o[e]=s[e](l)),{c(){t&&t.c(),n=Dt()},m(a,_){~e&&o[e].m(a,_),Ge(a,n,_),i=!0},p(a,[_]){let u=e;e=r(a),e===u?~e&&o[e].p(a,_):(t&&(gt(),X(o[u],1,1,()=>{o[u]=null}),dt()),~e?(t=o[e],t?t.p(a,_):(t=o[e]=s[e](a),t.c()),Q(t,1),t.m(n.parentNode,n)):t=null)},i(a){i||(Q(t),i=!0)},o(a){X(t),i=!1},d(a){a&&We(n),~e&&o[e].d(a)}}}const Ka=()=>{},Qa=()=>{};function Xa(l,e,t){let{type:n}=e,{components:i}=e,{value:s}=e,{target:o}=e,{theme_mode:r}=e,{props:a}=e,{i18n:_}=e,{upload:u}=e,{_fetch:f}=e,{allow_file_downloads:c}=e,{display_icon_button_wrapper_top_corner:b=!1}=e;function m(p){zt.call(this,l,p)}function h(p){zt.call(this,l,p)}function w(p){zt.call(this,l,p)}function d(p){zt.call(this,l,p)}function $(p){zt.call(this,l,p)}function z(p){zt.call(this,l,p)}function I(p){zt.call(this,l,p)}return l.$$set=p=>{"type"in p&&t(0,n=p.type),"components"in p&&t(1,i=p.components),"value"in p&&t(2,s=p.value),"target"in p&&t(3,o=p.target),"theme_mode"in p&&t(4,r=p.theme_mode),"props"in p&&t(5,a=p.props),"i18n"in p&&t(6,_=p.i18n),"upload"in p&&t(7,u=p.upload),"_fetch"in p&&t(8,f=p._fetch),"allow_file_downloads"in p&&t(9,c=p.allow_file_downloads),"display_icon_button_wrapper_top_corner"in p&&t(10,b=p.display_icon_button_wrapper_top_corner)},[n,i,s,o,r,a,_,u,f,c,b,m,h,w,d,$,z,I]}class xa extends Ia{constructor(e){super(),Ea(this,e,Xa,Ya,Ta,{type:0,components:1,value:2,target:3,theme_mode:4,props:5,i18n:6,upload:7,_fetch:8,allow_file_downloads:9,display_icon_button_wrapper_top_corner:10})}get type(){return this.$$.ctx[0]}set type(e){this.$$set({type:e}),$e()}get components(){return this.$$.ctx[1]}set components(e){this.$$set({components:e}),$e()}get value(){return this.$$.ctx[2]}set value(e){this.$$set({value:e}),$e()}get target(){return this.$$.ctx[3]}set target(e){this.$$set({target:e}),$e()}get theme_mode(){return this.$$.ctx[4]}set theme_mode(e){this.$$set({theme_mode:e}),$e()}get props(){return this.$$.ctx[5]}set props(e){this.$$set({props:e}),$e()}get i18n(){return this.$$.ctx[6]}set i18n(e){this.$$set({i18n:e}),$e()}get upload(){return this.$$.ctx[7]}set upload(e){this.$$set({upload:e}),$e()}get _fetch(){return this.$$.ctx[8]}set _fetch(e){this.$$set({_fetch:e}),$e()}get allow_file_downloads(){return this.$$.ctx[9]}set allow_file_downloads(e){this.$$set({allow_file_downloads:e}),$e()}get display_icon_button_wrapper_top_corner(){return this.$$.ctx[10]}set display_icon_button_wrapper_top_corner(e){this.$$set({display_icon_button_wrapper_top_corner:e}),$e()}}const{SvelteComponent:er,append:Te,attr:ce,check_outros:tr,create_component:rl,destroy_component:_l,detach:ul,element:St,empty:nr,flush:O,group_outros:lr,init:ir,insert:fl,is_function:or,mount_component:cl,safe_not_equal:sr,set_data:Kl,space:Ql,text:Xl,transition_in:Wt,transition_out:Gt}=window.__gradio__svelte__internal;function ar(l){let e,t,n,i,s,o,r,a=(l[16].content.value?.orig_name||l[16].content.value?.path.split("/").pop()||"file")+"",_,u,f,c,b,m=(l[16].content.value?.orig_name||l[16].content.value?.path||"").split(".").pop().toUpperCase()+"",h,w;return n=new tl({}),{c(){e=St("div"),t=St("div"),rl(n.$$.fragment),i=Ql(),s=St("div"),o=St("a"),r=St("span"),_=Xl(a),c=Ql(),b=St("span"),h=Xl(m),ce(t,"class","file-icon svelte-ulpe0d"),ce(r,"class","file-name svelte-ulpe0d"),ce(o,"data-testid","chatbot-file"),ce(o,"class","file-link svelte-ulpe0d"),ce(o,"href",u=l[16].content.value.url),ce(o,"target","_blank"),ce(o,"download",f=window.__is_colab__?null:l[16].content.value?.orig_name||l[16].content.value?.path.split("/").pop()||"file"),ce(b,"class","file-type svelte-ulpe0d"),ce(s,"class","file-info svelte-ulpe0d"),ce(e,"class","file-container svelte-ulpe0d")},m(d,$){fl(d,e,$),Te(e,t),cl(n,t,null),Te(e,i),Te(e,s),Te(s,o),Te(o,r),Te(r,_),Te(s,c),Te(s,b),Te(b,h),w=!0},p(d,$){(!w||$&65536)&&a!==(a=(d[16].content.value?.orig_name||d[16].content.value?.path.split("/").pop()||"file")+"")&&Kl(_,a),(!w||$&65536&&u!==(u=d[16].content.value.url))&&ce(o,"href",u),(!w||$&65536&&f!==(f=window.__is_colab__?null:d[16].content.value?.orig_name||d[16].content.value?.path.split("/").pop()||"file"))&&ce(o,"download",f),(!w||$&65536)&&m!==(m=(d[16].content.value?.orig_name||d[16].content.value?.path||"").split(".").pop().toUpperCase()+"")&&Kl(h,m)},i(d){w||(Wt(n.$$.fragment,d),w=!0)},o(d){Gt(n.$$.fragment,d),w=!1},d(d){d&&ul(e),_l(n)}}}function rr(l){let e,t;return e=new xa({props:{target:l[6],theme_mode:l[8],props:l[16].content.props,type:l[16].content.component,components:l[9],value:l[16].content.value,display_icon_button_wrapper_top_corner:l[14]>0&&l[13],i18n:l[3],upload:l[5],_fetch:l[2],allow_file_downloads:l[12]}}),e.$on("load",l[17]),{c(){rl(e.$$.fragment)},m(n,i){cl(e,n,i),t=!0},p(n,i){const s={};i&64&&(s.target=n[6]),i&256&&(s.theme_mode=n[8]),i&65536&&(s.props=n[16].content.props),i&65536&&(s.type=n[16].content.component),i&512&&(s.components=n[9]),i&65536&&(s.value=n[16].content.value),i&24576&&(s.display_icon_button_wrapper_top_corner=n[14]>0&&n[13]),i&8&&(s.i18n=n[3]),i&32&&(s.upload=n[5]),i&4&&(s._fetch=n[2]),i&4096&&(s.allow_file_downloads=n[12]),e.$set(s)},i(n){t||(Wt(e.$$.fragment,n),t=!0)},o(n){Gt(e.$$.fragment,n),t=!1},d(n){_l(e,n)}}}function _r(l){let e,t,n;return t=new nl({props:{message:l[16].content,latex_delimiters:l[0],sanitize_html:l[1],render_markdown:l[10],line_breaks:l[4],root:l[7],allow_tags:l[15]}}),t.$on("load",function(){or(l[11])&&l[11].apply(this,arguments)}),{c(){e=St("div"),rl(t.$$.fragment),ce(e,"class","message-content")},m(i,s){fl(i,e,s),cl(t,e,null),n=!0},p(i,s){l=i;const o={};s&65536&&(o.message=l[16].content),s&1&&(o.latex_delimiters=l[0]),s&2&&(o.sanitize_html=l[1]),s&1024&&(o.render_markdown=l[10]),s&16&&(o.line_breaks=l[4]),s&128&&(o.root=l[7]),s&32768&&(o.allow_tags=l[15]),t.$set(o)},i(i){n||(Wt(t.$$.fragment,i),n=!0)},o(i){Gt(t.$$.fragment,i),n=!1},d(i){i&&ul(e),_l(t)}}}function ur(l){let e,t,n,i;const s=[_r,rr,ar],o=[];function r(a,_){return a[16].type==="text"?0:a[16].type==="component"&&a[16].content.component in a[9]?1:a[16].type==="component"&&a[16].content.component==="file"?2:-1}return~(e=r(l))&&(t=o[e]=s[e](l)),{c(){t&&t.c(),n=nr()},m(a,_){~e&&o[e].m(a,_),fl(a,n,_),i=!0},p(a,[_]){let u=e;e=r(a),e===u?~e&&o[e].p(a,_):(t&&(lr(),Gt(o[u],1,1,()=>{o[u]=null}),tr()),~e?(t=o[e],t?t.p(a,_):(t=o[e]=s[e](a),t.c()),Wt(t,1),t.m(n.parentNode,n)):t=null)},i(a){i||(Wt(t),i=!0)},o(a){Gt(t),i=!1},d(a){a&&ul(n),~e&&o[e].d(a)}}}function fr(l,e,t){let{latex_delimiters:n}=e,{sanitize_html:i}=e,{_fetch:s}=e,{i18n:o}=e,{line_breaks:r}=e,{upload:a}=e,{target:_}=e,{root:u}=e,{theme_mode:f}=e,{_components:c}=e,{render_markdown:b}=e,{scroll:m}=e,{allow_file_downloads:h}=e,{display_consecutive_in_same_bubble:w}=e,{thought_index:d}=e,{allow_tags:$=null}=e,{message:z}=e;const I=()=>m();return l.$$set=p=>{"latex_delimiters"in p&&t(0,n=p.latex_delimiters),"sanitize_html"in p&&t(1,i=p.sanitize_html),"_fetch"in p&&t(2,s=p._fetch),"i18n"in p&&t(3,o=p.i18n),"line_breaks"in p&&t(4,r=p.line_breaks),"upload"in p&&t(5,a=p.upload),"target"in p&&t(6,_=p.target),"root"in p&&t(7,u=p.root),"theme_mode"in p&&t(8,f=p.theme_mode),"_components"in p&&t(9,c=p._components),"render_markdown"in p&&t(10,b=p.render_markdown),"scroll"in p&&t(11,m=p.scroll),"allow_file_downloads"in p&&t(12,h=p.allow_file_downloads),"display_consecutive_in_same_bubble"in p&&t(13,w=p.display_consecutive_in_same_bubble),"thought_index"in p&&t(14,d=p.thought_index),"allow_tags"in p&&t(15,$=p.allow_tags),"message"in p&&t(16,z=p.message)},[n,i,s,o,r,a,_,u,f,c,b,m,h,w,d,$,z,I]}class lo extends er{constructor(e){super(),ir(this,e,fr,ur,sr,{latex_delimiters:0,sanitize_html:1,_fetch:2,i18n:3,line_breaks:4,upload:5,target:6,root:7,theme_mode:8,_components:9,render_markdown:10,scroll:11,allow_file_downloads:12,display_consecutive_in_same_bubble:13,thought_index:14,allow_tags:15,message:16})}get latex_delimiters(){return this.$$.ctx[0]}set latex_delimiters(e){this.$$set({latex_delimiters:e}),O()}get sanitize_html(){return this.$$.ctx[1]}set sanitize_html(e){this.$$set({sanitize_html:e}),O()}get _fetch(){return this.$$.ctx[2]}set _fetch(e){this.$$set({_fetch:e}),O()}get i18n(){return this.$$.ctx[3]}set i18n(e){this.$$set({i18n:e}),O()}get line_breaks(){return this.$$.ctx[4]}set line_breaks(e){this.$$set({line_breaks:e}),O()}get upload(){return this.$$.ctx[5]}set upload(e){this.$$set({upload:e}),O()}get target(){return this.$$.ctx[6]}set target(e){this.$$set({target:e}),O()}get root(){return this.$$.ctx[7]}set root(e){this.$$set({root:e}),O()}get theme_mode(){return this.$$.ctx[8]}set theme_mode(e){this.$$set({theme_mode:e}),O()}get _components(){return this.$$.ctx[9]}set _components(e){this.$$set({_components:e}),O()}get render_markdown(){return this.$$.ctx[10]}set render_markdown(e){this.$$set({render_markdown:e}),O()}get scroll(){return this.$$.ctx[11]}set scroll(e){this.$$set({scroll:e}),O()}get allow_file_downloads(){return this.$$.ctx[12]}set allow_file_downloads(e){this.$$set({allow_file_downloads:e}),O()}get display_consecutive_in_same_bubble(){return this.$$.ctx[13]}set display_consecutive_in_same_bubble(e){this.$$set({display_consecutive_in_same_bubble:e}),O()}get thought_index(){return this.$$.ctx[14]}set thought_index(e){this.$$set({thought_index:e}),O()}get allow_tags(){return this.$$.ctx[15]}set allow_tags(e){this.$$set({allow_tags:e}),O()}get message(){return this.$$.ctx[16]}set message(e){this.$$set({message:e}),O()}}const{SvelteComponent:cr,add_render_callback:mr,append:st,attr:Ce,check_outros:ml,create_bidirectional_transition:xl,create_component:fn,destroy_component:cn,destroy_each:hr,detach:re,element:Lt,ensure_array_like:ei,flush:J,group_outros:hl,init:dr,insert:_e,listen:ti,mount_component:mn,run_all:gr,safe_not_equal:br,set_data:wn,set_style:ni,space:At,stop_propagation:wr,text:Je,toggle_class:li,transition_in:me,transition_out:je}=window.__gradio__svelte__internal;function ii(l,e,t){const n=l.slice();return n[21]=e[t],n[23]=t,n}function oi(l){let e;return{c(){e=Lt("span"),Ce(e,"class","loading-spinner svelte-i6yrue")},m(t,n){_e(t,e,n)},d(t){t&&re(e)}}}function si(l){let e,t,n=l[16].metadata.log&&ai(l),i=l[16].metadata.duration!==void 0&&ri(l);return{c(){e=Lt("span"),n&&n.c(),t=At(),i&&i.c(),Ce(e,"class","duration svelte-i6yrue")},m(s,o){_e(s,e,o),n&&n.m(e,null),st(e,t),i&&i.m(e,null)},p(s,o){s[16].metadata.log?n?n.p(s,o):(n=ai(s),n.c(),n.m(e,t)):n&&(n.d(1),n=null),s[16].metadata.duration!==void 0?i?i.p(s,o):(i=ri(s),i.c(),i.m(e,null)):i&&(i.d(1),i=null)},d(s){s&&re(e),n&&n.d(),i&&i.d()}}}function ai(l){let e=l[16].metadata.log+"",t;return{c(){t=Je(e)},m(n,i){_e(n,t,i)},p(n,i){i&65536&&e!==(e=n[16].metadata.log+"")&&wn(t,e)},d(n){n&&re(t)}}}function ri(l){let e,t,n;function i(r,a){return a&65536&&(t=null),t==null&&(t=!!Number.isInteger(r[16].metadata.duration)),t?vr:r[16].metadata.duration>=.1?pr:kr}let s=i(l,-1),o=s(l);return{c(){e=Je("("),o.c(),n=Je(")")},m(r,a){_e(r,e,a),o.m(r,a),_e(r,n,a)},p(r,a){s===(s=i(r,a))&&o?o.p(r,a):(o.d(1),o=s(r),o&&(o.c(),o.m(n.parentNode,n)))},d(r){r&&(re(e),re(n)),o.d(r)}}}function kr(l){let e=(l[16].metadata.duration*1e3).toFixed(1)+"",t,n;return{c(){t=Je(e),n=Je("ms")},m(i,s){_e(i,t,s),_e(i,n,s)},p(i,s){s&65536&&e!==(e=(i[16].metadata.duration*1e3).toFixed(1)+"")&&wn(t,e)},d(i){i&&(re(t),re(n))}}}function pr(l){let e=l[16].metadata.duration.toFixed(1)+"",t,n;return{c(){t=Je(e),n=Je("s")},m(i,s){_e(i,t,s),_e(i,n,s)},p(i,s){s&65536&&e!==(e=i[16].metadata.duration.toFixed(1)+"")&&wn(t,e)},d(i){i&&(re(t),re(n))}}}function vr(l){let e=l[16].metadata.duration+"",t,n;return{c(){t=Je(e),n=Je("s")},m(i,s){_e(i,t,s),_e(i,n,s)},p(i,s){s&65536&&e!==(e=i[16].metadata.duration+"")&&wn(t,e)},d(i){i&&(re(t),re(n))}}}function _i(l){let e,t,n,i,s;t=new lo({props:{message:l[16],sanitize_html:l[1],latex_delimiters:l[2],render_markdown:l[3],_components:l[4],upload:l[5],thought_index:l[6],target:l[7],root:l[8],theme_mode:l[9],_fetch:l[10],scroll:l[11],allow_file_downloads:l[12],display_consecutive_in_same_bubble:l[13],i18n:l[14],line_breaks:l[15]}});let o=l[16].children?.length>0&&ui(l);return{c(){e=Lt("div"),fn(t.$$.fragment),n=At(),o&&o.c(),Ce(e,"class","content svelte-i6yrue")},m(r,a){_e(r,e,a),mn(t,e,null),st(e,n),o&&o.m(e,null),s=!0},p(r,a){const _={};a&65536&&(_.message=r[16]),a&2&&(_.sanitize_html=r[1]),a&4&&(_.latex_delimiters=r[2]),a&8&&(_.render_markdown=r[3]),a&16&&(_._components=r[4]),a&32&&(_.upload=r[5]),a&64&&(_.thought_index=r[6]),a&128&&(_.target=r[7]),a&256&&(_.root=r[8]),a&512&&(_.theme_mode=r[9]),a&1024&&(_._fetch=r[10]),a&2048&&(_.scroll=r[11]),a&4096&&(_.allow_file_downloads=r[12]),a&8192&&(_.display_consecutive_in_same_bubble=r[13]),a&16384&&(_.i18n=r[14]),a&32768&&(_.line_breaks=r[15]),t.$set(_),r[16].children?.length>0?o?(o.p(r,a),a&65536&&me(o,1)):(o=ui(r),o.c(),me(o,1),o.m(e,null)):o&&(hl(),je(o,1,1,()=>{o=null}),ml())},i(r){s||(me(t.$$.fragment,r),me(o),r&&mr(()=>{s&&(i||(i=xl(e,bl,{},!0)),i.run(1))}),s=!0)},o(r){je(t.$$.fragment,r),je(o),r&&(i||(i=xl(e,bl,{},!1)),i.run(0)),s=!1},d(r){r&&re(e),cn(t),o&&o.d(),r&&i&&i.end()}}}function ui(l){let e,t,n=ei(l[16].children),i=[];for(let o=0;oje(i[o],1,1,()=>{i[o]=null});return{c(){e=Lt("div");for(let o=0;o{w=null}),ml())},i(d){f||(me(i.$$.fragment,d),me(o.$$.fragment,d),me(w),f=!0)},o(d){je(i.$$.fragment,d),je(o.$$.fragment,d),je(w),f=!1},d(d){d&&re(e),cn(i),cn(o),m&&m.d(),h&&h.d(),w&&w.d(),c=!1,gr(b)}}}function Cr(l){return"children"in l}function yr(l,e,t){let n,{thought:i}=e,{rtl:s=!1}=e,{sanitize_html:o}=e,{latex_delimiters:r}=e,{render_markdown:a}=e,{_components:_}=e,{upload:u}=e,{thought_index:f}=e,{target:c}=e,{root:b}=e,{theme_mode:m}=e,{_fetch:h}=e,{scroll:w}=e,{allow_file_downloads:d}=e,{display_consecutive_in_same_bubble:$}=e,{i18n:z}=e,{line_breaks:I}=e,p;function x(){t(17,n=!n)}const ne=y=>y.key==="Enter"&&x();return l.$$set=y=>{"thought"in y&&t(19,i=y.thought),"rtl"in y&&t(0,s=y.rtl),"sanitize_html"in y&&t(1,o=y.sanitize_html),"latex_delimiters"in y&&t(2,r=y.latex_delimiters),"render_markdown"in y&&t(3,a=y.render_markdown),"_components"in y&&t(4,_=y._components),"upload"in y&&t(5,u=y.upload),"thought_index"in y&&t(6,f=y.thought_index),"target"in y&&t(7,c=y.target),"root"in y&&t(8,b=y.root),"theme_mode"in y&&t(9,m=y.theme_mode),"_fetch"in y&&t(10,h=y._fetch),"scroll"in y&&t(11,w=y.scroll),"allow_file_downloads"in y&&t(12,d=y.allow_file_downloads),"display_consecutive_in_same_bubble"in y&&t(13,$=y.display_consecutive_in_same_bubble),"i18n"in y&&t(14,z=y.i18n),"line_breaks"in y&&t(15,I=y.line_breaks)},l.$$.update=()=>{l.$$.dirty&524288&&t(16,p={...i,children:Cr(i)?i.children:[]}),l.$$.dirty&65536&&t(17,n=p.metadata?.status!=="done")},[s,o,r,a,_,u,f,c,b,m,h,w,d,$,z,I,p,n,x,i,ne]}class io extends cr{constructor(e){super(),dr(this,e,yr,$r,br,{thought:19,rtl:0,sanitize_html:1,latex_delimiters:2,render_markdown:3,_components:4,upload:5,thought_index:6,target:7,root:8,theme_mode:9,_fetch:10,scroll:11,allow_file_downloads:12,display_consecutive_in_same_bubble:13,i18n:14,line_breaks:15})}get thought(){return this.$$.ctx[19]}set thought(e){this.$$set({thought:e}),J()}get rtl(){return this.$$.ctx[0]}set rtl(e){this.$$set({rtl:e}),J()}get sanitize_html(){return this.$$.ctx[1]}set sanitize_html(e){this.$$set({sanitize_html:e}),J()}get latex_delimiters(){return this.$$.ctx[2]}set latex_delimiters(e){this.$$set({latex_delimiters:e}),J()}get render_markdown(){return this.$$.ctx[3]}set render_markdown(e){this.$$set({render_markdown:e}),J()}get _components(){return this.$$.ctx[4]}set _components(e){this.$$set({_components:e}),J()}get upload(){return this.$$.ctx[5]}set upload(e){this.$$set({upload:e}),J()}get thought_index(){return this.$$.ctx[6]}set thought_index(e){this.$$set({thought_index:e}),J()}get target(){return this.$$.ctx[7]}set target(e){this.$$set({target:e}),J()}get root(){return this.$$.ctx[8]}set root(e){this.$$set({root:e}),J()}get theme_mode(){return this.$$.ctx[9]}set theme_mode(e){this.$$set({theme_mode:e}),J()}get _fetch(){return this.$$.ctx[10]}set _fetch(e){this.$$set({_fetch:e}),J()}get scroll(){return this.$$.ctx[11]}set scroll(e){this.$$set({scroll:e}),J()}get allow_file_downloads(){return this.$$.ctx[12]}set allow_file_downloads(e){this.$$set({allow_file_downloads:e}),J()}get display_consecutive_in_same_bubble(){return this.$$.ctx[13]}set display_consecutive_in_same_bubble(e){this.$$set({display_consecutive_in_same_bubble:e}),J()}get i18n(){return this.$$.ctx[14]}set i18n(e){this.$$set({i18n:e}),J()}get line_breaks(){return this.$$.ctx[15]}set line_breaks(e){this.$$set({line_breaks:e}),J()}}const{SvelteComponent:zr,append:Rn,assign:oo,attr:K,binding_callbacks:Sr,check_outros:Tt,create_component:Kt,destroy_component:Qt,destroy_each:Hr,detach:Re,element:jt,empty:so,ensure_array_like:ci,flush:q,get_spread_object:ao,get_spread_update:ro,group_outros:Ft,init:qr,insert:Oe,listen:Qn,mount_component:Xt,noop:mi,null_to_empty:hi,run_all:Lr,safe_not_equal:jr,set_input_value:di,set_style:Ue,space:Xn,toggle_class:D,transition_in:Z,transition_out:W}=window.__gradio__svelte__internal;function gi(l,e,t){const n=l.slice();return n[47]=e[t],n[48]=e,n[49]=t,n}function bi(l){let e,t,n;return t=new Yt({props:{class:"avatar-image",src:l[2]?.url,alt:l[4]+" avatar"}}),{c(){e=jt("div"),Kt(t.$$.fragment),K(e,"class","avatar-container svelte-yaaj3")},m(i,s){Oe(i,e,s),Xt(t,e,null),n=!0},p(i,s){const o={};s[0]&4&&(o.src=i[2]?.url),s[0]&16&&(o.alt=i[4]+" avatar"),t.$set(o)},i(i){n||(Z(t.$$.fragment,i),n=!0)},o(i){W(t.$$.fragment,i),n=!1},d(i){i&&Re(e),Qt(t)}}}function Mr(l){let e,t,n,i,s,o=l[49],r,a,_;const u=[Dr,Vr],f=[];function c(d,$){return d[47]?.metadata?.title?0:1}t=c(l),n=f[t]=u[t](l);const b=()=>l[43](e,o),m=()=>l[43](null,o);function h(){return l[44](l[47])}function w(...d){return l[45](l[47],...d)}return{c(){e=jt("div"),n.c(),K(e,"data-testid",l[4]),K(e,"dir",i=l[12]?"rtl":"ltr"),K(e,"aria-label",s=l[4]+"'s message: "+vi(l[47])),K(e,"class","svelte-yaaj3"),D(e,"latest",l[21]===l[1].length-1),D(e,"message-markdown-disabled",!l[7]),D(e,"selectable",l[10]),Ue(e,"user-select","text"),Ue(e,"cursor",l[10]?"pointer":"auto"),Ue(e,"text-align",l[12]?"right":"left")},m(d,$){Oe(d,e,$),f[t].m(e,null),b(),r=!0,a||(_=[Qn(e,"click",h),Qn(e,"keydown",w)],a=!0)},p(d,$){l=d;let z=t;t=c(l),t===z?f[t].p(l,$):(Ft(),W(f[z],1,1,()=>{f[z]=null}),Tt(),n=f[t],n?n.p(l,$):(n=f[t]=u[t](l),n.c()),Z(n,1),n.m(e,null)),(!r||$[0]&16)&&K(e,"data-testid",l[4]),(!r||$[0]&4096&&i!==(i=l[12]?"rtl":"ltr"))&&K(e,"dir",i),(!r||$[0]&48&&s!==(s=l[4]+"'s message: "+vi(l[47])))&&K(e,"aria-label",s),o!==l[49]&&(m(),o=l[49],b()),(!r||$[0]&2097154)&&D(e,"latest",l[21]===l[1].length-1),(!r||$[0]&128)&&D(e,"message-markdown-disabled",!l[7]),(!r||$[0]&1024)&&D(e,"selectable",l[10]),$[0]&1024&&Ue(e,"cursor",l[10]?"pointer":"auto"),$[0]&4096&&Ue(e,"text-align",l[12]?"right":"left")},i(d){r||(Z(n),r=!0)},o(d){W(n),r=!1},d(d){d&&Re(e),f[t].d(),m(),a=!1,Lr(_)}}}function Nr(l){let e,t,n;return{c(){e=jt("textarea"),K(e,"class","edit-textarea svelte-yaaj3"),e.autofocus=!0,Ue(e,"width",`max(${l[29]}px, 160px)`),Ue(e,"min-height",`${l[30]}px`)},m(i,s){Oe(i,e,s),di(e,l[0]),e.focus(),t||(n=Qn(e,"input",l[42]),t=!0)},p(i,s){s[0]&1&&di(e,i[0]),s[0]&536870912&&Ue(e,"width",`max(${i[29]}px, 160px)`),s[0]&1073741824&&Ue(e,"min-height",`${i[30]}px`)},i:mi,o:mi,d(i){i&&Re(e),t=!1,n()}}}function Vr(l){let e,t;return e=new lo({props:{message:l[47],sanitize_html:l[9],allow_tags:l[27],latex_delimiters:l[8],render_markdown:l[7],_components:l[20],upload:l[16],thought_index:l[49],target:l[17],root:l[18],theme_mode:l[19],_fetch:l[11],scroll:l[22],allow_file_downloads:l[23],display_consecutive_in_same_bubble:l[25],i18n:l[14],line_breaks:l[15]}}),{c(){Kt(e.$$.fragment)},m(n,i){Xt(e,n,i),t=!0},p(n,i){const s={};i[0]&32&&(s.message=n[47]),i[0]&512&&(s.sanitize_html=n[9]),i[0]&134217728&&(s.allow_tags=n[27]),i[0]&256&&(s.latex_delimiters=n[8]),i[0]&128&&(s.render_markdown=n[7]),i[0]&1048576&&(s._components=n[20]),i[0]&65536&&(s.upload=n[16]),i[0]&131072&&(s.target=n[17]),i[0]&262144&&(s.root=n[18]),i[0]&524288&&(s.theme_mode=n[19]),i[0]&2048&&(s._fetch=n[11]),i[0]&4194304&&(s.scroll=n[22]),i[0]&8388608&&(s.allow_file_downloads=n[23]),i[0]&33554432&&(s.display_consecutive_in_same_bubble=n[25]),i[0]&16384&&(s.i18n=n[14]),i[0]&32768&&(s.line_breaks=n[15]),e.$set(s)},i(n){t||(Z(e.$$.fragment,n),t=!0)},o(n){W(e.$$.fragment,n),t=!1},d(n){Qt(e,n)}}}function Dr(l){let e,t;return e=new io({props:{thought:l[47],rtl:l[12],sanitize_html:l[9],latex_delimiters:l[8],render_markdown:l[7],_components:l[20],upload:l[16],thought_index:l[49],target:l[17],root:l[18],theme_mode:l[19],_fetch:l[11],scroll:l[22],allow_file_downloads:l[23],display_consecutive_in_same_bubble:l[25],i18n:l[14],line_breaks:l[15]}}),{c(){Kt(e.$$.fragment)},m(n,i){Xt(e,n,i),t=!0},p(n,i){const s={};i[0]&32&&(s.thought=n[47]),i[0]&4096&&(s.rtl=n[12]),i[0]&512&&(s.sanitize_html=n[9]),i[0]&256&&(s.latex_delimiters=n[8]),i[0]&128&&(s.render_markdown=n[7]),i[0]&1048576&&(s._components=n[20]),i[0]&65536&&(s.upload=n[16]),i[0]&131072&&(s.target=n[17]),i[0]&262144&&(s.root=n[18]),i[0]&524288&&(s.theme_mode=n[19]),i[0]&2048&&(s._fetch=n[11]),i[0]&4194304&&(s.scroll=n[22]),i[0]&8388608&&(s.allow_file_downloads=n[23]),i[0]&33554432&&(s.display_consecutive_in_same_bubble=n[25]),i[0]&16384&&(s.i18n=n[14]),i[0]&32768&&(s.line_breaks=n[15]),e.$set(s)},i(n){t||(Z(e.$$.fragment,n),t=!0)},o(n){W(e.$$.fragment,n),t=!1},d(n){Qt(e,n)}}}function wi(l){let e,t;const n=[l[31],{current_feedback:l[26]}];let i={};for(let s=0;s0)},m(c,b){Oe(c,e,b),_[t].m(e,null),Oe(c,s,b),f&&f.m(c,b),Oe(c,o,b),r=!0},p(c,b){let m=t;t=u(c),t===m?_[t].p(c,b):(Ft(),W(_[m],1,1,()=>{_[m]=null}),Tt(),n=_[t],n?n.p(c,b):(n=_[t]=a[t](c),n.c()),Z(n,1),n.m(e,null)),(!r||b[0]&33554448&&i!==(i="message "+(c[25]?"":c[4])+" svelte-yaaj3"))&&K(e,"class",i),(!r||b[0]&33554448)&&D(e,"panel-full-width",!0),(!r||b[0]&33554576)&&D(e,"message-markdown-disabled",!c[7]),(!r||b[0]&33554480)&&D(e,"component",c[47].type==="component"),(!r||b[0]&33554480)&&D(e,"html",vl(c[47])&&c[47].content.component==="html"),(!r||b[0]&33554448)&&D(e,"thought",c[49]>0),c[6]==="panel"?f?(f.p(c,b),b[0]&64&&Z(f,1)):(f=wi(c),f.c(),Z(f,1),f.m(o.parentNode,o)):f&&(Ft(),W(f,1,1,()=>{f=null}),Tt())},i(c){r||(Z(n),Z(f),r=!0)},o(c){W(n),W(f),r=!1},d(c){c&&(Re(e),Re(s),Re(o)),_[t].d(),f&&f.d(c)}}}function pi(l){let e,t;const n=[l[31]];let i={};for(let s=0;sW(c[h],1,1,()=>{c[h]=null});let m=l[6]==="bubble"&&pi(l);return{c(){e=jt("div"),u&&u.c(),t=Xn(),n=jt("div"),i=jt("div");for(let h=0;h{u=null}),Tt()),w[0]&2147483635|w[1]&3){f=ci(h[5]);let d;for(d=0;d{m=null}),Tt())},i(h){if(!_){Z(u);for(let w=0;w{ue[ke]=v,t(28,ue)})}const it=v=>Be(ne,v),Y=(v,ke)=>{ke.key==="Enter"&&Be(ne,v)},It=v=>h("copy",v.detail);return l.$$set=v=>{"value"in v&&t(1,n=v.value),"avatar_img"in v&&t(2,i=v.avatar_img),"opposite_avatar_img"in v&&t(3,s=v.opposite_avatar_img),"role"in v&&t(4,o=v.role),"messages"in v&&t(5,r=v.messages),"layout"in v&&t(6,a=v.layout),"render_markdown"in v&&t(7,_=v.render_markdown),"latex_delimiters"in v&&t(8,u=v.latex_delimiters),"sanitize_html"in v&&t(9,f=v.sanitize_html),"selectable"in v&&t(10,c=v.selectable),"_fetch"in v&&t(11,b=v._fetch),"rtl"in v&&t(12,m=v.rtl),"dispatch"in v&&t(13,h=v.dispatch),"i18n"in v&&t(14,w=v.i18n),"line_breaks"in v&&t(15,d=v.line_breaks),"upload"in v&&t(16,$=v.upload),"target"in v&&t(17,z=v.target),"root"in v&&t(18,I=v.root),"theme_mode"in v&&t(19,p=v.theme_mode),"_components"in v&&t(20,x=v._components),"i"in v&&t(21,ne=v.i),"show_copy_button"in v&&t(33,y=v.show_copy_button),"generating"in v&&t(34,ge=v.generating),"feedback_options"in v&&t(35,S=v.feedback_options),"show_like"in v&&t(36,Me=v.show_like),"show_edit"in v&&t(37,Ne=v.show_edit),"show_retry"in v&&t(38,Ve=v.show_retry),"show_undo"in v&&t(39,ze=v.show_undo),"msg_format"in v&&t(40,E=v.msg_format),"handle_action"in v&&t(41,De=v.handle_action),"scroll"in v&&t(22,Xe=v.scroll),"allow_file_downloads"in v&&t(23,xe=v.allow_file_downloads),"in_edit_mode"in v&&t(24,be=v.in_edit_mode),"edit_message"in v&&t(0,we=v.edit_message),"display_consecutive_in_same_bubble"in v&&t(25,et=v.display_consecutive_in_same_bubble),"current_feedback"in v&&t(26,Ie=v.current_feedback),"allow_tags"in v&&t(27,tt=v.allow_tags)},l.$$.update=()=>{l.$$.dirty[0]&285212672&&be&&!Br&&(t(29,nt=ue[ue.length-1]?.clientWidth),t(30,lt=ue[ue.length-1]?.clientHeight)),l.$$.dirty[0]&83894388|l.$$.dirty[1]&2044&&t(31,Se={handle_action:De,likeable:Me,feedback_options:S,show_retry:Ve,show_undo:ze,show_edit:Ne,in_edit_mode:be,generating:ge,show_copy_button:y,message:E==="tuples"?r[0]:r,position:o==="user"?"right":"left",avatar:i,layout:a,dispatch:h,current_feedback:Ie})},[we,n,i,s,o,r,a,_,u,f,c,b,m,h,w,d,$,z,I,p,x,ne,Xe,xe,be,et,Ie,tt,ue,nt,lt,Se,Be,y,ge,S,Me,Ne,Ve,ze,E,De,Ee,G,it,Y,It]}class Ar extends zr{constructor(e){super(),qr(this,e,Er,Ir,jr,{value:1,avatar_img:2,opposite_avatar_img:3,role:4,messages:5,layout:6,render_markdown:7,latex_delimiters:8,sanitize_html:9,selectable:10,_fetch:11,rtl:12,dispatch:13,i18n:14,line_breaks:15,upload:16,target:17,root:18,theme_mode:19,_components:20,i:21,show_copy_button:33,generating:34,feedback_options:35,show_like:36,show_edit:37,show_retry:38,show_undo:39,msg_format:40,handle_action:41,scroll:22,allow_file_downloads:23,in_edit_mode:24,edit_message:0,display_consecutive_in_same_bubble:25,current_feedback:26,allow_tags:27},null,[-1,-1])}get value(){return this.$$.ctx[1]}set value(e){this.$$set({value:e}),q()}get avatar_img(){return this.$$.ctx[2]}set avatar_img(e){this.$$set({avatar_img:e}),q()}get opposite_avatar_img(){return this.$$.ctx[3]}set opposite_avatar_img(e){this.$$set({opposite_avatar_img:e}),q()}get role(){return this.$$.ctx[4]}set role(e){this.$$set({role:e}),q()}get messages(){return this.$$.ctx[5]}set messages(e){this.$$set({messages:e}),q()}get layout(){return this.$$.ctx[6]}set layout(e){this.$$set({layout:e}),q()}get render_markdown(){return this.$$.ctx[7]}set render_markdown(e){this.$$set({render_markdown:e}),q()}get latex_delimiters(){return this.$$.ctx[8]}set latex_delimiters(e){this.$$set({latex_delimiters:e}),q()}get sanitize_html(){return this.$$.ctx[9]}set sanitize_html(e){this.$$set({sanitize_html:e}),q()}get selectable(){return this.$$.ctx[10]}set selectable(e){this.$$set({selectable:e}),q()}get _fetch(){return this.$$.ctx[11]}set _fetch(e){this.$$set({_fetch:e}),q()}get rtl(){return this.$$.ctx[12]}set rtl(e){this.$$set({rtl:e}),q()}get dispatch(){return this.$$.ctx[13]}set dispatch(e){this.$$set({dispatch:e}),q()}get i18n(){return this.$$.ctx[14]}set i18n(e){this.$$set({i18n:e}),q()}get line_breaks(){return this.$$.ctx[15]}set line_breaks(e){this.$$set({line_breaks:e}),q()}get upload(){return this.$$.ctx[16]}set upload(e){this.$$set({upload:e}),q()}get target(){return this.$$.ctx[17]}set target(e){this.$$set({target:e}),q()}get root(){return this.$$.ctx[18]}set root(e){this.$$set({root:e}),q()}get theme_mode(){return this.$$.ctx[19]}set theme_mode(e){this.$$set({theme_mode:e}),q()}get _components(){return this.$$.ctx[20]}set _components(e){this.$$set({_components:e}),q()}get i(){return this.$$.ctx[21]}set i(e){this.$$set({i:e}),q()}get show_copy_button(){return this.$$.ctx[33]}set show_copy_button(e){this.$$set({show_copy_button:e}),q()}get generating(){return this.$$.ctx[34]}set generating(e){this.$$set({generating:e}),q()}get feedback_options(){return this.$$.ctx[35]}set feedback_options(e){this.$$set({feedback_options:e}),q()}get show_like(){return this.$$.ctx[36]}set show_like(e){this.$$set({show_like:e}),q()}get show_edit(){return this.$$.ctx[37]}set show_edit(e){this.$$set({show_edit:e}),q()}get show_retry(){return this.$$.ctx[38]}set show_retry(e){this.$$set({show_retry:e}),q()}get show_undo(){return this.$$.ctx[39]}set show_undo(e){this.$$set({show_undo:e}),q()}get msg_format(){return this.$$.ctx[40]}set msg_format(e){this.$$set({msg_format:e}),q()}get handle_action(){return this.$$.ctx[41]}set handle_action(e){this.$$set({handle_action:e}),q()}get scroll(){return this.$$.ctx[22]}set scroll(e){this.$$set({scroll:e}),q()}get allow_file_downloads(){return this.$$.ctx[23]}set allow_file_downloads(e){this.$$set({allow_file_downloads:e}),q()}get in_edit_mode(){return this.$$.ctx[24]}set in_edit_mode(e){this.$$set({in_edit_mode:e}),q()}get edit_message(){return this.$$.ctx[0]}set edit_message(e){this.$$set({edit_message:e}),q()}get display_consecutive_in_same_bubble(){return this.$$.ctx[25]}set display_consecutive_in_same_bubble(e){this.$$set({display_consecutive_in_same_bubble:e}),q()}get current_feedback(){return this.$$.ctx[26]}set current_feedback(e){this.$$set({current_feedback:e}),q()}get allow_tags(){return this.$$.ctx[27]}set allow_tags(e){this.$$set({allow_tags:e}),q()}}const{SvelteComponent:Tr,append:On,attr:ot,check_outros:Fr,create_component:Zr,destroy_component:Ur,detach:_o,element:sn,flush:$i,group_outros:Pr,init:Rr,insert:uo,mount_component:Or,safe_not_equal:Jr,space:Wr,toggle_class:ln,transition_in:an,transition_out:xn}=window.__gradio__svelte__internal;function Ci(l){let e,t,n;return t=new Yt({props:{class:"avatar-image",src:l[1][1].url,alt:"bot avatar"}}),{c(){e=sn("div"),Zr(t.$$.fragment),ot(e,"class","avatar-container svelte-134ihlx")},m(i,s){uo(i,e,s),Or(t,e,null),n=!0},p(i,s){const o={};s&2&&(o.src=i[1][1].url),t.$set(o)},i(i){n||(an(t.$$.fragment,i),n=!0)},o(i){xn(t.$$.fragment,i),n=!1},d(i){i&&_o(e),Ur(t)}}}function Gr(l){let e,t,n,i,s,o,r=l[1][1]!==null&&Ci(l);return{c(){e=sn("div"),r&&r.c(),t=Wr(),n=sn("div"),i=sn("div"),i.innerHTML='Loading content ',ot(i,"class","message-content svelte-134ihlx"),ot(n,"class",s="message bot pending "+l[0]+" svelte-134ihlx"),ot(n,"role","status"),ot(n,"aria-label","Loading response"),ot(n,"aria-live","polite"),ln(n,"with_avatar",l[1][1]!==null),ln(n,"with_opposite_avatar",l[1][0]!==null),ot(e,"class","container svelte-134ihlx")},m(a,_){uo(a,e,_),r&&r.m(e,null),On(e,t),On(e,n),On(n,i),o=!0},p(a,[_]){a[1][1]!==null?r?(r.p(a,_),_&2&&an(r,1)):(r=Ci(a),r.c(),an(r,1),r.m(e,t)):r&&(Pr(),xn(r,1,1,()=>{r=null}),Fr()),(!o||_&1&&s!==(s="message bot pending "+a[0]+" svelte-134ihlx"))&&ot(n,"class",s),(!o||_&3)&&ln(n,"with_avatar",a[1][1]!==null),(!o||_&3)&&ln(n,"with_opposite_avatar",a[1][0]!==null)},i(a){o||(an(r),o=!0)},o(a){xn(r),o=!1},d(a){a&&_o(e),r&&r.d()}}}function Yr(l,e,t){let{layout:n="bubble"}=e,{avatar_images:i=[null,null]}=e;return l.$$set=s=>{"layout"in s&&t(0,n=s.layout),"avatar_images"in s&&t(1,i=s.avatar_images)},[n,i]}class fo extends Tr{constructor(e){super(),Rr(this,e,Yr,Gr,Jr,{layout:0,avatar_images:1})}get layout(){return this.$$.ctx[0]}set layout(e){this.$$set({layout:e}),$i()}get avatar_images(){return this.$$.ctx[1]}set avatar_images(e){this.$$set({avatar_images:e}),$i()}}const{SvelteComponent:Kr,append:U,attr:C,check_outros:mt,create_component:bt,destroy_component:wt,destroy_each:co,detach:P,element:T,empty:mo,ensure_array_like:hn,flush:on,group_outros:ht,init:Qr,insert:R,listen:Xr,mount_component:kt,noop:Mt,safe_not_equal:xr,set_data:kn,space:Pt,src_url_equal:dn,text:Nt,transition_in:N,transition_out:A}=window.__gradio__svelte__internal,{createEventDispatcher:e_}=window.__gradio__svelte__internal;function yi(l,e,t){const n=l.slice();return n[7]=e[t],n[9]=t,n}function zi(l,e,t){const n=l.slice();return n[10]=e[t],n[9]=t,n}function Si(l){let e,t,n;return t=new nl({props:{message:l[1],latex_delimiters:l[2],root:l[3]}}),{c(){e=T("div"),bt(t.$$.fragment),C(e,"class","placeholder svelte-9pi8y1")},m(i,s){R(i,e,s),kt(t,e,null),n=!0},p(i,s){const o={};s&2&&(o.message=i[1]),s&4&&(o.latex_delimiters=i[2]),s&8&&(o.root=i[3]),t.$set(o)},i(i){n||(N(t.$$.fragment,i),n=!0)},o(i){A(t.$$.fragment,i),n=!1},d(i){i&&P(e),wt(t)}}}function Hi(l){let e,t,n=hn(l[0]),i=[];for(let o=0;oA(i[o],1,1,()=>{i[o]=null});return{c(){e=T("div");for(let o=0;o1?0:(e==null&&(e=!!f[7].files[0].mime_type?.includes("image")),e?1:(t==null&&(t=!!f[7].files[0].mime_type?.includes("video")),t?2:(n==null&&(n=!!f[7].files[0].mime_type?.includes("audio")),n?3:4)))}return i=u(l,-1),s=_[i]=a[i](l),{c(){s.c(),o=mo()},m(f,c){_[i].m(f,c),R(f,o,c),r=!0},p(f,c){let b=i;i=u(f,c),i===b?_[i].p(f,c):(ht(),A(_[b],1,1,()=>{_[b]=null}),mt(),s=_[i],s?s.p(f,c):(s=_[i]=a[i](f),s.c()),N(s,1),s.m(o.parentNode,o))},i(f){r||(N(s),r=!0)},o(f){A(s),r=!1},d(f){f&&P(o),_[i].d(f)}}}function n_(l){let e;return{c(){e=T("div"),e.innerHTML='Aa',C(e,"class","example-icon svelte-9pi8y1"),C(e,"aria-hidden","true")},m(t,n){R(t,e,n)},p:Mt,i:Mt,o:Mt,d(t){t&&P(e)}}}function l_(l){let e,t,n;return t=new Yt({props:{class:"example-image",src:l[7].icon.url,alt:"Example icon"}}),{c(){e=T("div"),bt(t.$$.fragment),C(e,"class","example-image-container svelte-9pi8y1")},m(i,s){R(i,e,s),kt(t,e,null),n=!0},p(i,s){const o={};s&1&&(o.src=i[7].icon.url),t.$set(o)},i(i){n||(N(t.$$.fragment,i),n=!0)},o(i){A(t.$$.fragment,i),n=!1},d(i){i&&P(e),wt(t)}}}function i_(l){let e,t,n,i;return t=new tl({}),{c(){e=T("div"),bt(t.$$.fragment),C(e,"class","example-icon svelte-9pi8y1"),C(e,"aria-label",n=`File: ${l[7].files[0].orig_name}`)},m(s,o){R(s,e,o),kt(t,e,null),i=!0},p(s,o){(!i||o&1&&n!==(n=`File: ${s[7].files[0].orig_name}`))&&C(e,"aria-label",n)},i(s){i||(N(t.$$.fragment,s),i=!0)},o(s){A(t.$$.fragment,s),i=!1},d(s){s&&P(e),wt(t)}}}function o_(l){let e,t,n,i;return t=new Qi({}),{c(){e=T("div"),bt(t.$$.fragment),C(e,"class","example-icon svelte-9pi8y1"),C(e,"aria-label",n=`File: ${l[7].files[0].orig_name}`)},m(s,o){R(s,e,o),kt(t,e,null),i=!0},p(s,o){(!i||o&1&&n!==(n=`File: ${s[7].files[0].orig_name}`))&&C(e,"aria-label",n)},i(s){i||(N(t.$$.fragment,s),i=!0)},o(s){A(t.$$.fragment,s),i=!1},d(s){s&&P(e),wt(t)}}}function s_(l){let e,t,n;return{c(){e=T("div"),t=T("video"),C(t,"class","example-image"),dn(t.src,n=l[7].files[0].url)||C(t,"src",n),C(t,"aria-hidden","true"),C(e,"class","example-image-container svelte-9pi8y1")},m(i,s){R(i,e,s),U(e,t)},p(i,s){s&1&&!dn(t.src,n=i[7].files[0].url)&&C(t,"src",n)},i:Mt,o:Mt,d(i){i&&P(e)}}}function a_(l){let e,t,n;return t=new Yt({props:{class:"example-image",src:l[7].files[0].url,alt:l[7].files[0].orig_name||"Example image"}}),{c(){e=T("div"),bt(t.$$.fragment),C(e,"class","example-image-container svelte-9pi8y1")},m(i,s){R(i,e,s),kt(t,e,null),n=!0},p(i,s){const o={};s&1&&(o.src=i[7].files[0].url),s&1&&(o.alt=i[7].files[0].orig_name||"Example image"),t.$set(o)},i(i){n||(N(t.$$.fragment,i),n=!0)},o(i){A(t.$$.fragment,i),n=!1},d(i){i&&P(e),wt(t)}}}function r_(l){let e,t,n,i=hn(l[7].files.slice(0,4)),s=[];for(let a=0;aA(s[a],1,1,()=>{s[a]=null});let r=l[7].files.length>4&&Mi(l);return{c(){e=T("div");for(let a=0;a4?r?r.p(a,_):(r=Mi(a),r.c(),r.m(e,null)):r&&(r.d(1),r=null)},i(a){if(!n){for(let _=0;_{a[c]=null}),mt(),i=a[n],i||(i=a[n]=r[n](u),i.c()),N(i,1),i.m(e,null)),(!o||f&1&&s!==(s=`File: ${u[10].orig_name}`))&&C(e,"aria-label",s)},i(u){o||(N(i),o=!0)},o(u){A(i),o=!1},d(u){u&&P(e),a[n].d()}}}function u_(l){let e,t,n,i,s=l[9]===3&&l[7].files.length>4&&qi(l);return{c(){e=T("div"),t=T("video"),i=Pt(),s&&s.c(),C(t,"class","example-image"),dn(t.src,n=l[10].url)||C(t,"src",n),C(t,"aria-hidden","true"),C(e,"class","example-image-container svelte-9pi8y1")},m(o,r){R(o,e,r),U(e,t),U(e,i),s&&s.m(e,null)},p(o,r){r&1&&!dn(t.src,n=o[10].url)&&C(t,"src",n),o[9]===3&&o[7].files.length>4?s?s.p(o,r):(s=qi(o),s.c(),s.m(e,null)):s&&(s.d(1),s=null)},i:Mt,o:Mt,d(o){o&&P(e),s&&s.d()}}}function f_(l){let e,t,n,i;t=new Yt({props:{class:"example-image",src:l[10].url,alt:l[10].orig_name||`Example image ${l[9]+1}`}});let s=l[9]===3&&l[7].files.length>4&&Li(l);return{c(){e=T("div"),bt(t.$$.fragment),n=Pt(),s&&s.c(),C(e,"class","example-image-container svelte-9pi8y1")},m(o,r){R(o,e,r),kt(t,e,null),U(e,n),s&&s.m(e,null),i=!0},p(o,r){const a={};r&1&&(a.src=o[10].url),r&1&&(a.alt=o[10].orig_name||`Example image ${o[9]+1}`),t.$set(a),o[9]===3&&o[7].files.length>4?s?s.p(o,r):(s=Li(o),s.c(),s.m(e,null)):s&&(s.d(1),s=null)},i(o){i||(N(t.$$.fragment,o),i=!0)},o(o){A(t.$$.fragment,o),i=!1},d(o){o&&P(e),wt(t),s&&s.d()}}}function c_(l){let e,t;return e=new tl({}),{c(){bt(e.$$.fragment)},m(n,i){kt(e,n,i),t=!0},i(n){t||(N(e.$$.fragment,n),t=!0)},o(n){A(e.$$.fragment,n),t=!1},d(n){wt(e,n)}}}function m_(l){let e,t;return e=new Qi({}),{c(){bt(e.$$.fragment)},m(n,i){kt(e,n,i),t=!0},i(n){t||(N(e.$$.fragment,n),t=!0)},o(n){A(e.$$.fragment,n),t=!1},d(n){wt(e,n)}}}function qi(l){let e,t,n=l[7].files.length-4+"",i,s;return{c(){e=T("div"),t=Nt("+"),i=Nt(n),C(e,"class","image-overlay svelte-9pi8y1"),C(e,"role","status"),C(e,"aria-label",s=`${l[7].files.length-4} more files`)},m(o,r){R(o,e,r),U(e,t),U(e,i)},p(o,r){r&1&&n!==(n=o[7].files.length-4+"")&&kn(i,n),r&1&&s!==(s=`${o[7].files.length-4} more files`)&&C(e,"aria-label",s)},d(o){o&&P(e)}}}function Li(l){let e,t,n=l[7].files.length-4+"",i,s;return{c(){e=T("div"),t=Nt("+"),i=Nt(n),C(e,"class","image-overlay svelte-9pi8y1"),C(e,"role","status"),C(e,"aria-label",s=`${l[7].files.length-4} more files`)},m(o,r){R(o,e,r),U(e,t),U(e,i)},p(o,r){r&1&&n!==(n=o[7].files.length-4+"")&&kn(i,n),r&1&&s!==(s=`${o[7].files.length-4} more files`)&&C(e,"aria-label",s)},d(o){o&&P(e)}}}function ji(l){let e,t,n,i,s,o;const r=[f_,u_,__],a=[];function _(u,f){return f&1&&(e=null),f&1&&(t=null),e==null&&(e=!!u[10].mime_type?.includes("image")),e?0:(t==null&&(t=!!u[10].mime_type?.includes("video")),t?1:2)}return n=_(l,-1),i=a[n]=r[n](l),{c(){i.c(),s=mo()},m(u,f){a[n].m(u,f),R(u,s,f),o=!0},p(u,f){let c=n;n=_(u,f),n===c?a[n].p(u,f):(ht(),A(a[c],1,1,()=>{a[c]=null}),mt(),i=a[n],i?i.p(u,f):(i=a[n]=r[n](u),i.c()),N(i,1),i.m(s.parentNode,s))},i(u){o||(N(i),o=!0)},o(u){A(i),o=!1},d(u){u&&P(s),a[n].d(u)}}}function Mi(l){let e,t,n,i=l[7].files.length-4+"",s,o;return{c(){e=T("div"),t=T("div"),n=Nt("+"),s=Nt(i),C(t,"class","file-overlay svelte-9pi8y1"),C(t,"role","status"),C(t,"aria-label",o=`${l[7].files.length-4} more files`),C(e,"class","example-icon svelte-9pi8y1")},m(r,a){R(r,e,a),U(e,t),U(t,n),U(t,s)},p(r,a){a&1&&i!==(i=r[7].files.length-4+"")&&kn(s,i),a&1&&o!==(o=`${r[7].files.length-4} more files`)&&C(t,"aria-label",o)},d(r){r&&P(e)}}}function Ni(l){let e,t,n,i,s,o,r,a=(l[7].display_text||l[7].text)+"",_,u,f,c,b,m;const h=[l_,n_,t_],w=[];function d(z,I){return z[7]?.icon?.url?0:z[7]?.icon?.mime_type==="text"?1:z[7].files!==void 0&&z[7].files.length>0?2:-1}~(n=d(l))&&(i=w[n]=h[n](l));function $(){return l[5](l[9],l[7])}return{c(){e=T("button"),t=T("div"),i&&i.c(),s=Pt(),o=T("div"),r=T("span"),_=Nt(a),u=Pt(),C(r,"class","example-text svelte-9pi8y1"),C(o,"class","example-text-content svelte-9pi8y1"),C(t,"class","example-content svelte-9pi8y1"),C(e,"class","example svelte-9pi8y1"),C(e,"aria-label",f=`Select example ${l[9]+1}: ${l[7].display_text||l[7].text}`)},m(z,I){R(z,e,I),U(e,t),~n&&w[n].m(t,null),U(t,s),U(t,o),U(o,r),U(r,_),U(e,u),c=!0,b||(m=Xr(e,"click",$),b=!0)},p(z,I){l=z;let p=n;n=d(l),n===p?~n&&w[n].p(l,I):(i&&(ht(),A(w[p],1,1,()=>{w[p]=null}),mt()),~n?(i=w[n],i?i.p(l,I):(i=w[n]=h[n](l),i.c()),N(i,1),i.m(t,s)):i=null),(!c||I&1)&&a!==(a=(l[7].display_text||l[7].text)+"")&&kn(_,a),(!c||I&1&&f!==(f=`Select example ${l[9]+1}: ${l[7].display_text||l[7].text}`))&&C(e,"aria-label",f)},i(z){c||(N(i),c=!0)},o(z){A(i),c=!1},d(z){z&&P(e),~n&&w[n].d(),b=!1,m()}}}function h_(l){let e,t,n,i=l[1]!==null&&Si(l),s=l[0]!==null&&Hi(l);return{c(){e=T("div"),i&&i.c(),t=Pt(),s&&s.c(),C(e,"class","placeholder-content svelte-9pi8y1"),C(e,"role","complementary")},m(o,r){R(o,e,r),i&&i.m(e,null),U(e,t),s&&s.m(e,null),n=!0},p(o,[r]){o[1]!==null?i?(i.p(o,r),r&2&&N(i,1)):(i=Si(o),i.c(),N(i,1),i.m(e,t)):i&&(ht(),A(i,1,1,()=>{i=null}),mt()),o[0]!==null?s?(s.p(o,r),r&1&&N(s,1)):(s=Hi(o),s.c(),N(s,1),s.m(e,null)):s&&(ht(),A(s,1,1,()=>{s=null}),mt())},i(o){n||(N(i),N(s),n=!0)},o(o){A(i),A(s),n=!1},d(o){o&&P(e),i&&i.d(),s&&s.d()}}}function d_(l,e,t){let{examples:n=null}=e,{placeholder:i=null}=e,{latex_delimiters:s}=e,{root:o}=e;const r=e_();function a(u,f){const c=typeof f=="string"?{text:f}:f;r("example_select",{index:u,value:{text:c.text,files:c.files}})}const _=(u,f)=>a(u,typeof f=="string"?{text:f}:f);return l.$$set=u=>{"examples"in u&&t(0,n=u.examples),"placeholder"in u&&t(1,i=u.placeholder),"latex_delimiters"in u&&t(2,s=u.latex_delimiters),"root"in u&&t(3,o=u.root)},[n,i,s,o,a,_]}class g_ extends Kr{constructor(e){super(),Qr(this,e,d_,h_,xr,{examples:0,placeholder:1,latex_delimiters:2,root:3})}get examples(){return this.$$.ctx[0]}set examples(e){this.$$set({examples:e}),on()}get placeholder(){return this.$$.ctx[1]}set placeholder(e){this.$$set({placeholder:e}),on()}get latex_delimiters(){return this.$$.ctx[2]}set latex_delimiters(e){this.$$set({latex_delimiters:e}),on()}get root(){return this.$$.ctx[3]}set root(e){this.$$set({root:e}),on()}}const{SvelteComponent:b_,create_component:w_,destroy_component:k_,flush:p_,init:v_,mount_component:$_,safe_not_equal:C_,transition_in:y_,transition_out:z_}=window.__gradio__svelte__internal,{onDestroy:S_}=window.__gradio__svelte__internal;function H_(l){let e,t;return e=new le({props:{Icon:l[0]?Jt:rn,label:l[0]?"Copied conversation":"Copy conversation"}}),e.$on("click",l[1]),{c(){w_(e.$$.fragment)},m(n,i){$_(e,n,i),t=!0},p(n,[i]){const s={};i&1&&(s.Icon=n[0]?Jt:rn),i&1&&(s.label=n[0]?"Copied conversation":"Copy conversation"),e.$set(s)},i(n){t||(y_(e.$$.fragment,n),t=!0)},o(n){z_(e.$$.fragment,n),t=!1},d(n){k_(e,n)}}}function q_(l,e,t){let n=!1,{value:i}=e,s;function o(){t(0,n=!0),s&&clearTimeout(s),s=setTimeout(()=>{t(0,n=!1)},1e3)}const r=()=>{if(i){const _=i.map(u=>u.type==="text"?`${u.role}: ${u.content}`:`${u.role}: ${u.content.value.url}`).join(`
`);navigator.clipboard.writeText(_).catch(u=>{console.error("Failed to copy conversation: ",u)})}};async function a(){"clipboard"in navigator&&(r(),o())}return S_(()=>{s&&clearTimeout(s)}),l.$$set=_=>{"value"in _&&t(2,i=_.value)},[n,a,i]}class L_ extends b_{constructor(e){super(),v_(this,e,q_,H_,C_,{value:2})}get value(){return this.$$.ctx[2]}set value(e){this.$$set({value:e}),p_()}}const{SvelteComponent:j_,action_destroyer:M_,add_flush_callback:N_,append:el,attr:Pe,bind:V_,binding_callbacks:ho,check_outros:rt,create_component:Ye,destroy_component:Ke,destroy_each:go,detach:he,element:xt,empty:dl,ensure_array_like:gn,flush:L,group_outros:_t,init:D_,insert:de,listen:I_,mount_component:Qe,noop:bn,null_to_empty:Vi,safe_not_equal:B_,set_data:E_,space:Vt,text:A_,transition_in:j,transition_out:B}=window.__gradio__svelte__internal,{createEventDispatcher:T_,tick:F_,onMount:Jn}=window.__gradio__svelte__internal;function Di(l,e,t){const n=l.slice();return n[60]=e[t],n[62]=t,n}function Ii(l,e,t){const n=l.slice();n[63]=e[t],n[70]=t;const i=n[63][0].role==="user"?"user":"bot";n[64]=i;const s=n[16][n[64]==="user"?0:1];n[65]=s;const o=n[16][n[64]==="user"?0:1];n[66]=o;const r=n[38].slice(0,n[70]).filter(_=>_[0].role==="assistant").length;n[67]=r;const a=n[64]==="bot"&&n[10]&&n[10][n[67]]?n[10][n[67]]:null;return n[68]=a,n}function Bi(l){let e,t;return e=new Ki({props:{$$slots:{default:[Z_]},$$scope:{ctx:l}}}),{c(){Ye(e.$$.fragment)},m(n,i){Qe(e,n,i),t=!0},p(n,i){const s={};i[0]&12289|i[2]&512&&(s.$$scope={dirty:i,ctx:n}),e.$set(s)},i(n){t||(j(e.$$.fragment,n),t=!0)},o(n){B(e.$$.fragment,n),t=!1},d(n){Ke(e,n)}}}function Ei(l){let e,t;return e=new le({props:{Icon:So}}),e.$on("click",l[47]),{c(){Ye(e.$$.fragment)},m(n,i){Qe(e,n,i),t=!0},p:bn,i(n){t||(j(e.$$.fragment,n),t=!0)},o(n){B(e.$$.fragment,n),t=!1},d(n){Ke(e,n)}}}function Ai(l){let e,t;return e=new L_({props:{value:l[0]}}),{c(){Ye(e.$$.fragment)},m(n,i){Qe(e,n,i),t=!0},p(n,i){const s={};i[0]&1&&(s.value=n[0]),e.$set(s)},i(n){t||(j(e.$$.fragment,n),t=!0)},o(n){B(e.$$.fragment,n),t=!1},d(n){Ke(e,n)}}}function Z_(l){let e,t,n,i,s,o=l[12]&&Ei(l);t=new le({props:{Icon:Ho,label:"Clear"}}),t.$on("click",l[48]);let r=l[13]&&Ai(l);return{c(){o&&o.c(),e=Vt(),Ye(t.$$.fragment),n=Vt(),r&&r.c(),i=dl()},m(a,_){o&&o.m(a,_),de(a,e,_),Qe(t,a,_),de(a,n,_),r&&r.m(a,_),de(a,i,_),s=!0},p(a,_){a[12]?o?(o.p(a,_),_[0]&4096&&j(o,1)):(o=Ei(a),o.c(),j(o,1),o.m(e.parentNode,e)):o&&(_t(),B(o,1,1,()=>{o=null}),rt()),a[13]?r?(r.p(a,_),_[0]&8192&&j(r,1)):(r=Ai(a),r.c(),j(r,1),r.m(i.parentNode,i)):r&&(_t(),B(r,1,1,()=>{r=null}),rt())},i(a){s||(j(o),j(t.$$.fragment,a),j(r),s=!0)},o(a){B(o),B(t.$$.fragment,a),B(r),s=!1},d(a){a&&(he(e),he(n),he(i)),o&&o.d(a),Ke(t,a),r&&r.d(a)}}}function U_(l){let e,t;return e=new g_({props:{examples:l[26],placeholder:l[23],latex_delimiters:l[4],root:l[30]}}),e.$on("example_select",l[53]),{c(){Ye(e.$$.fragment)},m(n,i){Qe(e,n,i),t=!0},p(n,i){const s={};i[0]&67108864&&(s.examples=n[26]),i[0]&8388608&&(s.placeholder=n[23]),i[0]&16&&(s.latex_delimiters=n[4]),i[0]&1073741824&&(s.root=n[30]),e.$set(s)},i(n){t||(j(e.$$.fragment,n),t=!0)},o(n){B(e.$$.fragment,n),t=!1},d(n){Ke(e,n)}}}function P_(l){let e,t,n,i,s,o,r,a=gn(l[38]),_=[];for(let m=0;mB(_[m],1,1,()=>{_[m]=null}),f=[O_,R_],c=[];function b(m,h){return m[5]?0:m[39]?1:-1}return~(n=b(l))&&(i=c[n]=f[n](l)),{c(){e=xt("div");for(let m=0;m<_.length;m+=1)_[m].c();t=Vt(),i&&i.c(),Pe(e,"class","message-wrap svelte-gjtrl6")},m(m,h){de(m,e,h);for(let w=0;w<_.length;w+=1)_[w]&&_[w].m(e,null);el(e,t),~n&&c[n].m(e,null),s=!0,o||(r=M_(vo.call(null,e)),o=!0)},p(m,h){if(h[0]&2071973855|h[1]&5791){a=gn(m[38]);let d;for(d=0;d{c[w]=null}),rt()),~n?(i=c[n],i?i.p(m,h):(i=c[n]=f[n](m),i.c()),j(i,1),i.m(e,null)):i=null)},i(m){if(!s){for(let h=0;h0&&l[63][l[63].length-1].type=="text",in_edit_mode:l[34]===l[70],show_copy_button:l[15],handle_action:o,scroll:l[40]?scroll:W_,allow_file_downloads:l[2]};l[35]!==void 0&&(a.edit_message=l[35]),e=new Ar({props:a}),ho.push(()=>V_(e,"edit_message",r)),e.$on("copy",l[51]);let _=l[6]&&l[63][l[63].length-1].role==="assistant"&&l[63][l[63].length-1].metadata?.status==="done"&&Ti(l);return{c(){Ye(e.$$.fragment),n=Vt(),_&&_.c(),i=dl()},m(u,f){Qe(e,u,f),de(u,n,f),_&&_.m(u,f),de(u,i,f),s=!0},p(u,f){l=u;const c={};f[1]&128&&(c.messages=l[63]),f[0]&8&&(c.display_consecutive_in_same_bubble=l[3]),f[0]&65536|f[1]&128&&(c.opposite_avatar_img=l[66]),f[0]&65536|f[1]&128&&(c.avatar_img=l[65]),f[1]&128&&(c.role=l[64]),f[0]&4194304&&(c.layout=l[22]),f[0]&2097152&&(c.i18n=l[21]),f[0]&2&&(c._fetch=l[1]),f[0]&524288&&(c.line_breaks=l[19]),f[0]&1048576&&(c.theme_mode=l[20]),f[1]&4&&(c.target=l[33]),f[0]&1073741824&&(c.root=l[30]),f[0]&16777216&&(c.upload=l[24]),f[0]&128&&(c.selectable=l[7]),f[0]&131072&&(c.sanitize_html=l[17]),f[0]&262144&&(c.render_markdown=l[18]),f[0]&16384&&(c.rtl=l[14]),f[0]&1&&(c.value=l[0]),f[0]&16&&(c.latex_delimiters=l[4]),f[1]&2&&(c._components=l[32]),f[0]&64&&(c.generating=l[6]),f[0]&33554432&&(c.msg_format=l[25]),f[0]&512&&(c.feedback_options=l[9]),f[0]&1024|f[1]&128&&(c.current_feedback=l[68]),f[1]&1&&(c.allow_tags=l[31]),f[0]&536871168|f[1]&128&&(c.show_like=l[64]==="user"?l[8]&&l[29]:l[8]),f[0]&134217729|f[1]&128&&(c.show_retry=l[27]&&nn(l[63],l[0])),f[0]&268435457|f[1]&128&&(c.show_undo=l[28]&&nn(l[63],l[0])),f[0]&2048|f[1]&128&&(c.show_edit=l[11]==="all"||l[11]=="user"&&l[64]==="user"&&l[63].length>0&&l[63][l[63].length-1].type=="text"),f[1]&8&&(c.in_edit_mode=l[34]===l[70]),f[0]&32768&&(c.show_copy_button=l[15]),f[1]&128&&(c.handle_action=o),f[0]&4&&(c.allow_file_downloads=l[2]),!t&&f[1]&16&&(t=!0,c.edit_message=l[35],N_(()=>t=!1)),e.$set(c),l[6]&&l[63][l[63].length-1].role==="assistant"&&l[63][l[63].length-1].metadata?.status==="done"?_?(_.p(l,f),f[0]&64|f[1]&128&&j(_,1)):(_=Ti(l),_.c(),j(_,1),_.m(i.parentNode,i)):_&&(_t(),B(_,1,1,()=>{_=null}),rt())},i(u){s||(j(e.$$.fragment,u),j(_),s=!0)},o(u){B(e.$$.fragment,u),B(_),s=!1},d(u){u&&(he(n),he(i)),Ke(e,u),_&&_.d(u)}}}function R_(l){let e,t=gn(l[39]),n=[];for(let i=0;i0&&Bi(l);const u=[P_,U_],f=[];function c(m,h){return m[0]!==null&&m[0].length>0&&m[38]!==null?0:1}n=c(l),i=f[n]=u[n](l);let b=l[37]&&Ui(l);return{c(){_&&_.c(),e=Vt(),t=xt("div"),i.c(),o=Vt(),b&&b.c(),r=dl(),Pe(t,"class",s=Vi(l[22]==="bubble"?"bubble-wrap":"panel-wrap")+" svelte-gjtrl6"),Pe(t,"role","log"),Pe(t,"aria-label","chatbot conversation"),Pe(t,"aria-live","polite")},m(m,h){_&&_.m(m,h),de(m,e,h),de(m,t,h),f[n].m(t,null),l[54](t),de(m,o,h),b&&b.m(m,h),de(m,r,h),a=!0},p(m,h){m[0]!==null&&m[0].length>0?_?(_.p(m,h),h[0]&1&&j(_,1)):(_=Bi(m),_.c(),j(_,1),_.m(e.parentNode,e)):_&&(_t(),B(_,1,1,()=>{_=null}),rt());let w=n;n=c(m),n===w?f[n].p(m,h):(_t(),B(f[w],1,1,()=>{f[w]=null}),rt(),i=f[n],i?i.p(m,h):(i=f[n]=u[n](m),i.c()),j(i,1),i.m(t,null)),(!a||h[0]&4194304&&s!==(s=Vi(m[22]==="bubble"?"bubble-wrap":"panel-wrap")+" svelte-gjtrl6"))&&Pe(t,"class",s),m[37]?b?(b.p(m,h),h[1]&64&&j(b,1)):(b=Ui(m),b.c(),j(b,1),b.m(r.parentNode,r)):b&&(_t(),B(b,1,1,()=>{b=null}),rt())},i(m){a||(j(_),j(i),j(b),a=!0)},o(m){B(_),B(i),B(b),a=!1},d(m){m&&(he(e),he(t),he(o),he(r)),_&&_.d(m),f[n].d(),l[54](null),b&&b.d(m)}}}const W_=()=>{};function G_(l,e,t){let n,i,{value:s=[]}=e,o=null,{_fetch:r}=e,{load_component:a}=e,{allow_file_downloads:_}=e,{display_consecutive_in_same_bubble:u}=e,f={};const c=typeof window<"u";async function b(){t(32,f=await fs(cs(s),f,a))}let{latex_delimiters:m}=e,{pending_message:h=!1}=e,{generating:w=!1}=e,{selectable:d=!1}=e,{likeable:$=!1}=e,{feedback_options:z}=e,{feedback_value:I=null}=e,{editable:p=null}=e,{show_share_button:x=!1}=e,{show_copy_all_button:ne=!1}=e,{rtl:y=!1}=e,{show_copy_button:ge=!1}=e,{avatar_images:S=[null,null]}=e,{sanitize_html:Me=!0}=e,{render_markdown:Ne=!0}=e,{line_breaks:Ve=!0}=e,{autoscroll:ze=!0}=e,{theme_mode:E}=e,{i18n:De}=e,{layout:Xe="bubble"}=e,{placeholder:xe=null}=e,{upload:be}=e,{msg_format:we="tuples"}=e,{examples:et=null}=e,{_retryable:Ie=!1}=e,{_undoable:tt=!1}=e,{like_user_message:ue=!1}=e,{root:nt}=e,{allow_tags:lt=null}=e,Be=null,Se=null,Ee="";Jn(()=>{t(33,Be=document.querySelector("div.gradio-container"))});let G,it=!1;const Y=T_();function It(){return G&&G.offsetHeight+G.scrollTop>G.scrollHeight-100}function v(){G&&(G.scrollTo(0,G.scrollHeight),t(37,it=!1))}async function ke(){ze&&(It()?(await F_(),v()):t(37,it=!0))}Jn(()=>{ke()}),Jn(()=>{function k(){It()&&t(37,it=!1)}return G?.addEventListener("scroll",k),()=>{G?.removeEventListener("scroll",k)}});function en(k,pe,ve){if(ve==="undo"||ve==="retry"){const pt=s;let Ae=pt.length-1;for(;pt[Ae].role==="assistant";)Ae--;Y(ve,{index:pt[Ae].index,value:pt[Ae].content})}else if(ve=="edit")t(34,Se=k),t(35,Ee=pe.content);else if(ve=="edit_cancel")t(34,Se=null);else if(ve=="edit_submit")t(34,Se=null),Y("edit",{index:pe.index,value:Ee,previous_value:pe.content});else{let pt=ve==="Like"?!0:ve==="Dislike"?!1:ve||"";if(we==="tuples")Y("like",{index:pe.index,value:pe.content,liked:pt});else{if(!n)return;const Ae=n[k],[wo,_u]=[Ae[0],Ae[Ae.length-1]];Y("like",{index:wo.index,value:Ae.map(ko=>ko.content),liked:pt})}}}function Cn(){if(!s||!n||n.length===0)return;const k=n[n.length-1];if(k[0].role==="assistant")return k[k.length-1].options}const yn=async()=>{try{const k=await ss(s);Y("share",{description:k})}catch(k){console.error(k);let pe=k instanceof po?k.message:"Share failed.";Y("error",pe)}},zn=()=>Y("clear"),Sn=(k,pe,ve)=>en(k,pe[0],ve);function Hn(k){Ee=k,t(35,Ee)}const qn=k=>Y("copy",k.detail),Ln=(k,pe)=>Y("option_select",{index:k,value:pe.value}),g=k=>Y("example_select",k.detail);function bo(k){ho[k?"unshift":"push"](()=>{G=k,t(36,G)})}return l.$$set=k=>{"value"in k&&t(0,s=k.value),"_fetch"in k&&t(1,r=k._fetch),"load_component"in k&&t(44,a=k.load_component),"allow_file_downloads"in k&&t(2,_=k.allow_file_downloads),"display_consecutive_in_same_bubble"in k&&t(3,u=k.display_consecutive_in_same_bubble),"latex_delimiters"in k&&t(4,m=k.latex_delimiters),"pending_message"in k&&t(5,h=k.pending_message),"generating"in k&&t(6,w=k.generating),"selectable"in k&&t(7,d=k.selectable),"likeable"in k&&t(8,$=k.likeable),"feedback_options"in k&&t(9,z=k.feedback_options),"feedback_value"in k&&t(10,I=k.feedback_value),"editable"in k&&t(11,p=k.editable),"show_share_button"in k&&t(12,x=k.show_share_button),"show_copy_all_button"in k&&t(13,ne=k.show_copy_all_button),"rtl"in k&&t(14,y=k.rtl),"show_copy_button"in k&&t(15,ge=k.show_copy_button),"avatar_images"in k&&t(16,S=k.avatar_images),"sanitize_html"in k&&t(17,Me=k.sanitize_html),"render_markdown"in k&&t(18,Ne=k.render_markdown),"line_breaks"in k&&t(19,Ve=k.line_breaks),"autoscroll"in k&&t(45,ze=k.autoscroll),"theme_mode"in k&&t(20,E=k.theme_mode),"i18n"in k&&t(21,De=k.i18n),"layout"in k&&t(22,Xe=k.layout),"placeholder"in k&&t(23,xe=k.placeholder),"upload"in k&&t(24,be=k.upload),"msg_format"in k&&t(25,we=k.msg_format),"examples"in k&&t(26,et=k.examples),"_retryable"in k&&t(27,Ie=k._retryable),"_undoable"in k&&t(28,tt=k._undoable),"like_user_message"in k&&t(29,ue=k.like_user_message),"root"in k&&t(30,nt=k.root),"allow_tags"in k&&t(31,lt=k.allow_tags)},l.$$.update=()=>{l.$$.dirty[0]&1&&b(),l.$$.dirty[0]&33|l.$$.dirty[1]&2&&(s||h||f)&&ke(),l.$$.dirty[0]&1|l.$$.dirty[1]&32768&&(zo(s,o)||(t(46,o=s),Y("change"))),l.$$.dirty[0]&33554433&&t(38,n=s&&us(s)),l.$$.dirty[0]&1&&t(39,i=s&&Cn())},[s,r,_,u,m,h,w,d,$,z,I,p,x,ne,y,ge,S,Me,Ne,Ve,E,De,Xe,xe,be,we,et,Ie,tt,ue,nt,lt,f,Be,Se,Ee,G,it,n,i,c,Y,v,en,a,ze,o,yn,zn,Sn,Hn,qn,Ln,g,bo]}class Y_ extends j_{constructor(e){super(),D_(this,e,G_,J_,B_,{value:0,_fetch:1,load_component:44,allow_file_downloads:2,display_consecutive_in_same_bubble:3,latex_delimiters:4,pending_message:5,generating:6,selectable:7,likeable:8,feedback_options:9,feedback_value:10,editable:11,show_share_button:12,show_copy_all_button:13,rtl:14,show_copy_button:15,avatar_images:16,sanitize_html:17,render_markdown:18,line_breaks:19,autoscroll:45,theme_mode:20,i18n:21,layout:22,placeholder:23,upload:24,msg_format:25,examples:26,_retryable:27,_undoable:28,like_user_message:29,root:30,allow_tags:31},null,[-1,-1,-1])}get value(){return this.$$.ctx[0]}set value(e){this.$$set({value:e}),L()}get _fetch(){return this.$$.ctx[1]}set _fetch(e){this.$$set({_fetch:e}),L()}get load_component(){return this.$$.ctx[44]}set load_component(e){this.$$set({load_component:e}),L()}get allow_file_downloads(){return this.$$.ctx[2]}set allow_file_downloads(e){this.$$set({allow_file_downloads:e}),L()}get display_consecutive_in_same_bubble(){return this.$$.ctx[3]}set display_consecutive_in_same_bubble(e){this.$$set({display_consecutive_in_same_bubble:e}),L()}get latex_delimiters(){return this.$$.ctx[4]}set latex_delimiters(e){this.$$set({latex_delimiters:e}),L()}get pending_message(){return this.$$.ctx[5]}set pending_message(e){this.$$set({pending_message:e}),L()}get generating(){return this.$$.ctx[6]}set generating(e){this.$$set({generating:e}),L()}get selectable(){return this.$$.ctx[7]}set selectable(e){this.$$set({selectable:e}),L()}get likeable(){return this.$$.ctx[8]}set likeable(e){this.$$set({likeable:e}),L()}get feedback_options(){return this.$$.ctx[9]}set feedback_options(e){this.$$set({feedback_options:e}),L()}get feedback_value(){return this.$$.ctx[10]}set feedback_value(e){this.$$set({feedback_value:e}),L()}get editable(){return this.$$.ctx[11]}set editable(e){this.$$set({editable:e}),L()}get show_share_button(){return this.$$.ctx[12]}set show_share_button(e){this.$$set({show_share_button:e}),L()}get show_copy_all_button(){return this.$$.ctx[13]}set show_copy_all_button(e){this.$$set({show_copy_all_button:e}),L()}get rtl(){return this.$$.ctx[14]}set rtl(e){this.$$set({rtl:e}),L()}get show_copy_button(){return this.$$.ctx[15]}set show_copy_button(e){this.$$set({show_copy_button:e}),L()}get avatar_images(){return this.$$.ctx[16]}set avatar_images(e){this.$$set({avatar_images:e}),L()}get sanitize_html(){return this.$$.ctx[17]}set sanitize_html(e){this.$$set({sanitize_html:e}),L()}get render_markdown(){return this.$$.ctx[18]}set render_markdown(e){this.$$set({render_markdown:e}),L()}get line_breaks(){return this.$$.ctx[19]}set line_breaks(e){this.$$set({line_breaks:e}),L()}get autoscroll(){return this.$$.ctx[45]}set autoscroll(e){this.$$set({autoscroll:e}),L()}get theme_mode(){return this.$$.ctx[20]}set theme_mode(e){this.$$set({theme_mode:e}),L()}get i18n(){return this.$$.ctx[21]}set i18n(e){this.$$set({i18n:e}),L()}get layout(){return this.$$.ctx[22]}set layout(e){this.$$set({layout:e}),L()}get placeholder(){return this.$$.ctx[23]}set placeholder(e){this.$$set({placeholder:e}),L()}get upload(){return this.$$.ctx[24]}set upload(e){this.$$set({upload:e}),L()}get msg_format(){return this.$$.ctx[25]}set msg_format(e){this.$$set({msg_format:e}),L()}get examples(){return this.$$.ctx[26]}set examples(e){this.$$set({examples:e}),L()}get _retryable(){return this.$$.ctx[27]}set _retryable(e){this.$$set({_retryable:e}),L()}get _undoable(){return this.$$.ctx[28]}set _undoable(e){this.$$set({_undoable:e}),L()}get like_user_message(){return this.$$.ctx[29]}set like_user_message(e){this.$$set({like_user_message:e}),L()}get root(){return this.$$.ctx[30]}set root(e){this.$$set({root:e}),L()}get allow_tags(){return this.$$.ctx[31]}set allow_tags(e){this.$$set({allow_tags:e}),L()}}const K_=Y_,{SvelteComponent:Q_,append:X_,assign:x_,attr:eu,check_outros:Pi,create_component:pn,destroy_component:vn,detach:Ri,element:tu,flush:H,get_spread_object:nu,get_spread_update:lu,group_outros:Oi,init:iu,insert:Ji,mount_component:$n,safe_not_equal:ou,space:Wi,transition_in:Le,transition_out:at}=window.__gradio__svelte__internal;function Gi(l){let e,t;const n=[{autoscroll:l[27].autoscroll},{i18n:l[27].i18n},l[30],{show_progress:l[30].show_progress==="hidden"?"hidden":"minimal"}];let i={};for(let s=0;s{o=null}),Pi()),a[7]?r?(r.p(a,_),_[0]&128&&Le(r,1)):(r=Yi(a),r.c(),Le(r,1),r.m(t,n)):r&&(Oi(),at(r,1,1,()=>{r=null}),Pi());const u={};_[0]&134217728&&(u.i18n=a[27].i18n),_[0]&256&&(u.selectable=a[8]),_[0]&512&&(u.likeable=a[9]),_[0]&1024&&(u.feedback_options=a[10]),_[0]&2048&&(u.feedback_value=a[11]),_[0]&4096&&(u.show_share_button=a[12]),_[0]&32768&&(u.show_copy_all_button=a[15]),_[1]&512&&(u.value=a[40]),_[0]&67108864&&(u.latex_delimiters=a[26]),_[0]&16777216&&(u.display_consecutive_in_same_bubble=a[24]),_[0]&524288&&(u.render_markdown=a[19]),_[1]&128&&(u.theme_mode=a[38]),_[1]&16&&(u.editable=a[35]),_[0]&1073741824&&(u.pending_message=a[30]?.status==="pending"),_[0]&1073741824&&(u.generating=a[30]?.status==="generating"),_[0]&8192&&(u.rtl=a[13]),_[0]&16384&&(u.show_copy_button=a[14]),_[0]&536870912&&(u.like_user_message=a[29]),_[0]&268435456&&(u.avatar_images=a[28]),_[0]&65536&&(u.sanitize_html=a[16]),_[0]&1048576&&(u.line_breaks=a[20]),_[0]&2097152&&(u.autoscroll=a[21]),_[0]&131072&&(u.layout=a[17]),_[1]&32&&(u.placeholder=a[36]),_[1]&64&&(u.examples=a[37]),_[0]&4194304&&(u._retryable=a[22]),_[0]&8388608&&(u._undoable=a[23]),_[0]&134217728&&(u.upload=a[43]),_[0]&134217728&&(u._fetch=a[44]),_[0]&134217728&&(u.load_component=a[27].load_component),_[0]&262144&&(u.msg_format=a[18]),_[0]&134217728&&(u.root=a[27].root),_[1]&256&&(u.allow_file_downloads=a[39]),_[0]&33554432&&(u.allow_tags=a[25]),i.$set(u)},i(a){s||(Le(o),Le(r),Le(i.$$.fragment,a),s=!0)},o(a){at(o),at(r),at(i.$$.fragment,a),s=!1},d(a){a&&(Ri(e),Ri(t)),o&&o.d(a),r&&r.d(),vn(i)}}}function au(l){let e,t;return e=new qo({props:{elem_id:l[1],elem_classes:l[2],visible:l[3],padding:!1,scale:l[4],min_width:l[5],height:l[31],resizable:l[32],min_height:l[33],max_height:l[34],allow_overflow:!0,flex:!0,overflow_behavior:"auto",$$slots:{default:[su]},$$scope:{ctx:l}}}),{c(){pn(e.$$.fragment)},m(n,i){$n(e,n,i),t=!0},p(n,i){const s={};i[0]&2&&(s.elem_id=n[1]),i[0]&4&&(s.elem_classes=n[2]),i[0]&8&&(s.visible=n[3]),i[0]&16&&(s.scale=n[4]),i[0]&32&&(s.min_width=n[5]),i[1]&1&&(s.height=n[31]),i[1]&2&&(s.resizable=n[32]),i[1]&4&&(s.min_height=n[33]),i[1]&8&&(s.max_height=n[34]),i[0]&2147483585|i[1]&67109872&&(s.$$scope={dirty:i,ctx:n}),e.$set(s)},i(n){t||(Le(e.$$.fragment,n),t=!0)},o(n){at(e.$$.fragment,n),t=!1},d(n){vn(e,n)}}}function ru(l,e,t){let{elem_id:n=""}=e,{elem_classes:i=[]}=e,{visible:s=!0}=e,{value:o=[]}=e,{scale:r=null}=e,{min_width:a=void 0}=e,{label:_}=e,{show_label:u=!0}=e,{root:f}=e,{_selectable:c=!1}=e,{likeable:b=!1}=e,{feedback_options:m=["Like","Dislike"]}=e,{feedback_value:h=null}=e,{show_share_button:w=!1}=e,{rtl:d=!1}=e,{show_copy_button:$=!0}=e,{show_copy_all_button:z=!1}=e,{sanitize_html:I=!0}=e,{layout:p="bubble"}=e,{type:x="tuples"}=e,{render_markdown:ne=!0}=e,{line_breaks:y=!0}=e,{autoscroll:ge=!0}=e,{_retryable:S=!1}=e,{_undoable:Me=!1}=e,{group_consecutive_messages:Ne=!0}=e,{allow_tags:Ve=null}=e,{latex_delimiters:ze}=e,{gradio:E}=e,De=[],{avatar_images:Xe=[null,null]}=e,{like_user_message:xe=!1}=e,{loading_status:be=void 0}=e,{height:we}=e,{resizable:et}=e,{min_height:Ie}=e,{max_height:tt}=e,{editable:ue=null}=e,{placeholder:nt=null}=e,{examples:lt=null}=e,{theme_mode:Be}=e,{allow_file_downloads:Se=!0}=e;const Ee=()=>E.dispatch("clear_status",be),G=(...g)=>E.client.upload(...g),it=(...g)=>E.client.fetch(...g),Y=()=>E.dispatch("change",o),It=g=>E.dispatch("select",g.detail),v=g=>E.dispatch("like",g.detail),ke=g=>E.dispatch("share",g.detail),en=g=>E.dispatch("error",g.detail),Cn=g=>E.dispatch("example_select",g.detail),yn=g=>E.dispatch("option_select",g.detail),zn=g=>E.dispatch("retry",g.detail),Sn=g=>E.dispatch("undo",g.detail),Hn=()=>{t(0,o=[]),E.dispatch("clear")},qn=g=>E.dispatch("copy",g.detail),Ln=g=>{o===null||o.length===0||(x==="messages"?t(0,o[g.detail.index].content=g.detail.value,o):t(0,o[g.detail.index[0]][g.detail.index[1]]=g.detail.value,o),t(0,o),E.dispatch("edit",g.detail))};return l.$$set=g=>{"elem_id"in g&&t(1,n=g.elem_id),"elem_classes"in g&&t(2,i=g.elem_classes),"visible"in g&&t(3,s=g.visible),"value"in g&&t(0,o=g.value),"scale"in g&&t(4,r=g.scale),"min_width"in g&&t(5,a=g.min_width),"label"in g&&t(6,_=g.label),"show_label"in g&&t(7,u=g.show_label),"root"in g&&t(41,f=g.root),"_selectable"in g&&t(8,c=g._selectable),"likeable"in g&&t(9,b=g.likeable),"feedback_options"in g&&t(10,m=g.feedback_options),"feedback_value"in g&&t(11,h=g.feedback_value),"show_share_button"in g&&t(12,w=g.show_share_button),"rtl"in g&&t(13,d=g.rtl),"show_copy_button"in g&&t(14,$=g.show_copy_button),"show_copy_all_button"in g&&t(15,z=g.show_copy_all_button),"sanitize_html"in g&&t(16,I=g.sanitize_html),"layout"in g&&t(17,p=g.layout),"type"in g&&t(18,x=g.type),"render_markdown"in g&&t(19,ne=g.render_markdown),"line_breaks"in g&&t(20,y=g.line_breaks),"autoscroll"in g&&t(21,ge=g.autoscroll),"_retryable"in g&&t(22,S=g._retryable),"_undoable"in g&&t(23,Me=g._undoable),"group_consecutive_messages"in g&&t(24,Ne=g.group_consecutive_messages),"allow_tags"in g&&t(25,Ve=g.allow_tags),"latex_delimiters"in g&&t(26,ze=g.latex_delimiters),"gradio"in g&&t(27,E=g.gradio),"avatar_images"in g&&t(28,Xe=g.avatar_images),"like_user_message"in g&&t(29,xe=g.like_user_message),"loading_status"in g&&t(30,be=g.loading_status),"height"in g&&t(31,we=g.height),"resizable"in g&&t(32,et=g.resizable),"min_height"in g&&t(33,Ie=g.min_height),"max_height"in g&&t(34,tt=g.max_height),"editable"in g&&t(35,ue=g.editable),"placeholder"in g&&t(36,nt=g.placeholder),"examples"in g&&t(37,lt=g.examples),"theme_mode"in g&&t(38,Be=g.theme_mode),"allow_file_downloads"in g&&t(39,Se=g.allow_file_downloads)},l.$$.update=()=>{l.$$.dirty[0]&262145|l.$$.dirty[1]&1024&&t(40,De=x==="tuples"?_s(o,f):rs(o,f))},[o,n,i,s,r,a,_,u,c,b,m,h,w,d,$,z,I,p,x,ne,y,ge,S,Me,Ne,Ve,ze,E,Xe,xe,be,we,et,Ie,tt,ue,nt,lt,Be,Se,De,f,Ee,G,it,Y,It,v,ke,en,Cn,yn,zn,Sn,Hn,qn,Ln]}class Tu extends Q_{constructor(e){super(),iu(this,e,ru,au,ou,{elem_id:1,elem_classes:2,visible:3,value:0,scale:4,min_width:5,label:6,show_label:7,root:41,_selectable:8,likeable:9,feedback_options:10,feedback_value:11,show_share_button:12,rtl:13,show_copy_button:14,show_copy_all_button:15,sanitize_html:16,layout:17,type:18,render_markdown:19,line_breaks:20,autoscroll:21,_retryable:22,_undoable:23,group_consecutive_messages:24,allow_tags:25,latex_delimiters:26,gradio:27,avatar_images:28,like_user_message:29,loading_status:30,height:31,resizable:32,min_height:33,max_height:34,editable:35,placeholder:36,examples:37,theme_mode:38,allow_file_downloads:39},null,[-1,-1])}get elem_id(){return this.$$.ctx[1]}set elem_id(e){this.$$set({elem_id:e}),H()}get elem_classes(){return this.$$.ctx[2]}set elem_classes(e){this.$$set({elem_classes:e}),H()}get visible(){return this.$$.ctx[3]}set visible(e){this.$$set({visible:e}),H()}get value(){return this.$$.ctx[0]}set value(e){this.$$set({value:e}),H()}get scale(){return this.$$.ctx[4]}set scale(e){this.$$set({scale:e}),H()}get min_width(){return this.$$.ctx[5]}set min_width(e){this.$$set({min_width:e}),H()}get label(){return this.$$.ctx[6]}set label(e){this.$$set({label:e}),H()}get show_label(){return this.$$.ctx[7]}set show_label(e){this.$$set({show_label:e}),H()}get root(){return this.$$.ctx[41]}set root(e){this.$$set({root:e}),H()}get _selectable(){return this.$$.ctx[8]}set _selectable(e){this.$$set({_selectable:e}),H()}get likeable(){return this.$$.ctx[9]}set likeable(e){this.$$set({likeable:e}),H()}get feedback_options(){return this.$$.ctx[10]}set feedback_options(e){this.$$set({feedback_options:e}),H()}get feedback_value(){return this.$$.ctx[11]}set feedback_value(e){this.$$set({feedback_value:e}),H()}get show_share_button(){return this.$$.ctx[12]}set show_share_button(e){this.$$set({show_share_button:e}),H()}get rtl(){return this.$$.ctx[13]}set rtl(e){this.$$set({rtl:e}),H()}get show_copy_button(){return this.$$.ctx[14]}set show_copy_button(e){this.$$set({show_copy_button:e}),H()}get show_copy_all_button(){return this.$$.ctx[15]}set show_copy_all_button(e){this.$$set({show_copy_all_button:e}),H()}get sanitize_html(){return this.$$.ctx[16]}set sanitize_html(e){this.$$set({sanitize_html:e}),H()}get layout(){return this.$$.ctx[17]}set layout(e){this.$$set({layout:e}),H()}get type(){return this.$$.ctx[18]}set type(e){this.$$set({type:e}),H()}get render_markdown(){return this.$$.ctx[19]}set render_markdown(e){this.$$set({render_markdown:e}),H()}get line_breaks(){return this.$$.ctx[20]}set line_breaks(e){this.$$set({line_breaks:e}),H()}get autoscroll(){return this.$$.ctx[21]}set autoscroll(e){this.$$set({autoscroll:e}),H()}get _retryable(){return this.$$.ctx[22]}set _retryable(e){this.$$set({_retryable:e}),H()}get _undoable(){return this.$$.ctx[23]}set _undoable(e){this.$$set({_undoable:e}),H()}get group_consecutive_messages(){return this.$$.ctx[24]}set group_consecutive_messages(e){this.$$set({group_consecutive_messages:e}),H()}get allow_tags(){return this.$$.ctx[25]}set allow_tags(e){this.$$set({allow_tags:e}),H()}get latex_delimiters(){return this.$$.ctx[26]}set latex_delimiters(e){this.$$set({latex_delimiters:e}),H()}get gradio(){return this.$$.ctx[27]}set gradio(e){this.$$set({gradio:e}),H()}get avatar_images(){return this.$$.ctx[28]}set avatar_images(e){this.$$set({avatar_images:e}),H()}get like_user_message(){return this.$$.ctx[29]}set like_user_message(e){this.$$set({like_user_message:e}),H()}get loading_status(){return this.$$.ctx[30]}set loading_status(e){this.$$set({loading_status:e}),H()}get height(){return this.$$.ctx[31]}set height(e){this.$$set({height:e}),H()}get resizable(){return this.$$.ctx[32]}set resizable(e){this.$$set({resizable:e}),H()}get min_height(){return this.$$.ctx[33]}set min_height(e){this.$$set({min_height:e}),H()}get max_height(){return this.$$.ctx[34]}set max_height(e){this.$$set({max_height:e}),H()}get editable(){return this.$$.ctx[35]}set editable(e){this.$$set({editable:e}),H()}get placeholder(){return this.$$.ctx[36]}set placeholder(e){this.$$set({placeholder:e}),H()}get examples(){return this.$$.ctx[37]}set examples(e){this.$$set({examples:e}),H()}get theme_mode(){return this.$$.ctx[38]}set theme_mode(e){this.$$set({theme_mode:e}),H()}get allow_file_downloads(){return this.$$.ctx[39]}set allow_file_downloads(e){this.$$set({allow_file_downloads:e}),H()}}export{K_ as BaseChatBot,Tu as default};
//# sourceMappingURL=Index-DEnoE7KK.js.map