1import { S as Static } from './Index-7fdff9d2.js'; 2import { F as File } from './File-e96cd7d6.js'; 3import { B as Block } from './Button-bd009e9a.js'; 4import { B as BlockLabel } from './BlockLabel-5d99d786.js'; 5import './index-10ead756.js'; 6import './svelte/svelte.js'; 7 8/* home/runner/work/gradio/gradio/js/fileexplorer/shared/ArrowIcon.svelte generated by Svelte v4.2.2 */ 9const { 10 SvelteComponent: SvelteComponent$4, 11 append: append$1, 12 attr: attr$3, 13 detach: detach$4, 14 init: init$4, 15 insert: insert$4, 16 noop: noop$3, 17 safe_not_equal: safe_not_equal$4, 18 set_style, 19 svg_element 20} = window.__gradio__svelte__internal; 21function create_fragment$4(ctx) { 22 let svg; 23 let g; 24 let path; 25 26 return { 27 c() { 28 svg = svg_element("svg"); 29 g = svg_element("g"); 30 path = svg_element("path"); 31 attr$3(path, "d", "M12.7,24.033C12.256,24.322 11.806,24.339 11.351,24.084C10.896,23.829 10.668,23.434 10.667,22.9L10.667,9.1C10.667,8.567 10.895,8.172 11.351,7.916C11.807,7.66 12.256,7.677 12.7,7.967L23.567,14.867C23.967,15.133 24.167,15.511 24.167,16C24.167,16.489 23.967,16.867 23.567,17.133L12.7,24.033Z"); 32 set_style(path, "fill", "currentColor"); 33 set_style(path, "fill-rule", "nonzero"); 34 attr$3(g, "transform", "matrix(1,0,0,1,-10.6667,-7.73588)"); 35 attr$3(svg, "width", "100%"); 36 attr$3(svg, "height", "100%"); 37 attr$3(svg, "viewBox", "0 0 14 17"); 38 attr$3(svg, "version", "1.1"); 39 set_style(svg, "fill-rule", "evenodd"); 40 set_style(svg, "clip-rule", "evenodd"); 41 set_style(svg, "stroke-linejoin", "round"); 42 set_style(svg, "stroke-miterlimit", "2"); 43 }, 44 m(target, anchor) { 45 insert$4(target, svg, anchor); 46 append$1(svg, g); 47 append$1(g, path); 48 }, 49 p: noop$3, 50 i: noop$3, 51 o: noop$3, 52 d(detaching) { 53 if (detaching) { 54 detach$4(svg); 55 } 56 } 57 }; 58} 59 60class ArrowIcon extends SvelteComponent$4 { 61 constructor(options) { 62 super(); 63 init$4(this, options, null, create_fragment$4, safe_not_equal$4, {}); 64 } 65} 66 67const Checkbox_svelte_svelte_type_style_lang = ''; 68 69/* home/runner/work/gradio/gradio/js/fileexplorer/shared/Checkbox.svelte generated by Svelte v4.2.2 */ 70const { 71 SvelteComponent: SvelteComponent$3, 72 attr: attr$2, 73 detach: detach$3, 74 element: element$2, 75 init: init$3, 76 insert: insert$3, 77 listen: listen$1, 78 noop: noop$2, 79 run_all: run_all$1, 80 safe_not_equal: safe_not_equal$3, 81 toggle_class: toggle_class$1 82} = window.__gradio__svelte__internal; 83const { createEventDispatcher: createEventDispatcher$1 } = window.__gradio__svelte__internal; 84function create_fragment$3(ctx) { 85 let input; 86 let mounted; 87 let dispose; 88 89 return { 90 c() { 91 input = element$2("input"); 92 attr$2(input, "type", "checkbox"); 93 input.disabled = /*disabled*/ ctx[1]; 94 attr$2(input, "class", "svelte-1j130g3"); 95 toggle_class$1(input, "disabled", /*disabled*/ ctx[1] && !/*value*/ ctx[0]); 96 }, 97 m(target, anchor) { 98 insert$3(target, input, anchor); 99 input.checked = /*value*/ ctx[0]; 100 101 if (!mounted) { 102 dispose = [ 103 listen$1(input, "change", /*input_change_handler*/ ctx[3]), 104 listen$1(input, "input", /*input_handler*/ ctx[4]) 105 ]; 106 107 mounted = true; 108 } 109 }, 110 p(ctx, [dirty]) { 111 if (dirty & /*disabled*/ 2) { 112 input.disabled = /*disabled*/ ctx[1]; 113 } 114 115 if (dirty & /*value*/ 1) { 116 input.checked = /*value*/ ctx[0]; 117 } 118 119 if (dirty & /*disabled, value*/ 3) { 120 toggle_class$1(input, "disabled", /*disabled*/ ctx[1] && !/*value*/ ctx[0]); 121 } 122 }, 123 i: noop$2, 124 o: noop$2, 125 d(detaching) { 126 if (detaching) { 127 detach$3(input); 128 } 129 130 mounted = false; 131 run_all$1(dispose); 132 } 133 }; 134} 135 136function instance$3($$self, $$props, $$invalidate) { 137 let { value } = $$props; 138 let { disabled } = $$props; 139 const dispatch = createEventDispatcher$1(); 140 141 function input_change_handler() { 142 value = this.checked; 143 $$invalidate(0, value); 144 } 145 146 const input_handler = () => dispatch("change", !value); 147 148 $$self.$$set = $$props => {
149 if ('value' in $$props) $$invalidate(0, value = $$props.value); 150 if ('disabled' in $$props) $$invalidate(1, disabled = $$props.disabled); 151 }; 152 153 return [value, disabled, dispatch, input_change_handler, input_handler]; 154} 155 156class Checkbox extends SvelteComponent$3 { 157 constructor(options) { 158 super(); 159 init$3(this, options, instance$3, create_fragment$3, safe_not_equal$3, { value: 0, disabled: 1 }); 160 } 161} 162 163const FileIcon = ""+new URL('light-file-0e72c1e1.svg', import.meta.url).href+""; 164 165const FolderIcon = ""+new URL('light-folder-4e9756c4.svg', import.meta.url).href+""; 166 167const FileTree_svelte_svelte_type_style_lang = ''; 168 169/* home/runner/work/gradio/gradio/js/fileexplorer/shared/FileTree.svelte generated by Svelte v4.2.2 */ 170const { 171 SvelteComponent: SvelteComponent$2, 172 append, 173 attr: attr$1, 174 bubble, 175 check_outros: check_outros$1, 176 create_component: create_component$2, 177 destroy_component: destroy_component$2, 178 destroy_each, 179 detach: detach$2, 180 element: element$1, 181 ensure_array_like, 182 group_outros: group_outros$1, 183 init: init$2, 184 insert: insert$2, 185 listen, 186 mount_component: mount_component$2, 187 noop: noop$1, 188 run_all, 189 safe_not_equal: safe_not_equal$2, 190 set_data, 191 space: space$1, 192 src_url_equal, 193 stop_propagation, 194 text, 195 toggle_class, 196 transition_in: transition_in$2, 197 transition_out: transition_out$2 198} = window.__gradio__svelte__internal; 199const { createEventDispatcher } = window.__gradio__svelte__internal; 200function get_each_context(ctx, list, i) { 201 const child_ctx = ctx.slice(); 202 child_ctx[21] = list[i].type; 203 child_ctx[22] = list[i].name; 204 child_ctx[23] = list[i].valid; 205 child_ctx[25] = i; 206 return child_ctx; 207} 208 209// (90:4) {:else} 210function create_else_block(ctx) { 211 let span; 212 let img; 213 let img_src_value; 214 215 return { 216 c() { 217 span = element$1("span"); 218 img = element$1("img"); 219 if (!src_url_equal(img.src, img_src_value = /*name*/ ctx[22] === "." ? FolderIcon : FileIcon)) attr$1(img, "src", img_src_value); 220 attr$1(img, "alt", "file icon"); 221 attr$1(img, "class", "svelte-hyugph"); 222 attr$1(span, "class", "file-icon svelte-hyugph"); 223 }, 224 m(target, anchor) { 225 insert$2(target, span, anchor); 226 append(span, img); 227 }, 228 p(ctx, dirty) { 229 if (dirty & /*content*/ 64 && !src_url_equal(img.src, img_src_value = /*name*/ ctx[22] === "." ? FolderIcon : FileIcon)) { 230 attr$1(img, "src", img_src_value); 231 } 232 }, 233 i: noop$1, 234 o: noop$1, 235 d(detaching) { 236 if (detaching) { 237 detach$2(span); 238 } 239 } 240 }; 241} 242 243// (76:4) {#if type === "folder"} 244function create_if_block_1(ctx) { 245 let span; 246 let arrow; 247 let current; 248 let mounted; 249 let dispose; 250 arrow = new ArrowIcon({}); 251 252 function click_handler() { 253 return /*click_handler*/ ctx[15](/*i*/ ctx[25]); 254 } 255 256 function keydown_handler(...args) { 257 return /*keydown_handler*/ ctx[16](/*i*/ ctx[25], ...args); 258 } 259 260 return { 261 c() { 262 span = element$1("span"); 263 create_component$2(arrow.$$.fragment); 264 attr$1(span, "class", "icon svelte-hyugph"); 265 attr$1(span, "role", "button"); 266 attr$1(span, "aria-label", "expand directory"); 267 attr$1(span, "tabindex", "0"); 268 toggle_class(span, "hidden", !/*opened_folders*/ ctx[7].includes(/*i*/ ctx[25])); 269 }, 270 m(target, anchor) { 271 insert$2(target, span, anchor); 272 mount_component$2(arrow, span, null); 273 current = true; 274 275 if (!mounted) { 276 dispose = [ 277 listen(span, "click", stop_propagation(click_handler)), 278 listen(span, "keydown", keydown_handler) 279 ]; 280 281 mounted = true; 282 } 283 }, 284 p(new_ctx, dirty) { 285 ctx = new_ctx; 286 287 if (!current || dirty & /*opened_folders*/ 128) { 288 toggle_class(span, "hidden", !/*opened_folders*/ ctx[7].includes(/*i*/ ctx[25])); 289 } 290 }, 291 i(local) { 292 if (current) return; 293 transition_in$2(arrow.$$.fragment, local); 294 current = true; 295 }, 296 o(local) { 297 transition_out$2(arrow.$$.fragment, local); 298 current = false; 299 }, 300 d(detaching) { 301 if (detaching) { 302 detach$2(span); 303 } 304 305 destroy_component$2(arrow); 306 mounted = false; 307 run_all(dispose); 308 } 309 }; 310} 311 312// (97:3) {#if type === "folder" && opened_folders.includes(i)} 313function create_if_block(ctx) { 314 let filetree; 315 let current; 316 317 function func_1(...args) { 318 return /*func_1*/ ctx[17](/*name*/ ctx[22], ...args); 319 } 320 321 function func_3(...args) { 322 return /*func_3*/ ctx[18](/*name*/ ctx[22], ...args); 323 } 324 325 function func_5(...args) { 326 return /*func_5*/ ctx[19](/*name*/ ctx[22], ...args); 327 } 328 329 filetree = new FileTree({ 330 props: { 331 path: [.../*path*/ ctx[0], /*name*/ ctx[22]], 332 selected_files: /*selected_files*/ ctx[1].filter(func_1).map(func_2), 333 selected_folders: /*selected_folders*/ ctx[2].filter(func_3).map(func_4), 334 is_selected_entirely: /*selected_folders*/ ctx[2].some(func_5), 335 interactive: /*interactive*/ ctx[3], 336 ls_fn: /*ls_fn*/ ctx[4], 337 file_count: /*file_count*/ ctx[5], 338 valid_for_selection: /*valid*/ ctx[23] 339 } 340 }); 341 342 filetree.$on("check", /*check_handler*/ ctx[20]); 343 344 return { 345 c() { 346 create_component$2(filetree.$$.fragment); 347 }, 348 m(target, anchor) { 349 mount_component$2(filetree, target, anchor); 350 current = true; 351 }, 352 p(new_ctx, dirty) { 353 ctx = new_ctx; 354 const filetree_changes = {};
355 if (dirty & /*path, content*/ 65) filetree_changes.path = [.../*path*/ ctx[0], /*name*/ ctx[22]]; 356 if (dirty & /*selected_files, content*/ 66) filetree_changes.selected_files = /*selected_files*/ ctx[1].filter(func_1).map(func_2); 357 if (dirty & /*selected_folders, content*/ 68) filetree_changes.selected_folders = /*selected_folders*/ ctx[2].filter(func_3).map(func_4); 358 if (dirty & /*selected_folders, content*/ 68) filetree_changes.is_selected_entirely = /*selected_folders*/ ctx[2].some(func_5); 359 if (dirty & /*interactive*/ 8) filetree_changes.interactive = /*interactive*/ ctx[3]; 360 if (dirty & /*ls_fn*/ 16) filetree_changes.ls_fn = /*ls_fn*/ ctx[4]; 361 if (dirty & /*file_count*/ 32) filetree_changes.file_count = /*file_count*/ ctx[5]; 362 if (dirty & /*content*/ 64) filetree_changes.valid_for_selection = /*valid*/ ctx[23]; 363 filetree.$set(filetree_changes); 364 }, 365 i(local) { 366 if (current) return; 367 transition_in$2(filetree.$$.fragment, local); 368 current = true; 369 }, 370 o(local) { 371 transition_out$2(filetree.$$.fragment, local); 372 current = false; 373 }, 374 d(detaching) { 375 destroy_component$2(filetree, detaching); 376 } 377 }; 378} 379 380// (54:1) {#each content as { type, name, valid } 381function create_each_block(ctx) { 382 let li; 383 let span; 384 let checkbox; 385 let t0; 386 let current_block_type_index; 387 let if_block0; 388 let t1; 389 let t2_value = /*name*/ ctx[22] + ""; 390 let t2; 391 let t3; 392 let show_if = /*type*/ ctx[21] === "folder" && /*opened_folders*/ ctx[7].includes(/*i*/ ctx[25]); 393 let t4; 394 let current; 395 396 function func(...args) { 397 return /*func*/ ctx[13](/*name*/ ctx[22], ...args); 398 } 399 400 function change_handler(...args) { 401 return /*change_handler*/ ctx[14](/*name*/ ctx[22], /*type*/ ctx[21], /*i*/ ctx[25], ...args); 402 } 403 404 checkbox = new Checkbox({ 405 props: { 406 disabled: !/*interactive*/ ctx[3] || /*type*/ ctx[21] === "folder" && /*file_count*/ ctx[5] === "single", 407 value: (/*type*/ ctx[21] === "file" 408 ? /*selected_files*/ ctx[1] 409 : /*selected_folders*/ ctx[2]).some(func) 410 } 411 }); 412 413 checkbox.$on("change", change_handler); 414 const if_block_creators = [create_if_block_1, create_else_block]; 415 const if_blocks = []; 416 417 function select_block_type(ctx, dirty) { 418 if (/*type*/ ctx[21] === "folder") return 0; 419 return 1; 420 } 421 422 current_block_type_index = select_block_type(ctx); 423 if_block0 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); 424 let if_block1 = show_if && create_if_block(ctx); 425 426 return { 427 c() { 428 li = element$1("li"); 429 span = element$1("span"); 430 create_component$2(checkbox.$$.fragment); 431 t0 = space$1(); 432 if_block0.c(); 433 t1 = space$1(); 434 t2 = text(t2_value); 435 t3 = space$1(); 436 if (if_block1) if_block1.c(); 437 t4 = space$1(); 438 attr$1(span, "class", "wrap svelte-hyugph"); 439 attr$1(li, "class", "svelte-hyugph"); 440 }, 441 m(target, anchor) { 442 insert$2(target, li, anchor); 443 append(li, span); 444 mount_component$2(checkbox, span, null); 445 append(span, t0); 446 if_blocks[current_block_type_index].m(span, null); 447 append(span, t1); 448 append(span, t2); 449 append(li, t3); 450 if (if_block1) if_block1.m(li, null); 451 append(li, t4); 452 current = true; 453 }, 454 p(new_ctx, dirty) { 455 ctx = new_ctx; 456 const checkbox_changes = {}; 457 if (dirty & /*interactive, content, file_count*/ 104) checkbox_changes.disabled = !/*interactive*/ ctx[3] || /*type*/ ctx[21] === "folder" && /*file_count*/ ctx[5] === "single"; 458 459 if (dirty & /*content, selected_files, selected_folders*/ 70) checkbox_changes.value = (/*type*/ ctx[21] === "file" 460 ? /*selected_files*/ ctx[1] 461 : /*selected_folders*/ ctx[2]).some(func); 462 463 checkbox.$set(checkbox_changes); 464 let previous_block_index = current_block_type_index; 465 current_block_type_index = select_block_type(ctx); 466 467 if (current_block_type_index === previous_block_index) { 468 if_blocks[current_block_type_index].p(ctx, dirty); 469 } else { 470 group_outros$1(); 471 472 transition_out$2(if_blocks[previous_block_index], 1, 1, () => { 473 if_blocks[previous_block_index] = null; 474 }); 475 476 check_outros$1(); 477 if_block0 = if_blocks[current_block_type_index]; 478 479 if (!if_block0) { 480 if_block0 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); 481 if_block0.c(); 482 } else { 483 if_block0.p(ctx, dirty); 484 } 485 486 transition_in$2(if_block0, 1); 487 if_block0.m(span, t1); 488 } 489 490 if ((!current || dirty & /*content*/ 64) && t2_value !== (t2_value = /*name*/ ctx[22] + "")) set_data(t2, t2_value);
491 if (dirty & /*content, opened_folders*/ 192) show_if = /*type*/ ctx[21] === "folder" && /*opened_folders*/ ctx[7].includes(/*i*/ ctx[25]); 492 493 if (show_if) { 494 if (if_block1) { 495 if_block1.p(ctx, dirty); 496 497 if (dirty & /*content, opened_folders*/ 192) { 498 transition_in$2(if_block1, 1); 499 } 500 } else { 501 if_block1 = create_if_block(ctx); 502 if_block1.c(); 503 transition_in$2(if_block1, 1); 504 if_block1.m(li, t4); 505 } 506 } else if (if_block1) { 507 group_outros$1(); 508 509 transition_out$2(if_block1, 1, 1, () => { 510 if_block1 = null; 511 }); 512 513 check_outros$1(); 514 } 515 }, 516 i(local) { 517 if (current) return; 518 transition_in$2(checkbox.$$.fragment, local); 519 transition_in$2(if_block0); 520 transition_in$2(if_block1); 521 current = true; 522 }, 523 o(local) { 524 transition_out$2(checkbox.$$.fragment, local); 525 transition_out$2(if_block0); 526 transition_out$2(if_block1); 527 current = false; 528 }, 529 d(detaching) { 530 if (detaching) { 531 detach$2(li); 532 } 533 534 destroy_component$2(checkbox); 535 if_blocks[current_block_type_index].d(); 536 if (if_block1) if_block1.d(); 537 } 538 }; 539} 540 541function create_fragment$2(ctx) { 542 let ul; 543 let current; 544 let each_value = ensure_array_like(/*content*/ ctx[6]); 545 let each_blocks = []; 546 547 for (let i = 0; i < each_value.length; i += 1) { 548 each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i)); 549 } 550 551 const out = i => transition_out$2(each_blocks[i], 1, 1, () => { 552 each_blocks[i] = null; 553 }); 554 555 return { 556 c() { 557 ul = element$1("ul"); 558 559 for (let i = 0; i < each_blocks.length; i += 1) { 560 each_blocks[i].c(); 561 } 562 563 attr$1(ul, "class", "svelte-hyugph"); 564 }, 565 m(target, anchor) { 566 insert$2(target, ul, anchor); 567 568 for (let i = 0; i < each_blocks.length; i += 1) { 569 if (each_blocks[i]) { 570 each_blocks[i].m(ul, null); 571 } 572 } 573 574 current = true; 575 }, 576 p(ctx, [dirty]) { 577 if (dirty & /*path, content, selected_files, selected_folders, interactive, ls_fn, file_count, opened_folders, toggle_open_folder, dispatch, open_folder*/ 2047) { 578 each_value = ensure_array_like(/*content*/ ctx[6]); 579 let i; 580 581 for (i = 0; i < each_value.length; i += 1) { 582 const child_ctx = get_each_context(ctx, each_value, i); 583 584 if (each_blocks[i]) { 585 each_blocks[i].p(child_ctx, dirty); 586 transition_in$2(each_blocks[i], 1); 587 } else { 588 each_blocks[i] = create_each_block(child_ctx); 589 each_blocks[i].c(); 590 transition_in$2(each_blocks[i], 1); 591 each_blocks[i].m(ul, null); 592 } 593 } 594 595 group_outros$1(); 596 597 for (i = each_value.length; i < each_blocks.length; i += 1) { 598 out(i); 599 } 600 601 check_outros$1(); 602 } 603 }, 604 i(local) { 605 if (current) return; 606 607 for (let i = 0; i < each_value.length; i += 1) { 608 transition_in$2(each_blocks[i]); 609 } 610 611 current = true; 612 }, 613 o(local) {
614 each_blocks = each_blocks.filter(Boolean); 615 616 for (let i = 0; i < each_blocks.length; i += 1) { 617 transition_out$2(each_blocks[i]); 618 } 619 620 current = false; 621 }, 622 d(detaching) { 623 if (detaching) { 624 detach$2(ul); 625 } 626 627 destroy_each(each_blocks, detaching); 628 } 629 }; 630} 631 632const func_2 = x => x.slice(1); 633const func_4 = x => x.slice(1); 634 635function instance$2($$self, $$props, $$invalidate) { 636 let { path = [] } = $$props; 637 let { selected_files = [] } = $$props; 638 let { selected_folders = [] } = $$props; 639 let { is_selected_entirely = false } = $$props; 640 let { interactive } = $$props; 641 let { ls_fn } = $$props; 642 let { file_count = "multiple" } = $$props; 643 let { valid_for_selection } = $$props; 644 let content = []; 645 let opened_folders = []; 646 647 const toggle_open_folder = i => { 648 if (opened_folders.includes(i)) { 649 $$invalidate(7, opened_folders = opened_folders.filter(x => x !== i)); 650 } else { 651 $$invalidate(7, opened_folders = [...opened_folders, i]); 652 } 653 }; 654 655 const open_folder = i => { 656 if (!opened_folders.includes(i)) { 657 $$invalidate(7, opened_folders = [...opened_folders, i]); 658 } 659 }; 660 661 (async () => { 662 $$invalidate(6, content = await ls_fn(path)); 663 664 if (valid_for_selection) { 665 $$invalidate(6, content = [{ name: ".", type: "file" }, ...content]); 666 } 667 668 $$invalidate(7, opened_folders = content.map((x, i) => x.type === "folder" && (is_selected_entirely || selected_files.some(y => y[0] === x.name)) 669 ? i 670 : null).filter(x => x !== null)); 671 })(); 672 673 const dispatch = createEventDispatcher(); 674 const func = (name, x) => x[0] === name && x.length === 1; 675 676 const change_handler = (name, type, i, e) => { 677 let checked = e.detail; 678 dispatch("check", { path: [...path, name], checked, type }); 679 680 if (type === "folder" && checked) { 681 open_folder(i); 682 } 683 }; 684 685 const click_handler = i => toggle_open_folder(i); 686 687 const keydown_handler = (i, { key }) => { 688 if (key === " " || key === "Enter") { 689 toggle_open_folder(i); 690 } 691 }; 692 693 const func_1 = (name, x) => x[0] === name; 694 const func_3 = (name, x) => x[0] === name; 695 const func_5 = (name, x) => x[0] === name && x.length === 1; 696 697 function check_handler(event) { 698 bubble.call(this, $$self, event); 699 } 700 701 $$self.$$set = $$props => {
702 if ('path' in $$props) $$invalidate(0, path = $$props.path); 703 if ('selected_files' in $$props) $$invalidate(1, selected_files = $$props.selected_files); 704 if ('selected_folders' in $$props) $$invalidate(2, selected_folders = $$props.selected_folders); 705 if ('is_selected_entirely' in $$props) $$invalidate(11, is_selected_entirely = $$props.is_selected_entirely); 706 if ('interactive' in $$props) $$invalidate(3, interactive = $$props.interactive); 707 if ('ls_fn' in $$props) $$invalidate(4, ls_fn = $$props.ls_fn); 708 if ('file_count' in $$props) $$invalidate(5, file_count = $$props.file_count); 709 if ('valid_for_selection' in $$props) $$invalidate(12, valid_for_selection = $$props.valid_for_selection); 710 }; 711 712 $$self.$$.update = () => { 713 if ($$self.$$.dirty & /*is_selected_entirely, content, path*/ 2113) { 714 if (is_selected_entirely) { 715 content.forEach(x => { 716 dispatch("check", { 717 path: [...path, x.name], 718 checked: true, 719 type: x.type 720 }); 721 }); 722 } 723 } 724 }; 725 726 return [ 727 path, 728 selected_files, 729 selected_folders, 730 interactive, 731 ls_fn, 732 file_count, 733 content, 734 opened_folders, 735 toggle_open_folder, 736 open_folder, 737 dispatch, 738 is_selected_entirely, 739 valid_for_selection, 740 func, 741 change_handler, 742 click_handler, 743 keydown_handler, 744 func_1, 745 func_3, 746 func_5, 747 check_handler 748 ]; 749} 750 751class FileTree extends SvelteComponent$2 { 752 constructor(options) { 753 super(); 754 755 init$2(this, options, instance$2, create_fragment$2, safe_not_equal$2, { 756 path: 0, 757 selected_files: 1, 758 selected_folders: 2, 759 is_selected_entirely: 11, 760 interactive: 3, 761 ls_fn: 4, 762 file_count: 5, 763 valid_for_selection: 12 764 }); 765 } 766} 767 768const DirectoryExplorer_svelte_svelte_type_style_lang = ''; 769 770/* home/runner/work/gradio/gradio/js/fileexplorer/shared/DirectoryExplorer.svelte generated by Svelte v4.2.2 */ 771const { 772 SvelteComponent: SvelteComponent$1, 773 attr, 774 create_component: create_component$1, 775 destroy_component: destroy_component$1, 776 detach: detach$1, 777 element, 778 init: init$1, 779 insert: insert$1, 780 mount_component: mount_component$1, 781 safe_not_equal: safe_not_equal$1, 782 transition_in: transition_in$1, 783 transition_out: transition_out$1 784} = window.__gradio__svelte__internal; 785function create_fragment$1(ctx) { 786 let div; 787 let filetree; 788 let current; 789 790 filetree = new FileTree({ 791 props: { 792 path: [], 793 selected_files: /*value*/ ctx[0], 794 selected_folders: /*selected_folders*/ ctx[4], 795 interactive: /*interactive*/ ctx[1], 796 ls_fn: /*ls_fn*/ ctx[3], 797 file_count: /*file_count*/ ctx[2], 798 valid_for_selection: false 799 } 800 }); 801 802 filetree.$on("check", /*check_handler*/ ctx[8]); 803 804 return { 805 c() { 806 div = element("div"); 807 create_component$1(filetree.$$.fragment); 808 attr(div, "class", "file-wrap svelte-dicskc"); 809 }, 810 m(target, anchor) { 811 insert$1(target, div, anchor); 812 mount_component$1(filetree, div, null); 813 current = true; 814 }, 815 p(ctx, [dirty]) { 816 const filetree_changes = {}; 817 if (dirty & /*value*/ 1) filetree_changes.selected_files = /*value*/ ctx[0]; 818 if (dirty & /*selected_folders*/ 16) filetree_changes.selected_folders = /*selected_folders*/ ctx[4]; 819 if (dirty & /*interactive*/ 2) filetree_changes.interactive = /*interactive*/ ctx[1]; 820 if (dirty & /*ls_fn*/ 8) filetree_changes.ls_fn = /*ls_fn*/ ctx[3]; 821 if (dirty & /*file_count*/ 4) filetree_changes.file_count = /*file_count*/ ctx[2]; 822 filetree.$set(filetree_changes); 823 }, 824 i(local) { 825 if (current) return; 826 transition_in$1(filetree.$$.fragment, local); 827 current = true; 828 }, 829 o(local) { 830 transition_out$1(filetree.$$.fragment, local); 831 current = false; 832 }, 833 d(detaching) { 834 if (detaching) { 835 detach$1(div); 836 } 837 838 destroy_component$1(filetree); 839 } 840 }; 841} 842 843function instance$1($$self, $$props, $$invalidate) { 844 let { interactive } = $$props; 845 let { file_count = "multiple" } = $$props; 846 let { value = [] } = $$props; 847 let { ls_fn } = $$props; 848 let selected_folders = []; 849 850 const paths_equal = (path, path_2) => { 851 return path.join("/") === path_2.join("/"); 852 }; 853 854 const path_in_set = (path, set) => { 855 return set.some(x => paths_equal(x, path)); 856 }; 857 858 const path_inside = (path, path_2) => { 859 return path.join("/").startsWith(path_2.join("/")); 860 }; 861 862 const check_handler = e => { 863 const { path, checked, type }
863 = e.detail; 864 865 if (checked) { 866 if (file_count === "single") { 867 $$invalidate(0, value = [path]); 868 } else if (type === "folder") { 869 if (!path_in_set(path, selected_folders)) { 870 $$invalidate(4, selected_folders = [...selected_folders, path]); 871 } 872 } else { 873 if (!path_in_set(path, value)) { 874 $$invalidate(0, value = [...value, path]); 875 } 876 } 877 } else { 878 $$invalidate(4, selected_folders = selected_folders.filter(folder => !path_inside(path, folder))); // deselect all parent folders 879 880 if (type === "folder") { 881 $$invalidate(4, selected_folders = selected_folders.filter(folder => !path_inside(folder, path))); // deselect all children folders 882 $$invalidate(0, value = value.filter(file => !path_inside(file, path))); // deselect all children files 883 } else { 884 $$invalidate(0, value = value.filter(x => !paths_equal(x, path))); 885 } 886 } 887 }; 888 889 $$self.$$set = $$props => { 890 if ('interactive' in $$props) $$invalidate(1, interactive = $$props.interactive); 891 if ('file_count' in $$props) $$invali
891date(2, file_count = $$props.file_count); 892 if ('value' in $$props) $$invalidate(0, value = $$props.value); 893 if ('ls_fn' in $$props) $$invalidate(3, ls_fn = $$props.ls_fn); 894 }; 895 896 return [ 897 value, 898 interactive, 899 file_count, 900 ls_fn, 901 selected_folders, 902 paths_equal, 903 path_in_set, 904 path_inside, 905 check_handler 906 ]; 907} 908 909class DirectoryExplorer extends SvelteComponent$1 { 910 constructor(options) { 911 super(); 912 913 init$1(this, options, instance$1, create_fragment$1, safe_not_equal$1, { 914 interactive: 1, 915 file_count: 2, 916 value: 0, 917 ls_fn: 3 918 }); 919 } 920} 921 922/* home/runner/work/gradio/gradio/js/fileexplorer/Index.svelte generated by Svelte v4.2.2 */ 923const { 924 SvelteComponent, 925 add_flush_callback, 926 assign, 927 bind, 928 binding_callbacks, 929 check_outros, 930 create_component, 931 destroy_component, 932 detach, 933 empty, 934 flush, 935 get_spread_object, 936 get_spread_update, 937 group_outros, 938 init, 939 insert, 940 mount_component, 941 noop, 942 safe_not_equal, 943 space, 944 transition_in, 945 transition_out 946} = window.__gradio__svelte__internal; 947function create_key_block(ctx) { 948 let directoryexplorer; 949 let updating_value; 950 let current; 951 952 function directoryexplorer_value_binding(value) { 953 /*directoryexplorer_value_binding*/ ctx[20](value); 954 } 955 956 let directoryexplorer_props = { 957 file_count: /*file_count*/ ctx[7], 958 interactive: /*interactive*/ ctx[14], 959 ls_fn: /*server*/ ctx[13].ls 960 }; 961 962 if (/*value*/ ctx[0] !== void 0) { 963 directoryexplorer_props.value = /*value*/ ctx[0]; 964 } 965 966 directoryexplorer = new DirectoryExplorer({ props: directoryexplorer_props }); 967 binding_callbacks.push(() => bind(directoryexplorer, 'value', directoryexplorer_value_binding)); 968 969 return { 970 c() { 971 create_component(directoryexplorer.$$.fragment); 972 }, 973 m(target, anchor) { 974 mount_component(directoryexplorer, target, anchor); 975 current = true; 976 }, 977 p(ctx, dirty) { 978 const directoryexplorer_changes = {}; 979 if (dirty & /*file_count*/ 128) directoryexplorer_changes.file_count = /*file_count*/ ctx[7]; 980 if (dirty & /*interactive*/ 16384) directoryexplorer_changes.interactive = /*interactive*/ ctx[14]; 981 if (dirty & /*server*/ 8192) directoryexplorer_changes.ls_fn = /*server*/ ctx[13].ls; 982 983 if (!updating_value && dirty & /*value*/ 1) { 984 updating_value = true; 985 directoryexplorer_changes.value = /*value*/ ctx[0]; 986 add_flush_callback(() => updating_value = false); 987 } 988 989 directoryexplorer.$set(directoryexplorer_changes); 990 }, 991 i(local) { 992 if (current) return; 993 transition_in(directoryexplorer.$$.fragment, local); 994 current = true; 995 }, 996 o(local) { 997 transition_out(directoryexplorer.$$.fragment, local); 998 current = false; 999 }, 1000 d(detaching) { 1001 destroy_component(directoryexplorer, detaching); 1002 } 1003 }; 1004} 1005 1006// (34:0) <Block {visible} variant={value === null ? "dashed" : "solid"} border_mode={"base"} padding={false} {elem_id} {elem_classes} {container} {scale} {min_width} allow_overflow={false} {height} > 1007function create_default_slot(ctx) { 1008 let statustracker; 1009 let t0; 1010 let blocklabel; 1011 let t1; 1012 let previous_key = /*rerender_key*/ ctx[15]; 1013 let key_block_anchor; 1014 let current; 1015 1016 const statustracker_spread_levels = [ 1017 /*loading_status*/ ctx[8], 1018 { 1019 autoscroll: /*gradio*/ ctx[12].autoscroll 1020 }, 1021 { i18n: /*gradio*/ ctx[12].i18n } 1022 ]; 1023 1024 let statustracker_props = {}; 1025 1026 for (let i = 0; i < statustracker_spread_levels.length; i += 1) { 1027 statustracker_props = assign(statustracker_props, statustracker_spread_levels[i]); 1028 } 1029 1030 statustracker = new Static({ props: statustracker_props }); 1031 1032 blocklabel = new BlockLabel({ 1033 props: { 1034 show_label: /*show_label*/ ctx[5], 1035 Icon: File, 1036 label: /*label*/ ctx[4] || "FileExplorer", 1037 float: false 1038 } 1039 }); 1040 1041 let key_block = create_key_block(ctx); 1042 1043 return { 1044 c() { 1045 create_component(statustracker.$$.fragment); 1046 t0 = space(); 1047 create_component(blocklabel.$$.fragment); 1048 t1 = space(); 1049 key_block.c(); 1050 key_block_anchor = empty(); 1051 }, 1052 m(target, anchor) { 1053 mount_component(statustracker, target, anchor); 1054 insert(target, t0, anchor); 1055 mount_component(blocklabel, target, anchor); 1056 insert(target, t1, anchor); 1057 key_block.m(target, anchor); 1058 insert(target, key_block_anchor, anchor); 1059 current = true; 1060 }, 1061 p(ctx, dirty) { 1062 const statustracker_changes = (dirty & /*loading_status, gradio*/ 4352) 1063 ? get_spread_update(statustracker_spread_levels, [ 1064 dirty & /*loading_status*/ 256 && get_spread_object(/*loading_status*/ ctx[8]), 1065 dirty & /*gradio*/ 4096 && { 1066 autoscroll: /*gradio*/ ctx[12].autoscroll 1067 }, 1068 dirty & /*gradio*/ 4096 && { i18n: /*gradio*/ ctx[12].i18n } 1069 ]) 1070 : {}; 1071 1072 statustracker.$set(statustracker_changes); 1073 const blocklabel_changes = {};
1074 if (dirty & /*show_label*/ 32) blocklabel_changes.show_label = /*show_label*/ ctx[5]; 1075 if (dirty & /*label*/ 16) blocklabel_changes.label = /*label*/ ctx[4] || "FileExplorer"; 1076 blocklabel.$set(blocklabel_changes); 1077 1078 if (dirty & /*rerender_key*/ 32768 && safe_not_equal(previous_key, previous_key = /*rerender_key*/ ctx[15])) { 1079 group_outros(); 1080 transition_out(key_block, 1, 1, noop); 1081 check_outros(); 1082 key_block = create_key_block(ctx); 1083 key_block.c(); 1084 transition_in(key_block, 1); 1085 key_block.m(key_block_anchor.parentNode, key_block_anchor); 1086 } else { 1087 key_block.p(ctx, dirty); 1088 } 1089 }, 1090 i(local) { 1091 if (current) return; 1092 transition_in(statustracker.$$.fragment, local); 1093 transition_in(blocklabel.$$.fragment, local); 1094 transition_in(key_block); 1095 current = true; 1096 }, 1097 o(local) { 1098 transition_out(statustracker.$$.fragment, local); 1099 transition_out(blocklabel.$$.fragment, local); 1100 transition_out(key_block); 1101 current = false; 1102 }, 1103 d(detaching) { 1104 if (detaching) { 1105 detach(t0); 1106 detach(t1); 1107 detach(key_block_anchor); 1108 } 1109 1110 destroy_component(statustracker, detaching); 1111 destroy_component(blocklabel, detaching); 1112 key_block.d(detaching); 1113 } 1114 }; 1115} 1116 1117function create_fragment(ctx) { 1118 let block; 1119 let current; 1120 1121 block = new Block({ 1122 props: { 1123 visible: /*visible*/ ctx[3], 1124 variant: /*value*/ ctx[0] === null ? "dashed" : "solid", 1125 border_mode: "base", 1126 padding: false, 1127 elem_id: /*elem_id*/ ctx[1], 1128 elem_classes: /*elem_classes*/ ctx[2], 1129 container: /*container*/ ctx[9], 1130 scale: /*scale*/ ctx[10], 1131 min_width: /*min_width*/ ctx[11], 1132 allow_overflow: false, 1133 height: /*height*/ ctx[6], 1134 $$slots: { default: [create_default_slot] }, 1135 $$scope: { ctx } 1136 } 1137 }); 1138 1139 return { 1140 c() { 1141 create_component(block.$$.fragment); 1142 }, 1143 m(target, anchor) { 1144 mount_component(block, target, anchor); 1145 current = true; 1146 }, 1147 p(ctx, [dirty]) { 1148 const block_changes = {}; 1149 if (dirty & /*visible*/ 8) block_changes.visible = /*visible*/ ctx[3]; 1150 if (dirty & /*value*/ 1) block_changes.variant = /*value*/ ctx[0] === null ? "dashed" : "solid"; 1151 if (dirty & /*elem_id*/ 2) block_changes.elem_id = /*elem_id*/ ctx[1]; 1152 if (dirty & /*elem_classes*/ 4) block_changes.elem_classes = /*elem_classes*/ ctx[2]; 1153 if (dirty & /*container*/ 512) block_changes.container = /*container*/ ctx[9]; 1154 if (dirty & /*scale*/ 1024) block_changes.scale = /*scale*/ ctx[10]; 1155 if (dirty & /*min_width*/ 2048) block_changes.min_width = /*min_width*/ ctx[11]; 1156 if (dirty & /*height*/ 64) block_changes.height = /*height*/ ctx[6]; 1157 1158 if (dirty & /*$$scope, rerender_key, file_count, interactive, server, value, show_label, label, loading_status, gradio*/ 2159025) { 1159 block_changes.$$scope = { dirty, ctx }; 1160 } 1161 1162 block.$set(block_changes); 1163 }, 1164 i(local) { 1165 if (current) return; 1166 transition_in(block.$$.fragment, local); 1167 current = true; 1168 }, 1169 o(local) { 1170 transition_out(block.$$.fragment, local); 1171 current = false; 1172 }, 1173 d(detaching) { 1174 destroy_component(block, detaching); 1175 } 1176 }; 1177} 1178 1179function instance($$self, $$props, $$invalidate) { 1180 let rerender_key; 1181 let { elem_id = "" } = $$props; 1182 let { elem_classes = [] } = $$props; 1183 let { visible = true } = $$props; 1184 let { value } = $$props; 1185 let old_value; 1186 let { label } = $$props; 1187 let { show_label } = $$props; 1188 let { height = undefined } = $$props; 1189 let { file_count = "multiple" } = $$props; 1190 let { root_dir } = $$props; 1191 let { glob } = $$props; 1192 let { ignore_glob } = $$props; 1193 let { loading_status } = $$props; 1194 let { container = true } = $$props; 1195 let { scale = null } = $$props; 1196 let { min_width = undefined } = $$props; 1197 let { gradio } = $$props; 1198 let { server } = $$props; 1199 let { interactive } = $$props; 1200 1201 function directoryexplorer_value_binding(value$1) { 1202 value = value$1; 1203 $$invalidate(0, value); 1204 } 1205 1206 $$self.$$set = $$props => {
1207 if ('elem_id' in $$props) $$invalidate(1, elem_id = $$props.elem_id); 1208 if ('elem_classes' in $$props) $$invalidate(2, elem_classes = $$props.elem_classes); 1209 if ('visible' in $$props) $$invalidate(3, visible = $$props.visible); 1210 if ('value' in $$props) $$invalidate(0, value = $$props.value); 1211 if ('label' in $$props) $$invalidate(4, label = $$props.label); 1212 if ('show_label' in $$props) $$invalidate(5, show_label = $$props.show_label); 1213 if ('height' in $$props) $$invalidate(6, height = $$props.height); 1214 if ('file_count' in $$props) $$invalidate(7, file_count = $$props.file_count); 1215 if ('root_dir' in $$props) $$invalidate(16, root_dir = $$props.root_dir); 1216 if ('glob' in $$props) $$invalidate(17, glob = $$props.glob); 1217 if ('ignore_glob' in $$props) $$invalidate(18, ignore_glob = $$props.ignore_glob); 1218 if ('loading_status' in $$props) $$invalidate(8, loading_status = $$props.loading_status); 1219 if ('container' in $$props) $$invalidate(9, container = $$props.container); 1220 if ('scale' in $$props) $$invalidate(10, scale = $$props.scale);
1221 if ('min_width' in $$props) $$invalidate(11, min_width = $$props.min_width); 1222 if ('gradio' in $$props) $$invalidate(12, gradio = $$props.gradio); 1223 if ('server' in $$props) $$invalidate(13, server = $$props.server); 1224 if ('interactive' in $$props) $$invalidate(14, interactive = $$props.interactive); 1225 }; 1226 1227 $$self.$$.update = () => { 1228 if ($$self.$$.dirty & /*root_dir, glob, ignore_glob*/ 458752) { 1229 $$invalidate(15, rerender_key = [root_dir, glob, ignore_glob]); 1230 } 1231 1232 if ($$self.$$.dirty & /*value, old_value, gradio*/ 528385) { 1233 if (JSON.stringify(value) !== JSON.stringify(old_value)) { 1234 $$invalidate(19, old_value = value); 1235 gradio.dispatch("change"); 1236 } 1237 } 1238 }; 1239 1240 return [ 1241 value, 1242 elem_id, 1243 elem_classes, 1244 visible, 1245 label, 1246 show_label, 1247 height, 1248 file_count, 1249 loading_status, 1250 container, 1251 scale, 1252 min_width, 1253 gradio, 1254 server, 1255 interactive, 1256 rerender_key, 1257 root_dir, 1258 glob, 1259 ignore_glob, 1260 old_value, 1261 directoryexplorer_value_binding 1262 ]; 1263} 1264 1265class Index extends SvelteComponent { 1266 constructor(options) { 1267 super(); 1268 1269 init(this, options, instance, create_fragment, safe_not_equal, { 1270 elem_id: 1, 1271 elem_classes: 2, 1272 visible: 3, 1273 value: 0, 1274 label: 4, 1275 show_label: 5, 1276 height: 6, 1277 file_count: 7, 1278 root_dir: 16, 1279 glob: 17, 1280 ignore_glob: 18, 1281 loading_status: 8, 1282 container: 9, 1283 scale: 10, 1284 min_width: 11, 1285 gradio: 12, 1286 server: 13, 1287 interactive: 14 1288 }); 1289 } 1290 1291 get elem_id() { 1292 return this.$$.ctx[1]; 1293 } 1294 1295 set elem_id(elem_id) { 1296 this.$$set({ elem_id }); 1297 flush(); 1298 } 1299 1300 get elem_classes() { 1301 return this.$$.ctx[2]; 1302 } 1303 1304 set elem_classes(elem_classes) { 1305 this.$$set({ elem_classes }); 1306 flush(); 1307 } 1308 1309 get visible() { 1310 return this.$$.ctx[3]; 1311 } 1312 1313 set visible(visible) { 1314 this.$$set({ visible }); 1315 flush(); 1316 } 1317 1318 get value() { 1319 return this.$$.ctx[0]; 1320 } 1321 1322 set value(value) { 1323 this.$$set({ value }); 1324 flush(); 1325 } 1326 1327 get label() { 1328 return this.$$.ctx[4]; 1329 } 1330 1331 set label(label) { 1332 this.$$set({ label }); 1333 flush(); 1334 } 1335 1336 get show_label() { 1337 return this.$$.ctx[5]; 1338 } 1339 1340 set show_label(show_label) { 1341 this.$$set({ show_label }); 1342 flush(); 1343 } 1344 1345 get height() { 1346 return this.$$.ctx[6]; 1347 } 1348 1349 set height(height) { 1350 this.$$set({ height }); 1351 flush(); 1352 } 1353 1354 get file_count() { 1355 return this.$$.ctx[7]; 1356 } 1357 1358 set file_count(file_count) { 1359 this.$$set({ file_count }); 1360 flush(); 1361 } 1362 1363 get root_dir() { 1364 return this.$$.ctx[16]; 1365 } 1366 1367 set root_dir(root_dir) { 1368 this.$$set({ root_dir }); 1369 flush(); 1370 } 1371 1372 get glob() { 1373 return this.$$.ctx[17]; 1374 } 1375 1376 set glob(glob) { 1377 this.$$set({ glob }); 1378 flush(); 1379 } 1380 1381 get ignore_glob() { 1382 return this.$$.ctx[18]; 1383 } 1384 1385 set ignore_glob(ignore_glob) { 1386 this.$$set({ ignore_glob }); 1387 flush(); 1388 } 1389 1390 get loading_status() { 1391 return this.$$.ctx[8]; 1392 } 1393 1394 set loading_status(loading_status) { 1395 this.$$set({ loading_status }); 1396 flush(); 1397 } 1398 1399 get container() { 1400 return this.$$.ctx[9]; 1401 } 1402 1403 set container(container) { 1404 this.$$set({ container }); 1405 flush(); 1406 } 1407 1408 get scale() { 1409 return this.$$.ctx[10]; 1410 } 1411 1412 set scale(scale) { 1413 this.$$set({ scale }); 1414 flush(); 1415 } 1416 1417 get min_width() { 1418 return this.$$.ctx[11]; 1419 } 1420 1421 set min_width(min_width) { 1422 this.$$set({ min_width }); 1423 flush(); 1424 } 1425 1426 get gradio() { 1427 return this.$$.ctx[12]; 1428 } 1429 1430 set gradio(gradio) { 1431 this.$$set({ gradio }); 1432 flush(); 1433 } 1434 1435 get server() { 1436 return this.$$.ctx[13]; 1437 } 1438 1439 set server(server) { 1440 this.$$set({ server }); 1441 flush(); 1442 } 1443 1444 get interactive() { 1445 return this.$$.ctx[14]; 1446 } 1447 1448 set interactive(interactive) { 1449 this.$$set({ interactive }); 1450 flush(); 1451 } 1452} 1453 1454export { Index as default }; 1455//# sourceMappingURL=Index-c871e021.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.