1import { B as Block } from './Button-c2bc75a7.js'; 2import { u as uploadToHuggingFace, c as copy } from './utils-013c0d40.js'; 3import { d as dequal } from './index-21d69e4c.js'; 4import { S as ShareButton } from './ShareButton-2cb5d936.js'; 5import { S as Static } from './Index-9d23d982.js'; 6import { r as resolve_wasm_src } from './file-url-84e08b20.js'; 7import { I as Image } from './Image-90d75330.js'; 8import { V as Video } from './Video-68550d07.js'; 9import './Index.svelte_svelte_type_style_lang-7fd1e462.js'; 10import { M as MarkdownCode } from './Example.svelte_svelte_type_style_lang-183af30f.js'; 11import './index-12d4b00b.js'; 12import { C as Check } from './Check-f7edb5d9.js'; 13import { C as Copy } from './Copy-a69620a8.js'; 14import { B as BlockLabel } from './BlockLabel-2a595353.js'; 15import './IconButton-c16a0681.js'; 16import './prism-python-9de6db01.js'; 17import './svelte/svelte.js'; 18 19/* home/runner/work/gradio/gradio/js/icons/src/Chat.svelte generated by Svelte v4.2.2 */ 20const { 21 SvelteComponent: SvelteComponent$8, 22 append: append$5, 23 attr: attr$7, 24 detach: detach$8, 25 init: init$8, 26 insert: insert$8, 27 noop: noop$5, 28 safe_not_equal: safe_not_equal$8, 29 svg_element: svg_element$2 30} = window.__gradio__svelte__internal; 31function create_fragment$8(ctx) { 32 let svg; 33 let path0; 34 let path1; 35 36 return { 37 c() { 38 svg = svg_element$2("svg"); 39 path0 = svg_element$2("path"); 40 path1 = svg_element$2("path"); 41 attr$7(path0, "fill", "currentColor"); 42 attr$7(path0, "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"); 43 attr$7(path1, "fill", "currentColor"); 44 attr$7(path1, "d", "M8 10h16v2H8zm0 6h10v2H8z"); 45 attr$7(svg, "xmlns", "http://www.w3.org/2000/svg"); 46 attr$7(svg, "xmlns:xlink", "http://www.w3.org/1999/xlink"); 47 attr$7(svg, "aria-hidden", "true"); 48 attr$7(svg, "role", "img"); 49 attr$7(svg, "class", "iconify iconify--carbon"); 50 attr$7(svg, "width", "100%"); 51 attr$7(svg, "height", "100%"); 52 attr$7(svg, "preserveAspectRatio", "xMidYMid meet"); 53 attr$7(svg, "viewBox", "0 0 32 32"); 54 }, 55 m(target, anchor) { 56 insert$8(target, svg, anchor); 57 append$5(svg, path0); 58 append$5(svg, path1); 59 }, 60 p: noop$5, 61 i: noop$5, 62 o: noop$5, 63 d(detaching) { 64 if (detaching) { 65 detach$8(svg); 66 } 67 } 68 }; 69} 70 71class Chat extends SvelteComponent$8 { 72 constructor(options) { 73 super(); 74 init$8(this, options, null, create_fragment$8, safe_not_equal$8, {}); 75 } 76} 77 78/* home/runner/work/gradio/gradio/js/icons/src/Dislike.svelte generated by Svelte v4.2.2 */ 79const { 80 SvelteComponent: SvelteComponent$7, 81 append: append$4, 82 attr: attr$6, 83 detach: detach$7, 84 init: init$7, 85 insert: insert$7, 86 noop: noop$4, 87 safe_not_equal: safe_not_equal$7, 88 svg_element: svg_element$1 89} = window.__gradio__svelte__internal; 90function create_fragment$7(ctx) { 91 let svg; 92 let path0; 93 let path1; 94 let svg_fill_value; 95 96 return { 97 c() { 98 svg = svg_element$1("svg"); 99 path0 = svg_element$1("path"); 100 path1 = svg_element$1("path"); 101 attr$6(path0, "stroke", "currentColor"); 102 attr$6(path0, "stroke-width", "1.5"); 103 attr$6(path0, "stroke-linecap", "round"); 104 attr$6(path0, "d", "M16.472 3.5H4.1a.6.6 0 0 0-.6.6v9.8a.6.6 0 0 0 .6.6h2.768a2 2 0 0 1 1.715.971l2.71 4.517a1.631 1.631 0 0 0 2.961-1.308l-1.022-3.408a.6.6 0 0 1 .574-.772h4.575a2 2 0 0 0 1.93-2.526l-1.91-7A2 2 0 0 0 16.473 3.5Z"); 105 attr$6(path1, "stroke", "currentColor"); 106 attr$6(path1, "stroke-width", "1.5"); 107 attr$6(path1, "stroke-linecap", "round"); 108 attr$6(path1, "stroke-linejoin", "round"); 109 attr$6(path1, "d", "M7 14.5v-11"); 110 attr$6(svg, "xmlns", "http://www.w3.org/2000/svg"); 111 attr$6(svg, "viewBox", "0 0 24 24"); 112 attr$6(svg, "fill", svg_fill_value = /*selected*/ ctx[0] ? "currentColor" : "none"); 113 attr$6(svg, "stroke-width", "1.5"); 114 attr$6(svg, "color", "currentColor"); 115 }, 116 m(target, anchor) { 117 insert$7(target, svg, anchor); 118 append$4(svg, path0); 119 append$4(svg, path1); 120 }, 121 p(ctx, [dirty]) { 122 if (dirty & /*selected*/ 1 && svg_fill_value !== (svg_fill_value = /*selected*/ ctx[0] ? "currentColor" : "none")) { 123 attr$6(svg, "fill", svg_fill_value); 124 } 125 }, 126 i: noop$4, 127 o: noop$4, 128 d(detaching) { 129 if (detaching) { 130 detach$7(svg); 131 } 132 } 133 }; 134} 135
136function instance$7($$self, $$props, $$invalidate) { 137 let { selected } = $$props; 138 139 $$self.$$set = $$props => { 140 if ('selected' in $$props) $$invalidate(0, selected = $$props.selected); 141 }; 142 143 return [selected]; 144} 145 146class Dislike extends SvelteComponent$7 { 147 constructor(options) { 148 super(); 149 init$7(this, options, instance$7, create_fragment$7, safe_not_equal$7, { selected: 0 }); 150 } 151} 152 153/* home/runner/work/gradio/gradio/js/icons/src/Like.svelte generated by Svelte v4.2.2 */ 154const { 155 SvelteComponent: SvelteComponent$6, 156 append: append$3, 157 attr: attr$5, 158 detach: detach$6, 159 init: init$6, 160 insert: insert$6, 161 noop: noop$3, 162 safe_not_equal: safe_not_equal$6, 163 svg_element 164} = window.__gradio__svelte__internal; 165function create_fragment$6(ctx) { 166 let svg; 167 let path0; 168 let path1; 169 let svg_fill_value; 170 171 return { 172 c() { 173 svg = svg_element("svg"); 174 path0 = svg_element("path"); 175 path1 = svg_element("path"); 176 attr$5(path0, "stroke", "currentColor"); 177 attr$5(path0, "stroke-width", "1.5"); 178 attr$5(path0, "stroke-linecap", "round"); 179 attr$5(path0, "d", "M16.472 20H4.1a.6.6 0 0 1-.6-.6V9.6a.6.6 0 0 1 .6-.6h2.768a2 2 0 0 0 1.715-.971l2.71-4.517a1.631 1.631 0 0 1 2.961 1.308l-1.022 3.408a.6.6 0 0 0 .574.772h4.575a2 2 0 0 1 1.93 2.526l-1.91 7A2 2 0 0 1 16.473 20Z"); 180 attr$5(path1, "stroke", "currentColor"); 181 attr$5(path1, "stroke-width", "1.5"); 182 attr$5(path1, "stroke-linecap", "round"); 183 attr$5(path1, "stroke-linejoin", "round"); 184 attr$5(path1, "d", "M7 20V9"); 185 attr$5(svg, "xmlns", "http://www.w3.org/2000/svg"); 186 attr$5(svg, "viewBox", "0 0 24 24"); 187 attr$5(svg, "fill", svg_fill_value = /*selected*/ ctx[0] ? "currentColor" : "none"); 188 attr$5(svg, "stroke-width", "1.5"); 189 attr$5(svg, "color", "currentColor"); 190 }, 191 m(target, anchor) { 192 insert$6(target, svg, anchor); 193 append$3(svg, path0); 194 append$3(svg, path1); 195 }, 196 p(ctx, [dirty]) { 197 if (dirty & /*selected*/ 1 && svg_fill_value !== (svg_fill_value = /*selected*/ ctx[0] ? "currentColor" : "none")) { 198 attr$5(svg, "fill", svg_fill_value); 199 } 200 }, 201 i: noop$3, 202 o: noop$3, 203 d(detaching) { 204 if (detaching) { 205 detach$6(svg); 206 } 207 } 208 }; 209} 210 211function instance$6($$self, $$props, $$invalidate) { 212 let { selected } = $$props; 213 214 $$self.$$set = $$props => {
215 if ('selected' in $$props) $$invalidate(0, selected = $$props.selected); 216 }; 217 218 return [selected]; 219} 220 221class Like extends SvelteComponent$6 { 222 constructor(options) { 223 super(); 224 init$6(this, options, instance$6, create_fragment$6, safe_not_equal$6, { selected: 0 }); 225 } 226} 227 228const format_chat_for_sharing = async (chat) => { 229 let messages = await Promise.all( 230 chat.map(async (message_pair) => { 231 return await Promise.all( 232 message_pair.map(async (message, i) => { 233 if (message === null) 234 return ""; 235 let speaker_emoji = i === 0 ? "ð" : "ð¤"; 236 let html_content = ""; 237 if (typeof message === "string") { 238 const regexPatterns = { 239 audio: /<audio.*?src="(\/file=.*?)"/g, 240 video: /<video.*?src="(\/file=.*?)"/g, 241 image: /<img.*?src="(\/file=.*?)".*?\/>|!\[.*?\]\((\/file=.*?)\)/g 242 }; 243 html_content = message; 244 for (let [_, regex] of Object.entries(regexPatterns)) { 245 let match; 246 while ((match = regex.exec(message)) !== null) { 247 const fileUrl = match[1] || match[2]; 248 const newUrl = await uploadToHuggingFace(fileUrl, "url"); 249 html_content = html_content.replace(fileUrl, newUrl); 250 } 251 } 252 } else { 253 if (!message?.url) 254 return ""; 255 const file_url = await uploadToHuggingFace(message.url, "url"); 256 if (message.mime_type?.includes("audio")) { 257 html_content = `<audio controls src="${file_url}"></audio>`; 258 } else if (message.mime_type?.includes("video")) { 259 html_content = file_url; 260 } else if (message.mime_type?.includes("image")) { 261 html_content = `<img src="${file_url}" />`; 262 } 263 } 264 return `${speaker_emoji}: ${html_content}`; 265 }) 266 ); 267 }) 268 ); 269 return messages.map( 270 (message_pair) => message_pair.join( 271 message_pair[0] !== "" && message_pair[1] !== "" ? "\n" : "" 272 ) 273 ).join("\n"); 274}; 275 276/* home/runner/work/gradio/gradio/js/audio/shared/Audio.svelte generated by Svelte v4.2.2 */ 277const { 278 SvelteComponent: SvelteComponent$5, 279 assign: assign$1, 280 compute_rest_props, 281 detach: detach$5, 282 element: element$5, 283 exclude_internal_props, 284 get_spread_update: get_spread_update$1, 285 init: init$5, 286 insert: insert$5, 287 listen: listen$3, 288 noop: noop$2, 289 run_all: run_all$2, 290 safe_not_equal: safe_not_equal$5, 291 set_attributes, 292 src_url_equal 293} = window.__gradio__svelte__internal; 294const { createEventDispatcher: createEventDispatcher$1 } = window.__gradio__svelte__internal; 295function create_fragment$5(ctx) { 296 let audio; 297 let audio_src_value; 298 let mounted; 299 let dispose; 300 301 let audio_levels = [ 302 { 303 src: audio_src_value = /*resolved_src*/ ctx[0] 304 }, 305 /*$$restProps*/ ctx[2] 306 ]; 307 308 let audio_data = {}; 309 310 for (let i = 0; i < audio_levels.length; i += 1) { 311 audio_data = assign$1(audio_data, audio_levels[i]); 312 } 313 314 return { 315 c() { 316 audio = element$5("audio"); 317 set_attributes(audio, audio_data); 318 }, 319 m(target, anchor) { 320 insert$5(target, audio, anchor); 321 322 if (!mounted) { 323 dispose = [ 324 listen$3(audio, "play", /*dispatch*/ ctx[1].bind(null, "play")), 325 listen$3(audio, "pause", /*dispatch*/ ctx[1].bind(null, "pause")), 326 listen$3(audio, "ended", /*dispatch*/ ctx[1].bind(null, "ended")) 327 ]; 328 329 mounted = true; 330 } 331 }, 332 p(ctx, [dirty]) { 333 set_attributes(audio, audio_data = get_spread_update$1(audio_levels, [ 334 dirty & /*resolved_src*/ 1 && !src_url_equal(audio.src, audio_src_value = /*resolved_src*/ ctx[0]) && { src: audio_src_value }, 335 dirty & /*$$restProps*/ 4 && /*$$restProps*/ ctx[2] 336 ])); 337 }, 338 i: noop$2, 339 o: noop$2, 340 d(detaching) { 341 if (detaching) { 342 detach$5(audio); 343 } 344 345 mounted = false; 346 run_all$2(dispose); 347 } 348 }; 349} 350 351function instance$5($$self, $$props, $$invalidate) { 352 const omit_props_names = ["src"]; 353 let $$restProps = compute_rest_props($$props, omit_props_names); 354 let { src = undefined } = $$props; 355 let resolved_src; 356 357 // The `src` prop can be updated before the Promise from `resolve_wasm_src` is resolved. 358 // In such a case, the resolved value for the old `src` has to be discarded, 359 // This variable `latest_src` is used to pick up only the value resolved for the latest `src` prop. 360 let latest_src; 361 362 const dispatch = createEventDispatcher$1(); 363 364 $$self.$$set = $$new_props => { 365 $$props = assign$1(assign$1({}, $$props), exclude_internal_props($$new_props));
366 $$invalidate(2, $$restProps = compute_rest_props($$props, omit_props_names)); 367 if ('src' in $$new_props) $$invalidate(3, src = $$new_props.src); 368 }; 369 370 $$self.$$.update = () => { 371 if ($$self.$$.dirty & /*src, latest_src*/ 24) { 372 { 373 // In normal (non-Wasm) Gradio, the `<audio>` element should be rendered with the passed `src` props immediately 374 // without waiting for `resolve_wasm_src()` to resolve. 375 // If it waits, a black image is displayed until the async task finishes 376 // and it leads to undesirable flickering. 377 // So set `src` to `resolved_src` here. 378 $$invalidate(0, resolved_src = src); 379 380 $$invalidate(4, latest_src = src); 381 const resolving_src = src; 382 383 resolve_wasm_src(resolving_src).then(s => { 384 if (latest_src === resolving_src) { 385 $$invalidate(0, resolved_src = s); 386 } 387 }); 388 } 389 } 390 }; 391 392 return [resolved_src, dispatch, $$restProps, src, latest_src]; 393} 394 395class Audio extends SvelteComponent$5 { 396 constructor(options) { 397 super(); 398 init$5(this, options, instance$5, create_fragment$5, safe_not_equal$5, { src: 3 }); 399 } 400} 401 402const Copy_svelte_svelte_type_style_lang = ''; 403 404/* home/runner/work/gradio/gradio/js/chatbot/shared/Copy.svelte generated by Svelte v4.2.2 */ 405const { 406 SvelteComponent: SvelteComponent$4, 407 append: append$2, 408 attr: attr$4, 409 check_outros: check_outros$2, 410 create_component: create_component$3, 411 destroy_component: destroy_component$3, 412 detach: detach$4, 413 element: element$4, 414 group_outros: group_outros$2, 415 init: init$4, 416 insert: insert$4, 417 listen: listen$2, 418 mount_component: mount_component$3, 419 safe_not_equal: safe_not_equal$4, 420 space: space$3, 421 transition_in: transition_in$3, 422 transition_out: transition_out$3 423} = window.__gradio__svelte__internal; 424const { onDestroy } = window.__gradio__svelte__internal; 425function create_if_block_1$2(ctx) { 426 let copy; 427 let current; 428 copy = new Copy({}); 429 430 return { 431 c() { 432 create_component$3(copy.$$.fragment); 433 }, 434 m(target, anchor) { 435 mount_component$3(copy, target, anchor); 436 current = true; 437 }, 438 i(local) { 439 if (current) return; 440 transition_in$3(copy.$$.fragment, local); 441 current = true; 442 }, 443 o(local) { 444 transition_out$3(copy.$$.fragment, local); 445 current = false; 446 }, 447 d(detaching) { 448 destroy_component$3(copy, detaching); 449 } 450 }; 451} 452 453// (53:1) {#if copied} 454function create_if_block$2(ctx) { 455 let check; 456 let current; 457 check = new Check({}); 458 459 return { 460 c() { 461 create_component$3(check.$$.fragment); 462 }, 463 m(target, anchor) { 464 mount_component$3(check, target, anchor); 465 current = true; 466 }, 467 i(local) { 468 if (current) return; 469 transition_in$3(check.$$.fragment, local); 470 current = true; 471 }, 472 o(local) { 473 transition_out$3(check.$$.fragment, local); 474 current = false; 475 }, 476 d(detaching) { 477 destroy_component$3(check, detaching); 478 } 479 }; 480} 481 482function create_fragment$4(ctx) { 483 let button; 484 let t; 485 let button_aria_label_value; 486 let current; 487 let mounted; 488 let dispose; 489 let if_block0 = !/*copied*/ ctx[0] && create_if_block_1$2(); 490 let if_block1 = /*copied*/ ctx[0] && create_if_block$2(); 491 492 return { 493 c() { 494 button = element$4("button"); 495 if (if_block0) if_block0.c(); 496 t = space$3(); 497 if (if_block1) if_block1.c(); 498 attr$4(button, "class", "action svelte-rvlubk"); 499 attr$4(button, "title", "copy"); 500 attr$4(button, "aria-label", button_aria_label_value = /*copied*/ ctx[0] ? "Copied message" : "Copy message"); 501 }, 502 m(target, anchor) { 503 insert$4(target, button, anchor); 504 if (if_block0) if_block0.m(button, null); 505 append$2(button, t); 506 if (if_block1) if_block1.m(button, null); 507 current = true; 508 509 if (!mounted) { 510 dispose = listen$2(button, "click", /*handle_copy*/ ctx[1]); 511 mounted = true; 512 } 513 }, 514 p(ctx, [dirty]) { 515 if (!/*copied*/ ctx[0]) { 516 if (if_block0) { 517 if (dirty & /*copied*/ 1) { 518 transition_in$3(if_block0, 1); 519 } 520 } else { 521 if_block0 = create_if_block_1$2(); 522 if_block0.c(); 523 transition_in$3(if_block0, 1); 524 if_block0.m(button, t); 525 } 526 } else if (if_block0) { 527 group_outros$2(); 528 529 transition_out$3(if_block0, 1, 1, () => { 530 if_block0 = null; 531 }); 532 533 check_outros$2(); 534 } 535 536 if (/*copied*/ ctx[0]) { 537 if (if_block1) {
538 if (dirty & /*copied*/ 1) { 539 transition_in$3(if_block1, 1); 540 } 541 } else { 542 if_block1 = create_if_block$2(); 543 if_block1.c(); 544 transition_in$3(if_block1, 1); 545 if_block1.m(button, null); 546 } 547 } else if (if_block1) { 548 group_outros$2(); 549 550 transition_out$3(if_block1, 1, 1, () => { 551 if_block1 = null; 552 }); 553 554 check_outros$2(); 555 } 556 557 if (!current || dirty & /*copied*/ 1 && button_aria_label_value !== (button_aria_label_value = /*copied*/ ctx[0] ? "Copied message" : "Copy message")) { 558 attr$4(button, "aria-label", button_aria_label_value); 559 } 560 }, 561 i(local) { 562 if (current) return; 563 transition_in$3(if_block0); 564 transition_in$3(if_block1); 565 current = true; 566 }, 567 o(local) { 568 transition_out$3(if_block0); 569 transition_out$3(if_block1); 570 current = false; 571 }, 572 d(detaching) { 573 if (detaching) { 574 detach$4(button); 575 } 576 577 if (if_block0) if_block0.d(); 578 if (if_block1) if_block1.d(); 579 mounted = false; 580 dispose(); 581 } 582 }; 583} 584 585function instance$4($$self, $$props, $$invalidate) { 586 let copied = false; 587 let { value } = $$props; 588 let timer; 589 590 function copy_feedback() { 591 $$invalidate(0, copied = true); 592 if (timer) clearTimeout(timer); 593 594 timer = setTimeout( 595 () => { 596 $$invalidate(0, copied = false); 597 }, 598 2000 599 ); 600 } 601 602 async function handle_copy() { 603 if ("clipboard" in navigator) { 604 await navigator.clipboard.writeText(value); 605 copy_feedback(); 606 } else { 607 const textArea = document.createElement("textarea"); 608 textArea.value = value; 609 textArea.style.position = "absolute"; 610 textArea.style.left = "-999999px"; 611 document.body.prepend(textArea); 612 textArea.select(); 613 614 try { 615 document.execCommand("copy"); 616 copy_feedback(); 617 } catch(error) { 618 console.error(error); 619 } finally { 620 textArea.remove(); 621 } 622 } 623 } 624 625 onDestroy(() => { 626 if (timer) clearTimeout(timer); 627 }); 628 629 $$self.$$set = $$props => {
630 if ('value' in $$props) $$invalidate(2, value = $$props.value); 631 }; 632 633 return [copied, handle_copy, value]; 634} 635 636class Copy_1 extends SvelteComponent$4 { 637 constructor(options) { 638 super(); 639 init$4(this, options, instance$4, create_fragment$4, safe_not_equal$4, { value: 2 }); 640 } 641} 642 643const LikeDislike_svelte_svelte_type_style_lang = ''; 644 645/* home/runner/work/gradio/gradio/js/chatbot/shared/LikeDislike.svelte generated by Svelte v4.2.2 */ 646const { 647 SvelteComponent: SvelteComponent$3, 648 attr: attr$3, 649 create_component: create_component$2, 650 destroy_component: destroy_component$2, 651 detach: detach$3, 652 element: element$3, 653 init: init$3, 654 insert: insert$3, 655 listen: listen$1, 656 mount_component: mount_component$2, 657 run_all: run_all$1, 658 safe_not_equal: safe_not_equal$3, 659 space: space$2, 660 transition_in: transition_in$2, 661 transition_out: transition_out$2 662} = window.__gradio__svelte__internal; 663function create_fragment$3(ctx) { 664 let button0; 665 let like; 666 let button0_aria_label_value; 667 let t; 668 let button1; 669 let dislike; 670 let button1_aria_label_value; 671 let current; 672 let mounted; 673 let dispose; 674 675 like = new Like({ 676 props: { selected: /*selected*/ ctx[1] === "like" } 677 }); 678 679 dislike = new Dislike({ 680 props: { 681 selected: /*selected*/ ctx[1] === "dislike" 682 } 683 }); 684 685 return { 686 c() { 687 button0 = element$3("button"); 688 create_component$2(like.$$.fragment); 689 t = space$2(); 690 button1 = element$3("button"); 691 create_component$2(dislike.$$.fragment); 692 attr$3(button0, "aria-label", button0_aria_label_value = /*selected*/ ctx[1] === "like" ? "clicked like" : "like"); 693 attr$3(button0, "class", "svelte-3snf3m"); 694 695 attr$3(button1, "aria-label", button1_aria_label_value = /*selected*/ ctx[1] === "dislike" 696 ? "clicked dislike" 697 : "dislike"); 698 699 attr$3(button1, "class", "svelte-3snf3m"); 700 }, 701 m(target, anchor) { 702 insert$3(target, button0, anchor); 703 mount_component$2(like, button0, null); 704 insert$3(target, t, anchor); 705 insert$3(target, button1, anchor); 706 mount_component$2(dislike, button1, null); 707 current = true; 708 709 if (!mounted) { 710 dispose = [ 711 listen$1(button0, "click", /*click_handler*/ ctx[2]), 712 listen$1(button1, "click", /*click_handler_1*/ ctx[3]) 713 ]; 714 715 mounted = true; 716 } 717 }, 718 p(ctx, [dirty]) { 719 const like_changes = {}; 720 if (dirty & /*selected*/ 2) like_changes.selected = /*selected*/ ctx[1] === "like"; 721 like.$set(like_changes); 722 723 if (!current || dirty & /*selected*/ 2 && button0_aria_label_value !== (button0_aria_label_value = /*selected*/ ctx[1] === "like" ? "clicked like" : "like")) { 724 attr$3(button0, "aria-label", button0_aria_label_value); 725 } 726 727 const dislike_changes = {}; 728 if (dirty & /*selected*/ 2) dislike_changes.selected = /*selected*/ ctx[1] === "dislike"; 729 dislike.$set(dislike_changes); 730 731 if (!current || dirty & /*selected*/ 2 && button1_aria_label_value !== (button1_aria_label_value = /*selected*/ ctx[1] === "dislike" 732 ? "clicked dislike" 733 : "dislike")) { 734 attr$3(button1, "aria-label", button1_aria_label_value); 735 } 736 }, 737 i(local) { 738 if (current) return; 739 transition_in$2(like.$$.fragment, local); 740 transition_in$2(dislike.$$.fragment, local); 741 current = true; 742 }, 743 o(local) { 744 transition_out$2(like.$$.fragment, local); 745 transition_out$2(dislike.$$.fragment, local); 746 current = false; 747 }, 748 d(detaching) { 749 if (detaching) { 750 detach$3(button0); 751 detach$3(t); 752 detach$3(button1); 753 } 754 755 destroy_component$2(like); 756 destroy_component$2(dislike); 757 mounted = false; 758 run_all$1(dispose); 759 } 760 }; 761} 762 763function instance$3($$self, $$props, $$invalidate) { 764 let { handle_action } = $$props; 765 let selected = null; 766 767 const click_handler = () => { 768 $$invalidate(1, selected = "like"); 769 handle_action(selected); 770 }; 771 772 const click_handler_1 = () => { 773 $$invalidate(1, selected = "dislike"); 774 handle_action(selected); 775 }; 776 777 $$self.$$set = $$props => {
778 if ('handle_action' in $$props) $$invalidate(0, handle_action = $$props.handle_action); 779 }; 780 781 return [handle_action, selected, click_handler, click_handler_1]; 782} 783 784class LikeDislike extends SvelteComponent$3 { 785 constructor(options) { 786 super(); 787 init$3(this, options, instance$3, create_fragment$3, safe_not_equal$3, { handle_action: 0 }); 788 } 789} 790 791const Pending_svelte_svelte_type_style_lang = ''; 792 793/* home/runner/work/gradio/gradio/js/chatbot/shared/Pending.svelte generated by Svelte v4.2.2 */ 794const { 795 SvelteComponent: SvelteComponent$2, 796 attr: attr$2, 797 detach: detach$2, 798 element: element$2, 799 init: init$2, 800 insert: insert$2, 801 noop: noop$1, 802 safe_not_equal: safe_not_equal$2, 803 set_style: set_style$1 804} = window.__gradio__svelte__internal; 805function create_fragment$2(ctx) { 806 let div3; 807 808 return { 809 c() { 810 div3 = element$2("div"); 811 812 div3.innerHTML = `<span class="sr-only">Loading content</span> <div class="dot-flashing svelte-1gpwetz"></div> 813 Â 814 <div class="dot-flashing svelte-1gpwetz"></div> 815 Â 816 <div class="dot-flashing svelte-1gpwetz"></div>`; 817 818 attr$2(div3, "class", "message pending svelte-1gpwetz"); 819 attr$2(div3, "role", "status"); 820 attr$2(div3, "aria-label", "Loading response"); 821 attr$2(div3, "aria-live", "polite"); 822 823 set_style$1(div3, "border-radius", /*layout*/ ctx[0] === "bubble" 824 ? "var(--radius-xxl)" 825 : "none"); 826 }, 827 m(target, anchor) { 828 insert$2(target, div3, anchor); 829 }, 830 p(ctx, [dirty]) { 831 if (dirty & /*layout*/ 1) { 832 set_style$1(div3, "border-radius", /*layout*/ ctx[0] === "bubble" 833 ? "var(--radius-xxl)" 834 : "none"); 835 } 836 }, 837 i: noop$1, 838 o: noop$1, 839 d(detaching) { 840 if (detaching) { 841 detach$2(div3); 842 } 843 } 844 }; 845} 846 847function instance$2($$self, $$props, $$invalidate) { 848 let { layout = "bubble" } = $$props; 849 850 $$self.$$set = $$props => {
851 if ('layout' in $$props) $$invalidate(0, layout = $$props.layout); 852 }; 853 854 return [layout]; 855} 856 857class Pending extends SvelteComponent$2 { 858 constructor(options) { 859 super(); 860 init$2(this, options, instance$2, create_fragment$2, safe_not_equal$2, { layout: 0 }); 861 } 862} 863 864const ChatBot_svelte_svelte_type_style_lang = ''; 865 866/* home/runner/work/gradio/gradio/js/chatbot/shared/ChatBot.svelte generated by Svelte v4.2.2 */ 867const { 868 SvelteComponent: SvelteComponent$1, 869 action_destroyer, 870 append: append$1, 871 attr: attr$1, 872 binding_callbacks, 873 bubble, 874 check_outros: check_outros$1, 875 create_component: create_component$1, 876 destroy_component: destroy_component$1, 877 destroy_each, 878 detach: detach$1, 879 element: element$1, 880 empty, 881 ensure_array_like, 882 group_outros: group_outros$1, 883 init: init$1, 884 insert: insert$1, 885 listen, 886 mount_component: mount_component$1, 887 noop, 888 null_to_empty, 889 run_all, 890 safe_not_equal: safe_not_equal$1, 891 set_data, 892 set_style, 893 space: space$1, 894 text, 895 toggle_class, 896 transition_in: transition_in$1, 897 transition_out: transition_out$1 898} = window.__gradio__svelte__internal;const { beforeUpdate, afterUpdate, createEventDispatcher } = window.__gradio__svelte__internal; 899function get_each_context(ctx, list, i) { 900 const child_ctx = ctx.slice(); 901 child_ctx[35] = list[i]; 902 child_ctx[37] = i; 903 return child_ctx; 904} 905 906function get_each_context_1(ctx, list, i) { 907 const child_ctx = ctx.slice(); 908 child_ctx[38] = list[i]; 909 child_ctx[40] = i; 910 return child_ctx; 911} 912 913// (94:0) {#if show_share_button && value !== null && value.length > 0} 914function create_if_block_12(ctx) { 915 let div_1; 916 let sharebutton; 917 let current; 918 919 sharebutton = new ShareButton({ 920 props: { 921 i18n: /*i18n*/ ctx[13], 922 formatter: format_chat_for_sharing, 923 value: /*value*/ ctx[0] 924 } 925 }); 926 927 sharebutton.$on("error", /*error_handler*/ ctx[21]); 928 sharebutton.$on("share", /*share_handler*/ ctx[22]); 929 930 return { 931 c() { 932 div_1 = element$1("div"); 933 create_component$1(sharebutton.$$.fragment); 934 attr$1(div_1, "class", "share-button svelte-1lcyrx4"); 935 }, 936 m(target, anchor) { 937 insert$1(target, div_1, anchor); 938 mount_component$1(sharebutton, div_1, null); 939 current = true; 940 }, 941 p(ctx, dirty) { 942 const sharebutton_changes = {}; 943 if (dirty[0] & /*i18n*/ 8192) sharebutton_changes.i18n = /*i18n*/ ctx[13]; 944 if (dirty[0] & /*value*/ 1) sharebutton_changes.value = /*value*/ ctx[0]; 945 sharebutton.$set(sharebutton_changes); 946 }, 947 i(local) { 948 if (current) return; 949 transition_in$1(sharebutton.$$.fragment, local); 950 current = true; 951 }, 952 o(local) { 953 transition_out$1(sharebutton.$$.fragment, local); 954 current = false; 955 }, 956 d(detaching) { 957 if (detaching) { 958 detach$1(div_1); 959 } 960 961 destroy_component$1(sharebutton); 962 } 963 }; 964} 965 966// (114:2) {#if value !== null} 967function create_if_block$1(ctx) { 968 let t; 969 let if_block_anchor; 970 let current; 971 let each_value = ensure_array_like(/*value*/ ctx[0]); 972 let each_blocks = []; 973 974 for (let i = 0; i < each_value.length; i += 1) { 975 each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i)); 976 } 977 978 const out = i => transition_out$1(each_blocks[i], 1, 1, () => { 979 each_blocks[i] = null; 980 }); 981 982 let if_block = /*pending_message*/ ctx[2] && create_if_block_1$1(ctx); 983 984 return { 985 c() { 986 for (let i = 0; i < each_blocks.length; i += 1) { 987 each_blocks[i].c(); 988 } 989 990 t = space$1(); 991 if (if_block) if_block.c(); 992 if_block_anchor = empty(); 993 }, 994 m(target, anchor) { 995 for (let i = 0; i < each_blocks.length; i += 1) { 996 if (each_blocks[i]) { 997 each_blocks[i].m(target, anchor); 998 } 999 } 1000 1001 insert$1(target, t, anchor); 1002 if (if_block) if_block.m(target, anchor); 1003 insert$1(target, if_block_anchor, anchor); 1004 current = true; 1005 }, 1006 p(ctx, dirty) { 1007 if (dirty[0] & /*value, layout, avatar_images, bubble_full_width, show_copy_button, handle_like, likeable, render_markdown, rtl, selectable, handle_select, latex_delimiters, sanitize_html, line_breaks, scroll*/ 483291) { 1008 each_value = ensure_array_like(/*value*/ ctx[0]); 1009 let i; 1010 1011 for (i = 0; i < each_value.length; i += 1) { 1012 const child_ctx = get_each_context(ctx, each_value, i); 1013 1014 if (each_blocks[i]) { 1015 each_blocks[i].p(child_ctx, dirty); 1016 transition_in$1(each_blocks[i], 1); 1017 } else { 1018 each_blocks[i] = create_each_block(child_ctx); 1019 each_blocks[i].c(); 1020 transition_in$1(each_blocks[i], 1); 1021 each_blocks[i].m(t.parentNode, t); 1022 } 1023 } 1024 1025 group_outros$1(); 1026 1027 for (i = each_value.length; i < each_blocks.length; i += 1) { 1028 out(i); 1029 } 1030 1031 check_outros$1(); 1032 } 1033 1034 if (/*pending_message*/ ctx[2]) { 1035 if (if_block) { 1036 if_block.p(ctx, dirty); 1037
1038 if (dirty[0] & /*pending_message*/ 4) { 1039 transition_in$1(if_block, 1); 1040 } 1041 } else { 1042 if_block = create_if_block_1$1(ctx); 1043 if_block.c(); 1044 transition_in$1(if_block, 1); 1045 if_block.m(if_block_anchor.parentNode, if_block_anchor); 1046 } 1047 } else if (if_block) { 1048 group_outros$1(); 1049 1050 transition_out$1(if_block, 1, 1, () => { 1051 if_block = null; 1052 }); 1053 1054 check_outros$1(); 1055 } 1056 }, 1057 i(local) { 1058 if (current) return; 1059 1060 for (let i = 0; i < each_value.length; i += 1) { 1061 transition_in$1(each_blocks[i]); 1062 } 1063 1064 transition_in$1(if_block); 1065 current = true; 1066 }, 1067 o(local) { 1068 each_blocks = each_blocks.filter(Boolean); 1069 1070 for (let i = 0; i < each_blocks.length; i += 1) { 1071 transition_out$1(each_blocks[i]); 1072 } 1073 1074 transition_out$1(if_block); 1075 current = false; 1076 }, 1077 d(detaching) { 1078 if (detaching) { 1079 detach$1(t); 1080 detach$1(if_block_anchor); 1081 } 1082 1083 destroy_each(each_blocks, detaching); 1084 if (if_block) if_block.d(detaching); 1085 } 1086 }; 1087} 1088 1089// (117:5) {#if message !== null} 1090function create_if_block_2(ctx) { 1091 let div1; 1092 let t0; 1093 let div0; 1094 let button; 1095 let show_if; 1096 let show_if_1; 1097 let show_if_2; 1098 let current_block_type_index; 1099 let if_block1; 1100 let button_dir_value; 1101 let button_aria_label_value; 1102 let t1; 1103 let div1_class_value; 1104 let current; 1105 let mounted; 1106 let dispose; 1107 let if_block0 = /*avatar_images*/ ctx[8][/*j*/ ctx[40]] !== null && create_if_block_11(ctx); 1108 1109 const if_block_creators = [ 1110 create_if_block_6, 1111 create_if_block_7, 1112 create_if_block_8, 1113 create_if_block_9, 1114 create_if_block_10 1115 ]; 1116 1117 const if_blocks = []; 1118 1119 function select_block_type(ctx, dirty) { 1120 if (dirty[0] & /*value*/ 1) show_if = null; 1121 if (dirty[0] & /*value*/ 1) show_if_1 = null; 1122 if (dirty[0] & /*value*/ 1) show_if_2 = null; 1123 if (typeof /*message*/ ctx[38] === "string") return 0; 1124 if (show_if == null) show_if = !!(/*message*/ ctx[38] !== null && /*message*/ ctx[38].file?.mime_type?.includes("audio")); 1125 if (show_if) return 1; 1126 if (show_if_1 == null) show_if_1 = !!(/*message*/ ctx[38] !== null && /*message*/ ctx[38].file?.mime_type?.includes("video")); 1127 if (show_if_1) return 2; 1128 if (show_if_2 == null) show_if_2 = !!(/*message*/ ctx[38] !== null && /*message*/ ctx[38].file?.mime_type?.includes("image")); 1129 if (show_if_2) return 3; 1130 if (/*message*/ ctx[38] !== null && /*message*/ ctx[38].file?.url !== null) return 4; 1131 return -1; 1132 } 1133 1134 if (~(current_block_type_index = select_block_type(ctx, [-1, -1]))) { 1135 if_block1 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); 1136 } 1137 1138 function click_handler() { 1139 return /*click_handler*/ ctx[29](/*i*/ ctx[37], /*j*/ ctx[40], /*message*/ ctx[38]); 1140 } 1141 1142 function keydown_handler(...args) { 1143 return /*keydown_handler*/ ctx[30](/*i*/ ctx[37], /*j*/ ctx[40], /*message*/ ctx[38], ...args); 1144 } 1145 1146 let if_block2 = (/*likeable*/ ctx[4] && /*j*/ ctx[40] !== 0 || /*show_copy_button*/ ctx[7] && /*message*/ ctx[38] && typeof /*message*/ ctx[38] === "string") && create_if_block_3(ctx); 1147 1148 return { 1149 c() { 1150 div1 = element$1("div"); 1151 if (if_block0) if_block0.c(); 1152 t0 = space$1(); 1153 div0 = element$1("div"); 1154 button = element$1("button"); 1155 if (if_block1) if_block1.c(); 1156 t1 = space$1(); 1157 if (if_block2) if_block2.c(); 1158 attr$1(button, "data-testid", /*j*/ ctx[40] == 0 ? "user" : "bot"); 1159 attr$1(button, "dir", button_dir_value = /*rtl*/ ctx[6] ? "rtl" : "ltr"); 1160 1161 attr$1(button, "aria-label", button_aria_label_value = (/*j*/ ctx[40] == 0 ? "user" : "bot") + "'s message: " + (typeof /*message*/ ctx[38] === "string" 1162 ? /*message*/ ctx[38] 1163 : `a file of type ${/*message*/ ctx[38].file?.mime_type}, ${/*message*/ ctx[38].file?.alt_text ?? /*message*/ ctx[38].file?.orig_name ?? ""}`)); 1164 1165 attr$1(button, "class", "svelte-1lcyrx4"); 1166 toggle_class(button, "latest", /*i*/ ctx[37] === /*value*/ ctx[0].length - 1); 1167 toggle_class(button, "message-markdown-disabled", !/*render_markdown*/ ctx[11]); 1168 toggle_class(button, "selectable", /*selectable*/ ctx[3]); 1169 set_style(button, "user-select", `text`); 1170 set_style(button, "text-align", /*rtl*/ ctx[6] ? "right" : "left"); 1171 attr$1(div0, "class", "message " + (/*j*/ ctx[40] == 0 ? 'user' : 'bot') + " svelte-1lcyrx4"); 1172 toggle_class(div0, "message-fit", /*layout*/ ctx[14] === "bubble" && !/*bubble_full_width*/ ctx[10]); 1173 toggle_class(div0, "panel-full-width", /*layout*/ ctx[14] === "panel"); 1174 toggle_class(div0, "message-bubble-border", /*layout*/ ctx[14] === "bubble"); 1175 toggle_class(div0, "message-markdown-disabled", !/*render_markdown*/ ctx[11]); 1176 set_style(div0, "text-align", /*rtl*/ ctx[6] && /*j*/ ctx[40] == 0 ? "left" : "right"); 1177 attr$1(div1, "class", div1_class_value = "message-row " + /*layout*/ ctx[14] + " " + (/*j*/ ctx[40] == 0 ? 'user-row' : 'bot-row') + " svelte-1lcyrx4"); 1178 }, 1179 m(target, anchor) { 1180 insert$1(target, div1, anchor); 1181 if (if_block0) if_block0.m(div1, null); 1182 append$1(div1, t0); 1183 append$1(div1, div0); 1184 append$1(div0, button); 1185 1186 if (~current_block_type_index) { 1187 if_blocks[current_block_type_index].m(button, null); 1188 } 1189 1190 append$1(div1, t1); 1191 if (if_block2) if_block2.m(div1, null); 1192 current = true; 1193 1194 if (!mounted) { 1195 dispose = [ 1196 listen(button, "click", click_handler), 1197 listen(button, "keydown", keydown_handler) 1198 ]; 1199 1200 mounted = true; 1201 } 1202 }, 1203 p(new_ctx, dirty) { 1204 ctx = new_ctx; 1205 1206 if (/*avatar_images*/ ctx[8][/*j*/ ctx[40]] !== null) { 1207 if (if_block0) { 1208 if_block0.p(ctx, dirty); 1209
1210 if (dirty[0] & /*avatar_images*/ 256) { 1211 transition_in$1(if_block0, 1); 1212 } 1213 } else { 1214 if_block0 = create_if_block_11(ctx); 1215 if_block0.c(); 1216 transition_in$1(if_block0, 1); 1217 if_block0.m(div1, t0); 1218 } 1219 } else if (if_block0) { 1220 group_outros$1(); 1221 1222 transition_out$1(if_block0, 1, 1, () => { 1223 if_block0 = null; 1224 }); 1225 1226 check_outros$1(); 1227 } 1228 1229 let previous_block_index = current_block_type_index; 1230 current_block_type_index = select_block_type(ctx, dirty); 1231 1232 if (current_block_type_index === previous_block_index) { 1233 if (~current_block_type_index) { 1234 if_blocks[current_block_type_index].p(ctx, dirty); 1235 } 1236 } else { 1237 if (if_block1) { 1238 group_outros$1(); 1239 1240 transition_out$1(if_blocks[previous_block_index], 1, 1, () => { 1241 if_blocks[previous_block_index] = null; 1242 }); 1243 1244 check_outros$1(); 1245 } 1246 1247 if (~current_block_type_index) { 1248 if_block1 = if_blocks[current_block_type_index]; 1249 1250 if (!if_block1) { 1251 if_block1 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); 1252 if_block1.c(); 1253 } else { 1254 if_block1.p(ctx, dirty); 1255 } 1256 1257 transition_in$1(if_block1, 1); 1258 if_block1.m(button, null); 1259 } else { 1260 if_block1 = null; 1261 } 1262 } 1263 1264 if (!current || dirty[0] & /*rtl*/ 64 && button_dir_value !== (button_dir_value = /*rtl*/ ctx[6] ? "rtl" : "ltr")) { 1265 attr$1(button, "dir", button_dir_value); 1266 } 1267 1268 if (!current || dirty[0] & /*value*/ 1 && button_aria_label_value !== (button_aria_label_value = (/*j*/ ctx[40] == 0 ? "user" : "bot") + "'s message: " + (typeof /*message*/ ctx[38] === "string" 1269 ? /*message*/ ctx[38] 1270 : `a file of type ${/*message*/ ctx[38].file?.mime_type}, ${/*message*/ ctx[38].file?.alt_text ?? /*message*/ ctx[38].file?.orig_name ?? ""}`))) { 1271 attr$1(button, "aria-label", button_aria_label_value); 1272 } 1273 1274 if (!current || dirty[0] & /*value*/ 1) { 1275 toggle_class(button, "latest", /*i*/ ctx[37] === /*value*/ ctx[0].length - 1); 1276 } 1277 1278 if (!current || dirty[0] & /*render_markdown*/ 2048) { 1279 toggle_class(button, "message-markdown-disabled", !/*render_markdown*/ ctx[11]); 1280 } 1281 1282 if (!current || dirty[0] & /*selectable*/ 8) { 1283 toggle_class(button, "selectable", /*selectable*/ ctx[3]); 1284 } 1285 1286 if (dirty[0] & /*rtl*/ 64) { 1287 set_style(button, "text-align", /*rtl*/ ctx[6] ? "right" : "left"); 1288 } 1289 1290 if (!current || dirty[0] & /*layout, bubble_full_width*/ 17408) { 1291 toggle_class(div0, "message-fit", /*layout*/ ctx[14] === "bubble" && !/*bubble_full_width*/ ctx[10]); 1292 } 1293 1294 if (!current || dirty[0] & /*layout*/ 16384) { 1295 toggle_class(div0, "panel-full-width", /*layout*/ ctx[14] === "panel"); 1296 } 1297 1298 if (!current || dirty[0] & /*layout*/ 16384) { 1299 toggle_class(div0, "message-bubble-border", /*layout*/ ctx[14] === "bubble"); 1300 } 1301 1302 if (!current || dirty[0] & /*render_markdown*/ 2048) { 1303 toggle_class(div0, "message-markdown-disabled", !/*render_markdown*/ ctx[11]); 1304 } 1305 1306 if (dirty[0] & /*rtl*/ 64) { 1307 set_style(div0, "text-align", /*rtl*/ ctx[6] && /*j*/ ctx[40] == 0 ? "left" : "right"); 1308 } 1309 1310 if (/*likeable*/ ctx[4] && /*j*/ ctx[40] !== 0 || /*show_copy_button*/ ctx[7] && /*message*/ ctx[38] && typeof /*message*/ ctx[38] === "string") { 1311 if (if_block2) { 1312 if_block2.p(ctx, dirty); 1313 1314 if (dirty[0] & /*likeable, show_copy_button, value*/ 145) { 1315 transition_in$1(if_block2, 1); 1316 } 1317 } else { 1318 if_block2 = create_if_block_3(ctx); 1319 if_block2.c(); 1320 transition_in$1(if_block2, 1); 1321 if_block2.m(div1, null); 1322 } 1323 } else if (if_block2) { 1324 group_outros$1(); 1325 1326 transition_out$1(if_block2, 1, 1, () => { 1327 if_block2 = null; 1328 }); 1329 1330 check_outros$1(); 1331 } 1332 1333 if (!current || dirty[0] & /*layout*/ 16384 && div1_class_value !== (div1_class_value = "message-row " + /*layout*/ ctx[14] + " " + (/*j*/ ctx[40] == 0 ? 'user-row' : 'bot-row') + " svelte-1lcyrx4")) { 1334 attr$1(div1, "class", div1_class_value); 1335 } 1336 }, 1337 i(local) { 1338 if (current) return; 1339 transition_in$1(if_block0); 1340 transition_in$1(if_block1); 1341 transition_in$1(if_block2); 1342 current = true; 1343 }, 1344 o(local) { 1345 transition_out$1(if_block0); 1346 transition_out$1(if_block1); 1347 transition_out$1(if_block2); 1348 current = false;
1349 }, 1350 d(detaching) { 1351 if (detaching) { 1352 detach$1(div1); 1353 } 1354 1355 if (if_block0) if_block0.d(); 1356 1357 if (~current_block_type_index) { 1358 if_blocks[current_block_type_index].d(); 1359 } 1360 1361 if (if_block2) if_block2.d(); 1362 mounted = false; 1363 run_all(dispose); 1364 } 1365 }; 1366} 1367 1368// (119:7) {#if avatar_images[j] !== null} 1369function create_if_block_11(ctx) { 1370 let div_1; 1371 let image; 1372 let current; 1373 1374 image = new Image({ 1375 props: { 1376 class: "avatar-image", 1377 src: /*avatar_images*/ ctx[8][/*j*/ ctx[40]]?.url, 1378 alt: "" + ((/*j*/ ctx[40] == 0 ? 'user' : 'bot') + " avatar") 1379 } 1380 }); 1381 1382 return { 1383 c() { 1384 div_1 = element$1("div"); 1385 create_component$1(image.$$.fragment); 1386 attr$1(div_1, "class", "avatar-container svelte-1lcyrx4"); 1387 }, 1388 m(target, anchor) { 1389 insert$1(target, div_1, anchor); 1390 mount_component$1(image, div_1, null); 1391 current = true; 1392 }, 1393 p(ctx, dirty) { 1394 const image_changes = {}; 1395 if (dirty[0] & /*avatar_images*/ 256) image_changes.src = /*avatar_images*/ ctx[8][/*j*/ ctx[40]]?.url; 1396 image.$set(image_changes); 1397 }, 1398 i(local) { 1399 if (current) return; 1400 transition_in$1(image.$$.fragment, local); 1401 current = true; 1402 }, 1403 o(local) { 1404 transition_out$1(image.$$.fragment, local); 1405 current = false; 1406 }, 1407 d(detaching) { 1408 if (detaching) { 1409 detach$1(div_1); 1410 } 1411 1412 destroy_component$1(image); 1413 } 1414 }; 1415} 1416 1417// (200:66) 1418function create_if_block_10(ctx) { 1419 let a; 1420 let t_value = (/*message*/ ctx[38].file?.orig_name || /*message*/ ctx[38].file?.path) + ""; 1421 let t; 1422 let a_href_value; 1423 let a_download_value; 1424 1425 return { 1426 c() { 1427 a = element$1("a"); 1428 t = text(t_value); 1429 attr$1(a, "data-testid", "chatbot-file"); 1430 attr$1(a, "href", a_href_value = /*message*/ ctx[38].file?.url); 1431 attr$1(a, "target", "_blank"); 1432 1433 attr$1(a, "download", a_download_value = window.__is_colab__ 1434 ? null 1435 : /*message*/ ctx[38].file?.orig_name || /*message*/ ctx[38].file?.path); 1436 1437 attr$1(a, "class", "svelte-1lcyrx4"); 1438 }, 1439 m(target, anchor) { 1440 insert$1(target, a, anchor); 1441 append$1(a, t); 1442 }, 1443 p(ctx, dirty) { 1444 if (dirty[0] & /*value*/ 1 && t_value !== (t_value = (/*message*/ ctx[38].file?.orig_name || /*message*/ ctx[38].file?.path) + "")) set_data(t, t_value); 1445 1446 if (dirty[0] & /*value*/ 1 && a_href_value !== (a_href_value = /*message*/ ctx[38].file?.url)) { 1447 attr$1(a, "href", a_href_value); 1448 } 1449 1450 if (dirty[0] & /*value*/ 1 && a_download_value !== (a_download_value = window.__is_colab__ 1451 ? null 1452 : /*message*/ ctx[38].file?.orig_name || /*message*/ ctx[38].file?.path)) { 1453 attr$1(a, "download", a_download_value); 1454 } 1455 }, 1456 i: noop, 1457 o: noop, 1458 d(detaching) { 1459 if (detaching) { 1460 detach$1(a); 1461 } 1462 } 1463 }; 1464} 1465 1466// (194:82) 1467function create_if_block_9(ctx) { 1468 let image; 1469 let current; 1470 1471 image = new Image({ 1472 props: { 1473 "data-testid": "chatbot-image", 1474 src: /*message*/ ctx[38].file?.url, 1475 alt: /*message*/ ctx[38].alt_text 1476 } 1477 }); 1478 1479 return { 1480 c() { 1481 create_component$1(image.$$.fragment); 1482 }, 1483 m(target, anchor) { 1484 mount_component$1(image, target, anchor); 1485 current = true; 1486 }, 1487 p(ctx, dirty) { 1488 const image_changes = {}; 1489 if (dirty[0] & /*value*/ 1) image_changes.src = /*message*/ ctx[38].file?.url; 1490 if (dirty[0] & /*value*/ 1) image_changes.alt = /*message*/ ctx[38].alt_text; 1491 image.$set(image_changes); 1492 }, 1493 i(local) { 1494 if (current) return; 1495 transition_in$1(image.$$.fragment, local); 1496 current = true; 1497 }, 1498 o(local) { 1499 transition_out$1(image.$$.fragment, local); 1500 current = false; 1501 }, 1502 d(detaching) { 1503 destroy_component$1(image, detaching); 1504 } 1505 }; 1506} 1507 1508// (181:82) 1509function create_if_block_8(ctx) { 1510 let video; 1511 let current; 1512 1513 video = new Video({ 1514 props: { 1515 "data-testid": "chatbot-video", 1516 controls: true, 1517 src: /*message*/ ctx[38].file?.url, 1518 title: /*message*/ ctx[38].alt_text, 1519 preload: "auto", 1520 $$slots: { default: [create_default_slot$1] }, 1521 $$scope: { ctx } 1522 } 1523 }); 1524 1525 video.$on("play", /*play_handler_1*/ ctx[26]); 1526 video.$on("pause", /*pause_handler_1*/ ctx[27]); 1527 video.$on("ended", /*ended_handler_1*/ ctx[28]); 1528 1529 return { 1530 c() { 1531 create_component$1(video.$$.fragment); 1532 }, 1533 m(target, anchor) { 1534 mount_component$1(video, target, anchor); 1535 current = true; 1536 }, 1537 p(ctx, dirty) { 1538 const video_changes = {};
1539 if (dirty[0] & /*value*/ 1) video_changes.src = /*message*/ ctx[38].file?.url; 1540 if (dirty[0] & /*value*/ 1) video_changes.title = /*message*/ ctx[38].alt_text; 1541 1542 if (dirty[1] & /*$$scope*/ 1024) { 1543 video_changes.$$scope = { dirty, ctx }; 1544 } 1545 1546 video.$set(video_changes); 1547 }, 1548 i(local) { 1549 if (current) return; 1550 transition_in$1(video.$$.fragment, local); 1551 current = true; 1552 }, 1553 o(local) { 1554 transition_out$1(video.$$.fragment, local); 1555 current = false; 1556 }, 1557 d(detaching) { 1558 destroy_component$1(video, detaching); 1559 } 1560 }; 1561} 1562 1563// (170:82) 1564function create_if_block_7(ctx) { 1565 let audio; 1566 let current; 1567 1568 audio = new Audio({ 1569 props: { 1570 "data-testid": "chatbot-audio", 1571 controls: true, 1572 preload: "metadata", 1573 src: /*message*/ ctx[38].file?.url, 1574 title: /*message*/ ctx[38].alt_text 1575 } 1576 }); 1577 1578 audio.$on("play", /*play_handler*/ ctx[23]); 1579 audio.$on("pause", /*pause_handler*/ ctx[24]); 1580 audio.$on("ended", /*ended_handler*/ ctx[25]); 1581 1582 return { 1583 c() { 1584 create_component$1(audio.$$.fragment); 1585 }, 1586 m(target, anchor) { 1587 mount_component$1(audio, target, anchor); 1588 current = true; 1589 }, 1590 p(ctx, dirty) { 1591 const audio_changes = {}; 1592 if (dirty[0] & /*value*/ 1) audio_changes.src = /*message*/ ctx[38].file?.url; 1593 if (dirty[0] & /*value*/ 1) audio_changes.title = /*message*/ ctx[38].alt_text; 1594 audio.$set(audio_changes); 1595 }, 1596 i(local) { 1597 if (current) return; 1598 transition_in$1(audio.$$.fragment, local); 1599 current = true; 1600 }, 1601 o(local) { 1602 transition_out$1(audio.$$.fragment, local); 1603 current = false; 1604 }, 1605 d(detaching) { 1606 destroy_component$1(audio, detaching); 1607 } 1608 }; 1609} 1610 1611// (161:9) {#if typeof message === "string"} 1612function create_if_block_6(ctx) { 1613 let markdown; 1614 let current; 1615 1616 markdown = new MarkdownCode({ 1617 props: { 1618 message: /*message*/ ctx[38], 1619 latex_delimiters: /*latex_delimiters*/ ctx[1], 1620 sanitize_html: /*sanitize_html*/ ctx[9], 1621 render_markdown: /*render_markdown*/ ctx[11], 1622 line_breaks: /*line_breaks*/ ctx[12] 1623 } 1624 }); 1625 1626 markdown.$on("load", /*scroll*/ ctx[16]); 1627 1628 return { 1629 c() { 1630 create_component$1(markdown.$$.fragment); 1631 }, 1632 m(target, anchor) { 1633 mount_component$1(markdown, target, anchor); 1634 current = true; 1635 }, 1636 p(ctx, dirty) { 1637 const markdown_changes = {}; 1638 if (dirty[0] & /*value*/ 1) markdown_changes.message = /*message*/ ctx[38]; 1639 if (dirty[0] & /*latex_delimiters*/ 2) markdown_changes.latex_delimiters = /*latex_delimiters*/ ctx[1]; 1640 if (dirty[0] & /*sanitize_html*/ 512) markdown_changes.sanitize_html = /*sanitize_html*/ ctx[9]; 1641 if (dirty[0] & /*render_markdown*/ 2048) markdown_changes.render_markdown = /*render_markdown*/ ctx[11]; 1642 if (dirty[0] & /*line_breaks*/ 4096) markdown_changes.line_breaks = /*line_breaks*/ ctx[12]; 1643 markdown.$set(markdown_changes); 1644 }, 1645 i(local) { 1646 if (current) return; 1647 transition_in$1(markdown.$$.fragment, local); 1648 current = true; 1649 }, 1650 o(local) { 1651 transition_out$1(markdown.$$.fragment, local); 1652 current = false; 1653 }, 1654 d(detaching) { 1655 destroy_component$1(markdown, detaching); 1656 } 1657 }; 1658} 1659 1660// (182:10) <Video data-testid="chatbot-video" controls src={message.file?.url} title={message.alt_text} preload="auto" on:play on:pause on:ended > 1661function create_default_slot$1(ctx) { 1662 let track; 1663 1664 return { 1665 c() { 1666 track = element$1("track"); 1667 attr$1(track, "kind", "captions"); 1668 attr$1(track, "class", "svelte-1lcyrx4"); 1669 }, 1670 m(target, anchor) { 1671 insert$1(target, track, anchor); 1672 }, 1673 p: noop, 1674 d(detaching) { 1675 if (detaching) { 1676 detach$1(track); 1677 } 1678 } 1679 }; 1680} 1681 1682// (214:7) {#if (likeable && j !== 0) || (show_copy_button && message && typeof message === "string")} 1683function create_if_block_3(ctx) { 1684 let div_1; 1685 let t; 1686 let div_1_class_value; 1687 let current; 1688 let if_block0 = /*likeable*/ ctx[4] && /*j*/ ctx[40] == 1 && create_if_block_5(ctx); 1689 let if_block1 = /*show_copy_button*/ ctx[7] && /*message*/ ctx[38] && typeof /*message*/ ctx[38] === "string" && create_if_block_4(ctx); 1690 1691 return { 1692 c() { 1693 div_1 = element$1("div"); 1694 if (if_block0) if_block0.c(); 1695 t = space$1(); 1696 if (if_block1) if_block1.c(); 1697 attr$1(div_1, "class", div_1_class_value = "message-buttons-" + (/*j*/ ctx[40] == 0 ? 'user' : 'bot') + " message-buttons-" + /*layout*/ ctx[14] + " " + (/*avatar_images*/ ctx[8][/*j*/ ctx[40]] !== null && 'with-avatar') + " svelte-1lcyrx4"); 1698 toggle_class(div_1, "message-buttons-fit", /*layout*/ ctx[14] === "bubble" && !/*bubble_full_width*/ ctx[10]); 1699 toggle_class(div_1, "bubble-buttons-user", /*layout*/ ctx[14] === "bubble"); 1700 }, 1701 m(target, anchor) { 1702 insert$1(target, div_1, anchor); 1703 if (if_block0) if_block0.m(div_1, null); 1704 append$1(div_1, t); 1705 if (if_block1) if_block1.m(div_1, null); 1706 current = true; 1707 }, 1708 p(ctx, dirty) { 1709 if (/*likeable*/ ctx[4] && /*j*/ ctx[40] == 1) { 1710 if (if_block0) { 1711 if_block0.p(ctx, dirty); 1712
1713 if (dirty[0] & /*likeable*/ 16) { 1714 transition_in$1(if_block0, 1); 1715 } 1716 } else { 1717 if_block0 = create_if_block_5(ctx); 1718 if_block0.c(); 1719 transition_in$1(if_block0, 1); 1720 if_block0.m(div_1, t); 1721 } 1722 } else if (if_block0) { 1723 group_outros$1(); 1724 1725 transition_out$1(if_block0, 1, 1, () => { 1726 if_block0 = null; 1727 }); 1728 1729 check_outros$1(); 1730 } 1731 1732 if (/*show_copy_button*/ ctx[7] && /*message*/ ctx[38] && typeof /*message*/ ctx[38] === "string") { 1733 if (if_block1) { 1734 if_block1.p(ctx, dirty); 1735 1736 if (dirty[0] & /*show_copy_button, value*/ 129) { 1737 transition_in$1(if_block1, 1); 1738 } 1739 } else { 1740 if_block1 = create_if_block_4(ctx); 1741 if_block1.c(); 1742 transition_in$1(if_block1, 1); 1743 if_block1.m(div_1, null); 1744 } 1745 } else if (if_block1) { 1746 group_outros$1(); 1747 1748 transition_out$1(if_block1, 1, 1, () => { 1749 if_block1 = null; 1750 }); 1751 1752 check_outros$1(); 1753 } 1754 1755 if (!current || dirty[0] & /*layout, avatar_images*/ 16640 && div_1_class_value !== (div_1_class_value = "message-buttons-" + (/*j*/ ctx[40] == 0 ? 'user' : 'bot') + " message-buttons-" + /*layout*/ ctx[14] + " " + (/*avatar_images*/ ctx[8][/*j*/ ctx[40]] !== null && 'with-avatar') + " svelte-1lcyrx4")) { 1756 attr$1(div_1, "class", div_1_class_value); 1757 } 1758 1759 if (!current || dirty[0] & /*layout, avatar_images, layout, bubble_full_width*/ 17664) { 1760 toggle_class(div_1, "message-buttons-fit", /*layout*/ ctx[14] === "bubble" && !/*bubble_full_width*/ ctx[10]); 1761 } 1762 1763 if (!current || dirty[0] & /*layout, avatar_images, layout*/ 16640) { 1764 toggle_class(div_1, "bubble-buttons-user", /*layout*/ ctx[14] === "bubble"); 1765 } 1766 }, 1767 i(local) { 1768 if (current) return; 1769 transition_in$1(if_block0); 1770 transition_in$1(if_block1); 1771 current = true; 1772 }, 1773 o(local) { 1774 transition_out$1(if_block0); 1775 transition_out$1(if_block1); 1776 current = false; 1777 }, 1778 d(detaching) { 1779 if (detaching) { 1780 detach$1(div_1); 1781 } 1782 1783 if (if_block0) if_block0.d(); 1784 if (if_block1) if_block1.d(); 1785 } 1786 }; 1787} 1788 1789// (224:9) {#if likeable && j == 1} 1790function create_if_block_5(ctx) { 1791 let likedislike; 1792 let current; 1793 1794 function func(...args) { 1795 return /*func*/ ctx[31](/*i*/ ctx[37], /*j*/ ctx[40], /*message*/ ctx[38], ...args); 1796 } 1797 1798 likedislike = new LikeDislike({ props: { handle_action: func } }); 1799 1800 return { 1801 c() { 1802 create_component$1(likedislike.$$.fragment); 1803 }, 1804 m(target, anchor) { 1805 mount_component$1(likedislike, target, anchor); 1806 current = true; 1807 }, 1808 p(new_ctx, dirty) { 1809 ctx = new_ctx; 1810 const likedislike_changes = {}; 1811 if (dirty[0] & /*value*/ 1) likedislike_changes.handle_action = func; 1812 likedislike.$set(likedislike_changes); 1813 }, 1814 i(local) { 1815 if (current) return; 1816 transition_in$1(likedislike.$$.fragment, local); 1817 current = true; 1818 }, 1819 o(local) { 1820 transition_out$1(likedislike.$$.fragment, local); 1821 current = false; 1822 }, 1823 d(detaching) { 1824 destroy_component$1(likedislike, detaching); 1825 } 1826 }; 1827} 1828 1829// (230:9) {#if show_copy_button && message && typeof message === "string"} 1830function create_if_block_4(ctx) { 1831 let copy_1; 1832 let current; 1833 copy_1 = new Copy_1({ props: { value: /*message*/ ctx[38] } }); 1834 1835 return { 1836 c() { 1837 create_component$1(copy_1.$$.fragment); 1838 }, 1839 m(target, anchor) { 1840 mount_component$1(copy_1, target, anchor); 1841 current = true; 1842 }, 1843 p(ctx, dirty) { 1844 const copy_1_changes = {}; 1845 if (dirty[0] & /*value*/ 1) copy_1_changes.value = /*message*/ ctx[38]; 1846 copy_1.$set(copy_1_changes); 1847 }, 1848 i(local) { 1849 if (current) return; 1850 transition_in$1(copy_1.$$.fragment, local); 1851 current = true; 1852 }, 1853 o(local) { 1854 transition_out$1(copy_1.$$.fragment, local); 1855 current = false; 1856 }, 1857 d(detaching) { 1858 destroy_component$1(copy_1, detaching); 1859 } 1860 }; 1861} 1862 1863// (116:4) {#each message_pair as message, j} 1864function create_each_block_1(ctx) { 1865 let if_block_anchor; 1866 let current; 1867 let if_block = /*message*/ ctx[38] !== null && create_if_block_2(ctx); 1868 1869 return { 1870 c() { 1871 if (if_block) if_block.c(); 1872 if_block_anchor = empty(); 1873 }, 1874 m(target, anchor) { 1875 if (if_block) if_block.m(target, anchor); 1876 insert$1(target, if_block_anchor, anchor); 1877 current = true; 1878 }, 1879 p(ctx, dirty) { 1880 if (/*message*/ ctx[38] !== null) { 1881 if (if_block) { 1882 if_block.p(ctx, dirty); 1883
1884 if (dirty[0] & /*value*/ 1) { 1885 transition_in$1(if_block, 1); 1886 } 1887 } else { 1888 if_block = create_if_block_2(ctx); 1889 if_block.c(); 1890 transition_in$1(if_block, 1); 1891 if_block.m(if_block_anchor.parentNode, if_block_anchor); 1892 } 1893 } else if (if_block) { 1894 group_outros$1(); 1895 1896 transition_out$1(if_block, 1, 1, () => { 1897 if_block = null; 1898 }); 1899 1900 check_outros$1(); 1901 } 1902 }, 1903 i(local) { 1904 if (current) return; 1905 transition_in$1(if_block); 1906 current = true; 1907 }, 1908 o(local) { 1909 transition_out$1(if_block); 1910 current = false; 1911 }, 1912 d(detaching) { 1913 if (detaching) { 1914 detach$1(if_block_anchor); 1915 } 1916 1917 if (if_block) if_block.d(detaching); 1918 } 1919 }; 1920} 1921 1922// (115:3) {#each value as message_pair, i} 1923function create_each_block(ctx) { 1924 let each_1_anchor; 1925 let current; 1926 let each_value_1 = ensure_array_like(/*message_pair*/ ctx[35]); 1927 let each_blocks = []; 1928 1929 for (let i = 0; i < each_value_1.length; i += 1) { 1930 each_blocks[i] = create_each_block_1(get_each_context_1(ctx, each_value_1, i)); 1931 } 1932 1933 const out = i => transition_out$1(each_blocks[i], 1, 1, () => { 1934 each_blocks[i] = null; 1935 }); 1936 1937 return { 1938 c() { 1939 for (let i = 0; i < each_blocks.length; i += 1) { 1940 each_blocks[i].c(); 1941 } 1942 1943 each_1_anchor = empty(); 1944 }, 1945 m(target, anchor) { 1946 for (let i = 0; i < each_blocks.length; i += 1) { 1947 if (each_blocks[i]) { 1948 each_blocks[i].m(target, anchor); 1949 } 1950 } 1951 1952 insert$1(target, each_1_anchor, anchor); 1953 current = true; 1954 }, 1955 p(ctx, dirty) { 1956 if (dirty[0] & /*layout, avatar_images, bubble_full_width, value, show_copy_button, handle_like, likeable, render_markdown, rtl, selectable, handle_select, latex_delimiters, sanitize_html, line_breaks, scroll*/ 483291) { 1957 each_value_1 = ensure_array_like(/*message_pair*/ ctx[35]); 1958 let i; 1959 1960 for (i = 0; i < each_value_1.length; i += 1) { 1961 const child_ctx = get_each_context_1(ctx, each_value_1, i); 1962 1963 if (each_blocks[i]) { 1964 each_blocks[i].p(child_ctx, dirty); 1965 transition_in$1(each_blocks[i], 1); 1966 } else { 1967 each_blocks[i] = create_each_block_1(child_ctx); 1968 each_blocks[i].c(); 1969 transition_in$1(each_blocks[i], 1); 1970 each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor); 1971 } 1972 } 1973 1974 group_outros$1(); 1975 1976 for (i = each_value_1.length; i < each_blocks.length; i += 1) { 1977 out(i); 1978 } 1979 1980 check_outros$1(); 1981 } 1982 }, 1983 i(local) { 1984 if (current) return; 1985 1986 for (let i = 0; i < each_value_1.length; i += 1) { 1987 transition_in$1(each_blocks[i]); 1988 } 1989 1990 current = true; 1991 }, 1992 o(local) {
1993 each_blocks = each_blocks.filter(Boolean); 1994 1995 for (let i = 0; i < each_blocks.length; i += 1) { 1996 transition_out$1(each_blocks[i]); 1997 } 1998 1999 current = false; 2000 }, 2001 d(detaching) { 2002 if (detaching) { 2003 detach$1(each_1_anchor); 2004 } 2005 2006 destroy_each(each_blocks, detaching); 2007 } 2008 }; 2009} 2010 2011// (239:3) {#if pending_message} 2012function create_if_block_1$1(ctx) { 2013 let pending; 2014 let current; 2015 pending = new Pending({ props: { layout: /*layout*/ ctx[14] } }); 2016 2017 return { 2018 c() { 2019 create_component$1(pending.$$.fragment); 2020 }, 2021 m(target, anchor) { 2022 mount_component$1(pending, target, anchor); 2023 current = true; 2024 }, 2025 p(ctx, dirty) { 2026 const pending_changes = {}; 2027 if (dirty[0] & /*layout*/ 16384) pending_changes.layout = /*layout*/ ctx[14]; 2028 pending.$set(pending_changes); 2029 }, 2030 i(local) { 2031 if (current) return; 2032 transition_in$1(pending.$$.fragment, local); 2033 current = true; 2034 }, 2035 o(local) { 2036 transition_out$1(pending.$$.fragment, local); 2037 current = false; 2038 }, 2039 d(detaching) { 2040 destroy_component$1(pending, detaching); 2041 } 2042 }; 2043} 2044 2045function create_fragment$1(ctx) { 2046 let t; 2047 let div1; 2048 let div0; 2049 let div1_class_value; 2050 let current; 2051 let mounted; 2052 let dispose; 2053 let if_block0 = /*show_share_button*/ ctx[5] && /*value*/ ctx[0] !== null && /*value*/ ctx[0].length > 0 && create_if_block_12(ctx); 2054 let if_block1 = /*value*/ ctx[0] !== null && create_if_block$1(ctx); 2055 2056 return { 2057 c() { 2058 if (if_block0) if_block0.c(); 2059 t = space$1(); 2060 div1 = element$1("div"); 2061 div0 = element$1("div"); 2062 if (if_block1) if_block1.c(); 2063 attr$1(div0, "class", "message-wrap svelte-1lcyrx4"); 2064 toggle_class(div0, "bubble-gap", /*layout*/ ctx[14] === "bubble"); 2065 2066 attr$1(div1, "class", div1_class_value = "" + (null_to_empty(/*layout*/ ctx[14] === "bubble" 2067 ? "bubble-wrap" 2068 : "panel-wrap") + " svelte-1lcyrx4")); 2069 2070 attr$1(div1, "role", "log"); 2071 attr$1(div1, "aria-label", "chatbot conversation"); 2072 attr$1(div1, "aria-live", "polite"); 2073 }, 2074 m(target, anchor) { 2075 if (if_block0) if_block0.m(target, anchor); 2076 insert$1(target, t, anchor); 2077 insert$1(target, div1, anchor); 2078 append$1(div1, div0); 2079 if (if_block1) if_block1.m(div0, null); 2080 /*div1_binding*/ ctx[32](div1); 2081 current = true; 2082 2083 if (!mounted) { 2084 dispose = action_destroyer(copy.call(null, div0)); 2085 mounted = true; 2086 } 2087 }, 2088 p(ctx, dirty) { 2089 if (/*show_share_button*/ ctx[5] && /*value*/ ctx[0] !== null && /*value*/ ctx[0].length > 0) { 2090 if (if_block0) { 2091 if_block0.p(ctx, dirty); 2092 2093 if (dirty[0] & /*show_share_button, value*/ 33) { 2094 transition_in$1(if_block0, 1); 2095 } 2096 } else { 2097 if_block0 = create_if_block_12(ctx); 2098 if_block0.c(); 2099 transition_in$1(if_block0, 1); 2100 if_block0.m(t.parentNode, t); 2101 } 2102 } else if (if_block0) { 2103 group_outros$1(); 2104 2105 transition_out$1(if_block0, 1, 1, () => { 2106 if_block0 = null; 2107 }); 2108 2109 check_outros$1(); 2110 } 2111 2112 if (/*value*/ ctx[0] !== null) { 2113 if (if_block1) { 2114 if_block1.p(ctx, dirty); 2115 2116 if (dirty[0] & /*value*/ 1) { 2117 transition_in$1(if_block1, 1); 2118 } 2119 } else { 2120 if_block1 = create_if_block$1(ctx); 2121 if_block1.c(); 2122 transition_in$1(if_block1, 1); 2123 if_block1.m(div0, null); 2124 } 2125 } else if (if_block1) { 2126 group_outros$1(); 2127 2128 transition_out$1(if_block1, 1, 1, () => { 2129 if_block1 = null; 2130 }); 2131 2132 check_outros$1(); 2133 } 2134 2135 if (!current || dirty[0] & /*layout*/ 16384) { 2136 toggle_class(div0, "bubble-gap", /*layout*/ ctx[14] === "bubble"); 2137 } 2138 2139 if (!current || dirty[0] & /*layout*/ 16384 && div1_class_value !== (div1_class_value = "" + (null_to_empty(/*layout*/ ctx[14] === "bubble" 2140 ? "bubble-wrap" 2141 : "panel-wrap") + " svelte-1lcyrx4"))) { 2142 attr$1(div1, "class", div1_class_value); 2143 } 2144 }, 2145 i(local) { 2146 if (current) return; 2147 transition_in$1(if_block0); 2148 transition_in$1(if_block1); 2149 current = true; 2150 }, 2151 o(local) { 2152 transition_out$1(if_block0); 2153 transition_out$1(if_block1); 2154 current = false; 2155 }, 2156 d(detaching) { 2157 if (detaching) { 2158 detach$1(t); 2159 detach$1(div1); 2160 } 2161 2162 if (if_block0) if_block0.d(detaching); 2163 if (if_block1) if_block1.d(); 2164 /*div1_binding*/ ctx[32](null);
2165 mounted = false; 2166 dispose(); 2167 } 2168 }; 2169} 2170 2171function instance$1($$self, $$props, $$invalidate) { 2172 let adjust_text_size; 2173 let { value } = $$props; 2174 let old_value = null; 2175 let { latex_delimiters } = $$props; 2176 let { pending_message = false } = $$props; 2177 let { selectable = false } = $$props; 2178 let { likeable = false } = $$props; 2179 let { show_share_button = false } = $$props; 2180 let { rtl = false } = $$props; 2181 let { show_copy_button = false } = $$props; 2182 let { avatar_images = [null, null] } = $$props; 2183 let { sanitize_html = true } = $$props; 2184 let { bubble_full_width = true } = $$props; 2185 let { render_markdown = true } = $$props; 2186 let { line_breaks = true } = $$props; 2187 let { i18n } = $$props; 2188 let { layout = "bubble" } = $$props; 2189 let div; 2190 let autoscroll; 2191 const dispatch = createEventDispatcher(); 2192 2193 beforeUpdate(() => { 2194 autoscroll = div && div.offsetHeight + div.scrollTop > div.scrollHeight - 100; 2195 }); 2196 2197 const scroll = () => { 2198 if (autoscroll) { 2199 div.scrollTo(0, div.scrollHeight); 2200 } 2201 }; 2202 2203 afterUpdate(() => { 2204 if (autoscroll) { 2205 scroll(); 2206 2207 div.querySelectorAll("img").forEach(n => { 2208 n.addEventListener("load", () => { 2209 scroll(); 2210 }); 2211 }); 2212 } 2213 }); 2214 2215 function handle_select(i, j, message) { 2216 dispatch("select", { index: [i, j], value: message }); 2217 } 2218 2219 function handle_like(i, j, message, selected) { 2220 dispatch("like", { 2221 index: [i, j], 2222 value: message, 2223 liked: selected === "like" 2224 }); 2225 } 2226 2227 function error_handler(event) { 2228 bubble.call(this, $$self, event); 2229 } 2230 2231 function share_handler(event) { 2232 bubble.call(this, $$self, event); 2233 } 2234 2235 function play_handler(event) { 2236 bubble.call(this, $$self, event); 2237 } 2238 2239 function pause_handler(event) { 2240 bubble.call(this, $$self, event); 2241 } 2242 2243 function ended_handler(event) { 2244 bubble.call(this, $$self, event); 2245 } 2246 2247 function play_handler_1(event) { 2248 bubble.call(this, $$self, event); 2249 } 2250 2251 function pause_handler_1(event) { 2252 bubble.call(this, $$self, event); 2253 } 2254 2255 function ended_handler_1(event) { 2256 bubble.call(this, $$self, event); 2257 } 2258 2259 const click_handler = (i, j, message) => handle_select(i, j, message); 2260 2261 const keydown_handler = (i, j, message, e) => { 2262 if (e.key === "Enter") { 2263 handle_select(i, j, message); 2264 } 2265 }; 2266 2267 const func = (i, j, message, selected) => handle_like(i, j, message, selected); 2268 2269 function div1_binding($$value) { 2270 binding_callbacks[$$value ? 'unshift' : 'push'](() => { 2271 div = $$value; 2272 $$invalidate(15, div); 2273 }); 2274 } 2275 2276 $$self.$$set = $$props => {
2277 if ('value' in $$props) $$invalidate(0, value = $$props.value); 2278 if ('latex_delimiters' in $$props) $$invalidate(1, latex_delimiters = $$props.latex_delimiters); 2279 if ('pending_message' in $$props) $$invalidate(2, pending_message = $$props.pending_message); 2280 if ('selectable' in $$props) $$invalidate(3, selectable = $$props.selectable); 2281 if ('likeable' in $$props) $$invalidate(4, likeable = $$props.likeable); 2282 if ('show_share_button' in $$props) $$invalidate(5, show_share_button = $$props.show_share_button); 2283 if ('rtl' in $$props) $$invalidate(6, rtl = $$props.rtl); 2284 if ('show_copy_button' in $$props) $$invalidate(7, show_copy_button = $$props.show_copy_button); 2285 if ('avatar_images' in $$props) $$invalidate(8, avatar_images = $$props.avatar_images); 2286 if ('sanitize_html' in $$props) $$invalidate(9, sanitize_html = $$props.sanitize_html); 2287 if ('bubble_full_width' in $$props) $$invalidate(10, bubble_full_width = $$props.bubble_full_width); 2288 if ('render_markdown' in $$props) $$invalidate(11, render_markdown = $$props.render_markdown);
2289 if ('line_breaks' in $$props) $$invalidate(12, line_breaks = $$props.line_breaks); 2290 if ('i18n' in $$props) $$invalidate(13, i18n = $$props.i18n); 2291 if ('layout' in $$props) $$invalidate(14, layout = $$props.layout); 2292 }; 2293 2294 $$self.$$.update = () => { 2295 if ($$self.$$.dirty[0] & /*adjust_text_size*/ 1048576) { 2296 adjust_text_size(); 2297 } 2298 2299 if ($$self.$$.dirty[0] & /*value, old_value*/ 524289) { 2300 { 2301 if (!dequal(value, old_value)) { 2302 $$invalidate(19, old_value = value); 2303 dispatch("change"); 2304 } 2305 } 2306 } 2307 }; 2308 2309 $$invalidate(20, adjust_text_size = () => { 2310 let style = getComputedStyle(document.body); 2311 let body_text_size = style.getPropertyValue("--body-text-size"); 2312 let updated_text_size; 2313 2314 switch (body_text_size) { 2315 case "13px": 2316 updated_text_size = 14; 2317 break; 2318 case "14px": 2319 updated_text_size = 16; 2320 break; 2321 case "16px": 2322 updated_text_size = 20; 2323 break; 2324 default: 2325 updated_text_size = 14; 2326 break; 2327 } 2328 2329 document.body.style.setProperty("--chatbot-body-text-size", updated_text_size + "px"); 2330 }); 2331 2332 return [ 2333 value, 2334 latex_delimiters, 2335 pending_message, 2336 selectable, 2337 likeable, 2338 show_share_button, 2339 rtl, 2340 show_copy_button, 2341 avatar_images, 2342 sanitize_html, 2343 bubble_full_width, 2344 render_markdown, 2345 line_breaks, 2346 i18n, 2347 layout, 2348 div, 2349 scroll, 2350 handle_select, 2351 handle_like, 2352 old_value, 2353 adjust_text_size, 2354 error_handler, 2355 share_handler, 2356 play_handler, 2357 pause_handler, 2358 ended_handler, 2359 play_handler_1, 2360 pause_handler_1, 2361 ended_handler_1, 2362 click_handler, 2363 keydown_handler, 2364 func, 2365 div1_binding 2366 ]; 2367} 2368 2369class ChatBot extends SvelteComponent$1 { 2370 constructor(options) { 2371 super(); 2372 2373 init$1( 2374 this, 2375 options, 2376 instance$1, 2377 create_fragment$1, 2378 safe_not_equal$1, 2379 { 2380 value: 0, 2381 latex_delimiters: 1, 2382 pending_message: 2, 2383 selectable: 3, 2384 likeable: 4, 2385 show_share_button: 5, 2386 rtl: 6, 2387 show_copy_button: 7, 2388 avatar_images: 8, 2389 sanitize_html: 9, 2390 bubble_full_width: 10, 2391 render_markdown: 11, 2392 line_breaks: 12, 2393 i18n: 13, 2394 layout: 14 2395 }, 2396 null, 2397 [-1, -1] 2398 ); 2399 } 2400} 2401 2402const ChatBot$1 = ChatBot; 2403 2404const Index_svelte_svelte_type_style_lang = ''; 2405 2406/* home/runner/work/gradio/gradio/js/chatbot/Index.svelte generated by Svelte v4.2.2 */ 2407const { 2408 SvelteComponent, 2409 append, 2410 assign, 2411 attr, 2412 check_outros, 2413 create_component, 2414 destroy_component, 2415 detach, 2416 element, 2417 get_spread_object, 2418 get_spread_update, 2419 group_outros, 2420 init, 2421 insert, 2422 mount_component, 2423 safe_not_equal, 2424 space, 2425 transition_in, 2426 transition_out 2427} = window.__gradio__svelte__internal; 2428function create_if_block_1(ctx) { 2429 let statustracker; 2430 let current; 2431 2432 const statustracker_spread_levels = [ 2433 { 2434 autoscroll: /*gradio*/ ctx[19].autoscroll 2435 }, 2436 { i18n: /*gradio*/ ctx[19].i18n }, 2437 /*loading_status*/ ctx[21], 2438 { 2439 show_progress: /*loading_status*/ ctx[21].show_progress === "hidden" 2440 ? "hidden" 2441 : "minimal" 2442 } 2443 ]; 2444 2445 let statustracker_props = {}; 2446 2447 for (let i = 0; i < statustracker_spread_levels.length; i += 1) { 2448 statustracker_props = assign(statustracker_props, statustracker_spread_levels[i]); 2449 } 2450 2451 statustracker = new Static({ props: statustracker_props }); 2452 2453 return { 2454 c() { 2455 create_component(statustracker.$$.fragment); 2456 }, 2457 m(target, anchor) { 2458 mount_component(statustracker, target, anchor); 2459 current = true; 2460 }, 2461 p(ctx, dirty) { 2462 const statustracker_changes = (dirty[0] & /*gradio, loading_status*/ 2621440) 2463 ? get_spread_update(statustracker_spread_levels, [ 2464 dirty[0] & /*gradio*/ 524288 && { 2465 autoscroll: /*gradio*/ ctx[19].autoscroll 2466 }, 2467 dirty[0] & /*gradio*/ 524288 && { i18n: /*gradio*/ ctx[19].i18n }, 2468 dirty[0] & /*loading_status*/ 2097152 && get_spread_object(/*loading_status*/ ctx[21]), 2469 dirty[0] & /*loading_status*/ 2097152 && { 2470 show_progress: /*loading_status*/ ctx[21].show_progress === "hidden" 2471 ? "hidden" 2472 : "minimal" 2473 } 2474 ]) 2475 : {}; 2476 2477 statustracker.$set(statustracker_changes); 2478 }, 2479 i(local) { 2480 if (current) return; 2481 transition_in(statustracker.$$.fragment, local); 2482 current = true; 2483 }, 2484 o(local) { 2485 transition_out(statustracker.$$.fragment, local); 2486 current = false;
2487 }, 2488 d(detaching) { 2489 destroy_component(statustracker, detaching); 2490 } 2491 }; 2492} 2493 2494// (76:2) {#if show_label} 2495function create_if_block(ctx) { 2496 let blocklabel; 2497 let current; 2498 2499 blocklabel = new BlockLabel({ 2500 props: { 2501 show_label: /*show_label*/ ctx[7], 2502 Icon: Chat, 2503 float: false, 2504 label: /*label*/ ctx[6] || "Chatbot" 2505 } 2506 }); 2507 2508 return { 2509 c() { 2510 create_component(blocklabel.$$.fragment); 2511 }, 2512 m(target, anchor) { 2513 mount_component(blocklabel, target, anchor); 2514 current = true; 2515 }, 2516 p(ctx, dirty) { 2517 const blocklabel_changes = {}; 2518 if (dirty[0] & /*show_label*/ 128) blocklabel_changes.show_label = /*show_label*/ ctx[7]; 2519 if (dirty[0] & /*label*/ 64) blocklabel_changes.label = /*label*/ ctx[6] || "Chatbot"; 2520 blocklabel.$set(blocklabel_changes); 2521 }, 2522 i(local) { 2523 if (current) return; 2524 transition_in(blocklabel.$$.fragment, local); 2525 current = true; 2526 }, 2527 o(local) { 2528 transition_out(blocklabel.$$.fragment, local); 2529 current = false; 2530 }, 2531 d(detaching) { 2532 destroy_component(blocklabel, detaching); 2533 } 2534 }; 2535} 2536 2537// (55:0) <Block {elem_id} {elem_classes} {visible} padding={false} {scale} {min_width} {height} allow_overflow={false} > 2538function create_default_slot(ctx) { 2539 let t0; 2540 let div; 2541 let t1; 2542 let chatbot; 2543 let current; 2544 let if_block0 = /*loading_status*/ ctx[21] && create_if_block_1(ctx); 2545 let if_block1 = /*show_label*/ ctx[7] && create_if_block(ctx); 2546 2547 chatbot = new ChatBot$1({ 2548 props: { 2549 i18n: /*gradio*/ ctx[19].i18n, 2550 selectable: /*_selectable*/ ctx[8], 2551 likeable: /*likeable*/ ctx[9], 2552 show_share_button: /*show_share_button*/ ctx[10], 2553 value: /*_value*/ ctx[23], 2554 latex_delimiters: /*latex_delimiters*/ ctx[18], 2555 render_markdown: /*render_markdown*/ ctx[16], 2556 pending_message: /*loading_status*/ ctx[21]?.status === "pending", 2557 rtl: /*rtl*/ ctx[11], 2558 show_copy_button: /*show_copy_button*/ ctx[12], 2559 avatar_images: /*avatar_images*/ ctx[20], 2560 sanitize_html: /*sanitize_html*/ ctx[13], 2561 bubble_full_width: /*bubble_full_width*/ ctx[14], 2562 line_breaks: /*line_breaks*/ ctx[17], 2563 layout: /*layout*/ ctx[15] 2564 } 2565 }); 2566 2567 chatbot.$on("change", /*change_handler*/ ctx[25]); 2568 chatbot.$on("select", /*select_handler*/ ctx[26]); 2569 chatbot.$on("like", /*like_handler*/ ctx[27]); 2570 chatbot.$on("share", /*share_handler*/ ctx[28]); 2571 chatbot.$on("error", /*error_handler*/ ctx[29]); 2572 2573 return { 2574 c() { 2575 if (if_block0) if_block0.c(); 2576 t0 = space(); 2577 div = element("div"); 2578 if (if_block1) if_block1.c(); 2579 t1 = space(); 2580 create_component(chatbot.$$.fragment); 2581 attr(div, "class", "wrapper svelte-nab2ao"); 2582 }, 2583 m(target, anchor) { 2584 if (if_block0) if_block0.m(target, anchor); 2585 insert(target, t0, anchor); 2586 insert(target, div, anchor); 2587 if (if_block1) if_block1.m(div, null); 2588 append(div, t1);
2589 mount_component(chatbot, div, null); 2590 current = true; 2591 }, 2592 p(ctx, dirty) { 2593 if (/*loading_status*/ ctx[21]) { 2594 if (if_block0) { 2595 if_block0.p(ctx, dirty); 2596 2597 if (dirty[0] & /*loading_status*/ 2097152) { 2598 transition_in(if_block0, 1); 2599 } 2600 } else { 2601 if_block0 = create_if_block_1(ctx); 2602 if_block0.c(); 2603 transition_in(if_block0, 1); 2604 if_block0.m(t0.parentNode, t0); 2605 } 2606 } else if (if_block0) { 2607 group_outros(); 2608 2609 transition_out(if_block0, 1, 1, () => { 2610 if_block0 = null; 2611 }); 2612 2613 check_outros(); 2614 } 2615 2616 if (/*show_label*/ ctx[7]) { 2617 if (if_block1) { 2618 if_block1.p(ctx, dirty); 2619 2620 if (dirty[0] & /*show_label*/ 128) { 2621 transition_in(if_block1, 1); 2622 } 2623 } else { 2624 if_block1 = create_if_block(ctx); 2625 if_block1.c(); 2626 transition_in(if_block1, 1); 2627 if_block1.m(div, t1); 2628 } 2629 } else if (if_block1) { 2630 group_outros(); 2631 2632 transition_out(if_block1, 1, 1, () => { 2633 if_block1 = null; 2634 }); 2635 2636 check_outros(); 2637 } 2638 2639 const chatbot_changes = {}; 2640 if (dirty[0] & /*gradio*/ 524288) chatbot_changes.i18n = /*gradio*/ ctx[19].i18n; 2641 if (dirty[0] & /*_selectable*/ 256) chatbot_changes.selectable = /*_selectable*/ ctx[8]; 2642 if (dirty[0] & /*likeable*/ 512) chatbot_changes.likeable = /*likeable*/ ctx[9]; 2643 if (dirty[0] & /*show_share_button*/ 1024) chatbot_changes.show_share_button = /*show_share_button*/ ctx[10]; 2644 if (dirty[0] & /*_value*/ 8388608) chatbot_changes.value = /*_value*/ ctx[23]; 2645 if (dirty[0] & /*latex_delimiters*/ 262144) chatbot_changes.latex_delimiters = /*latex_delimiters*/ ctx[18]; 2646 if (dirty[0] & /*render_markdown*/ 65536) chatbot_changes.render_markdown = /*render_markdown*/ ctx[16]; 2647 if (dirty[0] & /*loading_status*/ 2097152) chatbot_changes.pending_message = /*loading_status*/ ctx[21]?.status === "pending"; 2648 if (dirty[0] & /*rtl*/ 2048) chatbot_changes.rtl = /*rtl*/ ctx[11]; 2649 if (dirty[0] & /*show_copy_button*/ 4096) chatbot_changes.show_copy_button = /*show_copy_button*/ ctx[12]; 2650 if (dirty[0] & /*avatar_images*/ 1048576) chatbot_changes.avatar_images = /*avatar_images*/ ctx[20]; 2651 if (dirty[0] & /*sanitize_html*/ 8192) chatbot_changes.sanitize_html = /*sanitize_html*/ ctx[13]; 2652 if (dirty[0] & /*bubble_full_width*/ 16384) chatbot_changes.bubble_full_width = /*bubble_full_width*/ ctx[14]; 2653 if (dirty[0] & /*line_breaks*/ 131072) chatbot_changes.line_breaks = /*line_breaks*/ ctx[17]; 2654 if (dirty[0] & /*layout*/ 32768) chatbot_changes.layout = /*layout*/ ctx[15]; 2655 chatbot.$set(chatbot_changes); 2656 }, 2657 i(local) { 2658 if (current) return; 2659 transition_in(if_block0); 2660 transition_in(if_block1); 2661 transition_in(chatbot.$$.fragment, local); 2662 current = true; 2663 }, 2664 o(local) { 2665 transition_out(if_block0); 2666 transition_out(if_block1); 2667 transition_out(chatbot.$$.fragment, local); 2668 current = false; 2669 }, 2670 d(detaching) { 2671 if (detaching) { 2672 detach(t0); 2673 detach(div); 2674 } 2675 2676 if (if_block0) if_block0.d(detaching); 2677 if (if_block1) if_block1.d(); 2678 destroy_component(chatbot); 2679 } 2680 }; 2681} 2682 2683function create_fragment(ctx) { 2684 let block; 2685 let current; 2686 2687 block = new Block({ 2688 props: { 2689 elem_id: /*elem_id*/ ctx[0], 2690 elem_classes: /*elem_classes*/ ctx[1], 2691 visible: /*visible*/ ctx[2], 2692 padding: false, 2693 scale: /*scale*/ ctx[4], 2694 min_width: /*min_width*/ ctx[5], 2695 height: /*height*/ ctx[22], 2696 allow_overflow: false, 2697 $$slots: { default: [create_default_slot] }, 2698 $$scope: { ctx } 2699 } 2700 }); 2701 2702 return { 2703 c() { 2704 create_component(block.$$.fragment); 2705 }, 2706 m(target, anchor) { 2707 mount_component(block, target, anchor); 2708 current = true; 2709 }, 2710 p(ctx, dirty) { 2711 const block_changes = {}; 2712 if (dirty[0] & /*elem_id*/ 1) block_changes.elem_id = /*elem_id*/ ctx[0]; 2713 if (dirty[0] & /*elem_classes*/ 2) block_changes.elem_classes = /*elem_classes*/ ctx[1]; 2714 if (dirty[0] & /*visible*/ 4) block_changes.visible = /*visible*/ ctx[2]; 2715 if (dirty[0] & /*scale*/ 16) block_changes.scale = /*scale*/ ctx[4]; 2716 if (dirty[0] & /*min_width*/ 32) block_changes.min_width = /*min_width*/ ctx[5];
2717 if (dirty[0] & /*height*/ 4194304) block_changes.height = /*height*/ ctx[22]; 2718 2719 if (dirty[0] & /*gradio, _selectable, likeable, show_share_button, _value, latex_delimiters, render_markdown, loading_status, rtl, show_copy_button, avatar_images, sanitize_html, bubble_full_width, line_breaks, layout, value, show_label, label*/ 12582856 | dirty[1] & /*$$scope*/ 1) { 2720 block_changes.$$scope = { dirty, ctx }; 2721 } 2722 2723 block.$set(block_changes); 2724 }, 2725 i(local) { 2726 if (current) return; 2727 transition_in(block.$$.fragment, local); 2728 current = true; 2729 }, 2730 o(local) { 2731 transition_out(block.$$.fragment, local); 2732 current = false; 2733 }, 2734 d(detaching) { 2735 destroy_component(block, detaching); 2736 } 2737 }; 2738} 2739 2740function normalize_messages(message) { 2741 if (message === null) { 2742 return message; 2743 } 2744 2745 return { 2746 file: message?.file, 2747 alt_text: message?.alt_text 2748 }; 2749} 2750 2751function instance($$self, $$props, $$invalidate) { 2752 let { elem_id = "" } = $$props; 2753 let { elem_classes = [] } = $$props; 2754 let { visible = true } = $$props; 2755 let { value = [] } = $$props; 2756 let { scale = null } = $$props; 2757 let { min_width = undefined } = $$props; 2758 let { label } = $$props; 2759 let { show_label = true } = $$props; 2760 let { root } = $$props; 2761 let { _selectable = false } = $$props; 2762 let { likeable = false } = $$props; 2763 let { show_share_button = false } = $$props; 2764 let { rtl = false } = $$props; 2765 let { show_copy_button = false } = $$props; 2766 let { sanitize_html = true } = $$props; 2767 let { bubble_full_width = true } = $$props; 2768 let { layout = "bubble" } = $$props; 2769 let { render_markdown = true } = $$props; 2770 let { line_breaks = true } = $$props; 2771 let { latex_delimiters } = $$props; 2772 let { gradio } = $$props; 2773 let { avatar_images = [null, null] } = $$props; 2774 let _value; 2775 const redirect_src_url = src => src.replace('src="/file', `src="${root}file`); 2776 let { loading_status = undefined } = $$props; 2777 let { height = 400 } = $$props; 2778 const change_handler = () => gradio.dispatch("change", value); 2779 const select_handler = e => gradio.dispatch("select", e.detail); 2780 const like_handler = e => gradio.dispatch("like", e.detail); 2781 const share_handler = e => gradio.dispatch("share", e.detail); 2782 const error_handler = e => gradio.dispatch("error", e.detail); 2783 2784 $$self.$$set = $$props => {
2785 if ('elem_id' in $$props) $$invalidate(0, elem_id = $$props.elem_id); 2786 if ('elem_classes' in $$props) $$invalidate(1, elem_classes = $$props.elem_classes); 2787 if ('visible' in $$props) $$invalidate(2, visible = $$props.visible); 2788 if ('value' in $$props) $$invalidate(3, value = $$props.value); 2789 if ('scale' in $$props) $$invalidate(4, scale = $$props.scale); 2790 if ('min_width' in $$props) $$invalidate(5, min_width = $$props.min_width); 2791 if ('label' in $$props) $$invalidate(6, label = $$props.label); 2792 if ('show_label' in $$props) $$invalidate(7, show_label = $$props.show_label); 2793 if ('root' in $$props) $$invalidate(24, root = $$props.root); 2794 if ('_selectable' in $$props) $$invalidate(8, _selectable = $$props._selectable); 2795 if ('likeable' in $$props) $$invalidate(9, likeable = $$props.likeable); 2796 if ('show_share_button' in $$props) $$invalidate(10, show_share_button = $$props.show_share_button); 2797 if ('rtl' in $$props) $$invalidate(11, rtl = $$props.rtl); 2798 if ('show_copy_button' in $$props) $$invalidate(12, show_copy_button = $$props.show_copy_button);
2799 if ('sanitize_html' in $$props) $$invalidate(13, sanitize_html = $$props.sanitize_html); 2800 if ('bubble_full_width' in $$props) $$invalidate(14, bubble_full_width = $$props.bubble_full_width); 2801 if ('layout' in $$props) $$invalidate(15, layout = $$props.layout); 2802 if ('render_markdown' in $$props) $$invalidate(16, render_markdown = $$props.render_markdown); 2803 if ('line_breaks' in $$props) $$invalidate(17, line_breaks = $$props.line_breaks); 2804 if ('latex_delimiters' in $$props) $$invalidate(18, latex_delimiters = $$props.latex_delimiters); 2805 if ('gradio' in $$props) $$invalidate(19, gradio = $$props.gradio); 2806 if ('avatar_images' in $$props) $$invalidate(20, avatar_images = $$props.avatar_images); 2807 if ('loading_status' in $$props) $$invalidate(21, loading_status = $$props.loading_status); 2808 if ('height' in $$props) $$invalidate(22, height = $$props.height); 2809 }; 2810 2811 $$self.$$.update = () => { 2812 if ($$self.$$.dirty[0] & /*value*/ 8) { 2813 $$invalidate(23, _value = value 2814 ? value.map(([user_msg, bot_msg]) => [ 2815 typeof user_msg === "string" 2816 ? redirect_src_url(user_msg) 2817 : normalize_messages(user_msg), 2818 typeof bot_msg === "string" 2819 ? redirect_src_url(bot_msg) 2820 : normalize_messages(bot_msg) 2821 ]) 2822 : []); 2823 } 2824 }; 2825 2826 return [ 2827 elem_id, 2828 elem_classes, 2829 visible, 2830 value, 2831 scale, 2832 min_width, 2833 label, 2834 show_label, 2835 _selectable, 2836 likeable, 2837 show_share_button, 2838 rtl, 2839 show_copy_button, 2840 sanitize_html, 2841 bubble_full_width, 2842 layout, 2843 render_markdown, 2844 line_breaks, 2845 latex_delimiters, 2846 gradio, 2847 avatar_images, 2848 loading_status, 2849 height, 2850 _value, 2851 root, 2852 change_handler, 2853 select_handler, 2854 like_handler, 2855 share_handler, 2856 error_handler 2857 ]; 2858} 2859 2860class Index extends SvelteComponent { 2861 constructor(options) { 2862 super(); 2863 2864 init( 2865 this, 2866 options, 2867 instance, 2868 create_fragment, 2869 safe_not_equal, 2870 { 2871 elem_id: 0, 2872 elem_classes: 1, 2873 visible: 2, 2874 value: 3, 2875 scale: 4, 2876 min_width: 5, 2877 label: 6, 2878 show_label: 7, 2879 root: 24, 2880 _selectable: 8, 2881 likeable: 9, 2882 show_share_button: 10, 2883 rtl: 11, 2884 show_copy_button: 12, 2885 sanitize_html: 13, 2886 bubble_full_width: 14, 2887 layout: 15, 2888 render_markdown: 16, 2889 line_breaks: 17, 2890 latex_delimiters: 18, 2891 gradio: 19, 2892 avatar_images: 20, 2893 loading_status: 21, 2894 height: 22 2895 }, 2896 null, 2897 [-1, -1] 2898 ); 2899 } 2900} 2901 2902export { ChatBot$1 as BaseChatBot, Index as default }; 2903//# sourceMappingURL=Index-ba50e4bd.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.