likec4 1.57.0 → 1.59.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 (178) hide show
  1. package/__app__/codegen/react.mjs +7 -8
  2. package/__app__/codegen/webcomponent.mjs +78 -889
  3. package/__app__/src/aichat/index.mjs +8 -1
  4. package/__app__/src/chunks/AIChat.mjs +956 -0
  5. package/__app__/src/chunks/LikeC4Styles.mjs +2164 -0
  6. package/__app__/src/chunks/ProjectsOverview.mjs +537 -0
  7. package/__app__/src/chunks/es.mjs +439 -0
  8. package/__app__/src/chunks/hooks.mjs +458 -0
  9. package/__app__/src/chunks/libs/@floating-ui.mjs +2218 -0
  10. package/__app__/src/chunks/libs/@mantine.mjs +12974 -0
  11. package/__app__/src/chunks/libs/@tanstack-ai.mjs +1768 -0
  12. package/__app__/src/chunks/libs/@tanstack.mjs +2693 -0
  13. package/__app__/src/chunks/libs/@xstate/react.mjs +1996 -0
  14. package/__app__/src/chunks/libs/@xyflow/react.mjs +5280 -0
  15. package/__app__/src/chunks/libs/bezier-js.mjs +1006 -0
  16. package/__app__/src/chunks/libs/d3.mjs +2842 -0
  17. package/__app__/src/chunks/libs/fast-equals.mjs +268 -0
  18. package/__app__/src/chunks/libs/framer.mjs +5905 -0
  19. package/__app__/src/chunks/libs/zod.mjs +3173 -0
  20. package/__app__/src/chunks/rolldown-runtime.mjs +30 -0
  21. package/__app__/src/chunks/styled-system.mjs +1047 -0
  22. package/__app__/src/fonts.css +1 -1
  23. package/__app__/src/main.mjs +27659 -14
  24. package/__app__/src/style.css +1 -1
  25. package/dist/chunks/dist.mjs +10 -0
  26. package/dist/chunks/enableServer.mjs +1 -1
  27. package/dist/chunks/filenames.mjs +2 -2
  28. package/dist/chunks/index.d.mts +9 -9
  29. package/dist/chunks/index2.d.mts +2167 -867
  30. package/dist/chunks/libs/@chevrotain/gast.mjs +1 -1
  31. package/dist/chunks/libs/@chevrotain/regexp-to-ast.mjs +1 -1
  32. package/dist/chunks/libs/@logtape/logtape.mjs +4 -3
  33. package/dist/chunks/libs/@ts-graphviz/common.d.mts +1 -2
  34. package/dist/chunks/libs/@ts-graphviz/core.mjs +1 -1
  35. package/dist/chunks/libs/chevrotain-allstar.mjs +2 -2
  36. package/dist/chunks/libs/chevrotain.mjs +25 -25
  37. package/dist/chunks/libs/json5.mjs +1 -1
  38. package/dist/chunks/libs/langium.d.mts +2940 -2914
  39. package/dist/chunks/libs/langium.mjs +9 -9
  40. package/dist/chunks/libs/merge-error-cause.mjs +1 -1
  41. package/dist/chunks/libs/p-queue.mjs +1 -1
  42. package/dist/chunks/libs/package-manager-detector.mjs +1 -1
  43. package/dist/chunks/libs/pako.mjs +1 -1
  44. package/dist/chunks/libs/picomatch.mjs +1 -1
  45. package/dist/chunks/libs/pretty-ms.mjs +1 -1
  46. package/dist/chunks/libs/remeda.mjs +1 -1
  47. package/dist/chunks/libs/ufo.mjs +1 -1
  48. package/dist/chunks/libs/unstorage.d.mts +1 -0
  49. package/dist/chunks/libs/unstorage.mjs +1 -1
  50. package/dist/chunks/libs/which.mjs +1 -1
  51. package/dist/chunks/libs/zod.d.mts +48 -36
  52. package/dist/chunks/libs/zod.mjs +65 -0
  53. package/dist/chunks/logger.mjs +1 -0
  54. package/dist/chunks/node.mjs +65 -63
  55. package/dist/chunks/rolldown-runtime.mjs +1 -1
  56. package/dist/chunks/sequence-view.mjs +1 -1
  57. package/dist/chunks/{plugin.mjs → vite-plugin.mjs} +41 -41
  58. package/dist/cli/index.mjs +186 -144
  59. package/dist/index.d.mts +3 -4
  60. package/dist/index.mjs +1 -1
  61. package/dist/model/index.d.mts +6 -5
  62. package/dist/vite-plugin/index.d.mts +6 -9
  63. package/dist/vite-plugin/index.mjs +1 -1
  64. package/dist/vite-plugin/internal/index.d.mts +64 -64
  65. package/dist/vite-plugin/internal/index.mjs +946 -1
  66. package/package.json +51 -52
  67. package/react/index.d.mts +853 -134
  68. package/react/index.mjs +49718 -44030
  69. package/__app__/chunks/AIChat2.mjs +0 -2
  70. package/__app__/chunks/DiagramActorProvider.mjs +0 -10
  71. package/__app__/chunks/EmbedPage.mjs +0 -1
  72. package/__app__/chunks/ExportPage.mjs +0 -2
  73. package/__app__/chunks/LikeC4Diagram.mjs +0 -19
  74. package/__app__/chunks/LikeC4Styles.mjs +0 -48
  75. package/__app__/chunks/Markdown.mjs +0 -1
  76. package/__app__/chunks/NavigationPanel.mjs +0 -1
  77. package/__app__/chunks/ViewReact.mjs +0 -1
  78. package/__app__/chunks/adhoc-editor.mjs +0 -1
  79. package/__app__/chunks/aichat.mjs +0 -1
  80. package/__app__/chunks/box.mjs +0 -1
  81. package/__app__/chunks/create-style-context.mjs +0 -1
  82. package/__app__/chunks/css.mjs +0 -1
  83. package/__app__/chunks/factory.mjs +0 -1
  84. package/__app__/chunks/hooks.mjs +0 -1
  85. package/__app__/chunks/hstack.mjs +0 -1
  86. package/__app__/chunks/libs/@dagrejs/dagre.mjs +0 -1
  87. package/__app__/chunks/libs/@floating-ui/core.mjs +0 -1
  88. package/__app__/chunks/libs/@floating-ui/dom.mjs +0 -1
  89. package/__app__/chunks/libs/@floating-ui/react.mjs +0 -1
  90. package/__app__/chunks/libs/@mantine/core.mjs +0 -41
  91. package/__app__/chunks/libs/@mantine/hooks.mjs +0 -1
  92. package/__app__/chunks/libs/@nanostores/react.mjs +0 -1
  93. package/__app__/chunks/libs/@react-hookz/web.mjs +0 -1
  94. package/__app__/chunks/libs/@tabler/icons-react.mjs +0 -358
  95. package/__app__/chunks/libs/@tanstack/ai-client.mjs +0 -2
  96. package/__app__/chunks/libs/@tanstack/ai-react-ui.mjs +0 -1
  97. package/__app__/chunks/libs/@tanstack/ai-react.mjs +0 -1
  98. package/__app__/chunks/libs/@tanstack/ai.mjs +0 -2
  99. package/__app__/chunks/libs/@tanstack/history.mjs +0 -1
  100. package/__app__/chunks/libs/@tanstack/react-router.mjs +0 -3
  101. package/__app__/chunks/libs/@tanstack/router-core.mjs +0 -1
  102. package/__app__/chunks/libs/@xstate/react.mjs +0 -1
  103. package/__app__/chunks/libs/@xstate/store.mjs +0 -1
  104. package/__app__/chunks/libs/@xyflow/react.mjs +0 -7
  105. package/__app__/chunks/libs/@zag-js/anatomy.mjs +0 -1
  106. package/__app__/chunks/libs/@zag-js/collection.mjs +0 -1
  107. package/__app__/chunks/libs/@zag-js/core.mjs +0 -1
  108. package/__app__/chunks/libs/@zag-js/react.mjs +0 -1
  109. package/__app__/chunks/libs/@zag-js/tree-view.mjs +0 -1
  110. package/__app__/chunks/libs/bezier-js.mjs +0 -1
  111. package/__app__/chunks/libs/copy-anything.mjs +0 -1
  112. package/__app__/chunks/libs/d3-path.mjs +0 -1
  113. package/__app__/chunks/libs/d3-shape.mjs +0 -1
  114. package/__app__/chunks/libs/fast-equals.mjs +0 -1
  115. package/__app__/chunks/libs/framer-motion.mjs +0 -9
  116. package/__app__/chunks/libs/html-to-image.mjs +0 -2
  117. package/__app__/chunks/libs/motion-dom.mjs +0 -1
  118. package/__app__/chunks/libs/nanostores.mjs +0 -1
  119. package/__app__/chunks/libs/react-error-boundary.mjs +0 -1
  120. package/__app__/chunks/libs/react-resizable-panels.mjs +0 -1
  121. package/__app__/chunks/libs/remeda.mjs +0 -1
  122. package/__app__/chunks/libs/superjson.mjs +0 -1
  123. package/__app__/chunks/libs/zod.mjs +0 -64
  124. package/__app__/chunks/rolldown-runtime.mjs +0 -1
  125. package/__app__/chunks/styles.css.mjs +0 -1
  126. package/__app__/chunks/txt.mjs +0 -1
  127. package/__app__/chunks/useLikeC4Project.mjs +0 -1
  128. package/__app__/src/pages/AdHocViewEditor.mjs +0 -1
  129. package/__app__/src/pages/EmbedPage.mjs +0 -1
  130. package/__app__/src/pages/ExportPage.mjs +0 -1
  131. package/__app__/src/pages/ProjectsOverview.mjs +0 -1
  132. package/__app__/src/pages/ViewAsD2.mjs +0 -1
  133. package/__app__/src/pages/ViewAsDot.mjs +0 -1
  134. package/__app__/src/pages/ViewAsMmd.mjs +0 -1
  135. package/__app__/src/pages/ViewAsPuml.mjs +0 -1
  136. package/__app__/src/pages/ViewEditor.mjs +0 -1
  137. package/__app__/src/pages/ViewReact.mjs +0 -1
  138. package/dist/chunks/libs/@chevrotain/utils.mjs +0 -1
  139. package/dist/chunks/libs/@hono/mcp.mjs +0 -70
  140. package/dist/chunks/libs/@hono/node-server.mjs +0 -1
  141. package/dist/chunks/libs/@logtape/logtape.d.mts +0 -1023
  142. package/dist/chunks/libs/@modelcontextprotocol/sdk.mjs +0 -12
  143. package/dist/chunks/libs/ajv.mjs +0 -1
  144. package/dist/chunks/libs/ansi-align.mjs +0 -2
  145. package/dist/chunks/libs/ansi-regex.mjs +0 -1
  146. package/dist/chunks/libs/ansi-styles.mjs +0 -1
  147. package/dist/chunks/libs/atomically.mjs +0 -1
  148. package/dist/chunks/libs/boxen.mjs +0 -22
  149. package/dist/chunks/libs/conf.mjs +0 -1
  150. package/dist/chunks/libs/defu.mjs +0 -1
  151. package/dist/chunks/libs/destr.mjs +0 -1
  152. package/dist/chunks/libs/find-up-simple.mjs +0 -1
  153. package/dist/chunks/libs/get-port.mjs +0 -1
  154. package/dist/chunks/libs/hono.mjs +0 -1
  155. package/dist/chunks/libs/is-docker.mjs +0 -1
  156. package/dist/chunks/libs/is-error-instance.mjs +0 -1
  157. package/dist/chunks/libs/is-inside-container.mjs +0 -1
  158. package/dist/chunks/libs/is-plain-obj.mjs +0 -1
  159. package/dist/chunks/libs/isexe.mjs +0 -1
  160. package/dist/chunks/libs/ky.mjs +0 -3
  161. package/dist/chunks/libs/p-debounce.mjs +0 -1
  162. package/dist/chunks/libs/p-limit.mjs +0 -1
  163. package/dist/chunks/libs/p-timeout.mjs +0 -1
  164. package/dist/chunks/libs/package-up.mjs +0 -1
  165. package/dist/chunks/libs/parse-ms.mjs +0 -1
  166. package/dist/chunks/libs/safe-stringify.mjs +0 -1
  167. package/dist/chunks/libs/strip-indent.mjs +0 -1
  168. package/dist/chunks/libs/tinyrainbow.mjs +0 -1
  169. package/dist/chunks/libs/ts-graphviz.mjs +0 -1
  170. package/dist/chunks/libs/unctx.mjs +0 -1
  171. package/dist/chunks/libs/vscode-languageserver.mjs +0 -1
  172. package/dist/chunks/libs/word-wrap.mjs +0 -12
  173. package/dist/vite-plugin/internal/chunks/libs/@nanostores/react.mjs +0 -1
  174. package/dist/vite-plugin/internal/chunks/libs/birpc.mjs +0 -1
  175. package/dist/vite-plugin/internal/chunks/libs/fast-equals.mjs +0 -1
  176. package/dist/vite-plugin/internal/chunks/libs/nanostores.mjs +0 -1
  177. package/dist/vite-plugin/internal/chunks/libs/remeda.mjs +0 -1
  178. package/dist/vite-plugin/internal/chunks/rolldown-runtime.mjs +0 -1
