PageSourceSearch

https://juliandisalvoperez-tribe-v2-neural-activity-predictor.hf.space/assets/state.svelte-C1bUJRNp.js

js juliandisalvoperez-tribe-v2-neural-activity-predictor.hf.space collected 2026-10-03 17:00:45 UTC 5,108 bytes, 218 lines download raw bytes

1import { p as prop, k as each, m as setup_stores, f as set_style, q as store_get } from './i18n-dpAHICcw.js';
2import { R as push, u as state, v as proxy, y as user_effect, x as set, t as template_effect, a as append, T as pop, W as from_html, w as get, V as child, Y as reset } from './index-CDZuCcOm.js';
3import { T as ToastContent } from './StreamingBar.svelte_svelte_type_style_lang-BxBb9ZZb.js';
4import { s as spring } from './index-DyDpuTN9.js';
5
6var root_1 = from_html(`<div class="toast-item svelte-1qhecvt"><!></div>`);
7var root = from_html(`<div class="toast-wrap svelte-1qhecvt"></div>`);
8
9function Toast($$anchor, $$props) {
10	push($$props, true);
11
12	const $top = () => store_get(top, '$top', $$stores);
13	const [$$stores, $$cleanup] = setup_stores();
14	let messages = prop($$props, 'messages', 19, () => []);
15	const top = spring(0, { stiffness: 0.4, damping: 0.5 });
16	let grouped_messages = state(proxy([]));
17
18	user_effect(() => {
19		scroll_to_top(messages());
20	});
21
22	user_effect(() => {
23		set(grouped_messages, group_messages(messages()), true);
24	});
25
26	function group_messages(msgs) {
27		const groups = new Map();
28
29		msgs.forEach((msg) => {
30			const key = msg.type;
31
32			if (!groups.has(key)) {
33				groups.set(key, { type: msg.type, messages: [], expanded: true });
34			}
35
36			groups.get(key).messages.push(msg);
37		});
38
39		return Array.from(groups.values());
40	}
41
42	function scroll_to_top(_messages) {
43		if (_messages.length > 0) {
44			if ("parentIFrame" in window) {
45				window.parentIFrame?.getPageInfo((page_info) => {
46					if (page_info.scrollTop < page_info.offsetTop) {
47						top.set(0);
48					} else {
49						top.set(page_info.scrollTop - page_info.offsetTop);
50					}
51				});
52			}
53		}
54	}
55
56	function toggle_group(type) {
57		set(
58			grouped_messages,
59			get(grouped_messages).map((group) => {
60				if (group.type === type) {
61					return { ...group, expanded: !group.expanded };
62				}
63
64				return group;
65			}),
66			true
67		);
68	}
69
70	var div = root();
71
72	each(div, 21, () => get(grouped_messages), (group) => group.type, ($$anchor, group) => {
73		var div_1 = root_1();
74		var node = child(div_1);
75
76		ToastContent(node, {
77			get type() {
78				return get(group).type;
79			},
80
81			get messages() {
82				return get(group).messages;
83			},
84
85			get expanded() {
86				return get(group).expanded;
87			},
88			ontoggle: () => toggle_group(get(group).type),
89			onclose: (id) => $$props.on_close(id)
90		});
91
92		reset(div_1);
93		append($$anchor, div_1);
94	});
95
96	reset(div);
97	template_effect(() => set_style(div, `--toast-top: ${$top() ?? ''}px;`));
98	append($$anchor, div);
99	pop();
100	$$cleanup();
101}
102
103/* state.svelte.ts generated by Svelte v5.48.0 */
104
105class LoadingStatus {
106	current = {};
107	fn_outputs = {};
108	fn_inputs = {};
109	pending_outputs = /* @__PURE__ */ new Map();
110	fn_status = {};
111	show_progress = {};
112
113	register(dependency_id, outputs, inputs, show_progress) {
114		this.fn_outputs[dependency_id] = outputs;
115		this.fn_inputs[dependency_id] = inputs;
116		this.show_progress[dependency_id] = show_progress;
117	}
118
119	clear(id) {
120		if (id in this.current) {
121			this.current[id] = {};
122		}
123	}
124
125	update(args) {
126		const updates = this.resolve_args(args);
127
128		updates.forEach((
129			{
130				id,
131				queue_position,
132				queue_size,
133				eta,
134				status,
135				message,
136				progress,
137				stream_state,
138				time_limit,
139				type
140			}
141		) => {
142			this.current[id] = {
143				queue: args.queue || false,
144				queue_size,
145				queue_position,
146				eta,
147				stream_state,
148				message,
149				progress: progress || void 0,
150				status,
151				fn_index: args.fn_index,
152				time_limit,
153				type,
154				show_progress: this.show_progress[args.fn_index]
155			};
156		});
157	}
158
159	set_status(id, status) {
160		this.current[id].status = status;
161	}
162
163	resolve_args(args) {
164		const {
165			fn_index,
166			status,
167			size = void 0,
168			position = null,
169			eta = null,
170			message = null,
171			stream_state = null,
172			time_limit = null,
173			progress_data = null
174		} = args;
175
176		const outputs = this.fn_outputs[fn_index];
177		const last_status = this.fn_status[fn_index];
178		const inputs = this.fn_inputs[fn_index];
179		const all_ids = outputs.concat(inputs);
180
181		return all_ids.map((id) => {
182			let new_status;
183			const pending_count = this.pending_outputs.get(id) || 0;
184
185			if (last_status === "pending" && status !== "pending") {
186				let new_count = pending_count - 1;
187
188				this.pending_outputs.set(id, new_count < 0 ? 0 : new_count);
189				new_status = new_count > 0 ? "pending" : status;
190			} else if (last_status === "pending" && status === "pending") {
191				new_status = "pending";
192			} else if (last_status !== "pending" && status === "pending") {
193				new_status = "pending";
194				this.pending_outputs.set(id, pending_count + 1);
195			} else {
196				new_status = status;
197			}
198
199			const type = inputs.includes(id) && stream_state ? "input" : outputs.includes(id) ? "output" : "skip";
200
201			return {
202				id,
203				queue_position: position,
204				queue_size: size,
205				eta,
206				status: new_status,
207				message,
208				progress: progress_data,
209				stream_state,
210				time_limit,
211				type
212			};
213		}).filter((update) => update.type !== "skip");
214	}
215}
216
217export { LoadingStatus as L, Toast as T };
218//# sourceMappingURL=state.svelte-C1bUJRNp.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.