@raphy-js/raph 1.0.0-dev.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/LICENSE +202 -0
  2. package/dist/api/Raph.d.ts +97 -0
  3. package/dist/api/RaphFacadeSession.d.ts +90 -0
  4. package/dist/api/RaphReactivityInstance.d.ts +72 -0
  5. package/dist/api/errors.d.ts +25 -0
  6. package/dist/api/types.d.ts +170 -0
  7. package/dist/core-CyilRD7s.js +1055 -0
  8. package/dist/core-ugchZNqC.cjs +1 -0
  9. package/dist/debug/api/Raph.cjs +1 -0
  10. package/dist/debug/api/Raph.js +421 -0
  11. package/dist/debug/api/RaphFacadeSession.cjs +1 -0
  12. package/dist/debug/api/RaphFacadeSession.js +306 -0
  13. package/dist/debug/api/RaphReactivityInstance.cjs +1 -0
  14. package/dist/debug/api/RaphReactivityInstance.js +149 -0
  15. package/dist/debug/api/errors.cjs +1 -0
  16. package/dist/debug/api/errors.js +17 -0
  17. package/dist/debug/api/types.cjs +1 -0
  18. package/dist/debug/api/types.js +1 -0
  19. package/dist/debug/path/DataPath.cjs +1 -0
  20. package/dist/debug/path/DataPath.js +394 -0
  21. package/dist/debug/path/PathRouter.cjs +1 -0
  22. package/dist/debug/path/PathRouter.js +86 -0
  23. package/dist/debug/path/RaphKernel.cjs +1 -0
  24. package/dist/debug/path/RaphKernel.js +687 -0
  25. package/dist/debug/path/data-path.types.cjs +1 -0
  26. package/dist/debug/path/data-path.types.js +1 -0
  27. package/dist/debug/path/data-path.utils.cjs +1 -0
  28. package/dist/debug/path/data-path.utils.js +56 -0
  29. package/dist/debug/path/derived/DerivedRegistry.cjs +1 -0
  30. package/dist/debug/path/derived/DerivedRegistry.js +157 -0
  31. package/dist/debug/path/derived/RaphDerivedHandle.cjs +1 -0
  32. package/dist/debug/path/derived/RaphDerivedHandle.js +125 -0
  33. package/dist/debug/path/derived/derived-collection.types.cjs +1 -0
  34. package/dist/debug/path/derived/derived-collection.types.js +1 -0
  35. package/dist/debug/path/derived/derived-collection.utils.cjs +1 -0
  36. package/dist/debug/path/derived/derived-collection.utils.js +179 -0
  37. package/dist/debug/path/derived/derived-strategy.types.cjs +1 -0
  38. package/dist/debug/path/derived/derived-strategy.types.js +1 -0
  39. package/dist/debug/path/derived/derived-strategy.utils.cjs +1 -0
  40. package/dist/debug/path/derived/derived-strategy.utils.js +20 -0
  41. package/dist/debug/path/meta/MetaController.cjs +1 -0
  42. package/dist/debug/path/meta/MetaController.js +214 -0
  43. package/dist/debug/path/meta/RaphMeta.cjs +1 -0
  44. package/dist/debug/path/meta/RaphMeta.js +68 -0
  45. package/dist/debug/path/meta/RaphMetaStore.cjs +1 -0
  46. package/dist/debug/path/meta/RaphMetaStore.js +184 -0
  47. package/dist/debug/path/meta/meta.types.cjs +1 -0
  48. package/dist/debug/path/meta/meta.types.js +1 -0
  49. package/dist/debug/path/path.types.cjs +1 -0
  50. package/dist/debug/path/path.types.js +1 -0
  51. package/dist/debug/path/pathSegmentKey.cjs +1 -0
  52. package/dist/debug/path/pathSegmentKey.js +12 -0
  53. package/dist/debug/path/storage/AdapterPathStore.cjs +1 -0
  54. package/dist/debug/path/storage/AdapterPathStore.js +133 -0
  55. package/dist/debug/path/storage/DefaultDataAdapter.cjs +1 -0
  56. package/dist/debug/path/storage/DefaultDataAdapter.js +356 -0
  57. package/dist/debug/path/storage/PathEventHub.cjs +1 -0
  58. package/dist/debug/path/storage/PathEventHub.js +148 -0
  59. package/dist/debug/path/storage/PathStore.cjs +1 -0
  60. package/dist/debug/path/storage/PathStore.js +326 -0
  61. package/dist/debug/path/storage/createDataDraft.cjs +1 -0
  62. package/dist/debug/path/storage/createDataDraft.js +71 -0
  63. package/dist/debug/path/storage/data-adapter.types.cjs +1 -0
  64. package/dist/debug/path/storage/data-adapter.types.js +1 -0
  65. package/dist/debug/reactivity/engine.cjs +1 -0
  66. package/dist/debug/reactivity/engine.js +1305 -0
  67. package/dist/debug/reactivity/reactive-object.cjs +1 -0
  68. package/dist/debug/reactivity/reactive-object.js +280 -0
  69. package/dist/debug/reactivity/scope.cjs +1 -0
  70. package/dist/debug/reactivity/scope.js +274 -0
  71. package/dist/debug/reactivity/types.cjs +1 -0
  72. package/dist/debug/reactivity/types.js +1 -0
  73. package/dist/debug/reactivity/watch.cjs +1 -0
  74. package/dist/debug/reactivity/watch.js +64 -0
  75. package/dist/debug/runtime/RaphRuntime.cjs +1 -0
  76. package/dist/debug/runtime/RaphRuntime.js +979 -0
  77. package/dist/debug/runtime/diagnostics/RaphDebug.cjs +1 -0
  78. package/dist/debug/runtime/diagnostics/RaphDebug.js +297 -0
  79. package/dist/debug/runtime/errors.cjs +1 -0
  80. package/dist/debug/runtime/errors.js +15 -0
  81. package/dist/debug/runtime/ownership/RaphEffectScope.cjs +1 -0
  82. package/dist/debug/runtime/ownership/RaphEffectScope.js +171 -0
  83. package/dist/debug/runtime/ownership/RaphNode.cjs +1 -0
  84. package/dist/debug/runtime/ownership/RaphNode.js +206 -0
  85. package/dist/debug/runtime/ownership/RaphScope.cjs +1 -0
  86. package/dist/debug/runtime/ownership/RaphScope.js +101 -0
  87. package/dist/debug/runtime/ownership/parent-graph.types.cjs +1 -0
  88. package/dist/debug/runtime/ownership/parent-graph.types.js +1 -0
  89. package/dist/debug/runtime/ownership/parentGraph.cjs +1 -0
  90. package/dist/debug/runtime/ownership/parentGraph.js +10 -0
  91. package/dist/debug/runtime/ownership/throwDisposalErrors.cjs +1 -0
  92. package/dist/debug/runtime/ownership/throwDisposalErrors.js +9 -0
  93. package/dist/debug/runtime/phases/RaphFrameLoop.cjs +1 -0
  94. package/dist/debug/runtime/phases/RaphFrameLoop.js +106 -0
  95. package/dist/debug/runtime/phases/RaphPhasePipeline.cjs +1 -0
  96. package/dist/debug/runtime/phases/RaphPhasePipeline.js +587 -0
  97. package/dist/debug/runtime/phases/orderPhaseTasks.cjs +1 -0
  98. package/dist/debug/runtime/phases/orderPhaseTasks.js +59 -0
  99. package/dist/debug/runtime/phases/phase.types.cjs +1 -0
  100. package/dist/debug/runtime/phases/phase.types.js +8 -0
  101. package/dist/debug/runtime/reactivity/PathHandle.cjs +1 -0
  102. package/dist/debug/runtime/reactivity/PathHandle.js +175 -0
  103. package/dist/debug/runtime/reactivity/RaphMetaSource.cjs +1 -0
  104. package/dist/debug/runtime/reactivity/RaphMetaSource.js +112 -0
  105. package/dist/debug/runtime/reactivity/RaphWorkGraph.cjs +1 -0
  106. package/dist/debug/runtime/reactivity/RaphWorkGraph.js +995 -0
  107. package/dist/debug/runtime/reactivity/RuntimeReactivity.cjs +1 -0
  108. package/dist/debug/runtime/reactivity/RuntimeReactivity.js +156 -0
  109. package/dist/debug/runtime/reactivity/RuntimeWatch.cjs +1 -0
  110. package/dist/debug/runtime/reactivity/RuntimeWatch.js +88 -0
  111. package/dist/debug/runtime/reactivity/runtime-reactivity.types.cjs +1 -0
  112. package/dist/debug/runtime/reactivity/runtime-reactivity.types.js +1 -0
  113. package/dist/entrypoints/machine-testing.d.ts +2 -0
  114. package/dist/entrypoints/machine.d.ts +5 -0
  115. package/dist/entrypoints/path.d.ts +14 -0
  116. package/dist/entrypoints/reactivity.d.ts +1 -0
  117. package/dist/entrypoints/runtime.d.ts +17 -0
  118. package/dist/index.cjs +1 -0
  119. package/dist/index.js +48 -0
  120. package/dist/machine/compiler.d.ts +71 -0
  121. package/dist/machine/core.d.ts +50 -0
  122. package/dist/machine/persistence.d.ts +5 -0
  123. package/dist/machine/runtime.d.ts +4 -0
  124. package/dist/machine/testing.d.ts +43 -0
  125. package/dist/machine/types.d.ts +155 -0
  126. package/dist/machine-testing.cjs +1 -0
  127. package/dist/machine-testing.js +188 -0
  128. package/dist/machine.cjs +1 -0
  129. package/dist/machine.js +837 -0
  130. package/dist/main.d.ts +20 -0
  131. package/dist/path/DataPath.d.ts +73 -0
  132. package/dist/path/PathRouter.d.ts +21 -0
  133. package/dist/path/RaphKernel.d.ts +169 -0
  134. package/dist/path/data-path.types.d.ts +34 -0
  135. package/dist/path/data-path.utils.d.ts +9 -0
  136. package/dist/path/derived/DerivedRegistry.d.ts +67 -0
  137. package/dist/path/derived/RaphDerivedHandle.d.ts +97 -0
  138. package/dist/path/derived/derived-collection.types.d.ts +12 -0
  139. package/dist/path/derived/derived-collection.utils.d.ts +20 -0
  140. package/dist/path/derived/derived-strategy.types.d.ts +12 -0
  141. package/dist/path/derived/derived-strategy.utils.d.ts +4 -0
  142. package/dist/path/meta/MetaController.d.ts +85 -0
  143. package/dist/path/meta/RaphMeta.d.ts +45 -0
  144. package/dist/path/meta/RaphMetaStore.d.ts +45 -0
  145. package/dist/path/meta/meta.types.d.ts +31 -0
  146. package/dist/path/path.types.d.ts +27 -0
  147. package/dist/path/pathSegmentKey.d.ts +2 -0
  148. package/dist/path/storage/AdapterPathStore.d.ts +45 -0
  149. package/dist/path/storage/DefaultDataAdapter.d.ts +63 -0
  150. package/dist/path/storage/PathEventHub.d.ts +48 -0
  151. package/dist/path/storage/PathStore.d.ts +51 -0
  152. package/dist/path/storage/createDataDraft.d.ts +4 -0
  153. package/dist/path/storage/data-adapter.types.d.ts +17 -0
  154. package/dist/path.cjs +1 -0
  155. package/dist/path.js +18 -0
  156. package/dist/raph.cjs +1 -0
  157. package/dist/raph.js +48 -0
  158. package/dist/reactivity/engine.d.ts +393 -0
  159. package/dist/reactivity/reactive-object.d.ts +36 -0
  160. package/dist/reactivity/scope.d.ts +146 -0
  161. package/dist/reactivity/types.d.ts +175 -0
  162. package/dist/reactivity/watch.d.ts +15 -0
  163. package/dist/reactivity.cjs +1 -0
  164. package/dist/reactivity.js +14 -0
  165. package/dist/runtime/RaphRuntime.d.ts +225 -0
  166. package/dist/runtime/diagnostics/RaphDebug.d.ts +239 -0
  167. package/dist/runtime/errors.d.ts +21 -0
  168. package/dist/runtime/ownership/RaphEffectScope.d.ts +29 -0
  169. package/dist/runtime/ownership/RaphNode.d.ts +40 -0
  170. package/dist/runtime/ownership/RaphScope.d.ts +38 -0
  171. package/dist/runtime/ownership/parent-graph.types.d.ts +4 -0
  172. package/dist/runtime/ownership/parentGraph.d.ts +3 -0
  173. package/dist/runtime/ownership/throwDisposalErrors.d.ts +1 -0
  174. package/dist/runtime/phases/RaphFrameLoop.d.ts +51 -0
  175. package/dist/runtime/phases/RaphPhasePipeline.d.ts +79 -0
  176. package/dist/runtime/phases/orderPhaseTasks.d.ts +6 -0
  177. package/dist/runtime/phases/phase.types.d.ts +92 -0
  178. package/dist/runtime/reactivity/PathHandle.d.ts +80 -0
  179. package/dist/runtime/reactivity/RaphMetaSource.d.ts +32 -0
  180. package/dist/runtime/reactivity/RaphWorkGraph.d.ts +171 -0
  181. package/dist/runtime/reactivity/RuntimeReactivity.d.ts +45 -0
  182. package/dist/runtime/reactivity/RuntimeWatch.d.ts +34 -0
  183. package/dist/runtime/reactivity/runtime-reactivity.types.d.ts +11 -0
  184. package/dist/runtime.cjs +1 -0
  185. package/dist/runtime.js +23 -0
  186. package/package.json +141 -0
