@stonecrop/stonecrop 0.7.9 → 0.8.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/dist/stonecrop.js CHANGED
@@ -1,182 +1,182 @@
1
- import { hasInjectionContext as we, inject as te, getCurrentInstance as Fe, toRaw as Le, computed as B, isRef as re, isReactive as ye, toRef as se, ref as M, reactive as Ee, markRaw as oe, effectScope as Je, nextTick as le, getCurrentScope as Ke, onScopeDispose as Ze, watch as H, toRefs as Pe, onMounted as Ve, readonly as Me, customRef as Ge, toValue as q, shallowRef as xe, unref as Ye, provide as _e } from "vue";
2
- const Q = typeof window < "u";
3
- let K;
4
- const ge = (n) => K = n;
1
+ import { hasInjectionContext as Ae, inject as oe, getCurrentInstance as Me, toRaw as Fe, computed as W, isRef as se, isReactive as be, toRef as ce, ref as B, reactive as ye, markRaw as ae, effectScope as Ye, nextTick as de, getCurrentScope as Xe, onScopeDispose as et, watch as U, toRefs as $e, onMounted as Be, readonly as je, customRef as tt, toValue as q, shallowRef as We, unref as rt, provide as De } from "vue";
2
+ const te = typeof window < "u";
3
+ let G;
4
+ const me = (n) => G = n;
5
5
  process.env.NODE_ENV;
