PageSourceSearch

https://linoyts-qwen-image-2-1-move.hf.space/assets/Index-CnMXw2NO.js

js linoyts-qwen-image-2-1-move.hf.space collected 2026-10-03 17:05:12 UTC 15,166 bytes, 575 lines download raw bytes

1import { i as if_block, k as each, d as bind_this, b as set_class, u as index, a as set_attribute, t as remove_input_defaults, g as spread_props, r as rest_props } from './i18n-CMo5lpzy.js';
2import { a as append, f as from_svg, R as push, u as state, v as proxy, y as user_effect, w as get, x as set, a7 as text, t as template_effect, Z as event, T as pop, a5 as user_derived, X as sibling, V as child, W as from_html, at as to_array, a0 as set_text, a8 as next, Y as reset, S as first_child } from './index-BvBk1Iap.js';
3import { G as Gradio } from './utils.svelte-CYLB_jIA.js';
4import { b as bind_value } from './input-C317uaXR.js';
5import { p as preventDefault } from './event-modifiers-DanhKw3_.js';
6import './ScrollFade.svelte_svelte_type_style_lang-Xm-PLg9E.js';
7import { B as BlockTitle } from './BlockTitle-7XQ-8ENg.js';
8import { D as DropdownArrow } from './DropdownArrow-Dw1NZKCM.js';
9import { I as IconButtonWrapper } from './IconButtonWrapper-Ba0GidgU.js';
10import { D as DropdownOptions, h as handle_shared_keys, a as handle_filter, b as Dropdown } from './Dropdown-DUCTuRQm.js';
11import { B as Block } from './Block-Bx3BikCN.js';
12import { S as Static } from './index-Lz7fsHFt.js';
13import './StreamingBar.svelte_svelte_type_style_lang-CdFIGsJa.js';
14export { default as BaseExample } from './Example-t0cB3HBf.js';
15import './clone-DaB-S2nH.js';
16import './snippet-Bl5YVoCg.js';
17import './Info-BrkJhX6_.js';
18import './html-CdUEtR5E.js';
19import './window-BGXjFJtG.js';
20import './Clear-Dgs5UhTO.js';
21import './index-C7e-J7CF.js';
22/* empty css                                               */
23
24var root$1 = from_svg(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="100%" height="100%"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"></path></svg>`);
25
26function Remove($$anchor) {
27	var svg = root$1();
28
29	append($$anchor, svg);
30}
31
32var root_6 = from_html(`<div class="token-remove svelte-1dv2vbb" role="button" tabindex="0"><!></div>`);
33var root_3 = from_html(`<div class="token svelte-1dv2vbb"><span class="svelte-1dv2vbb"><!></span> <!></div>`);
34var root_8 = from_html(`<div role="button" tabindex="0" class="token-remove remove-all svelte-1dv2vbb"><!></div>`);
35var root_7 = from_html(`<!> <span class="icon-wrap svelte-1dv2vbb"><!></span>`, 1);
36var root = from_html(`<div><!> <!> <div class="wrap svelte-1dv2vbb"><div><!> <div class="secondary-wrap svelte-1dv2vbb"><input autocomplete="off"/> <!></div></div> <!></div></div>`);
37
38function Multiselect($$anchor, $$props) {
39	push($$props, true);
40	const gradio = $$props.gradio;
41	let filter_input;
42	let input_text = state("");
43	let label = user_derived(() => gradio.shared.label || "Multiselect");
44	let buttons = user_derived(() => gradio.props.buttons);
45
46	let choices_names = user_derived(() => {
47		return gradio.props.choices.map((c) => c[0]);
48	});
49
50	let choices_values = user_derived(() => {
51		return gradio.props.choices.map((c) => c[1]);
52	});
53
54	let disabled = user_derived(() => !gradio.shared.interactive);
55	let show_options = state(false);
56
57	// All of these are indices with respect to the choices array
58	let $$d = user_derived(() => {
59			const filtered = handle_filter(gradio.props.choices, get(input_text));
60
61			return [
62				filtered,
63				filtered.length > 0 && !gradio.props.allow_custom_value ? filtered[0] : null
64			];
65		}),
66		$$array = user_derived(() => to_array(get($$d), 2)),
67		filtered_indices = user_derived(() => get($$array)[0]),
68		active_index = user_derived(() => get($$array)[1]);
69
70	function set_selected_indices() {
71		if (gradio.props.value === undefined) {
72			return [];
73		} else if (Array.isArray(gradio.props.value)) {
74			return gradio.props.value.map((v) => {
75				const index = get(choices_values).indexOf(v);
76
77				if (index !== -1) {
78					return index;
79				}
80
81				if (gradio.props.allow_custom_value) {
82					return v;
83				}
84
85				// Instead of returning null, skip this iteration
86				return undefined;
87			}).filter((val) => val !== undefined);
88		}
89
90		return [];
91	}
92
93	let selected_indices = user_derived(set_selected_indices);
94
95	function handle_blur() {
96		if (!gradio.props.allow_custom_value) {
97			set(input_text, "");
98		}
99
100		if (gradio.props.allow_custom_value && get(input_text) !== "") {
101			add_selected_choice(get(input_text));
102			set(input_text, "");
103		}
104
105		gradio.dispatch("blur");
106		set(show_options, false);
107		set(active_index, null);
108	}
109
110	function remove_selected_choice(option_index) {
111		set(selected_indices, get(selected_indices).filter((v) => v !== option_index));
112		gradio.props.value = get(selected_indices).map((index) => typeof index === "number" ? get(choices_values)[index] : index);
113		gradio.dispatch("input");
114
115		gradio.dispatch("select", {
116			index: typeof option_index === "number" ? option_index : -1,
117			value: typeof option_index === "number" ? get(choices_values)[option_index] : option_index,
118			selected: false
119		});
120	}
121
122	function add_selected_choice(option_index) {
123		if (gradio.props.max_choices == null || get(selected_indices).length < gradio.props.max_choices) {
124			get(selected_indices).push(option_index);
125
126			gradio.dispatch("select", {
127				index: typeof option_index === "number" ? option_index : -1,
128				value: typeof option_index === "number" ? get(choices_values)[option_index] : option_index,
129				selected: true
130			});
131		}
132
133		if (get(selected_indices).length === gradio.props.max_choices) {
134			set(show_options, false);
135			set(active_index, null);
136			filter_input.blur();
137		}
138
139		gradio.props.value = get(selected_indices).map((index) => typeof index === "number" ? get(choices_values)[index] : index);
140	}
141
142	function handle_option_selected(index) {
143		const option_index = parseInt(index);
144
145		add_or_remove_index(option_index);
146	}
147
148	function add_or_remove_index(option_index) {
149		if (get(selected_indices).includes(option_index)) {
150			remove_selected_choice(option_index);
151		} else {
152			add_selected_choice(option_index);
153		}
154
155		set(input_text, "");
156		set(active_index, null);
157		gradio.dispatch("input");
158	}
159
160	function remove_all(e) {
161		set(selected_indices, []);
162		set(input_text, "");
163		gradio.props.value = [];
164		e.preventDefault();
165	}
166
167	function handle_focus(e) {
168		set(filtered_indices, gradio.props.choices.map((_, i) => i));
169
170		if (gradio.props.max_choices === null || get(selected_indices).length < gradio.props.max_choices) {
171			set(show_options, true);
172		}
173
174		gradio.dispatch("focus");
175		set(show_options, true);
176	}
177
178	function handle_key_down(e) {
179		(($$value) => {
180			var $$array_1 = to_array($$value, 2);
181
182			set(show_options, $$array_1[0], true);
183			set(active_index, $$array_1[1]);
184		})(handle_shared_keys(e, get(active_index), get(filtered_indices)));
185
186		if (e.key === "Enter") {
187			if (get(active_index) !== null) {
188				add_or_remove_index(get(active_index));
189			} else {
190				if (gradio.props.allow_custom_value) {
191					add_selected_choice(get(input_text));
192					set(input_text, "");
193				}
194			}
195		}
196
197		if (e.key === "Backspace" && get(input_text) === "") {
198			set(selected_indices, [...get(selected_indices).slice(0, -1)]);
199		}
200
201		if (get(selected_indices).length === gradio.props.max_choices) {
202			set(show_options, false);
203			set(active_index, null);
204		}
205	}
206
207	let old_value = state(proxy(gradio.props.value));
208
209	user_effect(() => {
210		if (get(old_value) !== gradio.props.value) {
211			set(old_value, gradio.props.value, true);
212			gradio.dispatch("change");
213		}
214	});
215
216	function oncustom_button_click(id) {
217		gradio.dispatch("custom_button_click", { id });
218	}
219
220	var div = root();
221	let classes;
222	var node = child(div);
223
224	{
225		var consequent = ($$anchor) => {
226			IconButtonWrapper($$anchor, {
227				get buttons() {
228					return get(buttons);
229				},
230				on_custom_button_click: oncustom_button_click
231			});
232		};
233
234		if_block(node, ($$render) => {
235			if (gradio.shared.show_label && get(buttons) && get(buttons).length > 0) $$render(consequent);
236		});
237	}
238
239	var node_1 = sibling(node, 2);
240
241	BlockTitle(node_1, {
242		get show_label() {
243			return gradio.shared.show_label;
244		},
245
246		get info() {
247			return gradio.props.info;
248		},
249
250		children: ($$anchor, $$slotProps) => {
251			next();
252
253			var text$1 = text();
254
255			template_effect(() => set_text(text$1, get(label)));
256			append($$anchor, text$1);
257		},
258		$$slots: { default: true }
259	});
260
261	var div_1 = sibling(node_1, 2);
262	var div_2 = child(div_1);
263	let classes_1;
264	var node_2 = child(div_2);
265
266	each(node_2, 17, () => get(selected_indices), index, ($$anchor, s) => {
267		var div_3 = root_3();
268		var span = child(div_3);
269		var node_3 = child(span);
270
271		{
272			var consequent_1 = ($$anchor) => {
273				var text_1 = text();
274
275				template_effect(() => set_text(text_1, get(choices_names)[get(s)]));
276				append($$anchor, text_1);
277			};
278
279			var alternate = ($$anchor) => {
280				var text_2 = text();
281
282				template_effect(() => set_text(text_2, get(s)));
283				append($$anchor, text_2);
284			};
285
286			if_block(node_3, ($$render) => {
287				if (typeof get(s) === "number") $$render(consequent_1); else $$render(alternate, false);
288			});
289		}
290
291		reset(span);
292
293		var node_4 = sibling(span, 2);
294
295		{
296			var consequent_2 = ($$anchor) => {
297				var div_4 = root_6();
298				var node_5 = child(div_4);
299
300				Remove(node_5);
301				reset(div_4);
302				template_effect(($0) => set_attribute(div_4, 'title', $0), [() => gradio.i18n("common.remove") + " " + get(s)]);
303				event('click', div_4, preventDefault(() => remove_selected_choice(get(s))));
304
305				event('keydown', div_4, (event) => {
306					if (event.key === "Enter") {
307						remove_selected_choice(get(s));
308					}
309				});
310
311				append($$anchor, div_4);
312			};
313
314			if_block(node_4, ($$render) => {
315				if (!get(disabled)) $$render(consequent_2);
316			});
317		}
318
319		reset(div_3);
320		append($$anchor, div_3);
321	});
322
323	var div_5 = sibling(node_2, 2);
324	var input = child(div_5);
325
326	remove_input_defaults(input);
327
328	let classes_2;
329
330	bind_this(input, ($$value) => filter_input = $$value, () => filter_input);
331
332	var node_6 = sibling(input, 2);
333
334	{
335		var consequent_4 = ($$anchor) => {
336			var fragment_4 = root_7();
337			var node_7 = first_child(fragment_4);
338
339			{
340				var consequent_3 = ($$anchor) => {
341					var div_6 = root_8();
342					var node_8 = child(div_6);
343
344					Remove(node_8);
345					reset(div_6);
346					template_effect(($0) => set_attribute(div_6, 'title', $0), [() => gradio.i18n("common.clear")]);
347					event('click', div_6, remove_all);
348
349					event('keydown', div_6, (event) => {
350						if (event.key === "Enter") {
351							remove_all(event);
352						}
353					});
354
355					append($$anchor, div_6);
356				};
357
358				if_block(node_7, ($$render) => {
359					if (get(selected_indices).length > 0) $$render(consequent_3);
360				});
361			}
362
363			var span_1 = sibling(node_7, 2);
364			var node_9 = child(span_1);
365
366			DropdownArrow(node_9);
367			reset(span_1);
368			append($$anchor, fragment_4);
369		};
370
371		if_block(node_6, ($$render) => {
372			if (!get(disabled)) $$render(consequent_4);
373		});
374	}
375
376	reset(div_5);
377	reset(div_2);
378
379	var node_10 = sibling(div_2, 2);
380
381	DropdownOptions(node_10, {
382		get show_options() {
383			return get(show_options);
384		},
385
386		get choices() {
387			return gradio.props.choices;
388		},
389
390		get filtered_indices() {
391			return get(filtered_indices);
392		},
393
394		get disabled() {
395			return get(disabled);
396		},
397
398		get selected_indices() {
399			return get(selected_indices);
400		},
401
402		get active_index() {
403			return get(active_index);
404		},
405		remember_scroll: true,
406		onchange: handle_option_selected
407	});
408
409	reset(div_1);
410	reset(div);
411
412	template_effect(
413		($0) => {
414			classes = set_class(div, 1, 'svelte-1dv2vbb', null, classes, { container: gradio.shared.container });
415			classes_1 = set_class(div_2, 1, 'wrap-inner svelte-1dv2vbb', null, classes_1, { show_options: get(show_options) });
416			classes_2 = set_class(input, 1, 'border-none svelte-1dv2vbb', null, classes_2, $0);
417			input.disabled = get(disabled);
418			input.readOnly = !gradio.props.filterable;
419		},
420		[
421			() => ({
422				subdued: !get(choices_names).includes(get(input_text)) && !gradio.props.allow_custom_value || get(selected_indices).length === gradio.props.max_choices
423			})
424		]
425	);
426
427	bind_value(input, () => get(input_text), ($$value) => set(input_text, $$value));
428	event('keydown', input, handle_key_down);
429
430	event('keyup', input, (e) => {
431		gradio.dispatch("key_up", { key: e.key, input_value: get(input_text) });
432	});
433
434	event('blur', input, handle_blur);
435	event('focus', input, handle_focus);
436	append($$anchor, div);
437	pop();
438}
439
440var root_1 = from_html(`<!> <!>`, 1);
441
442function Index($$anchor, $$props) {
443	push($$props, true);
444
445	let props = rest_props($$props, ['$$slots', '$$events', '$$legacy']);
446	const gradio = new Gradio(props);
447
448	Block($$anchor, {
449		get visible() {
450			return gradio.shared.visible;
451		},
452
453		get elem_id() {
454			return gradio.shared.elem_id;
455		},
456
457		get elem_classes() {
458			return gradio.shared.elem_classes;
459		},
460
461		get padding() {
462			return gradio.shared.container;
463		},
464		allow_overflow: false,
465		get scale() {
466			return gradio.shared.scale;
467		},
468
469		get min_width() {
470			return gradio.shared.min_width;
471		},
472
473		children: ($$anchor, $$slotProps) => {
474			var fragment_1 = root_1();
475			var node = first_child(fragment_1);
476
477			Static(node, spread_props(
478				{
479					get autoscroll() {
480						return gradio.shared.autoscroll;
481					},
482
483					get i18n() {
484						return gradio.i18n;
485					}
486				},
487				() => gradio.shared.loading_status,
488				{
489					on_clear_status: () => gradio.dispatch("clear_status", loading_status)
490				}
491			));
492
493			var node_1 = sibling(node, 2);
494
495			{
496				var consequent = ($$anchor) => {
497					Multiselect($$anchor, {
498						get gradio() {
499							return gradio;
500						}
501					});
502				};
503
504				var alternate = ($$anchor) => {
505					Dropdown($$anchor, {
506						get label() {
507							return gradio.shared.label;
508						},
509
510						get info() {
511							return gradio.props.info;
512						},
513
514						get choices() {
515							return gradio.props.choices;
516						},
517
518						get interactive() {
519							return gradio.shared.interactive;
520						},
521
522						get show_label() {
523							return gradio.shared.show_label;
524						},
525
526						get container() {
527							return gradio.shared.container;
528						},
529
530						get allow_custom_value() {
531							return gradio.props.allow_custom_value;
532						},
533
534						get filterable() {
535							return gradio.props.filterable;
536						},
537
538						get buttons() {
539							return gradio.props.buttons;
540						},
541
542						oncustom_button_click: (id) => {
543							gradio.dispatch("custom_button_click", { id });
544						},
545						on_change: () => gradio.dispatch("change"),
546						on_input: () => gradio.dispatch("input"),
547						on_select: (data) => gradio.dispatch("select", data),
548						on_focus: () => gradio.dispatch("focus"),
549						on_blur: () => gradio.dispatch("blur"),
550						on_key_up: (data) => gradio.dispatch("key_up", data),
551						get value() {
552							return gradio.props.value;
553						},
554
555						set value($$value) {
556							gradio.props.value = $$value;
557						}
558					});
559				};
560
561				if_block(node_1, ($$render) => {
562					if (gradio.props.multiselect) $$render(consequent); else $$render(alternate, false);
563				});
564			}
565
566			append($$anchor, fragment_1);
567		},
568		$$slots: { default: true }
569	});
570
571	pop();
572}
573
574export { Dropdown as BaseDropdown, DropdownOptions as BaseDropdownOptions, Multiselect as BaseMultiselect, Index as default };
575//# sourceMappingURL=Index-CnMXw2NO.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.