document-model 1.0.42 → 1.0.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/browser/document-model.cjs +1 -1
  2. package/dist/browser/document-model.js +2 -2
  3. package/dist/browser/document.cjs +1 -1
  4. package/dist/browser/document.js +2 -2
  5. package/dist/browser/index.cjs +1 -1
  6. package/dist/browser/index.js +3 -3
  7. package/dist/browser/internal/{index-CDcO7NCS.js → index-CJWLwwNi.js} +1 -1
  8. package/dist/{node/internal/index-fctxJxHD.js → browser/internal/index-CvQOfeml.js} +1 -1
  9. package/dist/{node/internal/index-D_LMFQg7.js → browser/internal/index-QMhrjNyi.js} +1 -1
  10. package/dist/browser/internal/{index-DhzefrNj.js → index-eSGNXD4L.js} +1 -1
  11. package/dist/browser/internal/{object-CrDRbO7a.js → object-ChusgY57.js} +822 -808
  12. package/dist/browser/internal/object-NkahWZEb.js +25 -0
  13. package/dist/browser/src/document/types.d.ts +2 -0
  14. package/dist/browser/src/document/utils/base.d.ts +7 -2
  15. package/dist/browser/src/document/utils/file.d.ts +3 -2
  16. package/dist/node/document-model.cjs +1 -1
  17. package/dist/node/document-model.js +2 -2
  18. package/dist/node/document.cjs +1 -1
  19. package/dist/node/document.js +2 -2
  20. package/dist/node/index.cjs +1 -1
  21. package/dist/node/index.js +3 -3
  22. package/dist/node/internal/{index-Cz8HaIxu.js → index-CAadnKaJ.js} +1 -1
  23. package/dist/{browser/internal/index-CfgX2mMt.js → node/internal/index-CKwU8URS.js} +1 -1
  24. package/dist/node/internal/{index-BWW7KbVk.js → index-CkYTa7KK.js} +1 -1
  25. package/dist/{browser/internal/index-EdTViyyq.js → node/internal/index-DphjSNet.js} +1 -1
  26. package/dist/node/internal/object-BLNJYMtQ.js +20 -0
  27. package/dist/node/internal/{object-BDRv-l-h.js → object-BsCssWq4.js} +622 -608
  28. package/dist/node/src/document/types.d.ts +2 -0
  29. package/dist/node/src/document/utils/base.d.ts +7 -2
  30. package/dist/node/src/document/utils/file.d.ts +3 -2
  31. package/package.json +3 -5
  32. package/dist/browser/internal/object-BkewFVld.js +0 -25
  33. package/dist/node/internal/object-Br6jYeW0.js +0 -20