6
- const Oe = process.env.NODE_ENV !== "production" ? /* @__PURE__ */ Symbol("pinia") : (
6
+ const Pe = process.env.NODE_ENV !== "production" ? /* @__PURE__ */ Symbol("pinia") : (
7
7
  /* istanbul ignore next */
8
8
  /* @__PURE__ */ Symbol()
9
9
  );
10
- function G(n) {
10
+ function Y(n) {
11
11
  return n && typeof n == "object" && Object.prototype.toString.call(n) === "[object Object]" && typeof n.toJSON != "function";
12
12
  }
13
- var ie;
13
+ var le;
14
14
  (function(n) {
15
15
  n.direct = "direct", n.patchObject = "patch object", n.patchFunction = "patch function";
16
- })(ie || (ie = {}));
17
- function Be(n, e) {
16
+ })(le || (le = {}));
17
+ function He(n, e) {
18
18
  for (const t in e) {
19
19
  const r = e[t];
20
20
  if (!(t in n))
21
21
  continue;
22
22
  const o = n[t];
23
- G(o) && G(r) && !re(r) && !ye(r) ? n[t] = Be(o, r) : n[t] = r;
23
+ Y(o) && Y(r) && !se(r) && !be(r) ? n[t] = He(o, r) : n[t] = r;
24
24
  }
25
25
  return n;
26
26
  }
27
- const je = () => {
27
+ const ze = () => {
28
28
  };
29
- function Ae(n, e, t, r = je) {
29
+ function Te(n, e, t, r = ze) {
30
30
  n.add(e);
31
31
  const o = () => {
32
32
  n.delete(e) && r();
33
33
  };
34
- return !t && Ke() && Ze(o), o;
34
+ return !t && Xe() && et(o), o;
35
35
  }
36
- function Y(n, ...e) {
36
+ function ee(n, ...e) {
37
37
  n.forEach((t) => {
38
38
  t(...e);
39
39
  });
40
40
  }
41
- const Qe = (n) => n(), $e = /* @__PURE__ */ Symbol(), me = /* @__PURE__ */ Symbol();
42
- function Re(n, e) {
41
+ const nt = (n) => n(), Ie = /* @__PURE__ */ Symbol(), Ee = /* @__PURE__ */ Symbol();
42
+ function Ne(n, e) {
43
43
  n instanceof Map && e instanceof Map ? e.forEach((t, r) => n.set(r, t)) : n instanceof Set && e instanceof Set && e.forEach(n.add, n);
44
44
  for (const t in e) {
45
45
  if (!e.hasOwnProperty(t))
46
46
  continue;
47
47
  const r = e[t], o = n[t];
48
- G(o) && G(r) && n.hasOwnProperty(t) && !re(r) && !ye(r) ? n[t] = Re(o, r) : n[t] = r;
48
+ Y(o) && Y(r) && n.hasOwnProperty(t) && !se(r) && !be(r) ? n[t] = Ne(o, r) : n[t] = r;
49
49
  }
50
50
  return n;
51
51
  }
52
- const Xe = process.env.NODE_ENV !== "production" ? /* @__PURE__ */ Symbol("pinia:skipHydration") : (
52
+ const ot = process.env.NODE_ENV !== "production" ? /* @__PURE__ */ Symbol("pinia:skipHydration") : (
53
53
  /* istanbul ignore next */
54
54
  /* @__PURE__ */ Symbol()
55
55
  );
56
- function et(n) {
57
- return !G(n) || !Object.prototype.hasOwnProperty.call(n, Xe);
56
+ function st(n) {
57
+ return !Y(n) || !Object.prototype.hasOwnProperty.call(n, ot);
58
58
  }
59
- const { assign: W } = Object;
60
- function Ie(n) {
61
- return !!(re(n) && n.effect);
59
+ const { assign: z } = Object;
60
+ function Ce(n) {
61
+ return !!(se(n) && n.effect);
62
62
  }
63
- function De(n, e, t, r) {
63
+ function ke(n, e, t, r) {
64
64
  const { state: o, actions: s, getters: i } = e, a = t.state.value[n];
65
65
  let c;
66
- function h() {
66
+ function f() {
67
67
  !a && (process.env.NODE_ENV === "production" || !r) && (t.state.value[n] = o ? o() : {});
68
68
  const g = process.env.NODE_ENV !== "production" && r ? (
69
69
  // use ref() to unwrap refs inside state TODO: check if this is still necessary
70
- Pe(M(o ? o() : {}).value)
71
- ) : Pe(t.state.value[n]);
72
- return W(g, s, Object.keys(i || {}).reduce((w, R) => (process.env.NODE_ENV !== "production" && R in g && console.warn(`[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "${R}" in store "${n}".`), w[R] = oe(B(() => {
73
- ge(t);
70
+ $e(B(o ? o() : {}).value)
71
+ ) : $e(t.state.value[n]);
72
+ return z(g, s, Object.keys(i || {}).reduce((b, A) => (process.env.NODE_ENV !== "production" && A in g && console.warn(`[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "${A}" in store "${n}".`), b[A] = ae(W(() => {
73
+ me(t);
74
74
  const $ = t._s.get(n);
75
- return i[R].call($, $);
76
- })), w), {}));
75
+ return i[A].call($, $);
76
+ })), b), {}));
77
77
  }
78
- return c = Ne(n, h, e, t, r, !0), c;
78
+ return c = _e(n, f, e, t, r, !0), c;
79
79
  }
80
- function Ne(n, e, t = {}, r, o, s) {
80
+ function _e(n, e, t = {}, r, o, s) {
81
81
  let i;
82
- const a = W({ actions: {} }, t);
82
+ const a = z({ actions: {} }, t);
83
83
  if (process.env.NODE_ENV !== "production" && !r._e.active)
84
84
  throw new Error("Pinia destroyed");
85
85
  const c = { deep: !0 };
86
- process.env.NODE_ENV !== "production" && (c.onTrigger = (l) => {
87
- h ? $ = l : h == !1 && !v._hotUpdating && (Array.isArray($) ? $.push(l) : console.error("🍍 debuggerEvents should be an array. This is most likely an internal Pinia bug."));
86
+ process.env.NODE_ENV !== "production" && (c.onTrigger = (d) => {
87
+ f ? $ = d : f == !1 && !v._hotUpdating && (Array.isArray($) ? $.push(d) : console.error("🍍 debuggerEvents should be an array. This is most likely an internal Pinia bug."));
88
88
  });
89
- let h, g, w = /* @__PURE__ */ new Set(), R = /* @__PURE__ */ new Set(), $;
90
- const T = r.state.value[n];
91
- !s && !T && (process.env.NODE_ENV === "production" || !o) && (r.state.value[n] = {});
92
- const L = M({});
93
- let P;
94
- function I(l) {
95
- let u;
96
- h = g = !1, process.env.NODE_ENV !== "production" && ($ = []), typeof l == "function" ? (l(r.state.value[n]), u = {
97
- type: ie.patchFunction,
89
+ let f, g, b = /* @__PURE__ */ new Set(), A = /* @__PURE__ */ new Set(), $;
90
+ const k = r.state.value[n];
91
+ !s && !k && (process.env.NODE_ENV === "production" || !o) && (r.state.value[n] = {});
92
+ const x = B({});
93
+ let N;
94
+ function D(d) {
95
+ let p;
96
+ f = g = !1, process.env.NODE_ENV !== "production" && ($ = []), typeof d == "function" ? (d(r.state.value[n]), p = {
97
+ type: le.patchFunction,
98
98
  storeId: n,
99
99
  events: $
100
- }) : (Re(r.state.value[n], l), u = {
101
- type: ie.patchObject,
102
- payload: l,
100
+ }) : (Ne(r.state.value[n], d), p = {
101
+ type: le.patchObject,
102
+ payload: d,
103
103
  storeId: n,
104
104
  events: $
105
105
  });
106
- const O = P = /* @__PURE__ */ Symbol();
107
- le().then(() => {
108
- P === O && (h = !0);
109
- }), g = !0, Y(w, u, r.state.value[n]);
110
- }
111
- const N = s ? function() {
112
- const { state: u } = t, O = u ? u() : {};
113
- this.$patch((m) => {
114
- W(m, O);
106
+ const R = N = /* @__PURE__ */ Symbol();
107
+ de().then(() => {
108
+ N === R && (f = !0);
109
+ }), g = !0, ee(b, p, r.state.value[n]);
110
+ }
111
+ const P = s ? function() {
112
+ const { state: p } = t, R = p ? p() : {};
113
+ this.$patch((F) => {
114
+ z(F, R);
115
115
  });
116
116
  } : (
117
117
  /* istanbul ignore next */
118
118
  process.env.NODE_ENV !== "production" ? () => {
119
119
  throw new Error(`🍍: Store "${n}" is built using the setup syntax and does not implement $reset().`);
120
- } : je
120
+ } : ze
121
121
  );
122
122
  function S() {
123
- i.stop(), w.clear(), R.clear(), r._s.delete(n);
124
- }
125
- const D = (l, u = "") => {
126
- if ($e in l)
127
- return l[me] = u, l;
128
- const O = function() {
129
- ge(r);
130
- const m = Array.from(arguments), f = /* @__PURE__ */ new Set(), b = /* @__PURE__ */ new Set();
131
- function A(k) {
132
- f.add(k);
123
+ i.stop(), b.clear(), A.clear(), r._s.delete(n);
124
+ }
125
+ const C = (d, p = "") => {
126
+ if (Ie in d)
127
+ return d[Ee] = p, d;
128
+ const R = function() {
129
+ me(r);
130
+ const F = Array.from(arguments), w = /* @__PURE__ */ new Set(), T = /* @__PURE__ */ new Set();
131
+ function L(m) {
132
+ w.add(m);
133
133
  }
134
- function C(k) {
135
- b.add(k);
134
+ function y(m) {
135
+ T.add(m);
136
136
  }
137
- Y(R, {
138
- args: m,
139
- name: O[me],
137
+ ee(A, {
138
+ args: F,
139
+ name: R[Ee],
140
140
  store: v,
141
- after: A,
142
- onError: C
141
+ after: L,
142
+ onError: y
143
143
  });
144
- let j;
144
+ let E;
145
145
  try {
146
- j = l.apply(this && this.$id === n ? this : v, m);
147
- } catch (k) {
148
- throw Y(b, k), k;
146
+ E = d.apply(this && this.$id === n ? this : v, F);
147
+ } catch (m) {
148
+ throw ee(T, m), m;
149
149
  }
150
- return j instanceof Promise ? j.then((k) => (Y(f, k), k)).catch((k) => (Y(b, k), Promise.reject(k))) : (Y(f, j), j);
150
+ return E instanceof Promise ? E.then((m) => (ee(w, m), m)).catch((m) => (ee(T, m), Promise.reject(m))) : (ee(w, E), E);
151
151
  };
152
- return O[$e] = !0, O[me] = u, O;
153
- }, E = /* @__PURE__ */ oe({
152
+ return R[Ie] = !0, R[Ee] = p, R;
153
+ }, O = /* @__PURE__ */ ae({
154
154
  actions: {},
155
155
  getters: {},
156
156
  state: [],
157
- hotState: L
157
+ hotState: x
158
158
  }), _ = {
159
159
  _p: r,
160
160
  // _s: scope,
161
161
  $id: n,
162
- $onAction: Ae.bind(null, R),
163
- $patch: I,
164
- $reset: N,
165
- $subscribe(l, u = {}) {
166
- const O = Ae(w, l, u.detached, () => m()), m = i.run(() => H(() => r.state.value[n], (f) => {
167
- (u.flush === "sync" ? g : h) && l({
162
+ $onAction: Te.bind(null, A),
163
+ $patch: D,
164
+ $reset: P,
165
+ $subscribe(d, p = {}) {
166
+ const R = Te(b, d, p.detached, () => F()), F = i.run(() => U(() => r.state.value[n], (w) => {
167
+ (p.flush === "sync" ? g : f) && d({
168
168
  storeId: n,
169
- type: ie.direct,
169
+ type: le.direct,
170
170
  events: $
171
- }, f);
172
- }, W({}, c, u)));
173
- return O;
171
+ }, w);
172
+ }, z({}, c, p)));
173
+ return R;
174
174
  },
175
175
  $dispose: S
176
- }, v = Ee(process.env.NODE_ENV !== "production" || process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && Q ? W(
176
+ }, v = ye(process.env.NODE_ENV !== "production" || process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && te ? z(
177
177
  {
178
- _hmrPayload: E,
179
- _customProperties: oe(/* @__PURE__ */ new Set())
178
+ _hmrPayload: O,
179
+ _customProperties: ae(/* @__PURE__ */ new Set())
180
180
  // devtools custom properties
181
181
  },
182
182
  _
@@ -184,81 +184,81 @@ function Ne(n, e, t = {}, r, o, s) {
184
184
  // setupStore
185
185
  ) : _);
186
186
  r._s.set(n, v);
187
- const V = (r._a && r._a.runWithContext || Qe)(() => r._e.run(() => (i = Je()).run(() => e({ action: D }))));
188
- for (const l in V) {
189
- const u = V[l];
190
- if (re(u) && !Ie(u) || ye(u))
191
- process.env.NODE_ENV !== "production" && o ? L.value[l] = se(V, l) : s || (T && et(u) && (re(u) ? u.value = T[l] : Re(u, T[l])), r.state.value[n][l] = u), process.env.NODE_ENV !== "production" && E.state.push(l);
192
- else if (typeof u == "function") {
193
- const O = process.env.NODE_ENV !== "production" && o ? u : D(u, l);
194
- V[l] = O, process.env.NODE_ENV !== "production" && (E.actions[l] = u), a.actions[l] = u;
195
- } else process.env.NODE_ENV !== "production" && Ie(u) && (E.getters[l] = s ? (
187
+ const M = (r._a && r._a.runWithContext || nt)(() => r._e.run(() => (i = Ye()).run(() => e({ action: C }))));
188
+ for (const d in M) {
189
+ const p = M[d];
190
+ if (se(p) && !Ce(p) || be(p))
191
+ process.env.NODE_ENV !== "production" && o ? x.value[d] = ce(M, d) : s || (k && st(p) && (se(p) ? p.value = k[d] : Ne(p, k[d])), r.state.value[n][d] = p), process.env.NODE_ENV !== "production" && O.state.push(d);
192
+ else if (typeof p == "function") {
193
+ const R = process.env.NODE_ENV !== "production" && o ? p : C(p, d);
194
+ M[d] = R, process.env.NODE_ENV !== "production" && (O.actions[d] = p), a.actions[d] = p;
195
+ } else process.env.NODE_ENV !== "production" && Ce(p) && (O.getters[d] = s ? (
196
196
  // @ts-expect-error
197
- t.getters[l]
198
- ) : u, Q && (V._getters || // @ts-expect-error: same
199
- (V._getters = oe([]))).push(l));
197
+ t.getters[d]
198
+ ) : p, te && (M._getters || // @ts-expect-error: same
199
+ (M._getters = ae([]))).push(d));
200
200
  }
201
- if (W(v, V), W(Le(v), V), Object.defineProperty(v, "$state", {
202
- get: () => process.env.NODE_ENV !== "production" && o ? L.value : r.state.value[n],
203
- set: (l) => {
201
+ if (z(v, M), z(Fe(v), M), Object.defineProperty(v, "$state", {
202
+ get: () => process.env.NODE_ENV !== "production" && o ? x.value : r.state.value[n],
203
+ set: (d) => {
204
204
  if (process.env.NODE_ENV !== "production" && o)
205
205
  throw new Error("cannot set hotState");
206
- I((u) => {
207
- W(u, l);
206
+ D((p) => {
207
+ z(p, d);
208
208
  });
209
209
  }
210
- }), process.env.NODE_ENV !== "production" && (v._hotUpdate = oe((l) => {
211
- v._hotUpdating = !0, l._hmrPayload.state.forEach((u) => {
212
- if (u in v.$state) {
213
- const O = l.$state[u], m = v.$state[u];
214
- typeof O == "object" && G(O) && G(m) ? Be(O, m) : l.$state[u] = m;
210
+ }), process.env.NODE_ENV !== "production" && (v._hotUpdate = ae((d) => {
211
+ v._hotUpdating = !0, d._hmrPayload.state.forEach((p) => {
212
+ if (p in v.$state) {
213
+ const R = d.$state[p], F = v.$state[p];
214
+ typeof R == "object" && Y(R) && Y(F) ? He(R, F) : d.$state[p] = F;
215
215
  }
216
- v[u] = se(l.$state, u);
217
- }), Object.keys(v.$state).forEach((u) => {
218
- u in l.$state || delete v[u];
219
- }), h = !1, g = !1, r.state.value[n] = se(l._hmrPayload, "hotState"), g = !0, le().then(() => {
220
- h = !0;
216
+ v[p] = ce(d.$state, p);
217
+ }), Object.keys(v.$state).forEach((p) => {
218
+ p in d.$state || delete v[p];
219
+ }), f = !1, g = !1, r.state.value[n] = ce(d._hmrPayload, "hotState"), g = !0, de().then(() => {
220
+ f = !0;
221
221
  });
222
- for (const u in l._hmrPayload.actions) {
223
- const O = l[u];
224
- v[u] = //
225
- D(O, u);
222
+ for (const p in d._hmrPayload.actions) {
223
+ const R = d[p];
224
+ v[p] = //
225
+ C(R, p);
226
226
  }
227
- for (const u in l._hmrPayload.getters) {
228
- const O = l._hmrPayload.getters[u], m = s ? (
227
+ for (const p in d._hmrPayload.getters) {
228
+ const R = d._hmrPayload.getters[p], F = s ? (
229
229
  // special handling of options api
230
- B(() => (ge(r), O.call(v, v)))
231
- ) : O;
232
- v[u] = //
233
- m;
230
+ W(() => (me(r), R.call(v, v)))
231
+ ) : R;
232
+ v[p] = //
233
+ F;
234
234
  }
235
- Object.keys(v._hmrPayload.getters).forEach((u) => {
236
- u in l._hmrPayload.getters || delete v[u];
237
- }), Object.keys(v._hmrPayload.actions).forEach((u) => {
238
- u in l._hmrPayload.actions || delete v[u];
239
- }), v._hmrPayload = l._hmrPayload, v._getters = l._getters, v._hotUpdating = !1;
240
- })), process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && Q) {
241
- const l = {
235
+ Object.keys(v._hmrPayload.getters).forEach((p) => {
236
+ p in d._hmrPayload.getters || delete v[p];
237
+ }), Object.keys(v._hmrPayload.actions).forEach((p) => {
238
+ p in d._hmrPayload.actions || delete v[p];
239
+ }), v._hmrPayload = d._hmrPayload, v._getters = d._getters, v._hotUpdating = !1;
240
+ })), process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && te) {
241
+ const d = {
242
242
  writable: !0,
243
243
  configurable: !0,
244
244
  // avoid warning on devtools trying to display this property
245
245
  enumerable: !1
246
246
  };
247
- ["_p", "_hmrPayload", "_getters", "_customProperties"].forEach((u) => {
248
- Object.defineProperty(v, u, W({ value: v[u] }, l));
247
+ ["_p", "_hmrPayload", "_getters", "_customProperties"].forEach((p) => {
248
+ Object.defineProperty(v, p, z({ value: v[p] }, d));
249
249
  });
250
250
  }
251
- return r._p.forEach((l) => {
252
- if (process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && Q) {
253
- const u = i.run(() => l({
251
+ return r._p.forEach((d) => {
252
+ if (process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && te) {
253
+ const p = i.run(() => d({
254
254
  store: v,
255
255
  app: r._a,
256
256
  pinia: r,
257
257
  options: a
258
258
  }));
259
- Object.keys(u || {}).forEach((O) => v._customProperties.add(O)), W(v, u);
259
+ Object.keys(p || {}).forEach((R) => v._customProperties.add(R)), z(v, p);
260
260
  } else
261
- W(v, i.run(() => l({
261
+ z(v, i.run(() => d({
262
262
  store: v,
263
263
  app: r._a,
264
264
  pinia: r,
@@ -266,67 +266,67 @@ function Ne(n, e, t = {}, r, o, s) {
266
266
  })));
267
267
  }), process.env.NODE_ENV !== "production" && v.$state && typeof v.$state == "object" && typeof v.$state.constructor == "function" && !v.$state.constructor.toString().includes("[native code]") && console.warn(`[🍍]: The "state" must be a plain object. It cannot be
268
268
  state: () => new MyClass()
269
- Found in store "${v.$id}".`), T && s && t.hydrate && t.hydrate(v.$state, T), h = !0, g = !0, v;
269
+ Found in store "${v.$id}".`), k && s && t.hydrate && t.hydrate(v.$state, k), f = !0, g = !0, v;
270
270
  }
271
271
  // @__NO_SIDE_EFFECTS__
272
- function tt(n, e, t) {
272
+ function it(n, e, t) {
273
273
  let r;
274
274
  const o = typeof e == "function";
275
275
  r = o ? t : e;
276
276
  function s(i, a) {
277
- const c = we();
277
+ const c = Ae();
278
278
  if (i = // in test mode, ignore the argument provided as we can always retrieve a
279
279
  // pinia instance with getActivePinia()
280
- (process.env.NODE_ENV === "test" && K && K._testing ? null : i) || (c ? te(Oe, null) : null), i && ge(i), process.env.NODE_ENV !== "production" && !K)
280
+ (process.env.NODE_ENV === "test" && G && G._testing ? null : i) || (c ? oe(Pe, null) : null), i && me(i), process.env.NODE_ENV !== "production" && !G)
281
281
  throw new Error(`[🍍]: "getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "app.use(pinia)"?
282
282
  See https://pinia.vuejs.org/core-concepts/outside-component-usage.html for help.
283
283
  This will fail in production.`);
284
- i = K, i._s.has(n) || (o ? Ne(n, e, r, i) : De(n, r, i), process.env.NODE_ENV !== "production" && (s._pinia = i));
285
- const h = i._s.get(n);
284
+ i = G, i._s.has(n) || (o ? _e(n, e, r, i) : ke(n, r, i), process.env.NODE_ENV !== "production" && (s._pinia = i));
285
+ const f = i._s.get(n);
286
286
  if (process.env.NODE_ENV !== "production" && a) {
287
- const g = "__hot:" + n, w = o ? Ne(g, e, r, i, !0) : De(g, W({}, r), i, !0);
288
- a._hotUpdate(w), delete i.state.value[g], i._s.delete(g);
287
+ const g = "__hot:" + n, b = o ? _e(g, e, r, i, !0) : ke(g, z({}, r), i, !0);
288
+ a._hotUpdate(b), delete i.state.value[g], i._s.delete(g);
289
289
  }
290
- if (process.env.NODE_ENV !== "production" && Q) {
291
- const g = Fe();
290
+ if (process.env.NODE_ENV !== "production" && te) {
291
+ const g = Me();
292
292
  if (g && g.proxy && // avoid adding stores that are just built for hot module replacement
293
293
  !a) {
294
- const w = g.proxy, R = "_pStores" in w ? w._pStores : w._pStores = {};
295
- R[n] = h;
294
+ const b = g.proxy, A = "_pStores" in b ? b._pStores : b._pStores = {};
295
+ A[n] = f;
296
296
  }
297
297
  }
298
- return h;
298
+ return f;
299
299
  }
300
300
  return s.$id = n, s;
301
301
  }
302
- function We(n) {
303
- const e = Le(n), t = {};
302
+ function Ue(n) {
303
+ const e = Fe(n), t = {};
304
304
  for (const r in e) {
305
305
  const o = e[r];
306
306
  o.effect ? t[r] = // ...
307
- B({
307
+ W({
308
308
  get: () => n[r],
309
309
  set(s) {
310
310
  n[r] = s;
311
311
  }
312
- }) : (re(o) || ye(o)) && (t[r] = // ---
313
- se(n, r));
312
+ }) : (se(o) || be(o)) && (t[r] = // ---
313
+ ce(n, r));
314
314
  }
315
315
  return t;
316
316
  }
317
- const rt = typeof window < "u" && typeof document < "u";
317
+ const at = typeof window < "u" && typeof document < "u";
318
318
  typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
319
- const nt = Object.prototype.toString, ot = (n) => nt.call(n) === "[object Object]", Ue = () => {
319
+ const ct = Object.prototype.toString, lt = (n) => ct.call(n) === "[object Object]", Je = () => {
320
320
  };
321
- function st(...n) {
322
- if (n.length !== 1) return se(...n);
321
+ function ut(...n) {
322
+ if (n.length !== 1) return ce(...n);
323
323
  const e = n[0];
324
- return typeof e == "function" ? Me(Ge(() => ({
324
+ return typeof e == "function" ? je(tt(() => ({
325
325
  get: e,
326
- set: Ue
327
- }))) : M(e);
326
+ set: Je
327
+ }))) : B(e);
328
328
  }
329
- function it(n, e) {
329
+ function ft(n, e) {
330
330
  function t(...r) {
331
331
  return new Promise((o, s) => {
332
332
  Promise.resolve(n(() => e.apply(this, r), {
@@ -338,9 +338,9 @@ function it(n, e) {
338
338
  }
339
339
  return t;
340
340
  }
341
- const ze = (n) => n();
342
- function at(n = ze, e = {}) {
343
- const { initialState: t = "active" } = e, r = st(t === "active");
341
+ const qe = (n) => n();
342
+ function dt(n = qe, e = {}) {
343
+ const { initialState: t = "active" } = e, r = ut(t === "active");
344
344
  function o() {
345
345
  r.value = !1;
346
346
  }
@@ -351,90 +351,90 @@ function at(n = ze, e = {}) {
351
351
  r.value && n(...a);
352
352
  };
353
353
  return {
354
- isActive: Me(r),
354
+ isActive: je(r),
355
355
  pause: o,
356
356
  resume: s,
357
357
  eventFilter: i
358
358
  };
359
359
  }
360
- function be(n) {
360
+ function Oe(n) {
361
361
  return Array.isArray(n) ? n : [n];
362
362
  }
363
- function ct(n) {
364
- return Fe();
363
+ function pt(n) {
364
+ return Me();
365
365
  }
366
- function lt(n, e, t = {}) {
367
- const { eventFilter: r = ze, ...o } = t;
368
- return H(n, it(r, e), o);
366
+ function ht(n, e, t = {}) {
367
+ const { eventFilter: r = qe, ...o } = t;
368
+ return U(n, ft(r, e), o);
369
369
  }
370
- function ut(n, e, t = {}) {
371
- const { eventFilter: r, initialState: o = "active", ...s } = t, { eventFilter: i, pause: a, resume: c, isActive: h } = at(r, { initialState: o });
370
+ function gt(n, e, t = {}) {
371
+ const { eventFilter: r, initialState: o = "active", ...s } = t, { eventFilter: i, pause: a, resume: c, isActive: f } = dt(r, { initialState: o });
372
372
  return {
373
- stop: lt(n, e, {
373
+ stop: ht(n, e, {
374
374
  ...s,
375
375
  eventFilter: i
376
376
  }),
377
377
  pause: a,
378
378
  resume: c,
379
- isActive: h
379
+ isActive: f
380
380
  };
381
381
  }
382
- const ft = ut;
383
- function dt(n, e = !0, t) {
384
- ct() ? Ve(n, t) : e ? n() : le(n);
382
+ const vt = gt;
383
+ function yt(n, e = !0, t) {
384
+ pt() ? Be(n, t) : e ? n() : de(n);
385
385
  }
386
- function pt(n, e, t) {
387
- return H(n, e, {
386
+ function mt(n, e, t) {
387
+ return U(n, e, {
388
388
  ...t,
389
389
  immediate: !0
390
390
  });
391
391
  }
392
- function ne(n, e, t) {
393
- return H(n, (o, s, i) => {
392
+ function ie(n, e, t) {
393
+ return U(n, (o, s, i) => {
394
394
  o && e(o, s, i);
395
395
  }, {
396
396
  ...t,
397
397
  once: !1
398
398
  });
399
399
  }
400
- const Z = rt ? window : void 0;
401
- function ht(n) {
400
+ const Q = at ? window : void 0;
401
+ function St(n) {
402
402
  var e;
403
403
  const t = q(n);
404
404
  return (e = t?.$el) !== null && e !== void 0 ? e : t;
405
405
  }
406
- function X(...n) {
407
- const e = (r, o, s, i) => (r.addEventListener(o, s, i), () => r.removeEventListener(o, s, i)), t = B(() => {
408
- const r = be(q(n[0])).filter((o) => o != null);
406
+ function re(...n) {
407
+ const e = (r, o, s, i) => (r.addEventListener(o, s, i), () => r.removeEventListener(o, s, i)), t = W(() => {
408
+ const r = Oe(q(n[0])).filter((o) => o != null);
409
409
  return r.every((o) => typeof o != "string") ? r : void 0;
410
410
  });
411
- return pt(() => {
411
+ return mt(() => {
412
412
  var r, o;
413
413
  return [
414
- (r = (o = t.value) === null || o === void 0 ? void 0 : o.map((s) => ht(s))) !== null && r !== void 0 ? r : [Z].filter((s) => s != null),
415
- be(q(t.value ? n[1] : n[0])),
416
- be(Ye(t.value ? n[2] : n[1])),
414
+ (r = (o = t.value) === null || o === void 0 ? void 0 : o.map((s) => St(s))) !== null && r !== void 0 ? r : [Q].filter((s) => s != null),
415
+ Oe(q(t.value ? n[1] : n[0])),
416
+ Oe(rt(t.value ? n[2] : n[1])),
417
417
  q(t.value ? n[3] : n[2])
418
418
  ];
419
419
  }, ([r, o, s, i], a, c) => {
420
420
  if (!r?.length || !o?.length || !s?.length) return;
421
- const h = ot(i) ? { ...i } : i, g = r.flatMap((w) => o.flatMap((R) => s.map(($) => e(w, R, $, h))));
421
+ const f = lt(i) ? { ...i } : i, g = r.flatMap((b) => o.flatMap((A) => s.map(($) => e(b, A, $, f))));
422
422
  c(() => {
423
- g.forEach((w) => w());
423
+ g.forEach((b) => b());
424
424
  });
425
425
  }, { flush: "post" });
426
426
  }
427
- const fe = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, de = "__vueuse_ssr_handlers__", gt = /* @__PURE__ */ vt();
428
- function vt() {
429
- return de in fe || (fe[de] = fe[de] || {}), fe[de];
427
+ const he = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, ge = "__vueuse_ssr_handlers__", bt = /* @__PURE__ */ wt();
428
+ function wt() {
429
+ return ge in he || (he[ge] = he[ge] || {}), he[ge];
430
430
  }
431
- function yt(n, e) {
432
- return gt[n] || e;
431
+ function Et(n, e) {
432
+ return bt[n] || e;
433
433
  }
434
- function mt(n) {
434
+ function Ot(n) {
435
435
  return n == null ? "any" : n instanceof Set ? "set" : n instanceof Map ? "map" : n instanceof Date ? "date" : typeof n == "boolean" ? "boolean" : typeof n == "string" ? "string" : typeof n == "object" ? "object" : Number.isNaN(n) ? "any" : "number";
436
436
  }
437
- const bt = {
437
+ const Rt = {
438
438
  boolean: {
439
439
  read: (n) => n === "true",
440
440
  write: (n) => String(n)
@@ -467,98 +467,98 @@ const bt = {
467
467
  read: (n) => new Date(n),
468
468
  write: (n) => n.toISOString()
469
469
  }
470
- }, Te = "vueuse-storage";
471
- function St(n, e, t, r = {}) {
470
+ }, Le = "vueuse-storage";
471
+ function At(n, e, t, r = {}) {
472
472
  var o;
473
- const { flush: s = "pre", deep: i = !0, listenToStorageChanges: a = !0, writeDefaults: c = !0, mergeDefaults: h = !1, shallow: g, window: w = Z, eventFilter: R, onError: $ = (f) => {
474
- console.error(f);
475
- }, initOnMounted: T } = r, L = (g ? xe : M)(e), P = B(() => q(n));
473
+ const { flush: s = "pre", deep: i = !0, listenToStorageChanges: a = !0, writeDefaults: c = !0, mergeDefaults: f = !1, shallow: g, window: b = Q, eventFilter: A, onError: $ = (w) => {
474
+ console.error(w);
475
+ }, initOnMounted: k } = r, x = (g ? We : B)(e), N = W(() => q(n));
476
476
  if (!t) try {
477
- t = yt("getDefaultStorage", () => Z?.localStorage)();
478
- } catch (f) {
479
- $(f);
477
+ t = Et("getDefaultStorage", () => Q?.localStorage)();
478
+ } catch (w) {
479
+ $(w);
480
480
  }
481
- if (!t) return L;
482
- const I = q(e), N = mt(I), S = (o = r.serializer) !== null && o !== void 0 ? o : bt[N], { pause: D, resume: E } = ft(L, (f) => l(f), {
481
+ if (!t) return x;
482
+ const D = q(e), P = Ot(D), S = (o = r.serializer) !== null && o !== void 0 ? o : Rt[P], { pause: C, resume: O } = vt(x, (w) => d(w), {
483
483
  flush: s,
484
484
  deep: i,
485
- eventFilter: R
485
+ eventFilter: A
486
486
  });
487
- H(P, () => O(), { flush: s });
487
+ U(N, () => R(), { flush: s });
488
488
  let _ = !1;
489
- const v = (f) => {
490
- T && !_ || O(f);
491
- }, x = (f) => {
492
- T && !_ || m(f);
489
+ const v = (w) => {
490
+ k && !_ || R(w);
491
+ }, j = (w) => {
492
+ k && !_ || F(w);
493
493
  };
494
- w && a && (t instanceof Storage ? X(w, "storage", v, { passive: !0 }) : X(w, Te, x)), T ? dt(() => {
495
- _ = !0, O();
496
- }) : O();
497
- function V(f, b) {
498
- if (w) {
499
- const A = {
500
- key: P.value,
501
- oldValue: f,
502
- newValue: b,
494
+ b && a && (t instanceof Storage ? re(b, "storage", v, { passive: !0 }) : re(b, Le, j)), k ? yt(() => {
495
+ _ = !0, R();
496
+ }) : R();
497
+ function M(w, T) {
498
+ if (b) {
499
+ const L = {
500
+ key: N.value,
501
+ oldValue: w,
502
+ newValue: T,
503
503
  storageArea: t
504
504
  };
505
- w.dispatchEvent(t instanceof Storage ? new StorageEvent("storage", A) : new CustomEvent(Te, { detail: A }));
505
+ b.dispatchEvent(t instanceof Storage ? new StorageEvent("storage", L) : new CustomEvent(Le, { detail: L }));
506
506
  }
507
507
  }
508
- function l(f) {
508
+ function d(w) {
509
509
  try {
510
- const b = t.getItem(P.value);
511
- if (f == null)
512
- V(b, null), t.removeItem(P.value);
510
+ const T = t.getItem(N.value);
511
+ if (w == null)
512
+ M(T, null), t.removeItem(N.value);
513
513
  else {
514
- const A = S.write(f);
515
- b !== A && (t.setItem(P.value, A), V(b, A));
514
+ const L = S.write(w);
515
+ T !== L && (t.setItem(N.value, L), M(T, L));
516
516
  }
517
- } catch (b) {
518
- $(b);
517
+ } catch (T) {
518
+ $(T);
519
519
  }
520
520
  }
521
- function u(f) {
522
- const b = f ? f.newValue : t.getItem(P.value);
523
- if (b == null)
524
- return c && I != null && t.setItem(P.value, S.write(I)), I;
525
- if (!f && h) {
526
- const A = S.read(b);
527
- return typeof h == "function" ? h(A, I) : N === "object" && !Array.isArray(A) ? {
528
- ...I,
529
- ...A
530
- } : A;
531
- } else return typeof b != "string" ? b : S.read(b);
532
- }
533
- function O(f) {
534
- if (!(f && f.storageArea !== t)) {
535
- if (f && f.key == null) {
536
- L.value = I;
521
+ function p(w) {
522
+ const T = w ? w.newValue : t.getItem(N.value);
523
+ if (T == null)
524
+ return c && D != null && t.setItem(N.value, S.write(D)), D;
525
+ if (!w && f) {
526
+ const L = S.read(T);
527
+ return typeof f == "function" ? f(L, D) : P === "object" && !Array.isArray(L) ? {
528
+ ...D,
529
+ ...L
530
+ } : L;
531
+ } else return typeof T != "string" ? T : S.read(T);
532
+ }
533
+ function R(w) {
534
+ if (!(w && w.storageArea !== t)) {
535
+ if (w && w.key == null) {
536
+ x.value = D;
537
537
  return;
538
538
  }
539
- if (!(f && f.key !== P.value)) {
540
- D();
539
+ if (!(w && w.key !== N.value)) {
540
+ C();
541
541
  try {
542
- const b = S.write(L.value);
543
- (f === void 0 || f?.newValue !== b) && (L.value = u(f));
544
- } catch (b) {
545
- $(b);
542
+ const T = S.write(x.value);
543
+ (w === void 0 || w?.newValue !== T) && (x.value = p(w));
544
+ } catch (T) {
545
+ $(T);
546
546
  } finally {
547
- f ? le(E) : E();
547
+ w ? de(O) : O();
548
548
  }
549
549
  }
550
550
  }
551
551
  }
552
- function m(f) {
553
- O(f.detail);
552
+ function F(w) {
553
+ R(w.detail);
554
554
  }
555
- return L;
555
+ return x;
556
556
  }
557
- function wt(n, e, t = {}) {
558
- const { window: r = Z } = t;
559
- return St(n, e, r?.localStorage, t);
557
+ function Pt(n, e, t = {}) {
558
+ const { window: r = Q } = t;
559
+ return At(n, e, r?.localStorage, t);
560
560
  }
561
- const Et = {
561
+ const Nt = {
562
562
  ctrl: "control",
563
563
  command: "meta",
564
564
  cmd: "meta",
@@ -568,69 +568,69 @@ const Et = {
568
568
  left: "arrowleft",
569
569
  right: "arrowright"
570
570
  };
571
- function Ot(n = {}) {
572
- const { reactive: e = !1, target: t = Z, aliasMap: r = Et, passive: o = !0, onEventFired: s = Ue } = n, i = Ee(/* @__PURE__ */ new Set()), a = {
571
+ function _t(n = {}) {
572
+ const { reactive: e = !1, target: t = Q, aliasMap: r = Nt, passive: o = !0, onEventFired: s = Je } = n, i = ye(/* @__PURE__ */ new Set()), a = {
573
573
  toJSON() {
574
574
  return {};
575
575
  },
576
576
  current: i
577
- }, c = e ? Ee(a) : a, h = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Map([
578
- ["Meta", h],
577
+ }, c = e ? ye(a) : a, f = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Map([
578
+ ["Meta", f],
579
579
  ["Shift", /* @__PURE__ */ new Set()],
580
580
  ["Alt", /* @__PURE__ */ new Set()]
581
- ]), w = /* @__PURE__ */ new Set();
582
- function R(N, S) {
583
- N in c && (e ? c[N] = S : c[N].value = S);
581
+ ]), b = /* @__PURE__ */ new Set();
582
+ function A(P, S) {
583
+ P in c && (e ? c[P] = S : c[P].value = S);
584
584
  }
585
585
  function $() {
586
586
  i.clear();
587
- for (const N of w) R(N, !1);
587
+ for (const P of b) A(P, !1);
588
588
  }
589
- function T(N, S, D) {
590
- if (!(!N || typeof S.getModifierState != "function")) {
591
- for (const [E, _] of g) if (S.getModifierState(E)) {
592
- D.forEach((v) => _.add(v));
589
+ function k(P, S, C) {
590
+ if (!(!P || typeof S.getModifierState != "function")) {
591
+ for (const [O, _] of g) if (S.getModifierState(O)) {
592
+ C.forEach((v) => _.add(v));
593
593
  break;
594
594
  }
595
595
  }
596
596
  }
597
- function L(N, S) {
598
- if (N) return;
599
- const D = `${S[0].toUpperCase()}${S.slice(1)}`, E = g.get(D);
600
- if (!["shift", "alt"].includes(S) || !E) return;
601
- const _ = Array.from(E), v = _.indexOf(S);
602
- _.forEach((x, V) => {
603
- V >= v && (i.delete(x), R(x, !1));
604
- }), E.clear();
605
- }
606
- function P(N, S) {
607
- var D, E;
608
- const _ = (D = N.key) === null || D === void 0 ? void 0 : D.toLowerCase(), v = [(E = N.code) === null || E === void 0 ? void 0 : E.toLowerCase(), _].filter(Boolean);
597
+ function x(P, S) {
598
+ if (P) return;
599
+ const C = `${S[0].toUpperCase()}${S.slice(1)}`, O = g.get(C);
600
+ if (!["shift", "alt"].includes(S) || !O) return;
601
+ const _ = Array.from(O), v = _.indexOf(S);
602
+ _.forEach((j, M) => {
603
+ M >= v && (i.delete(j), A(j, !1));
604
+ }), O.clear();
605
+ }
606
+ function N(P, S) {
607
+ var C, O;
608
+ const _ = (C = P.key) === null || C === void 0 ? void 0 : C.toLowerCase(), v = [(O = P.code) === null || O === void 0 ? void 0 : O.toLowerCase(), _].filter(Boolean);
609
609
  if (_ !== "") {
610
610
  _ && (S ? i.add(_) : i.delete(_));
611
- for (const x of v)
612
- w.add(x), R(x, S);
613
- T(S, N, [...i, ...v]), L(S, _), _ === "meta" && !S && (h.forEach((x) => {
614
- i.delete(x), R(x, !1);
615
- }), h.clear());
611
+ for (const j of v)
612
+ b.add(j), A(j, S);
613
+ k(S, P, [...i, ...v]), x(S, _), _ === "meta" && !S && (f.forEach((j) => {
614
+ i.delete(j), A(j, !1);
615
+ }), f.clear());
616
616
  }
617
617
  }
618
- X(t, "keydown", (N) => (P(N, !0), s(N)), { passive: o }), X(t, "keyup", (N) => (P(N, !1), s(N)), { passive: o }), X("blur", $, { passive: o }), X("focus", $, { passive: o });
619
- const I = new Proxy(c, { get(N, S, D) {
620
- if (typeof S != "string") return Reflect.get(N, S, D);
618
+ re(t, "keydown", (P) => (N(P, !0), s(P)), { passive: o }), re(t, "keyup", (P) => (N(P, !1), s(P)), { passive: o }), re("blur", $, { passive: o }), re("focus", $, { passive: o });
619
+ const D = new Proxy(c, { get(P, S, C) {
620
+ if (typeof S != "string") return Reflect.get(P, S, C);
621
621
  if (S = S.toLowerCase(), S in r && (S = r[S]), !(S in c)) if (/[+_-]/.test(S)) {
622
622
  const _ = S.split(/[+_-]/g).map((v) => v.trim());
623
- c[S] = B(() => _.map((v) => q(I[v])).every(Boolean));
624
- } else c[S] = xe(!1);
625
- const E = Reflect.get(N, S, D);
626
- return e ? q(E) : E;
623
+ c[S] = W(() => _.map((v) => q(D[v])).every(Boolean));
624
+ } else c[S] = We(!1);
625
+ const O = Reflect.get(P, S, C);
626
+ return e ? q(O) : O;
627
627
  } });
628
- return I;
628
+ return D;
629
629
  }
630
- function Se() {
630
+ function Re() {
631
631
  return typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
632
632
  }
633
- function pe(n) {
633
+ function ve(n) {
634
634
  const e = {
635
635
  type: n.type,
636
636
  clientId: n.clientId,
@@ -644,7 +644,7 @@ function pe(n) {
644
644
  timestamp: t.timestamp.toISOString()
645
645
  }))), e;
646
646
  }
647
- function Rt(n) {
647
+ function $t(n) {
648
648
  const e = {
649
649
  type: n.type,
650
650
  clientId: n.clientId,
@@ -658,54 +658,54 @@ function Rt(n) {
658
658
  timestamp: new Date(t.timestamp)
659
659
  }))), e;
660
660
  }
661
- const ue = /* @__PURE__ */ tt("hst-operation-log", () => {
662
- const n = M({
661
+ const pe = /* @__PURE__ */ it("hst-operation-log", () => {
662
+ const n = B({
663
663
  maxOperations: 100,
664
664
  enableCrossTabSync: !0,
665
665
  autoSyncInterval: 3e4,
666
666
  enablePersistence: !1,
667
667
  persistenceKeyPrefix: "stonecrop-ops"
668
- }), e = M([]), t = M(-1), r = M(Se()), o = M(!1), s = M([]), i = M(null), a = B(() => t.value < 0 ? !1 : e.value[t.value]?.reversible ?? !1), c = B(() => t.value < e.value.length - 1), h = B(() => {
669
- let d = 0;
670
- for (let p = t.value; p >= 0 && e.value[p]?.reversible; p--)
671
- d++;
672
- return d;
673
- }), g = B(() => e.value.length - 1 - t.value), w = B(() => ({
668
+ }), e = B([]), t = B(-1), r = B(Re()), o = B(!1), s = B([]), i = B(null), a = W(() => t.value < 0 ? !1 : e.value[t.value]?.reversible ?? !1), c = W(() => t.value < e.value.length - 1), f = W(() => {
669
+ let u = 0;
670
+ for (let l = t.value; l >= 0 && e.value[l]?.reversible; l--)
671
+ u++;
672
+ return u;
673
+ }), g = W(() => e.value.length - 1 - t.value), b = W(() => ({
674
674
  canUndo: a.value,
675
675
  canRedo: c.value,
676
- undoCount: h.value,
676
+ undoCount: f.value,
677
677
  redoCount: g.value,
678
678
  currentIndex: t.value
679
679
  }));
680
- function R(d) {
681
- n.value = { ...n.value, ...d }, n.value.enablePersistence && (C(), k()), n.value.enableCrossTabSync && u();
680
+ function A(u) {
681
+ n.value = { ...n.value, ...u }, n.value.enablePersistence && (y(), m()), n.value.enableCrossTabSync && p();
682
682
  }
683
- function $(d, p = "user") {
684
- const y = {
685
- ...d,
686
- id: Se(),
683
+ function $(u, l = "user") {
684
+ const h = {
685
+ ...u,
686
+ id: Re(),
687
687
  timestamp: /* @__PURE__ */ new Date(),
688
- source: p,
688
+ source: l,
689
689
  userId: n.value.userId
690
690
  };
691
- if (n.value.operationFilter && !n.value.operationFilter(y))
692
- return y.id;
691
+ if (n.value.operationFilter && !n.value.operationFilter(h))
692
+ return h.id;
693
693
  if (o.value)
694
- return s.value.push(y), y.id;
695
- if (t.value < e.value.length - 1 && (e.value = e.value.slice(0, t.value + 1)), e.value.push(y), t.value++, n.value.maxOperations && e.value.length > n.value.maxOperations) {
696
- const F = e.value.length - n.value.maxOperations;
697
- e.value = e.value.slice(F), t.value -= F;
694
+ return s.value.push(h), h.id;
695
+ if (t.value < e.value.length - 1 && (e.value = e.value.slice(0, t.value + 1)), e.value.push(h), t.value++, n.value.maxOperations && e.value.length > n.value.maxOperations) {
696
+ const I = e.value.length - n.value.maxOperations;
697
+ e.value = e.value.slice(I), t.value -= I;
698
698
  }
699
- return n.value.enableCrossTabSync && O(y), y.id;
699
+ return n.value.enableCrossTabSync && R(h), h.id;
700
700
  }
701
- function T() {
702
- o.value = !0, s.value = [], i.value = Se();
701
+ function k() {
702
+ o.value = !0, s.value = [], i.value = Re();
703
703
  }
704
- function L(d) {
704
+ function x(u) {
705
705
  if (!o.value || s.value.length === 0)
706
706
  return o.value = !1, s.value = [], i.value = null, null;
707
- const p = i.value, y = s.value.every((U) => U.reversible), F = {
708
- id: p,
707
+ const l = i.value, h = s.value.every((V) => V.reversible), I = {
708
+ id: l,
709
709
  type: "batch",
710
710
  path: "",
711
711
  // Batch doesn't have a single path
@@ -715,192 +715,192 @@ const ue = /* @__PURE__ */ tt("hst-operation-log", () => {
715
715
  doctype: s.value[0]?.doctype || "",
716
716
  timestamp: /* @__PURE__ */ new Date(),
717
717
  source: "user",
718
- reversible: y,
719
- irreversibleReason: y ? void 0 : "Contains irreversible operations",
720
- childOperationIds: s.value.map((U) => U.id),
721
- metadata: { description: d }
718
+ reversible: h,
719
+ irreversibleReason: h ? void 0 : "Contains irreversible operations",
720
+ childOperationIds: s.value.map((V) => V.id),
721
+ metadata: { description: u }
722
722
  };
723
- s.value.forEach((U) => {
724
- U.parentOperationId = p;
725
- }), e.value.push(...s.value, F), t.value = e.value.length - 1, n.value.enableCrossTabSync && m(s.value, F);
726
- const z = p;
727
- return o.value = !1, s.value = [], i.value = null, z;
723
+ s.value.forEach((V) => {
724
+ V.parentOperationId = l;
725
+ }), e.value.push(...s.value, I), t.value = e.value.length - 1, n.value.enableCrossTabSync && F(s.value, I);
726
+ const H = l;
727
+ return o.value = !1, s.value = [], i.value = null, H;
728
728
  }
729
- function P() {
729
+ function N() {
730
730
  o.value = !1, s.value = [], i.value = null;
731
731
  }
732
- function I(d) {
732
+ function D(u) {
733
733
  if (!a.value) return !1;
734
- const p = e.value[t.value];
735
- if (!p.reversible)
736
- return typeof console < "u" && p.irreversibleReason && console.warn("Cannot undo irreversible operation:", p.irreversibleReason), !1;
734
+ const l = e.value[t.value];
735
+ if (!l.reversible)
736
+ return typeof console < "u" && l.irreversibleReason && console.warn("Cannot undo irreversible operation:", l.irreversibleReason), !1;
737
737
  try {
738
- if (p.type === "batch" && p.childOperationIds)
739
- for (let y = p.childOperationIds.length - 1; y >= 0; y--) {
740
- const F = p.childOperationIds[y], z = e.value.find((U) => U.id === F);
741
- z && S(z, d);
738
+ if (l.type === "batch" && l.childOperationIds)
739
+ for (let h = l.childOperationIds.length - 1; h >= 0; h--) {
740
+ const I = l.childOperationIds[h], H = e.value.find((V) => V.id === I);
741
+ H && S(H, u);
742
742
  }
743
743
  else
744
- S(p, d);
745
- return t.value--, n.value.enableCrossTabSync && f(p), !0;
746
- } catch (y) {
747
- return typeof console < "u" && console.error("Undo failed:", y), !1;
744
+ S(l, u);
745
+ return t.value--, n.value.enableCrossTabSync && w(l), !0;
746
+ } catch (h) {
747
+ return typeof console < "u" && console.error("Undo failed:", h), !1;
748
748
  }
749
749
  }
750
- function N(d) {
750
+ function P(u) {
751
751
  if (!c.value) return !1;
752
- const p = e.value[t.value + 1];
752
+ const l = e.value[t.value + 1];
753
753
  try {
754
- if (p.type === "batch" && p.childOperationIds)
755
- for (const y of p.childOperationIds) {
756
- const F = e.value.find((z) => z.id === y);
757
- F && D(F, d);
754
+ if (l.type === "batch" && l.childOperationIds)
755
+ for (const h of l.childOperationIds) {
756
+ const I = e.value.find((H) => H.id === h);
757
+ I && C(I, u);
758
758
  }
759
759
  else
760
- D(p, d);
761
- return t.value++, n.value.enableCrossTabSync && b(p), !0;
762
- } catch (y) {
763
- return typeof console < "u" && console.error("Redo failed:", y), !1;
760
+ C(l, u);
761
+ return t.value++, n.value.enableCrossTabSync && T(l), !0;
762
+ } catch (h) {
763
+ return typeof console < "u" && console.error("Redo failed:", h), !1;
764
764
  }
765
765
  }
766
- function S(d, p) {
767
- (d.type === "set" || d.type === "delete") && p && typeof p.set == "function" && p.set(d.path, d.beforeValue, "undo");
766
+ function S(u, l) {
767
+ (u.type === "set" || u.type === "delete") && l && typeof l.set == "function" && l.set(u.path, u.beforeValue, "undo");
768
768
  }
769
- function D(d, p) {
770
- (d.type === "set" || d.type === "delete") && p && typeof p.set == "function" && p.set(d.path, d.afterValue, "redo");
769
+ function C(u, l) {
770
+ (u.type === "set" || u.type === "delete") && l && typeof l.set == "function" && l.set(u.path, u.afterValue, "redo");
771
771
  }
772
- function E() {
773
- const d = e.value.filter((y) => y.reversible).length, p = e.value.map((y) => y.timestamp);
772
+ function O() {
773
+ const u = e.value.filter((h) => h.reversible).length, l = e.value.map((h) => h.timestamp);
774
774
  return {
775
775
  operations: [...e.value],
776
776
  currentIndex: t.value,
777
777
  totalOperations: e.value.length,
778
- reversibleOperations: d,
779
- irreversibleOperations: e.value.length - d,
780
- oldestOperation: p.length > 0 ? new Date(Math.min(...p.map((y) => y.getTime()))) : void 0,
781
- newestOperation: p.length > 0 ? new Date(Math.max(...p.map((y) => y.getTime()))) : void 0
778
+ reversibleOperations: u,
779
+ irreversibleOperations: e.value.length - u,
780
+ oldestOperation: l.length > 0 ? new Date(Math.min(...l.map((h) => h.getTime()))) : void 0,
781
+ newestOperation: l.length > 0 ? new Date(Math.max(...l.map((h) => h.getTime()))) : void 0
782
782
  };
783
783
  }
784
784
  function _() {
785
785
  e.value = [], t.value = -1;
786
786
  }
787
- function v(d, p) {
788
- return e.value.filter((y) => y.doctype === d && (p === void 0 || y.recordId === p));
787
+ function v(u, l) {
788
+ return e.value.filter((h) => h.doctype === u && (l === void 0 || h.recordId === l));
789
789
  }
790
- function x(d, p) {
791
- const y = e.value.find((F) => F.id === d);
792
- y && (y.reversible = !1, y.irreversibleReason = p);
790
+ function j(u, l) {
791
+ const h = e.value.find((I) => I.id === u);
792
+ h && (h.reversible = !1, h.irreversibleReason = l);
793
793
  }
794
- function V(d, p, y, F = "success", z) {
795
- const U = {
794
+ function M(u, l, h, I = "success", H) {
795
+ const V = {
796
796
  type: "action",
797
- path: y && y.length > 0 ? `${d}.${y[0]}` : d,
797
+ path: h && h.length > 0 ? `${u}.${h[0]}` : u,
798
798
  fieldname: "",
799
799
  beforeValue: null,
800
800
  afterValue: null,
801
- doctype: d,
802
- recordId: y && y.length > 0 ? y[0] : void 0,
801
+ doctype: u,
802
+ recordId: h && h.length > 0 ? h[0] : void 0,
803
803
  reversible: !1,
804
804
  // Actions are typically not reversible
805
- actionName: p,
806
- actionRecordIds: y,
807
- actionResult: F,
808
- actionError: z
805
+ actionName: l,
806
+ actionRecordIds: h,
807
+ actionResult: I,
808
+ actionError: H
809
809
  };
810
- return $(U);
811
- }
812
- let l = null;
813
- function u() {
814
- typeof window > "u" || !window.BroadcastChannel || (l = new BroadcastChannel("stonecrop-operation-log"), l.addEventListener("message", (d) => {
815
- const p = d.data;
816
- if (!p || typeof p != "object") return;
817
- const y = Rt(p);
818
- y.clientId !== r.value && (y.type === "operation" && y.operation ? (e.value.push({ ...y.operation, source: "sync" }), t.value = e.value.length - 1) : y.type === "operation" && y.operations && (e.value.push(...y.operations.map((F) => ({ ...F, source: "sync" }))), t.value = e.value.length - 1));
810
+ return $(V);
811
+ }
812
+ let d = null;
813
+ function p() {
814
+ typeof window > "u" || !window.BroadcastChannel || (d = new BroadcastChannel("stonecrop-operation-log"), d.addEventListener("message", (u) => {
815
+ const l = u.data;
816
+ if (!l || typeof l != "object") return;
817
+ const h = $t(l);
818
+ h.clientId !== r.value && (h.type === "operation" && h.operation ? (e.value.push({ ...h.operation, source: "sync" }), t.value = e.value.length - 1) : h.type === "operation" && h.operations && (e.value.push(...h.operations.map((I) => ({ ...I, source: "sync" }))), t.value = e.value.length - 1));
819
819
  }));
820
820
  }
821
- function O(d) {
822
- if (!l) return;
823
- const p = {
821
+ function R(u) {
822
+ if (!d) return;
823
+ const l = {
824
824
  type: "operation",
825
- operation: d,
825
+ operation: u,
826
826
  clientId: r.value,
827
827
  timestamp: /* @__PURE__ */ new Date()
828
828
  };
829
- l.postMessage(pe(p));
829
+ d.postMessage(ve(l));
830
830
  }
831
- function m(d, p) {
832
- if (!l) return;
833
- const y = {
831
+ function F(u, l) {
832
+ if (!d) return;
833
+ const h = {
834
834
  type: "operation",
835
- operations: [...d, p],
835
+ operations: [...u, l],
836
836
  clientId: r.value,
837
837
  timestamp: /* @__PURE__ */ new Date()
838
838
  };
839
- l.postMessage(pe(y));
839
+ d.postMessage(ve(h));
840
840
  }
841
- function f(d) {
842
- if (!l) return;
843
- const p = {
841
+ function w(u) {
842
+ if (!d) return;
843
+ const l = {
844
844
  type: "undo",
845
- operation: d,
845
+ operation: u,
846
846
  clientId: r.value,
847
847
  timestamp: /* @__PURE__ */ new Date()
848
848
  };
849
- l.postMessage(pe(p));
849
+ d.postMessage(ve(l));
850
850
  }
851
- function b(d) {
852
- if (!l) return;
853
- const p = {
851
+ function T(u) {
852
+ if (!d) return;
853
+ const l = {
854
854
  type: "redo",
855
- operation: d,
855
+ operation: u,
856
856
  clientId: r.value,
857
857
  timestamp: /* @__PURE__ */ new Date()
858
858
  };
859
- l.postMessage(pe(p));
859
+ d.postMessage(ve(l));
860
860
  }
861
- const A = wt("stonecrop-ops-operations", null, {
861
+ const L = Pt("stonecrop-ops-operations", null, {
862
862
  serializer: {
863
- read: (d) => {
863
+ read: (u) => {
864
864
  try {
865
- return JSON.parse(d);
865
+ return JSON.parse(u);
866
866
  } catch {
867
867
  return null;
868
868
  }
869
869
  },
870
- write: (d) => d ? JSON.stringify(d) : ""
870
+ write: (u) => u ? JSON.stringify(u) : ""
871
871
  }
872
872
  });
873
- function C() {
873
+ function y() {
874
874
  if (!(typeof window > "u"))
875
875
  try {
876
- const d = A.value;
877
- d && Array.isArray(d.operations) && (e.value = d.operations.map((p) => ({
878
- ...p,
879
- timestamp: new Date(p.timestamp)
880
- })), t.value = d.currentIndex ?? -1);
881
- } catch (d) {
882
- typeof console < "u" && console.error("Failed to load operations from persistence:", d);
876
+ const u = L.value;
877
+ u && Array.isArray(u.operations) && (e.value = u.operations.map((l) => ({
878
+ ...l,
879
+ timestamp: new Date(l.timestamp)
880
+ })), t.value = u.currentIndex ?? -1);
881
+ } catch (u) {
882
+ typeof console < "u" && console.error("Failed to load operations from persistence:", u);
883
883
  }
884
884
  }
885
- function j() {
885
+ function E() {
886
886
  if (!(typeof window > "u"))
887
887
  try {
888
- A.value = {
889
- operations: e.value.map((d) => ({
890
- ...d,
891
- timestamp: d.timestamp.toISOString()
888
+ L.value = {
889
+ operations: e.value.map((u) => ({
890
+ ...u,
891
+ timestamp: u.timestamp.toISOString()
892
892
  })),
893
893
  currentIndex: t.value
894
894
  };
895
- } catch (d) {
896
- typeof console < "u" && console.error("Failed to save operations to persistence:", d);
895
+ } catch (u) {
896
+ typeof console < "u" && console.error("Failed to save operations to persistence:", u);
897
897
  }
898
898
  }
899
- function k() {
900
- H(
899
+ function m() {
900
+ U(
901
901
  [e, t],
902
902
  () => {
903
- n.value.enablePersistence && j();
903
+ n.value.enablePersistence && E();
904
904
  },
905
905
  { deep: !0 }
906
906
  );
@@ -911,28 +911,28 @@ const ue = /* @__PURE__ */ tt("hst-operation-log", () => {
911
911
  currentIndex: t,
912
912
  config: n,
913
913
  clientId: r,
914
- undoRedoState: w,
914
+ undoRedoState: b,
915
915
  // Computed
916
916
  canUndo: a,
917
917
  canRedo: c,
918
- undoCount: h,
918
+ undoCount: f,
919
919
  redoCount: g,
920
920
  // Methods
921
- configure: R,
921
+ configure: A,
922
922
  addOperation: $,
923
- startBatch: T,
924
- commitBatch: L,
925
- cancelBatch: P,
926
- undo: I,
927
- redo: N,
923
+ startBatch: k,
924
+ commitBatch: x,
925
+ cancelBatch: N,
926
+ undo: D,
927
+ redo: P,
928
928
  clear: _,
929
929
  getOperationsFor: v,
930
- getSnapshot: E,
931
- markIrreversible: x,
932
- logAction: V
930
+ getSnapshot: O,
931
+ markIrreversible: j,
932
+ logAction: M
933
933
  };
934
934
  });
935
- class ae {
935
+ class ue {
936
936
  /**
937
937
  * The root FieldTriggerEngine instance
938
938
  */
@@ -953,9 +953,9 @@ class ae {
953
953
  * @param options - Configuration options for the field trigger engine
954
954
  */
955
955
  constructor(e = {}) {
956
- if (ae._root)
957
- return ae._root;
958
- ae._root = this, this.options = {
956
+ if (ue._root)
957
+ return ue._root;
958
+ ue._root = this, this.options = {
959
959
  defaultTimeout: e.defaultTimeout ?? 5e3,
960
960
  debug: e.debug ?? !1,
961
961
  enableRollback: e.enableRollback ?? !0,
@@ -1045,48 +1045,48 @@ class ae {
1045
1045
  rolledBack: !1
1046
1046
  };
1047
1047
  const i = performance.now(), a = [];
1048
- let c = !1, h = !1, g;
1049
- const w = this.getFieldRollback(r, o), R = t.enableRollback ?? w ?? this.options.enableRollback;
1050
- R && e.store && (g = this.captureSnapshot(e));
1051
- for (const P of s)
1048
+ let c = !1, f = !1, g;
1049
+ const b = this.getFieldRollback(r, o), A = t.enableRollback ?? b ?? this.options.enableRollback;
1050
+ A && e.store && (g = this.captureSnapshot(e));
1051
+ for (const N of s)
1052
1052
  try {
1053
- const I = await this.executeAction(P, e, t.timeout);
1054
- if (a.push(I), !I.success) {
1053
+ const D = await this.executeAction(N, e, t.timeout);
1054
+ if (a.push(D), !D.success) {
1055
1055
  c = !0;
1056
1056
  break;
1057
1057
  }
1058
- } catch (I) {
1058
+ } catch (D) {
1059
1059
  const S = {
1060
1060
  success: !1,
1061
- error: I instanceof Error ? I : new Error(String(I)),
1061
+ error: D instanceof Error ? D : new Error(String(D)),
1062
1062
  executionTime: 0,
1063
- action: P
1063
+ action: N
1064
1064
  };
1065
1065
  a.push(S), c = !0;
1066
1066
  break;
1067
1067
  }
1068
- if (R && c && g && e.store)
1068
+ if (A && c && g && e.store)
1069
1069
  try {
1070
- this.restoreSnapshot(e, g), h = !0;
1071
- } catch (P) {
1072
- console.error("[FieldTriggers] Rollback failed:", P);
1070
+ this.restoreSnapshot(e, g), f = !0;
1071
+ } catch (N) {
1072
+ console.error("[FieldTriggers] Rollback failed:", N);
1073
1073
  }
1074
- const $ = performance.now() - i, T = a.filter((P) => !P.success);
1075
- if (T.length > 0 && this.options.errorHandler)
1076
- for (const P of T)
1074
+ const $ = performance.now() - i, k = a.filter((N) => !N.success);
1075
+ if (k.length > 0 && this.options.errorHandler)
1076
+ for (const N of k)
1077
1077
  try {
1078
- this.options.errorHandler(P.error, e, P.action);
1079
- } catch (I) {
1080
- console.error("[FieldTriggers] Error in global error handler:", I);
1078
+ this.options.errorHandler(N.error, e, N.action);
1079
+ } catch (D) {
1080
+ console.error("[FieldTriggers] Error in global error handler:", D);
1081
1081
  }
1082
1082
  return {
1083
1083
  path: e.path,
1084
1084
  actionResults: a,
1085
1085
  totalExecutionTime: $,
1086
- allSucceeded: a.every((P) => P.success),
1086
+ allSucceeded: a.every((N) => N.success),
1087
1087
  stoppedOnError: c,
1088
- rolledBack: h,
1089
- snapshot: this.options.debug && R ? g : void 0
1088
+ rolledBack: f,
1089
+ snapshot: this.options.debug && A ? g : void 0
1090
1090
  // Only include snapshot in debug mode if rollback is enabled
1091
1091
  };
1092
1092
  }
@@ -1103,18 +1103,18 @@ class ae {
1103
1103
  const i = [];
1104
1104
  for (const c of s)
1105
1105
  try {
1106
- const h = await this.executeTransitionAction(c, e, t.timeout);
1107
- if (i.push(h), !h.success)
1106
+ const f = await this.executeTransitionAction(c, e, t.timeout);
1107
+ if (i.push(f), !f.success)
1108
1108
  break;
1109
- } catch (h) {
1110
- const w = {
1109
+ } catch (f) {
1110
+ const b = {
1111
1111
  success: !1,
1112
- error: h instanceof Error ? h : new Error(String(h)),
1112
+ error: f instanceof Error ? f : new Error(String(f)),
1113
1113
  executionTime: 0,
1114
1114
  action: c,
1115
1115
  transition: o
1116
1116
  };
1117
- i.push(w);
1117
+ i.push(b);
1118
1118
  break;
1119
1119
  }
1120
1120
  const a = i.filter((c) => !c.success);
@@ -1122,8 +1122,8 @@ class ae {
1122
1122
  for (const c of a)
1123
1123
  try {
1124
1124
  this.options.errorHandler(c.error, e, c.action);
1125
- } catch (h) {
1126
- console.error("[FieldTriggers] Error in global error handler:", h);
1125
+ } catch (f) {
1126
+ console.error("[FieldTriggers] Error in global error handler:", f);
1127
1127
  }
1128
1128
  return i;
1129
1129
  }
@@ -1268,20 +1268,20 @@ class ae {
1268
1268
  }
1269
1269
  }
1270
1270
  }
1271
- function J(n) {
1272
- return new ae(n);
1271
+ function K(n) {
1272
+ return new ue(n);
1273
1273
  }
1274
- function Tt(n, e) {
1275
- J().registerAction(n, e);
1274
+ function xt(n, e) {
1275
+ K().registerAction(n, e);
1276
1276
  }
1277
- function Ct(n, e) {
1278
- J().registerTransitionAction(n, e);
1277
+ function Mt(n, e) {
1278
+ K().registerTransitionAction(n, e);
1279
1279
  }
1280
- function kt(n, e, t) {
1281
- J().setFieldRollback(n, e, t);
1280
+ function Ft(n, e, t) {
1281
+ K().setFieldRollback(n, e, t);
1282
1282
  }
1283
- async function Ft(n, e, t) {
1284
- const r = J(), o = {
1283
+ async function Bt(n, e, t) {
1284
+ const r = K(), o = {
1285
1285
  path: t?.path || (t?.recordId ? `${n}.${t.recordId}` : n),
1286
1286
  fieldname: "",
1287
1287
  beforeValue: void 0,
@@ -1297,28 +1297,28 @@ async function Ft(n, e, t) {
1297
1297
  };
1298
1298
  return await r.executeTransitionActions(o);
1299
1299
  }
1300
- function Lt(n, e) {
1300
+ function jt(n, e) {
1301
1301
  if (n)
1302
1302
  try {
1303
- ue().markIrreversible(n, e);
1303
+ pe().markIrreversible(n, e);
1304
1304
  } catch {
1305
1305
  }
1306
1306
  }
1307
- function Ce() {
1307
+ function Ve() {
1308
1308
  try {
1309
- return ue();
1309
+ return pe();
1310
1310
  } catch {
1311
1311
  return null;
1312
1312
  }
1313
1313
  }
1314
- class ee {
1314
+ class ne {
1315
1315
  static instance;
1316
1316
  /**
1317
1317
  * Gets the singleton instance of HST
1318
1318
  * @returns The HST singleton instance
1319
1319
  */
1320
1320
  static getInstance() {
1321
- return ee.instance || (ee.instance = new ee()), ee.instance;
1321
+ return ne.instance || (ne.instance = new ne()), ne.instance;
1322
1322
  }
1323
1323
  /**
1324
1324
  * Gets the global registry instance
@@ -1352,7 +1352,7 @@ class ee {
1352
1352
  return t.registry[e];
1353
1353
  }
1354
1354
  }
1355
- class ve {
1355
+ class Se {
1356
1356
  target;
1357
1357
  parentPath;
1358
1358
  rootNode;
@@ -1360,15 +1360,15 @@ class ve {
1360
1360
  parentDoctype;
1361
1361
  hst;
1362
1362
  constructor(e, t, r = "", o = null, s) {
1363
- return this.target = e, this.parentPath = r, this.rootNode = o || this, this.doctype = t, this.parentDoctype = s, this.hst = ee.getInstance(), new Proxy(this, {
1363
+ return this.target = e, this.parentPath = r, this.rootNode = o || this, this.doctype = t, this.parentDoctype = s, this.hst = ne.getInstance(), new Proxy(this, {
1364
1364
  get(i, a) {
1365
1365
  if (a in i) return i[a];
1366
1366
  const c = String(a);
1367
1367
  return i.getNode(c);
1368
1368
  },
1369
1369
  set(i, a, c) {
1370
- const h = String(a);
1371
- return i.set(h, c), !0;
1370
+ const f = String(a);
1371
+ return i.set(f, c), !0;
1372
1372
  }
1373
1373
  });
1374
1374
  }
@@ -1379,23 +1379,23 @@ class ve {
1379
1379
  getNode(e) {
1380
1380
  const t = this.resolvePath(e), r = this.resolveValue(e), o = t.split(".");
1381
1381
  let s = this.doctype;
1382
- return this.doctype === "StonecropStore" && o.length >= 1 && (s = o[0]), typeof r == "object" && r !== null && !this.isPrimitive(r) ? new ve(r, s, t, this.rootNode, this.parentDoctype) : new ve(r, s, t, this.rootNode, this.parentDoctype);
1382
+ return this.doctype === "StonecropStore" && o.length >= 1 && (s = o[0]), typeof r == "object" && r !== null && !this.isPrimitive(r) ? new Se(r, s, t, this.rootNode, this.parentDoctype) : new Se(r, s, t, this.rootNode, this.parentDoctype);
1383
1383
  }
1384
1384
  set(e, t, r = "user") {
1385
1385
  const o = this.resolvePath(e), s = this.has(e) ? this.get(e) : void 0;
1386
1386
  if (r !== "undo" && r !== "redo") {
1387
- const i = Ce();
1387
+ const i = Ve();
1388
1388
  if (i && typeof i.addOperation == "function") {
1389
- const a = o.split("."), c = this.doctype === "StonecropStore" && a.length >= 1 ? a[0] : this.doctype, h = a.length >= 2 ? a[1] : void 0, g = a.slice(2).join(".") || a[a.length - 1], R = t === void 0 && s !== void 0 ? "delete" : "set";
1389
+ const a = o.split("."), c = this.doctype === "StonecropStore" && a.length >= 1 ? a[0] : this.doctype, f = a.length >= 2 ? a[1] : void 0, g = a.slice(2).join(".") || a[a.length - 1], A = t === void 0 && s !== void 0 ? "delete" : "set";
1390
1390
  i.addOperation(
1391
1391
  {
1392
- type: R,
1392
+ type: A,
1393
1393
  path: o,
1394
1394
  fieldname: g,
1395
1395
  beforeValue: s,
1396
1396
  afterValue: t,
1397
1397
  doctype: c,
1398
- recordId: h,
1398
+ recordId: f,
1399
1399
  reversible: !0
1400
1400
  // Default to reversible, can be changed by field triggers
1401
1401
  },
@@ -1446,7 +1446,7 @@ class ve {
1446
1446
  * Trigger an XState transition with optional context data
1447
1447
  */
1448
1448
  async triggerTransition(e, t) {
1449
- const r = J(), o = this.parentPath.split(".");
1449
+ const r = K(), o = this.parentPath.split(".");
1450
1450
  let s = this.doctype, i;
1451
1451
  this.doctype === "StonecropStore" && o.length >= 1 && (s = o[0]), o.length >= 2 && (i = o[1]);
1452
1452
  const a = {
@@ -1464,7 +1464,7 @@ class ve {
1464
1464
  currentState: t?.currentState,
1465
1465
  targetState: t?.targetState,
1466
1466
  fsmContext: t?.fsmContext
1467
- }, c = Ce();
1467
+ }, c = Ve();
1468
1468
  return c && typeof c.addOperation == "function" && c.addOperation(
1469
1469
  {
1470
1470
  type: "transition",
@@ -1531,12 +1531,12 @@ class ve {
1531
1531
  const o = e.split(".");
1532
1532
  if (o.length < 3)
1533
1533
  return;
1534
- const s = J(), i = o.slice(2).join(".") || o[o.length - 1];
1534
+ const s = K(), i = o.slice(2).join(".") || o[o.length - 1];
1535
1535
  let a = this.doctype;
1536
1536
  this.doctype === "StonecropStore" && o.length >= 1 && (a = o[0]);
1537
1537
  let c;
1538
1538
  o.length >= 2 && (c = o[1]);
1539
- const h = {
1539
+ const f = {
1540
1540
  path: e,
1541
1541
  fieldname: i,
1542
1542
  beforeValue: t,
@@ -1548,7 +1548,7 @@ class ve {
1548
1548
  store: this.rootNode || void 0
1549
1549
  // Pass the root store for snapshot/rollback capabilities
1550
1550
  };
1551
- await s.executeFieldTriggers(h);
1551
+ await s.executeFieldTriggers(f);
1552
1552
  } catch (o) {
1553
1553
  o instanceof Error && console.warn("Field trigger error:", o.message);
1554
1554
  }
@@ -1567,8 +1567,8 @@ class ve {
1567
1567
  try {
1568
1568
  const c = e;
1569
1569
  if ("constructor" in c && c.constructor && typeof c.constructor == "object" && "name" in c.constructor) {
1570
- const h = c.constructor.name;
1571
- i = typeof h == "string" ? h : void 0;
1570
+ const f = c.constructor.name;
1571
+ i = typeof f == "string" ? f : void 0;
1572
1572
  }
1573
1573
  } catch {
1574
1574
  i = void 0;
@@ -1579,14 +1579,19 @@ class ve {
1579
1579
  isPrimitive(e) {
1580
1580
  return e == null || typeof e == "string" || typeof e == "number" || typeof e == "boolean" || typeof e == "function" || typeof e == "symbol" || typeof e == "bigint";
1581
1581
  }
1582
+ /**
1583
+ * Parse a path string into segments, handling both dot notation and array bracket notation
1584
+ * @param path - The path string to parse (e.g., "order.456.line_items[0].product")
1585
+ * @returns Array of path segments (e.g., ['order', '456', 'line_items', '0', 'product'])
1586
+ */
1582
1587
  parsePath(e) {
1583
- return e ? e.split(".").filter((t) => t.length > 0) : [];
1588
+ return e ? e.replace(/\[(\d+)\]/g, ".$1").split(".").filter((r) => r.length > 0) : [];
1584
1589
  }
1585
1590
  }
1586
- function Nt(n, e, t) {
1587
- return new ve(n, e, "", null, t);
1591
+ function Dt(n, e, t) {
1592
+ return new Se(n, e, "", null, t);
1588
1593
  }
1589
- class He {
1594
+ class Ke {
1590
1595
  hstStore;
1591
1596
  _operationLogStore;
1592
1597
  _operationLogConfig;
@@ -1605,7 +1610,7 @@ class He {
1605
1610
  * @internal
1606
1611
  */
1607
1612
  getOperationLogStore() {
1608
- return this._operationLogStore || (this._operationLogStore = ue(), this._operationLogConfig && this._operationLogStore.configure(this._operationLogConfig)), this._operationLogStore;
1613
+ return this._operationLogStore || (this._operationLogStore = pe(), this._operationLogConfig && this._operationLogStore.configure(this._operationLogConfig)), this._operationLogStore;
1609
1614
  }
1610
1615
  /**
1611
1616
  * Initialize the HST store structure
@@ -1614,7 +1619,7 @@ class He {
1614
1619
  const e = {};
1615
1620
  Object.keys(this.registry.registry).forEach((t) => {
1616
1621
  e[t] = {};
1617
- }), this.hstStore = Nt(e, "StonecropStore");
1622
+ }), this.hstStore = Dt(ye(e), "StonecropStore");
1618
1623
  }
1619
1624
  /**
1620
1625
  * Setup automatic sync with Registry when doctypes are added
@@ -1701,18 +1706,18 @@ class He {
1701
1706
  */
1702
1707
  runAction(e, t, r) {
1703
1708
  const s = this.registry.registry[e.slug]?.actions?.get(t), i = Array.isArray(r) ? r.filter((g) => typeof g == "string") : void 0, a = this.getOperationLogStore();
1704
- let c = "success", h;
1709
+ let c = "success", f;
1705
1710
  try {
1706
1711
  s && s.length > 0 && s.forEach((g) => {
1707
1712
  try {
1708
1713
  new Function("args", g)(r);
1709
- } catch (w) {
1710
- throw c = "failure", h = w instanceof Error ? w.message : "Unknown error", w;
1714
+ } catch (b) {
1715
+ throw c = "failure", f = b instanceof Error ? b.message : "Unknown error", b;
1711
1716
  }
1712
1717
  });
1713
1718
  } catch {
1714
1719
  } finally {
1715
- a.logAction(e.doctype, t, i, c, h);
1720
+ a.logAction(e.doctype, t, i, c, f);
1716
1721
  }
1717
1722
  }
1718
1723
  /**
@@ -1758,9 +1763,14 @@ class He {
1758
1763
  return this.hstStore;
1759
1764
  }
1760
1765
  }
1761
- function Vt(n) {
1766
+ function Wt(n) {
1762
1767
  n || (n = {});
1763
- const e = n.registry || te("$registry"), t = te("$stonecrop"), r = M(), o = M(), s = M({}), i = M(), a = M(), c = M([]), h = M(-1), g = B(() => r.value?.getOperationLogStore().canUndo ?? !1), w = B(() => r.value?.getOperationLogStore().canRedo ?? !1), R = B(() => r.value?.getOperationLogStore().undoCount ?? 0), $ = B(() => r.value?.getOperationLogStore().redoCount ?? 0), T = B(
1768
+ const e = n.registry || oe("$registry"), t = oe("$stonecrop"), r = B(), o = B(), s = B({}), i = B(), a = B(), c = B([]);
1769
+ if (n.doctype && e) {
1770
+ const y = n.doctype.schema ? Array.isArray(n.doctype.schema) ? n.doctype.schema : Array.from(n.doctype.schema) : [];
1771
+ c.value = e.resolveSchema(y);
1772
+ }
1773
+ const f = B([]), g = B(-1), b = W(() => r.value?.getOperationLogStore().canUndo ?? !1), A = W(() => r.value?.getOperationLogStore().canRedo ?? !1), $ = W(() => r.value?.getOperationLogStore().undoCount ?? 0), k = W(() => r.value?.getOperationLogStore().redoCount ?? 0), x = W(
1764
1774
  () => r.value?.getOperationLogStore().undoRedoState ?? {
1765
1775
  canUndo: !1,
1766
1776
  canRedo: !1,
@@ -1768,159 +1778,202 @@ function Vt(n) {
1768
1778
  redoCount: 0,
1769
1779
  currentIndex: -1
1770
1780
  }
1771
- ), L = (m) => r.value?.getOperationLogStore().undo(m) ?? !1, P = (m) => r.value?.getOperationLogStore().redo(m) ?? !1, I = () => {
1781
+ ), N = (y) => r.value?.getOperationLogStore().undo(y) ?? !1, D = (y) => r.value?.getOperationLogStore().redo(y) ?? !1, P = () => {
1772
1782
  r.value?.getOperationLogStore().startBatch();
1773
- }, N = (m) => r.value?.getOperationLogStore().commitBatch(m) ?? null, S = () => {
1783
+ }, S = (y) => r.value?.getOperationLogStore().commitBatch(y) ?? null, C = () => {
1774
1784
  r.value?.getOperationLogStore().cancelBatch();
1775
- }, D = () => {
1785
+ }, O = () => {
1776
1786
  r.value?.getOperationLogStore().clear();
1777
- }, E = (m, f) => r.value?.getOperationLogStore().getOperationsFor(m, f) ?? [], _ = () => r.value?.getOperationLogStore().getSnapshot() ?? {
1787
+ }, _ = (y, E) => r.value?.getOperationLogStore().getOperationsFor(y, E) ?? [], v = () => r.value?.getOperationLogStore().getSnapshot() ?? {
1778
1788
  operations: [],
1779
1789
  currentIndex: -1,
1780
1790
  totalOperations: 0,
1781
1791
  reversibleOperations: 0,
1782
1792
  irreversibleOperations: 0
1783
- }, v = (m, f) => {
1784
- r.value?.getOperationLogStore().markIrreversible(m, f);
1785
- }, x = (m, f, b, A = "success", C) => r.value?.getOperationLogStore().logAction(m, f, b, A, C) ?? "", V = (m) => {
1786
- r.value?.getOperationLogStore().configure(m);
1793
+ }, j = (y, E) => {
1794
+ r.value?.getOperationLogStore().markIrreversible(y, E);
1795
+ }, M = (y, E, m, u = "success", l) => r.value?.getOperationLogStore().logAction(y, E, m, u, l) ?? "", d = (y) => {
1796
+ r.value?.getOperationLogStore().configure(y);
1787
1797
  };
1788
- Ve(async () => {
1798
+ Be(async () => {
1789
1799
  if (e) {
1790
- r.value = t || new He(e);
1800
+ r.value = t || new Ke(e);
1791
1801
  try {
1792
- const m = r.value.getOperationLogStore(), f = We(m);
1793
- c.value = f.operations.value, h.value = f.currentIndex.value, H(
1794
- () => f.operations.value,
1795
- (b) => {
1796
- c.value = b;
1802
+ const y = r.value.getOperationLogStore(), E = Ue(y);
1803
+ f.value = E.operations.value, g.value = E.currentIndex.value, U(
1804
+ () => E.operations.value,
1805
+ (m) => {
1806
+ f.value = m;
1797
1807
  }
1798
- ), H(
1799
- () => f.currentIndex.value,
1800
- (b) => {
1801
- h.value = b;
1808
+ ), U(
1809
+ () => E.currentIndex.value,
1810
+ (m) => {
1811
+ g.value = m;
1802
1812
  }
1803
1813
  );
1804
1814
  } catch {
1805
1815
  }
1806
1816
  if (!n.doctype && e.router) {
1807
- const m = e.router.currentRoute.value;
1808
- if (!m.path) return;
1809
- const f = m.path.split("/").filter((A) => A.length > 0), b = f[1]?.toLowerCase();
1810
- if (f.length > 0) {
1811
- const A = {
1812
- path: m.path,
1813
- segments: f
1814
- }, C = await e.getMeta?.(A);
1815
- if (C) {
1816
- if (e.addDoctype(C), r.value.setup(C), i.value = C, a.value = b, o.value = r.value.getStore(), b && b !== "new") {
1817
- const j = r.value.getRecordById(C, b);
1818
- if (j)
1819
- s.value = j.get("") || {};
1817
+ const y = e.router.currentRoute.value;
1818
+ if (!y.path) return;
1819
+ const E = y.path.split("/").filter((u) => u.length > 0), m = E[1]?.toLowerCase();
1820
+ if (E.length > 0) {
1821
+ const u = {
1822
+ path: y.path,
1823
+ segments: E
1824
+ }, l = await e.getMeta?.(u);
1825
+ if (l) {
1826
+ if (e.addDoctype(l), r.value.setup(l), i.value = l, a.value = m, o.value = r.value.getStore(), e) {
1827
+ const h = l.schema ? Array.isArray(l.schema) ? l.schema : Array.from(l.schema) : [];
1828
+ c.value = e.resolveSchema(h);
1829
+ }
1830
+ if (m && m !== "new") {
1831
+ const h = r.value.getRecordById(l, m);
1832
+ if (h)
1833
+ s.value = h.get("") || {};
1820
1834
  else
1821
1835
  try {
1822
- await r.value.getRecord(C, b);
1823
- const k = r.value.getRecordById(C, b);
1824
- k && (s.value = k.get("") || {});
1836
+ await r.value.getRecord(l, m);
1837
+ const I = r.value.getRecordById(l, m);
1838
+ I && (s.value = I.get("") || {});
1825
1839
  } catch {
1826
- s.value = he(C);
1840
+ s.value = J(l);
1827
1841
  }
1828
1842
  } else
1829
- s.value = he(C);
1830
- o.value && ke(C, b || "new", s, o.value), r.value.runAction(C, "load", b ? [b] : void 0);
1843
+ s.value = J(l);
1844
+ o.value && xe(l, m || "new", s, o.value), r.value.runAction(l, "load", m ? [m] : void 0);
1831
1845
  }
1832
1846
  }
1833
1847
  }
1834
1848
  if (n.doctype) {
1835
1849
  o.value = r.value.getStore();
1836
- const m = n.doctype, f = n.recordId;
1837
- if (f && f !== "new") {
1838
- const b = r.value.getRecordById(m, f);
1839
- if (b)
1840
- s.value = b.get("") || {};
1850
+ const y = n.doctype, E = n.recordId;
1851
+ if (E && E !== "new") {
1852
+ const m = r.value.getRecordById(y, E);
1853
+ if (m)
1854
+ s.value = m.get("") || {};
1841
1855
  else
1842
1856
  try {
1843
- await r.value.getRecord(m, f);
1844
- const A = r.value.getRecordById(m, f);
1845
- A && (s.value = A.get("") || {});
1857
+ await r.value.getRecord(y, E);
1858
+ const u = r.value.getRecordById(y, E);
1859
+ u && (s.value = u.get("") || {});
1846
1860
  } catch {
1847
- s.value = he(m);
1861
+ s.value = J(y);
1848
1862
  }
1849
1863
  } else
1850
- s.value = he(m);
1851
- o.value && ke(m, f || "new", s, o.value);
1864
+ s.value = J(y);
1865
+ o.value && xe(y, E || "new", s, o.value);
1852
1866
  }
1853
1867
  }
1854
1868
  });
1855
- const l = (m, f) => {
1856
- const b = n.doctype || i.value;
1857
- if (!b) return "";
1858
- const A = f || n.recordId || a.value || "new";
1859
- return `${b.slug}.${A}.${m}`;
1860
- }, u = (m) => {
1861
- const f = n.doctype || i.value;
1862
- if (!(!o.value || !r.value || !f))
1869
+ const p = (y, E) => {
1870
+ const m = n.doctype || i.value;
1871
+ if (!m) return "";
1872
+ const u = E || n.recordId || a.value || "new";
1873
+ return `${m.slug}.${u}.${y}`;
1874
+ }, R = (y) => {
1875
+ const E = n.doctype || i.value;
1876
+ if (!(!o.value || !r.value || !E))
1863
1877
  try {
1864
- const b = m.path.split(".");
1865
- if (b.length >= 2) {
1866
- const j = b[0], k = b[1];
1867
- if (o.value.has(`${j}.${k}`) || r.value.addRecord(f, k, { ...s.value }), b.length > 3) {
1868
- const d = `${j}.${k}`, p = b.slice(2);
1869
- let y = d;
1870
- for (let F = 0; F < p.length - 1; F++)
1871
- if (y += `.${p[F]}`, !o.value.has(y)) {
1872
- const z = p[F + 1], U = !isNaN(Number(z));
1873
- o.value.set(y, U ? [] : {});
1878
+ const m = y.path.split(".");
1879
+ if (m.length >= 2) {
1880
+ const h = m[0], I = m[1];
1881
+ if (o.value.has(`${h}.${I}`) || r.value.addRecord(E, I, { ...s.value }), m.length > 3) {
1882
+ const H = `${h}.${I}`, V = m.slice(2);
1883
+ let Z = H;
1884
+ for (let X = 0; X < V.length - 1; X++)
1885
+ if (Z += `.${V[X]}`, !o.value.has(Z)) {
1886
+ const we = V[X + 1], Qe = !isNaN(Number(we));
1887
+ o.value.set(Z, Qe ? [] : {});
1874
1888
  }
1875
1889
  }
1876
1890
  }
1877
- o.value.set(m.path, m.value);
1878
- const A = m.fieldname.split("."), C = { ...s.value };
1879
- A.length === 1 ? C[A[0]] = m.value : Pt(C, A, m.value), s.value = C;
1891
+ o.value.set(y.path, y.value);
1892
+ const u = y.fieldname.split("."), l = { ...s.value };
1893
+ u.length === 1 ? l[u[0]] = y.value : Tt(l, u, y.value), s.value = l;
1880
1894
  } catch {
1881
1895
  }
1882
1896
  };
1883
- (n.doctype || e?.router) && (_e("hstPathProvider", l), _e("hstChangeHandler", u));
1884
- const O = {
1885
- operations: c,
1886
- currentIndex: h,
1887
- undoRedoState: T,
1888
- canUndo: g,
1889
- canRedo: w,
1890
- undoCount: R,
1891
- redoCount: $,
1892
- undo: L,
1893
- redo: P,
1894
- startBatch: I,
1895
- commitBatch: N,
1896
- cancelBatch: S,
1897
- clear: D,
1898
- getOperationsFor: E,
1899
- getSnapshot: _,
1900
- markIrreversible: v,
1901
- logAction: x,
1902
- configure: V
1897
+ (n.doctype || e?.router) && (De("hstPathProvider", p), De("hstChangeHandler", R));
1898
+ const F = (y, E, m) => {
1899
+ if (!r.value)
1900
+ return J(E);
1901
+ if (m)
1902
+ try {
1903
+ const u = o.value?.get(y);
1904
+ return u && typeof u == "object" ? u : J(E);
1905
+ } catch {
1906
+ return J(E);
1907
+ }
1908
+ return J(E);
1909
+ }, w = async (y, E) => {
1910
+ if (!o.value || !r.value)
1911
+ throw new Error("HST store not initialized");
1912
+ const m = `${y.slug}.${E}`, l = { ...o.value.get(m) || {} }, h = y.schema ? Array.isArray(y.schema) ? y.schema : Array.from(y.schema) : [], H = (e ? e.resolveSchema(h) : h).filter(
1913
+ (V) => "fieldtype" in V && V.fieldtype === "Doctype" && "schema" in V && Array.isArray(V.schema)
1914
+ );
1915
+ for (const V of H) {
1916
+ const Z = V, X = `${m}.${Z.fieldname}`, we = Ze(Z.schema, X, o.value);
1917
+ l[Z.fieldname] = we;
1918
+ }
1919
+ return l;
1920
+ }, T = (y, E) => ({
1921
+ provideHSTPath: (l) => `${y}.${l}`,
1922
+ handleHSTChange: (l) => {
1923
+ const h = l.path.startsWith(y) ? l.path : `${y}.${l.fieldname}`;
1924
+ R({
1925
+ ...l,
1926
+ path: h
1927
+ });
1928
+ }
1929
+ }), L = {
1930
+ operations: f,
1931
+ currentIndex: g,
1932
+ undoRedoState: x,
1933
+ canUndo: b,
1934
+ canRedo: A,
1935
+ undoCount: $,
1936
+ redoCount: k,
1937
+ undo: N,
1938
+ redo: D,
1939
+ startBatch: P,
1940
+ commitBatch: S,
1941
+ cancelBatch: C,
1942
+ clear: O,
1943
+ getOperationsFor: _,
1944
+ getSnapshot: v,
1945
+ markIrreversible: j,
1946
+ logAction: M,
1947
+ configure: d
1903
1948
  };
1904
1949
  return n.doctype ? {
1905
1950
  stonecrop: r,
1906
- operationLog: O,
1907
- provideHSTPath: l,
1908
- handleHSTChange: u,
1951
+ operationLog: L,
1952
+ provideHSTPath: p,
1953
+ handleHSTChange: R,
1909
1954
  hstStore: o,
1910
- formData: s
1955
+ formData: s,
1956
+ resolvedSchema: c,
1957
+ loadNestedData: F,
1958
+ saveRecursive: w,
1959
+ createNestedContext: T
1911
1960
  } : !n.doctype && e?.router ? {
1912
1961
  stonecrop: r,
1913
- operationLog: O,
1914
- provideHSTPath: l,
1915
- handleHSTChange: u,
1962
+ operationLog: L,
1963
+ provideHSTPath: p,
1964
+ handleHSTChange: R,
1916
1965
  hstStore: o,
1917
- formData: s
1966
+ formData: s,
1967
+ resolvedSchema: c,
1968
+ loadNestedData: F,
1969
+ saveRecursive: w,
1970
+ createNestedContext: T
1918
1971
  } : {
1919
1972
  stonecrop: r,
1920
- operationLog: O
1973
+ operationLog: L
1921
1974
  };
1922
1975
  }
1923
- function he(n) {
1976
+ function J(n) {
1924
1977
  const e = {};
1925
1978
  return n.schema && n.schema.forEach((t) => {
1926
1979
  switch ("fieldtype" in t ? t.fieldtype : "Data") {
@@ -1946,8 +1999,8 @@ function he(n) {
1946
1999
  }
1947
2000
  }), e;
1948
2001
  }
1949
- function ke(n, e, t, r) {
1950
- H(
2002
+ function xe(n, e, t, r) {
2003
+ U(
1951
2004
  t,
1952
2005
  (o) => {
1953
2006
  const s = `${n.slug}.${e}`;
@@ -1962,7 +2015,7 @@ function ke(n, e, t, r) {
1962
2015
  { deep: !0 }
1963
2016
  );
1964
2017
  }
1965
- function Pt(n, e, t) {
2018
+ function Tt(n, e, t) {
1966
2019
  let r = n;
1967
2020
  for (let s = 0; s < e.length - 1; s++) {
1968
2021
  const i = e[s];
@@ -1971,42 +2024,52 @@ function Pt(n, e, t) {
1971
2024
  const o = e[e.length - 1];
1972
2025
  r[o] = t;
1973
2026
  }
1974
- function qe(n) {
1975
- const t = te("$operationLogStore", void 0) || ue();
2027
+ function Ze(n, e, t) {
2028
+ const o = { ...t.get(e) || {} }, s = n.filter(
2029
+ (i) => "fieldtype" in i && i.fieldtype === "Doctype" && "schema" in i && Array.isArray(i.schema)
2030
+ );
2031
+ for (const i of s) {
2032
+ const a = i, c = `${e}.${a.fieldname}`, f = Ze(a.schema, c, t);
2033
+ o[a.fieldname] = f;
2034
+ }
2035
+ return o;
2036
+ }
2037
+ function Ge(n) {
2038
+ const t = oe("$operationLogStore", void 0) || pe();
1976
2039
  n && t.configure(n);
1977
- const { operations: r, currentIndex: o, undoRedoState: s, canUndo: i, canRedo: a, undoCount: c, redoCount: h } = We(t);
1978
- function g(E) {
1979
- return t.undo(E);
2040
+ const { operations: r, currentIndex: o, undoRedoState: s, canUndo: i, canRedo: a, undoCount: c, redoCount: f } = Ue(t);
2041
+ function g(O) {
2042
+ return t.undo(O);
1980
2043
  }
1981
- function w(E) {
1982
- return t.redo(E);
2044
+ function b(O) {
2045
+ return t.redo(O);
1983
2046
  }
1984
- function R() {
2047
+ function A() {
1985
2048
  t.startBatch();
1986
2049
  }
1987
- function $(E) {
1988
- return t.commitBatch(E);
2050
+ function $(O) {
2051
+ return t.commitBatch(O);
1989
2052
  }
1990
- function T() {
2053
+ function k() {
1991
2054
  t.cancelBatch();
1992
2055
  }
1993
- function L() {
2056
+ function x() {
1994
2057
  t.clear();
1995
2058
  }
1996
- function P(E, _) {
1997
- return t.getOperationsFor(E, _);
2059
+ function N(O, _) {
2060
+ return t.getOperationsFor(O, _);
1998
2061
  }
1999
- function I() {
2062
+ function D() {
2000
2063
  return t.getSnapshot();
2001
2064
  }
2002
- function N(E, _) {
2003
- t.markIrreversible(E, _);
2065
+ function P(O, _) {
2066
+ t.markIrreversible(O, _);
2004
2067
  }
2005
- function S(E, _, v, x = "success", V) {
2006
- return t.logAction(E, _, v, x, V);
2068
+ function S(O, _, v, j = "success", M) {
2069
+ return t.logAction(O, _, v, j, M);
2007
2070
  }
2008
- function D(E) {
2009
- t.configure(E);
2071
+ function C(O) {
2072
+ t.configure(O);
2010
2073
  }
2011
2074
  return {
2012
2075
  // State
@@ -2016,38 +2079,38 @@ function qe(n) {
2016
2079
  canUndo: i,
2017
2080
  canRedo: a,
2018
2081
  undoCount: c,
2019
- redoCount: h,
2082
+ redoCount: f,
2020
2083
  // Methods
2021
2084
  undo: g,
2022
- redo: w,
2023
- startBatch: R,
2085
+ redo: b,
2086
+ startBatch: A,
2024
2087
  commitBatch: $,
2025
- cancelBatch: T,
2026
- clear: L,
2027
- getOperationsFor: P,
2028
- getSnapshot: I,
2029
- markIrreversible: N,
2088
+ cancelBatch: k,
2089
+ clear: x,
2090
+ getOperationsFor: N,
2091
+ getSnapshot: D,
2092
+ markIrreversible: P,
2030
2093
  logAction: S,
2031
- configure: D
2094
+ configure: C
2032
2095
  };
2033
2096
  }
2034
- function Mt(n, e = !0) {
2097
+ function Ht(n, e = !0) {
2035
2098
  if (!e) return;
2036
- const { undo: t, redo: r, canUndo: o, canRedo: s } = qe(), i = Ot();
2037
- ne(i["Ctrl+Z"], () => {
2099
+ const { undo: t, redo: r, canUndo: o, canRedo: s } = Ge(), i = _t();
2100
+ ie(i["Ctrl+Z"], () => {
2038
2101
  o.value && t(n);
2039
- }), ne(i["Meta+Z"], () => {
2102
+ }), ie(i["Meta+Z"], () => {
2040
2103
  o.value && t(n);
2041
- }), ne(i["Ctrl+Shift+Z"], () => {
2104
+ }), ie(i["Ctrl+Shift+Z"], () => {
2042
2105
  s.value && r(n);
2043
- }), ne(i["Meta+Shift+Z"], () => {
2106
+ }), ie(i["Meta+Shift+Z"], () => {
2044
2107
  s.value && r(n);
2045
- }), ne(i["Ctrl+Y"], () => {
2108
+ }), ie(i["Ctrl+Y"], () => {
2046
2109
  s.value && r(n);
2047
2110
  });
2048
2111
  }
2049
- async function xt(n, e) {
2050
- const { startBatch: t, commitBatch: r, cancelBatch: o } = qe();
2112
+ async function zt(n, e) {
2113
+ const { startBatch: t, commitBatch: r, cancelBatch: o } = Ge();
2051
2114
  t();
2052
2115
  try {
2053
2116
  return await n(), r(e);
@@ -2055,7 +2118,7 @@ async function xt(n, e) {
2055
2118
  throw o(), s;
2056
2119
  }
2057
2120
  }
2058
- class Bt {
2121
+ class Ut {
2059
2122
  /**
2060
2123
  * The doctype name
2061
2124
  * @public
@@ -2117,7 +2180,7 @@ class Bt {
2117
2180
  return this.doctype.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
2118
2181
  }
2119
2182
  }
2120
- class ce {
2183
+ class fe {
2121
2184
  /**
2122
2185
  * The root Registry instance
2123
2186
  */
@@ -2144,9 +2207,9 @@ class ce {
2144
2207
  * @param getMeta - Optional function to fetch doctype metadata from an API
2145
2208
  */
2146
2209
  constructor(e, t) {
2147
- if (ce._root)
2148
- return ce._root;
2149
- ce._root = this, this.name = "Registry", this.registry = {}, this.router = e, this.getMeta = t;
2210
+ if (fe._root)
2211
+ return fe._root;
2212
+ fe._root = this, this.name = "Registry", this.registry = {}, this.router = e, this.getMeta = t;
2150
2213
  }
2151
2214
  /**
2152
2215
  * The getMeta function fetches doctype metadata from an API based on route context
@@ -2161,13 +2224,138 @@ class ce {
2161
2224
  */
2162
2225
  addDoctype(e) {
2163
2226
  e.doctype in Object.keys(this.registry) || (this.registry[e.slug] = e);
2164
- const t = J();
2227
+ const t = K();
2165
2228
  t.registerDoctypeActions(e.doctype, e.actions), e.slug !== e.doctype && t.registerDoctypeActions(e.slug, e.actions), e.component && this.router && !this.router.hasRoute(e.doctype) && this.router.addRoute({
2166
2229
  path: `/${e.slug}`,
2167
2230
  name: e.slug,
2168
2231
  component: e.component
2169
2232
  });
2170
2233
  }
2234
+ /**
2235
+ * Resolve nested Doctype and Table fields in a schema by embedding child schemas inline.
2236
+ *
2237
+ * @remarks
2238
+ * Walks the schema array and for each field with `fieldtype: 'Doctype'` and a string
2239
+ * `options` value, looks up the referenced doctype in the registry and embeds its schema
2240
+ * as the field's `schema` property. Recurses for deeply nested doctypes.
2241
+ *
2242
+ * For fields with `fieldtype: 'Table'`, looks up the referenced child doctype and
2243
+ * auto-derives `columns` from its schema fields (unless columns are already provided).
2244
+ * Also sets sensible defaults for `component` (`'ATable'`) and `config` (`{ view: 'list' }`).
2245
+ * Row data is expected to come from the parent form's data model at `data[fieldname]`.
2246
+ *
2247
+ * Returns a new array — does not mutate the original schema.
2248
+ *
2249
+ * @param schema - The schema array to resolve
2250
+ * @returns A new schema array with nested Doctype fields resolved
2251
+ *
2252
+ * @example
2253
+ * ```ts
2254
+ * registry.addDoctype(addressDoctype)
2255
+ * registry.addDoctype(customerDoctype)
2256
+ *
2257
+ * // Before: customer schema has { fieldname: 'address', fieldtype: 'Doctype', options: 'address' }
2258
+ * const resolved = registry.resolveSchema(customerSchema)
2259
+ * // After: address field now has schema: [...address fields...]
2260
+ * ```
2261
+ *
2262
+ * @public
2263
+ */
2264
+ resolveSchema(e, t) {
2265
+ const r = t || /* @__PURE__ */ new Set();
2266
+ return e.map((o) => {
2267
+ if ("fieldtype" in o && o.fieldtype === "Doctype" && "options" in o && typeof o.options == "string") {
2268
+ const s = o.options;
2269
+ if (r.has(s))
2270
+ return { ...o };
2271
+ const i = this.registry[s];
2272
+ if (i && i.schema) {
2273
+ const a = Array.isArray(i.schema) ? i.schema : Array.from(i.schema);
2274
+ r.add(s);
2275
+ const c = this.resolveSchema(a, r);
2276
+ return r.delete(s), { ...o, schema: c };
2277
+ }
2278
+ }
2279
+ if ("fieldtype" in o && o.fieldtype === "Table" && "options" in o && typeof o.options == "string") {
2280
+ const s = o.options;
2281
+ if (r.has(s))
2282
+ return { ...o };
2283
+ const i = this.registry[s];
2284
+ if (i && i.schema) {
2285
+ const a = Array.isArray(i.schema) ? i.schema : Array.from(i.schema), c = { ...o };
2286
+ return (!("columns" in o) || !o.columns) && (c.columns = a.map((f) => ({
2287
+ name: f.fieldname,
2288
+ fieldname: f.fieldname,
2289
+ label: "label" in f && f.label || f.fieldname,
2290
+ fieldtype: "fieldtype" in f ? f.fieldtype : "Data",
2291
+ align: "align" in f && f.align || "left",
2292
+ edit: "edit" in f ? f.edit : !0,
2293
+ width: "width" in f && f.width || "20ch"
2294
+ }))), c.component || (c.component = "ATable"), (!("config" in o) || !o.config) && (c.config = { view: "list" }), (!("rows" in o) || !o.rows) && (c.rows = []), c;
2295
+ }
2296
+ }
2297
+ return { ...o };
2298
+ });
2299
+ }
2300
+ /**
2301
+ * Initialize a new record with default values based on a schema.
2302
+ *
2303
+ * @remarks
2304
+ * Creates a plain object with keys from the schema's fieldnames and default values
2305
+ * derived from each field's `fieldtype`:
2306
+ * - Data, Text → `''`
2307
+ * - Check → `false`
2308
+ * - Int, Float, Decimal, Currency, Quantity → `0`
2309
+ * - Table → `[]`
2310
+ * - JSON, Doctype → `{}`
2311
+ * - All others → `null`
2312
+ *
2313
+ * For Doctype fields with a resolved `schema` array, recursively initializes the nested record.
2314
+ *
2315
+ * @param schema - The schema array to derive defaults from
2316
+ * @returns A plain object with default values for each field
2317
+ *
2318
+ * @example
2319
+ * ```ts
2320
+ * const defaults = registry.initializeRecord(addressSchema)
2321
+ * // { street: '', city: '', state: '', zip_code: '' }
2322
+ * ```
2323
+ *
2324
+ * @public
2325
+ */
2326
+ initializeRecord(e) {
2327
+ const t = {};
2328
+ return e.forEach((r) => {
2329
+ switch ("fieldtype" in r ? r.fieldtype : "Data") {
2330
+ case "Data":
2331
+ case "Text":
2332
+ case "Code":
2333
+ t[r.fieldname] = "";
2334
+ break;
2335
+ case "Check":
2336
+ t[r.fieldname] = !1;
2337
+ break;
2338
+ case "Int":
2339
+ case "Float":
2340
+ case "Decimal":
2341
+ case "Currency":
2342
+ case "Quantity":
2343
+ t[r.fieldname] = 0;
2344
+ break;
2345
+ case "Table":
2346
+ t[r.fieldname] = [];
2347
+ break;
2348
+ case "JSON":
2349
+ t[r.fieldname] = {};
2350
+ break;
2351
+ case "Doctype":
2352
+ "schema" in r && Array.isArray(r.schema) ? t[r.fieldname] = this.initializeRecord(r.schema) : t[r.fieldname] = {};
2353
+ break;
2354
+ default:
2355
+ t[r.fieldname] = null;
2356
+ }
2357
+ }), t;
2358
+ }
2171
2359
  // TODO: should we allow clearing the registry at all?
2172
2360
  // clear() {
2173
2361
  // this.registry = {}
@@ -2181,25 +2369,25 @@ class ce {
2181
2369
  // }
2182
2370
  // }
2183
2371
  }
2184
- async function _t(n, e, t) {
2185
- await le();
2372
+ async function It(n, e, t) {
2373
+ await de();
2186
2374
  try {
2187
2375
  await t(n, e);
2188
2376
  } catch {
2189
2377
  }
2190
2378
  }
2191
- const jt = {
2379
+ const Jt = {
2192
2380
  install: (n, e) => {
2193
2381
  const t = n.config.globalProperties.$router, r = e?.router, o = t || r;
2194
2382
  !t && r && n.use(r);
2195
- const s = new ce(o, e?.getMeta);
2383
+ const s = new fe(o, e?.getMeta);
2196
2384
  n.provide("$registry", s), n.config.globalProperties.$registry = s;
2197
- const i = new He(s);
2385
+ const i = new Ke(s);
2198
2386
  n.provide("$stonecrop", i), n.config.globalProperties.$stonecrop = i;
2199
2387
  try {
2200
2388
  const a = n.config.globalProperties.$pinia;
2201
2389
  if (a) {
2202
- const c = ue(a);
2390
+ const c = pe(a);
2203
2391
  n.provide("$operationLogStore", c), n.config.globalProperties.$operationLogStore = c;
2204
2392
  }
2205
2393
  } catch (a) {
@@ -2208,11 +2396,11 @@ const jt = {
2208
2396
  if (e?.components)
2209
2397
  for (const [a, c] of Object.entries(e.components))
2210
2398
  n.component(a, c);
2211
- e?.autoInitializeRouter && e.onRouterInitialized && _t(s, i, e.onRouterInitialized);
2399
+ e?.autoInitializeRouter && e.onRouterInitialized && It(s, i, e.onRouterInitialized);
2212
2400
  }
2213
2401
  };
2214
- var At = /* @__PURE__ */ ((n) => (n.ERROR = "error", n.WARNING = "warning", n.INFO = "info", n))(At || {});
2215
- class $t {
2402
+ var Ct = /* @__PURE__ */ ((n) => (n.ERROR = "error", n.WARNING = "warning", n.INFO = "info", n))(Ct || {});
2403
+ class kt {
2216
2404
  options;
2217
2405
  /**
2218
2406
  * Creates a new SchemaValidator instance
@@ -2247,7 +2435,7 @@ class $t {
2247
2435
  ).length, c = s.filter(
2248
2436
  (g) => g.severity === "warning"
2249
2437
  /* WARNING */
2250
- ).length, h = s.filter(
2438
+ ).length, f = s.filter(
2251
2439
  (g) => g.severity === "info"
2252
2440
  /* INFO */
2253
2441
  ).length;
@@ -2256,7 +2444,7 @@ class $t {
2256
2444
  issues: s,
2257
2445
  errorCount: a,
2258
2446
  warningCount: c,
2259
- infoCount: h
2447
+ infoCount: f
2260
2448
  };
2261
2449
  }
2262
2450
  /**
@@ -2365,13 +2553,13 @@ class $t {
2365
2553
  for (const [i, a] of Object.entries(t.states)) {
2366
2554
  const c = a;
2367
2555
  if (c.on) {
2368
- for (const [h, g] of Object.entries(c.on))
2556
+ for (const [f, g] of Object.entries(c.on))
2369
2557
  if (typeof g == "string")
2370
2558
  s.add(g);
2371
2559
  else if (g && typeof g == "object") {
2372
- const w = "target" in g ? g.target : void 0;
2373
- typeof w == "string" ? s.add(w) : Array.isArray(w) && w.forEach((R) => {
2374
- typeof R == "string" && s.add(R);
2560
+ const b = "target" in g ? g.target : void 0;
2561
+ typeof b == "string" ? s.add(b) : Array.isArray(b) && b.forEach((A) => {
2562
+ typeof A == "string" && s.add(A);
2375
2563
  });
2376
2564
  }
2377
2565
  }
@@ -2391,7 +2579,7 @@ class $t {
2391
2579
  * @internal
2392
2580
  */
2393
2581
  validateActionRegistration(e, t) {
2394
- const r = [], o = J();
2582
+ const r = [], o = K();
2395
2583
  for (const [s, i] of Object.entries(t)) {
2396
2584
  if (!Array.isArray(i)) {
2397
2585
  r.push({
@@ -2417,36 +2605,36 @@ class $t {
2417
2605
  return r;
2418
2606
  }
2419
2607
  }
2420
- function It(n, e) {
2421
- return new $t({
2608
+ function Lt(n, e) {
2609
+ return new kt({
2422
2610
  registry: n,
2423
2611
  ...e
2424
2612
  });
2425
2613
  }
2426
- function Wt(n, e, t, r, o) {
2427
- return It(t).validate(n, e, r, o);
2614
+ function qt(n, e, t, r, o) {
2615
+ return Lt(t).validate(n, e, r, o);
2428
2616
  }
2429
2617
  export {
2430
- Bt as DoctypeMeta,
2431
- ee as HST,
2432
- ce as Registry,
2433
- $t as SchemaValidator,
2434
- He as Stonecrop,
2435
- At as ValidationSeverity,
2436
- Nt as createHST,
2437
- It as createValidator,
2438
- jt as default,
2439
- J as getGlobalTriggerEngine,
2440
- Lt as markOperationIrreversible,
2441
- Tt as registerGlobalAction,
2442
- Ct as registerTransitionAction,
2443
- kt as setFieldRollback,
2444
- Ft as triggerTransition,
2445
- qe as useOperationLog,
2446
- ue as useOperationLogStore,
2447
- Vt as useStonecrop,
2448
- Mt as useUndoRedoShortcuts,
2449
- Wt as validateSchema,
2450
- xt as withBatch
2618
+ Ut as DoctypeMeta,
2619
+ ne as HST,
2620
+ fe as Registry,
2621
+ kt as SchemaValidator,
2622
+ Ke as Stonecrop,
2623
+ Ct as ValidationSeverity,
2624
+ Dt as createHST,
2625
+ Lt as createValidator,
2626
+ Jt as default,
2627
+ K as getGlobalTriggerEngine,
2628
+ jt as markOperationIrreversible,
2629
+ xt as registerGlobalAction,
2630
+ Mt as registerTransitionAction,
2631
+ Ft as setFieldRollback,
2632
+ Bt as triggerTransition,
2633
+ Ge as useOperationLog,
2634
+ pe as useOperationLogStore,
2635
+ Wt as useStonecrop,
2636
+ Ht as useUndoRedoShortcuts,
2637
+ qt as validateSchema,
2638
+ zt as withBatch
2451
2639
  };
2452
2640
  //# sourceMappingURL=stonecrop.js.map