@youcan/celeste 0.6.30 → 0.6.32

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 (101) hide show
  1. package/dist/celeste.css +483 -264
  2. package/dist/cjs/alert.js +2 -2
  3. package/dist/cjs/chunks/index.js +229 -2
  4. package/dist/cjs/chunks/index2.js +1457 -0
  5. package/dist/cjs/chunks/index3.js +16457 -0
  6. package/dist/cjs/chunks/sonner.js +1154 -0
  7. package/dist/cjs/config.js +136 -0
  8. package/dist/cjs/extra-settings.js +155 -0
  9. package/dist/cjs/index.js +75 -0
  10. package/dist/cjs/label.js +2 -2
  11. package/dist/cjs/link-bubble.js +228 -0
  12. package/dist/cjs/link-button.js +2 -2
  13. package/dist/cjs/rich-editor.js +4996 -0
  14. package/dist/cjs/select-icon.js +2 -2
  15. package/dist/cjs/sonner-alert.js +41 -0
  16. package/dist/cjs/sonner.js +3 -0
  17. package/dist/cjs/text-input-affix.js +2 -2
  18. package/dist/cjs/types.js +1 -0
  19. package/dist/components/index.d.ts +2 -0
  20. package/dist/components/rich-editor/config.d.ts +33 -0
  21. package/dist/components/rich-editor/extra-settings.d.ts +6 -0
  22. package/dist/components/rich-editor/index.d.ts +2 -0
  23. package/dist/components/rich-editor/link-bubble.d.ts +11 -0
  24. package/dist/components/rich-editor/rich-editor.d.ts +55 -0
  25. package/dist/components/rich-editor/types.d.ts +19 -0
  26. package/dist/components/sonner/index.d.ts +4 -0
  27. package/dist/components/sonner/sonner-alert.d.ts +13 -0
  28. package/dist/components/sonner/sonner.d.ts +5 -0
  29. package/dist/es/alert.js +2 -2
  30. package/dist/es/checkbox-label.js +1 -1
  31. package/dist/es/chunks/index.js +277 -50
  32. package/dist/es/chunks/index2.js +1457 -0
  33. package/dist/es/chunks/index3.js +16458 -0
  34. package/dist/es/chunks/sonner.js +1155 -0
  35. package/dist/es/combobox-group.js +1 -1
  36. package/dist/es/combobox-input.js +1 -1
  37. package/dist/es/combobox-item.js +1 -1
  38. package/dist/es/combobox-list.js +1 -1
  39. package/dist/es/combobox-root.js +1 -1
  40. package/dist/es/combobox-separator.js +1 -1
  41. package/dist/es/combobox-trigger.js +1 -1
  42. package/dist/es/command-group.js +1 -1
  43. package/dist/es/command-input.js +1 -1
  44. package/dist/es/command-item.js +1 -1
  45. package/dist/es/command-list.js +1 -1
  46. package/dist/es/command-root.js +1 -1
  47. package/dist/es/command-separator.js +1 -1
  48. package/dist/es/config.js +136 -0
  49. package/dist/es/dropdown-menu-group.js +1 -1
  50. package/dist/es/dropdown-menu-item.js +1 -1
  51. package/dist/es/dropdown-menu-label.js +1 -1
  52. package/dist/es/dropdown-menu-separator.js +1 -1
  53. package/dist/es/dropdown-menu-trigger.js +1 -1
  54. package/dist/es/dropdown-menu.js +1 -1
  55. package/dist/es/dropdown.js +1 -1
  56. package/dist/es/extra-settings.js +156 -0
  57. package/dist/es/index.js +94 -19
  58. package/dist/es/label.js +3 -3
  59. package/dist/es/link-bubble.js +229 -0
  60. package/dist/es/link-button.js +2 -2
  61. package/dist/es/modal-content.js +1 -1
  62. package/dist/es/modal-header.js +1 -1
  63. package/dist/es/popover-content.js +1 -1
  64. package/dist/es/popover-trigger.js +1 -1
  65. package/dist/es/rich-editor.js +4997 -0
  66. package/dist/es/scroll-bar.js +1 -1
  67. package/dist/es/segmented-control-item.js +1 -1
  68. package/dist/es/segmented-control.js +1 -1
  69. package/dist/es/select-content.js +1 -1
  70. package/dist/es/select-icon.js +2 -2
  71. package/dist/es/select-item.js +1 -1
  72. package/dist/es/select-trigger.js +1 -1
  73. package/dist/es/select-value.js +1 -1
  74. package/dist/es/sonner-alert.js +42 -0
  75. package/dist/es/sonner.js +4 -0
  76. package/dist/es/tab-menu-content.js +1 -1
  77. package/dist/es/tab-menu-item.js +1 -1
  78. package/dist/es/tab-menu-list.js +1 -1
  79. package/dist/es/tab-menu.js +1 -1
  80. package/dist/es/text-input-affix.js +2 -2
  81. package/dist/es/tooltip.js +1 -1
  82. package/dist/es/types.js +1 -0
  83. package/dist/index.d.ts +1 -0
  84. package/dist/utils/index.d.ts +3 -0
  85. package/dist/utils/sonner.d.ts +19 -0
  86. package/package.json +15 -4
  87. package/src/components/index.ts +2 -0
  88. package/src/components/rich-editor/config.ts +150 -0
  89. package/src/components/rich-editor/extra-settings.vue +151 -0
  90. package/src/components/rich-editor/index.ts +2 -0
  91. package/src/components/rich-editor/link-bubble.vue +288 -0
  92. package/src/components/rich-editor/rich-editor.vue +428 -0
  93. package/src/components/rich-editor/stories/rich-editor.stories.ts +87 -0
  94. package/src/components/rich-editor/types.ts +21 -0
  95. package/src/components/sonner/index.ts +5 -0
  96. package/src/components/sonner/sonner-alert.vue +54 -0
  97. package/src/components/sonner/sonner.vue +13 -0
  98. package/src/components/sonner/stories/sonner.stories.ts +194 -0
  99. package/src/index.ts +1 -0
  100. package/src/utils/index.ts +3 -0
  101. package/src/utils/sonner.ts +72 -0