@@ -0,0 +1,1996 @@
1
+ import { i as e } from "../../rolldown-runtime.mjs";
2
+ import { useCallback as t, useEffect as n, useLayoutEffect as r, useState as i } from "react";
3
+ import { useSyncExternalStoreWithSelector as a } from "use-sync-external-store/shim/with-selector";
4
+ //#region ../../node_modules/.pnpm/use-isomorphic-layout-effect@1.2.1_@types+react@19.2.17_react@19.2.7/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js
5
+ var o = r;
6
+ //#endregion
7
+ //#region ../../node_modules/.pnpm/xstate@5.32.4/node_modules/xstate/dist/xstate-dev.esm.js
8
+ function getGlobal() {
9
+ if (typeof globalThis < "u") return globalThis;
10
+ if (typeof self < "u") return self;
11
+ if (typeof window < "u") return window;
12
+ if (typeof global < "u") return global;
13
+ }
14
+ function getDevTools() {
15
+ let e = getGlobal();
16
+ if (e.__xstate__) return e.__xstate__;
17
+ }
18
+ var devToolsAdapter = (e) => {
19
+ if (typeof window > "u") return;
20
+ let t = getDevTools();
21
+ t && t.register(e);
22
+ }, Mailbox = class {
23
+ constructor(e) {
24
+ this._process = e, this._active = !1, this._current = null, this._last = null;
25
+ }
26
+ start() {
27
+ this._active = !0, this.flush();
28
+ }
29
+ clear() {
30
+ this._current && (this._current.next = null, this._last = this._current);
31
+ }
32
+ enqueue(e) {
33
+ let t = {
34
+ value: e,
35
+ next: null
36
+ };
37
+ if (this._current) {
38
+ this._last.next = t, this._last = t;
39
+ return;
40
+ }
41
+ this._current = t, this._last = t, this._active && this.flush();
42
+ }
43
+ flush() {
44
+ for (; this._current;) {
45
+ let e = this._current;
46
+ this._process(e.value), this._current = e.next;
47
+ }
48
+ this._last = null;
49
+ }
50
+ }, s = "", c = "#", l = "*", u = "xstate.init", d = "xstate.stop";
51
+ function createAfterEvent(e, t) {
52
+ return { type: `xstate.after.${e}.${t}` };
53
+ }
54
+ function createDoneStateEvent(e, t) {
55
+ return {
56
+ type: `xstate.done.state.${e}`,
57
+ output: t
58
+ };
59
+ }
60
+ function createDoneActorEvent(e, t) {
61
+ return {
62
+ type: `xstate.done.actor.${e}`,
63
+ output: t,
64
+ actorId: e
65
+ };
66
+ }
67
+ function createErrorActorEvent(e, t) {
68
+ return {
69
+ type: `xstate.error.actor.${e}`,
70
+ error: t,
71
+ actorId: e
72
+ };
73
+ }
74
+ function createInitEvent(e) {
75
+ return {
76
+ type: u,
77
+ input: e
78
+ };
79
+ }
80
+ function reportUnhandledError(e) {
81
+ setTimeout(() => {
82
+ throw e;
83
+ });
84
+ }
85
+ var f = typeof Symbol == "function" && Symbol.observable || "@@observable";
86
+ function matchesState(e, t) {
87
+ let n = toStateValue(e), r = toStateValue(t);
88
+ return typeof r == "string" ? typeof n == "string" ? r === n : !1 : typeof n == "string" ? n in r : Object.keys(n).every((e) => e in r ? matchesState(n[e], r[e]) : !1);
89
+ }
90
+ function toStatePath(e) {
91
+ if (isArray(e)) return e;
92
+ let t = [], n = "";
93
+ for (let r = 0; r < e.length; r++) {
94
+ switch (e.charCodeAt(r)) {
95
+ case 92:
96
+ n += e[r + 1], r++;
97
+ continue;
98
+ case 46:
99
+ t.push(n), n = "";
100
+ continue;
101
+ }
102
+ n += e[r];
103
+ }
104
+ return t.push(n), t;
105
+ }
106
+ function toStateValue(e) {
107
+ return isMachineSnapshot(e) ? e.value : typeof e == "string" ? pathToStateValue(toStatePath(e)) : e;
108
+ }
109
+ function pathToStateValue(e) {
110
+ if (e.length === 1) return e[0];
111
+ let t = {}, n = t;
112
+ for (let t = 0; t < e.length - 1; t++) if (t === e.length - 2) n[e[t]] = e[t + 1];
113
+ else {
114
+ let r = n;
115
+ n = {}, r[e[t]] = n;
116
+ }
117
+ return t;
118
+ }
119
+ function mapValues(e, t) {
120
+ let n = {}, r = Object.keys(e);
121
+ for (let i = 0; i < r.length; i++) {
122
+ let a = r[i];
123
+ n[a] = t(e[a], a, e, i);
124
+ }
125
+ return n;
126
+ }
127
+ function toArrayStrict(e) {
128
+ return isArray(e) ? e : [e];
129
+ }
130
+ function toArray(e) {
131
+ return e === void 0 ? [] : toArrayStrict(e);
132
+ }
133
+ function resolveOutput(e, t, n, r) {
134
+ return typeof e == "function" ? e({
135
+ context: t,
136
+ event: n,
137
+ self: r
138
+ }) : e;
139
+ }
140
+ function isArray(e) {
141
+ return Array.isArray(e);
142
+ }
143
+ function isErrorActorEvent(e) {
144
+ return e.type.startsWith("xstate.error.actor");
145
+ }
146
+ function toTransitionConfigArray(e) {
147
+ return toArrayStrict(e).map((e) => e === void 0 || typeof e == "string" ? { target: e } : e);
148
+ }
149
+ function normalizeTarget(e) {
150
+ if (!(e === void 0 || e === s)) return toArray(e);
151
+ }
152
+ function toObserver(e, t, n) {
153
+ let r = typeof e == "object", i = r ? e : void 0;
154
+ return {
155
+ next: (r ? e.next : e)?.bind(i),
156
+ error: (r ? e.error : t)?.bind(i),
157
+ complete: (r ? e.complete : n)?.bind(i)
158
+ };
159
+ }
160
+ function createInvokeId(e, t) {
161
+ return `${t}.${e}`;
162
+ }
163
+ function resolveReferencedActor(e, t) {
164
+ let n = t.match(/^xstate\.invoke\.(\d+)\.(.*)/);
165
+ if (!n) return e.implementations.actors[t];
166
+ let [, r, i] = n, a = e.getStateNodeById(i).config.invoke;
167
+ return (Array.isArray(a) ? a[r] : a).src;
168
+ }
169
+ function matchesEventDescriptor(e, t) {
170
+ if (t === e || t === l) return !0;
171
+ if (!t.endsWith(".*")) return !1;
172
+ let n = t.split("."), r = e.split(".");
173
+ for (let e = 0; e < n.length; e++) {
174
+ let t = n[e], i = r[e];
175
+ if (t === "*") return e === n.length - 1;
176
+ if (t !== i) return !1;
177
+ }
178
+ return !0;
179
+ }
180
+ function createScheduledEventId(e, t) {
181
+ return `${e.sessionId}.${t}`;
182
+ }
183
+ var p = 0;
184
+ function createSystem(e, t) {
185
+ let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), o = {}, { clock: s, logger: c } = t, l = {
186
+ schedule: (e, t, n, r, i = Math.random().toString(36).slice(2)) => {
187
+ let a = {
188
+ source: e,
189
+ target: t,
190
+ event: n,
191
+ delay: r,
192
+ id: i,
193
+ startedAt: Date.now()
194
+ }, c = createScheduledEventId(e, i);
195
+ u._snapshot._scheduledEvents[c] = a;
196
+ let l = s.setTimeout(() => {
197
+ delete o[c], delete u._snapshot._scheduledEvents[c], u._relay(e, t, n);
198
+ }, r);
199
+ o[c] = l;
200
+ },
201
+ cancel: (e, t) => {
202
+ let n = createScheduledEventId(e, t), r = o[n];
203
+ delete o[n], delete u._snapshot._scheduledEvents[n], r !== void 0 && s.clearTimeout(r);
204
+ },
205
+ cancelAll: (e) => {
206
+ for (let t in u._snapshot._scheduledEvents) {
207
+ let n = u._snapshot._scheduledEvents[t];
208
+ n.source === e && l.cancel(e, n.id);
209
+ }
210
+ }
211
+ }, sendInspectionEvent = (t) => {
212
+ if (!a.size) return;
213
+ let n = {
214
+ ...t,
215
+ rootId: e.sessionId
216
+ };
217
+ a.forEach((e) => e.next?.(n));
218
+ }, u = {
219
+ _snapshot: { _scheduledEvents: (t?.snapshot && t.snapshot.scheduler) ?? {} },
220
+ _bookId: () => `x:${p++}`,
221
+ _register: (e, t) => (n.set(e, t), e),
222
+ _unregister: (e) => {
223
+ n.delete(e.sessionId);
224
+ let t = i.get(e);
225
+ t !== void 0 && (r.delete(t), i.delete(e));
226
+ },
227
+ get: (e) => r.get(e),
228
+ getAll: () => Object.fromEntries(r.entries()),
229
+ _set: (e, t) => {
230
+ let n = r.get(e);
231
+ if (n && n !== t) throw Error(`Actor with system ID '${e}' already exists.`);
232
+ r.set(e, t), i.set(t, e);
233
+ },
234
+ inspect: (e) => {
235
+ let t = toObserver(e);
236
+ return a.add(t), { unsubscribe() {
237
+ a.delete(t);
238
+ } };
239
+ },
240
+ _sendInspectionEvent: sendInspectionEvent,
241
+ _relay: (e, t, n) => {
242
+ u._sendInspectionEvent({
243
+ type: "@xstate.event",
244
+ sourceRef: e,
245
+ actorRef: t,
246
+ event: n
247
+ }), t._send(n);
248
+ },
249
+ scheduler: l,
250
+ getSnapshot: () => ({ _scheduledEvents: { ...u._snapshot._scheduledEvents } }),
251
+ start: () => {
252
+ let e = u._snapshot._scheduledEvents;
253
+ u._snapshot._scheduledEvents = {};
254
+ for (let t in e) {
255
+ let { source: n, target: r, event: i, delay: a, id: o } = e[t];
256
+ l.schedule(n, r, i, a, o);
257
+ }
258
+ },
259
+ _clock: s,
260
+ _logger: c
261
+ };
262
+ return u;
263
+ }
264
+ var m = !1, h = /*#__PURE__*/ function(e) {
265
+ return e[e.NotStarted = 0] = "NotStarted", e[e.Running = 1] = "Running", e[e.Stopped = 2] = "Stopped", e;
266
+ }({}), g = {
267
+ clock: {
268
+ setTimeout: (e, t) => setTimeout(e, t),
269
+ clearTimeout: (e) => clearTimeout(e)
270
+ },
271
+ logger: console.log.bind(console),
272
+ devTools: !1
273
+ }, Actor = class {
274
+ constructor(e, t) {
275
+ this.logic = e, this._snapshot = void 0, this.clock = void 0, this.options = void 0, this.id = void 0, this.mailbox = new Mailbox(this._process.bind(this)), this.observers = /* @__PURE__ */ new Set(), this.eventListeners = /* @__PURE__ */ new Map(), this.logger = void 0, this._processingStatus = h.NotStarted, this._parent = void 0, this._syncSnapshot = void 0, this.ref = void 0, this._actorScope = void 0, this.systemId = void 0, this.sessionId = void 0, this.system = void 0, this._doneEvent = void 0, this.src = void 0, this._deferred = [];
276
+ let n = {
277
+ ...g,
278
+ ...t
279
+ }, { clock: r, logger: i, parent: a, syncSnapshot: o, id: s, systemId: c, inspect: l } = n;
280
+ this.system = a ? a.system : createSystem(this, {
281
+ clock: r,
282
+ logger: i
283
+ }), l && !a && this.system.inspect(toObserver(l)), this.sessionId = this.system._bookId(), this.id = s ?? this.sessionId, this.logger = t?.logger ?? this.system._logger, this.clock = t?.clock ?? this.system._clock, this._parent = a, this._syncSnapshot = o, this.options = n, this.src = n.src ?? e, this.ref = this, this._actorScope = {
284
+ self: this,
285
+ id: this.id,
286
+ sessionId: this.sessionId,
287
+ logger: this.logger,
288
+ defer: (e) => {
289
+ this._deferred.push(e);
290
+ },
291
+ system: this.system,
292
+ stopChild: (e) => {
293
+ if (e._parent !== this) throw Error(`Cannot stop child actor ${e.id} of ${this.id} because it is not a child`);
294
+ e._stop();
295
+ },
296
+ emit: (e) => {
297
+ let t = this.eventListeners.get(e.type), n = this.eventListeners.get("*");
298
+ if (!t && !n) return;
299
+ let r = [...t ? t.values() : [], ...n ? n.values() : []];
300
+ for (let t of r) try {
301
+ t(e);
302
+ } catch (e) {
303
+ reportUnhandledError(e);
304
+ }
305
+ },
306
+ actionExecutor: (e) => {
307
+ let exec = () => {
308
+ if (this._actorScope.system._sendInspectionEvent({
309
+ type: "@xstate.action",
310
+ actorRef: this,
311
+ action: {
312
+ type: e.type,
313
+ params: e.params
314
+ }
315
+ }), !e.exec) return;
316
+ let t = m;
317
+ try {
318
+ m = !0, e.exec(e.info, e.params);
319
+ } finally {
320
+ m = t;
321
+ }
322
+ };
323
+ this._processingStatus === h.Running ? exec() : this._deferred.push(exec);
324
+ }
325
+ }, this.send = this.send.bind(this), this.system._sendInspectionEvent({
326
+ type: "@xstate.actor",
327
+ actorRef: this
328
+ }), c && (this.systemId = c, this.system._set(c, this)), this._initState(t?.snapshot ?? t?.state), c && this._snapshot.status !== "active" && this.system._unregister(this);
329
+ }
330
+ _initState(e) {
331
+ try {
332
+ this._snapshot = e ? this.logic.restoreSnapshot ? this.logic.restoreSnapshot(e, this._actorScope) : e : this.logic.getInitialSnapshot(this._actorScope, this.options?.input);
333
+ } catch (e) {
334
+ this._snapshot = {
335
+ status: "error",
336
+ output: void 0,
337
+ error: e
338
+ };
339
+ }
340
+ }
341
+ update(e, t) {
342
+ this._snapshot = e;
343
+ let n;
344
+ for (; n = this._deferred.shift();) try {
345
+ n();
346
+ } catch (t) {
347
+ this._deferred.length = 0, this._snapshot = {
348
+ ...e,
349
+ status: "error",
350
+ error: t
351
+ };
352
+ }
353
+ switch (this._snapshot.status) {
354
+ case "active":
355
+ for (let t of this.observers) try {
356
+ t.next?.(e);
357
+ } catch (e) {
358
+ reportUnhandledError(e);
359
+ }
360
+ break;
361
+ case "done":
362
+ for (let t of this.observers) try {
363
+ t.next?.(e);
364
+ } catch (e) {
365
+ reportUnhandledError(e);
366
+ }
367
+ this._stopProcedure(), this._complete(), this._doneEvent = createDoneActorEvent(this.id, this._snapshot.output), this._parent && this.system._relay(this, this._parent, this._doneEvent);
368
+ break;
369
+ case "error":
370
+ this._error(this._snapshot.error);
371
+ break;
372
+ }
373
+ this.system._sendInspectionEvent({
374
+ type: "@xstate.snapshot",
375
+ actorRef: this,
376
+ event: t,
377
+ snapshot: e
378
+ });
379
+ }
380
+ subscribe(e, t, n) {
381
+ let r = toObserver(e, t, n);
382
+ if (this._processingStatus !== h.Stopped) this.observers.add(r);
383
+ else switch (this._snapshot.status) {
384
+ case "done":
385
+ try {
386
+ r.complete?.();
387
+ } catch (e) {
388
+ reportUnhandledError(e);
389
+ }
390
+ break;
391
+ case "error": {
392
+ let e = this._snapshot.error;
393
+ if (!r.error) reportUnhandledError(e);
394
+ else try {
395
+ r.error(e);
396
+ } catch (e) {
397
+ reportUnhandledError(e);
398
+ }
399
+ break;
400
+ }
401
+ }
402
+ return { unsubscribe: () => {
403
+ this.observers.delete(r);
404
+ } };
405
+ }
406
+ on(e, t) {
407
+ let n = this.eventListeners.get(e);
408
+ n || (n = /* @__PURE__ */ new Set(), this.eventListeners.set(e, n));
409
+ let r = t.bind(void 0);
410
+ return n.add(r), { unsubscribe: () => {
411
+ n.delete(r);
412
+ } };
413
+ }
414
+ select(e, t = Object.is) {
415
+ return {
416
+ subscribe: (n) => {
417
+ let r = toObserver(n), i = e(this.getSnapshot());
418
+ return this.subscribe((n) => {
419
+ let a = e(n);
420
+ t(i, a) || (i = a, r.next?.(a));
421
+ });
422
+ },
423
+ get: () => e(this.getSnapshot())
424
+ };
425
+ }
426
+ start() {
427
+ if (this._processingStatus === h.Running) return this;
428
+ this._syncSnapshot && this.subscribe({
429
+ next: (e) => {
430
+ e.status === "active" && this.system._relay(this, this._parent, {
431
+ type: `xstate.snapshot.${this.id}`,
432
+ snapshot: e
433
+ });
434
+ },
435
+ error: () => {}
436
+ }), this.system._register(this.sessionId, this), this.systemId && this.system._set(this.systemId, this), this._processingStatus = h.Running;
437
+ let e = createInitEvent(this.options.input);
438
+ switch (this.system._sendInspectionEvent({
439
+ type: "@xstate.event",
440
+ sourceRef: this._parent,
441
+ actorRef: this,
442
+ event: e
443
+ }), this._snapshot.status) {
444
+ case "done": return this.update(this._snapshot, e), this;
445
+ case "error": return this._error(this._snapshot.error), this;
446
+ }
447
+ if (this._parent || this.system.start(), this.logic.start) try {
448
+ this.logic.start(this._snapshot, this._actorScope);
449
+ } catch (e) {
450
+ return this._snapshot = {
451
+ ...this._snapshot,
452
+ status: "error",
453
+ error: e
454
+ }, this._error(e), this;
455
+ }
456
+ return this.update(this._snapshot, e), this.options.devTools && this.attachDevTools(), this.mailbox.start(), this;
457
+ }
458
+ _process(e) {
459
+ let t, n;
460
+ try {
461
+ t = this.logic.transition(this._snapshot, e, this._actorScope);
462
+ } catch (e) {
463
+ n = { err: e };
464
+ }
465
+ if (n) {
466
+ let { err: e } = n;
467
+ this._snapshot = {
468
+ ...this._snapshot,
469
+ status: "error",
470
+ error: e
471
+ }, this._error(e);
472
+ return;
473
+ }
474
+ this.update(t, e), e.type === "xstate.stop" && (this._stopProcedure(), this._complete());
475
+ }
476
+ _stop() {
477
+ return this._processingStatus === h.Stopped ? this : (this.mailbox.clear(), this._processingStatus === h.NotStarted ? (this._processingStatus = h.Stopped, this) : (this.mailbox.enqueue({ type: d }), this));
478
+ }
479
+ stop() {
480
+ if (this._parent) throw Error("A non-root actor cannot be stopped directly.");
481
+ return this._stop();
482
+ }
483
+ _complete() {
484
+ for (let e of this.observers) try {
485
+ e.complete?.();
486
+ } catch (e) {
487
+ reportUnhandledError(e);
488
+ }
489
+ this.observers.clear(), this.eventListeners.clear();
490
+ }
491
+ _reportError(e) {
492
+ if (!this.observers.size) {
493
+ this._parent || reportUnhandledError(e), this.eventListeners.clear();
494
+ return;
495
+ }
496
+ let t = !1;
497
+ for (let n of this.observers) {
498
+ let r = n.error;
499
+ t ||= !r;
500
+ try {
501
+ r?.(e);
502
+ } catch (e) {
503
+ reportUnhandledError(e);
504
+ }
505
+ }
506
+ this.observers.clear(), this.eventListeners.clear(), t && reportUnhandledError(e);
507
+ }
508
+ _error(e) {
509
+ this._stopProcedure(), this._reportError(e), this._parent && this.system._relay(this, this._parent, createErrorActorEvent(this.id, e));
510
+ }
511
+ _stopProcedure() {
512
+ return this._processingStatus === h.Running ? (this.system.scheduler.cancelAll(this), this.mailbox.clear(), this.mailbox = new Mailbox(this._process.bind(this)), this._processingStatus = h.Stopped, this.system._unregister(this), this) : this;
513
+ }
514
+ _send(e) {
515
+ this._processingStatus !== h.Stopped && this.mailbox.enqueue(e);
516
+ }
517
+ send(e) {
518
+ this.system._relay(void 0, this, e);
519
+ }
520
+ attachDevTools() {
521
+ let { devTools: e } = this.options;
522
+ e && (typeof e == "function" ? e : devToolsAdapter)(this);
523
+ }
524
+ toJSON() {
525
+ return {
526
+ xstate$$type: 1,
527
+ id: this.id
528
+ };
529
+ }
530
+ getPersistedSnapshot(e) {
531
+ return this.logic.getPersistedSnapshot(this._snapshot, e);
532
+ }
533
+ [f]() {
534
+ return this;
535
+ }
536
+ getSnapshot() {
537
+ return this._snapshot;
538
+ }
539
+ };
540
+ function createActor(e, ...[t]) {
541
+ return new Actor(e, t);
542
+ }
543
+ function resolveCancel(e, t, n, r, { sendId: i }) {
544
+ return [
545
+ t,
546
+ { sendId: typeof i == "function" ? i(n, r) : i },
547
+ void 0
548
+ ];
549
+ }
550
+ function executeCancel(e, t) {
551
+ e.defer(() => {
552
+ e.system.scheduler.cancel(e.self, t.sendId);
553
+ });
554
+ }
555
+ function cancel(e) {
556
+ function cancel(e, t) {}
557
+ return cancel.type = "xstate.cancel", cancel.sendId = e, cancel.resolve = resolveCancel, cancel.execute = executeCancel, cancel;
558
+ }
559
+ function resolveSpawn(e, t, n, r, { id: i, systemId: a, src: o, input: s, syncSnapshot: c }) {
560
+ let l = typeof o == "string" ? resolveReferencedActor(t.machine, o) : o, u = typeof i == "function" ? i(n) : i, d, f;
561
+ return l && (f = typeof s == "function" ? s({
562
+ context: t.context,
563
+ event: n.event,
564
+ self: e.self
565
+ }) : s, d = createActor(l, {
566
+ id: u,
567
+ src: o,
568
+ parent: e.self,
569
+ syncSnapshot: c,
570
+ systemId: a,
571
+ input: f
572
+ })), [
573
+ cloneMachineSnapshot(t, { children: {
574
+ ...t.children,
575
+ [u]: d
576
+ } }),
577
+ {
578
+ id: i,
579
+ systemId: a,
580
+ actorRef: d,
581
+ src: o,
582
+ input: f
583
+ },
584
+ void 0
585
+ ];
586
+ }
587
+ function executeSpawn(e, { actorRef: t }) {
588
+ t && e.defer(() => {
589
+ t._processingStatus !== h.Stopped && t.start();
590
+ });
591
+ }
592
+ function spawnChild(...[e, { id: t, systemId: n, input: r, syncSnapshot: i = !1 } = {}]) {
593
+ function spawnChild(e, t) {}
594
+ return spawnChild.type = "xstate.spawnChild", spawnChild.id = t, spawnChild.systemId = n, spawnChild.src = e, spawnChild.input = r, spawnChild.syncSnapshot = i, spawnChild.resolve = resolveSpawn, spawnChild.execute = executeSpawn, spawnChild;
595
+ }
596
+ function resolveStop(e, t, n, r, { actorRef: i }) {
597
+ let a = typeof i == "function" ? i(n, r) : i, o = typeof a == "string" ? t.children[a] : a, s = t.children;
598
+ return o && (s = { ...s }, delete s[o.id]), [
599
+ cloneMachineSnapshot(t, { children: s }),
600
+ o,
601
+ void 0
602
+ ];
603
+ }
604
+ function unregisterRecursively(e, t) {
605
+ let n = t.getSnapshot();
606
+ if (n && "children" in n) for (let t of Object.values(n.children)) unregisterRecursively(e, t);
607
+ e.system._unregister(t);
608
+ }
609
+ function executeStop(e, t) {
610
+ if (t) {
611
+ if (unregisterRecursively(e, t), t._processingStatus !== h.Running) {
612
+ e.stopChild(t);
613
+ return;
614
+ }
615
+ e.defer(() => {
616
+ e.stopChild(t);
617
+ });
618
+ }
619
+ }
620
+ function stopChild(e) {
621
+ function stop(e, t) {}
622
+ return stop.type = "xstate.stopChild", stop.actorRef = e, stop.resolve = resolveStop, stop.execute = executeStop, stop;
623
+ }
624
+ function checkNot(e, { context: t, event: n }, { guards: r }) {
625
+ return !evaluateGuard(r[0], t, n, e);
626
+ }
627
+ function not(e) {
628
+ function not(e, t) {
629
+ return !1;
630
+ }
631
+ return not.check = checkNot, not.guards = [e], not;
632
+ }
633
+ function checkAnd(e, { context: t, event: n }, { guards: r }) {
634
+ return r.every((r) => evaluateGuard(r, t, n, e));
635
+ }
636
+ function and(e) {
637
+ function and(e, t) {
638
+ return !1;
639
+ }
640
+ return and.check = checkAnd, and.guards = e, and;
641
+ }
642
+ function checkOr(e, { context: t, event: n }, { guards: r }) {
643
+ return r.some((r) => evaluateGuard(r, t, n, e));
644
+ }
645
+ function or(e) {
646
+ function or(e, t) {
647
+ return !1;
648
+ }
649
+ return or.check = checkOr, or.guards = e, or;
650
+ }
651
+ function evaluateGuard(e, t, n, r) {
652
+ let { machine: i } = r, a = typeof e == "function", o = a ? e : i.implementations.guards[typeof e == "string" ? e : e.type];
653
+ if (!a && !o) throw Error(`Guard '${typeof e == "string" ? e : e.type}' is not implemented.'.`);
654
+ if (typeof o != "function") return evaluateGuard(o, t, n, r);
655
+ let s = {
656
+ context: t,
657
+ event: n
658
+ }, c = a || typeof e == "string" ? void 0 : "params" in e ? typeof e.params == "function" ? e.params({
659
+ context: t,
660
+ event: n
661
+ }) : e.params : void 0;
662
+ return "check" in o ? o.check(r, s, o) : o(s, c);
663
+ }
664
+ function isAtomicStateNode(e) {
665
+ return e.type === "atomic" || e.type === "final";
666
+ }
667
+ function getChildren(e) {
668
+ return Object.values(e.states).filter((e) => e.type !== "history");
669
+ }
670
+ function getProperAncestors(e, t) {
671
+ let n = [];
672
+ if (t === e) return n;
673
+ let r = e.parent;
674
+ for (; r && r !== t;) n.push(r), r = r.parent;
675
+ return n;
676
+ }
677
+ function getAllStateNodes(e) {
678
+ let t = new Set(e), n = getAdjList(t);
679
+ for (let e of t) if (e.type === "compound" && (!n.get(e) || !n.get(e).length)) getInitialStateNodesWithTheirAncestors(e).forEach((e) => t.add(e));
680
+ else if (e.type === "parallel") {
681
+ for (let n of getChildren(e)) if (n.type !== "history" && !t.has(n)) {
682
+ let e = getInitialStateNodesWithTheirAncestors(n);
683
+ for (let n of e) t.add(n);
684
+ }
685
+ }
686
+ for (let e of t) {
687
+ let n = e.parent;
688
+ for (; n;) t.add(n), n = n.parent;
689
+ }
690
+ return t;
691
+ }
692
+ function getValueFromAdj(e, t) {
693
+ let n = t.get(e);
694
+ if (!n) return {};
695
+ if (e.type === "compound") {
696
+ let e = n[0];
697
+ if (e) {
698
+ if (isAtomicStateNode(e)) return e.key;
699
+ } else return {};
700
+ }
701
+ let r = {};
702
+ for (let e of n) r[e.key] = getValueFromAdj(e, t);
703
+ return r;
704
+ }
705
+ function getAdjList(e) {
706
+ let t = /* @__PURE__ */ new Map();
707
+ for (let n of e) t.has(n) || t.set(n, []), n.parent && (t.has(n.parent) || t.set(n.parent, []), t.get(n.parent).push(n));
708
+ return t;
709
+ }
710
+ function getStateValue(e, t) {
711
+ return getValueFromAdj(e, getAdjList(getAllStateNodes(t)));
712
+ }
713
+ function isInFinalState(e, t) {
714
+ return t.type === "compound" ? getChildren(t).some((t) => t.type === "final" && e.has(t)) : t.type === "parallel" ? getChildren(t).every((t) => isInFinalState(e, t)) : t.type === "final";
715
+ }
716
+ var isStateId = (e) => e[0] === c;
717
+ function getCandidates(e, t) {
718
+ let n = e.transitions.get(t), r = [...e.transitions.keys()].filter((e) => e !== t && matchesEventDescriptor(t, e)).sort((e, t) => t.length - e.length).flatMap((t) => e.transitions.get(t));
719
+ return n ? [...n, ...r] : r;
720
+ }
721
+ function getDelayedTransitions(e) {
722
+ let t = e.config.after;
723
+ if (!t) return [];
724
+ let mutateEntryExit = (t) => {
725
+ let n = createAfterEvent(t, e.id), r = n.type;
726
+ return e.entry.push(raise(n, {
727
+ id: r,
728
+ delay: t
729
+ })), e.exit.push(cancel(r)), r;
730
+ };
731
+ return Object.keys(t).flatMap((e) => {
732
+ let n = t[e], r = typeof n == "string" ? { target: n } : n, i = Number.isNaN(+e) ? e : +e, a = mutateEntryExit(i);
733
+ return toArray(r).map((e) => ({
734
+ ...e,
735
+ event: a,
736
+ delay: i
737
+ }));
738
+ }).map((t) => {
739
+ let { delay: n } = t;
740
+ return {
741
+ ...formatTransition(e, t.event, t),
742
+ delay: n
743
+ };
744
+ });
745
+ }
746
+ function formatTransition(e, t, n) {
747
+ let r = normalizeTarget(n.target), i = n.reenter ?? !1, a = resolveTarget(e, r), o = {
748
+ ...n,
749
+ actions: toArray(n.actions),
750
+ guard: n.guard,
751
+ target: a,
752
+ source: e,
753
+ reenter: i,
754
+ eventType: t,
755
+ toJSON: () => ({
756
+ ...o,
757
+ source: `#${e.id}`,
758
+ target: a ? a.map((e) => `#${e.id}`) : void 0
759
+ })
760
+ };
761
+ return o;
762
+ }
763
+ function formatTransitions(e) {
764
+ let t = /* @__PURE__ */ new Map();
765
+ if (e.config.on) for (let n of Object.keys(e.config.on)) {
766
+ if (n === "") throw Error("Null events (\"\") cannot be specified as a transition key. Use `always: { ... }` instead.");
767
+ let r = e.config.on[n];
768
+ t.set(n, toTransitionConfigArray(r).map((t) => formatTransition(e, n, t)));
769
+ }
770
+ if (e.config.onDone) {
771
+ let n = `xstate.done.state.${e.id}`;
772
+ t.set(n, toTransitionConfigArray(e.config.onDone).map((t) => formatTransition(e, n, t)));
773
+ }
774
+ for (let n of e.invoke) {
775
+ if (n.onDone) {
776
+ let r = `xstate.done.actor.${n.id}`;
777
+ t.set(r, toTransitionConfigArray(n.onDone).map((t) => formatTransition(e, r, t)));
778
+ }
779
+ if (n.onError) {
780
+ let r = `xstate.error.actor.${n.id}`;
781
+ t.set(r, toTransitionConfigArray(n.onError).map((t) => formatTransition(e, r, t)));
782
+ }
783
+ if (n.onSnapshot) {
784
+ let r = `xstate.snapshot.${n.id}`;
785
+ t.set(r, toTransitionConfigArray(n.onSnapshot).map((t) => formatTransition(e, r, t)));
786
+ }
787
+ }
788
+ for (let n of e.after) {
789
+ let e = t.get(n.eventType);
790
+ e || (e = [], t.set(n.eventType, e)), e.push(n);
791
+ }
792
+ return t;
793
+ }
794
+ function formatRouteTransitions(e) {
795
+ let t = [], collectRoutes = (n) => {
796
+ Object.values(n).forEach((n) => {
797
+ if (n.config.route && n.config.id) {
798
+ let r = n.config.id, i = n.config.route.guard, routeMatches = ({ event: e }) => e.to === `#${r}`, a = {
799
+ ...n.config.route,
800
+ guard: i ? and([routeMatches, i]) : routeMatches,
801
+ target: `#${r}`
802
+ };
803
+ t.push(formatTransition(e, "xstate.route", a));
804
+ }
805
+ n.states && collectRoutes(n.states);
806
+ });
807
+ };
808
+ collectRoutes(e.states), t.length > 0 && e.transitions.set("xstate.route", t);
809
+ }
810
+ function formatInitialTransition(e, t) {
811
+ let n = typeof t == "string" ? e.states[t] : t ? e.states[t.target] : void 0;
812
+ if (!n && t) throw Error(`Initial state node "${t}" not found on parent state node #${e.id}`);
813
+ let r = {
814
+ source: e,
815
+ actions: !t || typeof t == "string" ? [] : toArray(t.actions),
816
+ eventType: null,
817
+ reenter: !1,
818
+ target: n ? [n] : [],
819
+ toJSON: () => ({
820
+ ...r,
821
+ source: `#${e.id}`,
822
+ target: n ? [`#${n.id}`] : []
823
+ })
824
+ };
825
+ return r;
826
+ }
827
+ function resolveTarget(e, t) {
828
+ if (t !== void 0) return t.map((t) => {
829
+ if (typeof t != "string") return t;
830
+ if (isStateId(t)) return e.machine.getStateNodeById(t);
831
+ let n = t[0] === ".";
832
+ if (n && !e.parent) return getStateNodeByPath(e, t.slice(1));
833
+ let r = n ? e.key + t : t;
834
+ if (e.parent) try {
835
+ return getStateNodeByPath(e.parent, r);
836
+ } catch (t) {
837
+ throw Error(`Invalid transition definition for state node '${e.id}':\n${t.message}`);
838
+ }
839
+ else throw Error(`Invalid target: "${t}" is not a valid target from the root node. Did you mean ".${t}"?`);
840
+ });
841
+ }
842
+ function resolveHistoryDefaultTransition(e) {
843
+ let t = normalizeTarget(e.config.target);
844
+ return t ? { target: t.map((t) => typeof t == "string" ? getStateNodeByPath(e.parent, t) : t) } : e.parent.type === "parallel" ? { target: [e.parent] } : e.parent.initial;
845
+ }
846
+ function isHistoryNode(e) {
847
+ return e.type === "history";
848
+ }
849
+ function getInitialStateNodesWithTheirAncestors(e) {
850
+ let t = getInitialStateNodes(e);
851
+ for (let n of t) for (let r of getProperAncestors(n, e)) t.add(r);
852
+ return t;
853
+ }
854
+ function getInitialStateNodes(e) {
855
+ let t = /* @__PURE__ */ new Set();
856
+ function iter(e) {
857
+ if (!t.has(e)) {
858
+ if (t.add(e), e.type === "compound") iter(e.initial.target[0]);
859
+ else if (e.type === "parallel") for (let t of getChildren(e)) iter(t);
860
+ }
861
+ }
862
+ return iter(e), t;
863
+ }
864
+ function getStateNode(e, t) {
865
+ if (isStateId(t)) return e.machine.getStateNodeById(t);
866
+ if (!e.states) throw Error(`Unable to retrieve child state '${t}' from '${e.id}'; no child states exist.`);
867
+ let n = e.states[t];
868
+ if (!n) throw Error(`Child state '${t}' does not exist on '${e.id}'`);
869
+ return n;
870
+ }
871
+ function getStateNodeByPath(e, t) {
872
+ if (typeof t == "string" && isStateId(t)) try {
873
+ return e.machine.getStateNodeById(t);
874
+ } catch {}
875
+ let n = toStatePath(t).slice(), r = e;
876
+ for (; n.length;) {
877
+ let e = n.shift();
878
+ if (!e.length) break;
879
+ r = getStateNode(r, e);
880
+ }
881
+ return r;
882
+ }
883
+ function getStateNodes(e, t) {
884
+ if (typeof t == "string") {
885
+ let n = e.states[t];
886
+ if (!n) throw Error(`State '${t}' does not exist on '${e.id}'`);
887
+ return [e, n];
888
+ }
889
+ let n = Object.keys(t), r = n.map((t) => getStateNode(e, t)).filter(Boolean);
890
+ return [e.machine.root, e].concat(r, n.reduce((n, r) => {
891
+ let i = getStateNode(e, r);
892
+ if (!i) return n;
893
+ let a = getStateNodes(i, t[r]);
894
+ return n.concat(a);
895
+ }, []));
896
+ }
897
+ function transitionAtomicNode(e, t, n, r) {
898
+ let i = getStateNode(e, t).next(n, r);
899
+ return !i || !i.length ? e.next(n, r) : i;
900
+ }
901
+ function transitionCompoundNode(e, t, n, r) {
902
+ let i = Object.keys(t), a = transitionNode(getStateNode(e, i[0]), t[i[0]], n, r);
903
+ return !a || !a.length ? e.next(n, r) : a;
904
+ }
905
+ function transitionParallelNode(e, t, n, r) {
906
+ let i = [];
907
+ for (let a of Object.keys(t)) {
908
+ let o = t[a];
909
+ if (!o) continue;
910
+ let s = transitionNode(getStateNode(e, a), o, n, r);
911
+ s && i.push(...s);
912
+ }
913
+ return i.length ? i : e.next(n, r);
914
+ }
915
+ function transitionNode(e, t, n, r) {
916
+ return typeof t == "string" ? transitionAtomicNode(e, t, n, r) : Object.keys(t).length === 1 ? transitionCompoundNode(e, t, n, r) : transitionParallelNode(e, t, n, r);
917
+ }
918
+ function getHistoryNodes(e) {
919
+ return Object.keys(e.states).map((t) => e.states[t]).filter((e) => e.type === "history");
920
+ }
921
+ function isDescendant(e, t) {
922
+ let n = e;
923
+ for (; n.parent && n.parent !== t;) n = n.parent;
924
+ return n.parent === t;
925
+ }
926
+ function hasIntersection(e, t) {
927
+ let n = new Set(e), r = new Set(t);
928
+ for (let e of n) if (r.has(e)) return !0;
929
+ for (let e of r) if (n.has(e)) return !0;
930
+ return !1;
931
+ }
932
+ function removeConflictingTransitions(e, t, n) {
933
+ let r = /* @__PURE__ */ new Set();
934
+ for (let i of e) {
935
+ let e = !1, a = /* @__PURE__ */ new Set();
936
+ for (let o of r) if (hasIntersection(computeExitSet([i], t, n), computeExitSet([o], t, n))) if (isDescendant(i.source, o.source)) a.add(o);
937
+ else {
938
+ e = !0;
939
+ break;
940
+ }
941
+ if (!e) {
942
+ for (let e of a) r.delete(e);
943
+ r.add(i);
944
+ }
945
+ }
946
+ return Array.from(r);
947
+ }
948
+ function findLeastCommonAncestor(e) {
949
+ let [t, ...n] = e;
950
+ for (let e of getProperAncestors(t, void 0)) if (n.every((t) => isDescendant(t, e))) return e;
951
+ }
952
+ function getEffectiveTargetStates(e, t) {
953
+ if (!e.target) return [];
954
+ let n = /* @__PURE__ */ new Set();
955
+ for (let r of e.target) if (isHistoryNode(r)) if (t[r.id]) for (let e of t[r.id]) n.add(e);
956
+ else for (let e of getEffectiveTargetStates(resolveHistoryDefaultTransition(r), t)) n.add(e);
957
+ else n.add(r);
958
+ return [...n];
959
+ }
960
+ function getTransitionDomain(e, t) {
961
+ let n = getEffectiveTargetStates(e, t);
962
+ if (!n) return;
963
+ if (!e.reenter && n.every((t) => t === e.source || isDescendant(t, e.source))) return e.source;
964
+ let r = findLeastCommonAncestor(n.concat(e.source));
965
+ if (r) return r;
966
+ if (!e.reenter) return e.source.machine.root;
967
+ }
968
+ function computeExitSet(e, t, n) {
969
+ let r = /* @__PURE__ */ new Set();
970
+ for (let i of e) if (i.target?.length) {
971
+ let e = getTransitionDomain(i, n);
972
+ i.reenter && i.source === e && r.add(e);
973
+ for (let n of t) isDescendant(n, e) && r.add(n);
974
+ }
975
+ return [...r];
976
+ }
977
+ function areStateNodeCollectionsEqual(e, t) {
978
+ if (e.length !== t.size) return !1;
979
+ for (let n of e) if (!t.has(n)) return !1;
980
+ return !0;
981
+ }
982
+ function initialMicrostep(e, t, n, r, i) {
983
+ return microstep([{
984
+ target: [...getInitialStateNodes(e)],
985
+ source: e,
986
+ reenter: !0,
987
+ actions: [],
988
+ eventType: null,
989
+ toJSON: null
990
+ }], t, n, r, !0, i);
991
+ }
992
+ function microstep(e, t, n, r, i, a) {
993
+ let o = [];
994
+ if (!e.length) return [t, o];
995
+ let s = n.actionExecutor;
996
+ n.actionExecutor = (e) => {
997
+ o.push(e), s(e);
998
+ };
999
+ try {
1000
+ let s = new Set(t._nodes), c = t.historyValue, l = removeConflictingTransitions(e, s, c), u = t;
1001
+ i || ([u, c] = exitStates(u, r, n, l, s, c, a, n.actionExecutor)), u = resolveActionsAndContext(u, r, n, l.flatMap((e) => e.actions), a, void 0), u = enterStates(u, r, n, l, s, a, c, i);
1002
+ let d = [...s];
1003
+ u.status === "done" && (u = resolveActionsAndContext(u, r, n, d.sort((e, t) => t.order - e.order).flatMap((e) => e.exit), a, void 0));
1004
+ try {
1005
+ return c === t.historyValue && areStateNodeCollectionsEqual(t._nodes, s) ? [u, o] : [cloneMachineSnapshot(u, {
1006
+ _nodes: d,
1007
+ historyValue: c
1008
+ }), o];
1009
+ } catch (e) {
1010
+ throw e;
1011
+ }
1012
+ } finally {
1013
+ n.actionExecutor = s;
1014
+ }
1015
+ }
1016
+ function getMachineOutput(e, t, n, r, i) {
1017
+ if (r.output === void 0) return;
1018
+ let a = createDoneStateEvent(i.id, i.output !== void 0 && i.parent ? resolveOutput(i.output, e.context, t, n.self) : void 0);
1019
+ return resolveOutput(r.output, e.context, a, n.self);
1020
+ }
1021
+ function enterStates(e, t, n, r, i, a, o, s) {
1022
+ let c = e, l = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set();
1023
+ computeEntrySet(r, o, u, l), s && u.add(e.machine.root);
1024
+ let d = /* @__PURE__ */ new Set();
1025
+ for (let e of [...l].sort((e, t) => e.order - t.order)) {
1026
+ i.add(e);
1027
+ let r = [];
1028
+ r.push(...e.entry);
1029
+ for (let t of e.invoke) r.push(spawnChild(t.src, {
1030
+ ...t,
1031
+ syncSnapshot: !!t.onSnapshot
1032
+ }));
1033
+ if (u.has(e)) {
1034
+ let t = e.initial.actions;
1035
+ r.push(...t);
1036
+ }
1037
+ if (c = resolveActionsAndContext(c, t, n, r, a, e.invoke.map((e) => e.id)), e.type === "final") {
1038
+ let r = e.parent, o = r?.type === "parallel" ? r : r?.parent, s = o || e;
1039
+ for (r?.type === "compound" && a.push(createDoneStateEvent(r.id, e.output === void 0 ? void 0 : resolveOutput(e.output, c.context, t, n.self))); o?.type === "parallel" && !d.has(o) && isInFinalState(i, o);) d.add(o), a.push(createDoneStateEvent(o.id)), s = o, o = o.parent;
1040
+ if (o) continue;
1041
+ c = cloneMachineSnapshot(c, {
1042
+ status: "done",
1043
+ output: getMachineOutput(c, t, n, c.machine.root, s)
1044
+ });
1045
+ }
1046
+ }
1047
+ return c;
1048
+ }
1049
+ function computeEntrySet(e, t, n, r) {
1050
+ for (let i of e) {
1051
+ let e = getTransitionDomain(i, t);
1052
+ for (let a of i.target || []) !isHistoryNode(a) && (i.source !== a || i.source !== e || i.reenter) && (r.add(a), n.add(a)), addDescendantStatesToEnter(a, t, n, r);
1053
+ let a = getEffectiveTargetStates(i, t);
1054
+ for (let o of a) {
1055
+ let a = getProperAncestors(o, e);
1056
+ e?.type === "parallel" && a.push(e), addAncestorStatesToEnter(r, t, n, a, !i.source.parent && i.reenter ? void 0 : e);
1057
+ }
1058
+ }
1059
+ }
1060
+ function addDescendantStatesToEnter(e, t, n, r) {
1061
+ if (isHistoryNode(e)) if (t[e.id]) {
1062
+ let i = t[e.id];
1063
+ for (let e of i) r.add(e), addDescendantStatesToEnter(e, t, n, r);
1064
+ for (let a of i) addProperAncestorStatesToEnter(a, e.parent, r, t, n);
1065
+ } else {
1066
+ let i = resolveHistoryDefaultTransition(e);
1067
+ for (let a of i.target) r.add(a), i === e.parent?.initial && n.add(e.parent), addDescendantStatesToEnter(a, t, n, r);
1068
+ for (let a of i.target) addProperAncestorStatesToEnter(a, e.parent, r, t, n);
1069
+ }
1070
+ else if (e.type === "compound") {
1071
+ let [i] = e.initial.target;
1072
+ isHistoryNode(i) || (r.add(i), n.add(i)), addDescendantStatesToEnter(i, t, n, r), addProperAncestorStatesToEnter(i, e, r, t, n);
1073
+ } else if (e.type === "parallel") for (let i of getChildren(e).filter((e) => !isHistoryNode(e))) [...r].some((e) => isDescendant(e, i)) || (isHistoryNode(i) || (r.add(i), n.add(i)), addDescendantStatesToEnter(i, t, n, r));
1074
+ }
1075
+ function addAncestorStatesToEnter(e, t, n, r, i) {
1076
+ for (let a of r) if ((!i || isDescendant(a, i)) && e.add(a), a.type === "parallel") for (let r of getChildren(a).filter((e) => !isHistoryNode(e))) [...e].some((e) => isDescendant(e, r)) || (e.add(r), addDescendantStatesToEnter(r, t, n, e));
1077
+ }
1078
+ function addProperAncestorStatesToEnter(e, t, n, r, i) {
1079
+ addAncestorStatesToEnter(n, r, i, getProperAncestors(e, t));
1080
+ }
1081
+ function exitStates(e, t, n, r, i, a, o, s) {
1082
+ let c = e, l = computeExitSet(r, i, a);
1083
+ l.sort((e, t) => t.order - e.order);
1084
+ let u;
1085
+ for (let e of l) for (let t of getHistoryNodes(e)) {
1086
+ let n;
1087
+ n = t.history === "deep" ? (t) => isAtomicStateNode(t) && isDescendant(t, e) : (t) => t.parent === e, u ??= { ...a }, u[t.id] = Array.from(i).filter(n);
1088
+ }
1089
+ for (let e of l) c = resolveActionsAndContext(c, t, n, [...e.exit, ...e.invoke.map((e) => stopChild(e.id))], o, void 0), i.delete(e);
1090
+ return [c, u || a];
1091
+ }
1092
+ function getAction(e, t) {
1093
+ return e.implementations.actions[t];
1094
+ }
1095
+ function resolveAndExecuteActionsWithContext(e, t, n, r, i, a) {
1096
+ let { machine: o } = e, s = e;
1097
+ for (let e of r) {
1098
+ let r = typeof e == "function", c = r ? e : getAction(o, typeof e == "string" ? e : e.type), l = {
1099
+ context: s.context,
1100
+ event: t,
1101
+ self: n.self,
1102
+ system: n.system
1103
+ }, u = r || typeof e == "string" ? void 0 : "params" in e ? typeof e.params == "function" ? e.params({
1104
+ context: s.context,
1105
+ event: t
1106
+ }) : e.params : void 0;
1107
+ if (!c || !("resolve" in c)) {
1108
+ n.actionExecutor({
1109
+ type: typeof e == "string" ? e : typeof e == "object" ? e.type : e.name || "(anonymous)",
1110
+ info: l,
1111
+ params: u,
1112
+ exec: c
1113
+ });
1114
+ continue;
1115
+ }
1116
+ let d = c, [f, p, m] = d.resolve(n, s, l, u, c, i);
1117
+ s = f, "retryResolve" in d && a?.push([d, p]), "execute" in d && n.actionExecutor({
1118
+ type: d.type,
1119
+ info: l,
1120
+ params: p,
1121
+ exec: d.execute.bind(null, n, p)
1122
+ }), m && (s = resolveAndExecuteActionsWithContext(s, t, n, m, i, a));
1123
+ }
1124
+ return s;
1125
+ }
1126
+ function resolveActionsAndContext(e, t, n, r, i, a) {
1127
+ let o = a ? [] : void 0, s = resolveAndExecuteActionsWithContext(e, t, n, r, {
1128
+ internalQueue: i,
1129
+ deferredActorIds: a
1130
+ }, o);
1131
+ return o?.forEach(([e, t]) => {
1132
+ e.retryResolve(n, s, t);
1133
+ }), s;
1134
+ }
1135
+ function macrostep(e, t, n, r) {
1136
+ let i = e, a = [];
1137
+ function addMicrostep(e, t, r) {
1138
+ n.system._sendInspectionEvent({
1139
+ type: "@xstate.microstep",
1140
+ actorRef: n.self,
1141
+ event: t,
1142
+ snapshot: e[0],
1143
+ _transitions: r
1144
+ }), a.push(e);
1145
+ }
1146
+ if (t.type === "xstate.stop") return i = cloneMachineSnapshot(stopChildren(i, t, n), { status: "stopped" }), addMicrostep([i, []], t, []), {
1147
+ snapshot: i,
1148
+ microsteps: a
1149
+ };
1150
+ let o = t;
1151
+ if (o.type !== u) {
1152
+ let t = o, s = isErrorActorEvent(t), c = selectTransitions(t, i);
1153
+ if (s && !c.length) return i = cloneMachineSnapshot(e, {
1154
+ status: "error",
1155
+ error: t.error
1156
+ }), addMicrostep([i, []], t, []), {
1157
+ snapshot: i,
1158
+ microsteps: a
1159
+ };
1160
+ let l = microstep(c, e, n, o, !1, r);
1161
+ i = l[0], addMicrostep(l, t, c);
1162
+ }
1163
+ let s = !0, c = e.machine.options?.maxIterations ?? Infinity, l = 0;
1164
+ for (; i.status === "active";) {
1165
+ if (l++, l > c) throw Error(`Infinite loop detected: the machine has processed more than ${c} microsteps without reaching a stable state. This usually happens when there's a cycle of transitions (e.g., eventless transitions or raised events causing state A -> B -> C -> A).`);
1166
+ let e = s ? selectEventlessTransitions(i, o) : [], t = e.length ? i : void 0;
1167
+ if (!e.length) {
1168
+ if (!r.length) break;
1169
+ o = r.shift(), e = selectTransitions(o, i);
1170
+ }
1171
+ let a = microstep(e, i, n, o, !1, r);
1172
+ i = a[0], s = i !== t, addMicrostep(a, o, e);
1173
+ }
1174
+ return i.status !== "active" && stopChildren(i, o, n), {
1175
+ snapshot: i,
1176
+ microsteps: a
1177
+ };
1178
+ }
1179
+ function stopChildren(e, t, n) {
1180
+ return resolveActionsAndContext(e, t, n, Object.values(e.children).map((e) => stopChild(e)), [], void 0);
1181
+ }
1182
+ function selectTransitions(e, t) {
1183
+ return t.machine.getTransitionData(t, e);
1184
+ }
1185
+ function selectEventlessTransitions(e, t) {
1186
+ let n = /* @__PURE__ */ new Set(), r = e._nodes.filter(isAtomicStateNode);
1187
+ for (let i of r) loop: for (let r of [i].concat(getProperAncestors(i, void 0))) if (r.always) {
1188
+ for (let i of r.always) if (i.guard === void 0 || evaluateGuard(i.guard, e.context, t, e)) {
1189
+ n.add(i);
1190
+ break loop;
1191
+ }
1192
+ }
1193
+ return removeConflictingTransitions(Array.from(n), new Set(e._nodes), e.historyValue);
1194
+ }
1195
+ function resolveStateValue(e, t) {
1196
+ return getStateValue(e, [...getAllStateNodes(getStateNodes(e, t))]);
1197
+ }
1198
+ function isMachineSnapshot(e) {
1199
+ return !!e && typeof e == "object" && "machine" in e && "value" in e;
1200
+ }
1201
+ var _ = function matches(e) {
1202
+ return matchesState(e, this.value);
1203
+ }, v = function hasTag(e) {
1204
+ return this.tags.has(e);
1205
+ }, y = function can(e) {
1206
+ let t = this.machine.getTransitionData(this, e);
1207
+ return !!t?.length && t.some((e) => e.target !== void 0 || e.actions.length);
1208
+ }, b = function toJSON() {
1209
+ let { _nodes: e, tags: t, machine: n, getMeta: r, toJSON: i, can: a, hasTag: o, matches: s, ...c } = this;
1210
+ return {
1211
+ ...c,
1212
+ tags: Array.from(t)
1213
+ };
1214
+ }, x = function getMeta() {
1215
+ return this._nodes.reduce((e, t) => (t.meta !== void 0 && (e[t.id] = t.meta), e), {});
1216
+ };
1217
+ function createMachineSnapshot(e, t) {
1218
+ return {
1219
+ status: e.status,
1220
+ output: e.output,
1221
+ error: e.error,
1222
+ machine: t,
1223
+ context: e.context,
1224
+ _nodes: e._nodes,
1225
+ value: getStateValue(t.root, e._nodes),
1226
+ tags: new Set(e._nodes.flatMap((e) => e.tags)),
1227
+ children: e.children,
1228
+ historyValue: e.historyValue || {},
1229
+ matches: _,
1230
+ hasTag: v,
1231
+ can: y,
1232
+ getMeta: x,
1233
+ toJSON: b
1234
+ };
1235
+ }
1236
+ function cloneMachineSnapshot(e, t = {}) {
1237
+ return createMachineSnapshot({
1238
+ ...e,
1239
+ ...t
1240
+ }, e.machine);
1241
+ }
1242
+ function serializeHistoryValue(e) {
1243
+ if (typeof e != "object" || !e) return {};
1244
+ let t = {};
1245
+ for (let n in e) {
1246
+ let r = e[n];
1247
+ Array.isArray(r) && (t[n] = r.map((e) => ({ id: e.id })));
1248
+ }
1249
+ return t;
1250
+ }
1251
+ function getPersistedSnapshot(e, t) {
1252
+ let { _nodes: n, tags: r, machine: i, children: a, context: o, can: s, hasTag: c, matches: l, getMeta: u, toJSON: d, ...f } = e, p = {};
1253
+ for (let e in a) {
1254
+ let n = a[e];
1255
+ p[e] = {
1256
+ snapshot: n.getPersistedSnapshot(t),
1257
+ src: n.src,
1258
+ systemId: n.systemId,
1259
+ syncSnapshot: n._syncSnapshot
1260
+ };
1261
+ }
1262
+ return {
1263
+ ...f,
1264
+ context: persistContext(o),
1265
+ children: p,
1266
+ historyValue: serializeHistoryValue(f.historyValue)
1267
+ };
1268
+ }
1269
+ function persistContext(e) {
1270
+ let t;
1271
+ for (let n in e) {
1272
+ let r = e[n];
1273
+ if (r && typeof r == "object") if ("sessionId" in r && "send" in r && "ref" in r) t ??= Array.isArray(e) ? e.slice() : { ...e }, t[n] = {
1274
+ xstate$$type: 1,
1275
+ id: r.id
1276
+ };
1277
+ else {
1278
+ let i = persistContext(r);
1279
+ i !== r && (t ??= Array.isArray(e) ? e.slice() : { ...e }, t[n] = i);
1280
+ }
1281
+ }
1282
+ return t ?? e;
1283
+ }
1284
+ function resolveRaise(e, t, n, r, { event: i, id: a, delay: o }, { internalQueue: s }) {
1285
+ let c = t.machine.implementations.delays;
1286
+ if (typeof i == "string") throw Error(`Only event objects may be used with raise; use raise({ type: "${i}" }) instead`);
1287
+ let l = typeof i == "function" ? i(n, r) : i, u;
1288
+ if (typeof o == "string") {
1289
+ let e = c && c[o];
1290
+ u = typeof e == "function" ? e(n, r) : e;
1291
+ } else u = typeof o == "function" ? o(n, r) : o;
1292
+ return typeof u != "number" && s.push(l), [
1293
+ t,
1294
+ {
1295
+ event: l,
1296
+ id: a,
1297
+ delay: u
1298
+ },
1299
+ void 0
1300
+ ];
1301
+ }
1302
+ function executeRaise(e, t) {
1303
+ let { event: n, delay: r, id: i } = t;
1304
+ if (typeof r == "number") {
1305
+ e.defer(() => {
1306
+ let t = e.self;
1307
+ e.system.scheduler.schedule(t, t, n, r, i);
1308
+ });
1309
+ return;
1310
+ }
1311
+ }
1312
+ function raise(e, t) {
1313
+ function raise(e, t) {}
1314
+ return raise.type = "xstate.raise", raise.event = e, raise.id = t?.id, raise.delay = t?.delay, raise.resolve = resolveRaise, raise.execute = executeRaise, raise;
1315
+ }
1316
+ var S = /* #__PURE__ */ new WeakMap();
1317
+ function fromCallback(e) {
1318
+ return {
1319
+ config: e,
1320
+ start: (t, n) => {
1321
+ let { self: r, system: i, emit: a } = n, o = {
1322
+ receivers: void 0,
1323
+ dispose: void 0
1324
+ };
1325
+ S.set(r, o), o.dispose = e({
1326
+ input: t.input,
1327
+ system: i,
1328
+ self: r,
1329
+ sendBack: (e) => {
1330
+ r.getSnapshot().status !== "stopped" && r._parent && i._relay(r, r._parent, e);
1331
+ },
1332
+ receive: (e) => {
1333
+ o.receivers ??= /* @__PURE__ */ new Set(), o.receivers.add(e);
1334
+ },
1335
+ emit: a
1336
+ });
1337
+ },
1338
+ transition: (e, t, n) => {
1339
+ let r = S.get(n.self);
1340
+ return t.type === "xstate.stop" ? (e = {
1341
+ ...e,
1342
+ status: "stopped",
1343
+ error: void 0
1344
+ }, S.delete(n.self), r.receivers?.clear(), r.dispose?.(), e) : (r.receivers?.forEach((e) => e(t)), e);
1345
+ },
1346
+ getInitialSnapshot: (e, t) => ({
1347
+ status: "active",
1348
+ output: void 0,
1349
+ error: void 0,
1350
+ input: t
1351
+ }),
1352
+ getPersistedSnapshot: (e) => e,
1353
+ restoreSnapshot: (e) => e
1354
+ };
1355
+ }
1356
+ var C = "xstate.promise.resolve", w = "xstate.promise.reject", T = /* @__PURE__ */ new WeakMap();
1357
+ function fromPromise(e) {
1358
+ return {
1359
+ config: e,
1360
+ transition: (e, t, n) => {
1361
+ if (e.status !== "active") return e;
1362
+ switch (t.type) {
1363
+ case C: {
1364
+ let n = t.data;
1365
+ return {
1366
+ ...e,
1367
+ status: "done",
1368
+ output: n,
1369
+ input: void 0
1370
+ };
1371
+ }
1372
+ case w: return {
1373
+ ...e,
1374
+ status: "error",
1375
+ error: t.data,
1376
+ input: void 0
1377
+ };
1378
+ case d: return T.get(n.self)?.abort(), T.delete(n.self), {
1379
+ ...e,
1380
+ status: "stopped",
1381
+ input: void 0
1382
+ };
1383
+ default: return e;
1384
+ }
1385
+ },
1386
+ start: (t, { self: n, system: r, emit: i }) => {
1387
+ if (t.status !== "active") return;
1388
+ let a = new AbortController();
1389
+ T.set(n, a), Promise.resolve(e({
1390
+ input: t.input,
1391
+ system: r,
1392
+ self: n,
1393
+ signal: a.signal,
1394
+ emit: i
1395
+ })).then((e) => {
1396
+ n.getSnapshot().status === "active" && (T.delete(n), r._relay(n, n, {
1397
+ type: C,
1398
+ data: e
1399
+ }));
1400
+ }, (e) => {
1401
+ n.getSnapshot().status === "active" && (T.delete(n), r._relay(n, n, {
1402
+ type: w,
1403
+ data: e
1404
+ }));
1405
+ });
1406
+ },
1407
+ getInitialSnapshot: (e, t) => ({
1408
+ status: "active",
1409
+ output: void 0,
1410
+ error: void 0,
1411
+ input: t
1412
+ }),
1413
+ getPersistedSnapshot: (e) => e,
1414
+ restoreSnapshot: (e) => e
1415
+ };
1416
+ }
1417
+ //#endregion
1418
+ //#region ../../node_modules/.pnpm/xstate@5.32.4/node_modules/xstate/dist/assign-29f23f4d.esm.js
1419
+ function createSpawner(e, { machine: t, context: n }, r, i) {
1420
+ let spawn = (a, o) => {
1421
+ if (typeof a == "string") {
1422
+ let s = resolveReferencedActor(t, a);
1423
+ if (!s) throw Error(`Actor logic '${a}' not implemented in machine '${t.id}'`);
1424
+ let c = createActor(s, {
1425
+ id: o?.id,
1426
+ parent: e.self,
1427
+ syncSnapshot: o?.syncSnapshot,
1428
+ input: typeof o?.input == "function" ? o.input({
1429
+ context: n,
1430
+ event: r,
1431
+ self: e.self
1432
+ }) : o?.input,
1433
+ src: a,
1434
+ systemId: o?.systemId
1435
+ });
1436
+ return i[c.id] = c, c;
1437
+ } else return createActor(a, {
1438
+ id: o?.id,
1439
+ parent: e.self,
1440
+ syncSnapshot: o?.syncSnapshot,
1441
+ input: o?.input,
1442
+ src: a,
1443
+ systemId: o?.systemId
1444
+ });
1445
+ };
1446
+ return (t, n) => {
1447
+ let r = spawn(t, n);
1448
+ return i[r.id] = r, e.defer(() => {
1449
+ r._processingStatus !== h.Stopped && r.start();
1450
+ }), r;
1451
+ };
1452
+ }
1453
+ function resolveAssign(e, t, n, r, { assignment: i }) {
1454
+ if (!t.context) throw Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");
1455
+ let a = {}, o = {
1456
+ context: t.context,
1457
+ event: n.event,
1458
+ spawn: createSpawner(e, t, n.event, a),
1459
+ self: e.self,
1460
+ system: e.system
1461
+ }, s = {};
1462
+ if (typeof i == "function") s = i(o, r);
1463
+ else for (let e of Object.keys(i)) {
1464
+ let t = i[e];
1465
+ s[e] = typeof t == "function" ? t(o, r) : t;
1466
+ }
1467
+ return [
1468
+ cloneMachineSnapshot(t, {
1469
+ context: Object.assign({}, t.context, s),
1470
+ children: Object.keys(a).length ? {
1471
+ ...t.children,
1472
+ ...a
1473
+ } : t.children
1474
+ }),
1475
+ void 0,
1476
+ void 0
1477
+ ];
1478
+ }
1479
+ function assign(e) {
1480
+ function assign(e, t) {}
1481
+ return assign.type = "xstate.assign", assign.assignment = e, assign.resolve = resolveAssign, assign;
1482
+ }
1483
+ //#endregion
1484
+ //#region ../../node_modules/.pnpm/xstate@5.32.4/node_modules/xstate/dist/StateMachine-5f345bba.esm.js
1485
+ var E = /* @__PURE__ */ new WeakMap();
1486
+ function memo$1(e, t, n) {
1487
+ let r = E.get(e);
1488
+ return r ? t in r || (r[t] = n()) : (r = { [t]: n() }, E.set(e, r)), r[t];
1489
+ }
1490
+ e(memo$1, "memo");
1491
+ var D = {}, toSerializableAction = (e) => typeof e == "string" ? { type: e } : typeof e == "function" ? "resolve" in e ? { type: e.type } : { type: e.name } : e, O = class StateNode {
1492
+ constructor(e, t) {
1493
+ if (this.config = e, this.key = void 0, this.id = void 0, this.type = void 0, this.path = void 0, this.states = void 0, this.history = void 0, this.entry = void 0, this.exit = void 0, this.parent = void 0, this.machine = void 0, this.meta = void 0, this.output = void 0, this.order = -1, this.description = void 0, this.tags = [], this.transitions = void 0, this.always = void 0, this.parent = t._parent, this.key = t._key, this.machine = t._machine, this.path = this.parent ? this.parent.path.concat(this.key) : [], this.id = this.config.id || [this.machine.id, ...this.path].join("."), this.type = this.config.type || (this.config.states && Object.keys(this.config.states).length ? "compound" : this.config.history ? "history" : "atomic"), this.description = this.config.description, this.order = this.machine.idMap.size, this.machine.idMap.set(this.id, this), this.states = this.config.states ? mapValues(this.config.states, (e, t) => new StateNode(e, {
1494
+ _parent: this,
1495
+ _key: t,
1496
+ _machine: this.machine
1497
+ })) : D, this.type === "compound" && !this.config.initial) throw Error(`No initial state specified for compound state node "#${this.id}". Try adding { initial: "${Object.keys(this.states)[0]}" } to the state config.`);
1498
+ this.history = this.config.history === !0 ? "shallow" : this.config.history || !1, this.entry = toArray(this.config.entry).slice(), this.exit = toArray(this.config.exit).slice(), this.meta = this.config.meta, this.output = this.type === "final" || !this.parent ? this.config.output : void 0, this.tags = toArray(e.tags).slice();
1499
+ }
1500
+ _initialize() {
1501
+ this.transitions = formatTransitions(this), this.config.always && (this.always = toTransitionConfigArray(this.config.always).map((e) => formatTransition(this, "", e))), Object.keys(this.states).forEach((e) => {
1502
+ this.states[e]._initialize();
1503
+ });
1504
+ }
1505
+ get definition() {
1506
+ return {
1507
+ id: this.id,
1508
+ key: this.key,
1509
+ version: this.machine.version,
1510
+ type: this.type,
1511
+ initial: this.initial ? {
1512
+ target: this.initial.target,
1513
+ source: this,
1514
+ actions: this.initial.actions.map(toSerializableAction),
1515
+ eventType: null,
1516
+ reenter: !1,
1517
+ toJSON: () => ({
1518
+ target: this.initial.target.map((e) => `#${e.id}`),
1519
+ source: `#${this.id}`,
1520
+ actions: this.initial.actions.map(toSerializableAction),
1521
+ eventType: null
1522
+ })
1523
+ } : void 0,
1524
+ history: this.history,
1525
+ states: mapValues(this.states, (e) => e.definition),
1526
+ on: this.on,
1527
+ transitions: [...this.transitions.values()].flat().map((e) => ({
1528
+ ...e,
1529
+ actions: e.actions.map(toSerializableAction)
1530
+ })),
1531
+ entry: this.entry.map(toSerializableAction),
1532
+ exit: this.exit.map(toSerializableAction),
1533
+ meta: this.meta,
1534
+ order: this.order || -1,
1535
+ output: this.output,
1536
+ invoke: this.invoke,
1537
+ description: this.description,
1538
+ tags: this.tags
1539
+ };
1540
+ }
1541
+ toJSON() {
1542
+ return this.definition;
1543
+ }
1544
+ get invoke() {
1545
+ return memo$1(this, "invoke", () => toArray(this.config.invoke).map((e, t) => {
1546
+ let { src: n, systemId: r } = e, i = e.id ?? createInvokeId(this.id, t), a = typeof n == "string" ? n : `xstate.invoke.${createInvokeId(this.id, t)}`;
1547
+ return {
1548
+ ...e,
1549
+ src: a,
1550
+ id: i,
1551
+ systemId: r,
1552
+ toJSON() {
1553
+ let { onDone: t, onError: n, ...r } = e;
1554
+ return {
1555
+ ...r,
1556
+ type: "xstate.invoke",
1557
+ src: a,
1558
+ id: i
1559
+ };
1560
+ }
1561
+ };
1562
+ }));
1563
+ }
1564
+ get on() {
1565
+ return memo$1(this, "on", () => [...this.transitions].flatMap(([e, t]) => t.map((t) => [e, t])).reduce((e, [t, n]) => (e[t] = e[t] || [], e[t].push(n), e), {}));
1566
+ }
1567
+ get after() {
1568
+ return memo$1(this, "delayedTransitions", () => getDelayedTransitions(this));
1569
+ }
1570
+ get initial() {
1571
+ return memo$1(this, "initial", () => formatInitialTransition(this, this.config.initial));
1572
+ }
1573
+ next(e, t) {
1574
+ let n = t.type, r = [], i, a = memo$1(this, `candidates-${n}`, () => getCandidates(this, n));
1575
+ for (let o of a) {
1576
+ let { guard: a } = o, s = e.context, c = !1;
1577
+ try {
1578
+ c = !a || evaluateGuard(a, s, t, e);
1579
+ } catch (e) {
1580
+ let t = typeof a == "string" ? a : typeof a == "object" ? a.type : void 0;
1581
+ throw Error(`Unable to evaluate guard ${t ? `'${t}' ` : ""}in transition for event '${n}' in state node '${this.id}':\n${e.message}`);
1582
+ }
1583
+ if (c) {
1584
+ r.push(...o.actions), i = o;
1585
+ break;
1586
+ }
1587
+ }
1588
+ return i ? [i] : void 0;
1589
+ }
1590
+ get events() {
1591
+ return memo$1(this, "events", () => {
1592
+ let { states: e } = this, t = new Set(this.ownEvents);
1593
+ if (e) for (let n of Object.keys(e)) {
1594
+ let r = e[n];
1595
+ if (r.states) for (let e of r.events) t.add(`${e}`);
1596
+ }
1597
+ return Array.from(t);
1598
+ });
1599
+ }
1600
+ get ownEvents() {
1601
+ let e = Object.keys(Object.fromEntries(this.transitions)), t = new Set(e.filter((e) => this.transitions.get(e).some((e) => !(!e.target && !e.actions.length && !e.reenter))));
1602
+ return Array.from(t);
1603
+ }
1604
+ }, k = class StateMachine {
1605
+ constructor(e, t) {
1606
+ this.config = e, this.version = void 0, this.schemas = void 0, this.implementations = void 0, this.options = void 0, this.__xstatenode = !0, this.idMap = /* @__PURE__ */ new Map(), this.root = void 0, this.id = void 0, this.states = void 0, this.events = void 0, this.id = e.id || "(machine)", this.implementations = {
1607
+ actors: t?.actors ?? {},
1608
+ actions: t?.actions ?? {},
1609
+ delays: t?.delays ?? {},
1610
+ guards: t?.guards ?? {}
1611
+ }, this.version = this.config.version, this.schemas = this.config.schemas, this.options = {
1612
+ maxIterations: Infinity,
1613
+ ...this.config.options
1614
+ }, this.transition = this.transition.bind(this), this.getInitialSnapshot = this.getInitialSnapshot.bind(this), this.getPersistedSnapshot = this.getPersistedSnapshot.bind(this), this.restoreSnapshot = this.restoreSnapshot.bind(this), this.start = this.start.bind(this), this.root = new O(e, {
1615
+ _key: this.id,
1616
+ _machine: this
1617
+ }), this.root._initialize(), formatRouteTransitions(this.root), this.states = this.root.states, this.events = this.root.events;
1618
+ }
1619
+ provide(e) {
1620
+ let { actions: t, guards: n, actors: r, delays: i } = this.implementations;
1621
+ return new StateMachine(this.config, {
1622
+ actions: {
1623
+ ...t,
1624
+ ...e.actions
1625
+ },
1626
+ guards: {
1627
+ ...n,
1628
+ ...e.guards
1629
+ },
1630
+ actors: {
1631
+ ...r,
1632
+ ...e.actors
1633
+ },
1634
+ delays: {
1635
+ ...i,
1636
+ ...e.delays
1637
+ }
1638
+ });
1639
+ }
1640
+ resolveState(e) {
1641
+ let t = resolveStateValue(this.root, e.value), n = getAllStateNodes(getStateNodes(this.root, t));
1642
+ return createMachineSnapshot({
1643
+ _nodes: [...n],
1644
+ context: e.context || {},
1645
+ children: {},
1646
+ status: isInFinalState(n, this.root) ? "done" : e.status || "active",
1647
+ output: e.output,
1648
+ error: e.error,
1649
+ historyValue: e.historyValue
1650
+ }, this);
1651
+ }
1652
+ transition(e, t, n) {
1653
+ return macrostep(e, t, n, []).snapshot;
1654
+ }
1655
+ microstep(e, t, n) {
1656
+ return macrostep(e, t, n, []).microsteps.map(([e]) => e);
1657
+ }
1658
+ getTransitionData(e, t) {
1659
+ return transitionNode(this.root, e.value, e, t) || [];
1660
+ }
1661
+ _getPreInitialState(e, t, n) {
1662
+ let { context: r } = this.config, i = createMachineSnapshot({
1663
+ context: typeof r != "function" && r ? r : {},
1664
+ _nodes: [this.root],
1665
+ children: {},
1666
+ status: "active"
1667
+ }, this);
1668
+ if (typeof r == "function") {
1669
+ let assignment = ({ spawn: e, event: t, self: n }) => r({
1670
+ spawn: e,
1671
+ input: t.input,
1672
+ self: n
1673
+ });
1674
+ return resolveActionsAndContext(i, t, e, [assign(assignment)], n, void 0);
1675
+ }
1676
+ return i;
1677
+ }
1678
+ getInitialSnapshot(e, t) {
1679
+ let n = createInitEvent(t), r = [], i = this._getPreInitialState(e, n, r), [a] = initialMicrostep(this.root, i, e, n, r), { snapshot: o } = macrostep(a, n, e, r);
1680
+ return o;
1681
+ }
1682
+ start(e) {
1683
+ Object.values(e.children).forEach((e) => {
1684
+ e.getSnapshot().status === "active" && e.start();
1685
+ });
1686
+ }
1687
+ getStateNodeById(e) {
1688
+ let t = toStatePath(e), n = t.slice(1), r = isStateId(t[0]) ? t[0].slice(1) : t[0], i = this.idMap.get(r);
1689
+ if (!i) throw Error(`Child state node '#${r}' does not exist on machine '${this.id}'`);
1690
+ return getStateNodeByPath(i, n);
1691
+ }
1692
+ get definition() {
1693
+ return this.root.definition;
1694
+ }
1695
+ toJSON() {
1696
+ return this.definition;
1697
+ }
1698
+ getPersistedSnapshot(e, t) {
1699
+ return getPersistedSnapshot(e, t);
1700
+ }
1701
+ restoreSnapshot(e, t) {
1702
+ let n = {}, r = e.children;
1703
+ Object.keys(r).forEach((e) => {
1704
+ let i = r[e], a = i.snapshot, o = i.src, s = typeof o == "string" ? resolveReferencedActor(this, o) : o;
1705
+ if (!s) return;
1706
+ let c = createActor(s, {
1707
+ id: e,
1708
+ parent: t.self,
1709
+ syncSnapshot: i.syncSnapshot,
1710
+ snapshot: a,
1711
+ src: o,
1712
+ systemId: i.systemId
1713
+ });
1714
+ n[e] = c;
1715
+ });
1716
+ function resolveHistoryReferencedState(e, t) {
1717
+ if (t instanceof O) return t;
1718
+ try {
1719
+ return e.machine.getStateNodeById(t.id);
1720
+ } catch {}
1721
+ }
1722
+ function reviveHistoryValue(e, t) {
1723
+ if (!t || typeof t != "object") return {};
1724
+ let n = {};
1725
+ for (let r in t) {
1726
+ let i = t[r];
1727
+ for (let t of i) {
1728
+ let i = resolveHistoryReferencedState(e, t);
1729
+ i && (n[r] ??= [], n[r].push(i));
1730
+ }
1731
+ }
1732
+ return n;
1733
+ }
1734
+ let i = reviveHistoryValue(this.root, e.historyValue), a = createMachineSnapshot({
1735
+ ...e,
1736
+ children: n,
1737
+ _nodes: Array.from(getAllStateNodes(getStateNodes(this.root, e.value))),
1738
+ historyValue: i
1739
+ }, this), o = /* @__PURE__ */ new Set();
1740
+ function reviveContext(e, t) {
1741
+ if (!o.has(e)) {
1742
+ o.add(e);
1743
+ for (let n in e) {
1744
+ let r = e[n];
1745
+ if (r && typeof r == "object") {
1746
+ if ("xstate$$type" in r && r.xstate$$type === 1) {
1747
+ e[n] = t[r.id];
1748
+ continue;
1749
+ }
1750
+ reviveContext(r, t);
1751
+ }
1752
+ }
1753
+ }
1754
+ }
1755
+ return reviveContext(a.context, n), a;
1756
+ }
1757
+ };
1758
+ //#endregion
1759
+ //#region ../../node_modules/.pnpm/xstate@5.32.4/node_modules/xstate/dist/log-79409d72.esm.js
1760
+ function resolveEmit(e, t, n, r, { event: i }) {
1761
+ return [
1762
+ t,
1763
+ { event: typeof i == "function" ? i(n, r) : i },
1764
+ void 0
1765
+ ];
1766
+ }
1767
+ function executeEmit(e, { event: t }) {
1768
+ e.defer(() => e.emit(t));
1769
+ }
1770
+ function emit(e) {
1771
+ function emit(e, t) {}
1772
+ return emit.type = "xstate.emit", emit.event = e, emit.resolve = resolveEmit, emit.execute = executeEmit, emit;
1773
+ }
1774
+ var A = /*#__PURE__*/ function(e) {
1775
+ return e.Parent = "#_parent", e.Internal = "#_internal", e;
1776
+ }({});
1777
+ function resolveSendTo(e, t, n, r, { to: i, event: a, id: o, delay: s }, c) {
1778
+ let l = t.machine.implementations.delays;
1779
+ if (typeof a == "string") throw Error(`Only event objects may be used with sendTo; use sendTo({ type: "${a}" }) instead`);
1780
+ let u = typeof a == "function" ? a(n, r) : a, d;
1781
+ if (typeof s == "string") {
1782
+ let e = l && l[s];
1783
+ d = typeof e == "function" ? e(n, r) : e;
1784
+ } else d = typeof s == "function" ? s(n, r) : s;
1785
+ let f = typeof i == "function" ? i(n, r) : i, p;
1786
+ if (typeof f == "string") {
1787
+ if (p = f === A.Parent ? e.self._parent : f === A.Internal ? e.self : f.startsWith("#_") ? t.children[f.slice(2)] : c.deferredActorIds?.includes(f) ? f : t.children[f], !p) throw Error(`Unable to send event to actor '${f}' from machine '${t.machine.id}'.`);
1788
+ } else p = f || e.self;
1789
+ return [
1790
+ t,
1791
+ {
1792
+ to: p,
1793
+ targetId: typeof f == "string" ? f : void 0,
1794
+ event: u,
1795
+ id: o,
1796
+ delay: d
1797
+ },
1798
+ void 0
1799
+ ];
1800
+ }
1801
+ function retryResolveSendTo(e, t, n) {
1802
+ typeof n.to == "string" && (n.to = t.children[n.to]);
1803
+ }
1804
+ function executeSendTo(e, t) {
1805
+ e.defer(() => {
1806
+ let { to: n, event: r, delay: i, id: a } = t;
1807
+ if (typeof i == "number") {
1808
+ e.system.scheduler.schedule(e.self, n, r, i, a);
1809
+ return;
1810
+ }
1811
+ e.system._relay(e.self, n, r.type === "xstate.error" ? createErrorActorEvent(e.self.id, r.data) : r);
1812
+ });
1813
+ }
1814
+ function sendTo(e, t, n) {
1815
+ function sendTo(e, t) {}
1816
+ return sendTo.type = "xstate.sendTo", sendTo.to = e, sendTo.event = t, sendTo.id = n?.id, sendTo.delay = n?.delay, sendTo.resolve = resolveSendTo, sendTo.retryResolve = retryResolveSendTo, sendTo.execute = executeSendTo, sendTo;
1817
+ }
1818
+ function sendParent(e, t) {
1819
+ return sendTo(A.Parent, e, t);
1820
+ }
1821
+ function resolveEnqueueActions(e, t, n, r, { collect: i }) {
1822
+ let a = [], o = function enqueue(e) {
1823
+ a.push(e);
1824
+ };
1825
+ return o.assign = (...e) => {
1826
+ a.push(assign(...e));
1827
+ }, o.cancel = (...e) => {
1828
+ a.push(cancel(...e));
1829
+ }, o.raise = (...e) => {
1830
+ a.push(raise(...e));
1831
+ }, o.sendTo = (...e) => {
1832
+ a.push(sendTo(...e));
1833
+ }, o.sendParent = (...e) => {
1834
+ a.push(sendParent(...e));
1835
+ }, o.spawnChild = (...e) => {
1836
+ a.push(spawnChild(...e));
1837
+ }, o.stopChild = (...e) => {
1838
+ a.push(stopChild(...e));
1839
+ }, o.emit = (...e) => {
1840
+ a.push(emit(...e));
1841
+ }, i({
1842
+ context: n.context,
1843
+ event: n.event,
1844
+ enqueue: o,
1845
+ check: (e) => evaluateGuard(e, t.context, n.event, t),
1846
+ self: e.self,
1847
+ system: e.system
1848
+ }, r), [
1849
+ t,
1850
+ void 0,
1851
+ a
1852
+ ];
1853
+ }
1854
+ function enqueueActions(e) {
1855
+ function enqueueActions(e, t) {}
1856
+ return enqueueActions.type = "xstate.enqueueActions", enqueueActions.collect = e, enqueueActions.resolve = resolveEnqueueActions, enqueueActions;
1857
+ }
1858
+ function resolveLog(e, t, n, r, { value: i, label: a }) {
1859
+ return [
1860
+ t,
1861
+ {
1862
+ value: typeof i == "function" ? i(n, r) : i,
1863
+ label: a
1864
+ },
1865
+ void 0
1866
+ ];
1867
+ }
1868
+ function executeLog({ logger: e }, { value: t, label: n }) {
1869
+ n ? e(n, t) : e(t);
1870
+ }
1871
+ function log(e = ({ context: e, event: t }) => ({
1872
+ context: e,
1873
+ event: t
1874
+ }), t) {
1875
+ function log(e, t) {}
1876
+ return log.type = "xstate.log", log.value = e, log.label = t, log.resolve = resolveLog, log.execute = executeLog, log;
1877
+ }
1878
+ //#endregion
1879
+ //#region ../../node_modules/.pnpm/xstate@5.32.4/node_modules/xstate/dist/xstate.esm.js
1880
+ function assertEvent(e, t) {
1881
+ let n = toArray(t);
1882
+ if (!n.some((t) => matchesEventDescriptor(e.type, t))) {
1883
+ let t = n.length === 1 ? `type matching "${n[0]}"` : `one of types matching "${n.join("\", \"")}"`;
1884
+ throw Error(`Expected event ${JSON.stringify(e)} to have ${t}`);
1885
+ }
1886
+ }
1887
+ function createMachine(e, t) {
1888
+ return new k(e, t);
1889
+ }
1890
+ function setup({ schemas: e, actors: t, actions: n, guards: r, delays: i }) {
1891
+ return {
1892
+ assign,
1893
+ sendTo,
1894
+ raise,
1895
+ log,
1896
+ cancel,
1897
+ stopChild,
1898
+ enqueueActions,
1899
+ emit,
1900
+ spawnChild,
1901
+ createStateConfig: (e) => e,
1902
+ createAction: (e) => e,
1903
+ createMachine: (a) => createMachine({
1904
+ ...a,
1905
+ schemas: e
1906
+ }, {
1907
+ actors: t,
1908
+ actions: n,
1909
+ guards: r,
1910
+ delays: i
1911
+ }),
1912
+ extend: (a) => setup({
1913
+ schemas: e,
1914
+ actors: t,
1915
+ actions: {
1916
+ ...n,
1917
+ ...a.actions
1918
+ },
1919
+ guards: {
1920
+ ...r,
1921
+ ...a.guards
1922
+ },
1923
+ delays: {
1924
+ ...i,
1925
+ ...a.delays
1926
+ }
1927
+ })
1928
+ };
1929
+ }
1930
+ //#endregion
1931
+ //#region ../../node_modules/.pnpm/@xstate+react@6.1.0_@types+react@19.2.17_react@19.2.7_xstate@5.32.4/node_modules/@xstate/react/dist/xstate-react.esm.js
1932
+ var forEachActor = (e, t) => {
1933
+ t(e);
1934
+ let n = e.getSnapshot().children;
1935
+ n && Object.values(n).forEach((e) => {
1936
+ forEachActor(e, t);
1937
+ });
1938
+ };
1939
+ function stopRootWithRehydration(e) {
1940
+ let t = [];
1941
+ forEachActor(e, (e) => {
1942
+ t.push([e, e.getSnapshot()]), e.observers = /* @__PURE__ */ new Set();
1943
+ });
1944
+ let n = e.system.getSnapshot?.();
1945
+ e.stop(), e.system._snapshot = n, t.forEach(([e, t]) => {
1946
+ e._processingStatus = 0, e._snapshot = t;
1947
+ });
1948
+ }
1949
+ function useIdleActorRef(e, ...[t]) {
1950
+ let [[n, r], a] = i(() => {
1951
+ let n = createActor(e, t);
1952
+ return [e.config, n];
1953
+ });
1954
+ if (e.config !== n) {
1955
+ let n = createActor(e, {
1956
+ ...t,
1957
+ snapshot: r.getPersistedSnapshot({ __unsafeAllowInlineActors: !0 })
1958
+ });
1959
+ a([e.config, n]), r = n;
1960
+ }
1961
+ return o(() => {
1962
+ r.logic.implementations = e.implementations;
1963
+ }), r;
1964
+ }
1965
+ function useActorRef(e, ...[t, r]) {
1966
+ let i = useIdleActorRef(e, t);
1967
+ return n(() => {
1968
+ if (!r) return;
1969
+ let e = i.subscribe(toObserver(r));
1970
+ return () => {
1971
+ e.unsubscribe();
1972
+ };
1973
+ }, [r]), n(() => (i.start(), () => {
1974
+ stopRootWithRehydration(i);
1975
+ }), [i]), i;
1976
+ }
1977
+ function defaultCompare(e, t) {
1978
+ return e === t;
1979
+ }
1980
+ function useSelector(e, n, r = defaultCompare) {
1981
+ let i = t((t) => {
1982
+ if (!e) return () => {};
1983
+ let { unsubscribe: n } = e.subscribe({
1984
+ next: t,
1985
+ error: t
1986
+ });
1987
+ return n;
1988
+ }, [e]), o = t(() => {
1989
+ let t = e?.getSnapshot();
1990
+ if (t && "status" in t && t.status === "error") throw t.error;
1991
+ return t;
1992
+ }, [e]);
1993
+ return a(i, o, o, n, r);
1994
+ }
1995
+ //#endregion
1996
+ export { spawnChild as _, emit as a, sendTo as c, fromPromise as d, and as f, raise as g, or as h, setup as i, assign as l, not as m, useSelector as n, enqueueActions as o, cancel as p, assertEvent as r, log as s, useActorRef as t, fromCallback as u, stopChild as v };