@cloudlet/toast 1.0.0-rc.3 → 1.1.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 (72) hide show
  1. package/CHANGELOG.md +84 -16
  2. package/README.md +7 -5
  3. package/dist/contracts/controller.d.ts +7 -2
  4. package/dist/contracts/controller.d.ts.map +1 -1
  5. package/dist/contracts/events.d.ts +1 -1
  6. package/dist/contracts/events.d.ts.map +1 -1
  7. package/dist/contracts/internal.d.ts +23 -0
  8. package/dist/contracts/internal.d.ts.map +1 -1
  9. package/dist/contracts/notifications.d.ts +38 -6
  10. package/dist/contracts/notifications.d.ts.map +1 -1
  11. package/dist/contracts/snapshots.d.ts +3 -1
  12. package/dist/contracts/snapshots.d.ts.map +1 -1
  13. package/dist/core/bridge.d.ts +5 -0
  14. package/dist/core/bridge.d.ts.map +1 -0
  15. package/dist/core/bridge.js +345 -0
  16. package/dist/core/bridge.js.map +1 -0
  17. package/dist/core/controller.d.ts +122 -3
  18. package/dist/core/controller.d.ts.map +1 -1
  19. package/dist/core/controller.js +400 -541
  20. package/dist/core/controller.js.map +1 -1
  21. package/dist/core/validation.d.ts.map +1 -1
  22. package/dist/core/validation.js +181 -89
  23. package/dist/core/validation.js.map +1 -1
  24. package/dist/react/announcer.d.ts.map +1 -1
  25. package/dist/react/announcer.js +29 -23
  26. package/dist/react/announcer.js.map +1 -1
  27. package/dist/react/bindings.d.ts +9 -0
  28. package/dist/react/bindings.d.ts.map +1 -1
  29. package/dist/react/bindings.js +32 -69
  30. package/dist/react/bindings.js.map +1 -1
  31. package/dist/react/card.d.ts +5 -3
  32. package/dist/react/card.d.ts.map +1 -1
  33. package/dist/react/card.js +146 -34
  34. package/dist/react/card.js.map +1 -1
  35. package/dist/react/generators.d.ts +2 -2
  36. package/dist/react/generators.js.map +1 -1
  37. package/dist/react/gestures.js.map +1 -1
  38. package/dist/react/host.d.ts.map +1 -1
  39. package/dist/react/host.js +9 -5
  40. package/dist/react/host.js.map +1 -1
  41. package/dist/react/motion.d.ts +3 -3
  42. package/dist/react/motion.js.map +1 -1
  43. package/dist/react/plan.d.ts +1 -1
  44. package/dist/react/plan.d.ts.map +1 -1
  45. package/dist/react/plan.js +1 -0
  46. package/dist/react/plan.js.map +1 -1
  47. package/dist/react/renderer.d.ts +7 -0
  48. package/dist/react/renderer.d.ts.map +1 -0
  49. package/dist/react/renderer.js +62 -0
  50. package/dist/react/renderer.js.map +1 -0
  51. package/dist/react.d.ts +7 -5
  52. package/dist/react.d.ts.map +1 -1
  53. package/dist/styles.css +1 -1
  54. package/package.json +4 -2
  55. package/src/contracts/controller.ts +7 -2
  56. package/src/contracts/events.ts +2 -1
  57. package/src/contracts/internal.ts +20 -0
  58. package/src/contracts/notifications.ts +45 -6
  59. package/src/contracts/snapshots.ts +3 -0
  60. package/src/core/bridge.ts +336 -0
  61. package/src/core/controller.ts +118 -271
  62. package/src/core/validation.ts +49 -4
  63. package/src/react/announcer.ts +9 -0
  64. package/src/react/bindings.tsx +28 -72
  65. package/src/react/card.tsx +92 -9
  66. package/src/react/generators.ts +2 -2
  67. package/src/react/gestures.ts +1 -1
  68. package/src/react/host.tsx +22 -7
  69. package/src/react/motion.ts +4 -4
  70. package/src/react/plan.ts +4 -3
  71. package/src/react/renderer.tsx +77 -0
  72. package/src/react.ts +7 -5
