vetra-toast 1.0.2 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/animations/index.d.ts +0 -1
  2. package/dist/components/ToastIcon.d.ts +0 -1
  3. package/dist/components/ToastItem.d.ts +24 -22
  4. package/dist/components/ToastProgress.d.ts +0 -1
  5. package/dist/components/Toaster.d.ts +0 -1
  6. package/dist/core/index.d.ts +0 -1
  7. package/dist/core/store.d.ts +2 -23
  8. package/dist/core/timer.d.ts +0 -1
  9. package/dist/core/toast-api.d.ts +0 -1
  10. package/dist/core-BikVsncn.js +1 -0
  11. package/dist/core-DWP-MMiI.cjs +1 -0
  12. package/dist/core.cjs +1 -9
  13. package/dist/core.js +1 -1
  14. package/dist/hooks/use-mounted.d.ts +0 -1
  15. package/dist/hooks/use-swipe.d.ts +0 -1
  16. package/dist/hooks/use-system-theme.d.ts +0 -1
  17. package/dist/hooks/use-toasts.d.ts +0 -1
  18. package/dist/index.cjs +1 -1057
  19. package/dist/index.d.ts +0 -1
  20. package/dist/index.js +1 -1043
  21. package/dist/styles.css +1 -1419
  22. package/dist/types/index.d.ts +0 -1
  23. package/dist/utils/dom.d.ts +0 -1
  24. package/dist/utils/feedback.d.ts +0 -1
  25. package/dist/utils/id.d.ts +0 -1
  26. package/dist/utils/merge.d.ts +0 -1
  27. package/package.json +1 -1
  28. package/dist/animations/index.d.ts.map +0 -1
  29. package/dist/components/ToastIcon.d.ts.map +0 -1
  30. package/dist/components/ToastItem.d.ts.map +0 -1
  31. package/dist/components/ToastProgress.d.ts.map +0 -1
  32. package/dist/components/Toaster.d.ts.map +0 -1
  33. package/dist/core/index.d.ts.map +0 -1
  34. package/dist/core/store.d.ts.map +0 -1
  35. package/dist/core/timer.d.ts.map +0 -1
  36. package/dist/core/toast-api.d.ts.map +0 -1
  37. package/dist/core-CqZy4LyN.cjs +0 -893
  38. package/dist/core-CqZy4LyN.cjs.map +0 -1
  39. package/dist/core-KMoYj72S.js +0 -804
  40. package/dist/core-KMoYj72S.js.map +0 -1
  41. package/dist/hooks/use-mounted.d.ts.map +0 -1
  42. package/dist/hooks/use-swipe.d.ts.map +0 -1
  43. package/dist/hooks/use-system-theme.d.ts.map +0 -1
  44. package/dist/hooks/use-toasts.d.ts.map +0 -1
  45. package/dist/index.cjs.map +0 -1
  46. package/dist/index.d.ts.map +0 -1
  47. package/dist/index.js.map +0 -1
  48. package/dist/types/index.d.ts.map +0 -1
  49. package/dist/utils/dom.d.ts.map +0 -1
  50. package/dist/utils/feedback.d.ts.map +0 -1
  51. package/dist/utils/id.d.ts.map +0 -1
  52. package/dist/utils/merge.d.ts.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,1057 +1 @@