@@ -0,0 +1,1154 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ const Mo = require("vue");
6
+ let toastsCounter = 1;
7
+ var Observer = class {
8
+ constructor() {
9
+ __publicField(this, "subscribers");
10
+ __publicField(this, "toasts");
11
+ __publicField(this, "dismissedToasts");
12
+ __publicField(this, "subscribe", (subscriber) => {
13
+ this.subscribers.push(subscriber);
14
+ return () => {
15
+ const index = this.subscribers.indexOf(subscriber);
16
+ this.subscribers.splice(index, 1);
17
+ };
18
+ });
19
+ __publicField(this, "publish", (data) => {
20
+ this.subscribers.forEach((subscriber) => subscriber(data));
21
+ });
22
+ __publicField(this, "addToast", (data) => {
23
+ this.publish(data);
24
+ this.toasts = [...this.toasts, data];
25
+ });
26
+ __publicField(this, "create", (data) => {
27
+ var _a;
28
+ const { message, ...rest } = data;
29
+ const id = typeof data.id === "number" || data.id && ((_a = data.id) == null ? void 0 : _a.length) > 0 ? data.id : toastsCounter++;
30
+ const alreadyExists = this.toasts.find((toast$1) => {
31
+ return toast$1.id === id;
32
+ });
33
+ const dismissible = data.dismissible === void 0 ? true : data.dismissible;
34
+ if (this.dismissedToasts.has(id)) this.dismissedToasts.delete(id);
35
+ if (alreadyExists) this.toasts = this.toasts.map((toast$1) => {
36
+ if (toast$1.id === id) {
37
+ this.publish({
38
+ ...toast$1,
39
+ ...data,
40
+ id,
41
+ title: message
42
+ });
43
+ return {
44
+ ...toast$1,
45
+ ...data,
46
+ id,
47
+ dismissible,
48
+ title: message
49
+ };
50
+ }
51
+ return toast$1;
52
+ });
53
+ else this.addToast({
54
+ title: message,
55
+ ...rest,
56
+ dismissible,
57
+ id
58
+ });
59
+ return id;
60
+ });
61
+ __publicField(this, "dismiss", (id) => {
62
+ if (id) {
63
+ this.dismissedToasts.add(id);
64
+ requestAnimationFrame(() => this.subscribers.forEach((subscriber) => subscriber({
65
+ id,
66
+ dismiss: true
67
+ })));
68
+ } else this.toasts.forEach((toast$1) => {
69
+ this.subscribers.forEach((subscriber) => subscriber({
70
+ id: toast$1.id,
71
+ dismiss: true
72
+ }));
73
+ });
74
+ return id;
75
+ });
76
+ __publicField(this, "message", (message, data) => {
77
+ return this.create({
78
+ ...data,
79
+ message,
80
+ type: "default"
81
+ });
82
+ });
83
+ __publicField(this, "error", (message, data) => {
84
+ return this.create({
85
+ ...data,
86
+ type: "error",
87
+ message
88
+ });
89
+ });
90
+ __publicField(this, "success", (message, data) => {
91
+ return this.create({
92
+ ...data,
93
+ type: "success",
94
+ message
95
+ });
96
+ });
97
+ __publicField(this, "info", (message, data) => {
98
+ return this.create({
99
+ ...data,
100
+ type: "info",
101
+ message
102
+ });
103
+ });
104
+ __publicField(this, "warning", (message, data) => {
105
+ return this.create({
106
+ ...data,
107
+ type: "warning",
108
+ message
109
+ });
110
+ });
111
+ __publicField(this, "loading", (message, data) => {
112
+ return this.create({
113
+ ...data,
114
+ type: "loading",
115
+ message
116
+ });
117
+ });
118
+ __publicField(this, "promise", (promise, data) => {
119
+ if (!data) return;
120
+ let id;
121
+ if (data.loading !== void 0) id = this.create({
122
+ ...data,
123
+ promise,
124
+ type: "loading",
125
+ message: data.loading,
126
+ description: typeof data.description !== "function" ? data.description : void 0
127
+ });
128
+ const p = Promise.resolve(promise instanceof Function ? promise() : promise);
129
+ let shouldDismiss = id !== void 0;
130
+ let result;
131
+ const originalPromise = p.then(async (response) => {
132
+ result = ["resolve", response];
133
+ const isVueComponent = Mo.isVNode(response);
134
+ if (isVueComponent) {
135
+ shouldDismiss = false;
136
+ this.create({
137
+ id,
138
+ type: "default",
139
+ message: response
140
+ });
141
+ } else if (isHttpResponse(response) && !response.ok) {
142
+ shouldDismiss = false;
143
+ const promiseData = typeof data.error === "function" ? await data.error(`HTTP error! status: ${response.status}`) : data.error;
144
+ const description = typeof data.description === "function" ? await data.description(`HTTP error! status: ${response.status}`) : data.description;
145
+ const isExtendedResult = typeof promiseData === "object" && !Mo.isVNode(promiseData);
146
+ const toastSettings = isExtendedResult ? promiseData : {
147
+ message: promiseData || "",
148
+ id: id || ""
149
+ };
150
+ this.create({
151
+ id,
152
+ type: "error",
153
+ description,
154
+ ...toastSettings
155
+ });
156
+ } else if (response instanceof Error) {
157
+ shouldDismiss = false;
158
+ const promiseData = typeof data.error === "function" ? await data.error(response) : data.error;
159
+ const description = typeof data.description === "function" ? await data.description(response) : data.description;
160
+ const isExtendedResult = typeof promiseData === "object" && !Mo.isVNode(promiseData);
161
+ const toastSettings = isExtendedResult ? promiseData : {
162
+ message: promiseData || "",
163
+ id: id || ""
164
+ };
165
+ this.create({
166
+ id,
167
+ type: "error",
168
+ description,
169
+ ...toastSettings
170
+ });
171
+ } else if (data.success !== void 0) {
172
+ shouldDismiss = false;
173
+ const promiseData = typeof data.success === "function" ? await data.success(response) : data.success;
174
+ const description = typeof data.description === "function" ? await data.description(response) : data.description;
175
+ const isExtendedResult = typeof promiseData === "object" && !Mo.isVNode(promiseData);
176
+ const toastSettings = isExtendedResult ? promiseData : {
177
+ message: promiseData || "",
178
+ id: id || ""
179
+ };
180
+ this.create({
181
+ id,
182
+ type: "success",
183
+ description,
184
+ ...toastSettings
185
+ });
186
+ }
187
+ }).catch(async (error) => {
188
+ result = ["reject", error];
189
+ if (data.error !== void 0) {
190
+ shouldDismiss = false;
191
+ const promiseData = typeof data.error === "function" ? await data.error(error) : data.error;
192
+ const description = typeof data.description === "function" ? await data.description(error) : data.description;
193
+ const isExtendedResult = typeof promiseData === "object" && !Mo.isVNode(promiseData);
194
+ const toastSettings = isExtendedResult ? promiseData : {
195
+ message: promiseData || "",
196
+ id: id || ""
197
+ };
198
+ this.create({
199
+ id,
200
+ type: "error",
201
+ description,
202
+ ...toastSettings
203
+ });
204
+ }
205
+ }).finally(() => {
206
+ var _a;
207
+ if (shouldDismiss) {
208
+ this.dismiss(id);
209
+ id = void 0;
210
+ }
211
+ (_a = data.finally) == null ? void 0 : _a.call(data);
212
+ });
213
+ const unwrap = () => new Promise((resolve, reject) => originalPromise.then(() => result[0] === "reject" ? reject(result[1]) : resolve(result[1])).catch(reject));
214
+ if (typeof id !== "string" && typeof id !== "number") return { unwrap };
215
+ else return Object.assign(id, { unwrap });
216
+ });
217
+ __publicField(this, "custom", (component, data) => {
218
+ const id = (data == null ? void 0 : data.id) || toastsCounter++;
219
+ this.publish({
220
+ component,
221
+ id,
222
+ ...data
223
+ });
224
+ return id;
225
+ });
226
+ __publicField(this, "getActiveToasts", () => {
227
+ return this.toasts.filter((toast$1) => !this.dismissedToasts.has(toast$1.id));
228
+ });
229
+ this.subscribers = [];
230
+ this.toasts = [];
231
+ this.dismissedToasts = /* @__PURE__ */ new Set();
232
+ }
233
+ };
234
+ const ToastState = new Observer();
235
+ function toastFunction(message, data) {
236
+ const id = (data == null ? void 0 : data.id) || toastsCounter++;
237
+ ToastState.create({
238
+ message,
239
+ id,
240
+ type: "default",
241
+ ...data
242
+ });
243
+ return id;
244
+ }
245
+ const isHttpResponse = (data) => {
246
+ return data && typeof data === "object" && "ok" in data && typeof data.ok === "boolean" && "status" in data && typeof data.status === "number";
247
+ };
248
+ const basicToast = toastFunction;
249
+ const getHistory = () => ToastState.toasts;
250
+ const getToasts = () => ToastState.getActiveToasts();
251
+ const toast = Object.assign(basicToast, {
252
+ success: ToastState.success,
253
+ info: ToastState.info,
254
+ warning: ToastState.warning,
255
+ error: ToastState.error,
256
+ custom: ToastState.custom,
257
+ message: ToastState.message,
258
+ promise: ToastState.promise,
259
+ dismiss: ToastState.dismiss,
260
+ loading: ToastState.loading
261
+ }, {
262
+ getHistory,
263
+ getToasts
264
+ });
265
+ function isAction(action) {
266
+ return action.label !== void 0;
267
+ }
268
+ const VISIBLE_TOASTS_AMOUNT = 3;
269
+ const VIEWPORT_OFFSET = "24px";
270
+ const MOBILE_VIEWPORT_OFFSET = "16px";
271
+ const TOAST_LIFETIME = 4e3;
272
+ const TOAST_WIDTH = 356;
273
+ const GAP = 14;
274
+ const SWIPE_THRESHOLD = 45;
275
+ const TIME_BEFORE_UNMOUNT = 200;
276
+ function useIsDocumentHidden() {
277
+ const isDocumentHidden = Mo.ref(false);
278
+ Mo.watchEffect(() => {
279
+ const callback = () => {
280
+ isDocumentHidden.value = document.hidden;
281
+ };
282
+ document.addEventListener("visibilitychange", callback);
283
+ return () => window.removeEventListener("visibilitychange", callback);
284
+ });
285
+ return { isDocumentHidden };
286
+ }
287
+ function cn(...classes) {
288
+ return classes.filter(Boolean).join(" ");
289
+ }
290
+ function getDefaultSwipeDirections(position) {
291
+ const [y, x] = position.split("-");
292
+ const directions = [];
293
+ if (y) directions.push(y);
294
+ if (x) directions.push(x);
295
+ return directions;
296
+ }
297
+ function assignOffset(defaultOffset, mobileOffset) {
298
+ const styles = {};
299
+ [defaultOffset, mobileOffset].forEach((offset, index) => {
300
+ const isMobile = index === 1;
301
+ const prefix = isMobile ? "--mobile-offset" : "--offset";
302
+ const defaultValue = isMobile ? MOBILE_VIEWPORT_OFFSET : VIEWPORT_OFFSET;
303
+ function assignAll(offset$1) {
304
+ [
305
+ "top",
306
+ "right",
307
+ "bottom",
308
+ "left"
309
+ ].forEach((key) => {
310
+ styles[`${prefix}-${key}`] = typeof offset$1 === "number" ? `${offset$1}px` : offset$1;
311
+ });
312
+ }
313
+ if (typeof offset === "number" || typeof offset === "string") assignAll(offset);
314
+ else if (typeof offset === "object") [
315
+ "top",
316
+ "right",
317
+ "bottom",
318
+ "left"
319
+ ].forEach((key) => {
320
+ if (offset[key] === void 0) styles[`${prefix}-${key}`] = defaultValue;
321
+ else styles[`${prefix}-${key}`] = typeof offset[key] === "number" ? `${offset[key]}px` : offset[key];
322
+ });
323
+ else assignAll(defaultValue);
324
+ });
325
+ return styles;
326
+ }
327
+ const _hoisted_1$7 = [
328
+ "data-rich-colors",
329
+ "data-styled",
330
+ "data-mounted",
331
+ "data-promise",
332
+ "data-swiped",
333
+ "data-removed",
334
+ "data-visible",
335
+ "data-y-position",
336
+ "data-x-position",
337
+ "data-index",
338
+ "data-front",
339
+ "data-swiping",
340
+ "data-dismissible",
341
+ "data-type",
342
+ "data-invert",
343
+ "data-swipe-out",
344
+ "data-swipe-direction",
345
+ "data-expanded"
346
+ ];
347
+ const _hoisted_2$2 = ["aria-label", "data-disabled"];
348
+ var Toast_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ Mo.defineComponent({
349
+ __name: "Toast",
350
+ props: {
351
+ toast: {},
352
+ toasts: {},
353
+ index: {},
354
+ swipeDirections: {},
355
+ expanded: { type: Boolean },
356
+ invert: { type: Boolean },
357
+ heights: {},
358
+ gap: {},
359
+ position: {},
360
+ visibleToasts: {},
361
+ expandByDefault: { type: Boolean },
362
+ closeButton: { type: Boolean },
363
+ interacting: { type: Boolean },
364
+ style: {},
365
+ cancelButtonStyle: {},
366
+ actionButtonStyle: {},
367
+ duration: {},
368
+ class: {},
369
+ unstyled: { type: Boolean },
370
+ descriptionClass: {},
371
+ loadingIcon: {},
372
+ classes: {},
373
+ icons: {},
374
+ closeButtonAriaLabel: {},
375
+ defaultRichColors: { type: Boolean }
376
+ },
377
+ emits: [
378
+ "update:heights",
379
+ "update:height",
380
+ "removeToast"
381
+ ],
382
+ setup(__props, { emit: __emit }) {
383
+ const props = __props;
384
+ const emit = __emit;
385
+ const swipeDirection = Mo.ref(null);
386
+ const swipeOutDirection = Mo.ref(null);
387
+ const mounted = Mo.ref(false);
388
+ const removed = Mo.ref(false);
389
+ const swiping = Mo.ref(false);
390
+ const swipeOut = Mo.ref(false);
391
+ const swiped = Mo.ref(false);
392
+ const offsetBeforeRemove = Mo.ref(0);
393
+ const initialHeight = Mo.ref(0);
394
+ const remainingTime = Mo.ref(props.toast.duration || props.duration || TOAST_LIFETIME);
395
+ const dragStartTime = Mo.ref(null);
396
+ const toastRef = Mo.ref(null);
397
+ const isFront = Mo.computed(() => props.index === 0);
398
+ const isVisible = Mo.computed(() => props.index + 1 <= props.visibleToasts);
399
+ const toastType = Mo.computed(() => props.toast.type);
400
+ const dismissible = Mo.computed(() => props.toast.dismissible !== false);
401
+ const toastClass = Mo.computed(() => props.toast.class || "");
402
+ const toastDescriptionClass = Mo.computed(() => props.descriptionClass || "");
403
+ const heightIndex = Mo.computed(() => {
404
+ const currentPosition = props.toast.position || props.position;
405
+ const samePositionHeights = props.heights.filter((h) => h.position === currentPosition);
406
+ const index = samePositionHeights.findIndex((height) => height.toastId === props.toast.id);
407
+ return index >= 0 ? index : 0;
408
+ });
409
+ const toastsHeightBefore = Mo.computed(() => {
410
+ const currentPosition = props.toast.position || props.position;
411
+ const samePositionHeights = props.heights.filter((h) => h.position === currentPosition);
412
+ return samePositionHeights.reduce((prev, curr, reducerIndex) => {
413
+ if (reducerIndex >= heightIndex.value) return prev;
414
+ return prev + curr.height;
415
+ }, 0);
416
+ });
417
+ const offset = Mo.computed(() => heightIndex.value * props.gap + toastsHeightBefore.value || 0);
418
+ const closeButton = Mo.computed(() => props.toast.closeButton ?? props.closeButton);
419
+ const duration = Mo.computed(() => props.toast.duration || props.duration || TOAST_LIFETIME);
420
+ const closeTimerStartTimeRef = Mo.ref(0);
421
+ const lastCloseTimerStartTimeRef = Mo.ref(0);
422
+ const pointerStartRef = Mo.ref(null);
423
+ const coords = Mo.computed(() => props.position.split("-"));
424
+ const y = Mo.computed(() => coords.value[0]);
425
+ const x = Mo.computed(() => coords.value[1]);
426
+ const isStringOfTitle = Mo.computed(() => typeof props.toast.title !== "string");
427
+ const isStringOfDescription = Mo.computed(() => typeof props.toast.description !== "string");
428
+ const { isDocumentHidden } = useIsDocumentHidden();
429
+ const disabled = Mo.computed(() => toastType.value && toastType.value === "loading");
430
+ Mo.onMounted(() => {
431
+ mounted.value = true;
432
+ remainingTime.value = duration.value;
433
+ });
434
+ Mo.watchEffect(async () => {
435
+ if (!mounted.value || !toastRef.value) return;
436
+ await Mo.nextTick();
437
+ const toastNode = toastRef.value;
438
+ const originalHeight = toastNode.style.height;
439
+ toastNode.style.height = "auto";
440
+ const newHeight = toastNode.getBoundingClientRect().height;
441
+ toastNode.style.height = originalHeight;
442
+ initialHeight.value = newHeight;
443
+ emit("update:height", {
444
+ toastId: props.toast.id,
445
+ height: newHeight,
446
+ position: props.toast.position || props.position
447
+ });
448
+ });
449
+ function deleteToast() {
450
+ removed.value = true;
451
+ offsetBeforeRemove.value = offset.value;
452
+ setTimeout(() => {
453
+ emit("removeToast", props.toast);
454
+ }, TIME_BEFORE_UNMOUNT);
455
+ }
456
+ function handleCloseToast() {
457
+ var _a, _b;
458
+ if (disabled.value || !dismissible.value) return {};
459
+ deleteToast();
460
+ (_b = (_a = props.toast).onDismiss) == null ? void 0 : _b.call(_a, props.toast);
461
+ }
462
+ function onPointerDown(event) {
463
+ if (disabled.value || !dismissible.value) return;
464
+ dragStartTime.value = /* @__PURE__ */ new Date();
465
+ offsetBeforeRemove.value = offset.value;
466
+ event.target.setPointerCapture(event.pointerId);
467
+ if (event.target.tagName === "BUTTON") return;
468
+ swiping.value = true;
469
+ pointerStartRef.value = {
470
+ x: event.clientX,
471
+ y: event.clientY
472
+ };
473
+ }
474
+ function onPointerUp() {
475
+ var _a, _b, _c, _d, _e, _f, _g;
476
+ if (swipeOut.value || !dismissible.value) return;
477
+ pointerStartRef.value = null;
478
+ const swipeAmountX = Number(((_a = toastRef.value) == null ? void 0 : _a.style.getPropertyValue("--swipe-amount-x").replace("px", "")) || 0);
479
+ const swipeAmountY = Number(((_b = toastRef.value) == null ? void 0 : _b.style.getPropertyValue("--swipe-amount-y").replace("px", "")) || 0);
480
+ const timeTaken = (/* @__PURE__ */ new Date()).getTime() - (((_c = dragStartTime.value) == null ? void 0 : _c.getTime()) || 0);
481
+ const swipeAmount = swipeDirection.value === "x" ? swipeAmountX : swipeAmountY;
482
+ const velocity = Math.abs(swipeAmount) / timeTaken;
483
+ if (Math.abs(swipeAmount) >= SWIPE_THRESHOLD || velocity > 0.11) {
484
+ offsetBeforeRemove.value = offset.value;
485
+ (_e = (_d = props.toast).onDismiss) == null ? void 0 : _e.call(_d, props.toast);
486
+ if (swipeDirection.value === "x") swipeOutDirection.value = swipeAmountX > 0 ? "right" : "left";
487
+ else swipeOutDirection.value = swipeAmountY > 0 ? "down" : "up";
488
+ deleteToast();
489
+ swipeOut.value = true;
490
+ return;
491
+ } else {
492
+ (_f = toastRef.value) == null ? void 0 : _f.style.setProperty("--swipe-amount-x", `0px`);
493
+ (_g = toastRef.value) == null ? void 0 : _g.style.setProperty("--swipe-amount-y", `0px`);
494
+ }
495
+ swiped.value = false;
496
+ swiping.value = false;
497
+ swipeDirection.value = null;
498
+ }
499
+ function onPointerMove(event) {
500
+ var _a, _b, _c, _d;
501
+ if (!pointerStartRef.value || !dismissible.value) return;
502
+ const isHighlighted = ((_b = (_a = window == null ? void 0 : window.getSelection()) == null ? void 0 : _a.toString()) == null ? void 0 : _b.length) ?? false;
503
+ if (isHighlighted) return;
504
+ const yDelta = event.clientY - pointerStartRef.value.y;
505
+ const xDelta = event.clientX - pointerStartRef.value.x;
506
+ const swipeDirections = props.swipeDirections ?? getDefaultSwipeDirections(props.position);
507
+ if (!swipeDirection.value && (Math.abs(xDelta) > 1 || Math.abs(yDelta) > 1)) swipeDirection.value = Math.abs(xDelta) > Math.abs(yDelta) ? "x" : "y";
508
+ let swipeAmount = {
509
+ x: 0,
510
+ y: 0
511
+ };
512
+ const getDampening = (delta) => {
513
+ const factor = Math.abs(delta) / 20;
514
+ return 1 / (1.5 + factor);
515
+ };
516
+ if (swipeDirection.value === "y") {
517
+ if (swipeDirections.includes("top") || swipeDirections.includes("bottom")) if (swipeDirections.includes("top") && yDelta < 0 || swipeDirections.includes("bottom") && yDelta > 0) swipeAmount.y = yDelta;
518
+ else {
519
+ const dampenedDelta = yDelta * getDampening(yDelta);
520
+ swipeAmount.y = Math.abs(dampenedDelta) < Math.abs(yDelta) ? dampenedDelta : yDelta;
521
+ }
522
+ } else if (swipeDirection.value === "x") {
523
+ if (swipeDirections.includes("left") || swipeDirections.includes("right")) if (swipeDirections.includes("left") && xDelta < 0 || swipeDirections.includes("right") && xDelta > 0) swipeAmount.x = xDelta;
524
+ else {
525
+ const dampenedDelta = xDelta * getDampening(xDelta);
526
+ swipeAmount.x = Math.abs(dampenedDelta) < Math.abs(xDelta) ? dampenedDelta : xDelta;
527
+ }
528
+ }
529
+ if (Math.abs(swipeAmount.x) > 0 || Math.abs(swipeAmount.y) > 0) swiped.value = true;
530
+ (_c = toastRef.value) == null ? void 0 : _c.style.setProperty("--swipe-amount-x", `${swipeAmount.x}px`);
531
+ (_d = toastRef.value) == null ? void 0 : _d.style.setProperty("--swipe-amount-y", `${swipeAmount.y}px`);
532
+ }
533
+ Mo.onMounted(() => {
534
+ mounted.value = true;
535
+ if (!toastRef.value) return;
536
+ const height = toastRef.value.getBoundingClientRect().height;
537
+ initialHeight.value = height;
538
+ const newHeights = [{
539
+ toastId: props.toast.id,
540
+ height,
541
+ position: props.toast.position
542
+ }, ...props.heights];
543
+ emit("update:heights", newHeights);
544
+ });
545
+ Mo.onBeforeUnmount(() => {
546
+ if (toastRef.value) emit("removeToast", props.toast);
547
+ });
548
+ Mo.watchEffect((onInvalidate) => {
549
+ if (props.toast.promise && toastType.value === "loading" || props.toast.duration === Infinity || props.toast.type === "loading") return;
550
+ let timeoutId;
551
+ const pauseTimer = () => {
552
+ if (lastCloseTimerStartTimeRef.value < closeTimerStartTimeRef.value) {
553
+ const elapsedTime = (/* @__PURE__ */ new Date()).getTime() - closeTimerStartTimeRef.value;
554
+ remainingTime.value = remainingTime.value - elapsedTime;
555
+ }
556
+ lastCloseTimerStartTimeRef.value = (/* @__PURE__ */ new Date()).getTime();
557
+ };
558
+ const startTimer = () => {
559
+ if (remainingTime.value === Infinity) return;
560
+ closeTimerStartTimeRef.value = (/* @__PURE__ */ new Date()).getTime();
561
+ timeoutId = setTimeout(() => {
562
+ var _a, _b;
563
+ (_b = (_a = props.toast).onAutoClose) == null ? void 0 : _b.call(_a, props.toast);
564
+ deleteToast();
565
+ }, remainingTime.value);
566
+ };
567
+ if (props.expanded || props.interacting || isDocumentHidden.value) pauseTimer();
568
+ else startTimer();
569
+ onInvalidate(() => {
570
+ clearTimeout(timeoutId);
571
+ });
572
+ });
573
+ Mo.watch(() => props.toast.delete, (value) => {
574
+ if (value !== void 0 && value) deleteToast();
575
+ }, { deep: true });
576
+ function handleDragEnd() {
577
+ swiping.value = false;
578
+ swipeDirection.value = null;
579
+ pointerStartRef.value = null;
580
+ }
581
+ return (_ctx, _cache) => {
582
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A;
583
+ return Mo.openBlock(), Mo.createElementBlock("li", {
584
+ tabindex: "0",
585
+ ref_key: "toastRef",
586
+ ref: toastRef,
587
+ class: Mo.normalizeClass(Mo.unref(cn)(props.class, toastClass.value, (_a = _ctx.classes) == null ? void 0 : _a.toast, (_b = _ctx.toast.classes) == null ? void 0 : _b.toast, (_c = _ctx.classes) == null ? void 0 : _c[toastType.value], (_e = (_d = _ctx.toast) == null ? void 0 : _d.classes) == null ? void 0 : _e[toastType.value])),
588
+ "data-sonner-toast": "",
589
+ "data-rich-colors": _ctx.toast.richColors ?? _ctx.defaultRichColors,
590
+ "data-styled": !Boolean(_ctx.toast.component || ((_f = _ctx.toast) == null ? void 0 : _f.unstyled) || _ctx.unstyled),
591
+ "data-mounted": mounted.value,
592
+ "data-promise": Boolean(_ctx.toast.promise),
593
+ "data-swiped": swiped.value,
594
+ "data-removed": removed.value,
595
+ "data-visible": isVisible.value,
596
+ "data-y-position": y.value,
597
+ "data-x-position": x.value,
598
+ "data-index": _ctx.index,
599
+ "data-front": isFront.value,
600
+ "data-swiping": swiping.value,
601
+ "data-dismissible": dismissible.value,
602
+ "data-type": toastType.value,
603
+ "data-invert": _ctx.toast.invert || _ctx.invert,
604
+ "data-swipe-out": swipeOut.value,
605
+ "data-swipe-direction": swipeOutDirection.value,
606
+ "data-expanded": Boolean(_ctx.expanded || _ctx.expandByDefault && mounted.value),
607
+ style: Mo.normalizeStyle({
608
+ "--index": _ctx.index,
609
+ "--toasts-before": _ctx.index,
610
+ "--z-index": _ctx.toasts.length - _ctx.index,
611
+ "--offset": `${removed.value ? offsetBeforeRemove.value : offset.value}px`,
612
+ "--initial-height": _ctx.expandByDefault ? "auto" : `${initialHeight.value}px`,
613
+ ..._ctx.style,
614
+ ...props.toast.style
615
+ }),
616
+ onDragend: handleDragEnd,
617
+ onPointerdown: onPointerDown,
618
+ onPointerup: onPointerUp,
619
+ onPointermove: onPointerMove
620
+ }, [closeButton.value && !_ctx.toast.component && toastType.value !== "loading" ? (Mo.openBlock(), Mo.createElementBlock("button", {
621
+ key: 0,
622
+ "aria-label": _ctx.closeButtonAriaLabel || "Close toast",
623
+ "data-disabled": disabled.value,
624
+ "data-close-button": "true",
625
+ class: Mo.normalizeClass(Mo.unref(cn)((_g = _ctx.classes) == null ? void 0 : _g.closeButton, (_i = (_h = _ctx.toast) == null ? void 0 : _h.classes) == null ? void 0 : _i.closeButton)),
626
+ onClick: handleCloseToast
627
+ }, [((_j = _ctx.icons) == null ? void 0 : _j.close) ? (Mo.openBlock(), Mo.createBlock(Mo.resolveDynamicComponent((_k = _ctx.icons) == null ? void 0 : _k.close), { key: 0 })) : Mo.renderSlot(_ctx.$slots, "close-icon", { key: 1 })], 10, _hoisted_2$2)) : Mo.createCommentVNode("v-if", true), _ctx.toast.component ? (Mo.openBlock(), Mo.createBlock(Mo.resolveDynamicComponent(_ctx.toast.component), Mo.mergeProps({ key: 1 }, _ctx.toast.componentProps, { onCloseToast: handleCloseToast }), null, 16)) : (Mo.openBlock(), Mo.createElementBlock(Mo.Fragment, { key: 2 }, [
628
+ toastType.value !== "default" || _ctx.toast.icon || _ctx.toast.promise ? (Mo.openBlock(), Mo.createElementBlock("div", {
629
+ key: 0,
630
+ "data-icon": "",
631
+ class: Mo.normalizeClass(Mo.unref(cn)((_l = _ctx.classes) == null ? void 0 : _l.icon, (_n = (_m = _ctx.toast) == null ? void 0 : _m.classes) == null ? void 0 : _n.icon))
632
+ }, [_ctx.toast.icon ? (Mo.openBlock(), Mo.createBlock(Mo.resolveDynamicComponent(_ctx.toast.icon), { key: 0 })) : (Mo.openBlock(), Mo.createElementBlock(Mo.Fragment, { key: 1 }, [toastType.value === "loading" ? Mo.renderSlot(_ctx.$slots, "loading-icon", { key: 0 }) : toastType.value === "success" ? Mo.renderSlot(_ctx.$slots, "success-icon", { key: 1 }) : toastType.value === "error" ? Mo.renderSlot(_ctx.$slots, "error-icon", { key: 2 }) : toastType.value === "warning" ? Mo.renderSlot(_ctx.$slots, "warning-icon", { key: 3 }) : toastType.value === "info" ? Mo.renderSlot(_ctx.$slots, "info-icon", { key: 4 }) : Mo.createCommentVNode("v-if", true)], 64))], 2)) : Mo.createCommentVNode("v-if", true),
633
+ Mo.createElementVNode("div", {
634
+ "data-content": "",
635
+ class: Mo.normalizeClass(Mo.unref(cn)((_o = _ctx.classes) == null ? void 0 : _o.content, (_q = (_p = _ctx.toast) == null ? void 0 : _p.classes) == null ? void 0 : _q.content))
636
+ }, [Mo.createElementVNode("div", {
637
+ "data-title": "",
638
+ class: Mo.normalizeClass(Mo.unref(cn)((_r = _ctx.classes) == null ? void 0 : _r.title, (_s = _ctx.toast.classes) == null ? void 0 : _s.title))
639
+ }, [isStringOfTitle.value ? (Mo.openBlock(), Mo.createBlock(Mo.resolveDynamicComponent(_ctx.toast.title), Mo.normalizeProps(Mo.mergeProps({ key: 0 }, _ctx.toast.componentProps)), null, 16)) : (Mo.openBlock(), Mo.createElementBlock(Mo.Fragment, { key: 1 }, [Mo.createTextVNode(Mo.toDisplayString(_ctx.toast.title), 1)], 64))], 2), _ctx.toast.description ? (Mo.openBlock(), Mo.createElementBlock("div", {
640
+ key: 0,
641
+ "data-description": "",
642
+ class: Mo.normalizeClass(Mo.unref(cn)(_ctx.descriptionClass, toastDescriptionClass.value, (_t = _ctx.classes) == null ? void 0 : _t.description, (_u = _ctx.toast.classes) == null ? void 0 : _u.description))
643
+ }, [isStringOfDescription.value ? (Mo.openBlock(), Mo.createBlock(Mo.resolveDynamicComponent(_ctx.toast.description), Mo.normalizeProps(Mo.mergeProps({ key: 0 }, _ctx.toast.componentProps)), null, 16)) : (Mo.openBlock(), Mo.createElementBlock(Mo.Fragment, { key: 1 }, [Mo.createTextVNode(Mo.toDisplayString(_ctx.toast.description), 1)], 64))], 2)) : Mo.createCommentVNode("v-if", true)], 2),
644
+ _ctx.toast.cancel ? (Mo.openBlock(), Mo.createElementBlock("button", {
645
+ key: 1,
646
+ style: Mo.normalizeStyle(_ctx.toast.cancelButtonStyle || _ctx.cancelButtonStyle),
647
+ class: Mo.normalizeClass(Mo.unref(cn)((_v = _ctx.classes) == null ? void 0 : _v.cancelButton, (_w = _ctx.toast.classes) == null ? void 0 : _w.cancelButton)),
648
+ "data-button": "",
649
+ "data-cancel": "",
650
+ onClick: _cache[0] || (_cache[0] = (event) => {
651
+ var _a2, _b2;
652
+ if (!Mo.unref(isAction)(_ctx.toast.cancel)) return;
653
+ if (!dismissible.value) return;
654
+ (_b2 = (_a2 = _ctx.toast.cancel).onClick) == null ? void 0 : _b2.call(_a2, event);
655
+ deleteToast();
656
+ })
657
+ }, Mo.toDisplayString(Mo.unref(isAction)(_ctx.toast.cancel) ? (_x = _ctx.toast.cancel) == null ? void 0 : _x.label : _ctx.toast.cancel), 7)) : Mo.createCommentVNode("v-if", true),
658
+ _ctx.toast.action ? (Mo.openBlock(), Mo.createElementBlock("button", {
659
+ key: 2,
660
+ style: Mo.normalizeStyle(_ctx.toast.actionButtonStyle || _ctx.actionButtonStyle),
661
+ class: Mo.normalizeClass(Mo.unref(cn)((_y = _ctx.classes) == null ? void 0 : _y.actionButton, (_z = _ctx.toast.classes) == null ? void 0 : _z.actionButton)),
662
+ "data-button": "",
663
+ "data-action": "",
664
+ onClick: _cache[1] || (_cache[1] = (event) => {
665
+ var _a2, _b2;
666
+ if (!Mo.unref(isAction)(_ctx.toast.action)) return;
667
+ (_b2 = (_a2 = _ctx.toast.action).onClick) == null ? void 0 : _b2.call(_a2, event);
668
+ if (event.defaultPrevented) return;
669
+ deleteToast();
670
+ })
671
+ }, Mo.toDisplayString(Mo.unref(isAction)(_ctx.toast.action) ? (_A = _ctx.toast.action) == null ? void 0 : _A.label : _ctx.toast.action), 7)) : Mo.createCommentVNode("v-if", true)
672
+ ], 64))], 46, _hoisted_1$7);
673
+ };
674
+ }
675
+ });
676
+ var Toast_default = Toast_vue_vue_type_script_setup_true_lang_default;
677
+ var export_helper_default = (sfc, props) => {
678
+ const target = sfc.__vccOpts || sfc;
679
+ for (const [key, val] of props) target[key] = val;
680
+ return target;
681
+ };
682
+ const _sfc_main$4 = {};
683
+ const _hoisted_1$6 = {
684
+ xmlns: "http://www.w3.org/2000/svg",
685
+ width: "12",
686
+ height: "12",
687
+ viewBox: "0 0 24 24",
688
+ fill: "none",
689
+ stroke: "currentColor",
690
+ "stoke-width": "1.5",
691
+ "stroke-linecap": "round",
692
+ "stroke-linejoin": "round"
693
+ };
694
+ function _sfc_render$4(_ctx, _cache) {
695
+ return Mo.openBlock(), Mo.createElementBlock("svg", _hoisted_1$6, _cache[0] || (_cache[0] = [Mo.createElementVNode("line", {
696
+ x1: "18",
697
+ y1: "6",
698
+ x2: "6",
699
+ y2: "18"
700
+ }, null, -1), Mo.createElementVNode("line", {
701
+ x1: "6",
702
+ y1: "6",
703
+ x2: "18",
704
+ y2: "18"
705
+ }, null, -1)]));
706
+ }
707
+ var CloseIcon_default = /* @__PURE__ */ export_helper_default(_sfc_main$4, [["render", _sfc_render$4]]);
708
+ const _hoisted_1$5 = ["data-visible"];
709
+ const _hoisted_2$1 = { class: "sonner-spinner" };
710
+ var Loader_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ Mo.defineComponent({
711
+ __name: "Loader",
712
+ props: { visible: { type: Boolean } },
713
+ setup(__props) {
714
+ const bars = Array(12).fill(0);
715
+ return (_ctx, _cache) => {
716
+ return Mo.openBlock(), Mo.createElementBlock("div", {
717
+ class: "sonner-loading-wrapper",
718
+ "data-visible": _ctx.visible
719
+ }, [Mo.createElementVNode("div", _hoisted_2$1, [(Mo.openBlock(true), Mo.createElementBlock(Mo.Fragment, null, Mo.renderList(Mo.unref(bars), (bar) => {
720
+ return Mo.openBlock(), Mo.createElementBlock("div", {
721
+ key: `spinner-bar-${bar}`,
722
+ class: "sonner-loading-bar"
723
+ });
724
+ }), 128))])], 8, _hoisted_1$5);
725
+ };
726
+ }
727
+ });
728
+ var Loader_default = Loader_vue_vue_type_script_setup_true_lang_default;
729
+ const _sfc_main$3 = {};
730
+ const _hoisted_1$4 = {
731
+ xmlns: "http://www.w3.org/2000/svg",
732
+ viewBox: "0 0 20 20",
733
+ fill: "currentColor",
734
+ height: "20",
735
+ width: "20"
736
+ };
737
+ function _sfc_render$3(_ctx, _cache) {
738
+ return Mo.openBlock(), Mo.createElementBlock("svg", _hoisted_1$4, _cache[0] || (_cache[0] = [Mo.createElementVNode("path", {
739
+ "fill-rule": "evenodd",
740
+ d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",
741
+ "clip-rule": "evenodd"
742
+ }, null, -1)]));
743
+ }
744
+ var SuccessIcon_default = /* @__PURE__ */ export_helper_default(_sfc_main$3, [["render", _sfc_render$3]]);
745
+ const _sfc_main$2 = {};
746
+ const _hoisted_1$3 = {
747
+ xmlns: "http://www.w3.org/2000/svg",
748
+ viewBox: "0 0 20 20",
749
+ fill: "currentColor",
750
+ height: "20",
751
+ width: "20"
752
+ };
753
+ function _sfc_render$2(_ctx, _cache) {
754
+ return Mo.openBlock(), Mo.createElementBlock("svg", _hoisted_1$3, _cache[0] || (_cache[0] = [Mo.createElementVNode("path", {
755
+ "fill-rule": "evenodd",
756
+ d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",
757
+ "clip-rule": "evenodd"
758
+ }, null, -1)]));
759
+ }
760
+ var InfoIcon_default = /* @__PURE__ */ export_helper_default(_sfc_main$2, [["render", _sfc_render$2]]);
761
+ const _sfc_main$1 = {};
762
+ const _hoisted_1$2 = {
763
+ xmlns: "http://www.w3.org/2000/svg",
764
+ viewBox: "0 0 24 24",
765
+ fill: "currentColor",
766
+ height: "20",
767
+ width: "20"
768
+ };
769
+ function _sfc_render$1(_ctx, _cache) {
770
+ return Mo.openBlock(), Mo.createElementBlock("svg", _hoisted_1$2, _cache[0] || (_cache[0] = [Mo.createElementVNode("path", {
771
+ "fill-rule": "evenodd",
772
+ d: "M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",
773
+ "clip-rule": "evenodd"
774
+ }, null, -1)]));
775
+ }
776
+ var WarningIcon_default = /* @__PURE__ */ export_helper_default(_sfc_main$1, [["render", _sfc_render$1]]);
777
+ const _sfc_main$5 = {};
778
+ const _hoisted_1$1 = {
779
+ xmlns: "http://www.w3.org/2000/svg",
780
+ viewBox: "0 0 20 20",
781
+ fill: "currentColor",
782
+ height: "20",
783
+ width: "20"
784
+ };
785
+ function _sfc_render(_ctx, _cache) {
786
+ return Mo.openBlock(), Mo.createElementBlock("svg", _hoisted_1$1, _cache[0] || (_cache[0] = [Mo.createElementVNode("path", {
787
+ "fill-rule": "evenodd",
788
+ d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",
789
+ "clip-rule": "evenodd"
790
+ }, null, -1)]));
791
+ }
792
+ var ErrorIcon_default = /* @__PURE__ */ export_helper_default(_sfc_main$5, [["render", _sfc_render]]);
793
+ const _hoisted_1 = ["aria-label"];
794
+ const _hoisted_2 = [
795
+ "data-sonner-theme",
796
+ "dir",
797
+ "data-theme",
798
+ "data-rich-colors",
799
+ "data-y-position",
800
+ "data-x-position",
801
+ "data-lifted"
802
+ ];
803
+ const isClient = typeof window !== "undefined" && typeof document !== "undefined";
804
+ function getDocumentDirection() {
805
+ if (typeof window === "undefined") return "ltr";
806
+ if (typeof document === "undefined") return "ltr";
807
+ const dirAttribute = document.documentElement.getAttribute("dir");
808
+ if (dirAttribute === "auto" || !dirAttribute) return window.getComputedStyle(document.documentElement).direction;
809
+ return dirAttribute;
810
+ }
811
+ var Toaster_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ Mo.defineComponent({
812
+ name: "Toaster",
813
+ inheritAttrs: false,
814
+ __name: "Toaster",
815
+ props: {
816
+ invert: {
817
+ type: Boolean,
818
+ default: false
819
+ },
820
+ theme: { default: "light" },
821
+ position: { default: "bottom-right" },
822
+ hotkey: { default: () => ["altKey", "KeyT"] },
823
+ richColors: {
824
+ type: Boolean,
825
+ default: false
826
+ },
827
+ expand: {
828
+ type: Boolean,
829
+ default: false
830
+ },
831
+ duration: {},
832
+ gap: { default: GAP },
833
+ visibleToasts: { default: VISIBLE_TOASTS_AMOUNT },
834
+ closeButton: {
835
+ type: Boolean,
836
+ default: false
837
+ },
838
+ toastOptions: { default: () => ({}) },
839
+ class: { default: "" },
840
+ style: {},
841
+ offset: { default: VIEWPORT_OFFSET },
842
+ mobileOffset: { default: MOBILE_VIEWPORT_OFFSET },
843
+ dir: { default: "auto" },
844
+ swipeDirections: {},
845
+ icons: {},
846
+ containerAriaLabel: { default: "Notifications" }
847
+ },
848
+ setup(__props) {
849
+ const props = __props;
850
+ const attrs = Mo.useAttrs();
851
+ const toasts = Mo.ref([]);
852
+ function filteredToasts(pos, index) {
853
+ return toasts.value.filter((toast$1) => !toast$1.position && index === 0 || toast$1.position === pos);
854
+ }
855
+ const possiblePositions = Mo.computed(() => {
856
+ const posList = toasts.value.filter((toast$1) => toast$1.position).map((toast$1) => toast$1.position);
857
+ return posList.length > 0 ? Array.from(new Set([props.position].concat(posList))) : [props.position];
858
+ });
859
+ const toastsByPosition = Mo.computed(() => {
860
+ const result = {};
861
+ possiblePositions.value.forEach((pos) => {
862
+ result[pos] = toasts.value.filter((t) => t.position === pos);
863
+ });
864
+ return result;
865
+ });
866
+ const heights = Mo.ref([]);
867
+ const expanded = Mo.ref(false);
868
+ const interacting = Mo.ref(false);
869
+ const actualTheme = Mo.ref(props.theme !== "system" ? props.theme : typeof window !== "undefined" ? window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : "light");
870
+ const listRef = Mo.ref(null);
871
+ const lastFocusedElementRef = Mo.ref(null);
872
+ const isFocusWithinRef = Mo.ref(false);
873
+ const hotkeyLabel = props.hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, "");
874
+ function removeToast(toastToRemove) {
875
+ var _a;
876
+ if (!((_a = toasts.value.find((toast$1) => toast$1.id === toastToRemove.id)) == null ? void 0 : _a.delete)) ToastState.dismiss(toastToRemove.id);
877
+ toasts.value = toasts.value.filter(({ id }) => id !== toastToRemove.id);
878
+ setTimeout(() => {
879
+ if (!toasts.value.find((t) => t.id === toastToRemove.id)) heights.value = heights.value.filter((h) => h.toastId !== toastToRemove.id);
880
+ }, TIME_BEFORE_UNMOUNT + 50);
881
+ }
882
+ function onBlur(event) {
883
+ var _a, _b;
884
+ if (isFocusWithinRef.value && !((_b = (_a = event.currentTarget) == null ? void 0 : _a.contains) == null ? void 0 : _b.call(_a, event.relatedTarget))) {
885
+ isFocusWithinRef.value = false;
886
+ if (lastFocusedElementRef.value) {
887
+ lastFocusedElementRef.value.focus({ preventScroll: true });
888
+ lastFocusedElementRef.value = null;
889
+ }
890
+ }
891
+ }
892
+ function onFocus(event) {
893
+ const isNotDismissible = event.target instanceof HTMLElement && event.target.dataset.dismissible === "false";
894
+ if (isNotDismissible) return;
895
+ if (!isFocusWithinRef.value) {
896
+ isFocusWithinRef.value = true;
897
+ lastFocusedElementRef.value = event.relatedTarget;
898
+ }
899
+ }
900
+ function onPointerDown(event) {
901
+ if (event.target) {
902
+ const isNotDismissible = event.target instanceof HTMLElement && event.target.dataset.dismissible === "false";
903
+ if (isNotDismissible) return;
904
+ }
905
+ interacting.value = true;
906
+ }
907
+ Mo.watchEffect((onInvalidate) => {
908
+ const unsubscribe = ToastState.subscribe((toast$1) => {
909
+ if (toast$1.dismiss) {
910
+ requestAnimationFrame(() => {
911
+ toasts.value = toasts.value.map((t) => t.id === toast$1.id ? {
912
+ ...t,
913
+ delete: true
914
+ } : t);
915
+ });
916
+ return;
917
+ }
918
+ Mo.nextTick(() => {
919
+ const indexOfExistingToast = toasts.value.findIndex((t) => t.id === toast$1.id);
920
+ if (indexOfExistingToast !== -1) toasts.value = [
921
+ ...toasts.value.slice(0, indexOfExistingToast),
922
+ {
923
+ ...toasts.value[indexOfExistingToast],
924
+ ...toast$1
925
+ },
926
+ ...toasts.value.slice(indexOfExistingToast + 1)
927
+ ];
928
+ else toasts.value = [toast$1, ...toasts.value];
929
+ });
930
+ });
931
+ onInvalidate(unsubscribe);
932
+ });
933
+ Mo.watchEffect((onInvalidate) => {
934
+ if (typeof window === "undefined") return;
935
+ if (props.theme !== "system") {
936
+ actualTheme.value = props.theme;
937
+ return;
938
+ }
939
+ const darkMediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
940
+ const updateTheme = (matches) => {
941
+ actualTheme.value = matches ? "dark" : "light";
942
+ };
943
+ updateTheme(darkMediaQuery.matches);
944
+ const handler = (event) => {
945
+ updateTheme(event.matches);
946
+ };
947
+ try {
948
+ darkMediaQuery.addEventListener("change", handler);
949
+ } catch {
950
+ darkMediaQuery.addListener(handler);
951
+ }
952
+ onInvalidate(() => {
953
+ try {
954
+ darkMediaQuery.removeEventListener("change", handler);
955
+ } catch {
956
+ darkMediaQuery.removeListener(handler);
957
+ }
958
+ });
959
+ });
960
+ Mo.watchEffect(() => {
961
+ if (listRef.value && lastFocusedElementRef.value) {
962
+ lastFocusedElementRef.value.focus({ preventScroll: true });
963
+ lastFocusedElementRef.value = null;
964
+ isFocusWithinRef.value = false;
965
+ }
966
+ });
967
+ Mo.watchEffect(() => {
968
+ if (toasts.value.length <= 1) expanded.value = false;
969
+ });
970
+ Mo.watchEffect((onInvalidate) => {
971
+ function handleKeyDown(event) {
972
+ const isHotkeyPressed = props.hotkey.every((key) => event[key] || event.code === key);
973
+ const listRefItem = Array.isArray(listRef.value) ? listRef.value[0] : listRef.value;
974
+ if (isHotkeyPressed) {
975
+ expanded.value = true;
976
+ listRefItem == null ? void 0 : listRefItem.focus();
977
+ }
978
+ const isItemActive = document.activeElement === listRef.value || (listRefItem == null ? void 0 : listRefItem.contains(document.activeElement));
979
+ if (event.code === "Escape" && isItemActive) expanded.value = false;
980
+ }
981
+ if (!isClient) return;
982
+ document.addEventListener("keydown", handleKeyDown);
983
+ onInvalidate(() => {
984
+ document.removeEventListener("keydown", handleKeyDown);
985
+ });
986
+ });
987
+ function handleMouseEnter() {
988
+ expanded.value = true;
989
+ }
990
+ function handleMouseLeave() {
991
+ if (!interacting.value) expanded.value = false;
992
+ }
993
+ function handleDragEnd() {
994
+ expanded.value = false;
995
+ }
996
+ function handlePointerUp() {
997
+ interacting.value = false;
998
+ }
999
+ function updateHeights(h) {
1000
+ heights.value = h;
1001
+ }
1002
+ function updateHeight(h) {
1003
+ const index = heights.value.findIndex((item) => item.toastId === h.toastId);
1004
+ if (index !== -1) heights.value[index] = h;
1005
+ else {
1006
+ const samePositionIndex = heights.value.findIndex((item) => item.position === h.position);
1007
+ if (samePositionIndex !== -1) heights.value.splice(samePositionIndex, 0, h);
1008
+ else heights.value.unshift(h);
1009
+ }
1010
+ }
1011
+ return (_ctx, _cache) => {
1012
+ return Mo.openBlock(), Mo.createElementBlock(Mo.Fragment, null, [Mo.createCommentVNode(" Remove item from normal navigation flow, only available via hotkey "), Mo.createElementVNode("section", {
1013
+ "aria-label": `${_ctx.containerAriaLabel} ${Mo.unref(hotkeyLabel)}`,
1014
+ tabIndex: -1,
1015
+ "aria-live": "polite",
1016
+ "aria-relevant": "additions text",
1017
+ "aria-atomic": "false"
1018
+ }, [(Mo.openBlock(true), Mo.createElementBlock(Mo.Fragment, null, Mo.renderList(possiblePositions.value, (pos, index) => {
1019
+ var _a;
1020
+ return Mo.openBlock(), Mo.createElementBlock("ol", Mo.mergeProps({
1021
+ key: pos,
1022
+ ref_for: true,
1023
+ ref_key: "listRef",
1024
+ ref: listRef,
1025
+ "data-sonner-toaster": "",
1026
+ "data-sonner-theme": actualTheme.value,
1027
+ class: props.class,
1028
+ dir: _ctx.dir === "auto" ? getDocumentDirection() : _ctx.dir,
1029
+ tabIndex: -1,
1030
+ "data-theme": _ctx.theme,
1031
+ "data-rich-colors": _ctx.richColors,
1032
+ "data-y-position": pos.split("-")[0],
1033
+ "data-x-position": pos.split("-")[1],
1034
+ "data-lifted": expanded.value && toasts.value.length > 1 && !_ctx.expand,
1035
+ style: {
1036
+ "--front-toast-height": `${((_a = heights.value[0]) == null ? void 0 : _a.height) || 0}px`,
1037
+ "--width": `${Mo.unref(TOAST_WIDTH)}px`,
1038
+ "--gap": `${_ctx.gap}px`,
1039
+ ..._ctx.style,
1040
+ ...Mo.unref(attrs).style,
1041
+ ...Mo.unref(assignOffset)(_ctx.offset, _ctx.mobileOffset)
1042
+ }
1043
+ }, _ctx.$attrs, {
1044
+ onBlur,
1045
+ onFocus,
1046
+ onMouseenter: handleMouseEnter,
1047
+ onMousemove: handleMouseEnter,
1048
+ onMouseleave: handleMouseLeave,
1049
+ onDragend: handleDragEnd,
1050
+ onPointerdown: onPointerDown,
1051
+ onPointerup: handlePointerUp
1052
+ }), [(Mo.openBlock(true), Mo.createElementBlock(Mo.Fragment, null, Mo.renderList(filteredToasts(pos, index), (toast$1, idx) => {
1053
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
1054
+ return Mo.openBlock(), Mo.createBlock(Toast_default, {
1055
+ key: toast$1.id,
1056
+ heights: heights.value,
1057
+ icons: _ctx.icons,
1058
+ index: idx,
1059
+ toast: toast$1,
1060
+ defaultRichColors: _ctx.richColors,
1061
+ duration: ((_a2 = _ctx.toastOptions) == null ? void 0 : _a2.duration) ?? _ctx.duration,
1062
+ class: Mo.normalizeClass(((_b = _ctx.toastOptions) == null ? void 0 : _b.class) ?? ""),
1063
+ descriptionClass: (_c = _ctx.toastOptions) == null ? void 0 : _c.descriptionClass,
1064
+ invert: _ctx.invert,
1065
+ visibleToasts: _ctx.visibleToasts,
1066
+ closeButton: ((_d = _ctx.toastOptions) == null ? void 0 : _d.closeButton) ?? _ctx.closeButton,
1067
+ interacting: interacting.value,
1068
+ position: pos,
1069
+ style: Mo.normalizeStyle((_e = _ctx.toastOptions) == null ? void 0 : _e.style),
1070
+ unstyled: (_f = _ctx.toastOptions) == null ? void 0 : _f.unstyled,
1071
+ classes: (_g = _ctx.toastOptions) == null ? void 0 : _g.classes,
1072
+ cancelButtonStyle: (_h = _ctx.toastOptions) == null ? void 0 : _h.cancelButtonStyle,
1073
+ actionButtonStyle: (_i = _ctx.toastOptions) == null ? void 0 : _i.actionButtonStyle,
1074
+ "close-button-aria-label": (_j = _ctx.toastOptions) == null ? void 0 : _j.closeButtonAriaLabel,
1075
+ toasts: toastsByPosition.value[pos],
1076
+ expandByDefault: _ctx.expand,
1077
+ gap: _ctx.gap,
1078
+ expanded: expanded.value,
1079
+ swipeDirections: props.swipeDirections,
1080
+ "onUpdate:heights": updateHeights,
1081
+ "onUpdate:height": updateHeight,
1082
+ onRemoveToast: removeToast
1083
+ }, {
1084
+ "close-icon": Mo.withCtx(() => [Mo.renderSlot(_ctx.$slots, "close-icon", {}, () => [Mo.createVNode(CloseIcon_default)])]),
1085
+ "loading-icon": Mo.withCtx(() => [Mo.renderSlot(_ctx.$slots, "loading-icon", {}, () => [Mo.createVNode(Loader_default, { visible: toast$1.type === "loading" }, null, 8, ["visible"])])]),
1086
+ "success-icon": Mo.withCtx(() => [Mo.renderSlot(_ctx.$slots, "success-icon", {}, () => [Mo.createVNode(SuccessIcon_default)])]),
1087
+ "error-icon": Mo.withCtx(() => [Mo.renderSlot(_ctx.$slots, "error-icon", {}, () => [Mo.createVNode(ErrorIcon_default)])]),
1088
+ "warning-icon": Mo.withCtx(() => [Mo.renderSlot(_ctx.$slots, "warning-icon", {}, () => [Mo.createVNode(WarningIcon_default)])]),
1089
+ "info-icon": Mo.withCtx(() => [Mo.renderSlot(_ctx.$slots, "info-icon", {}, () => [Mo.createVNode(InfoIcon_default)])]),
1090
+ _: 2
1091
+ }, 1032, [
1092
+ "heights",
1093
+ "icons",
1094
+ "index",
1095
+ "toast",
1096
+ "defaultRichColors",
1097
+ "duration",
1098
+ "class",
1099
+ "descriptionClass",
1100
+ "invert",
1101
+ "visibleToasts",
1102
+ "closeButton",
1103
+ "interacting",
1104
+ "position",
1105
+ "style",
1106
+ "unstyled",
1107
+ "classes",
1108
+ "cancelButtonStyle",
1109
+ "actionButtonStyle",
1110
+ "close-button-aria-label",
1111
+ "toasts",
1112
+ "expandByDefault",
1113
+ "gap",
1114
+ "expanded",
1115
+ "swipeDirections"
1116
+ ]);
1117
+ }), 128))], 16, _hoisted_2);
1118
+ }), 128))], 8, _hoisted_1)], 2112);
1119
+ };
1120
+ }
1121
+ });
1122
+ var Toaster_default = Toaster_vue_vue_type_script_setup_true_lang_default;
1123
+ const _sfc_main = /* @__PURE__ */ Mo.defineComponent({
1124
+ __name: "sonner",
1125
+ props: {
1126
+ invert: { type: Boolean },
1127
+ theme: {},
1128
+ position: {},
1129
+ hotkey: {},
1130
+ richColors: { type: Boolean },
1131
+ expand: { type: Boolean },
1132
+ duration: {},
1133
+ gap: {},
1134
+ visibleToasts: {},
1135
+ closeButton: { type: Boolean },
1136
+ toastOptions: {},
1137
+ class: {},
1138
+ style: {},
1139
+ offset: {},
1140
+ mobileOffset: {},
1141
+ dir: {},
1142
+ swipeDirections: {},
1143
+ icons: {},
1144
+ containerAriaLabel: {}
1145
+ },
1146
+ setup(__props) {
1147
+ const props = __props;
1148
+ return (_ctx, _cache) => {
1149
+ return Mo.openBlock(), Mo.createBlock(Mo.unref(Toaster_default), Mo.normalizeProps(Mo.guardReactiveProps(props)), null, 16);
1150
+ };
1151
+ }
1152
+ });
1153
+ exports._sfc_main = _sfc_main;
1154
+ exports.toast = toast;