@alexgorbatchev/shadcn 0.0.0-stage → 0.0.12

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 (158) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +349 -2
  3. package/THIRD_PARTY_NOTICES.md +105 -0
  4. package/dist/chunk-1j2hz3w9.js +16 -0
  5. package/dist/chunk-5wvvqege.js +259 -0
  6. package/dist/chunk-8a7dn9ps.js +93 -0
  7. package/dist/chunk-cp2m7y7v.js +26 -0
  8. package/dist/chunk-jpvw9xqy.js +4 -0
  9. package/dist/chunk-rajgnfbr.js +24 -0
  10. package/dist/chunk-rjjwytbx.js +12 -0
  11. package/dist/chunk-tnktkgvp.js +63 -0
  12. package/dist/chunk-z1fy613d.js +64 -0
  13. package/dist/components/Accordion.d.ts +12 -0
  14. package/dist/components/Alert.d.ts +15 -0
  15. package/dist/components/AlertDialog.d.ts +28 -0
  16. package/dist/components/AspectRatio.d.ts +5 -0
  17. package/dist/components/Attachment.d.ts +36 -0
  18. package/dist/components/Avatar.d.ts +19 -0
  19. package/dist/components/Badge.d.ts +15 -0
  20. package/dist/components/Breadcrumb.d.ts +18 -0
  21. package/dist/components/Bubble.d.ts +25 -0
  22. package/dist/components/Button.d.ts +13 -0
  23. package/dist/components/ButtonGroup.d.ts +14 -0
  24. package/dist/components/Card.d.ts +19 -0
  25. package/dist/components/Checkbox.d.ts +6 -0
  26. package/dist/components/Collapsible.d.ts +6 -0
  27. package/dist/components/Combobox.d.ts +39 -0
  28. package/dist/components/ConfirmationDialog.d.ts +11 -0
  29. package/dist/components/ContextMenu.d.ts +24 -0
  30. package/dist/components/DensityProvider.d.ts +7 -0
  31. package/dist/components/Dialog.d.ts +25 -0
  32. package/dist/components/DirectionProvider.d.ts +1 -0
  33. package/dist/components/DragDropPreview.d.ts +7 -0
  34. package/dist/components/DragDropProvider.d.ts +6 -0
  35. package/dist/components/DragSource.d.ts +10 -0
  36. package/dist/components/Drawer.d.ts +25 -0
  37. package/dist/components/DropTarget.d.ts +11 -0
  38. package/dist/components/DropdownMenu.d.ts +26 -0
  39. package/dist/components/Empty.d.ts +19 -0
  40. package/dist/components/EmptyState.d.ts +8 -0
  41. package/dist/components/Field.d.ts +36 -0
  42. package/dist/components/HoverCard.d.ts +8 -0
  43. package/dist/components/ImagePicker.d.ts +11 -0
  44. package/dist/components/InlineEdit.d.ts +14 -0
  45. package/dist/components/Input.d.ts +6 -0
  46. package/dist/components/InputGroup.d.ts +26 -0
  47. package/dist/components/Item.d.ts +32 -0
  48. package/dist/components/JsonViewer.d.ts +8 -0
  49. package/dist/components/Kbd.d.ts +7 -0
  50. package/dist/components/Label.d.ts +5 -0
  51. package/dist/components/Marker.d.ts +19 -0
  52. package/dist/components/Menubar.d.ts +29 -0
  53. package/dist/components/Message.d.ts +17 -0
  54. package/dist/components/NativeSelect.d.ts +11 -0
  55. package/dist/components/NavigationMenu.d.ts +21 -0
  56. package/dist/components/Pagination.d.ts +21 -0
  57. package/dist/components/Popover.d.ts +14 -0
  58. package/dist/components/Progress.d.ts +14 -0
  59. package/dist/components/RadioGroup.d.ts +9 -0
  60. package/dist/components/ScrollArea.d.ts +10 -0
  61. package/dist/components/Select.d.ts +25 -0
  62. package/dist/components/Separator.d.ts +8 -0
  63. package/dist/components/Sheet.d.ts +20 -0
  64. package/dist/components/Sidebar.d.ts +60 -0
  65. package/dist/components/Skeleton.d.ts +5 -0
  66. package/dist/components/Slider.d.ts +6 -0
  67. package/dist/components/Spinner.d.ts +5 -0
  68. package/dist/components/StarRating.d.ts +10 -0
  69. package/dist/components/Switch.d.ts +8 -0
  70. package/dist/components/Table.d.ts +28 -0
  71. package/dist/components/Tabs.d.ts +16 -0
  72. package/dist/components/Textarea.d.ts +5 -0
  73. package/dist/components/ThemeProvider.d.ts +9 -0
  74. package/dist/components/Toast.d.ts +18 -0
  75. package/dist/components/Toggle.d.ts +11 -0
  76. package/dist/components/ToggleGroup.d.ts +12 -0
  77. package/dist/components/Tooltip.d.ts +9 -0
  78. package/dist/components/calendar/Calendar.d.ts +6 -0
  79. package/dist/components/calendar/getCalendarClassNames.d.ts +3 -0
  80. package/dist/components/calendar/index.d.ts +1 -0
  81. package/dist/components/calendar/index.js +10 -0
  82. package/dist/components/calendar/types.d.ts +9 -0
  83. package/dist/components/carousel/Carousel.d.ts +9 -0
  84. package/dist/components/carousel/CarouselContext.d.ts +2 -0
  85. package/dist/components/carousel/hooks/useCarousel.d.ts +2 -0
  86. package/dist/components/carousel/index.d.ts +3 -0
  87. package/dist/components/carousel/index.js +207 -0
  88. package/dist/components/carousel/types.d.ts +23 -0
  89. package/dist/components/chart/Chart.d.ts +10 -0
  90. package/dist/components/chart/ChartContext.d.ts +2 -0
  91. package/dist/components/chart/ChartStyle.d.ts +3 -0
  92. package/dist/components/chart/getPayloadConfigFromPayload.d.ts +2 -0
  93. package/dist/components/chart/hooks/useChart.d.ts +2 -0
  94. package/dist/components/chart/index.d.ts +3 -0
  95. package/dist/components/chart/index.js +284 -0
  96. package/dist/components/chart/types.d.ts +50 -0
  97. package/dist/components/command/Command.d.ts +21 -0
  98. package/dist/components/command/index.d.ts +1 -0
  99. package/dist/components/command/index.js +142 -0
  100. package/dist/components/input-otp/InputOTP.d.ts +12 -0
  101. package/dist/components/input-otp/index.d.ts +1 -0
  102. package/dist/components/input-otp/index.js +303 -0
  103. package/dist/components/message-scroller/MessageScroller.d.ts +16 -0
  104. package/dist/components/message-scroller/hooks/useMessageScroller.d.ts +1 -0
  105. package/dist/components/message-scroller/hooks/useMessageScrollerScrollable.d.ts +1 -0
  106. package/dist/components/message-scroller/hooks/useMessageScrollerVisibility.d.ts +1 -0
  107. package/dist/components/message-scroller/index.d.ts +5 -0
  108. package/dist/components/message-scroller/index.js +600 -0
  109. package/dist/components/persian-calendar/PersianCalendar.d.ts +6 -0
  110. package/dist/components/persian-calendar/index.d.ts +1 -0
  111. package/dist/components/persian-calendar/index.js +36 -0
  112. package/dist/components/questionnaire/Questionnaire.d.ts +20 -0
  113. package/dist/components/questionnaire/index.d.ts +2 -0
  114. package/dist/components/questionnaire/index.js +747 -0
  115. package/dist/components/resizable/Resizable.d.ts +10 -0
  116. package/dist/components/resizable/SplitView.d.ts +12 -0
  117. package/dist/components/resizable/index.d.ts +2 -0
  118. package/dist/components/resizable/index.js +147 -0
  119. package/dist/components/sonner/Sonner.d.ts +7 -0
  120. package/dist/components/sonner/hooks/useSonner.d.ts +1 -0
  121. package/dist/components/sonner/index.d.ts +2 -0
  122. package/dist/components/sonner/index.js +1273 -0
  123. package/dist/density/DensityContext.d.ts +2 -0
  124. package/dist/density/types.d.ts +4 -0
  125. package/dist/drag-drop/DragDropContext.d.ts +2 -0
  126. package/dist/drag-drop/types.d.ts +45 -0
  127. package/dist/drawer/DrawerContext.d.ts +2 -0
  128. package/dist/drawer/types.d.ts +7 -0
  129. package/dist/fonts.css +1 -0
  130. package/dist/hooks/useComboboxAnchor.d.ts +2 -0
  131. package/dist/hooks/useDensity.d.ts +2 -0
  132. package/dist/hooks/useDragDrop.d.ts +2 -0
  133. package/dist/hooks/useDragSource.d.ts +2 -0
  134. package/dist/hooks/useDrawer.d.ts +2 -0
  135. package/dist/hooks/useDropTarget.d.ts +2 -0
  136. package/dist/hooks/useMediaQuery.d.ts +1 -0
  137. package/dist/hooks/useObjectURL.d.ts +1 -0
  138. package/dist/hooks/useSidebar.d.ts +2 -0
  139. package/dist/hooks/useTheme.d.ts +2 -0
  140. package/dist/hooks/useToastManager.d.ts +2 -0
  141. package/dist/index.d.ts +82 -0
  142. package/dist/index.js +4908 -0
  143. package/dist/menu/types.d.ts +14 -0
  144. package/dist/message/MessageContext.d.ts +2 -0
  145. package/dist/message/types.d.ts +7 -0
  146. package/dist/sidebar/SidebarContext.d.ts +2 -0
  147. package/dist/sidebar/types.d.ts +32 -0
  148. package/dist/theme/ThemeContext.d.ts +2 -0
  149. package/dist/theme/types.d.ts +8 -0
  150. package/dist/theme.css +454 -0
  151. package/dist/toggle-group/ToggleGroupContext.d.ts +2 -0
  152. package/dist/toggle-group/types.d.ts +5 -0
  153. package/dist/typeset.css +444 -0
  154. package/dist/utils/cn.d.ts +2 -0
  155. package/package.json +193 -4
  156. package/patches/@shadcn%2Freact@0.3.1.patch +35 -0
  157. package/patches/input-otp@1.5.0.patch +20 -0
  158. package/patches/sonner@2.0.8.patch +87 -0