@@ -1,84 +1,89 @@
1
- import { copyContent as e, patchContent as t, validDelay as n, validateContent as r, validateOptions as i, validatePatch as a, validateSpec as o, validateTrackOptions as s } from "./validation.js";
2
- //#region src/core/controller.ts
3
- var c = 600, l = Object.freeze, u = /* @__PURE__ */ new WeakSet(), ee = /* @__PURE__ */ new WeakMap(), d = 0, f = l([]), te = l({
1
+ import { copyContent as e, patchContent as t, validateContent as n, validateOptions as r, validatePatch as i, validateSpec as a, validateTrackOptions as o } from "./validation.js";
2
+ var s = Object.freeze, c = /* @__PURE__ */ new WeakSet(), l = /* @__PURE__ */ new WeakMap(), u = 0, d = s([]), f = s({
4
3
  open: !1,
5
4
  reason: null,
6
5
  current: null
7
- }), p = l({
6
+ }), p = s({
8
7
  controller: null,
9
8
  revision: 0,
10
9
  disposed: !1,
11
- notifications: f,
12
- stack: f,
13
- island: te,
14
- overflow: l({
10
+ notifications: d,
11
+ stack: d,
12
+ island: f,
13
+ overflow: s({
15
14
  count: 0,
16
15
  pending: !1
17
16
  })
18
- }), m = l({
17
+ }), m = s({
19
18
  ...p,
20
19
  presentation: null,
21
20
  focusRequest: null,
22
- announcements: l({
23
- notifications: f,
21
+ forms: d,
22
+ announcements: s({
23
+ notifications: d,
24
24
  overflowCount: 0
25
25
  })
26
- }), h = l({ status: "idle" }), g = l({ status: "applied" }), _ = l({ status: "unchanged" }), v = (e) => ({
26
+ }), h = s({ status: "idle" }), g = s({
27
+ form: null,
28
+ fields: s({})
29
+ }), _ = s({ status: "applied" }), v = s({ status: "unchanged" }), y = (e) => ({
27
30
  status: "rejected",
28
31
  reason: e
29
32
  });
30
- function y(e) {
31
- let t = ee.get(e);
33
+ function b(e) {
34
+ let t = l.get(e);
32
35
  if (!t) throw TypeError("Controller was not created by this Cloudlet package instance");
33
36
  return t;
34
37
  }
35
- function b(f, y) {
36
- let b = i(f);
37
- if (!y?.clock || typeof y.clock.now != "function" || typeof y.clock.schedule != "function") throw TypeError("Cloudlet requires a monotonic clock");
38
- let x = y.clock;
39
- if (typeof y.createCancellation != "function") throw TypeError("Cloudlet requires a cancellation source factory");
40
- let S = `cloudlet-${++d}`, C = /* @__PURE__ */ new Map(), w = /* @__PURE__ */ new Set(), T = /* @__PURE__ */ new Set(), E = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Set(), O = [], k = null, A = null, j = null, M = null, ne = 0, re = 0, ie = 0, ae = 0, N = null, P = null, F, I, L = null, R = null, oe = 0, z = 0, B = 0, V = !1, se = !1, ce = null, le = 0, ue, de, H = () => `${S}:${++ne}`, fe = () => [...C.values()].reverse(), pe = () => fe()[0] ?? null, me = (e) => {
38
+ function x(d, m) {
39
+ let b = r(d);
40
+ if (!m?.clock || typeof m.clock.now != "function" || typeof m.clock.schedule != "function") throw TypeError("Cloudlet requires a monotonic clock");
41
+ let x = m.clock;
42
+ if (typeof m.createCancellation != "function") throw TypeError("Cloudlet requires a cancellation source factory");
43
+ let S = `cloudlet-${++u}`, C = /* @__PURE__ */ new Map(), w = /* @__PURE__ */ new Set(), T = /* @__PURE__ */ new Set(), E = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Set(), O = [], k = null, A = null, j = null, M = null, N = 0, ee = 0, P = 0, te = 0, F = null, I = null, L, R, z = null, B = null, ne = 0, V = 0, H = 0, U = !1, re = !1, ie = null, ae = 0, oe, se, W = () => `${S}:${++N}`, ce = () => [...C.values()].reverse(), le = () => ce()[0] ?? null, ue = (e) => {
41
44
  let t = e.operation?.getSnapshot();
42
45
  return !!t?.canRetry && t.status !== "fulfilled";
43
- }, he = (e) => !!e.content.action || me(e) || e.content.attention === "open", ge = (e) => {
46
+ }, de = (e) => !!e.content.action || ue(e) || e.content.attention === "open", fe = (e) => {
44
47
  let t = e.content.attention ?? "auto";
45
- return t === "open" || t === "auto" && (he(e) || !!e.content.description);
46
- }, _e = () => D.has("hover") || D.has("focus") || [...C.values()].some((e) => e.pauses.has("gesture")), ve = (e) => {
47
- let t = e === P;
48
+ return t === "open" || t === "auto" && (de(e) || !!e.content.description);
49
+ }, pe = (e) => {
50
+ let t = e.content.action;
51
+ return t?.kind === "form" ? (e.form?.action !== t && (e.form = {
52
+ action: t,
53
+ errors: g,
54
+ values: s(Object.fromEntries(t.fields.map((e) => [e.name, e.defaultValue ?? ""])))
55
+ }), e.form) : e.form = null;
56
+ }, me = (e) => {
57
+ let t = pe(e);
58
+ return !!t && t.action.fields.some((e) => t.values[e.name] !== (e.defaultValue ?? ""));
59
+ }, he = () => D.has("hover") || D.has("focus") || [...C.values()].some((e) => e.pauses.has("gesture")) || !!F && me(F.current), ge = (e) => {
60
+ let t = e === I;
48
61
  return [
49
62
  ...t ? [] : ["inactive"],
50
63
  ...j === null ? ["no-host"] : [],
51
64
  ...t && !e.readable ? ["presentation-pending"] : [],
52
- ...t && N && (N.reason === "user" || he(e)) ? ["island"] : [],
65
+ ...t && F && (F.reason === "user" || de(e)) ? ["island"] : [],
53
66
  ...e.action.status === "pending" ? ["action-pending"] : [],
67
+ ...me(e) ? ["draft"] : [],
54
68
  ...D,
55
69
  ...e.pauses
56
70
  ];
57
- }, U = (e) => {
58
- if (V) return "disposed";
59
- if (typeof e != "object" || !e || !u.has(e)) return "invalid-handle";
71
+ }, _e = (e) => {
72
+ if (U) return "disposed";
73
+ if (typeof e != "object" || !e || !c.has(e)) return "invalid-handle";
60
74
  if (e.controller !== S) return "foreign-controller";
61
75
  if (C.get(e.id)?.handle !== e) return "stale-handle";
62
- }, ye = (e) => V ? "disposed" : j === null || e !== j ? "stale-lease" : void 0, be = (e) => U(e) ?? (C.get(e.id) === P ? void 0 : "not-current");
63
- function W(e) {
76
+ };
77
+ function ve(e) {
64
78
  return (t, ...n) => {
65
- let r = U(t);
66
- return r ? v(r) : e(C.get(t.id), ...n);
79
+ let r = _e(t);
80
+ return r ? y(r) : e(C.get(t.id), ...n);
67
81
  };
68
82
  }
69
- function xe(e) {
70
- return W((t, ...n) => t === P ? e(t, ...n) : v("not-current"));
71
- }
72
- function Se(e) {
73
- return W((t, n, ...r) => {
74
- let i = t.operation;
75
- return i ? i.getSnapshot().token === n ? e(i, ...r) : v("stale-operation-token") : v("no-operation");
76
- });
77
- }
78
83
  function G(e) {
79
84
  q([{
80
85
  type: "diagnostic",
81
- diagnostic: l({ ...e })
86
+ diagnostic: s({ ...e })
82
87
  }]);
83
88
  }
84
89
  function K(e, t, n, r) {
@@ -90,7 +95,7 @@ function b(f, y) {
90
95
  ...r ? { handle: r } : {}
91
96
  });
92
97
  }
93
- function Ce(e, t) {
98
+ function ye(e, t) {
94
99
  for (let n of [...e]) if (e.has(n)) try {
95
100
  n();
96
101
  } catch (e) {
@@ -99,7 +104,7 @@ function b(f, y) {
99
104
  }
100
105
  function q(e, t = !1, n = x.now(), r = !1, i = !1) {
101
106
  if (O.push(() => {
102
- t && Ce(w, "subscribe");
107
+ t && ye(w, "subscribe");
103
108
  for (let t of e) {
104
109
  if ("callback" in t) {
105
110
  try {
@@ -109,10 +114,10 @@ function b(f, y) {
109
114
  }
110
115
  continue;
111
116
  }
112
- let e = l({
117
+ let e = s({
113
118
  ...t,
114
119
  controller: S,
115
- sequence: ++ae,
120
+ sequence: ++te,
116
121
  at: i ? x.now() : n
117
122
  });
118
123
  for (let t of [...T]) if (T.has(t)) try {
@@ -129,13 +134,13 @@ function b(f, y) {
129
134
  for (let e of E.keys()) e.clear();
130
135
  E.clear();
131
136
  }
132
- }), !se) {
133
- se = !0;
137
+ }), !re) {
138
+ re = !0;
134
139
  try {
135
140
  let e;
136
141
  for (; e = O.shift();) e();
137
142
  } finally {
138
- se = !1;
143
+ re = !1;
139
144
  }
140
145
  }
141
146
  }
@@ -144,132 +149,141 @@ function b(f, y) {
144
149
  for (let t of C.values()) t.activeSince !== null && t.remaining !== null && (t.remaining = Math.max(0, t.remaining - Math.max(0, e - t.activeSince)), t.activeSince = e);
145
150
  return e;
146
151
  }
147
- function we() {
148
- ++le, ce?.(), ce = null;
152
+ function be() {
153
+ ++ae, ie?.(), ie = null;
149
154
  }
150
- function Te(e) {
151
- we();
155
+ function xe(e) {
156
+ be();
152
157
  let t = Infinity;
153
158
  for (let n of C.values()) {
154
- let r = n.remaining !== null && ve(n).length === 0 && !V;
159
+ let r = n.remaining !== null && ge(n).length === 0 && !U;
155
160
  n.activeSince = r ? e : null, r && (t = Math.min(t, e + n.remaining));
156
161
  }
157
162
  if (!Number.isFinite(t)) return;
158
- let n = le;
159
- ce = x.schedule(t, () => {
160
- if (V || n !== le) return;
163
+ let n = ae;
164
+ ie = x.schedule(t, () => {
165
+ if (U || n !== ae) return;
161
166
  let e = J(), t = [...C.values()].filter((e) => e.activeSince !== null && e.remaining === 0), r = [];
162
- for (let e of t) Pe(e, "timeout", r);
163
- t.length ? Y(r, e) : Te(e);
167
+ for (let e of t) $(e, "timeout", r);
168
+ t.length ? Y(r, e) : xe(e);
164
169
  });
165
170
  }
166
- function Ee() {
167
- let e = [...C.values()], t = l(e.map((e) => l({
171
+ function Se() {
172
+ let e = [...C.values()], t = s(e.map((e) => s({
168
173
  handle: e.handle,
169
174
  kind: e.kind,
170
175
  content: e.content,
171
176
  priority: e.priority,
172
177
  occurrences: e.occurrences,
173
- location: e === P ? "current" : "stack",
178
+ location: e === I ? "current" : "stack",
174
179
  remainingMs: e.remaining,
175
- pauseReasons: l(ve(e)),
180
+ pauseReasons: s(ge(e)),
176
181
  operation: e.operation?.getSnapshot() ?? null,
177
- action: e.action
182
+ action: e.action,
183
+ draft: me(e)
178
184
  })));
179
- ue = l({
185
+ oe = s({
180
186
  controller: S,
181
- revision: ie,
182
- disposed: V,
187
+ revision: P,
188
+ disposed: U,
183
189
  notifications: t,
184
- stack: l(fe().map((e) => e.handle)),
185
- island: N ? l({
190
+ stack: s(ce().map((e) => e.handle)),
191
+ island: F ? s({
186
192
  open: !0,
187
- reason: N.reason,
188
- current: N.current.handle
189
- }) : te,
190
- overflow: l({
191
- count: z,
192
- pending: z > 0
193
+ reason: F.reason,
194
+ current: F.current.handle
195
+ }) : f,
196
+ overflow: s({
197
+ count: V,
198
+ pending: V > 0
193
199
  })
194
- }), de = l({
195
- ...ue,
196
- presentation: P ? l({
197
- handle: P.handle,
198
- token: P.presentation,
199
- readable: P.readable
200
+ }), se = s({
201
+ ...oe,
202
+ presentation: I ? s({
203
+ handle: I.handle,
204
+ token: I.presentation,
205
+ readable: I.readable
200
206
  }) : null,
201
207
  focusRequest: A,
202
- announcements: l({
203
- overflowCount: B,
204
- notifications: l(e.map((e) => l({
208
+ forms: s(e.flatMap((e) => {
209
+ let t = pe(e);
210
+ return t ? [s({
211
+ handle: e.handle,
212
+ values: t.values,
213
+ errors: t.errors
214
+ })] : [];
215
+ })),
216
+ announcements: s({
217
+ overflowCount: H,
218
+ notifications: s(e.map((e) => s({
205
219
  handle: e.handle,
206
220
  queued: e.queuedAnnounced,
207
221
  firstPresentation: e.firstAnnounced,
208
222
  occurrences: e.occurrencesAnnounced,
209
223
  action: e.actionAnnounced ?? null,
210
- operation: e.operation ? l({
224
+ operation: e.operation ? s({
211
225
  token: e.operation.getSnapshot().token,
212
- phases: l([...e.operationAnnounced])
226
+ phases: s([...e.operationAnnounced])
213
227
  }) : null
214
228
  })))
215
229
  })
216
230
  });
217
231
  }
218
232
  function Y(e = [], t = x.now(), n = !1) {
219
- ke(), Te(t), Me(t), ++ie, Ee(), q(e, !0, t, n);
233
+ Te(), xe(t), Oe(t), ++P, Se(), q(e, !0, t, n);
220
234
  }
221
235
  function X(e, t = !1) {
222
236
  let n = J(), r = [];
223
- return e(r), Y(r, n, t), g;
237
+ return e(r), Y(r, n, t), _;
224
238
  }
225
- function De(e) {
226
- e.readable = !1, e.presentation = j === null ? null : H();
239
+ function Ce(e) {
240
+ e.readable = !1, e.presentation = j === null ? null : W();
227
241
  }
228
- function Oe(e) {
242
+ function we(e) {
229
243
  e.presentation = null, e.readable = !1, e.pauses.clear(), k === e.handle && (k = null), A?.target.kind === "notification" && A.target.handle === e.handle && (A = null);
230
244
  }
231
- function ke() {
232
- let e = N ? N.current : pe();
233
- e !== P && (P && Oe(P), P = e, e && De(e));
245
+ function Te() {
246
+ let e = F ? F.current : le();
247
+ e !== I && (I && we(I), I = e, e && Ce(e));
234
248
  }
235
- function Ae() {
236
- ++oe, R?.(), R = null;
249
+ function Ee() {
250
+ ++ne, B?.(), B = null;
237
251
  }
238
- function je(e, t) {
239
- ge(e) && (L = {
252
+ function De(e, t) {
253
+ fe(e) && (z = {
240
254
  record: e,
241
- due: t + (F ?? b.attentionDelay ?? c),
255
+ due: t + (L ?? b.attentionDelay ?? 600),
242
256
  waiting: !1
243
257
  });
244
258
  }
245
- function Me(e) {
246
- Ae();
247
- let t = L;
248
- if (!t || V) return;
259
+ function Oe(e) {
260
+ Ee();
261
+ let t = z;
262
+ if (!t || U) return;
249
263
  if (j === null) {
250
264
  t.waiting = !0;
251
265
  return;
252
266
  }
253
267
  if (t.waiting) {
254
- if (_e()) return;
255
- t.waiting = !1, t.due = e + (F ?? b.attentionDelay ?? c);
268
+ if (he()) return;
269
+ t.waiting = !1, t.due = e + (L ?? b.attentionDelay ?? 600);
256
270
  }
257
- let n = oe;
258
- R = x.schedule(t.due, () => {
259
- if (V || n !== oe || L !== t) return;
271
+ let n = ne;
272
+ B = x.schedule(t.due, () => {
273
+ if (U || n !== ne || z !== t) return;
260
274
  let e = x.now();
261
275
  if (e < t.due) {
262
- Me(e);
276
+ Oe(e);
263
277
  return;
264
278
  }
265
- if (R = null, _e()) {
279
+ if (B = null, he()) {
266
280
  t.waiting = !0;
267
281
  return;
268
282
  }
269
- L = null;
283
+ z = null;
270
284
  let r = t.record;
271
- ge(r) && N?.current !== r && X(() => {
272
- N ? N.current = r : N = {
285
+ fe(r) && F?.current !== r && X(() => {
286
+ F ? F.current = r : F = {
273
287
  reason: "attention",
274
288
  current: r
275
289
  };
@@ -277,24 +291,24 @@ function b(f, y) {
277
291
  });
278
292
  }
279
293
  let Z = (e) => (e ?? b.autoDismiss) !== !1;
280
- function Ne(e) {
281
- let t = Z(e) !== Z(I);
282
- if (I = e, t) for (let e of C.values()) e.remaining = Q(e);
294
+ function ke(e) {
295
+ let t = Z(e) !== Z(R);
296
+ if (R = e, t) for (let e of C.values()) e.remaining = Q(e);
283
297
  }
284
298
  function Q(e) {
285
- return Z(I) ? e.content.duration === void 0 ? (e.kind === "info" || e.kind === "success") && !e.content.action ? 6e3 : null : e.content.duration : null;
299
+ return Z(R) ? e.content.duration === void 0 ? (e.kind === "info" || e.kind === "success") && !e.content.action ? 6e3 : null : e.content.duration : null;
286
300
  }
287
- function Pe(e, t, n) {
288
- if (N?.current === e) {
289
- let t = fe(), n = t.indexOf(e), r = t[n + 1] ?? t[n - 1];
290
- r ? N.current = r : N = null;
301
+ function $(e, t, n) {
302
+ if (F?.current === e) {
303
+ let t = ce(), n = t.indexOf(e), r = t[n + 1] ?? t[n - 1];
304
+ r ? F.current = r : F = null;
291
305
  }
292
- if (L?.record === e && (L = null), C.delete(e.handle.id), e.operation && n.push(e.operation.detach()), n.push({
306
+ if (z?.record === e && (z = null), C.delete(e.handle.id), e.operation && n.push(e.operation.detach()), n.push({
293
307
  type: "closed",
294
308
  handle: e.handle,
295
309
  reason: t
296
310
  }), e.onClose) {
297
- let r = e.onClose, i = l({
311
+ let r = e.onClose, i = s({
298
312
  handle: e.handle,
299
313
  reason: t
300
314
  });
@@ -305,35 +319,35 @@ function b(f, y) {
305
319
  });
306
320
  }
307
321
  }
308
- let Fe = W((e, t) => X((n) => Pe(e, t, n)));
309
- function Ie() {
310
- return V ? v("disposed") : z ? X((e) => {
322
+ let Ae = ve((e, t) => X((n) => $(e, t, n)));
323
+ function je() {
324
+ return U ? y("disposed") : V ? X((e) => {
311
325
  e.push({
312
326
  type: "overflow-acknowledged",
313
- count: z
314
- }), z = B = 0, A?.target.kind === "overflow" && (A = null);
315
- }) : _;
327
+ count: V
328
+ }), V = H = 0, A?.target.kind === "overflow" && (A = null);
329
+ }) : v;
316
330
  }
317
- function Le(e, t) {
331
+ function Me(e, t) {
318
332
  if (typeof t != "function") throw TypeError("Listener must be a function");
319
- return V ? () => {} : (e.add(t), () => {
333
+ return U ? () => {} : (e.add(t), () => {
320
334
  e.delete(t);
321
335
  });
322
336
  }
323
- function Re(e) {
324
- if (V) return v("disposed");
325
- let t = o(e);
337
+ function Ne(e) {
338
+ if (U) return y("disposed");
339
+ let t = a(e);
326
340
  return t.length ? (G({
327
341
  code: "invalid-input",
328
342
  source: "show",
329
343
  message: "Invalid notification specification"
330
344
  }), {
331
- ...v("invalid-input"),
345
+ ...y("invalid-input"),
332
346
  issues: t
333
- }) : ze(e);
347
+ }) : Pe(e);
334
348
  }
335
- function ze(t, n) {
336
- if (t.id !== void 0 && C.has(t.id)) return v("id-conflict");
349
+ function Pe(t, n) {
350
+ if (t.id !== void 0 && C.has(t.id)) return y("id-conflict");
337
351
  let r = t.dedupeKey === void 0 ? void 0 : [...C.values()].find((e) => e.dedupeKey === t.dedupeKey);
338
352
  if (r) {
339
353
  let e = r.occurrences;
@@ -350,30 +364,30 @@ function b(f, y) {
350
364
  };
351
365
  }
352
366
  if (C.size >= 100) return X((e) => {
353
- z = Math.min(2 ** 53 - 1, z + 1);
354
- let t = l({
355
- count: z,
367
+ V = Math.min(2 ** 53 - 1, V + 1);
368
+ let t = s({
369
+ count: V,
356
370
  pending: !0
357
371
  });
358
372
  e.push({
359
373
  type: "overflow",
360
- count: z
374
+ count: V
361
375
  }), b.onOverflow && e.push({
362
376
  callback: () => b.onOverflow(t),
363
377
  source: "onOverflow"
364
378
  });
365
- }), v("capacity");
379
+ }), y("capacity");
366
380
  let i = J(), a = t.id;
367
381
  if (a === void 0) do
368
- a = `${S}:notification-${++re}`;
382
+ a = `${S}:notification-${++ee}`;
369
383
  while (C.has(a));
370
- let o = l({
384
+ let o = s({
371
385
  id: a,
372
386
  controller: S,
373
- generation: H()
387
+ generation: W()
374
388
  });
375
- u.add(o);
376
- let s = {
389
+ c.add(o);
390
+ let l = {
377
391
  handle: o,
378
392
  dedupeKey: t.dedupeKey,
379
393
  onClose: t.onClose,
@@ -392,52 +406,53 @@ function b(f, y) {
392
406
  occurrencesAnnounced: 0,
393
407
  operation: null,
394
408
  operationAnnounced: /* @__PURE__ */ new Set(),
395
- action: h
409
+ action: h,
410
+ form: null
396
411
  };
397
- s.remaining = Q(s), C.set(a, s), n?.(s), je(s, i);
398
- let c = [{
412
+ l.remaining = Q(l), C.set(a, l), n?.(l), De(l, i);
413
+ let u = [{
399
414
  type: "admitted",
400
415
  handle: o
401
416
  }];
402
- if (s.operation) {
403
- let e = s.operation.getSnapshot();
404
- c.push({
417
+ if (l.operation) {
418
+ let e = l.operation.getSnapshot();
419
+ u.push({
405
420
  type: "operation-started",
406
421
  handle: o,
407
422
  token: e.token,
408
423
  attempt: e.attempt
409
424
  });
410
425
  }
411
- return Y(c, i), {
426
+ return Y(u, i), {
412
427
  status: "created",
413
428
  handle: o
414
429
  };
415
430
  }
416
- function Be(e) {
417
- V || q(e);
431
+ function Fe(e) {
432
+ U || q(e);
418
433
  }
419
- function Ve(e, t, n) {
420
- e.content = t, e.kind = n, e.remaining = n === "loading" ? null : Q(e), e.action = h, e === P && De(e), je(e, x.now()), A?.target.kind === "notification" && A.target.handle === e.handle && A.target.control === "action" && !t.action && (A = null);
434
+ function Ie(e, t, n) {
435
+ e.content = t, e.kind = n, e.remaining = n === "loading" ? null : Q(e), e.action = h, e === I && Ce(e), De(e, x.now()), A?.target.kind === "notification" && A.target.handle === e.handle && A.target.control === "action" && !t.action && (A = null);
421
436
  }
422
- function He(n, i) {
423
- let a = typeof n == "function" ? n : null, o;
424
- if (!a && (typeof n != "object" || !n || typeof (o = n.then) != "function")) throw TypeError("Operation source must be a factory or thenable");
425
- let c = s(i, a !== null), u = (e) => i && typeof i == "object" ? Object.getOwnPropertyDescriptor(i, e)?.value : void 0, ee = u("cancel"), d = !a && typeof ee == "function" ? ee : null, f = u("isCancellation"), te = typeof f == "function" ? f : null, p = c.length ? null : l({
437
+ function Le(r, i) {
438
+ let a = typeof r == "function" ? r : null, c;
439
+ if (!a && (typeof r != "object" || !r || typeof (c = r.then) != "function")) throw TypeError("Operation source must be a factory or thenable");
440
+ let l = o(i, a !== null), u = (e) => i && typeof i == "object" ? Object.getOwnPropertyDescriptor(i, e)?.value : void 0, d = u("cancel"), f = !a && typeof d == "function" ? d : null, p = u("isCancellation"), h = typeof p == "function" ? p : null, g = l.length ? null : s({
426
441
  ...i,
427
442
  pending: e(i.pending),
428
443
  success: typeof i.success == "function" ? i.success : e(i.success),
429
444
  error: typeof i.error == "function" ? i.error : e(i.error),
430
445
  ...i.cancelled === void 0 ? {} : { cancelled: typeof i.cancelled == "function" ? i.cancelled : e(i.cancelled) }
431
- }), m = /* @__PURE__ */ new Set(), h = null, g = !1, _, x = 0;
432
- function S() {
433
- let e = y.createCancellation(), t = l({
446
+ }), _ = /* @__PURE__ */ new Set(), v = null, x = !1, S, w = 0;
447
+ function T() {
448
+ let e = m.createCancellation(), t = s({
434
449
  signal: e.signal,
435
- token: H(),
436
- attempt: ++x
450
+ token: W(),
451
+ attempt: ++w
437
452
  }), n, r, i = new Promise((e, t) => {
438
453
  n = e, r = t;
439
454
  }), a = {
440
- public: l({
455
+ public: s({
441
456
  token: t.token,
442
457
  attempt: t.attempt,
443
458
  result: i
@@ -449,506 +464,350 @@ function b(f, y) {
449
464
  status: "pending",
450
465
  cancelRequested: !1
451
466
  };
452
- return i.then((e) => M(a, "fulfilled", e), (e) => M(a, "rejected", e)).catch((e) => {
453
- V || K("callback-error", "operation-settlement", e);
467
+ return i.then((e) => ee(a, "fulfilled", e), (e) => ee(a, "rejected", e)).catch((e) => {
468
+ U || K("callback-error", "operation-settlement", e);
454
469
  }), a;
455
470
  }
456
- let w = S(), T = w;
457
- function D() {
471
+ let D = T(), O = D;
472
+ function k() {
458
473
  let e = {
459
- token: T.context.token,
460
- attempt: T.context.attempt,
461
- status: T.status,
462
- cancelRequested: T.cancelRequested,
463
- canCancel: !V && T.status === "pending" && !T.cancelRequested && (!!a || !!d),
464
- canRetry: !V && !!a && T.status !== "pending",
465
- notification: g && !V ? h : null
474
+ token: O.context.token,
475
+ attempt: O.context.attempt,
476
+ status: O.status,
477
+ cancelRequested: O.cancelRequested,
478
+ canCancel: !U && O.status === "pending" && !O.cancelRequested && (!!a || !!f),
479
+ canRetry: !U && !!a && O.status !== "pending",
480
+ notification: x && !U ? v : null
466
481
  };
467
- return (!_ || Object.keys(e).some((t) => e[t] !== _[t])) && (_ = l(e)), _;
482
+ return (!S || Object.keys(e).some((t) => e[t] !== S[t])) && (S = s(e)), S;
468
483
  }
469
- let O = {
484
+ let A = {
470
485
  source: "operation.subscribe",
471
- callback: () => Ce(m, "operation.subscribe")
486
+ callback: () => ye(_, "operation.subscribe")
472
487
  };
473
- function k(e) {
474
- if (V || T !== e || !g || !h) return;
475
- let t = C.get(h.id);
476
- return t?.handle === h && t.operation === N ? t : void 0;
488
+ function j(e) {
489
+ if (U || O !== e || !x || !v) return;
490
+ let t = C.get(v.id);
491
+ return t?.handle === v && t.operation === L ? t : void 0;
477
492
  }
478
- function A(e) {
493
+ function M(e) {
479
494
  try {
480
- e.resolve(a ? a(e.context) : { then: o.bind(n) });
495
+ e.resolve(a ? a(e.context) : { then: c.bind(r) });
481
496
  } catch (t) {
482
497
  e.reject(t);
483
498
  }
484
499
  }
485
- function j(e, t) {
500
+ function N(e, t) {
486
501
  if (t) {
487
502
  let n = J();
488
503
  t(), Y(e, n);
489
- } else Be(e);
504
+ } else Fe(e);
490
505
  }
491
- function M(t, n, i) {
492
- if (t.status = n, n === "rejected") try {
493
- (te ? te(i, t.context) === !0 : t.cancelRequested && typeof i == "object" && i && "name" in i && i.name === "AbortError") && (t.status = "cancelled");
506
+ function ee(t, r, i) {
507
+ if (t.status = r, r === "rejected") try {
508
+ (h ? h(i, t.context) === !0 : t.cancelRequested && typeof i == "object" && i && "name" in i && i.name === "AbortError") && (t.status = "cancelled");
494
509
  } catch (e) {
495
- V || K("cancellation-error", "isCancellation", e);
510
+ U || K("cancellation-error", "isCancellation", e);
496
511
  }
497
512
  let a;
498
- if (k(t) && p) {
499
- let n = t.status, o = n === "fulfilled" ? b.messages?.operationSuccess ?? "Completed" : n === "cancelled" ? b.messages?.operationCancelled ?? "Cancelled" : b.messages?.operationError ?? "Something went wrong";
513
+ if (j(t) && g) {
514
+ let r = t.status, o = r === "fulfilled" ? b.messages?.operationSuccess ?? "Completed" : r === "cancelled" ? b.messages?.operationCancelled ?? "Cancelled" : b.messages?.operationError ?? "Something went wrong";
500
515
  try {
501
- let t = n === "fulfilled" ? p.success : n === "cancelled" ? p.cancelled : p.error, s = typeof t == "function" ? t(i) : t ?? { title: o };
502
- if (r(s).length) throw TypeError("Invalid terminal notification content");
516
+ let t = r === "fulfilled" ? g.success : r === "cancelled" ? g.cancelled : g.error, s = typeof t == "function" ? t(i) : t ?? { title: o };
517
+ if (n(s).length) throw TypeError("Invalid terminal notification content");
503
518
  a = e(s);
504
519
  } catch (e) {
505
- a = l({
520
+ a = s({
506
521
  title: o,
507
522
  announcementPriority: "polite"
508
- }), V || K("mapper-error", `track.${n}`, e, h ?? void 0);
523
+ }), U || K("mapper-error", `track.${r}`, e, v ?? void 0);
509
524
  }
510
525
  }
511
- let o = k(t), s = !!o && !!a;
512
- j([...T === t ? [O] : [], {
526
+ let o = j(t), c = !!o && !!a;
527
+ N([...O === t ? [A] : [], {
513
528
  type: "operation-settled",
514
- handle: h,
529
+ handle: v,
515
530
  token: t.context.token,
516
531
  status: t.status,
517
- uiApplied: s
518
- }], o && a ? () => Ve(o, a, t.status === "fulfilled" ? "success" : t.status === "cancelled" ? "warning" : "error") : void 0);
532
+ uiApplied: c
533
+ }], o && a ? () => Ie(o, a, t.status === "fulfilled" ? "success" : t.status === "cancelled" ? "warning" : "error") : void 0);
519
534
  }
520
- function ne(e, n) {
535
+ function P(e, n) {
521
536
  e.cancelRequested = !0;
522
- let r = k(e);
523
- j([O, {
537
+ let r = j(e);
538
+ N([A, {
524
539
  type: "cancellation-requested",
525
- handle: h,
540
+ handle: v,
526
541
  token: e.context.token
527
542
  }], r ? () => {
528
543
  r.content = t(r.content, { title: b.messages?.cancellationRequested ?? "Cancellation requested" });
529
544
  } : void 0);
530
545
  try {
531
- e.abort(n), d?.(n);
546
+ e.abort(n), f?.(n);
532
547
  } catch (e) {
533
- V || K("cancellation-error", "cancel", e, h ?? void 0);
548
+ U || K("cancellation-error", "cancel", e, v ?? void 0);
534
549
  }
535
550
  }
536
- function re() {
551
+ function te() {
537
552
  let e = /* @__PURE__ */ Error("Cancellation requested");
538
553
  return e.name = "AbortError", e;
539
554
  }
540
- function ie(e = re()) {
541
- return V ? v("disposed") : T.status === "pending" ? !a && !d ? v("not-cancellable") : T.cancelRequested ? {
555
+ function F(e = te()) {
556
+ return U ? y("disposed") : O.status === "pending" ? !a && !f ? y("not-cancellable") : O.cancelRequested ? {
542
557
  status: "unchanged",
543
558
  reason: "already-requested"
544
- } : (ne(T, e), { status: "requested" }) : {
559
+ } : (P(O, e), { status: "requested" }) : {
545
560
  status: "unchanged",
546
561
  reason: "settled"
547
562
  };
548
563
  }
549
- function ae(e) {
550
- if (V) return v("disposed");
551
- if (!a) return v("not-retryable");
552
- if (T.status === "pending" && !e) return v("already-pending");
553
- let t = T, n = S();
554
- T = n;
555
- let r = k(n);
556
- return j([O, {
564
+ function I(e) {
565
+ if (U) return y("disposed");
566
+ if (!a) return y("not-retryable");
567
+ if (O.status === "pending" && !e) return y("already-pending");
568
+ let t = O, n = T();
569
+ O = n;
570
+ let r = j(n);
571
+ return N([A, {
557
572
  type: "operation-started",
558
- handle: h,
573
+ handle: v,
559
574
  token: n.context.token,
560
575
  attempt: n.context.attempt
561
- }], r && p ? () => {
562
- r.operationAnnounced.clear(), Ve(r, p.pending, "loading");
563
- } : void 0), t.status === "pending" && !t.cancelRequested && ne(t, re()), A(n), {
576
+ }], r && g ? () => {
577
+ r.operationAnnounced.clear(), Ie(r, g.pending, "loading");
578
+ } : void 0), t.status === "pending" && !t.cancelRequested && P(t, te()), M(n), {
564
579
  status: "started",
565
580
  attempt: n.public
566
581
  };
567
582
  }
568
- let N = {
569
- getSnapshot: D,
570
- retry: () => ae(!1),
571
- cancel: ie,
572
- detach: () => (g = !1, O)
573
- }, P;
574
- if (V) P = v("disposed");
575
- else if (!p) P = {
576
- ...v("invalid-input"),
577
- issues: c
583
+ let L = {
584
+ getSnapshot: k,
585
+ retry: () => I(!1),
586
+ cancel: F,
587
+ detach: () => (x = !1, A)
588
+ }, R;
589
+ if (U) R = y("disposed");
590
+ else if (!g) R = {
591
+ ...y("invalid-input"),
592
+ issues: l
578
593
  }, G({
579
594
  code: "invalid-input",
580
595
  source: "track",
581
596
  message: "Invalid operation options"
582
597
  });
583
598
  else {
584
- let e = ze({
585
- ...p.pending,
586
- ...p,
599
+ let e = Pe({
600
+ ...g.pending,
601
+ ...g,
587
602
  kind: "loading"
588
603
  }, (e) => {
589
- h = e.handle, g = !0, e.operation = N;
604
+ v = e.handle, x = !0, e.operation = L;
590
605
  });
591
606
  if (e.status === "deduplicated") throw Error("Tracked operation cannot be deduplicated");
592
- P = e;
607
+ R = e;
593
608
  }
594
- return P.status === "rejected" && Be([{
609
+ return R.status === "rejected" && Fe([{
595
610
  type: "operation-started",
596
611
  handle: null,
597
- token: w.context.token,
612
+ token: D.context.token,
598
613
  attempt: 1
599
- }]), A(w), l({
600
- ...w.public,
601
- admission: l(P),
602
- getSnapshot: D,
614
+ }]), M(D), s({
615
+ ...D.public,
616
+ admission: s(R),
617
+ getSnapshot: k,
603
618
  subscribe(e) {
604
- let t = Le(m, e);
605
- return m.size && E.set(m, O), () => {
606
- t(), m.size || E.delete(m);
619
+ let t = Me(_, e);
620
+ return _.size && E.set(_, A), () => {
621
+ t(), _.size || E.delete(_);
607
622
  };
608
623
  },
609
- cancel: ie,
610
- retry: () => ae(!1),
611
- restart: () => ae(!0)
624
+ cancel: F,
625
+ retry: () => I(!1),
626
+ restart: () => I(!0)
612
627
  });
613
628
  }
614
- let Ue = l({
615
- show: (e) => Re(e),
616
- track: He,
617
- update: W((e, n) => {
618
- let r = e.handle, i = a(n);
619
- if (i.length) return G({
629
+ let Re = s({
630
+ show: (e) => Ne(e),
631
+ track: Le,
632
+ update: ve((e, n) => {
633
+ let r = e.handle, a = i(n);
634
+ if (a.length) return G({
620
635
  code: "invalid-input",
621
636
  source: "update",
622
637
  message: "Invalid notification patch",
623
638
  handle: r
624
639
  }), {
625
- ...v("invalid-input"),
626
- issues: i
640
+ ...y("invalid-input"),
641
+ issues: a
627
642
  };
628
- if (e.action.status === "pending" && Object.prototype.hasOwnProperty.call(n, "action")) return v("action-pending");
629
- if (e.operation && (Object.prototype.hasOwnProperty.call(n, "kind") || e.operation.getSnapshot().status === "pending" && Object.prototype.hasOwnProperty.call(n, "duration"))) return v("operation-owned");
643
+ if (e.action.status === "pending" && Object.prototype.hasOwnProperty.call(n, "action")) return y("action-pending");
644
+ if (e.operation && (Object.prototype.hasOwnProperty.call(n, "kind") || e.operation.getSnapshot().status === "pending" && Object.prototype.hasOwnProperty.call(n, "duration"))) return y("operation-owned");
630
645
  let o = t(e.content, n), s = n.kind ?? e.kind, c = n.priority ?? e.priority, l = Object.prototype.hasOwnProperty.call(n, "duration");
631
- return o === e.content && s === e.kind && c === e.priority && !l && !(Object.prototype.hasOwnProperty.call(n, "action") && e.action.status === "failed") ? _ : X((t) => {
646
+ return o === e.content && s === e.kind && c === e.priority && !l && !(Object.prototype.hasOwnProperty.call(n, "action") && e.action.status === "failed") ? v : X((t) => {
632
647
  let i = Q(e);
633
648
  e.content = o, Object.prototype.hasOwnProperty.call(n, "action") && (e.action = h), e.kind = s, e.priority = c;
634
649
  let a = Q(e);
635
- (l || i !== a) && (e.remaining = a), A?.target.kind === "notification" && A.target.handle === r && A.target.control === "action" && !o.action && (A = null), L?.record === e && !ge(e) && (L = null), t.push({
650
+ (l || i !== a) && (e.remaining = a), A?.target.kind === "notification" && A.target.handle === r && A.target.control === "action" && !o.action && (A = null), z?.record === e && !fe(e) && (z = null), t.push({
636
651
  type: "updated",
637
652
  handle: r
638
653
  });
639
654
  });
640
655
  }),
641
- getHandle: (e) => !V && typeof e == "string" ? C.get(e)?.handle : void 0,
642
- dismiss: (e) => Fe(e, "programmatic"),
656
+ getHandle: (e) => !U && typeof e == "string" ? C.get(e)?.handle : void 0,
657
+ dismiss: (e) => Ae(e, "programmatic"),
643
658
  clear() {
644
- if (V) return v("disposed");
659
+ if (U) return y("disposed");
645
660
  let e = C.size;
646
661
  return e && X((e) => {
647
- for (let t of C.values()) Pe(t, "clear", e);
662
+ for (let t of C.values()) $(t, "clear", e);
648
663
  }), {
649
664
  status: "cleared",
650
665
  count: e
651
666
  };
652
667
  },
653
668
  requestFocus(e = { kind: "anchor" }) {
654
- if (V) return v("disposed");
669
+ if (U) return y("disposed");
655
670
  if (e?.kind === "notification") {
656
- let t = U(e.handle);
657
- if (t) return v(t);
671
+ let t = _e(e.handle);
672
+ if (t) return y(t);
658
673
  }
659
- if (!j) return v("no-host");
674
+ if (!j) return y("no-host");
660
675
  if (!e || ![
661
676
  "anchor",
662
677
  "notification",
663
678
  "overflow"
664
- ].includes(e.kind)) return v("unavailable");
679
+ ].includes(e.kind)) return y("unavailable");
665
680
  if (e.kind === "notification") {
666
681
  let t = C.get(e.handle.id);
667
- if (t !== P) return v("not-visible");
668
- if (e.control !== void 0 && !["action", "close"].includes(e.control) || e.control === "action" && !t.content.action) return v("unavailable");
669
- if (e.control !== void 0 && !N) return v("not-visible");
682
+ if (t !== I) return y("not-visible");
683
+ if (e.control !== void 0 && !["action", "close"].includes(e.control) || e.control === "action" && !t.content.action) return y("unavailable");
684
+ if (e.control !== void 0 && !F) return y("not-visible");
670
685
  }
671
- return e.kind === "overflow" && !z ? v("unavailable") : (X(() => {
672
- let t = e.kind === "notification" ? l({
686
+ return e.kind === "overflow" && !V ? y("unavailable") : (X(() => {
687
+ let t = e.kind === "notification" ? s({
673
688
  kind: e.kind,
674
689
  handle: e.handle,
675
690
  ...e.control ? { control: e.control } : {}
676
- }) : l({ kind: e.kind });
677
- A = l({
678
- token: H(),
691
+ }) : s({ kind: e.kind });
692
+ A = s({
693
+ token: W(),
679
694
  target: t
680
695
  });
681
696
  }), { status: "requested" });
682
697
  },
683
- acknowledgeOverflow: Ie,
684
- getSnapshot: () => ue,
698
+ acknowledgeOverflow: je,
699
+ getSnapshot: () => oe,
685
700
  getServerSnapshot: () => p,
686
- subscribe: (e) => Le(w, e),
687
- onEvent: (e) => Le(T, e),
701
+ subscribe: (e) => Me(w, e),
702
+ onEvent: (e) => Me(T, e),
688
703
  dispose() {
689
- V || X((e) => {
690
- V = !0;
691
- for (let t of C.values()) Pe(t, "dispose", e);
704
+ U || X((e) => {
705
+ U = !0;
706
+ for (let t of C.values()) $(t, "dispose", e);
692
707
  for (let t of E.values()) e.includes(t) || e.push(t);
693
- j = M = null, N = null, L = null, Ae(), A = null, D.clear(), z = B = 0;
708
+ j = M = null, F = null, z = null, Ee(), A = null, D.clear(), V = H = 0;
694
709
  }, !0);
695
710
  }
696
711
  });
697
- function We(e) {
698
- return e === void 0 || typeof e == "object" && !!e && Object.keys(e).every((e) => e === "attentionDelay") && (e.attentionDelay === void 0 || n(e.attentionDelay));
699
- }
700
- function $(e) {
701
- return (t, ...n) => {
702
- let r = ye(t);
703
- return r ? v(r) : e(...n);
704
- };
705
- }
706
- let Ge = l({
707
- renderError: b.messages?.renderError ?? "Content unavailable",
708
- reportInvalidContainer(e, t) {
709
- V || G({
710
- code: "invalid-container",
711
- source: "Toaster.container",
712
- message: e,
713
- ...t === void 0 ? {} : { error: t }
714
- });
712
+ return Se(), l.set(Re, s({
713
+ options: b,
714
+ clock: x,
715
+ records: C,
716
+ globalPauses: D,
717
+ subscribe: Re.subscribe,
718
+ onEvent: Re.onEvent,
719
+ get disposed() {
720
+ return U;
715
721
  },
716
- attach(e) {
717
- if (V) return v("disposed");
718
- if (j !== null) return G({
719
- code: "second-host",
720
- source: "attach",
721
- message: "A renderer is already attached"
722
- }), v("host-exists");
723
- if (!We(e)) return v("invalid-input");
724
- let t = H();
725
- return X(() => {
726
- j = M = t, F = e?.attentionDelay, P && De(P);
727
- }), {
728
- status: "attached",
729
- lease: t
730
- };
722
+ get presented() {
723
+ return I;
731
724
  },
732
- detach(e) {
733
- if (V) return v("disposed");
734
- if (j === null && M !== null && e === M) return _;
735
- let t = ye(e);
736
- return t ? v(t) : X(() => {
737
- j = null, F = void 0, Ne(void 0), A = null, k = null, D.clear();
738
- for (let e of C.values()) e.pauses.clear(), e.readable = !1, e.presentation = null;
739
- });
725
+ get rendererSnapshot() {
726
+ return se;
740
727
  },
741
- getSnapshot: () => de,
742
- getServerSnapshot: () => m,
743
- subscribe: Ue.subscribe,
744
- onEvent: Ue.onEvent,
745
- openIsland: $((e, t) => {
746
- if (e !== "user" && e !== "attention") return v("invalid-input");
747
- let n;
748
- if (t === void 0) n = pe();
749
- else {
750
- let e = U(t);
751
- if (e) return v(e);
752
- n = C.get(t.id);
753
- }
754
- if (!n) return v("empty");
755
- let r = n;
756
- return N?.current === r ? _ : X(() => {
757
- N ? N.current = r : N = {
758
- reason: e,
759
- current: r
760
- };
761
- });
762
- }),
763
- collapseIsland: $(() => N ? X(() => {
764
- N = null;
765
- }) : _),
766
- setAutoDismiss: $((e) => e !== void 0 && typeof e != "boolean" ? v("invalid-input") : Z(e) === Z(I) ? (I = e, _) : X(() => Ne(e))),
767
- navigate: $(W((e) => N ? N.current === e ? _ : X(() => {
768
- N.current = e, L?.record === e ? L = null : L && (L.waiting = !1, L.due = x.now() + (F ?? b.attentionDelay ?? c));
769
- }) : v("island-closed"))),
770
- setPause: $((e) => {
771
- if (!e || typeof e.active != "boolean") return v("invalid-input");
772
- let t;
773
- if (e.scope === "host") {
774
- if (![
775
- "hover",
776
- "focus",
777
- "document-hidden",
778
- "window-blur"
779
- ].includes(e.reason)) return v("invalid-input");
780
- t = D;
781
- } else if (e.scope === "notification") {
782
- let n = be(e.handle);
783
- if (n) return v(n);
784
- if (!["gesture", "content-transition"].includes(e.reason)) return v("invalid-input");
785
- t = C.get(e.handle.id).pauses;
786
- } else return v("invalid-input");
787
- return t.has(e.reason) === e.active ? _ : X(() => {
788
- e.active ? t.add(e.reason) : t.delete(e.reason);
728
+ get overflow() {
729
+ return V;
730
+ },
731
+ get lease() {
732
+ return j;
733
+ },
734
+ set lease(e) {
735
+ j = e;
736
+ },
737
+ get lastLease() {
738
+ return M;
739
+ },
740
+ set lastLease(e) {
741
+ M = e;
742
+ },
743
+ get hostDelay() {
744
+ return L;
745
+ },
746
+ set hostDelay(e) {
747
+ L = e;
748
+ },
749
+ get hostAutoDismiss() {
750
+ return R;
751
+ },
752
+ set hostAutoDismiss(e) {
753
+ R = e;
754
+ },
755
+ get island() {
756
+ return F;
757
+ },
758
+ set island(e) {
759
+ F = e;
760
+ },
761
+ get attention() {
762
+ return z;
763
+ },
764
+ set attention(e) {
765
+ z = e;
766
+ },
767
+ get focusRequest() {
768
+ return A;
769
+ },
770
+ set focusRequest(e) {
771
+ A = e;
772
+ },
773
+ get focused() {
774
+ return k;
775
+ },
776
+ set focused(e) {
777
+ k = e;
778
+ },
779
+ get overflowAnnounced() {
780
+ return H;
781
+ },
782
+ set overflowAnnounced(e) {
783
+ H = e;
784
+ },
785
+ token: W,
786
+ diagnostic: G,
787
+ failure: K,
788
+ mutate: X,
789
+ commit: Y,
790
+ settle: J,
791
+ assign: Ce,
792
+ newest: le,
793
+ formOf: pe,
794
+ handleError: _e,
795
+ withRecord: ve,
796
+ autoDismissing: Z,
797
+ setHostAutoDismiss: ke,
798
+ dismiss: Ae,
799
+ acknowledgeOverflow: je,
800
+ reportRendererLoadError(e) {
801
+ U || G({
802
+ code: "renderer-load-error",
803
+ source: "Toaster",
804
+ message: "Toaster renderer failed to load",
805
+ error: e
789
806
  });
790
- }),
791
- setFocused: $((e) => {
792
- let t = e === null ? void 0 : be(e);
793
- return t ? v(t) : k === e ? _ : (k = e, g);
794
- }),
795
- beginPresentation: $(xe((e, t) => {
796
- if (e.presentation !== t) return v("stale-presentation");
797
- let n = H();
798
- return X(() => {
799
- e.presentation = n, e.readable = !1;
800
- }), {
801
- status: "started",
802
- token: n
803
- };
804
- })),
805
- acknowledgePresentation: $(xe((e, t) => e.presentation === t ? e.readable ? _ : X((t) => {
806
- t.push({
807
- type: "presented",
808
- handle: e.handle,
809
- firstPresentation: !e.everPresented
810
- }), e.readable = e.everPresented = !0;
811
- }) : v("stale-presentation"))),
812
- acknowledgeFocus: $((e, t) => A?.token === e ? t !== "focused" && t !== "unavailable" ? v("invalid-input") : X(() => {
813
- A = null;
814
- }) : v("stale-focus-request")),
815
- acknowledgeOverflow: $(() => Ie()),
816
- acknowledgeAnnouncements: $((e) => Ke(e)),
817
- dismiss: $((e, t) => {
818
- let n = U(e);
819
- return n ? v(n) : [
820
- "close-button",
821
- "swipe",
822
- "navigation"
823
- ].includes(t) ? Fe(e, t) : v("invalid-input");
824
- }),
825
- invokeAction: $(W((e) => {
826
- let t = e.handle, n = e.content.action;
827
- if (!n || n.kind !== "command") return v("no-command");
828
- if (e.action.status === "pending") return v("already-pending");
829
- let r = H(), i = () => !V && C.get(t.id) === e && e.action.status === "pending" && e.action.token === r, a = J();
830
- e.action = l({
831
- status: "pending",
832
- token: r
833
- }), Y([{
834
- type: "action-started",
835
- handle: t,
836
- token: r
837
- }], a);
838
- function o(a) {
839
- if (!i()) return;
840
- let o = b.messages?.actionError ?? "Action failed";
841
- if (n?.kind === "command" && n.errorMessage) try {
842
- let e = n.errorMessage(a);
843
- if (typeof e != "string" || !e.trim()) throw TypeError("Invalid action error message");
844
- o = e;
845
- } catch (e) {
846
- V || K("mapper-error", "action.errorMessage", e, t);
847
- }
848
- if (!i()) return;
849
- let s = J();
850
- e.action = l({
851
- status: "failed",
852
- token: r,
853
- message: o
854
- }), Y([{
855
- type: "action-failed",
856
- handle: t,
857
- token: r,
858
- message: o
859
- }], s);
860
- }
861
- let s;
862
- try {
863
- s = Promise.resolve(n.run(l({
864
- handle: t,
865
- token: r
866
- })));
867
- } catch (e) {
868
- s = Promise.reject(e);
869
- }
870
- return s.then(() => {
871
- i() && Fe(t, "action-success");
872
- }, o).catch((e) => {
873
- V || K("callback-error", "action-settlement", e, t);
874
- }), { status: "started" };
875
- })),
876
- retryOperation: $(Se((e) => {
877
- let t = e.retry();
878
- return t.status === "started" ? {
879
- status: "started",
880
- token: t.attempt.token
881
- } : t;
882
- })),
883
- cancelOperation: $(Se((e, t) => e.cancel(t))),
884
- reportDiagnostic: $((e) => !e || typeof e.source != "string" || typeof e.message != "string" || ![
885
- "invalid-input",
886
- "second-host",
887
- "stale-host",
888
- "mapper-error",
889
- "callback-error",
890
- "listener-error",
891
- "cancellation-error",
892
- "slot-error",
893
- "formatter-error",
894
- "invalid-container"
895
- ].includes(e.code) ? v("invalid-input") : (G(e), g))
896
- });
897
- function Ke(e) {
898
- if (!Array.isArray(e)) return v("invalid-input");
899
- let t = [], n = (e, t) => Number.isSafeInteger(e) && e >= 0 && e <= t;
900
- for (let r of e) {
901
- if (!r || typeof r != "object") return v("invalid-input");
902
- if (r.kind === "overflow") {
903
- if (!n(r.count, z)) return v("invalid-input");
904
- r.count > B && t.push(() => {
905
- B = Math.max(B, r.count);
906
- });
907
- continue;
908
- }
909
- let e = U(r.handle);
910
- if (e) return v(e);
911
- let i = C.get(r.handle.id);
912
- if (r.kind === "operation") {
913
- let e = i.operation?.getSnapshot();
914
- if (!e || e.token !== r.token) return v("stale-operation-token");
915
- if (![
916
- "started",
917
- "fulfilled",
918
- "rejected",
919
- "cancelled",
920
- "cancel-requested"
921
- ].includes(r.phase) || (r.phase === "cancel-requested" ? !e.cancelRequested : r.phase !== "started" && r.phase !== e.status)) return v("invalid-input");
922
- i.operationAnnounced.has(r.phase) || t.push(() => {
923
- i.operationAnnounced.add(r.phase);
924
- });
925
- } else if (r.kind === "action") {
926
- if (i.action.status === "idle" || i.action.token !== r.token || i.action.status !== r.status) return v("invalid-input");
927
- (i.actionAnnounced?.token !== r.token || i.actionAnnounced?.status !== r.status) && t.push(() => {
928
- i.actionAnnounced = l({
929
- token: r.token,
930
- status: r.status
931
- });
932
- });
933
- } else if (r.kind === "occurrences") {
934
- if (!n(r.count, i.occurrences)) return v("invalid-input");
935
- r.count > i.occurrencesAnnounced && t.push(() => {
936
- i.occurrencesAnnounced = Math.max(i.occurrencesAnnounced, r.count);
937
- });
938
- } else if (r.kind === "queued" || r.kind === "first-presentation") {
939
- let e = r.kind === "queued" ? "queuedAnnounced" : "firstAnnounced";
940
- i[e] || t.push(() => {
941
- i[e] = !0;
942
- });
943
- } else return v("invalid-input");
944
807
  }
945
- return t.length ? X(() => {
946
- for (let e of t) e();
947
- }) : _;
948
- }
949
- return Ee(), ee.set(Ue, Ge), Ue;
808
+ })), Re;
950
809
  }
951
810
  //#endregion
952
- export { b as createCloudletCore, y as getRendererBridge };
811
+ export { _ as APPLIED, g as NO_FORM_ERRORS, m as RENDERER_SERVER, v as UNCHANGED, x as createCloudletCore, b as getControllerKernel, y as reject };
953
812
 
954
813
  //# sourceMappingURL=controller.js.map