@cloudlet/toast 1.0.0 → 1.1.1

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