PageSourceSearch

https://raivisdejus-latvian-piper-tts.hf.space/assets/Index-0rZUl0Zh.js

js raivisdejus-latvian-piper-tts.hf.space collected 2026-10-03 17:17:37 UTC 6,942 bytes, 299 lines download raw bytes

1import { p as prop, d as bind_this, i as if_block, a as set_attribute, r as rest_props } from './i18n-CGlVUOvE.js';
2import { M as push, N as first_child, a as append, t as template_effect, O as pop, S as sibling, R as from_html, at as prepare_files, I as tick, ai as delegate, a3 as comment, Z as get, a2 as user_derived, ac as proxy, ad as user_effect, a4 as text, X as set_text, a5 as next } from './index-Bq2njFOY.js';
3import { G as Gradio } from './utils.svelte-Bi9ASwv9.js';
4import { s as snippet } from './snippet-BG7qkY_1.js';
5import { B as Button } from './Button-By21KHDn.js';
6import './Image-XuMqTTwB.js';
7import './misc-D8a4ZbMA.js';
8/* empty css                                             */
9import './ScrollFade.svelte_svelte_type_style_lang-D0JPkGar.js';
10import './MarkdownCode.svelte_svelte_type_style_lang-B29zDiob.js';
11import './prism-python-NrKIQnfs.js';
12/* empty css                                                    */
13
14var root_3 = from_html(`<img class="button-icon svelte-94gmgt"/>`);
15var root_2 = from_html(`<!> <!>`, 1);
16var root_1 = from_html(`<input class="hide svelte-94gmgt" type="file"/> <!>`, 1);
17
18function UploadButton($$anchor, $$props) {
19	push($$props, true);
20
21	let elem_id = prop($$props, 'elem_id', 3, ""),
22		elem_classes = prop($$props, 'elem_classes', 19, () => []),
23		visible = prop($$props, 'visible', 3, true),
24		file_types = prop($$props, 'file_types', 19, () => []),
25		size = prop($$props, 'size', 3, "lg"),
26		icon = prop($$props, 'icon', 3, null),
27		scale = prop($$props, 'scale', 3, null),
28		min_width = prop($$props, 'min_width', 3, undefined),
29		variant = prop($$props, 'variant', 3, "secondary"),
30		disabled = prop($$props, 'disabled', 3, false),
31		max_file_size = prop($$props, 'max_file_size', 3, null);
32
33	let hidden_upload;
34
35	let accept_file_types = user_derived(() => {
36		if (file_types() == null) {
37			return null;
38		}
39
40		const mapped = file_types().map((x) => {
41			if (x.startsWith(".")) {
42				return x;
43			}
44
45			return x + "/*";
46		});
47
48		return mapped.join(", ");
49	});
50
51	function open_file_upload() {
52		$$props.onclick?.();
53		hidden_upload.click();
54	}
55
56	async function load_files(files) {
57		let _files = Array.from(files);
58
59		if (!files.length) {
60			return;
61		}
62
63		if ($$props.file_count === "single") {
64			_files = [files[0]];
65		}
66
67		let all_file_data = await prepare_files(_files);
68
69		await tick();
70
71		try {
72			all_file_data = (await $$props.upload(all_file_data, $$props.root, undefined, max_file_size() ?? Infinity))?.filter((x) => x !== null);
73		} catch(e) {
74			$$props.onerror?.(e.message);
75
76			return;
77		}
78
79		const new_value = $$props.file_count === "single" ? all_file_data?.[0] : all_file_data;
80
81		$$props.onchange?.(new_value);
82		$$props.onupload?.(new_value);
83	}
84
85	async function load_files_from_upload(e) {
86		const target = e.target;
87
88		if (!target.files) return;
89
90		await load_files(target.files);
91	}
92
93	function clear_input_value(e) {
94		const target = e.target;
95
96		if (target.value) target.value = "";
97	}
98
99	var fragment = root_1();
100	var input = first_child(fragment);
101
102	input.__change = load_files_from_upload;
103	input.__click = clear_input_value;
104	bind_this(input, ($$value) => hidden_upload = $$value, () => hidden_upload);
105
106	var node = sibling(input, 2);
107
108	Button(node, {
109		get size() {
110			return size();
111		},
112
113		get variant() {
114			return variant();
115		},
116
117		get elem_id() {
118			return elem_id();
119		},
120
121		get elem_classes() {
122			return elem_classes();
123		},
124
125		get visible() {
126			return visible();
127		},
128		onclick: open_file_upload,
129		get scale() {
130			return scale();
131		},
132
133		get min_width() {
134			return min_width();
135		},
136
137		get disabled() {
138			return disabled();
139		},
140
141		children: ($$anchor, $$slotProps) => {
142			var fragment_1 = root_2();
143			var node_1 = first_child(fragment_1);
144
145			{
146				var consequent = ($$anchor) => {
147					var img = root_3();
148
149					template_effect(() => {
150						set_attribute(img, 'src', icon().url);
151						set_attribute(img, 'alt', `${$$props.value} icon`);
152					});
153
154					append($$anchor, img);
155				};
156
157				if_block(node_1, ($$render) => {
158					if (icon()) $$render(consequent);
159				});
160			}
161
162			var node_2 = sibling(node_1, 2);
163
164			{
165				var consequent_1 = ($$anchor) => {
166					var fragment_2 = comment();
167					var node_3 = first_child(fragment_2);
168
169					snippet(node_3, () => $$props.children);
170					append($$anchor, fragment_2);
171				};
172
173				if_block(node_2, ($$render) => {
174					if ($$props.children) $$render(consequent_1);
175				});
176			}
177
178			append($$anchor, fragment_1);
179		},
180		$$slots: { default: true }
181	});
182
183	template_effect(() => {
184		set_attribute(input, 'accept', get(accept_file_types));
185		input.multiple = $$props.file_count === "multiple" || undefined;
186		input.webkitdirectory = $$props.file_count === "directory" || undefined;
187		set_attribute(input, 'mozdirectory', $$props.file_count === "directory" || undefined);
188		set_attribute(input, 'data-testid', `${$$props.label ?? ''}-upload-button`);
189	});
190
191	append($$anchor, fragment);
192	pop();
193}
194
195delegate(['change', 'click']);
196
197function Index($$anchor, $$props) {
198	push($$props, true);
199
200	const props = rest_props($$props, ['$$slots', '$$events', '$$legacy']);
201	const gradio = new Gradio(props);
202	let value = proxy(gradio.props.value);
203
204	user_effect(() => {
205		if (value !== gradio.props.value) {
206			gradio.props.value = value;
207		}
208	});
209
210	async function handle_event(detail, event) {
211		gradio.props.value = detail;
212		gradio.dispatch(event);
213	}
214
215	const disabled = user_derived(() => !gradio.shared.interactive);
216
217	UploadButton($$anchor, {
218		get elem_id() {
219			return gradio.shared.elem_id;
220		},
221
222		get elem_classes() {
223			return gradio.shared.elem_classes;
224		},
225
226		get visible() {
227			return gradio.shared.visible;
228		},
229
230		get file_count() {
231			return gradio.props.file_count;
232		},
233
234		get file_types() {
235			return gradio.props.file_types;
236		},
237
238		get size() {
239			return gradio.props.size;
240		},
241
242		get scale() {
243			return gradio.shared.scale;
244		},
245
246		get icon() {
247			return gradio.props.icon;
248		},
249
250		get min_width() {
251			return gradio.shared.min_width;
252		},
253
254		get root() {
255			return gradio.shared.root;
256		},
257
258		get value() {
259			return value;
260		},
261
262		get disabled() {
263			return get(disabled);
264		},
265
266		get variant() {
267			return gradio.props.variant;
268		},
269
270		get label() {
271			return gradio.shared.label;
272		},
273
274		get max_file_size() {
275			return gradio.shared.max_file_size;
276		},
277		onclick: () => gradio.dispatch("click"),
278		onchange: (detail) => handle_event(detail, "change"),
279		onupload: (detail) => handle_event(detail, "upload"),
280		onerror: (detail) => {
281			gradio.dispatch("error", detail);
282		},
283		upload: (...args) => gradio.shared.client.upload(...args),
284		children: ($$anchor, $$slotProps) => {
285			next();
286
287			var text$1 = text();
288
289			template_effect(() => set_text(text$1, gradio.shared.label ?? ""));
290			append($$anchor, text$1);
291		},
292		$$slots: { default: true }
293	});
294
295	pop();
296}
297
298export { UploadButton as BaseUploadButton, Index as default };
299//# sourceMappingURL=Index-0rZUl0Zh.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.