PageSourceSearch

https://merve-owlv2.hf.space/assets/Index-a95b9053.js

js merve-owlv2.hf.space collected 2026-10-03 10:23:52 UTC 18,224 bytes, 643 lines download raw bytes

1import { a as Button } from './Button-f2ef1e3f.js';
2import { g as get_fetchable_url_or_file, p as prepare_files, u as upload } from './index-546f83db.js';
3import './Index-f4e7a341.js';
4import './svelte/svelte.js';
5
6const UploadButton_svelte_svelte_type_style_lang = '';
7
8/* home/runner/work/gradio/gradio/js/uploadbutton/shared/UploadButton.svelte generated by Svelte v4.2.2 */
9const {
10	SvelteComponent: SvelteComponent$1,
11	attr,
12	binding_callbacks,
13	create_component: create_component$1,
14	create_slot,
15	destroy_component: destroy_component$1,
16	detach: detach$1,
17	element,
18	get_all_dirty_from_scope,
19	get_slot_changes,
20	init: init$1,
21	insert: insert$1,
22	listen,
23	mount_component: mount_component$1,
24	run_all,
25	safe_not_equal: safe_not_equal$1,
26	space,
27	src_url_equal,
28	transition_in: transition_in$1,
29	transition_out: transition_out$1,
30	update_slot_base
31} = window.__gradio__svelte__internal;
32const { tick, createEventDispatcher, getContext } = window.__gradio__svelte__internal;
33function create_if_block(ctx) {
34	let img;
35	let img_src_value;
36	let img_alt_value;
37
38	return {
39		c() {
40			img = element("img");
41			attr(img, "class", "button-icon svelte-1rvxzzt");
42			if (!src_url_equal(img.src, img_src_value = /*icon_path*/ ctx[14])) attr(img, "src", img_src_value);
43			attr(img, "alt", img_alt_value = `${/*value*/ ctx[0]} icon`);
44		},
45		m(target, anchor) {
46			insert$1(target, img, anchor);
47		},
48		p(ctx, dirty) {
49			if (dirty & /*icon_path*/ 16384 && !src_url_equal(img.src, img_src_value = /*icon_path*/ ctx[14])) {
50				attr(img, "src", img_src_value);
51			}
52
53			if (dirty & /*value*/ 1 && img_alt_value !== (img_alt_value = `${/*value*/ ctx[0]} icon`)) {
54				attr(img, "alt", img_alt_value);
55			}
56		},
57		d(detaching) {
58			if (detaching) {
59				detach$1(img);
60			}
61		}
62	};
63}
64
65// (82:0) <BaseButton  {size}  {variant}  {elem_id}  {elem_classes}  {visible}  on:click={openFileUpload}  {scale}  {min_width}  {disabled} >
66function create_default_slot$1(ctx) {
67	let t;
68	let current;
69	let if_block = /*icon*/ ctx[7] && create_if_block(ctx);
70	const default_slot_template = /*#slots*/ ctx[20].default;
71	const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[22], null);
72
73	return {
74		c() {
75			if (if_block) if_block.c();
76			t = space();
77			if (default_slot) default_slot.c();
78		},
79		m(target, anchor) {
80			if (if_block) if_block.m(target, anchor);
81			insert$1(target, t, anchor);
82
83			if (default_slot) {
84				default_slot.m(target, anchor);
85			}
86
87			current = true;
88		},
89		p(ctx, dirty) {
90			if (/*icon*/ ctx[7]) {
91				if (if_block) {
92					if_block.p(ctx, dirty);
93				} else {
94					if_block = create_if_block(ctx);
95					if_block.c();
96					if_block.m(t.parentNode, t);
97				}
98			} else if (if_block) {
99				if_block.d(1);
100				if_block = null;
101			}
102
103			if (default_slot) {
104				if (default_slot.p && (!current || dirty & /*$$scope*/ 4194304)) {
105					update_slot_base(
106						default_slot,
107						default_slot_template,
108						ctx,
109						/*$$scope*/ ctx[22],
110						!current
111						? get_all_dirty_from_scope(/*$$scope*/ ctx[22])
112						: get_slot_changes(default_slot_template, /*$$scope*/ ctx[22], dirty, null),
113						null
114					);
115				}
116			}
117		},
118		i(local) {
119			if (current) return;
120			transition_in$1(default_slot, local);
121			current = true;
122		},
123		o(local) {
124			transition_out$1(default_slot, local);
125			current = false;
126		},
127		d(detaching) {
128			if (detaching) {
129				detach$1(t);
130			}
131
132			if (if_block) if_block.d(detaching);
133			if (default_slot) default_slot.d(detaching);
134		}
135	};
136}
137
138function create_fragment$1(ctx) {
139	let input;
140	let input_multiple_value;
141	let input_webkitdirectory_value;
142	let input_mozdirectory_value;
143	let input_data_testid_value;
144	let t;
145	let basebutton;
146	let current;
147	let mounted;
148	let dispose;
149
150	basebutton = new Button({
151			props: {
152				size: /*size*/ ctx[6],
153				variant: /*variant*/ ctx[10],
154				elem_id: /*elem_id*/ ctx[1],
155				elem_classes: /*elem_classes*/ ctx[2],
156				visible: /*visible*/ ctx[3],
157				scale: /*scale*/ ctx[8],
158				min_width: /*min_width*/ ctx[9],
159				disabled: /*disabled*/ ctx[11],
160				$$slots: { default: [create_default_slot$1] },
161				$$scope: { ctx }
162			}
163		});
164
165	basebutton.$on("click", /*openFileUpload*/ ctx[15]);
166
167	return {
168		c() {
169			input = element("input");
170			t = space();
171			create_component$1(basebutton.$$.fragment);
172			attr(input, "class", "hide svelte-1rvxzzt");
173			attr(input, "accept", /*accept_file_types*/ ctx[13]);
174			attr(input, "type", "file");
175			input.multiple = input_multiple_value = /*file_count*/ ctx[5] === "multiple" || undefined;
176			attr(input, "webkitdirectory", input_webkitdirectory_value = /*file_count*/ ctx[5] === "directory" || undefined);
177			attr(input, "mozdirectory", input_mozdirectory_value = /*file_count*/ ctx[5] === "directory" || undefined);
178			attr(input, "data-testid", input_data_testid_value = "" + (/*label*/ ctx[4] + "-upload-button"));
179		},
180		m(target, anchor) {
181			insert$1(target, input, anchor);
182			/*input_binding*/ ctx[21](input);
183			insert$1(target, t, anchor);
184			mount_component$1(basebutton, target, anchor);
185			current = true;
186
187			if (!mounted) {
188				dispose = [
189					listen(input, "change", /*loadFilesFromUpload*/ ctx[16]),
190					listen(input, "click", clearInputValue)
191				];
192
193				mounted = true;
194			}
195		},
196		p(ctx, [dirty]) {
197			if (!current || dirty & /*accept_file_types*/ 8192) {
198				attr(input, "accept", /*accept_file_types*/ ctx[13]);
199			}
200
201			if (!current || dirty & /*file_count*/ 32 && input_multiple_value !== (input_multiple_value = /*file_count*/ ctx[5] === "multiple" || undefined)) {
202				input.multiple = input_multiple_value;
203			}
204
205			if (!current || dirty & /*file_count*/ 32 && input_webkitdirectory_value !== (input_webkitdirectory_value = /*file_count*/ ctx[5] === "directory" || undefined)) {
206				attr(input, "webkitdirectory", input_webkitdirectory_value);
207			}
208
209			if (!current || dirty & /*file_count*/ 32 && input_mozdirectory_value !== (input_mozdirectory_value = /*file_count*/ ctx[5] === "directory" || undefined)) {
210				attr(input, "mozdirectory", input_mozdirectory_value);
211			}
212
213			if (!current || dirty & /*label*/ 16 && input_data_testid_value !== (input_data_testid_value = "" + (/*label*/ ctx[4] + "-upload-button"))) {
214				attr(input, "data-testid", input_data_testid_value);
215			}
216
217			const basebutton_changes = {};
218			if (dirty & /*size*/ 64) basebutton_changes.size = /*size*/ ctx[6];
219			if (dirty & /*variant*/ 1024) basebutton_changes.variant = /*variant*/ ctx[10];
220			if (dirty & /*elem_id*/ 2) basebutton_changes.elem_id = /*elem_id*/ ctx[1];
221			if (dirty & /*elem_classes*/ 4) basebutton_changes.elem_classes = /*elem_classes*/ ctx[2];
222			if (dirty & /*visible*/ 8) basebutton_changes.visible = /*visible*/ ctx[3];
223			if (dirty & /*scale*/ 256) basebutton_changes.scale = /*scale*/ ctx[8];
224			if (dirty & /*min_width*/ 512) basebutton_changes.min_width = /*min_width*/ ctx[9];
225			if (dirty & /*disabled*/ 2048) basebutton_changes.disabled = /*disabled*/ ctx[11];
226
227			if (dirty & /*$$scope, icon_path, value, icon*/ 4210817) {
228				basebutton_changes.$$scope = { dirty, ctx };
229			}
230
231			basebutton.$set(basebutton_changes);
232		},
233		i(local) {
234			if (current) return;
235			transition_in$1(basebutton.$$.fragment, local);
236			current = true;
237		},
238		o(local) {
239			transition_out$1(basebutton.$$.fragment, local);
240			current = false;
241		},
242		d(detaching) {
243			if (detaching) {
244				detach$1(input);
245				detach$1(t);
246			}
247
248			/*input_binding*/ ctx[21](null);
249			destroy_component$1(basebutton, detaching);
250			mounted = false;
251			run_all(dispose);
252		}
253	};
254}
255
256function clearInputValue(e) {
257	const target = e.target;
258	if (target.value) target.value = "";
259}
260
261function instance$1($$self, $$props, $$invalidate) {
262	let icon_path;
263	let { $$slots: slots = {}, $$scope } = $$props;
264	let { elem_id = "" } = $$props;
265	let { elem_classes = [] } = $$props;
266	let { visible = true } = $$props;
267	let { label } = $$props;
268	let { value } = $$props;
269	let { file_count } = $$props;
270	let { file_types = [] } = $$props;
271	let { root } = $$props;
272	let { size = "lg" } = $$props;
273	let { icon = null } = $$props;
274	let { scale = null } = $$props;
275	let { min_width = undefined } = $$props;
276	let { variant = "secondary" } = $$props;
277	let { disabled = false } = $$props;
278	let { proxy_url = null } = $$props;
279	const dispatch = createEventDispatcher();
280
281	// Needed for wasm support
282	const upload_fn = getContext("upload_files");
283
284	let hidden_upload;
285	let accept_file_types;
286
287	if (file_types == null) {
288		accept_file_types = null;
289	} else {
290		file_types = file_types.map(x => {
291			if (x.startsWith(".")) {
292				return x;
293			}
294
295			return x + "/*";
296		});
297
298		accept_file_types = file_types.join(", ");
299	}
300
301	function openFileUpload() {
302		dispatch("click");
303		hidden_upload.click();
304	}
305
306	async function loadFiles(files) {
307		let _files = Array.from(files);
308
309		if (!files.length) {
310			return;
311		}
312
313		if (file_count === "single") {
314			_files = [files[0]];
315		}
316
317		let all_file_data = await prepare_files(_files);
318		await tick();
319		all_file_data = (await upload(all_file_data, root, undefined, upload_fn))?.filter(x => x !== null);
320
321		$$invalidate(0, value = file_count === "single"
322		? all_file_data?.[0]
323		: all_file_data);
324
325		dispatch("change", value);
326		dispatch("upload", value);
327	}
328
329	async function loadFilesFromUpload(e) {
330		const target = e.target;
331		if (!target.files) return;
332		await loadFiles(target.files);
333	}
334
335	function input_binding($$value) {
336		binding_callbacks[$$value ? 'unshift' : 'push'](() => {
337			hidden_upload = $$value;
338			$$invalidate(12, hidden_upload);
339		});
340	}
341
342	$$self.$$set = $$props => {
343		if ('elem_id' in $$props) $$invalidate(1, elem_id = $$props.elem_id);
344		if ('elem_classes' in $$props) $$invalidate(2, elem_classes = $$props.elem_classes);
345		if ('visible' in $$props) $$invalidate(3, visible = $$props.visible);
346		if ('label' in $$props) $$invalidate(4, label = $$props.label);
347		if ('value' in $$props) $$invalidate(0, value = $$props.value);
348		if ('file_count' in $$props) $$invalidate(5, file_count = $$props.file_count);
349		if ('file_types' in $$props) $$invalidate(17, file_types = $$props.file_types);
350		if ('root' in $$props) $$invalidate(18, root = $$props.root);
351		if ('size' in $$props) $$invalidate(6, size = $$props.size);
352		if ('icon' in $$props) $$invalidate(7, icon = $$props.icon);
353		if ('scale' in $$props) $$invalidate(8, scale = $$props.scale);
354		if ('min_width' in $$props) $$invalidate(9, min_width = $$props.min_width);
355		if ('variant' in $$props) $$invalidate(10, variant = $$props.variant);
356		if ('disabled' in $$props) $$invali
356date(11, disabled = $$props.disabled);
357		if ('proxy_url' in $$props) $$invalidate(19, proxy_url = $$props.proxy_url);
358		if ('$$scope' in $$props) $$invalidate(22, $$scope = $$props.$$scope);
359	};
360
361	$$self.$$.update = () => {
362		if ($$self.$$.dirty & /*icon, root, proxy_url*/ 786560) {
363			$$invalidate(14, icon_path = get_fetchable_url_or_file(icon, root, proxy_url));
364		}
365	};
366
367	return [
368		value,
369		elem_id,
370		elem_classes,
371		visible,
372		label,
373		file_count,
374		size,
375		icon,
376		scale,
377		min_width,
378		variant,
379		disabled,
380		hidden_upload,
381		accept_file_types,
382		icon_path,
383		openFileUpload,
384		loadFilesFromUpload,
385		file_types,
386		root,
387		proxy_url,
388		slots,
389		input_binding,
390		$$scope
391	];
392}
393
394class UploadButton extends SvelteComponent$1 {
395	constructor(options) {
396		super();
397
398		init$1(this, options, instance$1, create_fragment$1, safe_not_equal$1, {
399			elem_id: 1,
400			elem_classes: 2,
401			visible: 3,
402			label: 4,
403			value: 0,
404			file_count: 5,
405			file_types: 17,
406			root: 18,
407			size: 6,
408			icon: 7,
409			scale: 8,
410			min_width: 9,
411			variant: 10,
412			disabled: 11,
413			proxy_url: 19
414		});
415	}
416}
417
418const UploadButton$1 = UploadButton;
419
420/* home/runner/work/gradio/gradio/js/uploadbutton/Index.svelte generated by Svelte v4.2.2 */
421const {
422	SvelteComponent,
423	create_component,
424	destroy_component,
425	detach,
426	init,
427	insert,
428	mount_component,
429	safe_not_equal,
430	set_data,
431	text,
432	transition_in,
433	transition_out
434} = window.__gradio__svelte__internal;
435function create_default_slot(ctx) {
436	let t_value = (/*label*/ ctx[4]
437	? /*gradio*/ ctx[13].i18n(/*label*/ ctx[4])
438	: "") + "";
439
440	let t;
441
442	return {
443		c() {
444			t = text(t_value);
445		},
446		m(target, anchor) {
447			insert(target, t, anchor);
448		},
449		p(ctx, dirty) {
450			if (dirty & /*label, gradio*/ 8208 && t_value !== (t_value = (/*label*/ ctx[4]
451			? /*gradio*/ ctx[13].i18n(/*label*/ ctx[4])
452			: "") + "")) set_data(t, t_value);
453		},
454		d(detaching) {
455			if (detaching) {
456				detach(t);
457			}
458		}
459	};
460}
461
462function create_fragment(ctx) {
463	let uploadbutton;
464	let current;
465
466	uploadbutton = new UploadButton$1({
467			props: {
468				elem_id: /*elem_id*/ ctx[1],
469				elem_classes: /*elem_classes*/ ctx[2],
470				visible: /*visible*/ ctx[3],
471				file_count: /*file_count*/ ctx[5],
472				file_types: /*file_types*/ ctx[6],
473				size: /*size*/ ctx[8],
474				scale: /*scale*/ ctx[9],
475				icon: /*icon*/ ctx[10],
476				min_width: /*min_width*/ ctx[11],
477				root: /*root*/ ctx[7],
478				value: /*value*/ ctx[0],
479				disabled: /*disabled*/ ctx[15],
480				variant: /*variant*/ ctx[12],
481				label: /*label*/ ctx[4],
482				proxy_url: /*proxy_url*/ ctx[14],
483				$$slots: { default: [create_default_slot] },
484				$$scope: { ctx }
485			}
486		});
487
488	uploadbutton.$on("click", /*click_handler*/ ctx[18]);
489	uploadbutton.$on("change", /*change_handler*/ ctx[19]);
490	uploadbutton.$on("upload", /*upload_handler*/ ctx[20]);
491
492	return {
493		c() {
494			create_component(uploadbutton.$$.fragment);
495		},
496		m(target, anchor) {
497			mount_component(uploadbutton, target, anchor);
498			current = true;
499		},
500		p(ctx, [dirty]) {
501			const uploadbutton_changes = {};
502			if (dirty & /*elem_id*/ 2) uploadbutton_changes.elem_id = /*elem_id*/ ctx[1];
503			if (dirty & /*elem_classes*/ 4) uploadbutton_changes.elem_classes = /*elem_classes*/ ctx[2];
504			if (dirty & /*visible*/ 8) uploadbutton_changes.visible = /*visible*/ ctx[3];
505			if (dirty & /*file_count*/ 32) uploadbutton_changes.file_count = /*file_count*/ ctx[5];
506			if (dirty & /*file_types*/ 64) uploadbutton_changes.file_types = /*file_types*/ ctx[6];
507			if (dirty & /*size*/ 256) uploadbutton_changes.size = /*size*/ ctx[8];
508			if (dirty & /*scale*/ 512) uploadbutton_changes.scale = /*scale*/ ctx[9];
509			if (dirty & /*icon*/ 1024) uploadbutton_changes.icon = /*icon*/ ctx[10];
510			if (dirty & /*min_width*/ 2048) uploadbutton_changes.min_width = /*min_width*/ ctx[11];
511			if (dirty & /*root*/ 128) uploadbutton_changes.root = /*root*/ ctx[7];
512			if (dirty & /*value*/ 1) uploadbutton_changes.value = /*value*/ ctx[0];
513			if (dirty & /*disabled*/ 32768) uploadbutton_changes.disabled = /*disabled*/ ctx[15];
514			if (dirty & /*variant*/ 4096) uploadbutton_changes.variant = /*variant*/ ctx[12];
515			if (dirty & /*label*/ 16) uploadbutton_changes.label = /*label*/ ctx[4];
516			if (dirty & /*proxy_url*/ 16384) uploadbutton_changes.proxy_url = /*proxy_url*/ ctx[14];
517
518			if (dirty & /*$$scope, label, gradio*/ 2105360) {
519				uploadbutton_changes.$$scope = { dirty, ctx };
520			}
521
522			uploadbutton.$set(uploadbutton_changes);
523		},
524		i(local) {
525			if (current) return;
526			transition_in(uploadbutton.$$.fragment, local);
527			current = true;
528		},
529		o(local) {
530			transition_out(uploadbutton.$$.fragment, local);
531			current = false;
532		},
533		d(detaching) {
534			destroy_component(uploadbutton, detaching);
535		}
536	};
537}
538
539function instance($$self, $$props, $$invalidate) {
540	let disabled;
541	let { elem_id = "" } = $$props;
542	let { elem_classes = [] } = $$props;
543	let { visible = true } = $$props;
544	let { label } = $$props;
545	let { value } = $$props;
546	let { file_count } = $$props;
547	let { file_types = [] } = $$props;
548	let { root } = $$props;
549	let { size = "lg" } = $$props;
550	let { scale = null } = $$props;
551	let { icon = null } = $$props;
552	let { min_width = undefined } = $$props;
553	let { variant = "secondary" } = $$props;
554	let { gradio } = $$props;
555	let { interactive } = $$props;
556	let { proxy_url = null } = $$props;
557
558	async function handle_event(detail, event) {
559		$$invalidate(0, value = detail);
560		gradio.dispatch(event);
561	}
562
563	const click_handler = () => gradio.dispatch("click");
564	const change_handler = ({ detail }) => handle_event(detail, "change");
565	const upload_handler = ({ detail }) => handle_event(detail, "upload");
566
567	$$self.$$set = $$props => {
568		if ('elem_id' in $$props) $$invalidate(1, elem_id = $$props.elem_id);
569		if ('elem_classes' in $$props) $$invalidate(2, elem_classes = $$props.elem_classes);
570		if ('visible' in $$props) $$invalidate(3, visible = $$props.visible);
571		if ('label' in $$props) $$invalidate(4, label = $$props.label);
572		if ('value' in $$props) $$invalidate(0, value = $$props.value);
573		if ('file_count' in $$props) $$invalidate(5, file_count = $$props.file_count);
574		if ('file_types' in $$props) $$invalidate(6, file_types = $$props.file_types);
575		if ('root' in $$props) $$invalidate(7, root = $$props.root);
576		if ('size' in $$props) $$invalidate(8, size = $$props.size);
577		if ('scale' in $$props) $$invalidate(9, scale = $$props.scale);
578		if ('icon' in $$props) $$invalidate(10, icon = $$props.icon);
579		if ('min_width' in $$props) $$invalidate(11, min_width = $$props.min_width);
580		if ('variant' in $$props) $$invalidate(12, variant = $$props.variant);
581		if ('gradio' in $$props) $$invalidate(13, gradio = $$props.gradio);
582		if ('interactive' in $$props) $$invali
582date(17, interactive = $$props.interactive);
583		if ('proxy_url' in $$props) $$invalidate(14, proxy_url = $$props.proxy_url);
584	};
585
586	$$self.$$.update = () => {
587		if ($$self.$$.dirty & /*interactive*/ 131072) {
588			$$invalidate(15, disabled = !interactive);
589		}
590	};
591
592	return [
593		value,
594		elem_id,
595		elem_classes,
596		visible,
597		label,
598		file_count,
599		file_types,
600		root,
601		size,
602		scale,
603		icon,
604		min_width,
605		variant,
606		gradio,
607		proxy_url,
608		disabled,
609		handle_event,
610		interactive,
611		click_handler,
612		change_handler,
613		upload_handler
614	];
615}
616
617class Index extends SvelteComponent {
618	constructor(options) {
619		super();
620
621		init(this, options, instance, create_fragment, safe_not_equal, {
622			elem_id: 1,
623			elem_classes: 2,
624			visible: 3,
625			label: 4,
626			value: 0,
627			file_count: 5,
628			file_types: 6,
629			root: 7,
630			size: 8,
631			scale: 9,
632			icon: 10,
633			min_width: 11,
634			variant: 12,
635			gradio: 13,
636			interactive: 17,
637			proxy_url: 14
638		});
639	}
640}
641
642export { UploadButton$1 as BaseUploadButton, Index as default };
643//# sourceMappingURL=Index-a95b9053.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.