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