@commentkit/comment-kit 0.7.7 → 1.0.0-beta.0

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 (109) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +108 -762
  3. package/SECURITY.md +19 -14
  4. package/dist/npm/THIRD_PARTY_NOTICES.txt +73 -0
  5. package/dist/npm/chunks/anchor-DT-Ynhh1.js +270 -0
  6. package/dist/npm/chunks/client-D1vrh_5G.js +590 -0
  7. package/dist/{shared/capture-colors-D0uLr-vZ.js → npm/chunks/colors-CX-IPjvb.js} +2 -0
  8. package/dist/npm/chunks/html2canvas-_mjSRP3G.js +4011 -0
  9. package/dist/npm/chunks/mount-Ce1MZrcm.js +2485 -0
  10. package/dist/{shared/pusher-CnhQgAvF.js → npm/chunks/pusher-DRKlokR8.js} +224 -222
  11. package/dist/npm/chunks/realtime-5SvAvTUU.js +23 -0
  12. package/dist/npm/chunks/rolldown-runtime-VHNaYcLd.js +13 -0
  13. package/dist/npm/chunks/src-DJjfvVsa.js +330 -0
  14. package/dist/npm/element.js +24 -0
  15. package/dist/npm/headless.js +3 -0
  16. package/dist/npm/index.js +3 -0
  17. package/dist/npm/react.js +17 -0
  18. package/dist/npm/svelte.js +8 -0
  19. package/dist/npm/types/adapters/react.d.ts +9 -0
  20. package/dist/npm/types/adapters/svelte.d.ts +9 -0
  21. package/dist/npm/types/adapters/vue.d.ts +46 -0
  22. package/dist/npm/types/anchor/index.d.ts +49 -0
  23. package/dist/npm/types/core/api.d.ts +29 -0
  24. package/dist/npm/types/core/auth.d.ts +48 -0
  25. package/dist/npm/types/core/client.d.ts +100 -0
  26. package/dist/npm/types/core/store.d.ts +7 -0
  27. package/dist/npm/types/core/types.d.ts +278 -0
  28. package/dist/npm/types/element.d.ts +10 -0
  29. package/dist/npm/types/headless.d.ts +7 -0
  30. package/dist/npm/types/index.d.ts +30 -0
  31. package/dist/npm/vue.js +32 -0
  32. package/package.json +65 -173
  33. package/dist/THIRD_PARTY_NOTICES.txt +0 -284
  34. package/dist/angular.es.js +0 -321
  35. package/dist/comment-kit.es.js +0 -218
  36. package/dist/demo.es.js +0 -483
  37. package/dist/headless.es.js +0 -4
  38. package/dist/preact.es.js +0 -117
  39. package/dist/qwik.es.js +0 -1
  40. package/dist/qwik.qwik.mjs +0 -114
  41. package/dist/react.es.js +0 -98
  42. package/dist/shared/ShadowRootContext-DD6a0QaI.js +0 -11
  43. package/dist/shared/annotation-icons-Dh-bmNYK.js +0 -172
  44. package/dist/shared/annotation-toolbar-zeiCmKIr.js +0 -1086
  45. package/dist/shared/attachment-refresh-DAacLaRu.js +0 -94
  46. package/dist/shared/bridge-CJoGYngu.js +0 -177
  47. package/dist/shared/button-D4GHW6oZ.js +0 -474
  48. package/dist/shared/button-group-BVR7iT-S.js +0 -91
  49. package/dist/shared/capture-privacy-CiOrcAlt.js +0 -101
  50. package/dist/shared/comment-drawing-canvas-Btc12IsS.js +0 -124
  51. package/dist/shared/comment-icon-D8JTCEJ7.js +0 -607
  52. package/dist/shared/comment-image-lightbox--QpbcAtH.js +0 -190
  53. package/dist/shared/comment-images-content-C_r4SHM-.js +0 -214
  54. package/dist/shared/comment-kit-core-CmLUFujd.js +0 -3682
  55. package/dist/shared/comment-kit-ui-BHwYuSIi.js +0 -19391
  56. package/dist/shared/comment-screenshot-annotator-zJZyO-XM.js +0 -151
  57. package/dist/shared/comment-screenshot-overlay-CoKTYB0J.js +0 -205
  58. package/dist/shared/comment-shortcut-groups-CfEmkitU.js +0 -153
  59. package/dist/shared/createReactComponent-BZHeRbD0.js +0 -45
  60. package/dist/shared/dev-export-panel-Cnt6oCZU.js +0 -207
  61. package/dist/shared/dev-grab-B85jo9AS.js +0 -197
  62. package/dist/shared/dist-D9A5k-N4.js +0 -617
  63. package/dist/shared/dom-Bhf4WFtY.js +0 -223
  64. package/dist/shared/element-selector-Cng84xC7.js +0 -902
  65. package/dist/shared/error-boundary-D3PD74vI.js +0 -21
  66. package/dist/shared/errors-Bu5ajEmB.js +0 -22
  67. package/dist/shared/icons-nzMOLzrm.js +0 -266
  68. package/dist/shared/input-UPtAj0M6.js +0 -111
  69. package/dist/shared/mount-ui-Dz7FB_Ak.js +0 -208
  70. package/dist/shared/realtime-recovery-BjlV-ewc.js +0 -162
  71. package/dist/shared/realtime-yGLX4wMK.js +0 -334
  72. package/dist/shared/request-activity-DQrAUwfA.js +0 -11
  73. package/dist/shared/screenshot-B5-hwpmt.js +0 -199
  74. package/dist/shared/separator-UhJb0Row.js +0 -3955
  75. package/dist/shared/shadow-root-B58ZI2yz.js +0 -133
  76. package/dist/shared/styles-CnYsLS2f.js +0 -2
  77. package/dist/shared/text-B4HHZNaa.js +0 -23
  78. package/dist/shared/token-session-D92MYbNu.js +0 -25
  79. package/dist/shared/useLabelableId-8n0QmH8N.js +0 -154
  80. package/dist/shared/useRender-Uxk1OPK-.js +0 -5
  81. package/dist/shared/useValueChanged-DKq5cMot.js +0 -92
  82. package/dist/shared/validation-3wbbbuX0.js +0 -70
  83. package/dist/shared/websocket-manager-KhH4hL0Q.js +0 -381
  84. package/dist/solid.es.js +0 -98
  85. package/dist/svelte.es.js +0 -130
  86. package/dist/types/adapters/bridge.d.ts +0 -122
  87. package/dist/types/angular/index.d.ts +0 -145
  88. package/dist/types/core/agent-context.d.ts +0 -17
  89. package/dist/types/core/api-client.d.ts +0 -155
  90. package/dist/types/core/comment-kit-core.d.ts +0 -254
  91. package/dist/types/core/local-demo.d.ts +0 -60
  92. package/dist/types/core/types.d.ts +0 -770
  93. package/dist/types/core/websocket-manager.d.ts +0 -125
  94. package/dist/types/core/write-access.d.ts +0 -11
  95. package/dist/types/demo.d.ts +0 -17
  96. package/dist/types/headless.d.ts +0 -8
  97. package/dist/types/index.d.ts +0 -87
  98. package/dist/types/preact/index.d.ts +0 -25
  99. package/dist/types/qwik/index.d.ts +0 -73
  100. package/dist/types/react/client.d.ts +0 -31
  101. package/dist/types/react/index.d.ts +0 -4
  102. package/dist/types/solid/index.d.ts +0 -37
  103. package/dist/types/svelte/index.d.ts +0 -55
  104. package/dist/types/utils/dom.d.ts +0 -59
  105. package/dist/types/utils/event-emitter.d.ts +0 -11
  106. package/dist/types/vue/index.d.ts +0 -87
  107. package/dist/vue.es.js +0 -148
  108. package/docs/api-reference.md +0 -405
  109. package/docs/local-demo.md +0 -60
