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