@@ -1,167 +1,167 @@
1
- var Ht = Object.defineProperty;
2
- var Qt = (e, t, i) => t in e ? Ht(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
1
+ var Gt = Object.defineProperty;
2
+ var Qt = (e, t, i) => t in e ? Gt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
3
3
  var nt = (e, t, i) => (Qt(e, typeof t != "symbol" ? t + "" : t, i), i);
4
- import { produce as H, castDraft as pt, castImmutable as Xt, freeze as Yt } from "immer";
5
- import { z as m } from "zod";
4
+ import { produce as G, castDraft as pt, castImmutable as Xt, freeze as Yt } from "immer";
5
+ import { z as u } from "zod";
6
6
  import te from "crypto";
7
7
  import ct from "fs";
8
8
  import ee from "https";
9
9
  import { join as ie } from "path";
10
10
  import St from "jszip";
11
- const Ot = (e) => e != null, ne = m.any().refine((e) => Ot(e)), $t = m.enum(["LOAD_STATE"]), Et = m.enum(["PRUNE"]), vt = m.enum(["REDO"]), Tt = m.enum(["SET_NAME"]), _t = m.enum(["UNDO"]);
11
+ const $t = (e) => e != null, ne = u.any().refine((e) => $t(e)), Et = u.enum(["LOAD_STATE"]), vt = u.enum(["PRUNE"]), Tt = u.enum(["REDO"]), kt = u.enum(["SET_NAME"]), _t = u.enum(["UNDO"]);
12
12
  function oe() {
13
- return m.object({
14
- __typename: m.literal("Action").optional(),
15
- type: m.string()
13
+ return u.object({
14
+ __typename: u.literal("Action").optional(),
15
+ type: u.string()
16
16
  });
17
17
  }
18
18
  function Q() {
19
- return m.literal("global").or(m.literal("local"));
19
+ return u.literal("global").or(u.literal("local"));
20
20
  }
21
- function kt() {
22
- return m.union([
23
- At(),
24
- Dt(),
21
+ function At() {
22
+ return u.union([
23
+ Nt(),
25
24
  Mt(),
26
25
  Pt(),
27
- It()
26
+ It(),
27
+ zt()
28
28
  ]);
29
29
  }
30
- function re() {
31
- return m.object({
32
- __typename: m.literal("DocumentFile").optional(),
33
- data: m.string(),
34
- extension: m.string().nullable(),
35
- fileName: m.string().nullable(),
36
- mimeType: m.string()
30
+ function se() {
31
+ return u.object({
32
+ __typename: u.literal("DocumentFile").optional(),
33
+ data: u.string(),
34
+ extension: u.string().nullable(),
35
+ fileName: u.string().nullable(),
36
+ mimeType: u.string()
37
37
  });
38
38
  }
39
- function At() {
40
- return m.object({
41
- input: m.lazy(() => ut()),
42
- type: $t,
39
+ function Nt() {
40
+ return u.object({
41
+ input: u.lazy(() => ut()),
42
+ type: Et,
43
43
  scope: Q()
44
44
  });
45
45
  }
46
46
  function ut() {
47
- return m.object({
48
- operations: m.number(),
49
- state: m.lazy(() => Nt())
47
+ return u.object({
48
+ operations: u.number(),
49
+ state: u.lazy(() => Dt())
50
50
  });
51
51
  }
52
- function Nt() {
53
- return m.object({
54
- data: m.unknown().nullish(),
55
- name: m.string()
52
+ function Dt() {
53
+ return u.object({
54
+ data: u.unknown().nullish(),
55
+ name: u.string()
56
56
  });
57
57
  }
58
- function se() {
59
- return m.object({
60
- __typename: m.literal("Operation").optional(),
61
- hash: m.string(),
62
- index: m.number(),
63
- timestamp: m.string().datetime(),
64
- type: m.string()
58
+ function re() {
59
+ return u.object({
60
+ __typename: u.literal("Operation").optional(),
61
+ hash: u.string(),
62
+ index: u.number(),
63
+ timestamp: u.string().datetime(),
64
+ type: u.string()
65
65
  });
66
66
  }
67
- function Dt() {
68
- return m.object({
69
- input: m.lazy(() => ft()),
70
- type: Et,
67
+ function Mt() {
68
+ return u.object({
69
+ input: u.lazy(() => ft()),
70
+ type: vt,
71
71
  scope: Q()
72
72
  });
73
73
  }
74
74
  function ft() {
75
- return m.object({
76
- end: m.number().nullish(),
77
- start: m.number().nullish()
75
+ return u.object({
76
+ end: u.number().nullish(),
77
+ start: u.number().nullish()
78
78
  });
79
79
  }
80
- const dt = m.number;
81
- function Mt() {
82
- return m.object({
80
+ const dt = u.number;
81
+ function Pt() {
82
+ return u.object({
83
83
  input: dt(),
84
- type: vt,
84
+ type: Tt,
85
85
  scope: Q()
86
86
  });
87
87
  }
88
- const gt = m.string;
89
- function Pt() {
90
- return m.object({
88
+ const gt = u.string;
89
+ function It() {
90
+ return u.object({
91
91
  input: gt(),
92
- type: Tt,
93
- scope: m.literal("global")
92
+ type: kt,
93
+ scope: u.literal("global")
94
94
  });
95
95
  }
96
96
  function ae() {
97
- return m.object({
98
- __typename: m.literal("SetNameOperation").optional(),
99
- hash: m.string(),
100
- index: m.number(),
101
- input: m.string(),
102
- timestamp: m.string().datetime(),
103
- type: m.string()
97
+ return u.object({
98
+ __typename: u.literal("SetNameOperation").optional(),
99
+ hash: u.string(),
100
+ index: u.number(),
101
+ input: u.string(),
102
+ timestamp: u.string().datetime(),
103
+ type: u.string()
104
104
  });
105
105
  }
106
- const ht = m.number;
107
- function It() {
108
- return m.object({
106
+ const ht = u.number;
107
+ function zt() {
108
+ return u.object({
109
109
  input: ht(),
110
110
  type: _t,
111
111
  scope: Q()
112
112
  });
113
113
  }
114
- const Be = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
114
+ const We = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
115
115
  __proto__: null,
116
116
  ActionSchema: oe,
117
- BaseActionSchema: kt,
118
- DocumentFileSchema: re,
117
+ BaseActionSchema: At,
118
+ DocumentFileSchema: se,
119
119
  LoadStateActionInputSchema: ut,
120
- LoadStateActionSchema: At,
121
- LoadStateActionStateInputSchema: Nt,
122
- Load_StateSchema: $t,
123
- OperationSchema: se,
120
+ LoadStateActionSchema: Nt,
121
+ LoadStateActionStateInputSchema: Dt,
122
+ Load_StateSchema: Et,
123
+ OperationSchema: re,
124
124
  OperationScopeSchema: Q,
125
125
  PruneActionInputSchema: ft,
126
- PruneActionSchema: Dt,
127
- PruneSchema: Et,
126
+ PruneActionSchema: Mt,
127
+ PruneSchema: vt,
128
128
  RedoActionInputSchema: dt,
129
- RedoActionSchema: Mt,
130
- RedoSchema: vt,
129
+ RedoActionSchema: Pt,
130
+ RedoSchema: Tt,
131
131
  SetNameActionInputSchema: gt,
132
- SetNameActionSchema: Pt,
132
+ SetNameActionSchema: It,
133
133
  SetNameOperationSchema: ae,
134
- Set_NameSchema: Tt,
134
+ Set_NameSchema: kt,
135
135
  UndoActionInputSchema: ht,
136
- UndoActionSchema: It,
136
+ UndoActionSchema: zt,
137
137
  UndoSchema: _t,
138
138
  definedNonNullAnySchema: ne,
139
- isDefinedNonNullAny: Ot
139
+ isDefinedNonNullAny: $t
140
140
  }, Symbol.toStringTag, { value: "Module" }));
141
141
  function pe(e) {
142
142
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
143
143
  }
144
144
  var lt = { exports: {} };
145
145
  (function(e, t) {
146
- const { hasOwnProperty: i } = Object.prototype, n = C();
147
- n.configure = C, n.stringify = n, n.default = n, t.stringify = n, t.configure = C, e.exports = n;
148
- const s = /[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/;
149
- function a(c) {
150
- return c.length < 5e3 && !s.test(c) ? `"${c}"` : JSON.stringify(c);
146
+ const { hasOwnProperty: i } = Object.prototype, n = A();
147
+ n.configure = A, n.stringify = n, n.default = n, t.stringify = n, t.configure = A, e.exports = n;
148
+ const a = /[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/;
149
+ function p(r) {
150
+ return r.length < 5e3 && !a.test(r) ? `"${r}"` : JSON.stringify(r);
151
151
  }
152
- function r(c) {
153
- if (c.length > 200)
154
- return c.sort();
155
- for (let l = 1; l < c.length; l++) {
156
- const j = c[l];
157
- let D = l;
158
- for (; D !== 0 && c[D - 1] > j; )
159
- c[D] = c[D - 1], D--;
160
- c[D] = j;
152
+ function s(r) {
153
+ if (r.length > 200)
154
+ return r.sort();
155
+ for (let m = 1; m < r.length; m++) {
156
+ const b = r[m];
157
+ let D = m;
158
+ for (; D !== 0 && r[D - 1] > b; )
159
+ r[D] = r[D - 1], D--;
160
+ r[D] = b;
161
161
  }
162
- return c;
162
+ return r;
163
163
  }
164
- const p = Object.getOwnPropertyDescriptor(
164
+ const l = Object.getOwnPropertyDescriptor(
165
165
  Object.getPrototypeOf(
166
166
  Object.getPrototypeOf(
167
167
  new Int8Array()
@@ -169,25 +169,25 @@ var lt = { exports: {} };
169
169
  ),
170
170
  Symbol.toStringTag
171
171
  ).get;
172
- function d(c) {
173
- return p.call(c) !== void 0 && c.length !== 0;
172
+ function c(r) {
173
+ return l.call(r) !== void 0 && r.length !== 0;
174
174
  }
175
- function f(c, l, j) {
176
- c.length < j && (j = c.length);
177
- const D = l === "," ? "" : " ";
178
- let V = `"0":${D}${c[0]}`;
179
- for (let z = 1; z < j; z++)
180
- V += `${l}"${z}":${D}${c[z]}`;
181
- return V;
175
+ function x(r, m, b) {
176
+ r.length < b && (b = r.length);
177
+ const D = m === "," ? "" : " ";
178
+ let U = `"0":${D}${r[0]}`;
179
+ for (let R = 1; R < b; R++)
180
+ U += `${m}"${R}":${D}${r[R]}`;
181
+ return U;
182
182
  }
183
- function A(c) {
184
- if (i.call(c, "circularValue")) {
185
- const l = c.circularValue;
186
- if (typeof l == "string")
187
- return `"${l}"`;
188
- if (l == null)
189
- return l;
190
- if (l === Error || l === TypeError)
183
+ function j(r) {
184
+ if (i.call(r, "circularValue")) {
185
+ const m = r.circularValue;
186
+ if (typeof m == "string")
187
+ return `"${m}"`;
188
+ if (m == null)
189
+ return m;
190
+ if (m === Error || m === TypeError)
191
191
  return {
192
192
  toString() {
193
193
  throw new TypeError("Converting circular structure to JSON");
@@ -197,168 +197,168 @@ var lt = { exports: {} };
197
197
  }
198
198
  return '"[Circular]"';
199
199
  }
200
- function b(c, l) {
201
- let j;
202
- if (i.call(c, l) && (j = c[l], typeof j != "boolean"))
203
- throw new TypeError(`The "${l}" argument must be of type boolean`);
204
- return j === void 0 ? !0 : j;
200
+ function E(r, m) {
201
+ let b;
202
+ if (i.call(r, m) && (b = r[m], typeof b != "boolean"))
203
+ throw new TypeError(`The "${m}" argument must be of type boolean`);
204
+ return b === void 0 ? !0 : b;
205
205
  }
206
- function h(c, l) {
207
- let j;
208
- if (i.call(c, l)) {
209
- if (j = c[l], typeof j != "number")
210
- throw new TypeError(`The "${l}" argument must be of type number`);
211
- if (!Number.isInteger(j))
212
- throw new TypeError(`The "${l}" argument must be an integer`);
213
- if (j < 1)
214
- throw new RangeError(`The "${l}" argument must be >= 1`);
206
+ function g(r, m) {
207
+ let b;
208
+ if (i.call(r, m)) {
209
+ if (b = r[m], typeof b != "number")
210
+ throw new TypeError(`The "${m}" argument must be of type number`);
211
+ if (!Number.isInteger(b))
212
+ throw new TypeError(`The "${m}" argument must be an integer`);
213
+ if (b < 1)
214
+ throw new RangeError(`The "${m}" argument must be >= 1`);
215
215
  }
216
- return j === void 0 ? 1 / 0 : j;
216
+ return b === void 0 ? 1 / 0 : b;
217
217
  }
218
- function $(c) {
219
- return c === 1 ? "1 item" : `${c} items`;
218
+ function S(r) {
219
+ return r === 1 ? "1 item" : `${r} items`;
220
220
  }
221
- function S(c) {
222
- const l = /* @__PURE__ */ new Set();
223
- for (const j of c)
224
- (typeof j == "string" || typeof j == "number") && l.add(String(j));
225
- return l;
221
+ function F(r) {
222
+ const m = /* @__PURE__ */ new Set();
223
+ for (const b of r)
224
+ (typeof b == "string" || typeof b == "number") && m.add(String(b));
225
+ return m;
226
226
  }
227
- function J(c) {
228
- if (i.call(c, "strict")) {
229
- const l = c.strict;
230
- if (typeof l != "boolean")
227
+ function _(r) {
228
+ if (i.call(r, "strict")) {
229
+ const m = r.strict;
230
+ if (typeof m != "boolean")
231
231
  throw new TypeError('The "strict" argument must be of type boolean');
232
- if (l)
233
- return (j) => {
234
- let D = `Object can not safely be stringified. Received type ${typeof j}`;
235
- throw typeof j != "function" && (D += ` (${j.toString()})`), new Error(D);
232
+ if (m)
233
+ return (b) => {
234
+ let D = `Object can not safely be stringified. Received type ${typeof b}`;
235
+ throw typeof b != "function" && (D += ` (${b.toString()})`), new Error(D);
236
236
  };
237
237
  }
238
238
  }
239
- function C(c) {
240
- c = { ...c };
241
- const l = J(c);
242
- l && (c.bigint === void 0 && (c.bigint = !1), "circularValue" in c || (c.circularValue = Error));
243
- const j = A(c), D = b(c, "bigint"), V = b(c, "deterministic"), z = h(c, "maximumDepth"), T = h(c, "maximumBreadth");
244
- function tt(M, o, u, y, x, O) {
245
- let g = o[M];
246
- switch (typeof g == "object" && g !== null && typeof g.toJSON == "function" && (g = g.toJSON(M)), g = y.call(o, M, g), typeof g) {
239
+ function A(r) {
240
+ r = { ...r };
241
+ const m = _(r);
242
+ m && (r.bigint === void 0 && (r.bigint = !1), "circularValue" in r || (r.circularValue = Error));
243
+ const b = j(r), D = E(r, "bigint"), U = E(r, "deterministic"), R = g(r, "maximumDepth"), T = g(r, "maximumBreadth");
244
+ function tt(P, o, f, y, h, O) {
245
+ let d = o[P];
246
+ switch (typeof d == "object" && d !== null && typeof d.toJSON == "function" && (d = d.toJSON(P)), d = y.call(o, P, d), typeof d) {
247
247
  case "string":
248
- return a(g);
248
+ return p(d);
249
249
  case "object": {
250
- if (g === null)
250
+ if (d === null)
251
251
  return "null";
252
- if (u.indexOf(g) !== -1)
253
- return j;
252
+ if (f.indexOf(d) !== -1)
253
+ return b;
254
254
  let w = "", v = ",";
255
- const _ = O;
256
- if (Array.isArray(g)) {
257
- if (g.length === 0)
255
+ const k = O;
256
+ if (Array.isArray(d)) {
257
+ if (d.length === 0)
258
258
  return "[]";
259
- if (z < u.length + 1)
259
+ if (R < f.length + 1)
260
260
  return '"[Array]"';
261
- u.push(g), x !== "" && (O += x, w += `
261
+ f.push(d), h !== "" && (O += h, w += `
262
262
  ${O}`, v = `,
263
263
  ${O}`);
264
- const I = Math.min(g.length, T);
265
- let L = 0;
266
- for (; L < I - 1; L++) {
267
- const it = tt(String(L), g, u, y, x, O);
264
+ const z = Math.min(d.length, T);
265
+ let C = 0;
266
+ for (; C < z - 1; C++) {
267
+ const it = tt(String(C), d, f, y, h, O);
268
268
  w += it !== void 0 ? it : "null", w += v;
269
269
  }
270
- const q = tt(String(L), g, u, y, x, O);
271
- if (w += q !== void 0 ? q : "null", g.length - 1 > T) {
272
- const it = g.length - T - 1;
273
- w += `${v}"... ${$(it)} not stringified"`;
270
+ const J = tt(String(C), d, f, y, h, O);
271
+ if (w += J !== void 0 ? J : "null", d.length - 1 > T) {
272
+ const it = d.length - T - 1;
273
+ w += `${v}"... ${S(it)} not stringified"`;
274
274
  }
275
- return x !== "" && (w += `
276
- ${_}`), u.pop(), `[${w}]`;
275
+ return h !== "" && (w += `
276
+ ${k}`), f.pop(), `[${w}]`;
277
277
  }
278
- let k = Object.keys(g);
279
- const N = k.length;
280
- if (N === 0)
278
+ let N = Object.keys(d);
279
+ const M = N.length;
280
+ if (M === 0)
281
281
  return "{}";
282
- if (z < u.length + 1)
282
+ if (R < f.length + 1)
283
283
  return '"[Object]"';
284
- let E = "", P = "";
285
- x !== "" && (O += x, v = `,
286
- ${O}`, E = " ");
287
- const R = Math.min(N, T);
288
- V && !d(g) && (k = r(k)), u.push(g);
289
- for (let I = 0; I < R; I++) {
290
- const L = k[I], q = tt(L, g, u, y, x, O);
291
- q !== void 0 && (w += `${P}${a(L)}:${E}${q}`, P = v);
284
+ let $ = "", I = "";
285
+ h !== "" && (O += h, v = `,
286
+ ${O}`, $ = " ");
287
+ const q = Math.min(M, T);
288
+ U && !c(d) && (N = s(N)), f.push(d);
289
+ for (let z = 0; z < q; z++) {
290
+ const C = N[z], J = tt(C, d, f, y, h, O);
291
+ J !== void 0 && (w += `${I}${p(C)}:${$}${J}`, I = v);
292
292
  }
293
- if (N > T) {
294
- const I = N - T;
295
- w += `${P}"...":${E}"${$(I)} not stringified"`, P = v;
293
+ if (M > T) {
294
+ const z = M - T;
295
+ w += `${I}"...":${$}"${S(z)} not stringified"`, I = v;
296
296
  }
297
- return x !== "" && P.length > 1 && (w = `
297
+ return h !== "" && I.length > 1 && (w = `
298
298
  ${O}${w}
299
- ${_}`), u.pop(), `{${w}}`;
299
+ ${k}`), f.pop(), `{${w}}`;
300
300
  }
301
301
  case "number":
302
- return isFinite(g) ? String(g) : l ? l(g) : "null";
302
+ return isFinite(d) ? String(d) : m ? m(d) : "null";
303
303
  case "boolean":
304
- return g === !0 ? "true" : "false";
304
+ return d === !0 ? "true" : "false";
305
305
  case "undefined":
306
306
  return;
307
307
  case "bigint":
308
308
  if (D)
309
- return String(g);
309
+ return String(d);
310
310
  default:
311
- return l ? l(g) : void 0;
311
+ return m ? m(d) : void 0;
312
312
  }
313
313
  }
314
- function et(M, o, u, y, x, O) {
315
- switch (typeof o == "object" && o !== null && typeof o.toJSON == "function" && (o = o.toJSON(M)), typeof o) {
314
+ function et(P, o, f, y, h, O) {
315
+ switch (typeof o == "object" && o !== null && typeof o.toJSON == "function" && (o = o.toJSON(P)), typeof o) {
316
316
  case "string":
317
- return a(o);
317
+ return p(o);
318
318
  case "object": {
319
319
  if (o === null)
320
320
  return "null";
321
- if (u.indexOf(o) !== -1)
322
- return j;
323
- const g = O;
321
+ if (f.indexOf(o) !== -1)
322
+ return b;
323
+ const d = O;
324
324
  let w = "", v = ",";
325
325
  if (Array.isArray(o)) {
326
326
  if (o.length === 0)
327
327
  return "[]";
328
- if (z < u.length + 1)
328
+ if (R < f.length + 1)
329
329
  return '"[Array]"';
330
- u.push(o), x !== "" && (O += x, w += `
330
+ f.push(o), h !== "" && (O += h, w += `
331
331
  ${O}`, v = `,
332
332
  ${O}`);
333
- const N = Math.min(o.length, T);
334
- let E = 0;
335
- for (; E < N - 1; E++) {
336
- const R = et(String(E), o[E], u, y, x, O);
337
- w += R !== void 0 ? R : "null", w += v;
333
+ const M = Math.min(o.length, T);
334
+ let $ = 0;
335
+ for (; $ < M - 1; $++) {
336
+ const q = et(String($), o[$], f, y, h, O);
337
+ w += q !== void 0 ? q : "null", w += v;
338
338
  }
339
- const P = et(String(E), o[E], u, y, x, O);
340
- if (w += P !== void 0 ? P : "null", o.length - 1 > T) {
341
- const R = o.length - T - 1;
342
- w += `${v}"... ${$(R)} not stringified"`;
339
+ const I = et(String($), o[$], f, y, h, O);
340
+ if (w += I !== void 0 ? I : "null", o.length - 1 > T) {
341
+ const q = o.length - T - 1;
342
+ w += `${v}"... ${S(q)} not stringified"`;
343
343
  }
344
- return x !== "" && (w += `
345
- ${g}`), u.pop(), `[${w}]`;
344
+ return h !== "" && (w += `
345
+ ${d}`), f.pop(), `[${w}]`;
346
346
  }
347
- u.push(o);
348
- let _ = "";
349
- x !== "" && (O += x, v = `,
350
- ${O}`, _ = " ");
347
+ f.push(o);
351
348
  let k = "";
352
- for (const N of y) {
353
- const E = et(N, o[N], u, y, x, O);
354
- E !== void 0 && (w += `${k}${a(N)}:${_}${E}`, k = v);
349
+ h !== "" && (O += h, v = `,
350
+ ${O}`, k = " ");
351
+ let N = "";
352
+ for (const M of y) {
353
+ const $ = et(M, o[M], f, y, h, O);
354
+ $ !== void 0 && (w += `${N}${p(M)}:${k}${$}`, N = v);
355
355
  }
356
- return x !== "" && k.length > 1 && (w = `
356
+ return h !== "" && N.length > 1 && (w = `
357
357
  ${O}${w}
358
- ${g}`), u.pop(), `{${w}}`;
358
+ ${d}`), f.pop(), `{${w}}`;
359
359
  }
360
360
  case "number":
361
- return isFinite(o) ? String(o) : l ? l(o) : "null";
361
+ return isFinite(o) ? String(o) : m ? m(o) : "null";
362
362
  case "boolean":
363
363
  return o === !0 ? "true" : "false";
364
364
  case "undefined":
@@ -367,73 +367,73 @@ ${g}`), u.pop(), `{${w}}`;
367
367
  if (D)
368
368
  return String(o);
369
369
  default:
370
- return l ? l(o) : void 0;
370
+ return m ? m(o) : void 0;
371
371
  }
372
372
  }
373
- function B(M, o, u, y, x) {
373
+ function W(P, o, f, y, h) {
374
374
  switch (typeof o) {
375
375
  case "string":
376
- return a(o);
376
+ return p(o);
377
377
  case "object": {
378
378
  if (o === null)
379
379
  return "null";
380
380
  if (typeof o.toJSON == "function") {
381
- if (o = o.toJSON(M), typeof o != "object")
382
- return B(M, o, u, y, x);
381
+ if (o = o.toJSON(P), typeof o != "object")
382
+ return W(P, o, f, y, h);
383
383
  if (o === null)
384
384
  return "null";
385
385
  }
386
- if (u.indexOf(o) !== -1)
387
- return j;
388
- const O = x;
386
+ if (f.indexOf(o) !== -1)
387
+ return b;
388
+ const O = h;
389
389
  if (Array.isArray(o)) {
390
390
  if (o.length === 0)
391
391
  return "[]";
392
- if (z < u.length + 1)
392
+ if (R < f.length + 1)
393
393
  return '"[Array]"';
394
- u.push(o), x += y;
395
- let E = `
396
- ${x}`;
397
- const P = `,
398
- ${x}`, R = Math.min(o.length, T);
399
- let I = 0;
400
- for (; I < R - 1; I++) {
401
- const q = B(String(I), o[I], u, y, x);
402
- E += q !== void 0 ? q : "null", E += P;
394
+ f.push(o), h += y;
395
+ let $ = `
396
+ ${h}`;
397
+ const I = `,
398
+ ${h}`, q = Math.min(o.length, T);
399
+ let z = 0;
400
+ for (; z < q - 1; z++) {
401
+ const J = W(String(z), o[z], f, y, h);
402
+ $ += J !== void 0 ? J : "null", $ += I;
403
403
  }
404
- const L = B(String(I), o[I], u, y, x);
405
- if (E += L !== void 0 ? L : "null", o.length - 1 > T) {
406
- const q = o.length - T - 1;
407
- E += `${P}"... ${$(q)} not stringified"`;
404
+ const C = W(String(z), o[z], f, y, h);
405
+ if ($ += C !== void 0 ? C : "null", o.length - 1 > T) {
406
+ const J = o.length - T - 1;
407
+ $ += `${I}"... ${S(J)} not stringified"`;
408
408
  }
409
- return E += `
410
- ${O}`, u.pop(), `[${E}]`;
409
+ return $ += `
410
+ ${O}`, f.pop(), `[${$}]`;
411
411
  }
412
- let g = Object.keys(o);
413
- const w = g.length;
412
+ let d = Object.keys(o);
413
+ const w = d.length;
414
414
  if (w === 0)
415
415
  return "{}";
416
- if (z < u.length + 1)
416
+ if (R < f.length + 1)
417
417
  return '"[Object]"';
418
- x += y;
418
+ h += y;
419
419
  const v = `,
420
- ${x}`;
421
- let _ = "", k = "", N = Math.min(w, T);
422
- d(o) && (_ += f(o, v, T), g = g.slice(o.length), N -= o.length, k = v), V && (g = r(g)), u.push(o);
423
- for (let E = 0; E < N; E++) {
424
- const P = g[E], R = B(P, o[P], u, y, x);
425
- R !== void 0 && (_ += `${k}${a(P)}: ${R}`, k = v);
420
+ ${h}`;
421
+ let k = "", N = "", M = Math.min(w, T);
422
+ c(o) && (k += x(o, v, T), d = d.slice(o.length), M -= o.length, N = v), U && (d = s(d)), f.push(o);
423
+ for (let $ = 0; $ < M; $++) {
424
+ const I = d[$], q = W(I, o[I], f, y, h);
425
+ q !== void 0 && (k += `${N}${p(I)}: ${q}`, N = v);
426
426
  }
427
427
  if (w > T) {
428
- const E = w - T;
429
- _ += `${k}"...": "${$(E)} not stringified"`, k = v;
428
+ const $ = w - T;
429
+ k += `${N}"...": "${S($)} not stringified"`, N = v;
430
430
  }
431
- return k !== "" && (_ = `
432
- ${x}${_}
433
- ${O}`), u.pop(), `{${_}}`;
431
+ return N !== "" && (k = `
432
+ ${h}${k}
433
+ ${O}`), f.pop(), `{${k}}`;
434
434
  }
435
435
  case "number":
436
- return isFinite(o) ? String(o) : l ? l(o) : "null";
436
+ return isFinite(o) ? String(o) : m ? m(o) : "null";
437
437
  case "boolean":
438
438
  return o === !0 ? "true" : "false";
439
439
  case "undefined":
@@ -442,64 +442,64 @@ ${O}`), u.pop(), `{${_}}`;
442
442
  if (D)
443
443
  return String(o);
444
444
  default:
445
- return l ? l(o) : void 0;
445
+ return m ? m(o) : void 0;
446
446
  }
447
447
  }
448
- function Z(M, o, u) {
448
+ function B(P, o, f) {
449
449
  switch (typeof o) {
450
450
  case "string":
451
- return a(o);
451
+ return p(o);
452
452
  case "object": {
453
453
  if (o === null)
454
454
  return "null";
455
455
  if (typeof o.toJSON == "function") {
456
- if (o = o.toJSON(M), typeof o != "object")
457
- return Z(M, o, u);
456
+ if (o = o.toJSON(P), typeof o != "object")
457
+ return B(P, o, f);
458
458
  if (o === null)
459
459
  return "null";
460
460
  }
461
- if (u.indexOf(o) !== -1)
462
- return j;
461
+ if (f.indexOf(o) !== -1)
462
+ return b;
463
463
  let y = "";
464
464
  if (Array.isArray(o)) {
465
465
  if (o.length === 0)
466
466
  return "[]";
467
- if (z < u.length + 1)
467
+ if (R < f.length + 1)
468
468
  return '"[Array]"';
469
- u.push(o);
469
+ f.push(o);
470
470
  const v = Math.min(o.length, T);
471
- let _ = 0;
472
- for (; _ < v - 1; _++) {
473
- const N = Z(String(_), o[_], u);
474
- y += N !== void 0 ? N : "null", y += ",";
471
+ let k = 0;
472
+ for (; k < v - 1; k++) {
473
+ const M = B(String(k), o[k], f);
474
+ y += M !== void 0 ? M : "null", y += ",";
475
475
  }
476
- const k = Z(String(_), o[_], u);
477
- if (y += k !== void 0 ? k : "null", o.length - 1 > T) {
478
- const N = o.length - T - 1;
479
- y += `,"... ${$(N)} not stringified"`;
476
+ const N = B(String(k), o[k], f);
477
+ if (y += N !== void 0 ? N : "null", o.length - 1 > T) {
478
+ const M = o.length - T - 1;
479
+ y += `,"... ${S(M)} not stringified"`;
480
480
  }
481
- return u.pop(), `[${y}]`;
481
+ return f.pop(), `[${y}]`;
482
482
  }
483
- let x = Object.keys(o);
484
- const O = x.length;
483
+ let h = Object.keys(o);
484
+ const O = h.length;
485
485
  if (O === 0)
486
486
  return "{}";
487
- if (z < u.length + 1)
487
+ if (R < f.length + 1)
488
488
  return '"[Object]"';
489
- let g = "", w = Math.min(O, T);
490
- d(o) && (y += f(o, ",", T), x = x.slice(o.length), w -= o.length, g = ","), V && (x = r(x)), u.push(o);
489
+ let d = "", w = Math.min(O, T);
490
+ c(o) && (y += x(o, ",", T), h = h.slice(o.length), w -= o.length, d = ","), U && (h = s(h)), f.push(o);
491
491
  for (let v = 0; v < w; v++) {
492
- const _ = x[v], k = Z(_, o[_], u);
493
- k !== void 0 && (y += `${g}${a(_)}:${k}`, g = ",");
492
+ const k = h[v], N = B(k, o[k], f);
493
+ N !== void 0 && (y += `${d}${p(k)}:${N}`, d = ",");
494
494
  }
495
495
  if (O > T) {
496
496
  const v = O - T;
497
- y += `${g}"...":"${$(v)} not stringified"`;
497
+ y += `${d}"...":"${S(v)} not stringified"`;
498
498
  }
499
- return u.pop(), `{${y}}`;
499
+ return f.pop(), `{${y}}`;
500
500
  }
501
501
  case "number":
502
- return isFinite(o) ? String(o) : l ? l(o) : "null";
502
+ return isFinite(o) ? String(o) : m ? m(o) : "null";
503
503
  case "boolean":
504
504
  return o === !0 ? "true" : "false";
505
505
  case "undefined":
@@ -508,29 +508,29 @@ ${O}`), u.pop(), `{${_}}`;
508
508
  if (D)
509
509
  return String(o);
510
510
  default:
511
- return l ? l(o) : void 0;
511
+ return m ? m(o) : void 0;
512
512
  }
513
513
  }
514
- function Gt(M, o, u) {
514
+ function Zt(P, o, f) {
515
515
  if (arguments.length > 1) {
516
516
  let y = "";
517
- if (typeof u == "number" ? y = " ".repeat(Math.min(u, 10)) : typeof u == "string" && (y = u.slice(0, 10)), o != null) {
517
+ if (typeof f == "number" ? y = " ".repeat(Math.min(f, 10)) : typeof f == "string" && (y = f.slice(0, 10)), o != null) {
518
518
  if (typeof o == "function")
519
- return tt("", { "": M }, [], o, y, "");
519
+ return tt("", { "": P }, [], o, y, "");
520
520
  if (Array.isArray(o))
521
- return et("", M, [], S(o), y, "");
521
+ return et("", P, [], F(o), y, "");
522
522
  }
523
523
  if (y.length !== 0)
524
- return B("", M, [], y, "");
524
+ return W("", P, [], y, "");
525
525
  }
526
- return Z("", M, []);
526
+ return B("", P, []);
527
527
  }
528
- return Gt;
528
+ return Zt;
529
529
  }
530
530
  })(lt, lt.exports);
531
531
  var ce = lt.exports;
532
- const rt = /* @__PURE__ */ pe(ce);
533
- rt.configure;
532
+ const st = /* @__PURE__ */ pe(ce);
533
+ st.configure;
534
534
  function le(e, t) {
535
535
  return { ...e, name: t };
536
536
  }
@@ -538,120 +538,120 @@ function me(e, t, i) {
538
538
  const n = {
539
539
  skip: i,
540
540
  document: e
541
- }, { scope: s } = t;
542
- return !s || t.skip === void 0 ? n : H(n, (a) => {
543
- const [r] = a.document.operations[s].slice(-1);
544
- t.skip && t.skip > 0 && (a.skip = t.skip), r.type === "NOOP" && t.index === r.index && a.skip > r.skip && a.document.operations[s].pop();
541
+ }, { scope: a } = t;
542
+ return !a || t.skip === void 0 ? n : G(n, (p) => {
543
+ const [s] = p.document.operations[a].slice(-1);
544
+ t.skip && t.skip > 0 && (p.skip = t.skip), s.type === "NOOP" && t.index === s.index && p.skip > s.skip && p.document.operations[a].pop();
545
545
  });
546
546
  }
547
547
  function ue(e, t, i) {
548
- const { scope: n, input: s } = t;
549
- return H({
548
+ const { scope: n, input: a } = t;
549
+ return G({
550
550
  document: e,
551
551
  action: t,
552
552
  skip: i
553
- }, (r) => {
554
- if (r.document.operations[n].length < 1)
553
+ }, (s) => {
554
+ if (s.document.operations[n].length < 1)
555
555
  throw new Error(
556
556
  `Cannot undo: no operations in history for scope "${n}"`
557
557
  );
558
- if (s < 1)
558
+ if (a < 1)
559
559
  throw new Error(
560
560
  "Invalid UNDO action: input value must be greater than 0"
561
561
  );
562
- if (r.skip > 0)
562
+ if (s.skip > 0)
563
563
  throw new Error(
564
564
  "Cannot undo: skip value from reducer cannot be used with UNDO action"
565
565
  );
566
- const [p] = r.document.operations[n].slice(-1), d = p.type === "NOOP" && p.skip > 0;
567
- if (r.skip += s, d) {
568
- r.skip += p.skip;
569
- const h = r.document.operations[n][r.document.operations[n].length - 2];
570
- h && p.index - h.index === 1 && r.document.operations[n].pop();
566
+ const [l] = s.document.operations[n].slice(-1), c = l.type === "NOOP" && l.skip > 0;
567
+ if (s.skip += a, c) {
568
+ s.skip += l.skip;
569
+ const g = s.document.operations[n][s.document.operations[n].length - 2];
570
+ g && l.index - g.index === 1 && s.document.operations[n].pop();
571
571
  }
572
- if (r.document.operations[n].length < r.skip)
572
+ if (s.document.operations[n].length < s.skip)
573
573
  throw new Error(
574
574
  "Cannot undo: you can't undo more operations than the ones in the scope history"
575
575
  );
576
- const f = r.document.operations[n].length - 1;
577
- let A = s, b = d ? f - p.skip : f;
578
- for (; A > 0 && b >= 0; ) {
579
- const h = r.document.operations[n][b];
580
- if (!h) {
581
- A--, b--;
576
+ const x = s.document.operations[n].length - 1;
577
+ let j = a, E = c ? x - l.skip : x;
578
+ for (; j > 0 && E >= 0; ) {
579
+ const g = s.document.operations[n][E];
580
+ if (!g) {
581
+ j--, E--;
582
582
  continue;
583
583
  }
584
- h.type === "NOOP" && h.skip > 0 ? (b = b - (h.skip + 1), r.skip += h.skip + 1) : (r.document.clipboard.push({ ...h }), A--, b--);
584
+ g.type === "NOOP" && g.skip > 0 ? (E = E - (g.skip + 1), s.skip += g.skip + 1) : (s.document.clipboard.push({ ...g }), j--, E--);
585
585
  }
586
- r.action = bt(n);
586
+ s.action = yt(n);
587
587
  });
588
588
  }
589
589
  function fe(e, t, i) {
590
- const { scope: n, input: s } = t;
591
- return H({
590
+ const { scope: n, input: a } = t;
591
+ return G({
592
592
  document: e,
593
593
  action: t,
594
594
  skip: i
595
- }, (r) => {
596
- if (r.skip > 0)
595
+ }, (s) => {
596
+ if (s.skip > 0)
597
597
  throw new Error(
598
598
  "Cannot redo: skip value from reducer cannot be used with REDO action"
599
599
  );
600
- if (s > 1)
600
+ if (a > 1)
601
601
  throw new Error(
602
602
  "Cannot redo: you can only redo one operation at a time"
603
603
  );
604
- if (s < 1)
604
+ if (a < 1)
605
605
  throw new Error("Invalid REDO action: invalid redo input value");
606
- if (r.document.clipboard.length < 1)
606
+ if (s.document.clipboard.length < 1)
607
607
  throw new Error("Cannot redo: no operations in the clipboard");
608
- const p = r.document.clipboard.findLastIndex(
609
- (f) => f.scope === n
608
+ const l = s.document.clipboard.findLastIndex(
609
+ (x) => x.scope === n
610
610
  );
611
- if (p < 0)
611
+ if (l < 0)
612
612
  throw new Error(
613
613
  `Cannot redo: no operations in clipboard for scope "${n}"`
614
614
  );
615
- const d = r.document.clipboard.splice(p, 1)[0];
616
- r.action = pt({
617
- type: d.type,
618
- scope: d.scope,
619
- input: d.input
615
+ const c = s.document.clipboard.splice(l, 1)[0];
616
+ s.action = pt({
617
+ type: c.type,
618
+ scope: c.scope,
619
+ input: c.input
620
620
  });
621
621
  });
622
622
  }
623
623
  function de(e, t, i) {
624
- const { scope: n } = t, s = e.operations[n];
624
+ const { scope: n } = t, a = e.operations[n];
625
625
  let {
626
- input: { start: a, end: r }
626
+ input: { start: p, end: s }
627
627
  } = t;
628
- a = a || 0, r = r || s.length;
629
- const p = s.slice(a, r), d = s.slice(0, a), f = s.slice(r), A = mt(
628
+ p = p || 0, s = s || a.length;
629
+ const l = a.slice(p, s), c = a.slice(0, p), x = a.slice(s), j = mt(
630
630
  e.initialState,
631
631
  {
632
632
  ...e.operations,
633
- [n]: d.concat(p)
633
+ [n]: c.concat(l)
634
634
  },
635
635
  i
636
- ), { name: b, state: h } = A, $ = d.length, S = d.length ? d[d.length - 1].timestamp : f.length ? f[0].timestamp : (/* @__PURE__ */ new Date()).toISOString();
636
+ ), { name: E, state: g } = j, S = c.length, F = c.length ? c[c.length - 1].timestamp : x.length ? x[0].timestamp : (/* @__PURE__ */ new Date()).toISOString();
637
637
  return mt(
638
638
  e.initialState,
639
639
  {
640
640
  ...e.operations,
641
641
  [n]: [
642
- ...d,
642
+ ...c,
643
643
  {
644
- ...xt(
645
- { name: b, state: h },
646
- p.length
644
+ ...bt(
645
+ { name: E, state: g },
646
+ l.length
647
647
  ),
648
- timestamp: S,
649
- index: $,
650
- hash: qt({ state: h }, "global")
648
+ timestamp: F,
649
+ index: S,
650
+ hash: xt({ state: g }, "global")
651
651
  },
652
- ...f.map((J, C) => ({
653
- ...J,
654
- index: $ + C + 1
652
+ ...x.map((_, A) => ({
653
+ ..._,
654
+ index: S + A + 1
655
655
  }))
656
656
  ]
657
657
  },
@@ -665,7 +665,7 @@ function ge(e, t) {
665
665
  state: t.state ?? { global: {}, local: {} }
666
666
  };
667
667
  }
668
- const zt = "SET_NAME", X = "UNDO", Y = "REDO", st = "PRUNE", Ft = "LOAD_STATE", he = "NOOP";
668
+ const Ft = "SET_NAME", X = "UNDO", Y = "REDO", rt = "PRUNE", Rt = "LOAD_STATE", he = "NOOP";
669
669
  function xe(e, t) {
670
670
  let i;
671
671
  return "index" in t ? i = { ...t } : i = e.operations[t.scope].slice(-1)[0], ((i == null ? void 0 : i.index) ?? -1) + 1;
@@ -681,30 +681,30 @@ function be(e, t) {
681
681
  };
682
682
  }
683
683
  function ye(e, t, i = 0) {
684
- if ([X, Y, st].includes(t.type))
684
+ if ([X, Y, rt].includes(t.type))
685
685
  return e;
686
- const { scope: n } = t, s = e.operations[n].slice(
686
+ const { scope: n } = t, a = e.operations[n].slice(
687
687
  0,
688
688
  e.revision[n]
689
- ), a = [...s].pop();
690
- let r = ((a == null ? void 0 : a.index) ?? -1) + 1;
689
+ ), p = [...a].pop();
690
+ let s = ((p == null ? void 0 : p.index) ?? -1) + 1;
691
691
  if ("index" in t) {
692
- if (t.index > r + i)
692
+ if (t.index > s + i)
693
693
  throw new Error(
694
- `Missing operations: expected ${r} with skip 0 or equivalent, got index ${t.index} with skip ${i}`
694
+ `Missing operations: expected ${s} with skip 0 or equivalent, got index ${t.index} with skip ${i}`
695
695
  );
696
- r = t.index;
696
+ s = t.index;
697
697
  }
698
- return s.push({
698
+ return a.push({
699
699
  ...t,
700
- index: r,
700
+ index: s,
701
701
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
702
702
  hash: "",
703
703
  scope: n,
704
704
  skip: i
705
705
  }), {
706
706
  ...e,
707
- operations: { ...e.operations, [n]: s }
707
+ operations: { ...e.operations, [n]: a }
708
708
  };
709
709
  }
710
710
  function we(e, t, i = 0) {
@@ -712,18 +712,18 @@ function we(e, t, i = 0) {
712
712
  return n = be(n, t), n;
713
713
  }
714
714
  function je(e, t, i) {
715
- switch (kt().parse(t), t.type) {
716
- case zt:
715
+ switch (At().parse(t), t.type) {
716
+ case Ft:
717
717
  return le(e, t.input);
718
- case st:
718
+ case rt:
719
719
  return de(e, t, i);
720
- case Ft:
720
+ case Rt:
721
721
  return ge(e, t.input.state);
722
722
  default:
723
723
  return e;
724
724
  }
725
725
  }
726
- function Se(e, t, i) {
726
+ function Oe(e, t, i) {
727
727
  switch (t.type) {
728
728
  case X:
729
729
  return ue(e, t, i);
@@ -733,119 +733,122 @@ function Se(e, t, i) {
733
733
  return { document: e, action: t, skip: i };
734
734
  }
735
735
  }
736
- function Rt(e, t, i, n, s = {}) {
737
- const { skip: a, ignoreSkipOperations: r = !1 } = s;
738
- let p = { ...t }, d = a || 0, f = e, A = [...e.clipboard];
739
- if (ve(p)) {
740
- const { document: b, skip: h } = me(f, p, d);
741
- d = h, f = b;
736
+ function Lt(e, t, i, n, a = {}) {
737
+ const { skip: p, ignoreSkipOperations: s = !1, reuseHash: l = !1 } = a;
738
+ let c = { ...t }, x = p || 0, j = e, E = [...e.clipboard];
739
+ if (ve(c)) {
740
+ const { document: g, skip: S } = me(j, c, x);
741
+ x = S, j = g;
742
742
  }
743
- if (yt(p)) {
743
+ if (wt(c)) {
744
744
  const {
745
- skip: b,
746
- action: h,
747
- document: $
748
- } = Se(e, p, d);
749
- p = h, d = b, f = $, A = [...f.clipboard];
745
+ skip: g,
746
+ action: S,
747
+ document: F
748
+ } = Oe(e, c, x);
749
+ c = S, x = g, j = F, E = [...j.clipboard];
750
750
  }
751
- if (wt(p) && (f = je(f, p, i)), d > 0 && !r) {
752
- let b = d;
753
- "index" in p && (b = Ne(
754
- f.operations[p.scope],
755
- p.index,
756
- d
757
- )), f = mt(
758
- f.initialState,
759
- f.operations,
751
+ if (jt(c) && (j = je(j, c, i)), x > 0 && !s) {
752
+ let g = x;
753
+ "index" in c && (g = Ne(
754
+ j.operations[c.scope],
755
+ c.index,
756
+ x
757
+ )), j = mt(
758
+ j.initialState,
759
+ j.operations,
760
760
  i,
761
761
  void 0,
762
762
  void 0,
763
763
  void 0,
764
- { [p.scope]: b }
764
+ { [c.scope]: g }
765
+ // TODO reuse hash?
765
766
  );
766
767
  }
767
- return f = we(f, p, d), f = H(f, (b) => {
768
- const h = i(
769
- b.state,
770
- p,
768
+ return j = we(j, c, x), j = G(j, (g) => {
769
+ const S = i(
770
+ g.state,
771
+ c,
771
772
  n
772
- ), $ = yt(t) ? [...A] : [];
773
- if (h)
773
+ ), F = wt(t) ? [...E] : [];
774
+ if (S)
774
775
  return pt({
775
- ...f,
776
- clipboard: [...$],
777
- state: h
776
+ ...j,
777
+ clipboard: [...F],
778
+ state: S
778
779
  });
779
- b.clipboard = pt([...$]);
780
- }), H(f, (b) => {
781
- if ([X, Y, st].includes(p.type))
782
- return b;
783
- const h = p.scope || "global";
784
- b.operations[h][b.operations[h].length - 1].hash = qt(b, h), !wt(p) && p.attachments && p.attachments.forEach(($) => {
785
- const { hash: S, ...J } = $;
786
- b.attachments[S] = {
787
- ...J
780
+ g.clipboard = pt([...F]);
781
+ }), G(j, (g) => {
782
+ if ([X, Y, rt].includes(c.type))
783
+ return g;
784
+ const S = c.scope || "global";
785
+ console.time("hash");
786
+ const F = l && Object.prototype.hasOwnProperty.call(c, "hash") ? c.hash : xt(g, S);
787
+ console.timeEnd("hash"), g.operations[S][g.operations[S].length - 1].hash = F, !jt(c) && c.attachments && c.attachments.forEach((_) => {
788
+ const { hash: A, ...r } = _;
789
+ g.attachments[A] = {
790
+ ...r
788
791
  };
789
792
  });
790
793
  });
791
794
  }
792
- function Oe(e, t, i) {
795
+ function Se(e, t, i) {
793
796
  const n = ie(e, t);
794
- return ct.mkdirSync(e, { recursive: !0 }), new Promise((s, a) => {
797
+ return ct.mkdirSync(e, { recursive: !0 }), new Promise((a, p) => {
795
798
  try {
796
- ct.writeFile(n, i, {}, (r) => {
797
- r ? a(r) : s(n);
799
+ ct.writeFile(n, i, {}, (s) => {
800
+ s ? p(s) : a(n);
798
801
  });
799
- } catch (r) {
800
- a(r);
802
+ } catch (s) {
803
+ p(s);
801
804
  }
802
805
  });
803
806
  }
804
- function Lt(e) {
807
+ function qt(e) {
805
808
  return ct.readFileSync(e);
806
809
  }
807
810
  function $e(e) {
808
811
  return new Promise((t, i) => {
809
812
  ee.get(e, (n) => {
810
- const s = [], a = n.headers["content-type"];
811
- n.on("data", (r) => {
812
- s.push(r);
813
+ const a = [], p = n.headers["content-type"];
814
+ n.on("data", (s) => {
815
+ a.push(s);
813
816
  }), n.on("end", () => {
814
- t({ buffer: Buffer.concat(s), mimeType: a });
817
+ t({ buffer: Buffer.concat(a), mimeType: p });
815
818
  });
816
819
  }).on("error", (n) => {
817
820
  i(n);
818
821
  });
819
822
  });
820
823
  }
821
- const Ee = async (e) => Lt(e), at = (e, t = "sha1") => te.createHash(t).update(e).digest("base64");
824
+ const Ee = async (e) => qt(e), at = (e, t = "sha1") => te.createHash(t).update(e).digest("base64");
822
825
  function ve(e) {
823
826
  return e.type === he && e.skip !== void 0 && e.skip > 0 && e.hash !== void 0;
824
827
  }
825
- function yt(e) {
828
+ function wt(e) {
826
829
  return [X, Y].includes(e.type);
827
830
  }
828
- function wt(e) {
829
- return [zt, X, Y, st, Ft].includes(e.type);
831
+ function jt(e) {
832
+ return [Ft, X, Y, rt, Rt].includes(e.type);
830
833
  }
831
- function W(e, t, i, n, s = "global") {
834
+ function H(e, t, i, n, a = "global") {
832
835
  if (!e)
833
836
  throw new Error("Empty action type");
834
837
  if (typeof e != "string")
835
- throw new Error(`Invalid action type: ${e}`);
836
- const a = { type: e, input: t, scope: s };
837
- i && (a.attachments = i);
838
+ throw new Error(`Invalid action type: ${JSON.stringify(e)}`);
839
+ const p = { type: e, input: t, scope: a };
840
+ i && (p.attachments = i);
838
841
  try {
839
- n == null || n().parse(a.input);
840
- } catch (r) {
841
- throw new Error(`Invalid action input: ${r}`);
842
+ n == null || n().parse(p.input);
843
+ } catch (s) {
844
+ throw new Error(`Invalid action input: ${s}`);
842
845
  }
843
- return a;
846
+ return p;
844
847
  }
845
- function Te(e, t = Rt) {
846
- return (i, n, s, a) => t(i, n, e, s, a);
848
+ function Te(e, t = Lt) {
849
+ return (i, n, a, p) => t(i, n, e, a, p);
847
850
  }
848
- const _e = (e, t) => ({
851
+ const ke = (e, t) => ({
849
852
  name: "",
850
853
  documentType: "",
851
854
  revision: {
@@ -857,8 +860,8 @@ const _e = (e, t) => ({
857
860
  attachments: {},
858
861
  ...e,
859
862
  state: (t == null ? void 0 : t(e == null ? void 0 : e.state)) ?? (e == null ? void 0 : e.state) ?? { global: {}, local: {} }
860
- }), ke = (e, t) => {
861
- const i = _e(
863
+ }), _e = (e, t) => {
864
+ const i = ke(
862
865
  e,
863
866
  t
864
867
  );
@@ -868,7 +871,7 @@ const _e = (e, t) => ({
868
871
  operations: { global: [], local: [] },
869
872
  clipboard: []
870
873
  };
871
- }, qt = (e, t = "global") => at(rt(e.state[t] || "")), Ze = (e, t = 1e3) => {
874
+ }, xt = (e, t = "global") => at(st(e.state[t] || "")), Be = (e, t = 1e3) => {
872
875
  const i = Math.random() * t;
873
876
  return at(`${(e ?? /* @__PURE__ */ new Date()).toISOString()}${i}`);
874
877
  };
@@ -877,40 +880,40 @@ function ot(e) {
877
880
  }
878
881
  function Ae(e, t) {
879
882
  const i = [...e];
880
- let n = t || 0, s = i.length > 0 ? i[i.length - 1].index : 0;
881
- const a = [];
882
- for (const r of i.reverse()) {
883
+ let n = t || 0, a = i.length > 0 ? i[i.length - 1].index : 0;
884
+ const p = [];
885
+ for (const s of i.reverse()) {
883
886
  if (n > 0) {
884
- const f = s - r.index;
885
- n -= f;
887
+ const x = a - s.index;
888
+ n -= x;
886
889
  }
887
890
  if (n < 0)
888
891
  throw new Error("Invalid operation index, missing operations");
889
- const p = {
892
+ const l = {
890
893
  ignore: n > 0,
891
- operation: r
892
- }, d = r.skip > 0 ? r.skip + 1 : 0;
893
- if (d > 0 && d > n) {
894
- const f = d - n;
895
- n = n + f;
894
+ operation: s
895
+ }, c = s.skip > 0 ? s.skip + 1 : 0;
896
+ if (c > 0 && c > n) {
897
+ const x = c - n;
898
+ n = n + x;
896
899
  }
897
- s = r.index, a.push(p);
900
+ a = s.index, p.push(l);
898
901
  }
899
- return a.reverse();
902
+ return p.reverse();
900
903
  }
901
904
  function Ne(e, t, i) {
902
- const n = e.slice().sort((p, d) => p.skip - d.skip).sort((p, d) => p.index - d.index);
903
- let s = i, a = 0, r = t;
904
- for (const p of n.reverse()) {
905
- const d = r - p.index;
906
- if (s = s - d, s > -1)
907
- a++, r = p.index;
905
+ const n = e.slice().sort((l, c) => l.skip - c.skip).sort((l, c) => l.index - c.index);
906
+ let a = i, p = 0, s = t;
907
+ for (const l of n.reverse()) {
908
+ const c = s - l.index;
909
+ if (a = a - c, a > -1)
910
+ p++, s = l.index;
908
911
  else
909
912
  break;
910
913
  }
911
- return a;
914
+ return p;
912
915
  }
913
- function Ge(e) {
916
+ function Ze(e) {
914
917
  return Object.values(e).flatMap((t) => t).sort(
915
918
  (t, i) => new Date(t.timestamp).getTime() - new Date(i.timestamp).getTime()
916
919
  );
@@ -920,140 +923,151 @@ function De(e) {
920
923
  (t, i) => new Date(t.operation.timestamp).getTime() - new Date(i.operation.timestamp).getTime()
921
924
  );
922
925
  }
923
- function mt(e, t, i, n, s, a = Rt, r = {}) {
924
- const p = Te(i, a);
926
+ function mt(e, t, i, n, a, p = Lt, s = {}, l) {
927
+ const c = Te(i, p);
925
928
  return Ct(
926
929
  e,
927
930
  t,
928
- p,
931
+ c,
929
932
  n,
933
+ a,
930
934
  s,
931
- r
935
+ l
932
936
  );
933
937
  }
934
- function Ct(e, t, i, n, s, a = {}) {
935
- const r = ke(e), p = Object.keys(t).reduce((h, $) => {
936
- const S = $;
938
+ function Ct(e, t, i, n, a, p = {}, s) {
939
+ const l = (s == null ? void 0 : s.checkHashes) ?? !0, c = _e(e), x = Object.keys(t).reduce((_, A) => {
940
+ const r = A;
937
941
  return {
938
- ...h,
939
- [S]: t[S].slice(0, s == null ? void 0 : s.revision[S])
942
+ ..._,
943
+ [r]: t[r].slice(0, a == null ? void 0 : a.revision[r])
940
944
  };
941
- }, {}), d = Object.keys(p).reduce(
942
- (h, $) => {
943
- const S = $;
945
+ }, {}), j = Object.keys(x).reduce(
946
+ (_, A) => {
947
+ const r = A;
944
948
  return {
945
- ...h,
946
- [S]: Ae(
947
- p[S],
948
- a[S]
949
+ ..._,
950
+ [r]: Ae(
951
+ x[r],
952
+ p[r]
949
953
  )
950
954
  };
951
955
  },
952
956
  {}
953
- ), f = De(d).reduce(
954
- (h, { ignore: $, operation: S }) => $ ? i(h, bt(S.scope), n, {
955
- skip: S.skip,
956
- ignoreSkipOperations: !0
957
- }) : i(h, S, n, {
958
- skip: S.skip,
957
+ ), E = De(j), g = E.reduce(
958
+ (_, { ignore: A, operation: r }, m, b) => A ? i(_, yt(r.scope), n, {
959
+ skip: r.skip,
959
960
  ignoreSkipOperations: !0
961
+ // TODO: reuse hash?
962
+ }) : i(_, r, n, {
963
+ skip: r.skip,
964
+ ignoreSkipOperations: !0,
965
+ reuseHash: !l
960
966
  }),
961
- r
962
- ), A = Object.keys(
963
- f.operations
967
+ c
968
+ );
969
+ for (const _ of Object.keys(g.state))
970
+ for (let A = E.length - 1; A >= 0; A--)
971
+ if (E[A].operation.scope === _) {
972
+ if (E[A].operation.hash !== xt(g, _))
973
+ throw new Error(`Hash mismatch for scope ${_}`);
974
+ break;
975
+ }
976
+ const S = Object.keys(
977
+ g.operations
964
978
  ).reduce(
965
- (h, $) => {
966
- const S = $, J = s && s.revision[S] < t[S].length ? t[S].slice(s.revision[S]) : [];
979
+ (_, A) => {
980
+ const r = A, m = a && a.revision[r] < t[r].length ? t[r].slice(a.revision[r]) : [];
967
981
  return {
968
- ...h,
969
- [S]: [
970
- ...f.operations[S].map((C, c) => {
971
- var l;
982
+ ..._,
983
+ [r]: [
984
+ ...g.operations[r].map((b, D) => {
985
+ var U;
972
986
  return {
973
- ...C,
974
- timestamp: ((l = t[S][c]) == null ? void 0 : l.timestamp) ?? C.timestamp
987
+ ...b,
988
+ timestamp: ((U = t[r][D]) == null ? void 0 : U.timestamp) ?? b.timestamp
975
989
  };
976
990
  }),
977
- ...J
991
+ ...m
978
992
  ]
979
993
  };
980
994
  },
981
995
  { global: [], local: [] }
982
- ), b = Object.values(A).reduce((h, $) => {
983
- for (const S of $)
984
- S.timestamp > h && (h = S.timestamp);
985
- return h;
996
+ ), F = Object.values(S).reduce((_, A) => {
997
+ for (const r of A)
998
+ r.timestamp > _ && (_ = r.timestamp);
999
+ return _;
986
1000
  }, e.lastModified);
987
- return { ...f, operations: A, lastModified: b };
1001
+ return { ...g, operations: S, lastModified: F };
988
1002
  }
989
- function He(e, t) {
990
- return rt(e) === rt(t);
1003
+ function Ge(e, t) {
1004
+ return st(e) === st(t);
991
1005
  }
992
- const Jt = (e) => W(
1006
+ const Jt = (e) => H(
993
1007
  "SET_NAME",
994
1008
  e,
995
1009
  void 0,
996
1010
  gt,
997
1011
  void 0
998
- ), Ut = (e = 1, t = "global") => W(
1012
+ ), Ut = (e = 1, t = "global") => H(
999
1013
  "UNDO",
1000
1014
  e,
1001
1015
  void 0,
1002
1016
  ht,
1003
1017
  t
1004
- ), Vt = (e = 1, t = "global") => W(
1018
+ ), Vt = (e = 1, t = "global") => H(
1005
1019
  "REDO",
1006
1020
  e,
1007
1021
  void 0,
1008
1022
  dt,
1009
1023
  t
1010
- ), Kt = (e, t, i = "global") => W(
1024
+ ), Kt = (e, t, i = "global") => H(
1011
1025
  "PRUNE",
1012
1026
  { start: e, end: t },
1013
1027
  void 0,
1014
1028
  ft,
1015
1029
  i
1016
- ), xt = (e, t) => W(
1030
+ ), bt = (e, t) => H(
1017
1031
  "LOAD_STATE",
1018
1032
  { state: e, operations: t },
1019
1033
  void 0,
1020
1034
  ut
1021
- ), bt = (e = "global") => W("NOOP", {}, void 0, void 0, e), Qe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1035
+ ), yt = (e = "global") => H("NOOP", {}, void 0, void 0, e), Qe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1022
1036
  __proto__: null,
1023
- loadState: xt,
1024
- noop: bt,
1037
+ loadState: bt,
1038
+ noop: yt,
1025
1039
  prune: Kt,
1026
1040
  redo: Vt,
1027
1041
  setName: Jt,
1028
1042
  undo: Ut
1029
- }, Symbol.toStringTag, { value: "Module" })), Wt = { "application/andrew-inset": ["ez"], "application/appinstaller": ["appinstaller"], "application/applixware": ["aw"], "application/appx": ["appx"], "application/appxbundle": ["appxbundle"], "application/atom+xml": ["atom"], "application/atomcat+xml": ["atomcat"], "application/atomdeleted+xml": ["atomdeleted"], "application/atomsvc+xml": ["atomsvc"], "application/atsc-dwd+xml": ["dwd"], "application/atsc-held+xml": ["held"], "application/atsc-rsat+xml": ["rsat"], "application/automationml-aml+xml": ["aml"], "application/automationml-amlx+zip": ["amlx"], "application/bdoc": ["bdoc"], "application/calendar+xml": ["xcs"], "application/ccxml+xml": ["ccxml"], "application/cdfx+xml": ["cdfx"], "application/cdmi-capability": ["cdmia"], "application/cdmi-container": ["cdmic"], "application/cdmi-domain": ["cdmid"], "application/cdmi-object": ["cdmio"], "application/cdmi-queue": ["cdmiq"], "application/cpl+xml": ["cpl"], "application/cu-seeme": ["cu"], "application/cwl": ["cwl"], "application/dash+xml": ["mpd"], "application/dash-patch+xml": ["mpp"], "application/davmount+xml": ["davmount"], "application/docbook+xml": ["dbk"], "application/dssc+der": ["dssc"], "application/dssc+xml": ["xdssc"], "application/ecmascript": ["ecma"], "application/emma+xml": ["emma"], "application/emotionml+xml": ["emotionml"], "application/epub+zip": ["epub"], "application/exi": ["exi"], "application/express": ["exp"], "application/fdf": ["fdf"], "application/fdt+xml": ["fdt"], "application/font-tdpfr": ["pfr"], "application/geo+json": ["geojson"], "application/gml+xml": ["gml"], "application/gpx+xml": ["gpx"], "application/gxf": ["gxf"], "application/gzip": ["gz"], "application/hjson": ["hjson"], "application/hyperstudio": ["stk"], "application/inkml+xml": ["ink", "inkml"], "application/ipfix": ["ipfix"], "application/its+xml": ["its"], "application/java-archive": ["jar", "war", "ear"], "application/java-serialized-object": ["ser"], "application/java-vm": ["class"], "application/javascript": ["*js"], "application/json": ["json", "map"], "application/json5": ["json5"], "application/jsonml+json": ["jsonml"], "application/ld+json": ["jsonld"], "application/lgr+xml": ["lgr"], "application/lost+xml": ["lostxml"], "application/mac-binhex40": ["hqx"], "application/mac-compactpro": ["cpt"], "application/mads+xml": ["mads"], "application/manifest+json": ["webmanifest"], "application/marc": ["mrc"], "application/marcxml+xml": ["mrcx"], "application/mathematica": ["ma", "nb", "mb"], "application/mathml+xml": ["mathml"], "application/mbox": ["mbox"], "application/media-policy-dataset+xml": ["mpf"], "application/mediaservercontrol+xml": ["mscml"], "application/metalink+xml": ["metalink"], "application/metalink4+xml": ["meta4"], "application/mets+xml": ["mets"], "application/mmt-aei+xml": ["maei"], "application/mmt-usd+xml": ["musd"], "application/mods+xml": ["mods"], "application/mp21": ["m21", "mp21"], "application/mp4": ["*mp4", "*mpg4", "mp4s", "m4p"], "application/msix": ["msix"], "application/msixbundle": ["msixbundle"], "application/msword": ["doc", "dot"], "application/mxf": ["mxf"], "application/n-quads": ["nq"], "application/n-triples": ["nt"], "application/node": ["cjs"], "application/octet-stream": ["bin", "dms", "lrf", "mar", "so", "dist", "distz", "pkg", "bpk", "dump", "elc", "deploy", "exe", "dll", "deb", "dmg", "iso", "img", "msi", "msp", "msm", "buffer"], "application/oda": ["oda"], "application/oebps-package+xml": ["opf"], "application/ogg": ["ogx"], "application/omdoc+xml": ["omdoc"], "application/onenote": ["onetoc", "onetoc2", "onetmp", "onepkg"], "application/oxps": ["oxps"], "application/p2p-overlay+xml": ["relo"], "application/patch-ops-error+xml": ["xer"], "application/pdf": ["pdf"], "application/pgp-encrypted": ["pgp"], "application/pgp-keys": ["asc"], "application/pgp-signature": ["sig", "*asc"], "application/pics-rules": ["prf"], "application/pkcs10": ["p10"], "application/pkcs7-mime": ["p7m", "p7c"], "application/pkcs7-signature": ["p7s"], "application/pkcs8": ["p8"], "application/pkix-attr-cert": ["ac"], "application/pkix-cert": ["cer"], "application/pkix-crl": ["crl"], "application/pkix-pkipath": ["pkipath"], "application/pkixcmp": ["pki"], "application/pls+xml": ["pls"], "application/postscript": ["ai", "eps", "ps"], "application/provenance+xml": ["provx"], "application/pskc+xml": ["pskcxml"], "application/raml+yaml": ["raml"], "application/rdf+xml": ["rdf", "owl"], "application/reginfo+xml": ["rif"], "application/relax-ng-compact-syntax": ["rnc"], "application/resource-lists+xml": ["rl"], "application/resource-lists-diff+xml": ["rld"], "application/rls-services+xml": ["rs"], "application/route-apd+xml": ["rapd"], "application/route-s-tsid+xml": ["sls"], "application/route-usd+xml": ["rusd"], "application/rpki-ghostbusters": ["gbr"], "application/rpki-manifest": ["mft"], "application/rpki-roa": ["roa"], "application/rsd+xml": ["rsd"], "application/rss+xml": ["rss"], "application/rtf": ["rtf"], "application/sbml+xml": ["sbml"], "application/scvp-cv-request": ["scq"], "application/scvp-cv-response": ["scs"], "application/scvp-vp-request": ["spq"], "application/scvp-vp-response": ["spp"], "application/sdp": ["sdp"], "application/senml+xml": ["senmlx"], "application/sensml+xml": ["sensmlx"], "application/set-payment-initiation": ["setpay"], "application/set-registration-initiation": ["setreg"], "application/shf+xml": ["shf"], "application/sieve": ["siv", "sieve"], "application/smil+xml": ["smi", "smil"], "application/sparql-query": ["rq"], "application/sparql-results+xml": ["srx"], "application/sql": ["sql"], "application/srgs": ["gram"], "application/srgs+xml": ["grxml"], "application/sru+xml": ["sru"], "application/ssdl+xml": ["ssdl"], "application/ssml+xml": ["ssml"], "application/swid+xml": ["swidtag"], "application/tei+xml": ["tei", "teicorpus"], "application/thraud+xml": ["tfi"], "application/timestamped-data": ["tsd"], "application/toml": ["toml"], "application/trig": ["trig"], "application/ttml+xml": ["ttml"], "application/ubjson": ["ubj"], "application/urc-ressheet+xml": ["rsheet"], "application/urc-targetdesc+xml": ["td"], "application/voicexml+xml": ["vxml"], "application/wasm": ["wasm"], "application/watcherinfo+xml": ["wif"], "application/widget": ["wgt"], "application/winhlp": ["hlp"], "application/wsdl+xml": ["wsdl"], "application/wspolicy+xml": ["wspolicy"], "application/xaml+xml": ["xaml"], "application/xcap-att+xml": ["xav"], "application/xcap-caps+xml": ["xca"], "application/xcap-diff+xml": ["xdf"], "application/xcap-el+xml": ["xel"], "application/xcap-ns+xml": ["xns"], "application/xenc+xml": ["xenc"], "application/xfdf": ["xfdf"], "application/xhtml+xml": ["xhtml", "xht"], "application/xliff+xml": ["xlf"], "application/xml": ["xml", "xsl", "xsd", "rng"], "application/xml-dtd": ["dtd"], "application/xop+xml": ["xop"], "application/xproc+xml": ["xpl"], "application/xslt+xml": ["*xsl", "xslt"], "application/xspf+xml": ["xspf"], "application/xv+xml": ["mxml", "xhvml", "xvml", "xvm"], "application/yang": ["yang"], "application/yin+xml": ["yin"], "application/zip": ["zip"], "audio/3gpp": ["*3gpp"], "audio/aac": ["adts", "aac"], "audio/adpcm": ["adp"], "audio/amr": ["amr"], "audio/basic": ["au", "snd"], "audio/midi": ["mid", "midi", "kar", "rmi"], "audio/mobile-xmf": ["mxmf"], "audio/mp3": ["*mp3"], "audio/mp4": ["m4a", "mp4a"], "audio/mpeg": ["mpga", "mp2", "mp2a", "mp3", "m2a", "m3a"], "audio/ogg": ["oga", "ogg", "spx", "opus"], "audio/s3m": ["s3m"], "audio/silk": ["sil"], "audio/wav": ["wav"], "audio/wave": ["*wav"], "audio/webm": ["weba"], "audio/xm": ["xm"], "font/collection": ["ttc"], "font/otf": ["otf"], "font/ttf": ["ttf"], "font/woff": ["woff"], "font/woff2": ["woff2"], "image/aces": ["exr"], "image/apng": ["apng"], "image/avci": ["avci"], "image/avcs": ["avcs"], "image/avif": ["avif"], "image/bmp": ["bmp", "dib"], "image/cgm": ["cgm"], "image/dicom-rle": ["drle"], "image/dpx": ["dpx"], "image/emf": ["emf"], "image/fits": ["fits"], "image/g3fax": ["g3"], "image/gif": ["gif"], "image/heic": ["heic"], "image/heic-sequence": ["heics"], "image/heif": ["heif"], "image/heif-sequence": ["heifs"], "image/hej2k": ["hej2"], "image/hsj2": ["hsj2"], "image/ief": ["ief"], "image/jls": ["jls"], "image/jp2": ["jp2", "jpg2"], "image/jpeg": ["jpeg", "jpg", "jpe"], "image/jph": ["jph"], "image/jphc": ["jhc"], "image/jpm": ["jpm", "jpgm"], "image/jpx": ["jpx", "jpf"], "image/jxr": ["jxr"], "image/jxra": ["jxra"], "image/jxrs": ["jxrs"], "image/jxs": ["jxs"], "image/jxsc": ["jxsc"], "image/jxsi": ["jxsi"], "image/jxss": ["jxss"], "image/ktx": ["ktx"], "image/ktx2": ["ktx2"], "image/png": ["png"], "image/sgi": ["sgi"], "image/svg+xml": ["svg", "svgz"], "image/t38": ["t38"], "image/tiff": ["tif", "tiff"], "image/tiff-fx": ["tfx"], "image/webp": ["webp"], "image/wmf": ["wmf"], "message/disposition-notification": ["disposition-notification"], "message/global": ["u8msg"], "message/global-delivery-status": ["u8dsn"], "message/global-disposition-notification": ["u8mdn"], "message/global-headers": ["u8hdr"], "message/rfc822": ["eml", "mime"], "model/3mf": ["3mf"], "model/gltf+json": ["gltf"], "model/gltf-binary": ["glb"], "model/iges": ["igs", "iges"], "model/jt": ["jt"], "model/mesh": ["msh", "mesh", "silo"], "model/mtl": ["mtl"], "model/obj": ["obj"], "model/prc": ["prc"], "model/step+xml": ["stpx"], "model/step+zip": ["stpz"], "model/step-xml+zip": ["stpxz"], "model/stl": ["stl"], "model/u3d": ["u3d"], "model/vrml": ["wrl", "vrml"], "model/x3d+binary": ["*x3db", "x3dbz"], "model/x3d+fastinfoset": ["x3db"], "model/x3d+vrml": ["*x3dv", "x3dvz"], "model/x3d+xml": ["x3d", "x3dz"], "model/x3d-vrml": ["x3dv"], "text/cache-manifest": ["appcache", "manifest"], "text/calendar": ["ics", "ifb"], "text/coffeescript": ["coffee", "litcoffee"], "text/css": ["css"], "text/csv": ["csv"], "text/html": ["html", "htm", "shtml"], "text/jade": ["jade"], "text/javascript": ["js", "mjs"], "text/jsx": ["jsx"], "text/less": ["less"], "text/markdown": ["md", "markdown"], "text/mathml": ["mml"], "text/mdx": ["mdx"], "text/n3": ["n3"], "text/plain": ["txt", "text", "conf", "def", "list", "log", "in", "ini"], "text/richtext": ["rtx"], "text/rtf": ["*rtf"], "text/sgml": ["sgml", "sgm"], "text/shex": ["shex"], "text/slim": ["slim", "slm"], "text/spdx": ["spdx"], "text/stylus": ["stylus", "styl"], "text/tab-separated-values": ["tsv"], "text/troff": ["t", "tr", "roff", "man", "me", "ms"], "text/turtle": ["ttl"], "text/uri-list": ["uri", "uris", "urls"], "text/vcard": ["vcard"], "text/vtt": ["vtt"], "text/wgsl": ["wgsl"], "text/xml": ["*xml"], "text/yaml": ["yaml", "yml"], "video/3gpp": ["3gp", "3gpp"], "video/3gpp2": ["3g2"], "video/h261": ["h261"], "video/h263": ["h263"], "video/h264": ["h264"], "video/iso.segment": ["m4s"], "video/jpeg": ["jpgv"], "video/jpm": ["*jpm", "*jpgm"], "video/mj2": ["mj2", "mjp2"], "video/mp2t": ["ts"], "video/mp4": ["mp4", "mp4v", "mpg4"], "video/mpeg": ["mpeg", "mpg", "mpe", "m1v", "m2v"], "video/ogg": ["ogv"], "video/quicktime": ["qt", "mov"], "video/webm": ["webm"] };
1030
- Object.freeze(Wt);
1031
- var F = function(e, t, i, n) {
1043
+ }, Symbol.toStringTag, { value: "Module" })), Ht = { "application/andrew-inset": ["ez"], "application/appinstaller": ["appinstaller"], "application/applixware": ["aw"], "application/appx": ["appx"], "application/appxbundle": ["appxbundle"], "application/atom+xml": ["atom"], "application/atomcat+xml": ["atomcat"], "application/atomdeleted+xml": ["atomdeleted"], "application/atomsvc+xml": ["atomsvc"], "application/atsc-dwd+xml": ["dwd"], "application/atsc-held+xml": ["held"], "application/atsc-rsat+xml": ["rsat"], "application/automationml-aml+xml": ["aml"], "application/automationml-amlx+zip": ["amlx"], "application/bdoc": ["bdoc"], "application/calendar+xml": ["xcs"], "application/ccxml+xml": ["ccxml"], "application/cdfx+xml": ["cdfx"], "application/cdmi-capability": ["cdmia"], "application/cdmi-container": ["cdmic"], "application/cdmi-domain": ["cdmid"], "application/cdmi-object": ["cdmio"], "application/cdmi-queue": ["cdmiq"], "application/cpl+xml": ["cpl"], "application/cu-seeme": ["cu"], "application/cwl": ["cwl"], "application/dash+xml": ["mpd"], "application/dash-patch+xml": ["mpp"], "application/davmount+xml": ["davmount"], "application/docbook+xml": ["dbk"], "application/dssc+der": ["dssc"], "application/dssc+xml": ["xdssc"], "application/ecmascript": ["ecma"], "application/emma+xml": ["emma"], "application/emotionml+xml": ["emotionml"], "application/epub+zip": ["epub"], "application/exi": ["exi"], "application/express": ["exp"], "application/fdf": ["fdf"], "application/fdt+xml": ["fdt"], "application/font-tdpfr": ["pfr"], "application/geo+json": ["geojson"], "application/gml+xml": ["gml"], "application/gpx+xml": ["gpx"], "application/gxf": ["gxf"], "application/gzip": ["gz"], "application/hjson": ["hjson"], "application/hyperstudio": ["stk"], "application/inkml+xml": ["ink", "inkml"], "application/ipfix": ["ipfix"], "application/its+xml": ["its"], "application/java-archive": ["jar", "war", "ear"], "application/java-serialized-object": ["ser"], "application/java-vm": ["class"], "application/javascript": ["*js"], "application/json": ["json", "map"], "application/json5": ["json5"], "application/jsonml+json": ["jsonml"], "application/ld+json": ["jsonld"], "application/lgr+xml": ["lgr"], "application/lost+xml": ["lostxml"], "application/mac-binhex40": ["hqx"], "application/mac-compactpro": ["cpt"], "application/mads+xml": ["mads"], "application/manifest+json": ["webmanifest"], "application/marc": ["mrc"], "application/marcxml+xml": ["mrcx"], "application/mathematica": ["ma", "nb", "mb"], "application/mathml+xml": ["mathml"], "application/mbox": ["mbox"], "application/media-policy-dataset+xml": ["mpf"], "application/mediaservercontrol+xml": ["mscml"], "application/metalink+xml": ["metalink"], "application/metalink4+xml": ["meta4"], "application/mets+xml": ["mets"], "application/mmt-aei+xml": ["maei"], "application/mmt-usd+xml": ["musd"], "application/mods+xml": ["mods"], "application/mp21": ["m21", "mp21"], "application/mp4": ["*mp4", "*mpg4", "mp4s", "m4p"], "application/msix": ["msix"], "application/msixbundle": ["msixbundle"], "application/msword": ["doc", "dot"], "application/mxf": ["mxf"], "application/n-quads": ["nq"], "application/n-triples": ["nt"], "application/node": ["cjs"], "application/octet-stream": ["bin", "dms", "lrf", "mar", "so", "dist", "distz", "pkg", "bpk", "dump", "elc", "deploy", "exe", "dll", "deb", "dmg", "iso", "img", "msi", "msp", "msm", "buffer"], "application/oda": ["oda"], "application/oebps-package+xml": ["opf"], "application/ogg": ["ogx"], "application/omdoc+xml": ["omdoc"], "application/onenote": ["onetoc", "onetoc2", "onetmp", "onepkg"], "application/oxps": ["oxps"], "application/p2p-overlay+xml": ["relo"], "application/patch-ops-error+xml": ["xer"], "application/pdf": ["pdf"], "application/pgp-encrypted": ["pgp"], "application/pgp-keys": ["asc"], "application/pgp-signature": ["sig", "*asc"], "application/pics-rules": ["prf"], "application/pkcs10": ["p10"], "application/pkcs7-mime": ["p7m", "p7c"], "application/pkcs7-signature": ["p7s"], "application/pkcs8": ["p8"], "application/pkix-attr-cert": ["ac"], "application/pkix-cert": ["cer"], "application/pkix-crl": ["crl"], "application/pkix-pkipath": ["pkipath"], "application/pkixcmp": ["pki"], "application/pls+xml": ["pls"], "application/postscript": ["ai", "eps", "ps"], "application/provenance+xml": ["provx"], "application/pskc+xml": ["pskcxml"], "application/raml+yaml": ["raml"], "application/rdf+xml": ["rdf", "owl"], "application/reginfo+xml": ["rif"], "application/relax-ng-compact-syntax": ["rnc"], "application/resource-lists+xml": ["rl"], "application/resource-lists-diff+xml": ["rld"], "application/rls-services+xml": ["rs"], "application/route-apd+xml": ["rapd"], "application/route-s-tsid+xml": ["sls"], "application/route-usd+xml": ["rusd"], "application/rpki-ghostbusters": ["gbr"], "application/rpki-manifest": ["mft"], "application/rpki-roa": ["roa"], "application/rsd+xml": ["rsd"], "application/rss+xml": ["rss"], "application/rtf": ["rtf"], "application/sbml+xml": ["sbml"], "application/scvp-cv-request": ["scq"], "application/scvp-cv-response": ["scs"], "application/scvp-vp-request": ["spq"], "application/scvp-vp-response": ["spp"], "application/sdp": ["sdp"], "application/senml+xml": ["senmlx"], "application/sensml+xml": ["sensmlx"], "application/set-payment-initiation": ["setpay"], "application/set-registration-initiation": ["setreg"], "application/shf+xml": ["shf"], "application/sieve": ["siv", "sieve"], "application/smil+xml": ["smi", "smil"], "application/sparql-query": ["rq"], "application/sparql-results+xml": ["srx"], "application/sql": ["sql"], "application/srgs": ["gram"], "application/srgs+xml": ["grxml"], "application/sru+xml": ["sru"], "application/ssdl+xml": ["ssdl"], "application/ssml+xml": ["ssml"], "application/swid+xml": ["swidtag"], "application/tei+xml": ["tei", "teicorpus"], "application/thraud+xml": ["tfi"], "application/timestamped-data": ["tsd"], "application/toml": ["toml"], "application/trig": ["trig"], "application/ttml+xml": ["ttml"], "application/ubjson": ["ubj"], "application/urc-ressheet+xml": ["rsheet"], "application/urc-targetdesc+xml": ["td"], "application/voicexml+xml": ["vxml"], "application/wasm": ["wasm"], "application/watcherinfo+xml": ["wif"], "application/widget": ["wgt"], "application/winhlp": ["hlp"], "application/wsdl+xml": ["wsdl"], "application/wspolicy+xml": ["wspolicy"], "application/xaml+xml": ["xaml"], "application/xcap-att+xml": ["xav"], "application/xcap-caps+xml": ["xca"], "application/xcap-diff+xml": ["xdf"], "application/xcap-el+xml": ["xel"], "application/xcap-ns+xml": ["xns"], "application/xenc+xml": ["xenc"], "application/xfdf": ["xfdf"], "application/xhtml+xml": ["xhtml", "xht"], "application/xliff+xml": ["xlf"], "application/xml": ["xml", "xsl", "xsd", "rng"], "application/xml-dtd": ["dtd"], "application/xop+xml": ["xop"], "application/xproc+xml": ["xpl"], "application/xslt+xml": ["*xsl", "xslt"], "application/xspf+xml": ["xspf"], "application/xv+xml": ["mxml", "xhvml", "xvml", "xvm"], "application/yang": ["yang"], "application/yin+xml": ["yin"], "application/zip": ["zip"], "audio/3gpp": ["*3gpp"], "audio/aac": ["adts", "aac"], "audio/adpcm": ["adp"], "audio/amr": ["amr"], "audio/basic": ["au", "snd"], "audio/midi": ["mid", "midi", "kar", "rmi"], "audio/mobile-xmf": ["mxmf"], "audio/mp3": ["*mp3"], "audio/mp4": ["m4a", "mp4a"], "audio/mpeg": ["mpga", "mp2", "mp2a", "mp3", "m2a", "m3a"], "audio/ogg": ["oga", "ogg", "spx", "opus"], "audio/s3m": ["s3m"], "audio/silk": ["sil"], "audio/wav": ["wav"], "audio/wave": ["*wav"], "audio/webm": ["weba"], "audio/xm": ["xm"], "font/collection": ["ttc"], "font/otf": ["otf"], "font/ttf": ["ttf"], "font/woff": ["woff"], "font/woff2": ["woff2"], "image/aces": ["exr"], "image/apng": ["apng"], "image/avci": ["avci"], "image/avcs": ["avcs"], "image/avif": ["avif"], "image/bmp": ["bmp", "dib"], "image/cgm": ["cgm"], "image/dicom-rle": ["drle"], "image/dpx": ["dpx"], "image/emf": ["emf"], "image/fits": ["fits"], "image/g3fax": ["g3"], "image/gif": ["gif"], "image/heic": ["heic"], "image/heic-sequence": ["heics"], "image/heif": ["heif"], "image/heif-sequence": ["heifs"], "image/hej2k": ["hej2"], "image/hsj2": ["hsj2"], "image/ief": ["ief"], "image/jls": ["jls"], "image/jp2": ["jp2", "jpg2"], "image/jpeg": ["jpeg", "jpg", "jpe"], "image/jph": ["jph"], "image/jphc": ["jhc"], "image/jpm": ["jpm", "jpgm"], "image/jpx": ["jpx", "jpf"], "image/jxr": ["jxr"], "image/jxra": ["jxra"], "image/jxrs": ["jxrs"], "image/jxs": ["jxs"], "image/jxsc": ["jxsc"], "image/jxsi": ["jxsi"], "image/jxss": ["jxss"], "image/ktx": ["ktx"], "image/ktx2": ["ktx2"], "image/png": ["png"], "image/sgi": ["sgi"], "image/svg+xml": ["svg", "svgz"], "image/t38": ["t38"], "image/tiff": ["tif", "tiff"], "image/tiff-fx": ["tfx"], "image/webp": ["webp"], "image/wmf": ["wmf"], "message/disposition-notification": ["disposition-notification"], "message/global": ["u8msg"], "message/global-delivery-status": ["u8dsn"], "message/global-disposition-notification": ["u8mdn"], "message/global-headers": ["u8hdr"], "message/rfc822": ["eml", "mime"], "model/3mf": ["3mf"], "model/gltf+json": ["gltf"], "model/gltf-binary": ["glb"], "model/iges": ["igs", "iges"], "model/jt": ["jt"], "model/mesh": ["msh", "mesh", "silo"], "model/mtl": ["mtl"], "model/obj": ["obj"], "model/prc": ["prc"], "model/step+xml": ["stpx"], "model/step+zip": ["stpz"], "model/step-xml+zip": ["stpxz"], "model/stl": ["stl"], "model/u3d": ["u3d"], "model/vrml": ["wrl", "vrml"], "model/x3d+binary": ["*x3db", "x3dbz"], "model/x3d+fastinfoset": ["x3db"], "model/x3d+vrml": ["*x3dv", "x3dvz"], "model/x3d+xml": ["x3d", "x3dz"], "model/x3d-vrml": ["x3dv"], "text/cache-manifest": ["appcache", "manifest"], "text/calendar": ["ics", "ifb"], "text/coffeescript": ["coffee", "litcoffee"], "text/css": ["css"], "text/csv": ["csv"], "text/html": ["html", "htm", "shtml"], "text/jade": ["jade"], "text/javascript": ["js", "mjs"], "text/jsx": ["jsx"], "text/less": ["less"], "text/markdown": ["md", "markdown"], "text/mathml": ["mml"], "text/mdx": ["mdx"], "text/n3": ["n3"], "text/plain": ["txt", "text", "conf", "def", "list", "log", "in", "ini"], "text/richtext": ["rtx"], "text/rtf": ["*rtf"], "text/sgml": ["sgml", "sgm"], "text/shex": ["shex"], "text/slim": ["slim", "slm"], "text/spdx": ["spdx"], "text/stylus": ["stylus", "styl"], "text/tab-separated-values": ["tsv"], "text/troff": ["t", "tr", "roff", "man", "me", "ms"], "text/turtle": ["ttl"], "text/uri-list": ["uri", "uris", "urls"], "text/vcard": ["vcard"], "text/vtt": ["vtt"], "text/wgsl": ["wgsl"], "text/xml": ["*xml"], "text/yaml": ["yaml", "yml"], "video/3gpp": ["3gp", "3gpp"], "video/3gpp2": ["3g2"], "video/h261": ["h261"], "video/h263": ["h263"], "video/h264": ["h264"], "video/iso.segment": ["m4s"], "video/jpeg": ["jpgv"], "video/jpm": ["*jpm", "*jpgm"], "video/mj2": ["mj2", "mjp2"], "video/mp2t": ["ts"], "video/mp4": ["mp4", "mp4v", "mpg4"], "video/mpeg": ["mpeg", "mpg", "mpe", "m1v", "m2v"], "video/ogg": ["ogv"], "video/quicktime": ["qt", "mov"], "video/webm": ["webm"] };
1044
+ Object.freeze(Ht);
1045
+ var L = function(e, t, i, n) {
1032
1046
  if (i === "a" && !n)
1033
1047
  throw new TypeError("Private accessor was defined without a getter");
1034
1048
  if (typeof t == "function" ? e !== t || !n : !t.has(e))
1035
1049
  throw new TypeError("Cannot read private member from an object whose class did not declare it");
1036
1050
  return i === "m" ? n : i === "a" ? n.call(e) : n ? n.value : t.get(e);
1037
- }, K, G, U;
1051
+ }, K, Z, V;
1038
1052
  class Me {
1039
1053
  constructor(...t) {
1040
- K.set(this, /* @__PURE__ */ new Map()), G.set(this, /* @__PURE__ */ new Map()), U.set(this, /* @__PURE__ */ new Map());
1054
+ K.set(this, /* @__PURE__ */ new Map()), Z.set(this, /* @__PURE__ */ new Map()), V.set(this, /* @__PURE__ */ new Map());
1041
1055
  for (const i of t)
1042
1056
  this.define(i);
1043
1057
  }
1044
1058
  define(t, i = !1) {
1045
- for (let [n, s] of Object.entries(t)) {
1046
- n = n.toLowerCase(), s = s.map((p) => p.toLowerCase()), F(this, U, "f").has(n) || F(this, U, "f").set(n, /* @__PURE__ */ new Set());
1047
- const a = F(this, U, "f").get(n);
1048
- let r = !0;
1049
- for (let p of s) {
1050
- const d = p.startsWith("*");
1051
- if (p = d ? p.slice(1) : p, a == null || a.add(p), r && F(this, G, "f").set(n, p), r = !1, d)
1059
+ for (let [n, a] of Object.entries(t)) {
1060
+ n = n.toLowerCase(), a = a.map((l) => l.toLowerCase()), L(this, V, "f").has(n) || L(this, V, "f").set(n, /* @__PURE__ */ new Set());
1061
+ const p = L(this, V, "f").get(n);
1062
+ let s = !0;
1063
+ for (let l of a) {
1064
+ const c = l.startsWith("*");
1065
+ if (l = c ? l.slice(1) : l, p == null || p.add(l), s && L(this, Z, "f").set(n, l), s = !1, c)
1052
1066
  continue;
1053
- const f = F(this, K, "f").get(p);
1054
- if (f && f != n && !i)
1055
- throw new Error(`"${n} -> ${p}" conflicts with "${f} -> ${p}". Pass \`force=true\` to override this definition.`);
1056
- F(this, K, "f").set(p, n);
1067
+ const x = L(this, K, "f").get(l);
1068
+ if (x && x != n && !i)
1069
+ throw new Error(`"${n} -> ${l}" conflicts with "${x} -> ${l}". Pass \`force=true\` to override this definition.`);
1070
+ L(this, K, "f").set(l, n);
1057
1071
  }
1058
1072
  }
1059
1073
  return this;
@@ -1061,134 +1075,134 @@ class Me {
1061
1075
  getType(t) {
1062
1076
  if (typeof t != "string")
1063
1077
  return null;
1064
- const i = t.replace(/^.*[/\\]/, "").toLowerCase(), n = i.replace(/^.*\./, "").toLowerCase(), s = i.length < t.length;
1065
- return !(n.length < i.length - 1) && s ? null : F(this, K, "f").get(n) ?? null;
1078
+ const i = t.replace(/^.*[/\\]/, "").toLowerCase(), n = i.replace(/^.*\./, "").toLowerCase(), a = i.length < t.length;
1079
+ return !(n.length < i.length - 1) && a ? null : L(this, K, "f").get(n) ?? null;
1066
1080
  }
1067
1081
  getExtension(t) {
1068
1082
  var i;
1069
- return typeof t != "string" ? null : (t = (i = t == null ? void 0 : t.split) == null ? void 0 : i.call(t, ";")[0], (t && F(this, G, "f").get(t.trim().toLowerCase())) ?? null);
1083
+ return typeof t != "string" ? null : (t = (i = t == null ? void 0 : t.split) == null ? void 0 : i.call(t, ";")[0], (t && L(this, Z, "f").get(t.trim().toLowerCase())) ?? null);
1070
1084
  }
1071
1085
  getAllExtensions(t) {
1072
- return typeof t != "string" ? null : F(this, U, "f").get(t.toLowerCase()) ?? null;
1086
+ return typeof t != "string" ? null : L(this, V, "f").get(t.toLowerCase()) ?? null;
1073
1087
  }
1074
1088
  _freeze() {
1075
1089
  this.define = () => {
1076
1090
  throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances");
1077
1091
  }, Object.freeze(this);
1078
- for (const t of F(this, U, "f").values())
1092
+ for (const t of L(this, V, "f").values())
1079
1093
  Object.freeze(t);
1080
1094
  return this;
1081
1095
  }
1082
1096
  _getTestState() {
1083
1097
  return {
1084
- types: F(this, K, "f"),
1085
- extensions: F(this, G, "f")
1098
+ types: L(this, K, "f"),
1099
+ extensions: L(this, Z, "f")
1086
1100
  };
1087
1101
  }
1088
1102
  }
1089
- K = /* @__PURE__ */ new WeakMap(), G = /* @__PURE__ */ new WeakMap(), U = /* @__PURE__ */ new WeakMap();
1090
- const Pe = new Me(Wt)._freeze();
1103
+ K = /* @__PURE__ */ new WeakMap(), Z = /* @__PURE__ */ new WeakMap(), V = /* @__PURE__ */ new WeakMap();
1104
+ const Pe = new Me(Ht)._freeze();
1091
1105
  function Ie(e) {
1092
1106
  const t = [], i = Object.keys(e);
1093
1107
  for (const n of i) {
1094
- const s = e[n].sort((a, r) => a.index - r.index);
1095
- for (let a = 0; a < s.length; a++)
1096
- s[a].index !== a && t.push({
1097
- message: `Invalid operation index ${s[a].index} at position ${a}`,
1108
+ const a = e[n].sort((p, s) => p.index - s.index);
1109
+ for (let p = 0; p < a.length; p++)
1110
+ a[p].index !== p && t.push({
1111
+ message: `Invalid operation index ${a[p].index} at position ${p}`,
1098
1112
  details: {
1099
- position: a,
1100
- operation: s[a],
1101
- scope: s[a].scope
1113
+ position: p,
1114
+ operation: a[p],
1115
+ scope: a[p].scope
1102
1116
  }
1103
1117
  });
1104
1118
  }
1105
1119
  return t;
1106
1120
  }
1107
- const Bt = async (e) => {
1108
- const t = new St(), { name: i, revision: n, documentType: s, created: a, lastModified: r } = e, p = {
1121
+ const Wt = async (e) => {
1122
+ const t = new St(), { name: i, revision: n, documentType: a, created: p, lastModified: s } = e, l = {
1109
1123
  name: i,
1110
1124
  revision: n,
1111
- documentType: s,
1112
- created: a,
1113
- lastModified: r
1125
+ documentType: a,
1126
+ created: p,
1127
+ lastModified: s
1114
1128
  };
1115
- return t.file("header.json", JSON.stringify(p, null, 2)), t.file(
1129
+ return t.file("header.json", JSON.stringify(l, null, 2)), t.file(
1116
1130
  "state.json",
1117
1131
  JSON.stringify(e.initialState || {}, null, 2)
1118
- ), t.file("operations.json", JSON.stringify(e.operations, null, 2)), Object.keys(e.attachments).forEach((f) => {
1119
- const { data: A, ...b } = e.attachments[f];
1120
- t.file(f, A, {
1132
+ ), t.file("operations.json", JSON.stringify(e.operations, null, 2)), Object.keys(e.attachments).forEach((x) => {
1133
+ const { data: j, ...E } = e.attachments[x];
1134
+ t.file(x, j, {
1121
1135
  base64: !0,
1122
1136
  createFolders: !0,
1123
- comment: JSON.stringify(b)
1137
+ comment: JSON.stringify(E)
1124
1138
  });
1125
1139
  }), t;
1126
1140
  }, ze = async (e, t, i, n) => {
1127
- const a = await (await Bt(e)).generateAsync({
1141
+ const p = await (await Wt(e)).generateAsync({
1128
1142
  type: "uint8array",
1129
1143
  streamFiles: !0
1130
- }), r = n ?? e.name, p = `.${i}.zip`;
1131
- return Oe(
1144
+ }), s = n ?? e.name, l = `.${i}.zip`;
1145
+ return Se(
1132
1146
  t,
1133
- r.endsWith(p) ? r : `${r}${p}`,
1134
- a
1147
+ s.endsWith(l) ? s : `${s}${l}`,
1148
+ p
1135
1149
  );
1136
1150
  }, Xe = async (e, t) => {
1137
- const n = await (await Bt(e)).generateAsync({ type: "blob" }), s = await t.createWritable();
1138
- await s.write(n), await s.close();
1139
- }, jt = async (e, t) => {
1140
- const i = Lt(e);
1141
- return Fe(i, t);
1142
- }, Fe = async (e, t) => {
1143
- const i = new St();
1144
- return await i.loadAsync(e), Re(i, t);
1151
+ const n = await (await Wt(e)).generateAsync({ type: "blob" }), a = await t.createWritable();
1152
+ await a.write(n), await a.close();
1153
+ }, Ot = async (e, t, i) => {
1154
+ const n = qt(e);
1155
+ return Fe(n, t);
1156
+ }, Fe = async (e, t, i) => {
1157
+ const n = new St();
1158
+ return await n.loadAsync(e), Re(n, t);
1145
1159
  };
1146
- async function Re(e, t) {
1147
- const i = e.file("state.json");
1148
- if (!i)
1160
+ async function Re(e, t, i) {
1161
+ const n = e.file("state.json");
1162
+ if (!n)
1149
1163
  throw new Error("Initial state not found");
1150
- const n = await i.async("string"), s = JSON.parse(n), a = e.file("header.json");
1151
- let r;
1152
- a && (r = JSON.parse(await a.async("string")));
1153
- const p = e.file("operations.json");
1154
- if (!p)
1164
+ const a = await n.async("string"), p = JSON.parse(a), s = e.file("header.json");
1165
+ let l;
1166
+ s && (l = JSON.parse(await s.async("string")));
1167
+ const c = e.file("operations.json");
1168
+ if (!c)
1155
1169
  throw new Error("Operations history not found");
1156
- const d = JSON.parse(
1157
- await p.async("string")
1158
- ), f = Ie(d);
1159
- if (f.length) {
1160
- const b = f.map((h) => h.message);
1161
- throw new Error(b.join(`
1170
+ const x = JSON.parse(
1171
+ await c.async("string")
1172
+ ), j = Ie(x);
1173
+ if (j.length) {
1174
+ const g = j.map((S) => S.message);
1175
+ throw new Error(g.join(`
1162
1176
  `));
1163
1177
  }
1164
- let A = Ct(
1165
- s,
1166
- d,
1178
+ let E = Ct(
1179
+ p,
1180
+ x,
1167
1181
  t,
1168
1182
  void 0,
1169
- r
1183
+ l
1170
1184
  );
1171
- return r && (A = {
1172
- ...A,
1173
- ...r
1174
- }), A;
1185
+ return l && (E = {
1186
+ ...E,
1187
+ ...l
1188
+ }), E;
1175
1189
  }
1176
- function Zt(e) {
1190
+ function Bt(e) {
1177
1191
  const t = e.replace(/^.*\./, "") || void 0, i = e.replace(/^.*[/\\]/, "") || void 0;
1178
1192
  return { extension: t, fileName: i };
1179
1193
  }
1180
1194
  async function Ye(e) {
1181
- const { buffer: t, mimeType: i = "application/octet-stream" } = await $e(e), n = Zt(e), s = t.toString("base64");
1195
+ const { buffer: t, mimeType: i = "application/octet-stream" } = await $e(e), n = Bt(e), a = t.toString("base64");
1182
1196
  return {
1183
- data: s,
1184
- hash: at(s),
1197
+ data: a,
1198
+ hash: at(a),
1185
1199
  mimeType: i,
1186
1200
  ...n
1187
1201
  };
1188
1202
  }
1189
1203
  async function ti(e) {
1190
- const t = await Ee(e), i = Pe.getType(e) || "application/octet-stream", n = Zt(e), s = t.toString("base64");
1191
- return { data: s, hash: at(s), mimeType: i, ...n };
1204
+ const t = await Ee(e), i = Pe.getType(e) || "application/octet-stream", n = Bt(e), a = t.toString("base64");
1205
+ return { data: a, hash: at(a), mimeType: i, ...n };
1192
1206
  }
1193
1207
  class ei {
1194
1208
  /**
@@ -1229,7 +1243,7 @@ class ei {
1229
1243
  * @param path - The file path where the state is stored.
1230
1244
  */
1231
1245
  async loadFromFile(t) {
1232
- this._document = await jt(t, this._reducer);
1246
+ this._document = await Ot(t, this._reducer);
1233
1247
  }
1234
1248
  /**
1235
1249
  * Loads the state of the document from a file and returns it.
@@ -1238,7 +1252,7 @@ class ei {
1238
1252
  * @returns The state of the document.
1239
1253
  */
1240
1254
  static async stateFromFile(t, i) {
1241
- return await jt(t, i);
1255
+ return await Ot(t, i);
1242
1256
  }
1243
1257
  /**
1244
1258
  * Gets the current state of the document.
@@ -1339,7 +1353,7 @@ class ei {
1339
1353
  * @param operations - The operations to apply to the document.
1340
1354
  */
1341
1355
  loadState(t, i) {
1342
- return this.dispatch(xt(t, i)), this;
1356
+ return this.dispatch(bt(t, i)), this;
1343
1357
  }
1344
1358
  }
1345
1359
  function ii(e, t) {
@@ -1358,33 +1372,33 @@ function ii(e, t) {
1358
1372
  export {
1359
1373
  Ie as A,
1360
1374
  ei as B,
1361
- Rt as C,
1362
- Se as D,
1363
- Be as E,
1364
- _e as a,
1365
- ke as b,
1375
+ Lt as C,
1376
+ Oe as D,
1377
+ We as E,
1378
+ ke as a,
1379
+ _e as b,
1366
1380
  Te as c,
1367
1381
  Xe as d,
1368
1382
  Fe as e,
1369
- W as f,
1383
+ H as f,
1370
1384
  ii as g,
1371
1385
  Qe as h,
1372
- wt as i,
1386
+ jt as i,
1373
1387
  Ne as j,
1374
- Bt as k,
1375
- jt as l,
1388
+ Wt as k,
1389
+ Ot as l,
1376
1390
  ti as m,
1377
1391
  Ye as n,
1378
- qt as o,
1379
- Ze as p,
1392
+ xt as o,
1393
+ Be as p,
1380
1394
  ve as q,
1381
- He as r,
1395
+ Ge as r,
1382
1396
  ze as s,
1383
- yt as t,
1397
+ wt as t,
1384
1398
  Ae as u,
1385
1399
  ot as v,
1386
1400
  Ct as w,
1387
1401
  mt as x,
1388
1402
  De as y,
1389
- Ge as z
1403
+ Ze as z
1390
1404
  };