@@ -0,0 +1,837 @@
1
+ import { b as B, g as N, h as L, c as J, r as Q, d as W, s as H } from "./core-CyilRD7s.js";
2
+ import { e as rt, a as st, t as nt } from "./core-CyilRD7s.js";
3
+ import { RaphScope as F } from "./debug/runtime/ownership/RaphScope.js";
4
+ class m extends Error {
5
+ }
6
+ function V(o, t) {
7
+ return B(
8
+ o,
9
+ t
10
+ ), y(t.context, "context"), t.output !== void 0 && y(t.output, "output"), Object.freeze({
11
+ active: Object.freeze([...t.active]),
12
+ context: P(t.context),
13
+ history: Object.freeze(Object.fromEntries(
14
+ Object.entries(t.history).map(([e, r]) => [e, Object.freeze([...r])])
15
+ )),
16
+ modelId: o.id,
17
+ ...t.output === void 0 ? {} : { output: P(t.output) },
18
+ revision: t.revision,
19
+ status: t.status,
20
+ version: o.version
21
+ });
22
+ }
23
+ function G(o, t, e) {
24
+ const r = N(o);
25
+ try {
26
+ if (typeof t != "object" || t === null || Array.isArray(t))
27
+ throw new m("[Raph machine] Persisted snapshot must be an object.");
28
+ if (t.modelId !== o.id)
29
+ throw new m(
30
+ `[Raph machine] Snapshot model "${t.modelId}" is incompatible with "${o.id}".`
31
+ );
32
+ if (!Number.isSafeInteger(t.version) || t.version < 1)
33
+ throw new m("[Raph machine] Persisted version must be a positive integer.");
34
+ let i = t;
35
+ for (; i.version < o.version; ) {
36
+ const s = r.migrations.get(i.version);
37
+ if (s === void 0)
38
+ throw new m(
39
+ `[Raph machine] Missing migration from version ${i.version} for "${o.id}".`
40
+ );
41
+ const n = s(i);
42
+ if (n.version !== i.version + 1 || n.modelId !== o.id)
43
+ throw new m(
44
+ `[Raph machine] Migration from version ${i.version} must produce version ${i.version + 1}.`
45
+ );
46
+ i = n;
47
+ }
48
+ if (i.version !== o.version)
49
+ throw new m(
50
+ `[Raph machine] Snapshot version ${i.version} is newer than model version ${o.version}.`
51
+ );
52
+ return y(i.context, "context"), i.output !== void 0 && y(i.output, "output"), L(
53
+ o,
54
+ i,
55
+ e
56
+ );
57
+ } catch (i) {
58
+ throw i instanceof m ? i : new m(
59
+ `[Raph machine] Persisted snapshot is invalid: ${i instanceof Error ? i.message : String(i)}`
60
+ );
61
+ }
62
+ }
63
+ function y(o, t, e = /* @__PURE__ */ new Set()) {
64
+ if (o === null)
65
+ return;
66
+ const r = typeof o;
67
+ if (r === "string" || r === "boolean")
68
+ return;
69
+ if (r === "number") {
70
+ if (!Number.isFinite(o))
71
+ throw new m(`[Raph machine] ${t} contains a non-finite number.`);
72
+ return;
73
+ }
74
+ if (r !== "object")
75
+ throw new m(`[Raph machine] ${t} is not JSON-safe.`);
76
+ const i = o;
77
+ if (e.has(i))
78
+ throw new m(`[Raph machine] ${t} contains a cycle.`);
79
+ if (e.add(i), Array.isArray(o))
80
+ o.forEach((s, n) => y(s, `${t}[${n}]`, e));
81
+ else {
82
+ const s = Object.getPrototypeOf(o);
83
+ if (s !== Object.prototype && s !== null)
84
+ throw new m(`[Raph machine] ${t} contains a non-plain object.`);
85
+ for (const [n, a] of Object.entries(o))
86
+ y(a, `${t}.${n}`, e);
87
+ }
88
+ e.delete(i);
89
+ }
90
+ function P(o) {
91
+ return JSON.parse(JSON.stringify(o));
92
+ }
93
+ const k = /* @__PURE__ */ new WeakMap(), S = Symbol("RaphMachineActivationCancelled"), A = Object.freeze({ type: "@@init" }), K = Object.freeze({
94
+ clearTimeout: (o) => clearTimeout(o),
95
+ now: () => Date.now(),
96
+ setTimeout: (o, t) => setTimeout(o, t)
97
+ });
98
+ class E {
99
+ constructor(t, e, r, i) {
100
+ if (this.id = void 0, this.model = void 0, this.snapshot = void 0, this._owner = void 0, this._runtime = void 0, this._compiled = void 0, this._bindings = void 0, this._clock = void 0, this._input = void 0, this._errorPolicy = void 0, this._releaseSnapshot = O, this._writeSnapshotInBoundary = void 0, this._currentSnapshot = void 0, this._queue = void 0, this._listeners = void 0, this._stateCleanups = void 0, this._invocations = void 0, this._actors = void 0, this._releaseOwnership = O, this._releaseDebug = O, this._restored = !1, this._initialPlan = void 0, this._onError = void 0, this._queueCursor = 0, this._processing = !1, this._started = !1, this._stopped = !1, this._lastIgnoredSnapshot = void 0, this._lastIgnoredResult = void 0, !(t instanceof F))
101
+ throw new TypeError("[Raph machine] Machine owner must be a Raph Runtime scope or node.");
102
+ if (t._assertAlive(), this._owner = t, this._runtime = t.runtime, this._compiled = N(
103
+ e
104
+ ), this.model = e, this._bindings = r, this._clock = i.clock ?? K, this._input = i.input, this._errorPolicy = i.errorPolicy ?? "throw", this._errorPolicy !== "ignore" && this._errorPolicy !== "stop" && this._errorPolicy !== "throw")
105
+ throw new TypeError(`[Raph machine] Unknown error policy "${String(this._errorPolicy)}".`);
106
+ this._onError = i.onError;
107
+ const s = (k.get(this._runtime) ?? 0) + 1;
108
+ if (k.set(this._runtime, s), this.id = i.id ?? `${e.id}#${s}`, !this.id.trim())
109
+ throw new TypeError("[Raph machine] Instance id must not be empty.");
110
+ if (this._runtime._hasMachineDebug(this.id))
111
+ throw new Error(`[Raph] Machine diagnostic id "${this.id}" is already registered.`);
112
+ const n = i.persisted === void 0 ? this._runtime.untracked(() => J(
113
+ e,
114
+ this._input,
115
+ r,
116
+ this._runtime._traces("machine") ? this._traceHooks() : void 0
117
+ )) : void 0, a = (n == null ? void 0 : n.snapshot) ?? G(e, i.persisted, this._input);
118
+ this._initialPlan = n == null ? void 0 : n.plan, this._restored = i.persisted !== void 0;
119
+ const c = U(this._runtime, t, a);
120
+ this._releaseSnapshot = c.dispose, this._writeSnapshotInBoundary = c.writeInBoundary, this._currentSnapshot = a, this.snapshot = c.source;
121
+ try {
122
+ this._releaseDebug = this._runtime._registerMachineDebug({
123
+ id: this.id,
124
+ ownerId: t.id,
125
+ ...i.parentId === void 0 ? {} : { parentId: i.parentId },
126
+ snapshot: () => {
127
+ var _;
128
+ const h = this._currentSnapshot, u = Object.fromEntries(this._activeClosure(h).flatMap((f) => {
129
+ const d = this._compiled.states[f].meta;
130
+ return d === void 0 ? [] : [[this._compiled.states[f].path, d]];
131
+ }));
132
+ return Object.freeze({
133
+ active: h.active,
134
+ actors: Object.freeze([...((_ = this._actors) == null ? void 0 : _.keys()) ?? []]),
135
+ contextKeys: Object.freeze(D(h.context) ? Object.keys(h.context) : []),
136
+ id: this.id,
137
+ meta: Object.freeze(u),
138
+ modelId: e.id,
139
+ ownerId: t.id,
140
+ ...i.parentId === void 0 ? {} : { parentId: i.parentId },
141
+ revision: h.revision,
142
+ status: h.status
143
+ });
144
+ }
145
+ }), this._releaseOwnership = t.own(() => this._dispose(!1));
146
+ } catch (h) {
147
+ const u = [h];
148
+ try {
149
+ this._releaseDebug();
150
+ } catch (_) {
151
+ u.push(_);
152
+ }
153
+ try {
154
+ this._releaseSnapshot();
155
+ } catch (_) {
156
+ u.push(_);
157
+ }
158
+ throw u.length > 1 ? new AggregateError(u, `[Raph machine] Machine "${this.id}" construction rollback failed.`) : h;
159
+ }
160
+ }
161
+ get started() {
162
+ return this._started && !this._stopped;
163
+ }
164
+ start() {
165
+ var s, n;
166
+ if (this._stopped)
167
+ throw new Error(`[Raph machine] Machine "${this.id}" is stopped.`);
168
+ if (this._started)
169
+ return this;
170
+ this._owner._assertAlive();
171
+ const t = this._currentSnapshot;
172
+ if (t.status === "stopped")
173
+ throw new Error(`[Raph machine] Persisted machine "${this.id}" is stopped.`);
174
+ if (this._started = !0, this._compiled.flat)
175
+ return this;
176
+ const e = this._activeClosure(t).sort((a, c) => this._compiled.states[a].depth - this._compiled.states[c].depth);
177
+ let r = !1, i;
178
+ this._processing = !0;
179
+ try {
180
+ const a = [];
181
+ if (!this._restored) {
182
+ try {
183
+ this._runOutputs(
184
+ ((s = this._initialPlan) == null ? void 0 : s.exitOutputs) ?? [],
185
+ t,
186
+ this._runtime._currentTraceCauseId()
187
+ );
188
+ } catch (c) {
189
+ a.push(c);
190
+ }
191
+ if (this.started)
192
+ try {
193
+ this._runOutputs(
194
+ ((n = this._initialPlan) == null ? void 0 : n.transitionOutputs) ?? [],
195
+ t,
196
+ this._runtime._currentTraceCauseId()
197
+ );
198
+ } catch (c) {
199
+ a.push(c);
200
+ }
201
+ if (this.started) {
202
+ const c = e.flatMap((h) => this._compiled.states[h].entry.map((u) => ({ event: A, ref: u })));
203
+ try {
204
+ this._runOutputs(c, t, this._runtime._currentTraceCauseId());
205
+ } catch (h) {
206
+ a.push(h);
207
+ }
208
+ }
209
+ }
210
+ if (this.started && t.status === "active")
211
+ for (const c of e) {
212
+ if (!this.started)
213
+ break;
214
+ try {
215
+ this._activateState(c, A, t);
216
+ } catch (h) {
217
+ a.push(h);
218
+ }
219
+ }
220
+ g(a, `[Raph machine] Machine "${this.id}" start work failed.`);
221
+ } catch (a) {
222
+ try {
223
+ this._handlePostCommitError(a, "start", this._runtime._currentTraceCauseId());
224
+ } catch (c) {
225
+ r = !0, i = c;
226
+ }
227
+ } finally {
228
+ this._processing = !1, r ? (this._queue !== void 0 && (this._queue.length = 0), this._queueCursor = 0) : this._drainQueued();
229
+ }
230
+ if (r)
231
+ throw i;
232
+ return this;
233
+ }
234
+ send(t) {
235
+ return this._enqueue(t);
236
+ }
237
+ sendTo(t, e) {
238
+ var i;
239
+ const r = (i = this._actors) == null ? void 0 : i.get(t);
240
+ if (r === void 0)
241
+ throw new Error(`[Raph machine] Actor "${t}" is not active in "${this.id}".`);
242
+ return r.send(e);
243
+ }
244
+ matches(t) {
245
+ return this.snapshot.get().active.some((e) => e === t || e.startsWith(`${t}.`));
246
+ }
247
+ hasTag(t) {
248
+ for (const e of this._activeClosure(this.snapshot.get()))
249
+ if (this._compiled.states[e].tags.includes(t))
250
+ return !0;
251
+ return !1;
252
+ }
253
+ subscribe(t) {
254
+ if (typeof t != "function")
255
+ throw new TypeError("[Raph machine] Subscriber must be a function.");
256
+ if (this._stopped)
257
+ return () => {
258
+ };
259
+ const e = { listener: t }, r = this._listeners;
260
+ return this._listeners = r === void 0 ? [e] : [...r, e], () => this._removeListener(e);
261
+ }
262
+ persist() {
263
+ return V(this.model, this.snapshot.get());
264
+ }
265
+ stop() {
266
+ let t;
267
+ try {
268
+ this._dispose(!0);
269
+ } catch (e) {
270
+ (t ?? (t = [])).push(e);
271
+ }
272
+ try {
273
+ this._releaseOwnership();
274
+ } catch (e) {
275
+ (t ?? (t = [])).push(e);
276
+ }
277
+ g(t, `[Raph machine] Machine "${this.id}" stop failed.`);
278
+ }
279
+ _enqueue(t, e) {
280
+ if (!this.started)
281
+ throw new Error(`[Raph machine] Machine "${this.id}" must be started before send().`);
282
+ if (X(t), this._processing)
283
+ return (this._queue ?? (this._queue = [])).push({ event: t, ...e === void 0 ? {} : { transitions: e } }), { snapshot: this._currentSnapshot, status: "queued" };
284
+ this._processing = !0;
285
+ let r;
286
+ try {
287
+ r = this._process(t, e), this._drainQueuedItems();
288
+ } finally {
289
+ this._queue !== void 0 && (this._queue.length = 0), this._queueCursor = 0, this._processing = !1;
290
+ }
291
+ return r;
292
+ }
293
+ _process(t, e) {
294
+ const r = this._currentSnapshot, i = this._runtime._nextTraceOperation("machine"), s = this._runtime._currentTraceCauseId() ?? i;
295
+ let n;
296
+ i !== void 0 && this._trace(t.type, "start", i, s, r);
297
+ try {
298
+ const a = e === void 0 ? this._compiled.eventIndexes.get(t.type) : void 0;
299
+ if (e === void 0 && a === void 0)
300
+ return i !== void 0 && this._trace(t.type, "ignored", i, s, r), this._ignored(r);
301
+ const c = i === void 0 ? void 0 : this._traceHooks(i, s), h = this._runtime._hasActiveReactiveContext() ? this._runtime.untracked(() => this._evaluate(r, t, a, e, c)) : this._evaluate(r, t, a, e, c);
302
+ if (!h.changed)
303
+ return i !== void 0 && this._trace(t.type, "ignored", i, s, r), this._ignored(r);
304
+ this._runtime._batchReactive(() => {
305
+ this._writeSnapshotInBoundary(h.snapshot), this._currentSnapshot = h.snapshot, n = h.snapshot;
306
+ });
307
+ let u;
308
+ try {
309
+ this._applyPlan(h.plan, h.snapshot, s);
310
+ } catch (d) {
311
+ (u ?? (u = [])).push(d);
312
+ }
313
+ const _ = this._listeners;
314
+ if (this.started && _ !== void 0) {
315
+ const d = this._notifyListeners(_, h.snapshot);
316
+ d !== void 0 && (u ?? (u = [])).push(...d);
317
+ }
318
+ if (this.started && h.snapshot.status === "done")
319
+ try {
320
+ this._stopStateResources();
321
+ } catch (d) {
322
+ (u ?? (u = [])).push(d);
323
+ }
324
+ u !== void 0 && g(u, `[Raph machine] Machine "${this.id}" post-commit work failed.`);
325
+ const f = this.started ? h.snapshot : this._currentSnapshot;
326
+ return i !== void 0 && this._trace(t.type, "end", i, s, f), { snapshot: f, status: "transitioned" };
327
+ } catch (a) {
328
+ if (n !== void 0)
329
+ return this._handlePostCommitError(a, t.type, s), { snapshot: this._currentSnapshot, status: "transitioned" };
330
+ if (this._traceError(t.type, a, i, s), this._onError !== void 0)
331
+ return this._onError(a), this._ignored(this._currentSnapshot);
332
+ if (this._errorPolicy === "stop" && this._dispose(!0), this._errorPolicy === "ignore")
333
+ return this._ignored(this._currentSnapshot);
334
+ throw a;
335
+ }
336
+ }
337
+ _ignored(t) {
338
+ return this._lastIgnoredSnapshot !== t && (this._lastIgnoredSnapshot = t, this._lastIgnoredResult = { snapshot: t, status: "ignored" }), this._lastIgnoredResult;
339
+ }
340
+ _evaluate(t, e, r, i, s) {
341
+ return i === void 0 ? Q(
342
+ this.model,
343
+ t,
344
+ e,
345
+ this._bindings,
346
+ this._input,
347
+ s,
348
+ this._compiled,
349
+ r
350
+ ) : W(
351
+ this.model,
352
+ t,
353
+ e,
354
+ i,
355
+ this._bindings,
356
+ this._input,
357
+ s
358
+ );
359
+ }
360
+ _drainQueued() {
361
+ if (this._queue === void 0 || this._queue.length === 0 || !this.started) {
362
+ this._queue !== void 0 && (this._queue.length = 0), this._queueCursor = 0;
363
+ return;
364
+ }
365
+ this._processing = !0;
366
+ try {
367
+ this._drainQueuedItems();
368
+ } finally {
369
+ this._queue !== void 0 && (this._queue.length = 0), this._queueCursor = 0, this._processing = !1;
370
+ }
371
+ }
372
+ _drainQueuedItems() {
373
+ const t = this._queue;
374
+ if (t !== void 0)
375
+ for (; this._queueCursor < t.length && this.started; ) {
376
+ const e = t[this._queueCursor++];
377
+ this._process(e.event, e.transitions);
378
+ }
379
+ }
380
+ _applyPlan(t, e, r) {
381
+ if (t.exited.length === 0 && t.exitOutputs.length === 0 && t.transitionOutputs.length === 0 && t.transitionOutputRefs === void 0 && t.entryOutputs.length === 0 && t.entered.length === 0)
382
+ return;
383
+ const i = [];
384
+ for (const s of t.exited) {
385
+ try {
386
+ this._cleanupState(s);
387
+ } catch (n) {
388
+ i.push(n);
389
+ }
390
+ if (!this.started)
391
+ break;
392
+ }
393
+ if (this.started && t.exitOutputs.length !== 0)
394
+ try {
395
+ this._runOutputs(t.exitOutputs, e, r);
396
+ } catch (s) {
397
+ i.push(s);
398
+ }
399
+ if (this.started && t.transitionOutputRefs !== void 0)
400
+ try {
401
+ this._runOutputRefs(t.transitionOutputRefs, t.event, e, r);
402
+ } catch (s) {
403
+ i.push(s);
404
+ }
405
+ else if (this.started && t.transitionOutputs.length !== 0)
406
+ try {
407
+ this._runOutputs(t.transitionOutputs, e, r);
408
+ } catch (s) {
409
+ i.push(s);
410
+ }
411
+ if (this.started && t.entryOutputs.length !== 0)
412
+ try {
413
+ this._runOutputs(t.entryOutputs, e, r);
414
+ } catch (s) {
415
+ i.push(s);
416
+ }
417
+ if (this.started)
418
+ for (const s of t.entered) {
419
+ if (!this.started)
420
+ break;
421
+ try {
422
+ this._activateState(s, t.event, e);
423
+ } catch (n) {
424
+ i.push(n);
425
+ }
426
+ }
427
+ g(i, `[Raph machine] Machine "${this.id}" post-commit work failed.`);
428
+ }
429
+ _activateState(t, e, r) {
430
+ var a, c;
431
+ if (!this.started || (a = this._stateCleanups) != null && a.has(t))
432
+ return;
433
+ const i = this._compiled.states[t];
434
+ if (i.resources.length === 0 && i.after.size === 0 && i.invokes.length === 0)
435
+ return;
436
+ const s = [], n = this._stateCleanups ?? (this._stateCleanups = /* @__PURE__ */ new Map());
437
+ n.set(t, s);
438
+ try {
439
+ for (const h of i.resources) {
440
+ const u = (c = this._bindings.resources) == null ? void 0 : c[h];
441
+ if (u === void 0)
442
+ throw new Error(`[Raph machine] Resource binding "${h}" is not defined.`);
443
+ const _ = new AbortController();
444
+ let f;
445
+ try {
446
+ const d = this._runtime.untracked(() => u({
447
+ context: r.context,
448
+ event: e,
449
+ input: this._input,
450
+ owner: this._owner,
451
+ signal: _.signal,
452
+ snapshot: r
453
+ }));
454
+ typeof d == "function" && (f = d);
455
+ } catch (d) {
456
+ throw _.abort(), d;
457
+ }
458
+ if (s.push(R(() => {
459
+ _.abort(), f == null || f();
460
+ })), !this.started)
461
+ throw S;
462
+ }
463
+ for (const [h, u] of i.after) {
464
+ const _ = this._resolveDelay(h, r, e);
465
+ if (!this.started)
466
+ throw S;
467
+ const f = this._clock.setTimeout(() => {
468
+ var d;
469
+ !this.started || !((d = this._stateCleanups) != null && d.has(t)) || this._enqueue(Object.freeze({ type: `@@after:${i.path}:${h}` }), u);
470
+ }, _);
471
+ if (s.push(R(() => this._clock.clearTimeout(f))), !this.started)
472
+ throw S;
473
+ }
474
+ for (const h of i.invokes)
475
+ if (this._startInvoke(i, h, e, r, s), !this.started)
476
+ throw S;
477
+ } catch (h) {
478
+ n.get(t) === s && n.delete(t), n.size === 0 && this._stateCleanups === n && (this._stateCleanups = void 0);
479
+ const u = z(s);
480
+ g(
481
+ h === S ? u : [h, ...u],
482
+ `[Raph machine] State "${i.path}" activation failed.`
483
+ );
484
+ }
485
+ }
486
+ _startInvoke(t, e, r, i, s) {
487
+ var C, x, T, M, q, I;
488
+ const n = this._invocations ?? (this._invocations = /* @__PURE__ */ new Map());
489
+ if (n.has(e.id))
490
+ throw new Error(`[Raph machine] Invoke id "${e.id}" is already active.`);
491
+ const a = new AbortController(), c = {}, h = { controller: a, invoke: e, token: c };
492
+ n.set(e.id, h);
493
+ const u = () => {
494
+ var v;
495
+ a.abort();
496
+ const l = n.get(e.id);
497
+ (l == null ? void 0 : l.token) === c && n.delete(e.id), n.size === 0 && this._invocations === n && (this._invocations = void 0);
498
+ const p = this._actors;
499
+ p == null || p.delete(e.id), (p == null ? void 0 : p.size) === 0 && this._actors === p && (this._actors = void 0), (v = h.actor) == null || v.stop();
500
+ };
501
+ s.push(R(u));
502
+ const _ = typeof e.input == "function" ? e.input({ context: i.context, event: r, input: this._input }) : e.input;
503
+ if (!this.started)
504
+ return;
505
+ if (e.type === "machine") {
506
+ const l = typeof e.src == "string" ? (C = this._bindings.actors) == null ? void 0 : C[e.src] : e.src;
507
+ if (l === void 0)
508
+ throw new Error(`[Raph machine] Actor source "${String(e.src)}" is not defined.`);
509
+ const p = new E(
510
+ this._owner,
511
+ l,
512
+ {},
513
+ {
514
+ errorPolicy: e.onError.length === 0 ? "throw" : "ignore",
515
+ id: `${this.id}/${e.id}`,
516
+ input: _,
517
+ onError: e.onError.length === 0 ? void 0 : ($) => {
518
+ var w, b;
519
+ !this.started || ((b = (w = this._invocations) == null ? void 0 : w.get(e.id)) == null ? void 0 : b.token) !== c || this._enqueue(
520
+ Object.freeze({ error: $, type: `@@error.actor:${e.id}` }),
521
+ e.onError
522
+ );
523
+ },
524
+ parentId: this.id
525
+ }
526
+ );
527
+ if (!this.started || ((T = (x = this._invocations) == null ? void 0 : x.get(e.id)) == null ? void 0 : T.token) !== c || a.signal.aborted) {
528
+ p.stop();
529
+ return;
530
+ }
531
+ h.actor = p, (this._actors ?? (this._actors = /* @__PURE__ */ new Map())).set(e.id, p);
532
+ const v = p.subscribe(($) => {
533
+ var w, b;
534
+ $.status === "done" && ((b = (w = this._invocations) == null ? void 0 : w.get(e.id)) == null ? void 0 : b.token) === c && this._enqueue(
535
+ Object.freeze({ output: $.output, type: `@@done.actor:${e.id}` }),
536
+ e.onDone
537
+ );
538
+ });
539
+ if (s.push(R(v)), p.start(), !this.started)
540
+ return;
541
+ const j = p.snapshot.peek();
542
+ j.status === "done" && ((q = (M = this._invocations) == null ? void 0 : M.get(e.id)) == null ? void 0 : q.token) === c && this._enqueue(
543
+ Object.freeze({ output: j.output, type: `@@done.actor:${e.id}` }),
544
+ e.onDone
545
+ );
546
+ return;
547
+ }
548
+ if (typeof e.src != "string")
549
+ throw new TypeError(`[Raph machine] Task invoke "${e.id}" requires a string source.`);
550
+ const f = (I = this._bindings.tasks) == null ? void 0 : I[e.src];
551
+ if (f === void 0)
552
+ throw new Error(`[Raph machine] Task binding "${e.src}" is not defined.`);
553
+ let d;
554
+ try {
555
+ d = this._runtime.untracked(() => f({
556
+ context: i.context,
557
+ event: r,
558
+ input: this._input,
559
+ send: (l) => {
560
+ var v;
561
+ const p = (v = this._invocations) == null ? void 0 : v.get(e.id);
562
+ !this.started || (p == null ? void 0 : p.token) !== c || a.signal.aborted || this.send(l);
563
+ },
564
+ signal: a.signal
565
+ }));
566
+ } catch (l) {
567
+ this._completeInvoke(e, c, !1, l);
568
+ return;
569
+ }
570
+ this.started && Promise.resolve(d).then(
571
+ (l) => this._completeInvoke(e, c, !0, l),
572
+ (l) => this._completeInvoke(e, c, !1, l)
573
+ );
574
+ }
575
+ _completeInvoke(t, e, r, i) {
576
+ var n;
577
+ const s = (n = this._invocations) == null ? void 0 : n.get(t.id);
578
+ !this.started || (s == null ? void 0 : s.token) !== e || s.controller.signal.aborted || this._enqueue(
579
+ Object.freeze(r ? { data: i, type: `@@done.invoke:${t.id}` } : { error: i, type: `@@error.invoke:${t.id}` }),
580
+ r ? t.onDone : t.onError
581
+ );
582
+ }
583
+ _resolveDelay(t, e, r) {
584
+ var a;
585
+ const i = Number(t), s = Number.isFinite(i) && t.trim() !== "" ? i : (a = this._bindings.delays) == null ? void 0 : a[t];
586
+ if (s === void 0)
587
+ throw new Error(`[Raph machine] Delay binding "${t}" is not defined.`);
588
+ const n = typeof s == "function" ? s({ context: e.context, event: r, input: this._input }) : s;
589
+ if (!Number.isFinite(n) || n < 0)
590
+ throw new TypeError(`[Raph machine] Delay "${t}" must resolve to a non-negative finite number.`);
591
+ return n;
592
+ }
593
+ _runOutputs(t, e, r) {
594
+ if (t.length === 0)
595
+ return;
596
+ let i;
597
+ for (const s of t) {
598
+ try {
599
+ const n = this._resolveOutput(s.ref);
600
+ this._runtime._runWithTraceCause(r, () => this._runtime.untracked(() => n({
601
+ context: e.context,
602
+ event: s.event,
603
+ input: this._input,
604
+ snapshot: e
605
+ })));
606
+ } catch (n) {
607
+ (i ?? (i = [])).push(n);
608
+ }
609
+ if (!this.started)
610
+ break;
611
+ }
612
+ i !== void 0 && g(i, `[Raph machine] Machine "${this.id}" output work failed.`);
613
+ }
614
+ _notifyListeners(t, e) {
615
+ let r;
616
+ for (let i = 0; i < t.length; i += 1)
617
+ try {
618
+ t[i].listener(e);
619
+ } catch (s) {
620
+ (r ?? (r = [])).push(s);
621
+ }
622
+ return r;
623
+ }
624
+ _removeListener(t) {
625
+ const e = this._listeners;
626
+ if (e === void 0)
627
+ return;
628
+ const r = e.indexOf(t);
629
+ r !== -1 && (this._listeners = e.length === 1 ? void 0 : [...e.slice(0, r), ...e.slice(r + 1)]);
630
+ }
631
+ _runOutputRefs(t, e, r, i) {
632
+ let s;
633
+ for (const n of t) {
634
+ try {
635
+ const a = this._resolveOutput(n);
636
+ this._runtime._runWithTraceCause(i, () => this._runtime.untracked(() => a({
637
+ context: r.context,
638
+ event: e,
639
+ input: this._input,
640
+ snapshot: r
641
+ })));
642
+ } catch (a) {
643
+ (s ?? (s = [])).push(a);
644
+ }
645
+ if (!this.started)
646
+ break;
647
+ }
648
+ s !== void 0 && g(s, `[Raph machine] Machine "${this.id}" output work failed.`);
649
+ }
650
+ _resolveOutput(t) {
651
+ var r;
652
+ if (typeof t == "function")
653
+ return t;
654
+ const e = (r = this._bindings.outputs) == null ? void 0 : r[t];
655
+ if (e === void 0)
656
+ throw new Error(`[Raph machine] Output binding "${t}" is not defined.`);
657
+ return e;
658
+ }
659
+ _cleanupState(t) {
660
+ const e = this._stateCleanups, r = e == null ? void 0 : e.get(t);
661
+ e === void 0 || r === void 0 || (e.delete(t), e.size === 0 && this._stateCleanups === e && (this._stateCleanups = void 0), g(
662
+ z(r),
663
+ `[Raph machine] State "${this._compiled.states[t].path}" cleanup failed.`
664
+ ));
665
+ }
666
+ _stopStateResources() {
667
+ if (this._stateCleanups === void 0)
668
+ return;
669
+ const t = [...this._stateCleanups.keys()].sort((r, i) => this._compiled.states[i].depth - this._compiled.states[r].depth), e = [];
670
+ for (const r of t)
671
+ try {
672
+ this._cleanupState(r);
673
+ } catch (i) {
674
+ e.push(i);
675
+ }
676
+ g(e, `[Raph machine] Machine "${this.id}" final cleanup failed.`);
677
+ }
678
+ _dispose(t) {
679
+ if (this._stopped)
680
+ return;
681
+ this._stopped = !0, this._started = !1;
682
+ let e;
683
+ try {
684
+ this._stopStateResources();
685
+ } catch (r) {
686
+ (e ?? (e = [])).push(r);
687
+ }
688
+ this._queue !== void 0 && (this._queue.length = 0), this._queueCursor = 0, this._listeners = void 0;
689
+ try {
690
+ this._releaseDebug();
691
+ } catch (r) {
692
+ (e ?? (e = [])).push(r);
693
+ }
694
+ if (t && !this._runtime.disposed) {
695
+ const r = this._currentSnapshot, i = H(this.model, r);
696
+ try {
697
+ this._runtime._batchReactive(() => {
698
+ this._writeSnapshotInBoundary(i), this._currentSnapshot = i;
699
+ });
700
+ } catch (s) {
701
+ (e ?? (e = [])).push(s);
702
+ }
703
+ }
704
+ try {
705
+ this._releaseSnapshot();
706
+ } catch (r) {
707
+ (e ?? (e = [])).push(r);
708
+ }
709
+ g(e, `[Raph machine] Machine "${this.id}" stop failed.`);
710
+ }
711
+ _activeClosure(t) {
712
+ const e = /* @__PURE__ */ new Set();
713
+ for (const r of t.active) {
714
+ let i = this._compiled.pathToState.get(r);
715
+ for (; i !== void 0; )
716
+ e.add(i), i = this._compiled.states[i].parent;
717
+ }
718
+ return [...e];
719
+ }
720
+ _traceHooks(t, e = this._runtime._currentTraceCauseId() ?? t) {
721
+ return {
722
+ guard: (r, i, s) => this._runtime._recordTrace({
723
+ ...e === void 0 ? {} : { causeId: e },
724
+ ...s === void 0 ? {} : { context: s },
725
+ guard: i ? "passed" : "failed",
726
+ kind: "machine",
727
+ name: `${this.id}:guard:${r}`,
728
+ ...t === void 0 ? {} : { operationId: t }
729
+ }),
730
+ transition: (r) => this._runtime._recordTrace({
731
+ ...e === void 0 ? {} : { causeId: e },
732
+ details: r,
733
+ kind: "machine",
734
+ name: `${this.id}:transition`,
735
+ ...t === void 0 ? {} : { operationId: t }
736
+ })
737
+ };
738
+ }
739
+ _trace(t, e, r, i, s) {
740
+ this._runtime._recordTrace({
741
+ ...i === void 0 ? {} : { causeId: i },
742
+ context: D(s.context) ? s.context : void 0,
743
+ details: { active: s.active, revision: s.revision },
744
+ kind: "machine",
745
+ name: `${this.id}:${t}`,
746
+ ...r === void 0 ? {} : { operationId: r },
747
+ status: e
748
+ });
749
+ }
750
+ _traceError(t, e, r, i) {
751
+ const s = { message: e instanceof Error ? e.message : String(e) };
752
+ this._runtime._recordTrace({
753
+ ...i === void 0 ? {} : { causeId: i },
754
+ details: s,
755
+ kind: "machine",
756
+ name: `${this.id}:${t}`,
757
+ ...r === void 0 ? {} : { operationId: r },
758
+ status: "error"
759
+ }), this._runtime._recordTrace({
760
+ ...i === void 0 ? {} : { causeId: i },
761
+ details: s,
762
+ kind: "error",
763
+ name: `machine:${this.id}`,
764
+ ...r === void 0 ? {} : { operationId: r },
765
+ status: "error"
766
+ });
767
+ }
768
+ _handlePostCommitError(t, e, r) {
769
+ if (this._traceError(e, t, void 0, r), this._onError !== void 0) {
770
+ this._onError(t);
771
+ return;
772
+ }
773
+ if (this._errorPolicy === "stop" && this._dispose(!0), this._errorPolicy === "throw")
774
+ throw t;
775
+ }
776
+ }
777
+ function tt(o, t, e = {}, r = {}) {
778
+ return new E(o, t, e, r);
779
+ }
780
+ function U(o, t, e) {
781
+ const r = o._getWorkGraph(), i = r.createProducer(t), s = o._getReactivity()._ownedSignal(e, r.producerHooks(i));
782
+ let n = s.source, a = e;
783
+ const c = Object.freeze({
784
+ get: () => (o._assertSourceReadable(t), n === void 0 ? a : n.get()),
785
+ peek: () => (t._assertAlive(), n === void 0 ? a : n.peek())
786
+ });
787
+ return r.attachProducer(i, c), {
788
+ dispose: () => {
789
+ const h = n;
790
+ h !== void 0 && (a = h.peek(), n = void 0, s.dispose());
791
+ },
792
+ source: c,
793
+ writeInBoundary: (h) => {
794
+ t._assertAlive(), n.set(h), a = h;
795
+ }
796
+ };
797
+ }
798
+ function z(o) {
799
+ const t = [];
800
+ for (let e = o.length - 1; e >= 0; e--)
801
+ try {
802
+ o[e]();
803
+ } catch (r) {
804
+ t.push(r);
805
+ }
806
+ return t;
807
+ }
808
+ function g(o, t) {
809
+ if ((o == null ? void 0 : o.length) === 1)
810
+ throw o[0];
811
+ if (o !== void 0 && o.length > 1)
812
+ throw new AggregateError(o, t);
813
+ }
814
+ function X(o) {
815
+ if (typeof o != "object" || o === null || typeof o.type != "string" || !o.type)
816
+ throw new TypeError("[Raph machine] Event must contain a non-empty string type.");
817
+ }
818
+ function D(o) {
819
+ return typeof o == "object" && o !== null && !Array.isArray(o);
820
+ }
821
+ function O() {
822
+ }
823
+ function R(o) {
824
+ let t = !0;
825
+ return () => {
826
+ t && (t = !1, o());
827
+ };
828
+ }
829
+ export {
830
+ m as MachinePersistenceError,
831
+ tt as createMachine,
832
+ rt as defineMachine,
833
+ st as getInitialSnapshot,
834
+ V as persistMachineSnapshot,
835
+ G as restoreMachineSnapshot,
836
+ nt as transition
837
+ };