@@ -1,617 +0,0 @@
1
- import e from "react";
2
- import t from "react-dom";
3
- var n = (e) => {
4
- switch (e) {
5
- case "success": return a;
6
- case "info": return s;
7
- case "warning": return o;
8
- case "error": return c;
9
- default: return null;
10
- }
11
- }, r = Array(12).fill(0), i = ({ visible: t, className: n }) => /*#__PURE__*/ e.createElement("div", {
12
- className: ["sonner-loading-wrapper", n].filter(Boolean).join(" "),
13
- "data-visible": t
14
- }, /*#__PURE__*/ e.createElement("div", { className: "sonner-spinner" }, r.map((t, n) => /*#__PURE__*/ e.createElement("div", {
15
- className: "sonner-loading-bar",
16
- key: `spinner-bar-${n}`
17
- })))), a = /*#__PURE__*/ e.createElement("svg", {
18
- xmlns: "http://www.w3.org/2000/svg",
19
- viewBox: "0 0 20 20",
20
- fill: "currentColor",
21
- height: "20",
22
- width: "20",
23
- "aria-hidden": "true"
24
- }, /*#__PURE__*/ e.createElement("path", {
25
- fillRule: "evenodd",
26
- 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",
27
- clipRule: "evenodd"
28
- })), o = /*#__PURE__*/ e.createElement("svg", {
29
- xmlns: "http://www.w3.org/2000/svg",
30
- viewBox: "0 0 24 24",
31
- fill: "currentColor",
32
- height: "20",
33
- width: "20",
34
- "aria-hidden": "true"
35
- }, /*#__PURE__*/ e.createElement("path", {
36
- fillRule: "evenodd",
37
- 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",
38
- clipRule: "evenodd"
39
- })), s = /*#__PURE__*/ e.createElement("svg", {
40
- xmlns: "http://www.w3.org/2000/svg",
41
- viewBox: "0 0 20 20",
42
- fill: "currentColor",
43
- height: "20",
44
- width: "20",
45
- "aria-hidden": "true"
46
- }, /*#__PURE__*/ e.createElement("path", {
47
- fillRule: "evenodd",
48
- 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",
49
- clipRule: "evenodd"
50
- })), c = /*#__PURE__*/ e.createElement("svg", {
51
- xmlns: "http://www.w3.org/2000/svg",
52
- viewBox: "0 0 20 20",
53
- fill: "currentColor",
54
- height: "20",
55
- width: "20",
56
- "aria-hidden": "true"
57
- }, /*#__PURE__*/ e.createElement("path", {
58
- fillRule: "evenodd",
59
- 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",
60
- clipRule: "evenodd"
61
- })), ee = /*#__PURE__*/ e.createElement("svg", {
62
- xmlns: "http://www.w3.org/2000/svg",
63
- width: "12",
64
- height: "12",
65
- viewBox: "0 0 24 24",
66
- fill: "none",
67
- stroke: "currentColor",
68
- strokeWidth: "1.5",
69
- strokeLinecap: "round",
70
- strokeLinejoin: "round",
71
- "aria-hidden": "true"
72
- }, /*#__PURE__*/ e.createElement("line", {
73
- x1: "18",
74
- y1: "6",
75
- x2: "6",
76
- y2: "18"
77
- }), /*#__PURE__*/ e.createElement("line", {
78
- x1: "6",
79
- y1: "6",
80
- x2: "18",
81
- y2: "18"
82
- })), l = () => {
83
- let [t, n] = e.useState(document.hidden);
84
- return e.useEffect(() => {
85
- let e = () => {
86
- n(document.hidden);
87
- };
88
- return document.addEventListener("visibilitychange", e), () => document.removeEventListener("visibilitychange", e);
89
- }, []), t;
90
- }, u = 1, d = 100, f = (e) => typeof e?.id == "number" || e?.id?.length > 0 ? e.id : u++, p = new class {
91
- constructor() {
92
- this.subscribe = (e) => (this.subscribers.push(e), this.getActiveToasts().forEach((t) => e(t)), () => {
93
- let t = this.subscribers.indexOf(e);
94
- this.subscribers.splice(t, 1);
95
- }), this.publish = (e) => {
96
- this.subscribers.forEach((t) => t(e));
97
- }, this.addToast = (e) => {
98
- this.publish(e), this.toasts = [...this.toasts, e], this.trimHistory();
99
- }, this.trimHistory = () => {
100
- let e = this.toasts.length - d;
101
- e <= 0 || (this.toasts = this.toasts.filter((t) => e > 0 && this.dismissedToasts.has(t.id) ? (this.dismissedToasts.delete(t.id), e--, !1) : !0));
102
- }, this.create = (e) => {
103
- let { message: t, ...n } = e, r = f(e), i = this.pendingDismissals.get(r);
104
- i !== void 0 && (cancelAnimationFrame(i), this.pendingDismissals.delete(r), this.dismissedToasts.delete(r));
105
- let a = this.dismissedToasts.has(r), o = e.dismissible === void 0 || e.dismissible;
106
- return a && (this.dismissedToasts.delete(r), this.toasts = this.toasts.filter((e) => e.id !== r)), !a && this.toasts.find((e) => e.id === r) ? this.toasts = this.toasts.map((n) => n.id === r ? (this.publish({
107
- ...n,
108
- ...e,
109
- id: r,
110
- title: t
111
- }), {
112
- ...n,
113
- ...e,
114
- id: r,
115
- dismissible: o,
116
- title: t
117
- }) : n) : this.addToast({
118
- title: t,
119
- ...n,
120
- dismissible: o,
121
- id: r
122
- }), r;
123
- }, this.dismiss = (e) => {
124
- if (e == null) return this.getActiveToasts().forEach((e) => {
125
- this.dismissedToasts.add(e.id), this.subscribers.forEach((t) => t({
126
- id: e.id,
127
- dismiss: !0
128
- }));
129
- }), e;
130
- this.dismissedToasts.add(e);
131
- let t = this.pendingDismissals.get(e);
132
- return t !== void 0 && cancelAnimationFrame(t), this.pendingDismissals.set(e, requestAnimationFrame(() => {
133
- this.pendingDismissals.delete(e), this.subscribers.forEach((t) => t({
134
- id: e,
135
- dismiss: !0
136
- }));
137
- })), e;
138
- }, this.message = (e, t) => this.create({
139
- ...t,
140
- message: e,
141
- type: void 0
142
- }), this.error = (e, t) => this.create({
143
- ...t,
144
- message: e,
145
- type: "error"
146
- }), this.success = (e, t) => this.create({
147
- ...t,
148
- type: "success",
149
- message: e
150
- }), this.info = (e, t) => this.create({
151
- ...t,
152
- type: "info",
153
- message: e
154
- }), this.warning = (e, t) => this.create({
155
- ...t,
156
- type: "warning",
157
- message: e
158
- }), this.loading = (e, t) => this.create({
159
- ...t,
160
- type: "loading",
161
- message: e
162
- }), this.promise = (t, n) => {
163
- if (!n) return;
164
- let r;
165
- n.loading !== void 0 && (r = this.create({
166
- ...n,
167
- promise: t,
168
- type: "loading",
169
- message: n.loading,
170
- description: typeof n.description == "function" ? void 0 : n.description
171
- }));
172
- let i = Promise.resolve(t instanceof Function ? t() : t), a = r !== void 0, o, s = i.then(async (t) => {
173
- if (o = ["resolve", t], e.isValidElement(t)) a = !1, this.create({
174
- id: r,
175
- type: "default",
176
- message: t
177
- });
178
- else if (h(t) && !t.ok) {
179
- a = !1;
180
- let i = typeof n.error == "function" ? await n.error(`HTTP error! status: ${t.status}`) : n.error, o = typeof n.description == "function" ? await n.description(`HTTP error! status: ${t.status}`) : n.description, s = typeof i == "object" && !e.isValidElement(i) ? i : { message: i };
181
- this.create({
182
- id: r,
183
- type: "error",
184
- description: o,
185
- ...s
186
- });
187
- } else if (t instanceof Error) {
188
- a = !1;
189
- let i = typeof n.error == "function" ? await n.error(t) : n.error, o = typeof n.description == "function" ? await n.description(t) : n.description, s = typeof i == "object" && !e.isValidElement(i) ? i : { message: i };
190
- this.create({
191
- id: r,
192
- type: "error",
193
- description: o,
194
- ...s
195
- });
196
- } else if (n.success !== void 0) {
197
- a = !1;
198
- let i = typeof n.success == "function" ? await n.success(t) : n.success, o = typeof n.description == "function" ? await n.description(t) : n.description, s = typeof i == "object" && !e.isValidElement(i) ? i : { message: i };
199
- this.create({
200
- id: r,
201
- type: "success",
202
- description: o,
203
- ...s
204
- });
205
- }
206
- }).catch(async (t) => {
207
- if (o = ["reject", t], n.error !== void 0) {
208
- a = !1;
209
- let i = typeof n.error == "function" ? await n.error(t) : n.error, o = typeof n.description == "function" ? await n.description(t) : n.description, s = typeof i == "object" && !e.isValidElement(i) ? i : { message: i };
210
- this.create({
211
- id: r,
212
- type: "error",
213
- description: o,
214
- ...s
215
- });
216
- }
217
- }).finally(() => {
218
- a && (this.dismiss(r), r = void 0), n.finally == null || n.finally.call(n);
219
- }), c = () => new Promise((e, t) => s.then(() => o[0] === "reject" ? t(o[1]) : e(o[1])).catch(t));
220
- return typeof r != "string" && typeof r != "number" ? { unwrap: c } : Object.assign(r, { unwrap: c });
221
- }, this.custom = (e, t) => {
222
- let n = f(t);
223
- return this.create({
224
- ...t,
225
- jsx: e(n),
226
- id: n,
227
- type: void 0
228
- }), n;
229
- }, this.getActiveToasts = () => this.toasts.filter((e) => !this.dismissedToasts.has(e.id)), this.subscribers = [], this.toasts = [], this.dismissedToasts = /* @__PURE__ */ new Set(), this.pendingDismissals = /* @__PURE__ */ new Map();
230
- }
231
- }(), m = (e, t) => p.message(e, t), h = (e) => e && typeof e == "object" && "ok" in e && typeof e.ok == "boolean" && "status" in e && typeof e.status == "number", g = Object.assign(m, {
232
- success: p.success,
233
- info: p.info,
234
- warning: p.warning,
235
- error: p.error,
236
- custom: p.custom,
237
- message: p.message,
238
- promise: p.promise,
239
- dismiss: p.dismiss,
240
- loading: p.loading
241
- }, {
242
- getHistory: () => p.toasts,
243
- getToasts: () => p.getActiveToasts()
244
- });
245
- function _(e) {
246
- return e.label !== void 0;
247
- }
248
- var v = 3, y = "24px", b = "16px", x = 4e3, te = 356, ne = 14, re = 45, ie = 200;
249
- function S(...e) {
250
- return e.filter(Boolean).join(" ");
251
- }
252
- function C(e) {
253
- let [t, n] = e.split("-"), r = [];
254
- return t && r.push(t), n && r.push(n), r;
255
- }
256
- var ae = (t) => {
257
- let { invert: r, toast: a, unstyled: o, interacting: s, setHeights: c, visibleToasts: u, heights: d, index: f, toasts: p, expanded: m, removeToast: h, defaultRichColors: g, closeButton: v, style: y, cancelButtonStyle: b, actionButtonStyle: te, className: ne = "", descriptionClassName: ae = "", duration: w, position: T, gap: E, expandByDefault: D, classNames: O, icons: k, closeButtonAriaLabel: oe = "Close toast" } = t, [A, j] = e.useState(null), [M, N] = e.useState(null), [P, F] = e.useState(!1), [I, L] = e.useState(!1), [R, z] = e.useState(!1), [B, se] = e.useState(!1), [ce, le] = e.useState(!1), [ue, V] = e.useState(0), [de, H] = e.useState(0), U = e.useRef(a.duration || w || x), fe = e.useRef(null), W = e.useRef(null), pe = f === 0, me = f + 1 <= u, G = a.type, he = G ?? "default", K = a.dismissible !== !1, ge = a.className || "", _e = a.descriptionClassName || "", q = e.useMemo(() => d.findIndex((e) => e.toastId === a.id) || 0, [d, a.id]), ve = e.useMemo(() => a.closeButton ?? v, [a.closeButton, v]), ye = e.useMemo(() => a.duration || w || x, [a.duration, w]), J = e.useRef(0), Y = e.useRef(0), be = e.useRef(0), X = e.useRef(null), [xe, Se] = T.split("-"), Ce = e.useMemo(() => d.reduce((e, t, n) => n >= q ? e : e + t.height, 0), [d, q]), we = l(), Z = e.useMemo(() => t.swipeDirections ?? C(T), [t.swipeDirections, T]), Te = a.invert || r, Q = G === "loading";
258
- Y.current = e.useMemo(() => q * E + Ce, [q, Ce]), e.useEffect(() => {
259
- U.current = ye;
260
- }, [ye]), e.useEffect(() => {
261
- F(!0);
262
- }, []), e.useEffect(() => {
263
- let e = W.current;
264
- if (e) {
265
- let t = e.getBoundingClientRect().height;
266
- return H(t), c((e) => [{
267
- toastId: a.id,
268
- height: t,
269
- position: a.position
270
- }, ...e]), () => c((e) => e.filter((e) => e.toastId !== a.id));
271
- }
272
- }, [c, a.id]), e.useLayoutEffect(() => {
273
- if (!P) return;
274
- let e = W.current, t = e.style.height;
275
- e.style.height = "auto";
276
- let n = e.getBoundingClientRect().height;
277
- e.style.height = t, H(n), c((e) => e.find((e) => e.toastId === a.id) ? e.map((e) => e.toastId === a.id ? {
278
- ...e,
279
- height: n
280
- } : e) : [{
281
- toastId: a.id,
282
- height: n,
283
- position: a.position
284
- }, ...e]);
285
- }, [
286
- P,
287
- a.title,
288
- a.description,
289
- c,
290
- a.id,
291
- a.jsx,
292
- a.action,
293
- a.cancel
294
- ]);
295
- let $ = e.useCallback(() => {
296
- L(!0), V(Y.current), c((e) => e.filter((e) => e.toastId !== a.id)), setTimeout(() => {
297
- h(a);
298
- }, ie);
299
- }, [
300
- a,
301
- h,
302
- c,
303
- Y
304
- ]);
305
- e.useEffect(() => {
306
- if (a.promise && G === "loading" || a.duration === Infinity || a.type === "loading") return;
307
- let e;
308
- return m || s || we ? (() => {
309
- if (be.current < J.current) {
310
- let e = (/* @__PURE__ */ new Date()).getTime() - J.current;
311
- U.current -= e;
312
- }
313
- be.current = (/* @__PURE__ */ new Date()).getTime();
314
- })() : U.current !== Infinity && (J.current = (/* @__PURE__ */ new Date()).getTime(), e = setTimeout(() => {
315
- a.onAutoClose == null || a.onAutoClose.call(a, a), $();
316
- }, U.current)), () => clearTimeout(e);
317
- }, [
318
- m,
319
- s,
320
- a,
321
- G,
322
- we,
323
- $
324
- ]), e.useEffect(() => {
325
- a.delete && ($(), a.onDismiss == null || a.onDismiss.call(a, a));
326
- }, [$, a.delete]);
327
- function Ee() {
328
- return k?.loading ? /*#__PURE__*/ e.createElement("div", {
329
- className: S(O?.loader, a?.classNames?.loader, "sonner-loader"),
330
- "data-visible": G === "loading"
331
- }, k.loading) : /*#__PURE__*/ e.createElement(i, {
332
- className: S(O?.loader, a?.classNames?.loader),
333
- visible: G === "loading"
334
- });
335
- }
336
- let De = a.icon || k?.[G] || n(G);
337
- return /*#__PURE__*/ e.createElement("li", {
338
- tabIndex: 0,
339
- ref: W,
340
- className: S(ne, ge, O?.toast, a?.classNames?.toast, O?.[he], a?.classNames?.[he]),
341
- "data-sonner-toast": "",
342
- "data-rich-colors": a.richColors ?? g,
343
- "data-styled": !(a.jsx || a.unstyled || o),
344
- "data-mounted": P,
345
- "data-promise": !!a.promise,
346
- "data-swiped": ce,
347
- "data-removed": I,
348
- "data-visible": me,
349
- "data-y-position": xe,
350
- "data-x-position": Se,
351
- "data-index": f,
352
- "data-front": pe,
353
- "data-swiping": R,
354
- "data-dismissible": K,
355
- "data-type": G,
356
- "data-invert": Te,
357
- "data-swipe-out": B,
358
- "data-swipe-direction": M,
359
- "data-expanded": !!(m || D && P),
360
- "data-testid": a.testId,
361
- style: {
362
- "--index": f,
363
- "--toasts-before": f,
364
- "--z-index": p.length - f,
365
- "--offset": `${I ? ue : Y.current}px`,
366
- "--initial-height": D ? "auto" : `${de}px`,
367
- ...y,
368
- ...a.style
369
- },
370
- onDragEnd: () => {
371
- z(!1), j(null), X.current = null;
372
- },
373
- onPointerDown: (e) => {
374
- e.button !== 2 && !Q && K && (fe.current = /* @__PURE__ */ new Date(), V(Y.current), e.target.setPointerCapture(e.pointerId), e.target.tagName !== "BUTTON" && (z(!0), X.current = {
375
- x: e.clientX,
376
- y: e.clientY
377
- }));
378
- },
379
- onPointerUp: () => {
380
- if (B || !K) return;
381
- X.current = null;
382
- let e = Number(W.current?.style.getPropertyValue("--swipe-amount-x").replace("px", "") || 0), t = Number(W.current?.style.getPropertyValue("--swipe-amount-y").replace("px", "") || 0), n = (/* @__PURE__ */ new Date()).getTime() - fe.current?.getTime(), r = A === "x" ? e : t, i = Math.abs(r) / n;
383
- if ((A === "x" ? Z.includes(e > 0 ? "right" : "left") : Z.includes(t > 0 ? "bottom" : "top")) && (Math.abs(r) >= re || i > .11)) V(Y.current), a.onDismiss == null || a.onDismiss.call(a, a), N(A === "x" ? e > 0 ? "right" : "left" : t > 0 ? "down" : "up"), $(), se(!0);
384
- else {
385
- var o, s;
386
- (o = W.current) == null || o.style.setProperty("--swipe-amount-x", "0px"), (s = W.current) == null || s.style.setProperty("--swipe-amount-y", "0px"), le(!1), z(!1), j(null);
387
- }
388
- },
389
- onPointerMove: (e) => {
390
- var t, n;
391
- if (!X.current || !K || window.getSelection()?.toString().length > 0) return;
392
- let r = e.clientY - X.current.y, i = e.clientX - X.current.x;
393
- !A && (Math.abs(i) > 1 || Math.abs(r) > 1) && j(Math.abs(i) > Math.abs(r) ? "x" : "y");
394
- let a = {
395
- x: 0,
396
- y: 0
397
- }, o = (e) => 1 / (1.5 + Math.abs(e) / 20);
398
- if (A === "y") {
399
- if (Z.includes("top") || Z.includes("bottom")) {
400
- if (Z.includes("top") && r < 0 || Z.includes("bottom") && r > 0) a.y = r;
401
- else {
402
- let e = r * o(r);
403
- a.y = Math.abs(e) < Math.abs(r) ? e : r;
404
- }
405
- }
406
- } else if (A === "x" && (Z.includes("left") || Z.includes("right"))) {
407
- if (Z.includes("left") && i < 0 || Z.includes("right") && i > 0) a.x = i;
408
- else {
409
- let e = i * o(i);
410
- a.x = Math.abs(e) < Math.abs(i) ? e : i;
411
- }
412
- }
413
- (Math.abs(a.x) > 0 || Math.abs(a.y) > 0) && le(!0), (t = W.current) == null || t.style.setProperty("--swipe-amount-x", `${a.x}px`), (n = W.current) == null || n.style.setProperty("--swipe-amount-y", `${a.y}px`);
414
- }
415
- }, ve && !a.jsx && G !== "loading" ? /*#__PURE__*/ e.createElement("button", {
416
- "aria-label": oe,
417
- "data-disabled": Q,
418
- "data-close-button": !0,
419
- onClick: Q || !K ? () => {} : () => {
420
- $(), a.onDismiss == null || a.onDismiss.call(a, a);
421
- },
422
- className: S(O?.closeButton, a?.classNames?.closeButton)
423
- }, k?.close ?? ee) : null, (G || a.icon || a.promise) && a.icon !== null && (k?.[G] !== null || a.icon) ? /*#__PURE__*/ e.createElement("div", {
424
- "data-icon": "",
425
- className: S(O?.icon, a?.classNames?.icon)
426
- }, G === "loading" ? a.icon || Ee() : a.promise ? Ee() : null, G === "loading" ? null : De) : null, /*#__PURE__*/ e.createElement("div", {
427
- "data-content": "",
428
- className: S(O?.content, a?.classNames?.content)
429
- }, /*#__PURE__*/ e.createElement("div", {
430
- "data-title": "",
431
- className: S(O?.title, a?.classNames?.title)
432
- }, a.jsx ? a.jsx : typeof a.title == "function" ? a.title() : a.title), a.description ? /*#__PURE__*/ e.createElement("div", {
433
- "data-description": "",
434
- className: S(ae, _e, O?.description, a?.classNames?.description)
435
- }, typeof a.description == "function" ? a.description() : a.description) : null), /*#__PURE__*/ e.isValidElement(a.cancel) ? a.cancel : a.cancel && _(a.cancel) ? /*#__PURE__*/ e.createElement("button", {
436
- "data-button": !0,
437
- "data-cancel": !0,
438
- style: a.cancelButtonStyle || b,
439
- onClick: (e) => {
440
- _(a.cancel) && K && (a.cancel.onClick == null || a.cancel.onClick.call(a.cancel, e), $());
441
- },
442
- className: S(O?.cancelButton, a?.classNames?.cancelButton)
443
- }, a.cancel.label) : null, /*#__PURE__*/ e.isValidElement(a.action) ? a.action : a.action && _(a.action) ? /*#__PURE__*/ e.createElement("button", {
444
- "data-button": !0,
445
- "data-action": !0,
446
- style: a.actionButtonStyle || te,
447
- onClick: (e) => {
448
- _(a.action) && (a.action.onClick == null || a.action.onClick.call(a.action, e), !e.defaultPrevented && $());
449
- },
450
- className: S(O?.actionButton, a?.classNames?.actionButton)
451
- }, a.action.label) : null);
452
- };
453
- function w() {
454
- if (typeof window > "u" || typeof document > "u") return "ltr";
455
- let e = document.documentElement.getAttribute("dir");
456
- return e === "auto" || !e ? window.getComputedStyle(document.documentElement).direction : e;
457
- }
458
- function T(e, t) {
459
- let n = {};
460
- return [e, t].forEach((e, t) => {
461
- let r = t === 1, i = r ? "--mobile-offset" : "--offset", a = r ? b : y;
462
- function o(e) {
463
- [
464
- "top",
465
- "right",
466
- "bottom",
467
- "left"
468
- ].forEach((t) => {
469
- n[`${i}-${t}`] = typeof e == "number" ? `${e}px` : e;
470
- });
471
- }
472
- typeof e == "number" || typeof e == "string" ? o(e) : typeof e == "object" ? [
473
- "top",
474
- "right",
475
- "bottom",
476
- "left"
477
- ].forEach((t) => {
478
- e[t] === void 0 ? n[`${i}-${t}`] = a : n[`${i}-${t}`] = typeof e[t] == "number" ? `${e[t]}px` : e[t];
479
- }) : o(a);
480
- }), n;
481
- }
482
- var E = /*#__PURE__*/ e.forwardRef(function(n, r) {
483
- let { id: i, invert: a, position: o = "bottom-right", hotkey: s = ["altKey", "KeyT"], expand: c, closeButton: ee, className: l, offset: u, mobileOffset: d, theme: f = "light", richColors: m, duration: h, style: g, visibleToasts: _ = v, toastOptions: y, dir: b = w(), gap: x = ne, icons: re, customAriaLabel: ie, containerAriaLabel: S = "Notifications" } = n, [C, E] = e.useState([]), D = e.useMemo(() => i ? C.filter((e) => e.toasterId === i) : C.filter((e) => !e.toasterId), [C, i]), O = e.useMemo(() => Array.from(new Set([o].concat(D.filter((e) => e.position).map((e) => e.position)))), [D, o]), [k, oe] = e.useState([]), [A, j] = e.useState(!1), [M, N] = e.useState(!1), [P, F] = e.useState(f === "system" ? typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : f), I = e.useRef(null), L = s.join("+").replace(/Key/g, "").replace(/Digit/g, ""), R = e.useRef(null), z = e.useRef(!1), B = e.useCallback((e) => {
484
- E((t) => (t.find((t) => t.id === e.id)?.delete || p.dismiss(e.id), t.filter(({ id: t }) => t !== e.id)));
485
- }, []);
486
- return e.useEffect(() => p.subscribe((e) => {
487
- e.dismiss ? requestAnimationFrame(() => {
488
- E((t) => t.map((t) => t.id === e.id ? {
489
- ...t,
490
- delete: !0
491
- } : t));
492
- }) : setTimeout(() => {
493
- t.flushSync(() => {
494
- E((t) => {
495
- let n = t.findIndex((t) => t.id === e.id);
496
- return n === -1 ? [e, ...t] : [
497
- ...t.slice(0, n),
498
- {
499
- ...t[n],
500
- ...e
501
- },
502
- ...t.slice(n + 1)
503
- ];
504
- });
505
- });
506
- });
507
- }), []), e.useEffect(() => {
508
- if (f !== "system") {
509
- F(f);
510
- return;
511
- }
512
- if (f === "system" && (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? F("dark") : F("light")), typeof window > "u") return;
513
- let e = window.matchMedia("(prefers-color-scheme: dark)");
514
- try {
515
- e.addEventListener("change", ({ matches: e }) => {
516
- F(e ? "dark" : "light");
517
- });
518
- } catch {
519
- e.addListener(({ matches: e }) => {
520
- try {
521
- F(e ? "dark" : "light");
522
- } catch (e) {
523
- console.error(e);
524
- }
525
- });
526
- }
527
- }, [f]), e.useEffect(() => {
528
- C.length <= 1 && j(!1);
529
- }, [C]), e.useEffect(() => {
530
- let e = (e) => {
531
- if (s.length > 0 && s.every((t) => e[t] || e.code === t)) {
532
- var t;
533
- j(!0), (t = I.current) == null || t.focus();
534
- }
535
- e.code === "Escape" && (document.activeElement === I.current || I.current?.contains(document.activeElement)) && j(!1);
536
- };
537
- return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
538
- }, [s]), e.useEffect(() => {
539
- if (I.current) return () => {
540
- R.current && (R.current.focus({ preventScroll: !0 }), R.current = null, z.current = !1);
541
- };
542
- }, [I.current]), /*#__PURE__*/ e.createElement("section", {
543
- ref: r,
544
- "aria-label": ie ?? `${S} ${L}`,
545
- tabIndex: -1,
546
- "aria-live": "polite",
547
- "aria-relevant": "additions text",
548
- "aria-atomic": "false",
549
- suppressHydrationWarning: !0,
550
- "data-react-aria-top-layer": !0
551
- }, O.map((t, r) => {
552
- let [i, o] = t.split("-");
553
- return D.length ? /*#__PURE__*/ e.createElement("ol", {
554
- key: t,
555
- dir: b === "auto" ? w() : b,
556
- tabIndex: -1,
557
- ref: I,
558
- className: l,
559
- "data-sonner-toaster": !0,
560
- "data-sonner-theme": P,
561
- "data-y-position": i,
562
- "data-x-position": o,
563
- style: {
564
- "--front-toast-height": `${k[0]?.height || 0}px`,
565
- "--width": `${te}px`,
566
- "--gap": `${x}px`,
567
- ...g,
568
- ...T(u, d)
569
- },
570
- onBlur: (e) => {
571
- z.current && !e.currentTarget.contains(e.relatedTarget) && (z.current = !1, R.current &&= (R.current.focus({ preventScroll: !0 }), null));
572
- },
573
- onFocus: (e) => {
574
- e.target instanceof HTMLElement && e.target.dataset.dismissible === "false" || z.current || (z.current = !0, R.current = e.relatedTarget);
575
- },
576
- onMouseEnter: () => j(!0),
577
- onMouseMove: () => j(!0),
578
- onMouseLeave: () => {
579
- M || j(!1);
580
- },
581
- onDragEnd: () => j(!1),
582
- onPointerDown: (e) => {
583
- e.target instanceof HTMLElement && e.target.dataset.dismissible === "false" || N(!0);
584
- },
585
- onPointerUp: () => N(!1)
586
- }, D.filter((e) => !e.position && r === 0 || e.position === t).map((r, i) => /*#__PURE__*/ e.createElement(ae, {
587
- key: r.id,
588
- icons: re,
589
- index: i,
590
- toast: r,
591
- defaultRichColors: m,
592
- duration: y?.duration ?? h,
593
- className: y?.className,
594
- descriptionClassName: y?.descriptionClassName,
595
- invert: a,
596
- visibleToasts: _,
597
- closeButton: y?.closeButton ?? ee,
598
- interacting: M,
599
- position: t,
600
- style: y?.style,
601
- unstyled: y?.unstyled,
602
- classNames: y?.classNames,
603
- cancelButtonStyle: y?.cancelButtonStyle,
604
- actionButtonStyle: y?.actionButtonStyle,
605
- closeButtonAriaLabel: y?.closeButtonAriaLabel,
606
- removeToast: B,
607
- toasts: D.filter((e) => e.position == r.position),
608
- heights: k.filter((e) => e.position == r.position),
609
- setHeights: oe,
610
- expandByDefault: c,
611
- gap: x,
612
- expanded: A,
613
- swipeDirections: n.swipeDirections
614
- }))) : null;
615
- }));
616
- });
617
- export { g as n, E as t };