1
- "use client";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const require_core = require("./core-CqZy4LyN.cjs");
4
- let react = require("react");
5
- let react_dom = require("react-dom");
6
- let react_jsx_runtime = require("react/jsx-runtime");
7
- // src/hooks/use-mounted.ts
8
- var emptySubscribe = () => () => {};
9
- var getClientSnapshot = () => true;
10
- var getServerSnapshot = () => false;
11
- function useMounted() {
12
- return (0, react.useSyncExternalStore)(emptySubscribe, getClientSnapshot, getServerSnapshot);
13
- }
14
- // src/utils/dom.ts
15
- function isBrowser() {
16
- return typeof window !== "undefined" && typeof document !== "undefined";
17
- }
18
- function getSystemColorScheme() {
19
- if (!isBrowser() || typeof window.matchMedia !== "function") return "dark";
20
- return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
21
- }
22
- // src/hooks/use-system-theme.ts
23
- function useResolvedTheme(theme) {
24
- const [systemTheme, setSystemTheme] = (0, react.useState)(() => theme === "system" ? getSystemColorScheme() : theme);
25
- (0, react.useEffect)(() => {
26
- if (theme !== "system" || !isBrowser() || typeof window.matchMedia !== "function") return;
27
- const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
28
- const sync = () => {
29
- setSystemTheme(mediaQuery.matches ? "dark" : "light");
30
- };
31
- sync();
32
- if (typeof mediaQuery.addEventListener === "function") {
33
- mediaQuery.addEventListener("change", sync);
34
- return () => {
35
- mediaQuery.removeEventListener("change", sync);
36
- };
37
- }
38
- mediaQuery.addListener(sync);
39
- return () => {
40
- mediaQuery.removeListener(sync);
41
- };
42
- }, [theme]);
43
- if (theme === "system") return systemTheme;
44
- return theme;
45
- }
46
- // src/hooks/use-toasts.ts
47
- function useToasts(store = require_core.defaultToastStore) {
48
- return (0, react.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getServerSnapshot);
49
- }
50
- // src/utils/feedback.ts
51
- var SOUND_PATTERNS = {
52
- success: [523.25, 659.25],
53
- error: [311.13, 246.94],
54
- warning: [440, 392],
55
- info: [587.33],
56
- loading: [493.88],
57
- default: [523.25],
58
- custom: [523.25]
59
- };
60
- var HAPTIC_PATTERNS = {
61
- success: 18,
62
- error: [
63
- 28,
64
- 36,
65
- 28
66
- ],
67
- warning: [22, 28],
68
- info: 12,
69
- loading: 10,
70
- default: 12,
71
- custom: 12
72
- };
73
- var sharedAudioContext = null;
74
- function getAudioContext() {
75
- if (!isBrowser()) return null;
76
- const AudioCtx = window.AudioContext ?? window.webkitAudioContext;
77
- if (!AudioCtx) return null;
78
- try {
79
- if (!sharedAudioContext || sharedAudioContext.state === "closed") sharedAudioContext = new AudioCtx();
80
- return sharedAudioContext;
81
- } catch {
82
- return null;
83
- }
84
- }
85
- function playToastSound(variant) {
86
- const ctx = getAudioContext();
87
- if (!ctx) return;
88
- try {
89
- if (ctx.state === "suspended") ctx.resume().catch(() => {});
90
- const notes = SOUND_PATTERNS[variant] ?? SOUND_PATTERNS.default;
91
- const now = ctx.currentTime;
92
- notes.forEach((freq, idx) => {
93
- const osc = ctx.createOscillator();
94
- const gain = ctx.createGain();
95
- const start = now + idx * .085;
96
- const end = start + .14;
97
- osc.type = variant === "error" ? "triangle" : "sine";
98
- osc.frequency.setValueAtTime(freq, start);
99
- gain.gain.setValueAtTime(1e-4, start);
100
- gain.gain.exponentialRampToValueAtTime(.045, start + .015);
101
- gain.gain.exponentialRampToValueAtTime(1e-4, end);
102
- osc.connect(gain);
103
- gain.connect(ctx.destination);
104
- osc.start(start);
105
- osc.stop(end + .01);
106
- });
107
- } catch {}
108
- }
109
- function triggerToastHaptic(variant) {
110
- if (!isBrowser() || typeof navigator === "undefined" || typeof navigator.vibrate !== "function") return;
111
- try {
112
- navigator.vibrate(HAPTIC_PATTERNS[variant] ?? 12);
113
- } catch {}
114
- }
115
- // src/hooks/use-swipe.ts
116
- var INITIAL_SWIPE_STATE = {
117
- isSwiping: false,
118
- offsetX: 0,
119
- offsetY: 0,
120
- opacity: 1
121
- };
122
- function isInteractiveTarget(target) {
123
- if (!(target instanceof Element)) return false;
124
- return target.closest("button, a, input, textarea, select, [data-vt-no-swipe]") !== null;
125
- }
126
- function useSwipe({ enabled, position, directions, onSwipeStart, onSwipeCancel, onDismiss }) {
127
- const [swipeState, setSwipeState] = (0, react.useState)(INITIAL_SWIPE_STATE);
128
- const dragRef = (0, react.useRef)(null);
129
- const allowedDirections = directions && directions.length > 0 ? directions : require_core.getDefaultSwipeDirections(position);
130
- const allowLeft = allowedDirections.includes("left");
131
- const allowRight = allowedDirections.includes("right");
132
- const allowUp = allowedDirections.includes("up");
133
- const allowDown = allowedDirections.includes("down");
134
- const supportsX = allowLeft || allowRight;
135
- const supportsY = allowUp || allowDown;
136
- const computeDismissOffset = (0, react.useCallback)((dx, dy, axis) => {
137
- if (axis === "x") {
138
- const isAligned = dx > 0 && allowRight || dx < 0 && allowLeft;
139
- return {
140
- offsetX: isAligned ? dx : dx * require_core.SWIPE_DRAG_DAMPENING,
141
- offsetY: 0,
142
- primaryDelta: isAligned ? Math.abs(dx) : 0
143
- };
144
- }
145
- const isAligned = dy < 0 && allowUp || dy > 0 && allowDown;
146
- return {
147
- offsetX: 0,
148
- offsetY: isAligned ? dy : dy * require_core.SWIPE_DRAG_DAMPENING,
149
- primaryDelta: isAligned ? Math.abs(dy) : 0
150
- };
151
- }, [
152
- allowDown,
153
- allowLeft,
154
- allowRight,
155
- allowUp
156
- ]);
157
- const resetSwipe = (0, react.useCallback)((notifyCancel) => {
158
- dragRef.current = null;
159
- setSwipeState(INITIAL_SWIPE_STATE);
160
- if (notifyCancel) onSwipeCancel?.();
161
- }, [onSwipeCancel]);
162
- return {
163
- swipeState,
164
- handlers: {
165
- onPointerDown: (0, react.useCallback)((event) => {
166
- if (!enabled || event.button !== 0 || isInteractiveTarget(event.target)) return;
167
- dragRef.current = {
168
- pointerId: event.pointerId,
169
- startX: event.clientX,
170
- startY: event.clientY,
171
- startTime: Date.now(),
172
- active: false,
173
- lockedAxis: null
174
- };
175
- if (typeof event.currentTarget.setPointerCapture === "function") try {
176
- event.currentTarget.setPointerCapture(event.pointerId);
177
- } catch {}
178
- }, [enabled]),
179
- onPointerMove: (0, react.useCallback)((event) => {
180
- const drag = dragRef.current;
181
- if (!drag || drag.pointerId !== event.pointerId) return;
182
- const dx = event.clientX - drag.startX;
183
- const dy = event.clientY - drag.startY;
184
- const absX = Math.abs(dx);
185
- const absY = Math.abs(dy);
186
- if (!drag.lockedAxis) {
187
- if (Math.max(absX, absY) < 6) return;
188
- if (supportsX && supportsY) drag.lockedAxis = absX >= absY ? "x" : "y";
189
- else drag.lockedAxis = supportsX ? "x" : "y";
190
- }
191
- const movement = drag.lockedAxis === "x" ? absX : absY;
192
- if (!drag.active && movement < 6) return;
193
- if (!drag.active) {
194
- drag.active = true;
195
- onSwipeStart?.();
196
- }
197
- const { offsetX, offsetY, primaryDelta } = computeDismissOffset(dx, dy, drag.lockedAxis);
198
- const progress = Math.min(1, Math.max(0, primaryDelta / 126));
199
- setSwipeState({
200
- isSwiping: true,
201
- offsetX,
202
- offsetY,
203
- opacity: Math.max(.25, 1 - progress * .7)
204
- });
205
- }, [
206
- computeDismissOffset,
207
- onSwipeStart,
208
- supportsX,
209
- supportsY
210
- ]),
211
- onPointerUp: (0, react.useCallback)((event) => {
212
- const drag = dragRef.current;
213
- if (!drag || drag.pointerId !== event.pointerId) return;
214
- if (typeof event.currentTarget.releasePointerCapture === "function") try {
215
- if (event.currentTarget.hasPointerCapture?.(event.pointerId)) event.currentTarget.releasePointerCapture(event.pointerId);
216
- } catch {}
217
- if (!drag.active || !drag.lockedAxis) {
218
- dragRef.current = null;
219
- return;
220
- }
221
- const dx = event.clientX - drag.startX;
222
- const dy = event.clientY - drag.startY;
223
- const elapsed = Math.max(1, Date.now() - drag.startTime);
224
- const { primaryDelta } = computeDismissOffset(dx, dy, drag.lockedAxis);
225
- const velocity = primaryDelta / elapsed;
226
- if (primaryDelta >= 84 || velocity >= .45) {
227
- dragRef.current = null;
228
- setSwipeState(INITIAL_SWIPE_STATE);
229
- onDismiss();
230
- } else resetSwipe(true);
231
- }, [
232
- computeDismissOffset,
233
- onDismiss,
234
- resetSwipe
235
- ]),
236
- onPointerCancel: (0, react.useCallback)((event) => {
237
- const drag = dragRef.current;
238
- if (!drag || drag.pointerId !== event.pointerId) return;
239
- resetSwipe(drag.active);
240
- }, [resetSwipe])
241
- }
242
- };
243
- }
244
- // src/components/ToastIcon.tsx
245
- function ToastIcon({ variant, icon, animationMode = "default", className }) {
246
- const uid = (0, react.useId)();
247
- if (icon === null) return null;
248
- if (icon !== void 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
249
- className: require_core.cx("vt-icon-badge vt-icon-badge-custom", className),
250
- "data-vt-icon": "",
251
- "data-vt-icon-animation": animationMode,
252
- "aria-hidden": "true",
253
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
254
- className: "vt-icon-inner",
255
- children: icon
256
- })
257
- });
258
- if (variant === "default" || variant === "custom") return null;
259
- const gradId = `vt-grad-${uid}`;
260
- const glowId = `vt-glow-${uid}`;
261
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
262
- className: require_core.cx("vt-icon-badge", className),
263
- "data-vt-icon": "",
264
- "data-vt-variant": variant,
265
- "data-vt-icon-animation": animationMode,
266
- "aria-hidden": "true",
267
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
268
- className: "vt-icon-pulse",
269
- "aria-hidden": "true"
270
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
271
- className: "vt-icon-inner",
272
- children: [
273
- variant === "success" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
274
- viewBox: "0 0 24 24",
275
- fill: "none",
276
- className: "vt-svg vt-svg-success",
277
- focusable: "false",
278
- "aria-hidden": "true",
279
- children: [
280
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("defs", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("linearGradient", {
281
- id: gradId,
282
- x1: "4",
283
- y1: "4",
284
- x2: "20",
285
- y2: "20",
286
- gradientUnits: "userSpaceOnUse",
287
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
288
- offset: "0%",
289
- stopColor: "currentColor",
290
- stopOpacity: "1"
291
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
292
- offset: "100%",
293
- stopColor: "#a7f3d0",
294
- stopOpacity: "0.95"
295
- })]
296
- }) }),
297
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
298
- cx: "12",
299
- cy: "12",
300
- r: "8.75",
301
- fill: "currentColor",
302
- className: "vt-success-fill"
303
- }),
304
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
305
- cx: "12",
306
- cy: "12",
307
- r: "8.75",
308
- stroke: `url(#${gradId})`,
309
- strokeWidth: "1.75",
310
- strokeLinecap: "round",
311
- pathLength: 100,
312
- className: "vt-success-ring"
313
- }),
314
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
315
- d: "M8.1 12.35L10.75 15L16.1 9.35",
316
- stroke: `url(#${gradId})`,
317
- strokeWidth: "2.2",
318
- strokeLinecap: "round",
319
- strokeLinejoin: "round",
320
- pathLength: 100,
321
- className: "vt-success-check"
322
- }),
323
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
324
- cx: "4.2",
325
- cy: "4.8",
326
- r: "1.05",
327
- fill: "currentColor",
328
- className: "vt-spark vt-spark-1"
329
- }),
330
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
331
- cx: "19.8",
332
- cy: "4.8",
333
- r: "0.95",
334
- fill: "currentColor",
335
- className: "vt-spark vt-spark-2"
336
- }),
337
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
338
- cx: "20.2",
339
- cy: "18.8",
340
- r: "0.9",
341
- fill: "currentColor",
342
- className: "vt-spark vt-spark-3"
343
- }),
344
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
345
- cx: "4.2",
346
- cy: "18.8",
347
- r: "0.85",
348
- fill: "currentColor",
349
- className: "vt-spark vt-spark-4"
350
- })
351
- ]
352
- }),
353
- variant === "error" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
354
- viewBox: "0 0 24 24",
355
- fill: "none",
356
- className: "vt-svg vt-svg-error",
357
- focusable: "false",
358
- "aria-hidden": "true",
359
- children: [
360
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("defs", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("linearGradient", {
361
- id: gradId,
362
- x1: "4",
363
- y1: "4",
364
- x2: "20",
365
- y2: "20",
366
- gradientUnits: "userSpaceOnUse",
367
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
368
- offset: "0%",
369
- stopColor: "#fda4af",
370
- stopOpacity: "1"
371
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
372
- offset: "100%",
373
- stopColor: "currentColor",
374
- stopOpacity: "1"
375
- })]
376
- }) }),
377
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
378
- d: "M8.4 3.4H15.6L20.6 8.4V15.6L15.6 20.6H8.4L3.4 15.6V8.4L8.4 3.4Z",
379
- fill: "currentColor",
380
- className: "vt-error-fill"
381
- }),
382
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
383
- d: "M8.4 3.4H15.6L20.6 8.4V15.6L15.6 20.6H8.4L3.4 15.6V8.4L8.4 3.4Z",
384
- stroke: `url(#${gradId})`,
385
- strokeWidth: "1.75",
386
- strokeLinejoin: "round",
387
- pathLength: 100,
388
- className: "vt-error-frame"
389
- }),
390
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
391
- d: "M9.1 9.1L14.9 14.9",
392
- stroke: `url(#${gradId})`,
393
- strokeWidth: "2.15",
394
- strokeLinecap: "round",
395
- pathLength: 100,
396
- className: "vt-error-line-1"
397
- }),
398
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
399
- d: "M14.9 9.1L9.1 14.9",
400
- stroke: `url(#${gradId})`,
401
- strokeWidth: "2.15",
402
- strokeLinecap: "round",
403
- pathLength: 100,
404
- className: "vt-error-line-2"
405
- })
406
- ]
407
- }),
408
- variant === "warning" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
409
- viewBox: "0 0 24 24",
410
- fill: "none",
411
- className: "vt-svg vt-svg-warning",
412
- focusable: "false",
413
- "aria-hidden": "true",
414
- children: [
415
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("defs", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("linearGradient", {
416
- id: gradId,
417
- x1: "12",
418
- y1: "3",
419
- x2: "12",
420
- y2: "21",
421
- gradientUnits: "userSpaceOnUse",
422
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
423
- offset: "0%",
424
- stopColor: "#fde68a",
425
- stopOpacity: "1"
426
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
427
- offset: "100%",
428
- stopColor: "currentColor",
429
- stopOpacity: "1"
430
- })]
431
- }) }),
432
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
433
- d: "M10.42 4.65C11.12 3.43 12.88 3.43 13.58 4.65L20.38 16.45C21.08 17.67 20.2 19.2 18.8 19.2H5.2C3.8 19.2 2.92 17.67 3.62 16.45L10.42 4.65Z",
434
- fill: "currentColor",
435
- className: "vt-warning-fill"
436
- }),
437
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
438
- d: "M10.42 4.65C11.12 3.43 12.88 3.43 13.58 4.65L20.38 16.45C21.08 17.67 20.2 19.2 18.8 19.2H5.2C3.8 19.2 2.92 17.67 3.62 16.45L10.42 4.65Z",
439
- stroke: `url(#${gradId})`,
440
- strokeWidth: "1.75",
441
- strokeLinejoin: "round",
442
- pathLength: 100,
443
- className: "vt-warning-frame"
444
- }),
445
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
446
- d: "M12 9.1V13.15",
447
- stroke: `url(#${gradId})`,
448
- strokeWidth: "2.1",
449
- strokeLinecap: "round",
450
- pathLength: 100,
451
- className: "vt-warning-stem"
452
- }),
453
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
454
- cx: "12",
455
- cy: "16.1",
456
- r: "1.2",
457
- fill: `url(#${gradId})`,
458
- className: "vt-warning-dot"
459
- })
460
- ]
461
- }),
462
- variant === "info" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
463
- viewBox: "0 0 24 24",
464
- fill: "none",
465
- className: "vt-svg vt-svg-info",
466
- focusable: "false",
467
- "aria-hidden": "true",
468
- children: [
469
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("defs", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("linearGradient", {
470
- id: gradId,
471
- x1: "4",
472
- y1: "4",
473
- x2: "20",
474
- y2: "20",
475
- gradientUnits: "userSpaceOnUse",
476
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
477
- offset: "0%",
478
- stopColor: "#bae6fd",
479
- stopOpacity: "1"
480
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
481
- offset: "100%",
482
- stopColor: "currentColor",
483
- stopOpacity: "1"
484
- })]
485
- }) }),
486
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
487
- cx: "12",
488
- cy: "12",
489
- r: "8.75",
490
- fill: "currentColor",
491
- className: "vt-info-fill"
492
- }),
493
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
494
- cx: "12",
495
- cy: "12",
496
- r: "8.75",
497
- stroke: `url(#${gradId})`,
498
- strokeWidth: "1.75",
499
- pathLength: 100,
500
- className: "vt-info-ring"
501
- }),
502
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
503
- cx: "12",
504
- cy: "12",
505
- r: "8.75",
506
- stroke: "#ffffff",
507
- strokeWidth: "1.75",
508
- strokeLinecap: "round",
509
- strokeDasharray: "16 84",
510
- pathLength: 100,
511
- className: "vt-info-glint"
512
- }),
513
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
514
- cx: "12",
515
- cy: "8.25",
516
- r: "1.25",
517
- fill: `url(#${gradId})`,
518
- className: "vt-info-dot"
519
- }),
520
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
521
- d: "M12 11.2V16.1",
522
- stroke: `url(#${gradId})`,
523
- strokeWidth: "2.15",
524
- strokeLinecap: "round",
525
- pathLength: 100,
526
- className: "vt-info-stem"
527
- })
528
- ]
529
- }),
530
- variant === "loading" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
531
- viewBox: "0 0 24 24",
532
- fill: "none",
533
- className: "vt-svg vt-svg-loading",
534
- focusable: "false",
535
- "aria-hidden": "true",
536
- children: [
537
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("defs", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("linearGradient", {
538
- id: gradId,
539
- x1: "2",
540
- y1: "2",
541
- x2: "22",
542
- y2: "22",
543
- gradientUnits: "userSpaceOnUse",
544
- children: [
545
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
546
- offset: "0%",
547
- stopColor: "currentColor",
548
- stopOpacity: "1"
549
- }),
550
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
551
- offset: "65%",
552
- stopColor: "#c4b5fd",
553
- stopOpacity: "0.85"
554
- }),
555
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
556
- offset: "100%",
557
- stopColor: "currentColor",
558
- stopOpacity: "0.08"
559
- })
560
- ]
561
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("linearGradient", {
562
- id: glowId,
563
- x1: "20",
564
- y1: "4",
565
- x2: "4",
566
- y2: "20",
567
- gradientUnits: "userSpaceOnUse",
568
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
569
- offset: "0%",
570
- stopColor: "#ffffff",
571
- stopOpacity: "0.85"
572
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
573
- offset: "100%",
574
- stopColor: "currentColor",
575
- stopOpacity: "0.1"
576
- })]
577
- })] }),
578
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
579
- cx: "12",
580
- cy: "12",
581
- r: "9",
582
- stroke: "currentColor",
583
- strokeOpacity: "0.18",
584
- strokeWidth: "1.8"
585
- }),
586
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
587
- cx: "12",
588
- cy: "12",
589
- r: "9",
590
- stroke: `url(#${gradId})`,
591
- strokeWidth: "2.1",
592
- strokeLinecap: "round",
593
- pathLength: 100,
594
- className: "vt-loader-outer"
595
- }),
596
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
597
- cx: "12",
598
- cy: "12",
599
- r: "5.3",
600
- stroke: `url(#${glowId})`,
601
- strokeWidth: "1.65",
602
- strokeLinecap: "round",
603
- strokeDasharray: "34 66",
604
- pathLength: 100,
605
- className: "vt-loader-inner"
606
- }),
607
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
608
- cx: "12",
609
- cy: "12",
610
- r: "2.1",
611
- fill: "currentColor",
612
- className: "vt-loader-core"
613
- })
614
- ]
615
- })
616
- ]
617
- })]
618
- }, variant);
619
- }
620
- // src/components/ToastProgress.tsx
621
- function ToastProgress({ duration, paused, variant, resetKey, position = "bottom", height = 3, trackClassName, barClassName }) {
622
- if (!require_core.isFiniteDuration(duration)) return null;
623
- const trackStyle = { height: `${Math.max(1, height)}px` };
624
- const barStyle = {
625
- animationDuration: `${duration}ms`,
626
- animationPlayState: paused ? "paused" : "running"
627
- };
628
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
629
- className: require_core.cx("vt-progress-track", trackClassName),
630
- style: trackStyle,
631
- "aria-hidden": "true",
632
- "data-vt-progress": "",
633
- "data-vt-progress-position": position,
634
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
635
- className: require_core.cx("vt-progress-bar", barClassName),
636
- "data-vt-variant": variant,
637
- style: barStyle
638
- }, resetKey)
639
- });
640
- }
641
- // src/components/ToastItem.tsx
642
- function resolveGlobalVariantIcon(variant, icons) {
643
- if (!icons) return;
644
- switch (variant) {
645
- case "success": return icons.success;
646
- case "error": return icons.error;
647
- case "warning": return icons.warning;
648
- case "info": return icons.info;
649
- case "loading": return icons.loading;
650
- default: return;
651
- }
652
- }
653
- var ToastItem = (0, react.memo)(function ToastItem({ toast, index, total, position, expanded, store, glassDefault, radiusDefault, sizeDefault, ambientGlowDefault, animationDefault, iconAnimationDefault, showCloseButton, closeButtonPositionDefault, showCloseOnHoverDefault, showProgressDefault, progressPositionDefault, progressHeightDefault, pauseOnHoverDefault, pauseOnFocusDefault, swipeToDismissDefault, swipeDirectionsDefault, richColors, icons, classNames, toastClassName }) {
654
- const canHoverPause = pauseOnHoverDefault && toast.pauseOnHover;
655
- const canFocusPause = pauseOnFocusDefault && toast.pauseOnFocus;
656
- const canSwipe = swipeToDismissDefault && toast.swipeToDismiss && toast.dismissible;
657
- const shouldShowProgress = showProgressDefault && toast.showProgress && toast.status !== "exiting";
658
- const shouldShowClose = (toast.closeButton ?? showCloseButton) && toast.dismissible;
659
- const effectiveGlass = toast.glass ?? glassDefault;
660
- const effectiveRadius = toast.radius ?? radiusDefault;
661
- const effectiveSize = toast.size ?? sizeDefault;
662
- const effectiveGlow = toast.ambientGlow ?? ambientGlowDefault;
663
- const effectiveAnimation = toast.animation ?? animationDefault;
664
- const effectiveIconAnimation = require_core.resolveIconAnimationMode(toast.iconAnimation ?? iconAnimationDefault);
665
- const effectiveProgressPos = toast.progressPosition ?? progressPositionDefault;
666
- const effectiveProgressHeight = toast.progressHeight ?? progressHeightDefault;
667
- const effectiveClosePos = toast.closeButtonPosition ?? closeButtonPositionDefault;
668
- const effectiveCloseOnHover = toast.showCloseOnHover ?? showCloseOnHoverDefault;
669
- const effectiveSwipeDirections = toast.swipeDirections ?? swipeDirectionsDefault;
670
- const resolvedClassNames = require_core.mergeClassNames(classNames, toast.classNames);
671
- const effectiveIcon = toast.icon !== void 0 ? toast.icon : resolveGlobalVariantIcon(toast.variant, icons);
672
- const handleDismiss = (0, react.useCallback)(() => {
673
- store.dismiss(toast.id, "user");
674
- }, [store, toast.id]);
675
- const handlePauseManual = (0, react.useCallback)(() => {
676
- store.pause(toast.id, "manual");
677
- }, [store, toast.id]);
678
- const handleResumeManual = (0, react.useCallback)(() => {
679
- store.resume(toast.id, "manual");
680
- }, [store, toast.id]);
681
- const { swipeState, handlers: swipeHandlers } = useSwipe({
682
- enabled: canSwipe,
683
- position,
684
- directions: effectiveSwipeDirections,
685
- onSwipeStart: (0, react.useCallback)(() => {
686
- store.pause(toast.id, "swipe");
687
- }, [store, toast.id]),
688
- onSwipeCancel: (0, react.useCallback)(() => {
689
- store.resume(toast.id, "swipe");
690
- }, [store, toast.id]),
691
- onDismiss: handleDismiss
692
- });
693
- const handleMouseEnter = (0, react.useCallback)(() => {
694
- if (canHoverPause) store.pause(toast.id, "hover");
695
- }, [
696
- canHoverPause,
697
- store,
698
- toast.id
699
- ]);
700
- const handleMouseLeave = (0, react.useCallback)(() => {
701
- if (canHoverPause) store.resume(toast.id, "hover");
702
- }, [
703
- canHoverPause,
704
- store,
705
- toast.id
706
- ]);
707
- const handleFocus = (0, react.useCallback)(() => {
708
- if (canFocusPause) store.pause(toast.id, "focus");
709
- }, [
710
- canFocusPause,
711
- store,
712
- toast.id
713
- ]);
714
- const handleBlur = (0, react.useCallback)((event) => {
715
- if (!canFocusPause) return;
716
- if (event.relatedTarget && event.currentTarget.contains(event.relatedTarget)) return;
717
- store.resume(toast.id, "focus");
718
- }, [
719
- canFocusPause,
720
- store,
721
- toast.id
722
- ]);
723
- const handleKeyDown = (0, react.useCallback)((event) => {
724
- if (event.key === "Escape" && toast.dismissible) {
725
- event.stopPropagation();
726
- handleDismiss();
727
- }
728
- }, [handleDismiss, toast.dismissible]);
729
- const isFront = index === 0;
730
- const zIndex = Math.max(1, total - index);
731
- const stackStyle = {
732
- ...toast.style,
733
- "--vt-index": String(index),
734
- "--vt-z-index": String(zIndex),
735
- "--vt-swipe-x": `${swipeState.offsetX}px`,
736
- "--vt-swipe-y": `${swipeState.offsetY}px`,
737
- "--vt-swipe-opacity": String(swipeState.opacity)
738
- };
739
- const isCustom = toast.variant === "custom" && typeof toast.customRender === "function";
740
- const closeButtonEl = shouldShowClose ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
741
- type: "button",
742
- className: require_core.cx("vt-close", effectiveClosePos === "floating" && "vt-close-floating", effectiveClosePos === "top-left" && "vt-close-left", effectiveCloseOnHover && "vt-close-hover-only", resolvedClassNames?.closeButton),
743
- "aria-label": "Dismiss notification",
744
- "data-vt-close": "",
745
- "data-vt-close-position": effectiveClosePos,
746
- onClick: handleDismiss,
747
- children: icons?.close !== void 0 ? icons.close : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
748
- viewBox: "0 0 16 16",
749
- fill: "none",
750
- className: "vt-close-svg",
751
- "aria-hidden": "true",
752
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
753
- d: "M4.5 4.5L11.5 11.5M11.5 4.5L4.5 11.5",
754
- stroke: "currentColor",
755
- strokeWidth: "1.75",
756
- strokeLinecap: "round"
757
- })
758
- })
759
- }) : null;
760
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
761
- className: require_core.cx("vt-toast-slot", expanded && "vt-toast-slot-expanded"),
762
- "data-vt-slot": "",
763
- "data-vt-index": index,
764
- "data-vt-front": isFront ? "true" : "false",
765
- "data-vt-status": toast.status,
766
- style: stackStyle,
767
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
768
- className: require_core.cx("vt-toast", richColors && "vt-toast-rich", swipeState.isSwiping && "vt-toast-swiping", effectiveClosePos === "floating" && "vt-toast-floating-close", toastClassName, resolvedClassNames?.toast, toast.className),
769
- role: toast.role,
770
- "aria-live": toast.role === "alert" ? "assertive" : "polite",
771
- "aria-atomic": "true",
772
- "aria-label": toast.ariaLabel,
773
- tabIndex: 0,
774
- "data-vt-toast": "",
775
- "data-vt-id": toast.id,
776
- "data-vt-variant": toast.variant,
777
- "data-vt-status": toast.status,
778
- "data-vt-paused": toast.paused ? "true" : "false",
779
- "data-vt-swiping": swipeState.isSwiping ? "true" : "false",
780
- "data-vt-position": position,
781
- "data-vt-glass": effectiveGlass,
782
- "data-vt-radius": effectiveRadius,
783
- "data-vt-size": effectiveSize,
784
- "data-vt-glow": effectiveGlow ? "true" : "false",
785
- "data-vt-animation": effectiveAnimation,
786
- onMouseEnter: handleMouseEnter,
787
- onMouseLeave: handleMouseLeave,
788
- onFocus: handleFocus,
789
- onBlur: handleBlur,
790
- onKeyDown: handleKeyDown,
791
- ...swipeHandlers,
792
- children: [
793
- effectiveClosePos === "floating" && closeButtonEl,
794
- isCustom && toast.customRender ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
795
- className: "vt-custom-content",
796
- children: toast.customRender({
797
- id: toast.id,
798
- toast,
799
- dismiss: handleDismiss,
800
- pause: handlePauseManual,
801
- resume: handleResumeManual
802
- })
803
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
804
- className: require_core.cx("vt-body", resolvedClassNames?.body),
805
- children: [
806
- effectiveClosePos === "top-left" && closeButtonEl,
807
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToastIcon, {
808
- variant: toast.variant,
809
- icon: effectiveIcon,
810
- animationMode: effectiveIconAnimation,
811
- className: resolvedClassNames?.icon
812
- }),
813
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
814
- className: require_core.cx("vt-content", resolvedClassNames?.content),
815
- children: [
816
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
817
- className: "vt-header",
818
- children: [toast.title !== void 0 && toast.title !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
819
- className: require_core.cx("vt-title", resolvedClassNames?.title),
820
- "data-vt-title": "",
821
- children: toast.title
822
- }), toast.count > 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
823
- className: require_core.cx("vt-count-badge", resolvedClassNames?.countBadge),
824
- title: `${toast.count} occurrences`,
825
- "data-vt-count": toast.count,
826
- children: ["×", toast.count]
827
- })]
828
- }),
829
- toast.description !== void 0 && toast.description !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
830
- className: require_core.cx("vt-description", resolvedClassNames?.description),
831
- "data-vt-description": "",
832
- children: toast.description
833
- }),
834
- (toast.action || toast.cancel) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
835
- className: require_core.cx("vt-actions", resolvedClassNames?.actions),
836
- "data-vt-actions": "",
837
- children: [toast.action && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
838
- type: "button",
839
- className: require_core.cx("vt-btn vt-btn-primary", resolvedClassNames?.actionButton),
840
- "aria-label": toast.action.ariaLabel,
841
- onClick: (event) => {
842
- toast.action?.onClick(event);
843
- },
844
- children: toast.action.label
845
- }), toast.cancel && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
846
- type: "button",
847
- className: require_core.cx("vt-btn vt-btn-secondary", resolvedClassNames?.cancelButton),
848
- "aria-label": toast.cancel.ariaLabel,
849
- onClick: (event) => {
850
- toast.cancel?.onClick(event);
851
- },
852
- children: toast.cancel.label
853
- })]
854
- })
855
- ]
856
- }),
857
- effectiveClosePos === "top-right" && closeButtonEl
858
- ]
859
- }),
860
- shouldShowProgress && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToastProgress, {
861
- duration: toast.duration,
862
- paused: toast.paused,
863
- variant: toast.variant,
864
- position: effectiveProgressPos,
865
- height: effectiveProgressHeight,
866
- trackClassName: resolvedClassNames?.progress,
867
- barClassName: resolvedClassNames?.progressBar,
868
- resetKey: `${toast.id}-${toast.duration}-${toast.count}-${toast.variant}`
869
- })
870
- ]
871
- })
872
- });
873
- });
874
- // src/components/Toaster.tsx
875
- var ALL_POSITIONS = [
876
- "top-left",
877
- "top-center",
878
- "top-right",
879
- "bottom-left",
880
- "bottom-center",
881
- "bottom-right"
882
- ];
883
- var DEFAULT_HOTKEY = ["altKey", "KeyT"];
884
- function matchesHotkey(event, hotkey) {
885
- if (hotkey.length === 0) return false;
886
- return hotkey.every((key) => {
887
- if (key === "altKey") return event.altKey;
888
- if (key === "ctrlKey") return event.ctrlKey;
889
- if (key === "metaKey") return event.metaKey;
890
- if (key === "shiftKey") return event.shiftKey;
891
- return event.code === key || event.key.toLowerCase() === key.toLowerCase();
892
- });
893
- }
894
- function Toaster({ position = "top-right", theme = "dark", duration = 4e3, visibleToasts = 4, gap = 12, offset = 20, expand = false, glass = "frosted", radius = "md", size = "default", ambientGlow = true, themeTokens, animation = "bounce", iconAnimation = "default", progressPosition = "bottom", progressHeight = 3, pauseOnHover = true, pauseOnFocus = true, swipeToDismiss = true, swipeDirections, showProgress = false, closeButton = true, closeButtonPosition = "floating", showCloseOnHover = true, preventDuplicates = false, richColors = false, icons, classNames, hotkey = DEFAULT_HOTKEY, sound = true, haptic = true, onToastShow, toastOptions, dir = "ltr", className, toastClassName, style, containerAriaLabel = "Notifications", portalContainer, exitDuration = 240, store = require_core.defaultToastStore }) {
895
- const mounted = useMounted();
896
- const resolvedTheme = useResolvedTheme(theme);
897
- const { toasts } = useToasts(store);
898
- const [hoveredPosition, setHoveredPosition] = (0, react.useState)(null);
899
- const [focusedPosition, setFocusedPosition] = (0, react.useState)(null);
900
- const seenToastIdsRef = (0, react.useRef)(/* @__PURE__ */ new Set());
901
- const effectiveExitDuration = animation === "none" ? 0 : exitDuration;
902
- (0, react.useEffect)(() => {
903
- store.configure({
904
- defaultDuration: duration,
905
- visibleToasts,
906
- exitDuration: effectiveExitDuration,
907
- preventDuplicates,
908
- toastOptions
909
- });
910
- }, [
911
- duration,
912
- effectiveExitDuration,
913
- preventDuplicates,
914
- store,
915
- toastOptions,
916
- visibleToasts
917
- ]);
918
- (0, react.useEffect)(() => {
919
- if (!isBrowser()) return;
920
- const handleVisibilityChange = () => {
921
- if (document.hidden) store.pauseAll("document-hidden");
922
- else store.resumeAll("document-hidden");
923
- };
924
- document.addEventListener("visibilitychange", handleVisibilityChange);
925
- return () => {
926
- document.removeEventListener("visibilitychange", handleVisibilityChange);
927
- };
928
- }, [store]);
929
- (0, react.useEffect)(() => {
930
- if (!isBrowser() || hotkey.length === 0) return;
931
- const handleKeyDown = (event) => {
932
- if (!matchesHotkey(event, hotkey)) return;
933
- const firstToast = document.querySelector("[data-vt-toast]");
934
- if (firstToast) {
935
- event.preventDefault();
936
- firstToast.focus();
937
- }
938
- };
939
- window.addEventListener("keydown", handleKeyDown);
940
- return () => {
941
- window.removeEventListener("keydown", handleKeyDown);
942
- };
943
- }, [hotkey]);
944
- (0, react.useEffect)(() => {
945
- const activeIds = /* @__PURE__ */ new Set();
946
- for (const item of toasts) {
947
- activeIds.add(item.id);
948
- if (item.status !== "exiting" && !seenToastIdsRef.current.has(item.id)) {
949
- seenToastIdsRef.current.add(item.id);
950
- onToastShow?.(item);
951
- if (item.sound ?? sound) playToastSound(item.variant);
952
- if (item.haptic ?? haptic) triggerToastHaptic(item.variant);
953
- }
954
- }
955
- for (const seenId of seenToastIdsRef.current) if (!activeIds.has(seenId)) seenToastIdsRef.current.delete(seenId);
956
- }, [
957
- haptic,
958
- onToastShow,
959
- sound,
960
- toasts
961
- ]);
962
- const tokenCssVars = (0, react.useMemo)(() => require_core.tokensToCssVars(themeTokens), [themeTokens]);
963
- const groupedByPosition = (0, react.useMemo)(() => {
964
- const groups = /* @__PURE__ */ new Map();
965
- for (const item of toasts) {
966
- const targetPos = item.position ?? position;
967
- const list = groups.get(targetPos);
968
- if (list) list.push(item);
969
- else groups.set(targetPos, [item]);
970
- }
971
- return groups;
972
- }, [position, toasts]);
973
- if (!mounted || !isBrowser()) return null;
974
- const targetContainer = portalContainer ?? document.body;
975
- if (!targetContainer) return null;
976
- const resolvedOffset = typeof offset === "number" ? `${offset}px` : offset;
977
- const activePositions = ALL_POSITIONS.filter((pos) => {
978
- const group = groupedByPosition.get(pos);
979
- return group && group.length > 0;
980
- });
981
- if (activePositions.length === 0) return null;
982
- const content = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: activePositions.map((pos) => {
983
- const ordered = [...groupedByPosition.get(pos) ?? []].reverse();
984
- const isExpanded = expand || hoveredPosition === pos || focusedPosition === pos;
985
- const sectionStyle = {
986
- ...tokenCssVars,
987
- ...style,
988
- "--vt-gap": `${gap}px`,
989
- "--vt-offset": resolvedOffset
990
- };
991
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
992
- "aria-label": containerAriaLabel,
993
- dir,
994
- className: require_core.cx("vt-toaster", classNames?.toaster, className),
995
- "data-vt-toaster": "",
996
- "data-vt-theme": resolvedTheme,
997
- "data-vt-position": pos,
998
- "data-vt-expanded": isExpanded ? "true" : "false",
999
- style: sectionStyle,
1000
- onMouseEnter: () => setHoveredPosition(pos),
1001
- onMouseLeave: () => setHoveredPosition((prev) => prev === pos ? null : prev),
1002
- onFocus: () => setFocusedPosition(pos),
1003
- onBlur: (event) => {
1004
- if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) setFocusedPosition((prev) => prev === pos ? null : prev);
1005
- },
1006
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ol", {
1007
- className: require_core.cx("vt-list", classNames?.list),
1008
- "data-vt-list": "",
1009
- children: ordered.map((item, idx) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToastItem, {
1010
- toast: item,
1011
- index: idx,
1012
- total: ordered.length,
1013
- position: pos,
1014
- expanded: isExpanded,
1015
- store,
1016
- glassDefault: glass,
1017
- radiusDefault: radius,
1018
- sizeDefault: size,
1019
- ambientGlowDefault: ambientGlow,
1020
- animationDefault: animation,
1021
- iconAnimationDefault: iconAnimation,
1022
- showCloseButton: closeButton,
1023
- closeButtonPositionDefault: closeButtonPosition,
1024
- showCloseOnHoverDefault: showCloseOnHover,
1025
- showProgressDefault: showProgress,
1026
- progressPositionDefault: progressPosition,
1027
- progressHeightDefault: progressHeight,
1028
- pauseOnHoverDefault: pauseOnHover,
1029
- pauseOnFocusDefault: pauseOnFocus,
1030
- swipeToDismissDefault: swipeToDismiss,
1031
- swipeDirectionsDefault: swipeDirections,
1032
- richColors,
1033
- icons,
1034
- classNames,
1035
- toastClassName
1036
- }, item.id))
1037
- })
1038
- }, pos);
1039
- }) });
1040
- return (0, react_dom.createPortal)(content, targetContainer);
1041
- }
1042
- exports.EMPTY_SNAPSHOT = require_core.EMPTY_SNAPSHOT;
1043
- exports.PauseableTimer = require_core.PauseableTimer;
1044
- exports.ToastStore = require_core.ToastStore;
1045
- exports.Toaster = Toaster;
1046
- exports.createToastApi = require_core.createToastApi;
1047
- exports.createToastStore = require_core.createToastStore;
1048
- exports.defaultToastStore = require_core.defaultToastStore;
1049
- exports.playToastSound = playToastSound;
1050
- exports.toast = require_core.toast;
1051
- exports.tokensToCssVars = require_core.tokensToCssVars;
1052
- exports.triggerToastHaptic = triggerToastHaptic;
1053
- exports.useMounted = useMounted;
1054
- exports.useResolvedTheme = useResolvedTheme;
1055
- exports.useToasts = useToasts;
1056
-
1057
- //# sourceMappingURL=index.cjs.map
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./core-DWP-MMiI.cjs");let t=require("react"),n=require("react-dom"),r=require("react/jsx-runtime");var i=()=>()=>{},a=()=>!0,o=()=>!1;function s(){return(0,t.useSyncExternalStore)(i,a,o)}function c(){return typeof window<`u`&&typeof document<`u`}function l(){return!c()||typeof window.matchMedia!=`function`||window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function u(e){let[n,r]=(0,t.useState)(()=>e===`system`?l():e);return(0,t.useEffect)(()=>{if(e!==`system`||!c()||typeof window.matchMedia!=`function`)return;let t=window.matchMedia(`(prefers-color-scheme: dark)`),n=()=>{r(t.matches?`dark`:`light`)};return n(),typeof t.addEventListener==`function`?(t.addEventListener(`change`,n),()=>{t.removeEventListener(`change`,n)}):(t.addListener(n),()=>{t.removeListener(n)})},[e]),e===`system`?n:e}function d(n=e.o){return(0,t.useSyncExternalStore)(n.subscribe,n.getSnapshot,n.getServerSnapshot)}var f={success:[523.25,659.25],error:[311.13,246.94],warning:[440,392],info:[587.33],loading:[493.88],default:[523.25],custom:[523.25]},p={success:18,error:[28,36,28],warning:[22,28],info:12,loading:10,default:12,custom:12},m=null;function h(){if(!c())return null;let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;try{return m&&m.state!==`closed`||(m=new e),m}catch{return null}}function g(e){let t=h();if(t)try{t.state===`suspended`&&t.resume().catch(()=>{});let n=f[e]??f.default,r=t.currentTime;n.forEach((n,i)=>{let a=t.createOscillator(),o=t.createGain(),s=r+i*.085,c=s+.14;a.type=e===`error`?`triangle`:`sine`,a.frequency.setValueAtTime(n,s),o.gain.setValueAtTime(1e-4,s),o.gain.exponentialRampToValueAtTime(.045,s+.015),o.gain.exponentialRampToValueAtTime(1e-4,c),a.connect(o),o.connect(t.destination),a.start(s),a.stop(c+.01)})}catch{}}function _(e){if(c()&&typeof navigator<`u`&&typeof navigator.vibrate==`function`)try{navigator.vibrate(p[e]??12)}catch{}}var v={isSwiping:!1,offsetX:0,offsetY:0,opacity:1};function y(e){return e instanceof Element&&e.closest(`button, a, input, textarea, select, [data-vt-no-swipe]`)!==null}function b({enabled:n,position:r,directions:i,onSwipeStart:a,onSwipeCancel:o,onDismiss:s}){let[c,l]=(0,t.useState)(v),u=(0,t.useRef)(null),d=i&&i.length>0?i:e.h(r),f=d.includes(`left`),p=d.includes(`right`),m=d.includes(`up`),h=d.includes(`down`),g=f||p,_=m||h,b=(0,t.useCallback)((t,n,r)=>{if(r===`x`){let n=t>0&&p||t<0&&f;return{offsetX:n?t:t*e.p,offsetY:0,primaryDelta:n?Math.abs(t):0}}let i=n<0&&m||n>0&&h;return{offsetX:0,offsetY:i?n:n*e.p,primaryDelta:i?Math.abs(n):0}},[h,f,p,m]),x=(0,t.useCallback)(e=>{u.current=null,l(v),e&&o?.()},[o]);return{swipeState:c,handlers:{onPointerDown:(0,t.useCallback)(e=>{if(n&&e.button===0&&!y(e.target)&&(u.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,startTime:Date.now(),active:!1,lockedAxis:null},typeof e.currentTarget.setPointerCapture==`function`))try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}},[n]),onPointerMove:(0,t.useCallback)(e=>{let t=u.current;if(!t||t.pointerId!==e.pointerId)return;let n=e.clientX-t.startX,r=e.clientY-t.startY,i=Math.abs(n),o=Math.abs(r);if(!t.lockedAxis){if(Math.max(i,o)<6)return;t.lockedAxis=g&&_?i>=o?`x`:`y`:g?`x`:`y`}let s=t.lockedAxis===`x`?i:o;if(!t.active&&s<6)return;t.active||(t.active=!0,a?.());let{offsetX:c,offsetY:d,primaryDelta:f}=b(n,r,t.lockedAxis),p=Math.min(1,Math.max(0,f/126));l({isSwiping:!0,offsetX:c,offsetY:d,opacity:Math.max(.25,1-p*.7)})},[b,a,g,_]),onPointerUp:(0,t.useCallback)(e=>{let t=u.current;if(!t||t.pointerId!==e.pointerId)return;if(typeof e.currentTarget.releasePointerCapture==`function`)try{e.currentTarget.hasPointerCapture?.(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)}catch{}if(!t.active||!t.lockedAxis){u.current=null;return}let n=e.clientX-t.startX,r=e.clientY-t.startY,i=Math.max(1,Date.now()-t.startTime),{primaryDelta:a}=b(n,r,t.lockedAxis),o=a/i;a>=84||o>=.45?(u.current=null,l(v),s()):x(!0)},[b,s,x]),onPointerCancel:(0,t.useCallback)(e=>{let t=u.current;t&&t.pointerId===e.pointerId&&x(t.active)},[x])}}}var x=`M8.4 3.4H15.6L20.6 8.4V15.6L15.6 20.6H8.4L3.4 15.6V8.4L8.4 3.4Z`,S=`M10.42 4.65C11.12 3.43 12.88 3.43 13.58 4.65L20.38 16.45C21.08 17.67 20.2 19.2 18.8 19.2H5.2C3.8 19.2 2.92 17.67 3.62 16.45L10.42 4.65Z`,C=[[4.2,4.8,1.05],[19.8,4.8,.95],[20.2,18.8,.9],[4.2,18.8,.85]],w={success:[4,4,20,20,`currentColor`,`#a7f3d0`,1,.95],error:[4,4,20,20,`#fda4af`,`currentColor`],warning:[12,3,12,21,`#fde68a`,`currentColor`],info:[4,4,20,20,`#bae6fd`,`currentColor`],loading:[2,2,22,22,`currentColor`,`currentColor`,1,.08]};function T({variant:n,icon:i,animationMode:a=`default`,className:o}){let s=(0,t.useId)();if(i===null)return null;if(i!==void 0)return(0,r.jsx)(`span`,{className:e.c(`vt-icon-badge vt-icon-badge-custom`,o),"data-vt-icon":``,"data-vt-icon-animation":a,"aria-hidden":`true`,children:(0,r.jsx)(`span`,{className:`vt-icon-inner`,children:i})});if(n==="default"||n===`custom`)return null;let c=`vt-grad-${s}`,l=`vt-glow-${s}`,u=`url(#${c})`,[d,f,p,m,h,g,_=1,v=1]=w[n];return(0,r.jsxs)(`span`,{className:e.c(`vt-icon-badge`,o),"data-vt-icon":``,"data-vt-variant":n,"data-vt-icon-animation":a,"aria-hidden":`true`,children:[(0,r.jsx)(`span`,{className:`vt-icon-pulse`,"aria-hidden":`true`}),(0,r.jsx)(`span`,{className:`vt-icon-inner`,children:(0,r.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,className:`vt-svg vt-svg-${n}`,focusable:`false`,"aria-hidden":`true`,children:[(0,r.jsxs)(`defs`,{children:[(0,r.jsxs)(`linearGradient`,{id:c,x1:d,y1:f,x2:p,y2:m,gradientUnits:`userSpaceOnUse`,children:[(0,r.jsx)(`stop`,{offset:`0%`,stopColor:h,stopOpacity:_}),n===`loading`&&(0,r.jsx)(`stop`,{offset:`65%`,stopColor:`#c4b5fd`,stopOpacity:`0.85`}),(0,r.jsx)(`stop`,{offset:`100%`,stopColor:g,stopOpacity:v})]}),n===`loading`&&(0,r.jsxs)(`linearGradient`,{id:l,x1:`20`,y1:`4`,x2:`4`,y2:`20`,gradientUnits:`userSpaceOnUse`,children:[(0,r.jsx)(`stop`,{offset:`0%`,stopColor:`#fff`,stopOpacity:`0.85`}),(0,r.jsx)(`stop`,{offset:`100%`,stopColor:`currentColor`,stopOpacity:`0.1`})]})]}),n===`success`&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.75`,fill:`currentColor`,className:`vt-success-fill`}),(0,r.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.75`,stroke:u,strokeWidth:`1.75`,strokeLinecap:`round`,pathLength:100,className:`vt-success-ring`}),(0,r.jsx)(`path`,{d:`M8.1 12.35L10.75 15L16.1 9.35`,stroke:u,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,pathLength:100,className:`vt-success-check`}),C.map(([e,t,n],i)=>(0,r.jsx)(`circle`,{cx:e,cy:t,r:n,fill:`currentColor`,className:`vt-spark vt-spark-${i+1}`},i))]}),n===`error`&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(`path`,{d:x,fill:`currentColor`,className:`vt-error-fill`}),(0,r.jsx)(`path`,{d:x,stroke:u,strokeWidth:`1.75`,strokeLinejoin:`round`,pathLength:100,className:`vt-error-frame`}),(0,r.jsx)(`path`,{d:`M9.1 9.1L14.9 14.9`,stroke:u,strokeWidth:`2.15`,strokeLinecap:`round`,pathLength:100,className:`vt-error-line-1`}),(0,r.jsx)(`path`,{d:`M14.9 9.1L9.1 14.9`,stroke:u,strokeWidth:`2.15`,strokeLinecap:`round`,pathLength:100,className:`vt-error-line-2`})]}),n===`warning`&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(`path`,{d:S,fill:`currentColor`,className:`vt-warning-fill`}),(0,r.jsx)(`path`,{d:S,stroke:u,strokeWidth:`1.75`,strokeLinejoin:`round`,pathLength:100,className:`vt-warning-frame`}),(0,r.jsx)(`path`,{d:`M12 9.1V13.15`,stroke:u,strokeWidth:`2.1`,strokeLinecap:`round`,pathLength:100,className:`vt-warning-stem`}),(0,r.jsx)(`circle`,{cx:`12`,cy:`16.1`,r:`1.2`,fill:u,className:`vt-warning-dot`})]}),n===`info`&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.75`,fill:`currentColor`,className:`vt-info-fill`}),(0,r.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.75`,stroke:u,strokeWidth:`1.75`,pathLength:100,className:`vt-info-ring`}),(0,r.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.75`,stroke:`#fff`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeDasharray:`16 84`,pathLength:100,className:`vt-info-glint`}),(0,r.jsx)(`circle`,{cx:`12`,cy:`8.25`,r:`1.25`,fill:u,className:`vt-info-dot`}),(0,r.jsx)(`path`,{d:`M12 11.2V16.1`,stroke:u,strokeWidth:`2.15`,strokeLinecap:`round`,pathLength:100,className:`vt-info-stem`})]}),n===`loading`&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,stroke:`currentColor`,strokeOpacity:`0.18`,strokeWidth:`1.8`}),(0,r.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,stroke:u,strokeWidth:`2.1`,strokeLinecap:`round`,pathLength:100,className:`vt-loader-outer`}),(0,r.jsx)(`circle`,{cx:`12`,cy:`12`,r:`5.3`,stroke:`url(#${l})`,strokeWidth:`1.65`,strokeLinecap:`round`,strokeDasharray:`34 66`,pathLength:100,className:`vt-loader-inner`}),(0,r.jsx)(`circle`,{cx:`12`,cy:`12`,r:`2.1`,fill:`currentColor`,className:`vt-loader-core`})]})]})})]},n)}function E({duration:t,paused:n,variant:i,resetKey:a,position:o=`bottom`,height:s=3,trackClassName:c,barClassName:l}){if(!e.l(t))return null;let u={height:`${Math.max(1,s)}px`},d={animationDuration:`${t}ms`,animationPlayState:n?`paused`:`running`};return(0,r.jsx)(`div`,{className:e.c(`vt-progress-track`,c),style:u,"aria-hidden":`true`,"data-vt-progress":``,"data-vt-progress-position":o,children:(0,r.jsx)(`div`,{className:e.c(`vt-progress-bar`,l),"data-vt-variant":i,style:d},a)})}var ee=(0,t.memo)(function({toast:n,index:i,total:a,position:o,expanded:s,store:c,cfg:l}){let u=l.pauseOnHover&&n.pauseOnHover,d=l.pauseOnFocus&&n.pauseOnFocus,f=l.showProgress&&n.showProgress&&n.status!==`exiting`,p=(n.closeButton??l.closeButton)&&n.dismissible,m=n.closeButtonPosition??l.closeButtonPosition,h=e.u(l.classNames,n.classNames),g=n.icon===void 0?l.icons&&n.variant!=="default"&&n.variant!==`custom`?l.icons[n.variant]:void 0:n.icon,_=(0,t.useCallback)(()=>{c.dismiss(n.id,`user`)},[c,n.id]),{swipeState:v,handlers:y}=b({enabled:l.swipeToDismiss&&n.swipeToDismiss&&n.dismissible,position:o,directions:n.swipeDirections??l.swipeDirections,onSwipeStart:(0,t.useCallback)(()=>c.pause(n.id,`swipe`),[c,n.id]),onSwipeCancel:(0,t.useCallback)(()=>c.resume(n.id,`swipe`),[c,n.id]),onDismiss:_}),x=e=>{!d||e.relatedTarget&&e.currentTarget.contains(e.relatedTarget)||c.resume(n.id,`focus`)},S=e=>{e.key===`Escape`&&n.dismissible&&(e.stopPropagation(),_())},C={...n.style,"--vt-index":String(i),"--vt-z-index":String(Math.max(1,a-i)),"--vt-swipe-x":`${v.offsetX}px`,"--vt-swipe-y":`${v.offsetY}px`,"--vt-swipe-opacity":String(v.opacity)},w=p?(0,r.jsx)(`button`,{type:`button`,className:e.c(`vt-close`,m===`floating`&&`vt-close-floating`,m===`top-left`&&`vt-close-left`,(n.showCloseOnHover??l.showCloseOnHover)&&`vt-close-hover-only`,h?.closeButton),"aria-label":`Dismiss notification`,"data-vt-close":``,"data-vt-close-position":m,onClick:_,children:l.icons?.close===void 0?(0,r.jsx)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,className:`vt-close-svg`,"aria-hidden":`true`,children:(0,r.jsx)(`path`,{d:`M4.5 4.5L11.5 11.5M11.5 4.5L4.5 11.5`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`})}):l.icons.close}):null;return(0,r.jsx)(`li`,{className:e.c(`vt-toast-slot`,s&&`vt-toast-slot-expanded`),"data-vt-slot":``,"data-vt-index":i,"data-vt-front":i===0?`true`:`false`,"data-vt-status":n.status,style:C,children:(0,r.jsxs)(`div`,{className:e.c(`vt-toast`,l.richColors&&`vt-toast-rich`,v.isSwiping&&`vt-toast-swiping`,m===`floating`&&`vt-toast-floating-close`,l.toastClassName,h?.toast,n.className),role:n.role,"aria-live":n.role===`alert`?`assertive`:`polite`,"aria-atomic":`true`,"aria-label":n.ariaLabel,tabIndex:0,"data-vt-toast":``,"data-vt-id":n.id,"data-vt-variant":n.variant,"data-vt-status":n.status,"data-vt-paused":n.paused?`true`:`false`,"data-vt-swiping":v.isSwiping?`true`:`false`,"data-vt-position":o,"data-vt-glass":n.glass??l.glass,"data-vt-radius":n.radius??l.radius,"data-vt-size":n.size??l.size,"data-vt-glow":n.ambientGlow??l.ambientGlow?`true`:`false`,"data-vt-animation":n.animation??l.animation,onMouseEnter:()=>u&&c.pause(n.id,`hover`),onMouseLeave:()=>u&&c.resume(n.id,`hover`),onFocus:()=>d&&c.pause(n.id,`focus`),onBlur:x,onKeyDown:S,...y,children:[m===`floating`&&w,n.variant===`custom`&&typeof n.customRender==`function`?(0,r.jsx)(`div`,{className:`vt-custom-content`,children:n.customRender({id:n.id,toast:n,dismiss:_,pause:()=>c.pause(n.id,`manual`),resume:()=>c.resume(n.id,`manual`)})}):(0,r.jsxs)(`div`,{className:e.c(`vt-body`,h?.body),children:[m===`top-left`&&w,(0,r.jsx)(T,{variant:n.variant,icon:g,animationMode:e.d(n.iconAnimation??l.iconAnimation),className:h?.icon}),(0,r.jsxs)(`div`,{className:e.c(`vt-content`,h?.content),children:[(0,r.jsxs)(`div`,{className:`vt-header`,children:[n.title!=null&&(0,r.jsx)(`div`,{className:e.c(`vt-title`,h?.title),"data-vt-title":``,children:n.title}),n.count>1&&(0,r.jsxs)(`span`,{className:e.c(`vt-count-badge`,h?.countBadge),title:`${n.count} occurrences`,"data-vt-count":n.count,children:[`×`,n.count]})]}),n.description!=null&&(0,r.jsx)(`div`,{className:e.c(`vt-description`,h?.description),"data-vt-description":``,children:n.description}),(n.action||n.cancel)&&(0,r.jsxs)(`div`,{className:e.c(`vt-actions`,h?.actions),"data-vt-actions":``,children:[n.action&&(0,r.jsx)(`button`,{type:`button`,className:e.c(`vt-btn vt-btn-primary`,h?.actionButton),"aria-label":n.action.ariaLabel,onClick:e=>n.action?.onClick(e),children:n.action.label}),n.cancel&&(0,r.jsx)(`button`,{type:`button`,className:e.c(`vt-btn vt-btn-secondary`,h?.cancelButton),"aria-label":n.cancel.ariaLabel,onClick:e=>n.cancel?.onClick(e),children:n.cancel.label})]})]}),m===`top-right`&&w]}),f&&(0,r.jsx)(E,{duration:n.duration,paused:n.paused,variant:n.variant,position:n.progressPosition??l.progressPosition,height:n.progressHeight??l.progressHeight,trackClassName:h?.progress,barClassName:h?.progressBar,resetKey:`${n.id}-${n.duration}-${n.count}-${n.variant}`})]})})}),te=[`top-left`,`top-center`,`top-right`,`bottom-left`,`bottom-center`,`bottom-right`],ne=[`altKey`,`KeyT`];function re(e,t){return t.length!==0&&t.every(t=>t===`altKey`?e.altKey:t===`ctrlKey`?e.ctrlKey:t===`metaKey`?e.metaKey:t===`shiftKey`?e.shiftKey:e.code===t||e.key.toLowerCase()===t.toLowerCase())}function D({position:i=`top-right`,theme:a=`dark`,duration:o=4e3,visibleToasts:l=4,gap:f=12,offset:p=20,expand:m=!1,glass:h=`frosted`,radius:v=`md`,size:y=`default`,ambientGlow:b=!0,themeTokens:x,animation:S=`bounce`,iconAnimation:C=`default`,progressPosition:w=`bottom`,progressHeight:T=3,pauseOnHover:E=!0,pauseOnFocus:D=!0,swipeToDismiss:O=!0,swipeDirections:k,showProgress:A=!1,closeButton:j=!0,closeButtonPosition:M=`floating`,showCloseOnHover:N=!0,preventDuplicates:P=!1,richColors:F=!1,icons:I,classNames:L,hotkey:R=ne,sound:z=!0,haptic:B=!0,onToastShow:V,toastOptions:H,dir:ie=`ltr`,className:ae,toastClassName:U,style:oe,containerAriaLabel:se=`Notifications`,portalContainer:ce,exitDuration:W=240,store:G=e.o}){let le=s(),ue=u(a),{toasts:K}=d(G),[de,q]=(0,t.useState)(null),[fe,J]=(0,t.useState)(null),Y=(0,t.useRef)(new Set),X=S===`none`?0:W;(0,t.useEffect)(()=>{G.configure({defaultDuration:o,visibleToasts:l,exitDuration:X,preventDuplicates:P,toastOptions:H})},[o,X,P,G,H,l]),(0,t.useEffect)(()=>{if(!c())return;let e=()=>{document.hidden?G.pauseAll(`document-hidden`):G.resumeAll(`document-hidden`)};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e)}},[G]),(0,t.useEffect)(()=>{if(!c()||R.length===0)return;let e=e=>{if(!re(e,R))return;let t=document.querySelector(`[data-vt-toast]`);t&&(e.preventDefault(),t.focus())};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[R]),(0,t.useEffect)(()=>{let e=new Set;for(let t of K)e.add(t.id),t.status!==`exiting`&&!Y.current.has(t.id)&&(Y.current.add(t.id),V?.(t),(t.sound??z)&&g(t.variant),(t.haptic??B)&&_(t.variant));for(let t of Y.current)e.has(t)||Y.current.delete(t)},[B,V,z,K]);let pe=(0,t.useMemo)(()=>e.f(x),[x]),Z=(0,t.useMemo)(()=>{let e=new Map;for(let t of K){let n=t.position??i,r=e.get(n);r?r.push(t):e.set(n,[t])}return e},[i,K]),me=(0,t.useMemo)(()=>({glass:h,radius:v,size:y,ambientGlow:b,animation:S,iconAnimation:C,closeButton:j,closeButtonPosition:M,showCloseOnHover:N,showProgress:A,progressPosition:w,progressHeight:T,pauseOnHover:E,pauseOnFocus:D,swipeToDismiss:O,swipeDirections:k,richColors:F,icons:I,classNames:L,toastClassName:U}),[h,v,y,b,S,C,j,M,N,A,w,T,E,D,O,k,F,I,L,U]);if(!le||!c())return null;let Q=ce??document.body;if(!Q)return null;let he=typeof p==`number`?`${p}px`:p,$=te.filter(e=>{let t=Z.get(e);return t&&t.length>0});if($.length===0)return null;let ge=(0,r.jsx)(r.Fragment,{children:$.map(t=>{let n=[...Z.get(t)??[]].reverse(),i=m||de===t||fe===t,a={...pe,...oe,"--vt-gap":`${f}px`,"--vt-offset":he};return(0,r.jsx)(`section`,{"aria-label":se,dir:ie,className:e.c(`vt-toaster`,L?.toaster,ae),"data-vt-toaster":``,"data-vt-theme":ue,"data-vt-position":t,"data-vt-expanded":i?`true`:`false`,style:a,onMouseEnter:()=>q(t),onMouseLeave:()=>q(e=>e===t?null:e),onFocus:()=>J(t),onBlur:e=>{e.relatedTarget&&e.currentTarget.contains(e.relatedTarget)||J(e=>e===t?null:e)},children:(0,r.jsx)(`ol`,{className:e.c(`vt-list`,L?.list),"data-vt-list":``,children:n.map((e,a)=>(0,r.jsx)(ee,{toast:e,index:a,total:n.length,position:t,expanded:i,store:G,cfg:me},e.id))})},t)})});return(0,n.createPortal)(ge,Q)}exports.EMPTY_SNAPSHOT=e.r,exports.PauseableTimer=e.s,exports.ToastStore=e.i,exports.Toaster=D,exports.createToastApi=e.t,exports.createToastStore=e.a,exports.defaultToastStore=e.o,exports.playToastSound=g,exports.toast=e.n,exports.tokensToCssVars=e.f,exports.triggerToastHaptic=_,exports.useMounted=s,exports.useResolvedTheme=u,exports.useToasts=d;