@@ -0,0 +1,1273 @@
1
+ import {
2
+ useTheme2
3
+ } from "../../chunk-1j2hz3w9.js";
4
+ import {
5
+ useDensity
6
+ } from "../../chunk-rjjwytbx.js";
7
+ import {
8
+ cn2
9
+ } from "../../chunk-cp2m7y7v.js";
10
+ import {
11
+ buttonVariants2
12
+ } from "../../chunk-tnktkgvp.js";
13
+
14
+ // node_modules/sonner/dist/index.mjs
15
+ import React from "react";
16
+ import ReactDOM from "react-dom";
17
+ "use client";
18
+ function __insertCSS(code) {
19
+ if (!code || typeof document == "undefined")
20
+ return;
21
+ let head = document.head || document.getElementsByTagName("head")[0];
22
+ let style = document.createElement("style");
23
+ style.type = "text/css";
24
+ head.appendChild(style);
25
+ style.styleSheet ? style.styleSheet.cssText = code : style.appendChild(document.createTextNode(code));
26
+ }
27
+ var getAsset = (type) => {
28
+ switch (type) {
29
+ case "success":
30
+ return SuccessIcon;
31
+ case "info":
32
+ return InfoIcon;
33
+ case "warning":
34
+ return WarningIcon;
35
+ case "error":
36
+ return ErrorIcon;
37
+ default:
38
+ return null;
39
+ }
40
+ };
41
+ var bars = Array(12).fill(0);
42
+ var Loader = ({ visible, className }) => {
43
+ return /* @__PURE__ */ React.createElement("div", {
44
+ className: [
45
+ "sonner-loading-wrapper",
46
+ className
47
+ ].filter(Boolean).join(" "),
48
+ "data-visible": visible
49
+ }, /* @__PURE__ */ React.createElement("div", {
50
+ className: "sonner-spinner"
51
+ }, bars.map((_, i) => /* @__PURE__ */ React.createElement("div", {
52
+ className: "sonner-loading-bar",
53
+ key: `spinner-bar-${i}`
54
+ }))));
55
+ };
56
+ var SuccessIcon = /* @__PURE__ */ React.createElement("svg", {
57
+ xmlns: "http://www.w3.org/2000/svg",
58
+ viewBox: "0 0 20 20",
59
+ fill: "currentColor",
60
+ height: "20",
61
+ width: "20",
62
+ "aria-hidden": "true"
63
+ }, /* @__PURE__ */ React.createElement("path", {
64
+ fillRule: "evenodd",
65
+ 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",
66
+ clipRule: "evenodd"
67
+ }));
68
+ var WarningIcon = /* @__PURE__ */ React.createElement("svg", {
69
+ xmlns: "http://www.w3.org/2000/svg",
70
+ viewBox: "0 0 24 24",
71
+ fill: "currentColor",
72
+ height: "20",
73
+ width: "20",
74
+ "aria-hidden": "true"
75
+ }, /* @__PURE__ */ React.createElement("path", {
76
+ fillRule: "evenodd",
77
+ 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",
78
+ clipRule: "evenodd"
79
+ }));
80
+ var InfoIcon = /* @__PURE__ */ React.createElement("svg", {
81
+ xmlns: "http://www.w3.org/2000/svg",
82
+ viewBox: "0 0 20 20",
83
+ fill: "currentColor",
84
+ height: "20",
85
+ width: "20",
86
+ "aria-hidden": "true"
87
+ }, /* @__PURE__ */ React.createElement("path", {
88
+ fillRule: "evenodd",
89
+ 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",
90
+ clipRule: "evenodd"
91
+ }));
92
+ var ErrorIcon = /* @__PURE__ */ React.createElement("svg", {
93
+ xmlns: "http://www.w3.org/2000/svg",
94
+ viewBox: "0 0 20 20",
95
+ fill: "currentColor",
96
+ height: "20",
97
+ width: "20",
98
+ "aria-hidden": "true"
99
+ }, /* @__PURE__ */ React.createElement("path", {
100
+ fillRule: "evenodd",
101
+ 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",
102
+ clipRule: "evenodd"
103
+ }));
104
+ var CloseIcon = /* @__PURE__ */ React.createElement("svg", {
105
+ xmlns: "http://www.w3.org/2000/svg",
106
+ width: "12",
107
+ height: "12",
108
+ viewBox: "0 0 24 24",
109
+ fill: "none",
110
+ stroke: "currentColor",
111
+ strokeWidth: "1.5",
112
+ strokeLinecap: "round",
113
+ strokeLinejoin: "round",
114
+ "aria-hidden": "true"
115
+ }, /* @__PURE__ */ React.createElement("line", {
116
+ x1: "18",
117
+ y1: "6",
118
+ x2: "6",
119
+ y2: "18"
120
+ }), /* @__PURE__ */ React.createElement("line", {
121
+ x1: "6",
122
+ y1: "6",
123
+ x2: "18",
124
+ y2: "18"
125
+ }));
126
+ var useIsDocumentHidden = () => {
127
+ const [isDocumentHidden, setIsDocumentHidden] = React.useState(document.hidden);
128
+ React.useEffect(() => {
129
+ const callback = () => {
130
+ setIsDocumentHidden(document.hidden);
131
+ };
132
+ document.addEventListener("visibilitychange", callback);
133
+ return () => document.removeEventListener("visibilitychange", callback);
134
+ }, []);
135
+ return isDocumentHidden;
136
+ };
137
+ var toastsCounter = 1;
138
+ var MAX_HISTORY_SIZE = 100;
139
+ var getToastId = (data) => {
140
+ var _data_id;
141
+ return typeof (data == null ? undefined : data.id) === "number" || (data == null ? undefined : (_data_id = data.id) == null ? undefined : _data_id.length) > 0 ? data.id : toastsCounter++;
142
+ };
143
+
144
+ class Observer {
145
+ constructor() {
146
+ this.subscribe = (subscriber) => {
147
+ this.subscribers.push(subscriber);
148
+ this.getActiveToasts().forEach((toast) => subscriber(toast));
149
+ return () => {
150
+ const index = this.subscribers.indexOf(subscriber);
151
+ this.subscribers.splice(index, 1);
152
+ };
153
+ };
154
+ this.publish = (data) => {
155
+ this.subscribers.forEach((subscriber) => subscriber(data));
156
+ };
157
+ this.addToast = (data) => {
158
+ this.publish(data);
159
+ this.toasts = [
160
+ ...this.toasts,
161
+ data
162
+ ];
163
+ this.trimHistory();
164
+ };
165
+ this.trimHistory = () => {
166
+ let toRemove = this.toasts.length - MAX_HISTORY_SIZE;
167
+ if (toRemove <= 0)
168
+ return;
169
+ this.toasts = this.toasts.filter((toast) => {
170
+ if (toRemove > 0 && this.dismissedToasts.has(toast.id)) {
171
+ this.dismissedToasts.delete(toast.id);
172
+ toRemove--;
173
+ return false;
174
+ }
175
+ return true;
176
+ });
177
+ };
178
+ this.create = (data) => {
179
+ const { message, ...rest } = data;
180
+ const id = getToastId(data);
181
+ const pendingDismissal = this.pendingDismissals.get(id);
182
+ if (pendingDismissal !== undefined) {
183
+ cancelAnimationFrame(pendingDismissal);
184
+ this.pendingDismissals.delete(id);
185
+ this.dismissedToasts.delete(id);
186
+ }
187
+ const wasDismissed = this.dismissedToasts.has(id);
188
+ const dismissible = data.dismissible === undefined ? true : data.dismissible;
189
+ if (wasDismissed) {
190
+ this.dismissedToasts.delete(id);
191
+ this.toasts = this.toasts.filter((toast) => toast.id !== id);
192
+ }
193
+ const alreadyExists = wasDismissed ? undefined : this.toasts.find((toast) => {
194
+ return toast.id === id;
195
+ });
196
+ if (alreadyExists) {
197
+ this.toasts = this.toasts.map((toast) => {
198
+ if (toast.id === id) {
199
+ this.publish({
200
+ ...toast,
201
+ ...data,
202
+ id,
203
+ title: message
204
+ });
205
+ return {
206
+ ...toast,
207
+ ...data,
208
+ id,
209
+ dismissible,
210
+ title: message
211
+ };
212
+ }
213
+ return toast;
214
+ });
215
+ } else {
216
+ this.addToast({
217
+ title: message,
218
+ ...rest,
219
+ dismissible,
220
+ id
221
+ });
222
+ }
223
+ return id;
224
+ };
225
+ this.dismiss = (id) => {
226
+ if (id === undefined || id === null) {
227
+ this.getActiveToasts().forEach((toast) => {
228
+ this.dismissedToasts.add(toast.id);
229
+ this.subscribers.forEach((subscriber) => subscriber({
230
+ id: toast.id,
231
+ dismiss: true
232
+ }));
233
+ });
234
+ return id;
235
+ }
236
+ this.dismissedToasts.add(id);
237
+ const alreadyPending = this.pendingDismissals.get(id);
238
+ if (alreadyPending !== undefined) {
239
+ cancelAnimationFrame(alreadyPending);
240
+ }
241
+ this.pendingDismissals.set(id, requestAnimationFrame(() => {
242
+ this.pendingDismissals.delete(id);
243
+ this.subscribers.forEach((subscriber) => subscriber({
244
+ id,
245
+ dismiss: true
246
+ }));
247
+ }));
248
+ return id;
249
+ };
250
+ this.message = (message, data) => {
251
+ return this.create({
252
+ ...data,
253
+ message,
254
+ type: undefined
255
+ });
256
+ };
257
+ this.error = (message, data) => {
258
+ return this.create({
259
+ ...data,
260
+ message,
261
+ type: "error"
262
+ });
263
+ };
264
+ this.success = (message, data) => {
265
+ return this.create({
266
+ ...data,
267
+ type: "success",
268
+ message
269
+ });
270
+ };
271
+ this.info = (message, data) => {
272
+ return this.create({
273
+ ...data,
274
+ type: "info",
275
+ message
276
+ });
277
+ };
278
+ this.warning = (message, data) => {
279
+ return this.create({
280
+ ...data,
281
+ type: "warning",
282
+ message
283
+ });
284
+ };
285
+ this.loading = (message, data) => {
286
+ return this.create({
287
+ ...data,
288
+ type: "loading",
289
+ message
290
+ });
291
+ };
292
+ this.promise = (promise, data) => {
293
+ if (!data) {
294
+ return;
295
+ }
296
+ let id = undefined;
297
+ if (data.loading !== undefined) {
298
+ id = this.create({
299
+ ...data,
300
+ promise,
301
+ type: "loading",
302
+ message: data.loading,
303
+ description: typeof data.description !== "function" ? data.description : undefined
304
+ });
305
+ }
306
+ const p = Promise.resolve(promise instanceof Function ? promise() : promise);
307
+ let shouldDismiss = id !== undefined;
308
+ let result;
309
+ const originalPromise = p.then(async (response) => {
310
+ result = [
311
+ "resolve",
312
+ response
313
+ ];
314
+ const isReactElementResponse = React.isValidElement(response);
315
+ if (isReactElementResponse) {
316
+ shouldDismiss = false;
317
+ this.create({
318
+ id,
319
+ type: "default",
320
+ message: response
321
+ });
322
+ } else if (isHttpResponse(response) && !response.ok) {
323
+ shouldDismiss = false;
324
+ const promiseData = typeof data.error === "function" ? await data.error(`HTTP error! status: ${response.status}`) : data.error;
325
+ const description = typeof data.description === "function" ? await data.description(`HTTP error! status: ${response.status}`) : data.description;
326
+ const isExtendedResult = typeof promiseData === "object" && !React.isValidElement(promiseData);
327
+ const toastSettings = isExtendedResult ? promiseData : {
328
+ message: promiseData
329
+ };
330
+ this.create({
331
+ id,
332
+ type: "error",
333
+ description,
334
+ ...toastSettings
335
+ });
336
+ } else if (response instanceof Error) {
337
+ shouldDismiss = false;
338
+ const promiseData = typeof data.error === "function" ? await data.error(response) : data.error;
339
+ const description = typeof data.description === "function" ? await data.description(response) : data.description;
340
+ const isExtendedResult = typeof promiseData === "object" && !React.isValidElement(promiseData);
341
+ const toastSettings = isExtendedResult ? promiseData : {
342
+ message: promiseData
343
+ };
344
+ this.create({
345
+ id,
346
+ type: "error",
347
+ description,
348
+ ...toastSettings
349
+ });
350
+ } else if (data.success !== undefined) {
351
+ shouldDismiss = false;
352
+ const promiseData = typeof data.success === "function" ? await data.success(response) : data.success;
353
+ const description = typeof data.description === "function" ? await data.description(response) : data.description;
354
+ const isExtendedResult = typeof promiseData === "object" && !React.isValidElement(promiseData);
355
+ const toastSettings = isExtendedResult ? promiseData : {
356
+ message: promiseData
357
+ };
358
+ this.create({
359
+ id,
360
+ type: "success",
361
+ description,
362
+ ...toastSettings
363
+ });
364
+ }
365
+ }).catch(async (error) => {
366
+ result = [
367
+ "reject",
368
+ error
369
+ ];
370
+ if (data.error !== undefined) {
371
+ shouldDismiss = false;
372
+ const promiseData = typeof data.error === "function" ? await data.error(error) : data.error;
373
+ const description = typeof data.description === "function" ? await data.description(error) : data.description;
374
+ const isExtendedResult = typeof promiseData === "object" && !React.isValidElement(promiseData);
375
+ const toastSettings = isExtendedResult ? promiseData : {
376
+ message: promiseData
377
+ };
378
+ this.create({
379
+ id,
380
+ type: "error",
381
+ description,
382
+ ...toastSettings
383
+ });
384
+ }
385
+ }).finally(() => {
386
+ if (shouldDismiss) {
387
+ this.dismiss(id);
388
+ id = undefined;
389
+ }
390
+ data.finally == null || data.finally.call(data);
391
+ });
392
+ const unwrap = () => new Promise((resolve, reject) => originalPromise.then(() => result[0] === "reject" ? reject(result[1]) : resolve(result[1])).catch(reject));
393
+ if (typeof id !== "string" && typeof id !== "number") {
394
+ return {
395
+ unwrap
396
+ };
397
+ } else {
398
+ return Object.assign(id, {
399
+ unwrap
400
+ });
401
+ }
402
+ };
403
+ this.custom = (jsx, data) => {
404
+ const id = getToastId(data);
405
+ this.create({
406
+ ...data,
407
+ jsx: jsx(id),
408
+ id,
409
+ type: undefined
410
+ });
411
+ return id;
412
+ };
413
+ this.getActiveToasts = () => {
414
+ return this.toasts.filter((toast) => !this.dismissedToasts.has(toast.id));
415
+ };
416
+ this.subscribers = [];
417
+ this.toasts = [];
418
+ this.dismissedToasts = new Set;
419
+ this.pendingDismissals = new Map;
420
+ }
421
+ }
422
+ var ToastState = new Observer;
423
+ var toastFunction = (message, data) => {
424
+ return ToastState.message(message, data);
425
+ };
426
+ var isHttpResponse = (data) => {
427
+ return data && typeof data === "object" && "ok" in data && typeof data.ok === "boolean" && "status" in data && typeof data.status === "number";
428
+ };
429
+ var basicToast = toastFunction;
430
+ var getHistory = () => ToastState.toasts;
431
+ var getToasts = () => ToastState.getActiveToasts();
432
+ var toast = Object.assign(basicToast, {
433
+ success: ToastState.success,
434
+ info: ToastState.info,
435
+ warning: ToastState.warning,
436
+ error: ToastState.error,
437
+ custom: ToastState.custom,
438
+ message: ToastState.message,
439
+ promise: ToastState.promise,
440
+ dismiss: ToastState.dismiss,
441
+ loading: ToastState.loading
442
+ }, {
443
+ getHistory,
444
+ getToasts
445
+ });
446
+ __insertCSS("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--normal-text);background:var(--normal-bg);border:1px solid var(--normal-border);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{-webkit-user-select:none;user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");
447
+ function isAction(action) {
448
+ return action.label !== undefined;
449
+ }
450
+ var VISIBLE_TOASTS_AMOUNT = 3;
451
+ var VIEWPORT_OFFSET = "24px";
452
+ var MOBILE_VIEWPORT_OFFSET = "16px";
453
+ var TOAST_LIFETIME = 4000;
454
+ var TOAST_WIDTH = 356;
455
+ var GAP = 14;
456
+ var SWIPE_THRESHOLD = 45;
457
+ var TIME_BEFORE_UNMOUNT = 200;
458
+ function cn(...classes) {
459
+ return classes.filter(Boolean).join(" ");
460
+ }
461
+ function getDefaultSwipeDirections(position) {
462
+ const [y, x] = position.split("-");
463
+ const directions = [];
464
+ if (y) {
465
+ directions.push(y);
466
+ }
467
+ if (x) {
468
+ directions.push(x);
469
+ }
470
+ return directions;
471
+ }
472
+ var Toast = (props) => {
473
+ var _toast_classNames, _toast_classNames1, _toast_classNames2, _toast_classNames3, _toast_classNames4, _toast_classNames5, _toast_classNames6, _toast_classNames7, _toast_classNames8;
474
+ const { invert: ToasterInvert, toast, unstyled, interacting, setHeights, visibleToasts, heights, index, toasts, expanded, removeToast, defaultRichColors, closeButton: closeButtonFromToaster, style, cancelButtonStyle, actionButtonStyle, className = "", descriptionClassName = "", duration: durationFromToaster, position, gap, expandByDefault, classNames, icons, closeButtonAriaLabel = "Close toast" } = props;
475
+ const [swipeDirection, setSwipeDirection] = React.useState(null);
476
+ const [swipeOutDirection, setSwipeOutDirection] = React.useState(null);
477
+ const [mounted, setMounted] = React.useState(false);
478
+ const [removed, setRemoved] = React.useState(false);
479
+ const [swiping, setSwiping] = React.useState(false);
480
+ const [swipeOut, setSwipeOut] = React.useState(false);
481
+ const [isSwiped, setIsSwiped] = React.useState(false);
482
+ const [offsetBeforeRemove, setOffsetBeforeRemove] = React.useState(0);
483
+ const [initialHeight, setInitialHeight] = React.useState(0);
484
+ const remainingTime = React.useRef(toast.duration || durationFromToaster || TOAST_LIFETIME);
485
+ const dragStartTime = React.useRef(null);
486
+ const toastRef = React.useRef(null);
487
+ const isFront = index === 0;
488
+ const isVisible = index + 1 <= visibleToasts;
489
+ const toastType = toast.type;
490
+ const toastTypeKey = toastType != null ? toastType : "default";
491
+ const dismissible = toast.dismissible !== false;
492
+ const toastClassname = toast.className || "";
493
+ const toastDescriptionClassname = toast.descriptionClassName || "";
494
+ const heightIndex = React.useMemo(() => heights.findIndex((height) => height.toastId === toast.id) || 0, [
495
+ heights,
496
+ toast.id
497
+ ]);
498
+ const closeButton = React.useMemo(() => {
499
+ var _toast_closeButton;
500
+ return (_toast_closeButton = toast.closeButton) != null ? _toast_closeButton : closeButtonFromToaster;
501
+ }, [
502
+ toast.closeButton,
503
+ closeButtonFromToaster
504
+ ]);
505
+ const duration = React.useMemo(() => toast.duration || durationFromToaster || TOAST_LIFETIME, [
506
+ toast.duration,
507
+ durationFromToaster
508
+ ]);
509
+ const closeTimerStartTimeRef = React.useRef(0);
510
+ const offset = React.useRef(0);
511
+ const lastCloseTimerStartTimeRef = React.useRef(0);
512
+ const pointerStartRef = React.useRef(null);
513
+ const [y, x] = position.split("-");
514
+ const toastsHeightBefore = React.useMemo(() => {
515
+ return heights.reduce((prev, curr, reducerIndex) => {
516
+ if (reducerIndex >= heightIndex) {
517
+ return prev;
518
+ }
519
+ return prev + curr.height;
520
+ }, 0);
521
+ }, [
522
+ heights,
523
+ heightIndex
524
+ ]);
525
+ const isDocumentHidden = useIsDocumentHidden();
526
+ const swipeDirections = React.useMemo(() => {
527
+ var _props_swipeDirections;
528
+ return (_props_swipeDirections = props.swipeDirections) != null ? _props_swipeDirections : getDefaultSwipeDirections(position);
529
+ }, [
530
+ props.swipeDirections,
531
+ position
532
+ ]);
533
+ const invert = toast.invert || ToasterInvert;
534
+ const disabled = toastType === "loading";
535
+ offset.current = React.useMemo(() => heightIndex * gap + toastsHeightBefore, [
536
+ heightIndex,
537
+ toastsHeightBefore
538
+ ]);
539
+ React.useEffect(() => {
540
+ remainingTime.current = duration;
541
+ }, [
542
+ duration
543
+ ]);
544
+ React.useEffect(() => {
545
+ setMounted(true);
546
+ }, []);
547
+ React.useEffect(() => {
548
+ const toastNode = toastRef.current;
549
+ if (toastNode) {
550
+ const height = toastNode.getBoundingClientRect().height;
551
+ setInitialHeight(height);
552
+ setHeights((h) => [
553
+ {
554
+ toastId: toast.id,
555
+ height,
556
+ position: toast.position
557
+ },
558
+ ...h
559
+ ]);
560
+ return () => setHeights((h) => h.filter((height) => height.toastId !== toast.id));
561
+ }
562
+ }, [
563
+ setHeights,
564
+ toast.id
565
+ ]);
566
+ React.useLayoutEffect(() => {
567
+ if (!mounted || removed)
568
+ return;
569
+ const toastNode = toastRef.current;
570
+ const originalHeight = toastNode.style.height;
571
+ toastNode.style.height = "auto";
572
+ const newHeight = toastNode.getBoundingClientRect().height;
573
+ toastNode.style.height = originalHeight;
574
+ setInitialHeight(newHeight);
575
+ setHeights((heights) => {
576
+ const alreadyExists = heights.find((height) => height.toastId === toast.id);
577
+ if (!alreadyExists) {
578
+ return [
579
+ {
580
+ toastId: toast.id,
581
+ height: newHeight,
582
+ position: toast.position
583
+ },
584
+ ...heights
585
+ ];
586
+ } else if (alreadyExists.height !== newHeight) {
587
+ return heights.map((height) => height.toastId === toast.id ? {
588
+ ...height,
589
+ height: newHeight
590
+ } : height);
591
+ }
592
+ return heights;
593
+ });
594
+ });
595
+ const deleteToast = React.useCallback(() => {
596
+ setRemoved(true);
597
+ setOffsetBeforeRemove(offset.current);
598
+ setHeights((h) => h.filter((height) => height.toastId !== toast.id));
599
+ setTimeout(() => {
600
+ removeToast(toast);
601
+ }, TIME_BEFORE_UNMOUNT);
602
+ }, [
603
+ toast,
604
+ removeToast,
605
+ setHeights,
606
+ offset
607
+ ]);
608
+ React.useEffect(() => {
609
+ if (toast.promise && toastType === "loading" || toast.duration === Infinity || toast.type === "loading")
610
+ return;
611
+ let timeoutId;
612
+ const pauseTimer = () => {
613
+ if (lastCloseTimerStartTimeRef.current < closeTimerStartTimeRef.current) {
614
+ const elapsedTime = new Date().getTime() - closeTimerStartTimeRef.current;
615
+ remainingTime.current = remainingTime.current - elapsedTime;
616
+ }
617
+ lastCloseTimerStartTimeRef.current = new Date().getTime();
618
+ };
619
+ const startTimer = () => {
620
+ if (remainingTime.current === Infinity)
621
+ return;
622
+ closeTimerStartTimeRef.current = new Date().getTime();
623
+ timeoutId = setTimeout(() => {
624
+ toast.onAutoClose == null || toast.onAutoClose.call(toast, toast);
625
+ deleteToast();
626
+ }, remainingTime.current);
627
+ };
628
+ if (expanded || interacting || isDocumentHidden) {
629
+ pauseTimer();
630
+ } else {
631
+ startTimer();
632
+ }
633
+ return () => clearTimeout(timeoutId);
634
+ }, [
635
+ expanded,
636
+ interacting,
637
+ toast,
638
+ toastType,
639
+ isDocumentHidden,
640
+ deleteToast
641
+ ]);
642
+ React.useEffect(() => {
643
+ if (toast.delete) {
644
+ deleteToast();
645
+ toast.onDismiss == null || toast.onDismiss.call(toast, toast);
646
+ }
647
+ }, [
648
+ deleteToast,
649
+ toast.delete
650
+ ]);
651
+ function getLoadingIcon() {
652
+ var _toast_classNames;
653
+ if (icons == null ? undefined : icons.loading) {
654
+ var _toast_classNames1;
655
+ return /* @__PURE__ */ React.createElement("div", {
656
+ className: cn(classNames == null ? undefined : classNames.loader, toast == null ? undefined : (_toast_classNames1 = toast.classNames) == null ? undefined : _toast_classNames1.loader, "sonner-loader"),
657
+ "data-visible": toastType === "loading"
658
+ }, icons.loading);
659
+ }
660
+ return /* @__PURE__ */ React.createElement(Loader, {
661
+ className: cn(classNames == null ? undefined : classNames.loader, toast == null ? undefined : (_toast_classNames = toast.classNames) == null ? undefined : _toast_classNames.loader),
662
+ visible: toastType === "loading"
663
+ });
664
+ }
665
+ const icon = toast.icon || (icons == null ? undefined : icons[toastType]) || getAsset(toastType);
666
+ var _toast_richColors, _icons_close;
667
+ return /* @__PURE__ */ React.createElement("li", {
668
+ tabIndex: 0,
669
+ ref: toastRef,
670
+ className: cn(className, toastClassname, classNames == null ? undefined : classNames.toast, toast == null ? undefined : (_toast_classNames = toast.classNames) == null ? undefined : _toast_classNames.toast, classNames == null ? undefined : classNames[toastTypeKey], toast == null ? undefined : (_toast_classNames1 = toast.classNames) == null ? undefined : _toast_classNames1[toastTypeKey]),
671
+ "data-sonner-toast": "",
672
+ "data-rich-colors": (_toast_richColors = toast.richColors) != null ? _toast_richColors : defaultRichColors,
673
+ "data-styled": !Boolean(toast.jsx || toast.unstyled || unstyled),
674
+ "data-mounted": mounted,
675
+ "data-promise": Boolean(toast.promise),
676
+ "data-swiped": isSwiped,
677
+ "data-removed": removed,
678
+ "data-visible": isVisible,
679
+ "data-y-position": y,
680
+ "data-x-position": x,
681
+ "data-index": index,
682
+ "data-front": isFront,
683
+ "data-swiping": swiping,
684
+ "data-dismissible": dismissible,
685
+ "data-type": toastType,
686
+ "data-invert": invert,
687
+ "data-swipe-out": swipeOut,
688
+ "data-swipe-direction": swipeOutDirection,
689
+ "data-expanded": Boolean(expanded || expandByDefault && mounted),
690
+ "data-testid": toast.testId,
691
+ style: {
692
+ "--index": index,
693
+ "--toasts-before": index,
694
+ "--z-index": toasts.length - index,
695
+ "--offset": `${removed ? offsetBeforeRemove : offset.current}px`,
696
+ "--initial-height": expandByDefault ? "auto" : `${initialHeight}px`,
697
+ ...style,
698
+ ...toast.style
699
+ },
700
+ onDragEnd: () => {
701
+ setSwiping(false);
702
+ setSwipeDirection(null);
703
+ pointerStartRef.current = null;
704
+ },
705
+ onPointerDown: (event) => {
706
+ if (event.button === 2)
707
+ return;
708
+ if (disabled || !dismissible)
709
+ return;
710
+ dragStartTime.current = new Date;
711
+ setOffsetBeforeRemove(offset.current);
712
+ event.target.setPointerCapture(event.pointerId);
713
+ if (event.target.tagName === "BUTTON")
714
+ return;
715
+ setSwiping(true);
716
+ pointerStartRef.current = {
717
+ x: event.clientX,
718
+ y: event.clientY
719
+ };
720
+ },
721
+ onPointerUp: () => {
722
+ var _toastRef_current, _toastRef_current1, _dragStartTime_current;
723
+ if (swipeOut || !dismissible)
724
+ return;
725
+ pointerStartRef.current = null;
726
+ const swipeAmountX = Number(((_toastRef_current = toastRef.current) == null ? undefined : _toastRef_current.style.getPropertyValue("--swipe-amount-x").replace("px", "")) || 0);
727
+ const swipeAmountY = Number(((_toastRef_current1 = toastRef.current) == null ? undefined : _toastRef_current1.style.getPropertyValue("--swipe-amount-y").replace("px", "")) || 0);
728
+ const timeTaken = new Date().getTime() - ((_dragStartTime_current = dragStartTime.current) == null ? undefined : _dragStartTime_current.getTime());
729
+ const swipeAmount = swipeDirection === "x" ? swipeAmountX : swipeAmountY;
730
+ const velocity = Math.abs(swipeAmount) / timeTaken;
731
+ const isAllowedDirection = swipeDirection === "x" ? swipeDirections.includes(swipeAmountX > 0 ? "right" : "left") : swipeDirections.includes(swipeAmountY > 0 ? "bottom" : "top");
732
+ if (isAllowedDirection && (Math.abs(swipeAmount) >= SWIPE_THRESHOLD || velocity > 0.11)) {
733
+ setOffsetBeforeRemove(offset.current);
734
+ toast.onDismiss == null || toast.onDismiss.call(toast, toast);
735
+ if (swipeDirection === "x") {
736
+ setSwipeOutDirection(swipeAmountX > 0 ? "right" : "left");
737
+ } else {
738
+ setSwipeOutDirection(swipeAmountY > 0 ? "down" : "up");
739
+ }
740
+ deleteToast();
741
+ setSwipeOut(true);
742
+ return;
743
+ } else {
744
+ var _toastRef_current2, _toastRef_current3;
745
+ (_toastRef_current2 = toastRef.current) == null || _toastRef_current2.style.setProperty("--swipe-amount-x", `0px`);
746
+ (_toastRef_current3 = toastRef.current) == null || _toastRef_current3.style.setProperty("--swipe-amount-y", `0px`);
747
+ }
748
+ setIsSwiped(false);
749
+ setSwiping(false);
750
+ setSwipeDirection(null);
751
+ },
752
+ onPointerMove: (event) => {
753
+ var _window_getSelection, _toastRef_current, _toastRef_current1;
754
+ if (!pointerStartRef.current || !dismissible)
755
+ return;
756
+ const isHighlighted = ((_window_getSelection = window.getSelection()) == null ? undefined : _window_getSelection.toString().length) > 0;
757
+ if (isHighlighted)
758
+ return;
759
+ const yDelta = event.clientY - pointerStartRef.current.y;
760
+ const xDelta = event.clientX - pointerStartRef.current.x;
761
+ if (!swipeDirection && (Math.abs(xDelta) > 1 || Math.abs(yDelta) > 1)) {
762
+ setSwipeDirection(Math.abs(xDelta) > Math.abs(yDelta) ? "x" : "y");
763
+ }
764
+ let swipeAmount = {
765
+ x: 0,
766
+ y: 0
767
+ };
768
+ const getDampening = (delta) => {
769
+ const factor = Math.abs(delta) / 20;
770
+ return 1 / (1.5 + factor);
771
+ };
772
+ if (swipeDirection === "y") {
773
+ if (swipeDirections.includes("top") || swipeDirections.includes("bottom")) {
774
+ if (swipeDirections.includes("top") && yDelta < 0 || swipeDirections.includes("bottom") && yDelta > 0) {
775
+ swipeAmount.y = yDelta;
776
+ } else {
777
+ const dampenedDelta = yDelta * getDampening(yDelta);
778
+ swipeAmount.y = Math.abs(dampenedDelta) < Math.abs(yDelta) ? dampenedDelta : yDelta;
779
+ }
780
+ }
781
+ } else if (swipeDirection === "x") {
782
+ if (swipeDirections.includes("left") || swipeDirections.includes("right")) {
783
+ if (swipeDirections.includes("left") && xDelta < 0 || swipeDirections.includes("right") && xDelta > 0) {
784
+ swipeAmount.x = xDelta;
785
+ } else {
786
+ const dampenedDelta = xDelta * getDampening(xDelta);
787
+ swipeAmount.x = Math.abs(dampenedDelta) < Math.abs(xDelta) ? dampenedDelta : xDelta;
788
+ }
789
+ }
790
+ }
791
+ if (Math.abs(swipeAmount.x) > 0 || Math.abs(swipeAmount.y) > 0) {
792
+ setIsSwiped(true);
793
+ }
794
+ (_toastRef_current = toastRef.current) == null || _toastRef_current.style.setProperty("--swipe-amount-x", `${swipeAmount.x}px`);
795
+ (_toastRef_current1 = toastRef.current) == null || _toastRef_current1.style.setProperty("--swipe-amount-y", `${swipeAmount.y}px`);
796
+ }
797
+ }, closeButton && !toast.jsx && toastType !== "loading" ? /* @__PURE__ */ React.createElement("button", {
798
+ "aria-label": closeButtonAriaLabel,
799
+ "data-disabled": disabled,
800
+ "data-close-button": true,
801
+ onClick: disabled || !dismissible ? () => {} : () => {
802
+ deleteToast();
803
+ toast.onDismiss == null || toast.onDismiss.call(toast, toast);
804
+ },
805
+ className: cn(classNames == null ? undefined : classNames.closeButton, toast == null ? undefined : (_toast_classNames2 = toast.classNames) == null ? undefined : _toast_classNames2.closeButton)
806
+ }, (_icons_close = icons == null ? undefined : icons.close) != null ? _icons_close : CloseIcon) : null, (toastType || toast.icon || toast.promise) && toast.icon !== null && ((icons == null ? undefined : icons[toastType]) !== null || toast.icon) ? /* @__PURE__ */ React.createElement("div", {
807
+ "data-icon": "",
808
+ className: cn(classNames == null ? undefined : classNames.icon, toast == null ? undefined : (_toast_classNames3 = toast.classNames) == null ? undefined : _toast_classNames3.icon)
809
+ }, toastType === "loading" ? toast.icon || getLoadingIcon() : toast.promise ? getLoadingIcon() : null, toastType !== "loading" ? icon : null) : null, /* @__PURE__ */ React.createElement("div", {
810
+ "data-content": "",
811
+ className: cn(classNames == null ? undefined : classNames.content, toast == null ? undefined : (_toast_classNames4 = toast.classNames) == null ? undefined : _toast_classNames4.content)
812
+ }, /* @__PURE__ */ React.createElement("div", {
813
+ "data-title": "",
814
+ className: cn(classNames == null ? undefined : classNames.title, toast == null ? undefined : (_toast_classNames5 = toast.classNames) == null ? undefined : _toast_classNames5.title)
815
+ }, toast.jsx ? toast.jsx : typeof toast.title === "function" ? toast.title() : toast.title), toast.description ? /* @__PURE__ */ React.createElement("div", {
816
+ "data-description": "",
817
+ className: cn(descriptionClassName, toastDescriptionClassname, classNames == null ? undefined : classNames.description, toast == null ? undefined : (_toast_classNames6 = toast.classNames) == null ? undefined : _toast_classNames6.description)
818
+ }, typeof toast.description === "function" ? toast.description() : toast.description) : null), /* @__PURE__ */ React.isValidElement(toast.cancel) ? toast.cancel : toast.cancel && isAction(toast.cancel) ? /* @__PURE__ */ React.createElement("button", {
819
+ "data-button": true,
820
+ "data-cancel": true,
821
+ style: toast.cancelButtonStyle || cancelButtonStyle,
822
+ onClick: (event) => {
823
+ if (!isAction(toast.cancel))
824
+ return;
825
+ if (!dismissible)
826
+ return;
827
+ toast.cancel.onClick == null || toast.cancel.onClick.call(toast.cancel, event);
828
+ deleteToast();
829
+ },
830
+ className: cn(classNames == null ? undefined : classNames.cancelButton, toast == null ? undefined : (_toast_classNames7 = toast.classNames) == null ? undefined : _toast_classNames7.cancelButton)
831
+ }, toast.cancel.label) : null, /* @__PURE__ */ React.isValidElement(toast.action) ? toast.action : toast.action && isAction(toast.action) ? /* @__PURE__ */ React.createElement("button", {
832
+ "data-button": true,
833
+ "data-action": true,
834
+ style: toast.actionButtonStyle || actionButtonStyle,
835
+ onClick: (event) => {
836
+ if (!isAction(toast.action))
837
+ return;
838
+ toast.action.onClick == null || toast.action.onClick.call(toast.action, event);
839
+ if (event.defaultPrevented)
840
+ return;
841
+ deleteToast();
842
+ },
843
+ className: cn(classNames == null ? undefined : classNames.actionButton, toast == null ? undefined : (_toast_classNames8 = toast.classNames) == null ? undefined : _toast_classNames8.actionButton)
844
+ }, toast.action.label) : null);
845
+ };
846
+ function getDocumentDirection() {
847
+ if (typeof window === "undefined")
848
+ return "ltr";
849
+ if (typeof document === "undefined")
850
+ return "ltr";
851
+ const dirAttribute = document.documentElement.getAttribute("dir");
852
+ if (dirAttribute === "auto" || !dirAttribute) {
853
+ return window.getComputedStyle(document.documentElement).direction;
854
+ }
855
+ return dirAttribute;
856
+ }
857
+ function assignOffset(defaultOffset, mobileOffset) {
858
+ const styles = {};
859
+ [
860
+ defaultOffset,
861
+ mobileOffset
862
+ ].forEach((offset, index) => {
863
+ const isMobile = index === 1;
864
+ const prefix = isMobile ? "--mobile-offset" : "--offset";
865
+ const defaultValue = isMobile ? MOBILE_VIEWPORT_OFFSET : VIEWPORT_OFFSET;
866
+ function assignAll(offset) {
867
+ [
868
+ "top",
869
+ "right",
870
+ "bottom",
871
+ "left"
872
+ ].forEach((key) => {
873
+ styles[`${prefix}-${key}`] = typeof offset === "number" ? `${offset}px` : offset;
874
+ });
875
+ }
876
+ if (typeof offset === "number" || typeof offset === "string") {
877
+ assignAll(offset);
878
+ } else if (typeof offset === "object") {
879
+ [
880
+ "top",
881
+ "right",
882
+ "bottom",
883
+ "left"
884
+ ].forEach((key) => {
885
+ if (offset[key] === undefined) {
886
+ styles[`${prefix}-${key}`] = defaultValue;
887
+ } else {
888
+ styles[`${prefix}-${key}`] = typeof offset[key] === "number" ? `${offset[key]}px` : offset[key];
889
+ }
890
+ });
891
+ } else {
892
+ assignAll(defaultValue);
893
+ }
894
+ });
895
+ return styles;
896
+ }
897
+ function useSonner() {
898
+ const [activeToasts, setActiveToasts] = React.useState([]);
899
+ React.useEffect(() => {
900
+ return ToastState.subscribe((toast) => {
901
+ if (toast.dismiss) {
902
+ setTimeout(() => {
903
+ ReactDOM.flushSync(() => {
904
+ setActiveToasts((toasts) => toasts.filter((t) => t.id !== toast.id));
905
+ });
906
+ });
907
+ return;
908
+ }
909
+ setTimeout(() => {
910
+ ReactDOM.flushSync(() => {
911
+ setActiveToasts((toasts) => {
912
+ const indexOfExistingToast = toasts.findIndex((t) => t.id === toast.id);
913
+ if (indexOfExistingToast !== -1) {
914
+ return [
915
+ ...toasts.slice(0, indexOfExistingToast),
916
+ {
917
+ ...toasts[indexOfExistingToast],
918
+ ...toast
919
+ },
920
+ ...toasts.slice(indexOfExistingToast + 1)
921
+ ];
922
+ }
923
+ return [
924
+ toast,
925
+ ...toasts
926
+ ];
927
+ });
928
+ });
929
+ });
930
+ });
931
+ }, []);
932
+ return {
933
+ toasts: activeToasts
934
+ };
935
+ }
936
+ var Toaster = /* @__PURE__ */ React.forwardRef(function Toaster(props, ref) {
937
+ const { id, invert, position = "bottom-right", hotkey = [
938
+ "altKey",
939
+ "KeyT"
940
+ ], expand, closeButton, className, offset, mobileOffset, theme = "light", richColors, duration, style, visibleToasts = VISIBLE_TOASTS_AMOUNT, toastOptions, dir = getDocumentDirection(), gap = GAP, icons, customAriaLabel, containerAriaLabel = "Notifications" } = props;
941
+ const [toasts, setToasts] = React.useState([]);
942
+ const filteredToasts = React.useMemo(() => {
943
+ if (id) {
944
+ return toasts.filter((toast) => toast.toasterId === id);
945
+ }
946
+ return toasts.filter((toast) => !toast.toasterId);
947
+ }, [
948
+ toasts,
949
+ id
950
+ ]);
951
+ const possiblePositions = React.useMemo(() => {
952
+ return Array.from(new Set([
953
+ position
954
+ ].concat(filteredToasts.filter((toast) => toast.position).map((toast) => toast.position))));
955
+ }, [
956
+ filteredToasts,
957
+ position
958
+ ]);
959
+ const [heights, setHeights] = React.useState([]);
960
+ const [expanded, setExpanded] = React.useState(false);
961
+ const [interacting, setInteracting] = React.useState(false);
962
+ const [actualTheme, setActualTheme] = React.useState(theme !== "system" ? theme : typeof window !== "undefined" ? window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : "light");
963
+ const listRef = React.useRef(null);
964
+ const hotkeyLabel = hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, "");
965
+ const lastFocusedElementRef = React.useRef(null);
966
+ const isFocusWithinRef = React.useRef(false);
967
+ const removeToast = React.useCallback((toastToRemove) => {
968
+ setToasts((toasts) => {
969
+ var _toasts_find;
970
+ if (!((_toasts_find = toasts.find((toast) => toast.id === toastToRemove.id)) == null ? undefined : _toasts_find.delete)) {
971
+ ToastState.dismiss(toastToRemove.id);
972
+ }
973
+ return toasts.filter(({ id }) => id !== toastToRemove.id);
974
+ });
975
+ }, []);
976
+ React.useEffect(() => {
977
+ return ToastState.subscribe((toast) => {
978
+ if (toast.dismiss) {
979
+ requestAnimationFrame(() => {
980
+ setToasts((toasts) => toasts.map((t) => t.id === toast.id ? {
981
+ ...t,
982
+ delete: true
983
+ } : t));
984
+ });
985
+ return;
986
+ }
987
+ setTimeout(() => {
988
+ ReactDOM.flushSync(() => {
989
+ setToasts((toasts) => {
990
+ const indexOfExistingToast = toasts.findIndex((t) => t.id === toast.id);
991
+ if (indexOfExistingToast !== -1) {
992
+ return [
993
+ ...toasts.slice(0, indexOfExistingToast),
994
+ {
995
+ ...toasts[indexOfExistingToast],
996
+ ...toast
997
+ },
998
+ ...toasts.slice(indexOfExistingToast + 1)
999
+ ];
1000
+ }
1001
+ return [
1002
+ toast,
1003
+ ...toasts
1004
+ ];
1005
+ });
1006
+ });
1007
+ });
1008
+ });
1009
+ }, []);
1010
+ React.useEffect(() => {
1011
+ if (theme !== "system") {
1012
+ setActualTheme(theme);
1013
+ return;
1014
+ }
1015
+ if (theme === "system") {
1016
+ if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
1017
+ setActualTheme("dark");
1018
+ } else {
1019
+ setActualTheme("light");
1020
+ }
1021
+ }
1022
+ if (typeof window === "undefined")
1023
+ return;
1024
+ const darkMediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
1025
+ try {
1026
+ darkMediaQuery.addEventListener("change", ({ matches }) => {
1027
+ if (matches) {
1028
+ setActualTheme("dark");
1029
+ } else {
1030
+ setActualTheme("light");
1031
+ }
1032
+ });
1033
+ } catch (error) {
1034
+ darkMediaQuery.addListener(({ matches }) => {
1035
+ try {
1036
+ if (matches) {
1037
+ setActualTheme("dark");
1038
+ } else {
1039
+ setActualTheme("light");
1040
+ }
1041
+ } catch (e) {
1042
+ console.error(e);
1043
+ }
1044
+ });
1045
+ }
1046
+ }, [
1047
+ theme
1048
+ ]);
1049
+ React.useEffect(() => {
1050
+ if (toasts.length <= 1) {
1051
+ setExpanded(false);
1052
+ }
1053
+ }, [
1054
+ toasts
1055
+ ]);
1056
+ React.useEffect(() => {
1057
+ const handleKeyDown = (event) => {
1058
+ var _listRef_current;
1059
+ const isHotkeyPressed = hotkey.length > 0 && hotkey.every((key) => event[key] || event.code === key);
1060
+ if (isHotkeyPressed) {
1061
+ var _listRef_current1;
1062
+ setExpanded(true);
1063
+ (_listRef_current1 = listRef.current) == null || _listRef_current1.focus();
1064
+ }
1065
+ if (event.code === "Escape" && (document.activeElement === listRef.current || ((_listRef_current = listRef.current) == null ? undefined : _listRef_current.contains(document.activeElement)))) {
1066
+ setExpanded(false);
1067
+ }
1068
+ };
1069
+ document.addEventListener("keydown", handleKeyDown);
1070
+ return () => document.removeEventListener("keydown", handleKeyDown);
1071
+ }, [
1072
+ hotkey
1073
+ ]);
1074
+ React.useEffect(() => {
1075
+ if (listRef.current) {
1076
+ return () => {
1077
+ if (lastFocusedElementRef.current) {
1078
+ lastFocusedElementRef.current.focus({
1079
+ preventScroll: true
1080
+ });
1081
+ lastFocusedElementRef.current = null;
1082
+ isFocusWithinRef.current = false;
1083
+ }
1084
+ };
1085
+ }
1086
+ }, [
1087
+ listRef.current
1088
+ ]);
1089
+ return /* @__PURE__ */ React.createElement("section", {
1090
+ ref,
1091
+ "aria-label": customAriaLabel != null ? customAriaLabel : `${containerAriaLabel} ${hotkeyLabel}`,
1092
+ tabIndex: -1,
1093
+ "aria-live": "polite",
1094
+ "aria-relevant": "additions text",
1095
+ "aria-atomic": "false",
1096
+ suppressHydrationWarning: true,
1097
+ "data-react-aria-top-layer": true
1098
+ }, possiblePositions.map((position, index) => {
1099
+ var _heights_;
1100
+ const [y, x] = position.split("-");
1101
+ if (!filteredToasts.length)
1102
+ return null;
1103
+ return /* @__PURE__ */ React.createElement("ol", {
1104
+ key: position,
1105
+ dir: dir === "auto" ? getDocumentDirection() : dir,
1106
+ tabIndex: -1,
1107
+ ref: listRef,
1108
+ className,
1109
+ "data-sonner-toaster": true,
1110
+ "data-sonner-theme": actualTheme,
1111
+ "data-y-position": y,
1112
+ "data-x-position": x,
1113
+ style: {
1114
+ "--front-toast-height": `${((_heights_ = heights[0]) == null ? undefined : _heights_.height) || 0}px`,
1115
+ "--width": `${TOAST_WIDTH}px`,
1116
+ "--gap": `${gap}px`,
1117
+ ...style,
1118
+ ...assignOffset(offset, mobileOffset)
1119
+ },
1120
+ onBlur: (event) => {
1121
+ if (isFocusWithinRef.current && !event.currentTarget.contains(event.relatedTarget)) {
1122
+ isFocusWithinRef.current = false;
1123
+ if (lastFocusedElementRef.current) {
1124
+ lastFocusedElementRef.current.focus({
1125
+ preventScroll: true
1126
+ });
1127
+ lastFocusedElementRef.current = null;
1128
+ }
1129
+ }
1130
+ },
1131
+ onFocus: (event) => {
1132
+ const isNotDismissible = event.target instanceof HTMLElement && event.target.dataset.dismissible === "false";
1133
+ if (isNotDismissible)
1134
+ return;
1135
+ if (!isFocusWithinRef.current) {
1136
+ isFocusWithinRef.current = true;
1137
+ lastFocusedElementRef.current = event.relatedTarget;
1138
+ }
1139
+ },
1140
+ onMouseEnter: () => setExpanded(true),
1141
+ onMouseMove: () => setExpanded(true),
1142
+ onMouseLeave: () => {
1143
+ if (!interacting) {
1144
+ setExpanded(false);
1145
+ }
1146
+ },
1147
+ onDragEnd: () => setExpanded(false),
1148
+ onPointerDown: (event) => {
1149
+ const isNotDismissible = event.target instanceof HTMLElement && event.target.dataset.dismissible === "false";
1150
+ if (isNotDismissible)
1151
+ return;
1152
+ setInteracting(true);
1153
+ },
1154
+ onPointerUp: () => setInteracting(false)
1155
+ }, filteredToasts.filter((toast) => !toast.position && index === 0 || toast.position === position).map((toast, index) => {
1156
+ var _toastOptions_duration, _toastOptions_closeButton;
1157
+ return /* @__PURE__ */ React.createElement(Toast, {
1158
+ key: toast.id,
1159
+ icons,
1160
+ index,
1161
+ toast,
1162
+ defaultRichColors: richColors,
1163
+ duration: (_toastOptions_duration = toastOptions == null ? undefined : toastOptions.duration) != null ? _toastOptions_duration : duration,
1164
+ className: toastOptions == null ? undefined : toastOptions.className,
1165
+ descriptionClassName: toastOptions == null ? undefined : toastOptions.descriptionClassName,
1166
+ invert,
1167
+ visibleToasts,
1168
+ closeButton: (_toastOptions_closeButton = toastOptions == null ? undefined : toastOptions.closeButton) != null ? _toastOptions_closeButton : closeButton,
1169
+ interacting,
1170
+ position,
1171
+ style: toastOptions == null ? undefined : toastOptions.style,
1172
+ unstyled: toastOptions == null ? undefined : toastOptions.unstyled,
1173
+ classNames: toastOptions == null ? undefined : toastOptions.classNames,
1174
+ cancelButtonStyle: toastOptions == null ? undefined : toastOptions.cancelButtonStyle,
1175
+ actionButtonStyle: toastOptions == null ? undefined : toastOptions.actionButtonStyle,
1176
+ closeButtonAriaLabel: toastOptions == null ? undefined : toastOptions.closeButtonAriaLabel,
1177
+ removeToast,
1178
+ toasts: filteredToasts.filter((t) => t.position == toast.position),
1179
+ heights: heights.filter((h) => h.position == toast.position),
1180
+ setHeights,
1181
+ expandByDefault: expand,
1182
+ gap,
1183
+ expanded,
1184
+ swipeDirections: props.swipeDirections
1185
+ });
1186
+ }));
1187
+ }));
1188
+ });
1189
+
1190
+ // src/components/sonner/Sonner.tsx
1191
+ import { CircleCheckIcon, InfoIcon as InfoIcon2, TriangleAlertIcon, OctagonXIcon, LoaderCircleIcon, XIcon } from "lucide-react";
1192
+ import { useDirection } from "@base-ui/react/direction-provider";
1193
+ import { jsx } from "react/jsx-runtime";
1194
+ function Sonner({
1195
+ density,
1196
+ className,
1197
+ toastOptions,
1198
+ icons,
1199
+ theme,
1200
+ dir,
1201
+ expand = true,
1202
+ ...props
1203
+ }) {
1204
+ const { resolvedTheme } = useTheme2();
1205
+ const resolvedDensity = useDensity(density);
1206
+ const inheritedDirection = useDirection();
1207
+ return /* @__PURE__ */ jsx("div", {
1208
+ "data-slot": "sonner",
1209
+ "data-density": resolvedDensity,
1210
+ className: "contents",
1211
+ children: /* @__PURE__ */ jsx(Toaster, {
1212
+ theme: theme ?? resolvedTheme,
1213
+ dir: dir ?? inheritedDirection,
1214
+ expand,
1215
+ className: cn2("[&[data-sonner-toaster]]:font-mono", "[@media(max-width:600px)]:[&[data-sonner-toaster]]:w-auto!", "[@media(max-width:600px)]:[&[data-sonner-toaster]]:left-[var(--mobile-offset-left)]!", "[@media(max-width:600px)]:[&[data-sonner-toaster]]:right-[var(--mobile-offset-right)]!", "[@media(max-width:600px)]:[&[data-sonner-toaster]_[data-sonner-toast]]:w-full!", className),
1216
+ icons: {
1217
+ success: /* @__PURE__ */ jsx("span", {
1218
+ children: /* @__PURE__ */ jsx(CircleCheckIcon, {
1219
+ "aria-hidden": "true"
1220
+ })
1221
+ }),
1222
+ info: /* @__PURE__ */ jsx("span", {
1223
+ children: /* @__PURE__ */ jsx(InfoIcon2, {
1224
+ "aria-hidden": "true"
1225
+ })
1226
+ }),
1227
+ warning: /* @__PURE__ */ jsx("span", {
1228
+ children: /* @__PURE__ */ jsx(TriangleAlertIcon, {
1229
+ "aria-hidden": "true"
1230
+ })
1231
+ }),
1232
+ error: /* @__PURE__ */ jsx("span", {
1233
+ children: /* @__PURE__ */ jsx(OctagonXIcon, {
1234
+ "aria-hidden": "true"
1235
+ })
1236
+ }),
1237
+ loading: /* @__PURE__ */ jsx(LoaderCircleIcon, {
1238
+ "aria-hidden": "true",
1239
+ className: "animate-spin motion-reduce:animate-none"
1240
+ }),
1241
+ close: /* @__PURE__ */ jsx(XIcon, {
1242
+ "aria-hidden": "true"
1243
+ }),
1244
+ ...icons
1245
+ },
1246
+ toastOptions: {
1247
+ ...toastOptions,
1248
+ unstyled: toastOptions?.unstyled ?? true,
1249
+ closeButtonAriaLabel: toastOptions?.closeButtonAriaLabel ?? "Close toast",
1250
+ classNames: {
1251
+ ...toastOptions?.classNames,
1252
+ toast: cn2("flex w-full items-center gap-control-gap rounded-md border border-frame-edge bg-popover p-panel text-sm text-popover-foreground shadow-frame outline-none focus-visible:ring-1 focus-visible:ring-ring", "data-[expanded=false]:data-[front=false]:[&>*]:opacity-0 data-[expanded=false]:data-[front=false]:[--y:translateY(calc(var(--lift-amount)*var(--toasts-before)))]!", toastOptions?.classNames?.toast),
1253
+ title: cn2("font-medium", toastOptions?.classNames?.title),
1254
+ description: cn2("text-muted-foreground!", toastOptions?.classNames?.description),
1255
+ content: cn2("flex min-w-0 flex-1 flex-col gap-1", toastOptions?.classNames?.content),
1256
+ icon: cn2("relative flex size-4 shrink-0 [&_svg]:size-4", toastOptions?.classNames?.icon),
1257
+ loader: cn2("[&.sonner-loader[data-visible=false]]:[transform:translate(-50%,-50%)]", toastOptions?.classNames?.loader),
1258
+ actionButton: cn2(buttonVariants2({ variant: "outline", size: "sm" }), "ml-auto", toastOptions?.classNames?.actionButton),
1259
+ cancelButton: cn2(buttonVariants2({ variant: "ghost", size: "sm" }), toastOptions?.classNames?.cancelButton),
1260
+ closeButton: cn2(buttonVariants2({ variant: "ghost", size: "icon-sm" }), "relative order-last shrink-0 [&_svg]:size-4", "border-transparent! bg-transparent! text-inherit! hover:bg-muted! hover:text-foreground! focus-visible:border-ring!", toastOptions?.classNames?.closeButton)
1261
+ }
1262
+ },
1263
+ ...props
1264
+ })
1265
+ });
1266
+ }
1267
+ export {
1268
+ Sonner,
1269
+ Sonner as SonnerToaster,
1270
+ Sonner as Toaster,
1271
+ toast,
1272
+ useSonner
1273
+ };