document-model 1.0.55 → 1.1.0-experimental.1

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 (108) hide show
  1. package/dist/browser/cjs/document-model.js +1 -1
  2. package/dist/browser/cjs/document.js +1 -1
  3. package/dist/browser/cjs/index.js +1 -1
  4. package/dist/browser/cjs/internal/index-DZx9eknf.js +1 -0
  5. package/dist/browser/cjs/internal/{index-C_OFq7P5.js → index-DypcJuba.js} +1 -1
  6. package/dist/browser/cjs/internal/object-BU2CI8g7.js +25 -0
  7. package/dist/browser/es/document-model.js +2 -2
  8. package/dist/browser/es/document.js +2 -2
  9. package/dist/browser/es/index.js +3 -3
  10. package/dist/browser/es/internal/index-BP3Z2ZVF.js +43 -0
  11. package/dist/browser/es/internal/{index-DvHnaqeu.js → index-CyBZ1dJQ.js} +1 -1
  12. package/dist/browser/es/internal/object-CPDHmXxz.js +2712 -0
  13. package/dist/browser/src/document/reducer.d.ts +13 -2
  14. package/dist/browser/src/document/utils/base.d.ts +1 -1
  15. package/dist/browser/src/document/utils/document-helpers.d.ts +53 -0
  16. package/dist/browser/src/document/utils/index.d.ts +1 -0
  17. package/dist/node/cjs/document-model.js +1 -1
  18. package/dist/node/cjs/document.js +1 -1
  19. package/dist/node/cjs/index.js +1 -1
  20. package/dist/node/cjs/internal/{index-GZsLKtHl.js → index-Bt4KwBzM.js} +1 -1
  21. package/dist/node/cjs/internal/index-CwTTSCCW.js +1 -0
  22. package/dist/node/cjs/internal/object-Bc_eSRcx.js +20 -0
  23. package/dist/node/es/document-model.js +3 -3
  24. package/dist/node/es/document.js +3 -3
  25. package/dist/node/es/index.js +4 -4
  26. package/dist/node/es/internal/{index-Chx4C-Xl.js → index-6nUwJlFL.js} +2 -2
  27. package/dist/node/es/internal/index-CLgAZiia.js +43 -0
  28. package/dist/node/es/internal/object-DofGWMf1.js +1610 -0
  29. package/dist/node/src/document/reducer.d.ts +13 -2
  30. package/dist/node/src/document/utils/base.d.ts +1 -1
  31. package/dist/node/src/document/utils/document-helpers.d.ts +53 -0
  32. package/dist/node/src/document/utils/index.d.ts +1 -0
  33. package/package.json +7 -2
  34. package/dist/browser/cjs/internal/index-Dwhv4k_6.js +0 -1
  35. package/dist/browser/cjs/internal/object-CeLE3akL.js +0 -25
  36. package/dist/browser/es/internal/index-Xcvn-MUq.js +0 -42
  37. package/dist/browser/es/internal/object-BDWVt0Zy.js +0 -2504
  38. package/dist/node/cjs/internal/index-Bi9yeV3W.js +0 -1
  39. package/dist/node/cjs/internal/object-CnhDksx1.js +0 -20
  40. package/dist/node/es/internal/index-B6iEYnbQ.js +0 -42
  41. package/dist/node/es/internal/object-CnV5hY_A.js +0 -1402
  42. package/dist/src/document/actions/creators.d.ts +0 -47
  43. package/dist/src/document/actions/index.d.ts +0 -14
  44. package/dist/src/document/actions/types.d.ts +0 -15
  45. package/dist/src/document/index.d.ts +0 -6
  46. package/dist/src/document/object.d.ts +0 -1175
  47. package/dist/src/document/reducer.d.ts +0 -32
  48. package/dist/src/document/schema/index.d.ts +0 -2
  49. package/dist/src/document/schema/types.d.ts +0 -176
  50. package/dist/src/document/schema/zod.d.ts +0 -113
  51. package/dist/src/document/signal.d.ts +0 -29
  52. package/dist/src/document/types.d.ts +0 -249
  53. package/dist/src/document/utils/base.d.ts +0 -85
  54. package/dist/src/document/utils/file.d.ts +0 -48
  55. package/dist/src/document/utils/index.d.ts +0 -4
  56. package/dist/src/document/utils/node.d.ts +0 -9
  57. package/dist/src/document/utils/validation.d.ts +0 -2
  58. package/dist/src/document-model/custom/reducers/header.d.ts +0 -2
  59. package/dist/src/document-model/custom/reducers/module.d.ts +0 -2
  60. package/dist/src/document-model/custom/reducers/operation-error.d.ts +0 -2
  61. package/dist/src/document-model/custom/reducers/operation-example.d.ts +0 -2
  62. package/dist/src/document-model/custom/reducers/operation.d.ts +0 -2
  63. package/dist/src/document-model/custom/reducers/state.d.ts +0 -2
  64. package/dist/src/document-model/custom/reducers/versioning.d.ts +0 -7
  65. package/dist/src/document-model/custom/utils.d.ts +0 -7
  66. package/dist/src/document-model/gen/actions.d.ts +0 -15
  67. package/dist/src/document-model/gen/creators.d.ts +0 -7
  68. package/dist/src/document-model/gen/document-model.d.ts +0 -2
  69. package/dist/src/document-model/gen/header/actions.d.ts +0 -9
  70. package/dist/src/document-model/gen/header/creators.d.ts +0 -8
  71. package/dist/src/document-model/gen/header/object.d.ts +0 -12
  72. package/dist/src/document-model/gen/header/operations.d.ts +0 -10
  73. package/dist/src/document-model/gen/index.d.ts +0 -5
  74. package/dist/src/document-model/gen/module/actions.d.ts +0 -8
  75. package/dist/src/document-model/gen/module/creators.d.ts +0 -7
  76. package/dist/src/document-model/gen/module/object.d.ts +0 -11
  77. package/dist/src/document-model/gen/module/operations.d.ts +0 -9
  78. package/dist/src/document-model/gen/object.d.ts +0 -28
  79. package/dist/src/document-model/gen/operation/actions.d.ts +0 -13
  80. package/dist/src/document-model/gen/operation/creators.d.ts +0 -12
  81. package/dist/src/document-model/gen/operation/object.d.ts +0 -16
  82. package/dist/src/document-model/gen/operation/operations.d.ts +0 -14
  83. package/dist/src/document-model/gen/operation-error/actions.d.ts +0 -10
  84. package/dist/src/document-model/gen/operation-error/creators.d.ts +0 -9
  85. package/dist/src/document-model/gen/operation-error/object.d.ts +0 -13
  86. package/dist/src/document-model/gen/operation-error/operations.d.ts +0 -11
  87. package/dist/src/document-model/gen/operation-example/actions.d.ts +0 -7
  88. package/dist/src/document-model/gen/operation-example/creators.d.ts +0 -6
  89. package/dist/src/document-model/gen/operation-example/object.d.ts +0 -10
  90. package/dist/src/document-model/gen/operation-example/operations.d.ts +0 -8
  91. package/dist/src/document-model/gen/reducer.d.ts +0 -5
  92. package/dist/src/document-model/gen/schema/index.d.ts +0 -2
  93. package/dist/src/document-model/gen/schema/types.d.ts +0 -453
  94. package/dist/src/document-model/gen/schema/zod.d.ts +0 -453
  95. package/dist/src/document-model/gen/state/actions.d.ts +0 -9
  96. package/dist/src/document-model/gen/state/creators.d.ts +0 -8
  97. package/dist/src/document-model/gen/state/object.d.ts +0 -12
  98. package/dist/src/document-model/gen/state/operations.d.ts +0 -10
  99. package/dist/src/document-model/gen/types.d.ts +0 -8
  100. package/dist/src/document-model/gen/utils.d.ts +0 -6
  101. package/dist/src/document-model/gen/versioning/actions.d.ts +0 -8
  102. package/dist/src/document-model/gen/versioning/creators.d.ts +0 -7
  103. package/dist/src/document-model/gen/versioning/object.d.ts +0 -11
  104. package/dist/src/document-model/gen/versioning/operations.d.ts +0 -9
  105. package/dist/src/document-model/index.d.ts +0 -80
  106. package/dist/src/index.d.ts +0 -25
  107. package/dist/vite.config.d.ts +0 -2
  108. package/dist/vitest.config.d.ts +0 -2
@@ -1,2504 +0,0 @@
1
- var De = Object.defineProperty;
2
- var Ce = (r, i, s) => i in r ? De(r, i, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[i] = s;
3
- var At = (r, i, s) => (Ce(r, typeof i != "symbol" ? i + "" : i, s), s);
4
- import { produce as xt, castDraft as Ut, castImmutable as Ne, freeze as Me } from "immer";
5
- import { z as v } from "zod";
6
- import ee from "jszip";
7
- const re = (r) => r != null, Re = v.any().refine((r) => re(r)), ie = v.enum(["LOAD_STATE"]), ne = v.enum(["PRUNE"]), oe = v.enum(["REDO"]), ae = v.enum(["SET_NAME"]), se = v.enum(["UNDO"]);
8
- function Le() {
9
- return v.object({
10
- __typename: v.literal("Action").optional(),
11
- type: v.string()
12
- });
13
- }
14
- function dt() {
15
- return v.literal("global").or(v.literal("local"));
16
- }
17
- function pe() {
18
- return v.union([
19
- ce(),
20
- ue(),
21
- fe(),
22
- he(),
23
- me()
24
- ]);
25
- }
26
- function ze() {
27
- return v.object({
28
- __typename: v.literal("DocumentFile").optional(),
29
- data: v.string(),
30
- extension: v.string().nullable(),
31
- fileName: v.string().nullable(),
32
- mimeType: v.string()
33
- });
34
- }
35
- function ce() {
36
- return v.object({
37
- input: v.lazy(() => Mt()),
38
- type: ie,
39
- scope: dt()
40
- });
41
- }
42
- function Mt() {
43
- return v.object({
44
- operations: v.number(),
45
- state: v.lazy(() => le())
46
- });
47
- }
48
- function le() {
49
- return v.object({
50
- data: v.unknown().nullish(),
51
- name: v.string()
52
- });
53
- }
54
- function Pe() {
55
- return v.object({
56
- __typename: v.literal("Operation").optional(),
57
- hash: v.string(),
58
- index: v.number(),
59
- timestamp: v.string().datetime(),
60
- type: v.string()
61
- });
62
- }
63
- function ue() {
64
- return v.object({
65
- input: v.lazy(() => Rt()),
66
- type: ne,
67
- scope: dt()
68
- });
69
- }
70
- function Rt() {
71
- return v.object({
72
- end: v.number().nullish(),
73
- start: v.number().nullish()
74
- });
75
- }
76
- const Lt = v.number;
77
- function fe() {
78
- return v.object({
79
- input: Lt(),
80
- type: oe,
81
- scope: dt()
82
- });
83
- }
84
- const zt = v.string;
85
- function he() {
86
- return v.object({
87
- input: zt(),
88
- type: ae,
89
- scope: v.literal("global")
90
- });
91
- }
92
- function qe() {
93
- return v.object({
94
- __typename: v.literal("SetNameOperation").optional(),
95
- hash: v.string(),
96
- index: v.number(),
97
- input: v.string(),
98
- timestamp: v.string().datetime(),
99
- type: v.string()
100
- });
101
- }
102
- const Pt = v.number;
103
- function me() {
104
- return v.object({
105
- input: Pt(),
106
- type: se,
107
- scope: dt()
108
- });
109
- }
110
- const ei = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
111
- __proto__: null,
112
- ActionSchema: Le,
113
- BaseActionSchema: pe,
114
- DocumentFileSchema: ze,
115
- LoadStateActionInputSchema: Mt,
116
- LoadStateActionSchema: ce,
117
- LoadStateActionStateInputSchema: le,
118
- Load_StateSchema: ie,
119
- OperationSchema: Pe,
120
- OperationScopeSchema: dt,
121
- PruneActionInputSchema: Rt,
122
- PruneActionSchema: ue,
123
- PruneSchema: ne,
124
- RedoActionInputSchema: Lt,
125
- RedoActionSchema: fe,
126
- RedoSchema: oe,
127
- SetNameActionInputSchema: zt,
128
- SetNameActionSchema: he,
129
- SetNameOperationSchema: qe,
130
- Set_NameSchema: ae,
131
- UndoActionInputSchema: Pt,
132
- UndoActionSchema: me,
133
- UndoSchema: se,
134
- definedNonNullAnySchema: Re,
135
- isDefinedNonNullAny: re
136
- }, Symbol.toStringTag, { value: "Module" }));
137
- function qt(r) {
138
- return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
139
- }
140
- var $t = { exports: {} };
141
- (function(r, i) {
142
- const { hasOwnProperty: s } = Object.prototype, p = C();
143
- p.configure = C, p.stringify = p, p.default = p, i.stringify = p, i.configure = C, r.exports = p;
144
- const f = /[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/;
145
- function u(y) {
146
- return y.length < 5e3 && !f.test(y) ? `"${y}"` : JSON.stringify(y);
147
- }
148
- function l(y) {
149
- if (y.length > 200)
150
- return y.sort();
151
- for (let b = 1; b < y.length; b++) {
152
- const I = y[b];
153
- let W = b;
154
- for (; W !== 0 && y[W - 1] > I; )
155
- y[W] = y[W - 1], W--;
156
- y[W] = I;
157
- }
158
- return y;
159
- }
160
- const a = Object.getOwnPropertyDescriptor(
161
- Object.getPrototypeOf(
162
- Object.getPrototypeOf(
163
- new Int8Array()
164
- )
165
- ),
166
- Symbol.toStringTag
167
- ).get;
168
- function h(y) {
169
- return a.call(y) !== void 0 && y.length !== 0;
170
- }
171
- function w(y, b, I) {
172
- y.length < I && (I = y.length);
173
- const W = b === "," ? "" : " ";
174
- let Y = `"0":${W}${y[0]}`;
175
- for (let G = 1; G < I; G++)
176
- Y += `${b}"${G}":${W}${y[G]}`;
177
- return Y;
178
- }
179
- function g(y) {
180
- if (s.call(y, "circularValue")) {
181
- const b = y.circularValue;
182
- if (typeof b == "string")
183
- return `"${b}"`;
184
- if (b == null)
185
- return b;
186
- if (b === Error || b === TypeError)
187
- return {
188
- toString() {
189
- throw new TypeError("Converting circular structure to JSON");
190
- }
191
- };
192
- throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined');
193
- }
194
- return '"[Circular]"';
195
- }
196
- function A(y, b) {
197
- let I;
198
- if (s.call(y, b) && (I = y[b], typeof I != "boolean"))
199
- throw new TypeError(`The "${b}" argument must be of type boolean`);
200
- return I === void 0 ? !0 : I;
201
- }
202
- function _(y, b) {
203
- let I;
204
- if (s.call(y, b)) {
205
- if (I = y[b], typeof I != "number")
206
- throw new TypeError(`The "${b}" argument must be of type number`);
207
- if (!Number.isInteger(I))
208
- throw new TypeError(`The "${b}" argument must be an integer`);
209
- if (I < 1)
210
- throw new RangeError(`The "${b}" argument must be >= 1`);
211
- }
212
- return I === void 0 ? 1 / 0 : I;
213
- }
214
- function F(y) {
215
- return y === 1 ? "1 item" : `${y} items`;
216
- }
217
- function U(y) {
218
- const b = /* @__PURE__ */ new Set();
219
- for (const I of y)
220
- (typeof I == "string" || typeof I == "number") && b.add(String(I));
221
- return b;
222
- }
223
- function L(y) {
224
- if (s.call(y, "strict")) {
225
- const b = y.strict;
226
- if (typeof b != "boolean")
227
- throw new TypeError('The "strict" argument must be of type boolean');
228
- if (b)
229
- return (I) => {
230
- let W = `Object can not safely be stringified. Received type ${typeof I}`;
231
- throw typeof I != "function" && (W += ` (${I.toString()})`), new Error(W);
232
- };
233
- }
234
- }
235
- function C(y) {
236
- y = { ...y };
237
- const b = L(y);
238
- b && (y.bigint === void 0 && (y.bigint = !1), "circularValue" in y || (y.circularValue = Error));
239
- const I = g(y), W = A(y, "bigint"), Y = A(y, "deterministic"), G = _(y, "maximumDepth"), R = _(y, "maximumBreadth");
240
- function ct(V, m, E, T, j, D) {
241
- let S = m[V];
242
- switch (typeof S == "object" && S !== null && typeof S.toJSON == "function" && (S = S.toJSON(V)), S = T.call(m, V, S), typeof S) {
243
- case "string":
244
- return u(S);
245
- case "object": {
246
- if (S === null)
247
- return "null";
248
- if (E.indexOf(S) !== -1)
249
- return I;
250
- let k = "", B = ",";
251
- const O = D;
252
- if (Array.isArray(S)) {
253
- if (S.length === 0)
254
- return "[]";
255
- if (G < E.length + 1)
256
- return '"[Array]"';
257
- E.push(S), j !== "" && (D += j, k += `
258
- ${D}`, B = `,
259
- ${D}`);
260
- const H = Math.min(S.length, R);
261
- let Q = 0;
262
- for (; Q < H - 1; Q++) {
263
- const st = ct(String(Q), S, E, T, j, D);
264
- k += st !== void 0 ? st : "null", k += B;
265
- }
266
- const tt = ct(String(Q), S, E, T, j, D);
267
- if (k += tt !== void 0 ? tt : "null", S.length - 1 > R) {
268
- const st = S.length - R - 1;
269
- k += `${B}"... ${F(st)} not stringified"`;
270
- }
271
- return j !== "" && (k += `
272
- ${O}`), E.pop(), `[${k}]`;
273
- }
274
- let z = Object.keys(S);
275
- const J = z.length;
276
- if (J === 0)
277
- return "{}";
278
- if (G < E.length + 1)
279
- return '"[Object]"';
280
- let N = "", K = "";
281
- j !== "" && (D += j, B = `,
282
- ${D}`, N = " ");
283
- const X = Math.min(J, R);
284
- Y && !h(S) && (z = l(z)), E.push(S);
285
- for (let H = 0; H < X; H++) {
286
- const Q = z[H], tt = ct(Q, S, E, T, j, D);
287
- tt !== void 0 && (k += `${K}${u(Q)}:${N}${tt}`, K = B);
288
- }
289
- if (J > R) {
290
- const H = J - R;
291
- k += `${K}"...":${N}"${F(H)} not stringified"`, K = B;
292
- }
293
- return j !== "" && K.length > 1 && (k = `
294
- ${D}${k}
295
- ${O}`), E.pop(), `{${k}}`;
296
- }
297
- case "number":
298
- return isFinite(S) ? String(S) : b ? b(S) : "null";
299
- case "boolean":
300
- return S === !0 ? "true" : "false";
301
- case "undefined":
302
- return;
303
- case "bigint":
304
- if (W)
305
- return String(S);
306
- default:
307
- return b ? b(S) : void 0;
308
- }
309
- }
310
- function lt(V, m, E, T, j, D) {
311
- switch (typeof m == "object" && m !== null && typeof m.toJSON == "function" && (m = m.toJSON(V)), typeof m) {
312
- case "string":
313
- return u(m);
314
- case "object": {
315
- if (m === null)
316
- return "null";
317
- if (E.indexOf(m) !== -1)
318
- return I;
319
- const S = D;
320
- let k = "", B = ",";
321
- if (Array.isArray(m)) {
322
- if (m.length === 0)
323
- return "[]";
324
- if (G < E.length + 1)
325
- return '"[Array]"';
326
- E.push(m), j !== "" && (D += j, k += `
327
- ${D}`, B = `,
328
- ${D}`);
329
- const J = Math.min(m.length, R);
330
- let N = 0;
331
- for (; N < J - 1; N++) {
332
- const X = lt(String(N), m[N], E, T, j, D);
333
- k += X !== void 0 ? X : "null", k += B;
334
- }
335
- const K = lt(String(N), m[N], E, T, j, D);
336
- if (k += K !== void 0 ? K : "null", m.length - 1 > R) {
337
- const X = m.length - R - 1;
338
- k += `${B}"... ${F(X)} not stringified"`;
339
- }
340
- return j !== "" && (k += `
341
- ${S}`), E.pop(), `[${k}]`;
342
- }
343
- E.push(m);
344
- let O = "";
345
- j !== "" && (D += j, B = `,
346
- ${D}`, O = " ");
347
- let z = "";
348
- for (const J of T) {
349
- const N = lt(J, m[J], E, T, j, D);
350
- N !== void 0 && (k += `${z}${u(J)}:${O}${N}`, z = B);
351
- }
352
- return j !== "" && z.length > 1 && (k = `
353
- ${D}${k}
354
- ${S}`), E.pop(), `{${k}}`;
355
- }
356
- case "number":
357
- return isFinite(m) ? String(m) : b ? b(m) : "null";
358
- case "boolean":
359
- return m === !0 ? "true" : "false";
360
- case "undefined":
361
- return;
362
- case "bigint":
363
- if (W)
364
- return String(m);
365
- default:
366
- return b ? b(m) : void 0;
367
- }
368
- }
369
- function ot(V, m, E, T, j) {
370
- switch (typeof m) {
371
- case "string":
372
- return u(m);
373
- case "object": {
374
- if (m === null)
375
- return "null";
376
- if (typeof m.toJSON == "function") {
377
- if (m = m.toJSON(V), typeof m != "object")
378
- return ot(V, m, E, T, j);
379
- if (m === null)
380
- return "null";
381
- }
382
- if (E.indexOf(m) !== -1)
383
- return I;
384
- const D = j;
385
- if (Array.isArray(m)) {
386
- if (m.length === 0)
387
- return "[]";
388
- if (G < E.length + 1)
389
- return '"[Array]"';
390
- E.push(m), j += T;
391
- let N = `
392
- ${j}`;
393
- const K = `,
394
- ${j}`, X = Math.min(m.length, R);
395
- let H = 0;
396
- for (; H < X - 1; H++) {
397
- const tt = ot(String(H), m[H], E, T, j);
398
- N += tt !== void 0 ? tt : "null", N += K;
399
- }
400
- const Q = ot(String(H), m[H], E, T, j);
401
- if (N += Q !== void 0 ? Q : "null", m.length - 1 > R) {
402
- const tt = m.length - R - 1;
403
- N += `${K}"... ${F(tt)} not stringified"`;
404
- }
405
- return N += `
406
- ${D}`, E.pop(), `[${N}]`;
407
- }
408
- let S = Object.keys(m);
409
- const k = S.length;
410
- if (k === 0)
411
- return "{}";
412
- if (G < E.length + 1)
413
- return '"[Object]"';
414
- j += T;
415
- const B = `,
416
- ${j}`;
417
- let O = "", z = "", J = Math.min(k, R);
418
- h(m) && (O += w(m, B, R), S = S.slice(m.length), J -= m.length, z = B), Y && (S = l(S)), E.push(m);
419
- for (let N = 0; N < J; N++) {
420
- const K = S[N], X = ot(K, m[K], E, T, j);
421
- X !== void 0 && (O += `${z}${u(K)}: ${X}`, z = B);
422
- }
423
- if (k > R) {
424
- const N = k - R;
425
- O += `${z}"...": "${F(N)} not stringified"`, z = B;
426
- }
427
- return z !== "" && (O = `
428
- ${j}${O}
429
- ${D}`), E.pop(), `{${O}}`;
430
- }
431
- case "number":
432
- return isFinite(m) ? String(m) : b ? b(m) : "null";
433
- case "boolean":
434
- return m === !0 ? "true" : "false";
435
- case "undefined":
436
- return;
437
- case "bigint":
438
- if (W)
439
- return String(m);
440
- default:
441
- return b ? b(m) : void 0;
442
- }
443
- }
444
- function at(V, m, E) {
445
- switch (typeof m) {
446
- case "string":
447
- return u(m);
448
- case "object": {
449
- if (m === null)
450
- return "null";
451
- if (typeof m.toJSON == "function") {
452
- if (m = m.toJSON(V), typeof m != "object")
453
- return at(V, m, E);
454
- if (m === null)
455
- return "null";
456
- }
457
- if (E.indexOf(m) !== -1)
458
- return I;
459
- let T = "";
460
- if (Array.isArray(m)) {
461
- if (m.length === 0)
462
- return "[]";
463
- if (G < E.length + 1)
464
- return '"[Array]"';
465
- E.push(m);
466
- const B = Math.min(m.length, R);
467
- let O = 0;
468
- for (; O < B - 1; O++) {
469
- const J = at(String(O), m[O], E);
470
- T += J !== void 0 ? J : "null", T += ",";
471
- }
472
- const z = at(String(O), m[O], E);
473
- if (T += z !== void 0 ? z : "null", m.length - 1 > R) {
474
- const J = m.length - R - 1;
475
- T += `,"... ${F(J)} not stringified"`;
476
- }
477
- return E.pop(), `[${T}]`;
478
- }
479
- let j = Object.keys(m);
480
- const D = j.length;
481
- if (D === 0)
482
- return "{}";
483
- if (G < E.length + 1)
484
- return '"[Object]"';
485
- let S = "", k = Math.min(D, R);
486
- h(m) && (T += w(m, ",", R), j = j.slice(m.length), k -= m.length, S = ","), Y && (j = l(j)), E.push(m);
487
- for (let B = 0; B < k; B++) {
488
- const O = j[B], z = at(O, m[O], E);
489
- z !== void 0 && (T += `${S}${u(O)}:${z}`, S = ",");
490
- }
491
- if (D > R) {
492
- const B = D - R;
493
- T += `${S}"...":"${F(B)} not stringified"`;
494
- }
495
- return E.pop(), `{${T}}`;
496
- }
497
- case "number":
498
- return isFinite(m) ? String(m) : b ? b(m) : "null";
499
- case "boolean":
500
- return m === !0 ? "true" : "false";
501
- case "undefined":
502
- return;
503
- case "bigint":
504
- if (W)
505
- return String(m);
506
- default:
507
- return b ? b(m) : void 0;
508
- }
509
- }
510
- function It(V, m, E) {
511
- if (arguments.length > 1) {
512
- let T = "";
513
- if (typeof E == "number" ? T = " ".repeat(Math.min(E, 10)) : typeof E == "string" && (T = E.slice(0, 10)), m != null) {
514
- if (typeof m == "function")
515
- return ct("", { "": V }, [], m, T, "");
516
- if (Array.isArray(m))
517
- return lt("", V, [], U(m), T, "");
518
- }
519
- if (T.length !== 0)
520
- return ot("", V, [], T, "");
521
- }
522
- return at("", V, []);
523
- }
524
- return It;
525
- }
526
- })($t, $t.exports);
527
- var Je = $t.exports;
528
- const St = /* @__PURE__ */ qt(Je);
529
- St.configure;
530
- function We(r, i) {
531
- return { ...r, name: i };
532
- }
533
- function Ve(r, i, s) {
534
- const p = {
535
- skip: s,
536
- document: r
537
- }, { scope: f } = i;
538
- return !f || i.skip === void 0 ? p : xt(p, (u) => {
539
- const l = u.document.operations[f].at(-1);
540
- i.skip && i.skip > 0 && (u.skip = i.skip), l && l.type === "NOOP" && i.index === l.index && u.skip > l.skip && u.document.operations[f].pop();
541
- });
542
- }
543
- function He(r, i, s) {
544
- const { scope: p, input: f } = i;
545
- return xt({
546
- document: r,
547
- action: i,
548
- skip: s
549
- }, (l) => {
550
- if (l.document.operations[p].length < 1)
551
- throw new Error(
552
- `Cannot undo: no operations in history for scope "${p}"`
553
- );
554
- if (f < 1)
555
- throw new Error(
556
- "Invalid UNDO action: input value must be greater than 0"
557
- );
558
- if (l.skip > 0)
559
- throw new Error(
560
- "Cannot undo: skip value from reducer cannot be used with UNDO action"
561
- );
562
- const a = l.document.operations[p].at(-1), h = a && a.type === "NOOP" && a.skip > 0;
563
- if (l.skip += f, h) {
564
- l.skip += a.skip;
565
- const _ = l.document.operations[p][l.document.operations[p].length - 2];
566
- _ && a.index - _.index === 1 && l.document.operations[p].pop();
567
- }
568
- if (l.document.operations[p].length < l.skip)
569
- throw new Error(
570
- "Cannot undo: you can't undo more operations than the ones in the scope history"
571
- );
572
- const w = l.document.operations[p].length - 1;
573
- let g = f, A = h ? w - a.skip : w;
574
- for (; g > 0 && A >= 0; ) {
575
- const _ = l.document.operations[p][A];
576
- if (!_) {
577
- g--, A--;
578
- continue;
579
- }
580
- _.type === "NOOP" && _.skip > 0 ? (A = A - (_.skip + 1), l.skip += _.skip + 1) : (l.document.clipboard.push({ ..._ }), g--, A--);
581
- }
582
- l.action = Zt(p);
583
- });
584
- }
585
- function Ke(r, i, s) {
586
- const { scope: p, input: f } = i;
587
- return xt({
588
- document: r,
589
- action: i,
590
- skip: s
591
- }, (l) => {
592
- if (l.skip > 0)
593
- throw new Error(
594
- "Cannot redo: skip value from reducer cannot be used with REDO action"
595
- );
596
- if (f > 1)
597
- throw new Error(
598
- "Cannot redo: you can only redo one operation at a time"
599
- );
600
- if (f < 1)
601
- throw new Error("Invalid REDO action: invalid redo input value");
602
- if (l.document.clipboard.length < 1)
603
- throw new Error("Cannot redo: no operations in the clipboard");
604
- const a = l.document.clipboard.findLastIndex(
605
- (w) => w.scope === p
606
- );
607
- if (a < 0)
608
- throw new Error(
609
- `Cannot redo: no operations in clipboard for scope "${p}"`
610
- );
611
- const h = l.document.clipboard.splice(a, 1)[0];
612
- l.action = Ut({
613
- type: h.type,
614
- scope: h.scope,
615
- input: h.input
616
- });
617
- });
618
- }
619
- function Ze(r, i, s) {
620
- const { scope: p } = i, f = r.operations[p];
621
- let {
622
- input: { start: u, end: l }
623
- } = i;
624
- u = u || 0, l = l || f.length;
625
- const a = f.slice(u, l), h = f.slice(0, u), w = f.slice(l), g = Nt(
626
- r.initialState,
627
- {
628
- ...r.operations,
629
- [p]: h.concat(a)
630
- },
631
- s
632
- ), { name: A, state: _ } = g, F = h.length, U = h.length ? h[h.length - 1].timestamp : w.length ? w[0].timestamp : (/* @__PURE__ */ new Date()).toISOString();
633
- return Nt(
634
- r.initialState,
635
- {
636
- ...r.operations,
637
- [p]: [
638
- ...h,
639
- {
640
- ...Kt(
641
- { name: A, state: _ },
642
- a.length
643
- ),
644
- timestamp: U,
645
- index: F,
646
- hash: Ht({ state: _ }, "global")
647
- },
648
- ...w.map((L, C) => ({
649
- ...L,
650
- index: F + C + 1
651
- }))
652
- ]
653
- },
654
- s
655
- );
656
- }
657
- function Ge(r, i) {
658
- return {
659
- ...r,
660
- name: i.name,
661
- state: i.state ?? { global: {}, local: {} }
662
- };
663
- }
664
- const xe = "SET_NAME", gt = "UNDO", yt = "REDO", Ft = "PRUNE", de = "LOAD_STATE", Ye = "NOOP";
665
- function Xe(r, i) {
666
- let s;
667
- return "index" in i ? s = { ...i } : s = r.operations[i.scope].at(-1), ((s == null ? void 0 : s.index) ?? -1) + 1;
668
- }
669
- function Qe(r, i) {
670
- return {
671
- ...r,
672
- revision: {
673
- ...r.revision,
674
- [i.scope]: Xe(r, i)
675
- },
676
- lastModified: (/* @__PURE__ */ new Date()).toISOString()
677
- };
678
- }
679
- function tr(r, i, s = 0) {
680
- if ([gt, yt, Ft].includes(i.type))
681
- return r;
682
- const { scope: p } = i, f = r.operations[p].slice(
683
- 0,
684
- r.revision[p]
685
- ), u = [...f].pop();
686
- let l = ((u == null ? void 0 : u.index) ?? -1) + 1;
687
- if ("index" in i) {
688
- if (i.index > l + s)
689
- throw new Error(
690
- `Missing operations: expected ${l} with skip 0 or equivalent, got index ${i.index} with skip ${s}`
691
- );
692
- l = i.index;
693
- }
694
- return f.push({
695
- ...i,
696
- index: l,
697
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
698
- hash: "",
699
- scope: p,
700
- skip: s,
701
- error: void 0
702
- }), {
703
- ...r,
704
- operations: { ...r.operations, [p]: f }
705
- };
706
- }
707
- function er(r, i, s = 0) {
708
- let p = tr(r, i, s);
709
- return p = Qe(p, i), p;
710
- }
711
- function rr(r, i, s) {
712
- switch (pe().parse(i), i.type) {
713
- case xe:
714
- return We(r, i.input);
715
- case Ft:
716
- return Ze(r, i, s);
717
- case de:
718
- return Ge(r, i.input.state);
719
- default:
720
- return r;
721
- }
722
- }
723
- function ir(r, i, s) {
724
- switch (i.type) {
725
- case gt:
726
- return He(r, i, s);
727
- case yt:
728
- return Ke(r, i, s);
729
- default:
730
- return { document: r, action: i, skip: s };
731
- }
732
- }
733
- function ge(r, i, s, p, f = {}) {
734
- const { skip: u, ignoreSkipOperations: l = !1, reuseHash: a = !1 } = f;
735
- let h = { ...i }, w = u || 0, g = r, A = [...r.clipboard];
736
- if (Mr(h)) {
737
- const { document: _, skip: F } = Ve(g, h, w);
738
- w = F, g = _;
739
- }
740
- if (Xt(h)) {
741
- const {
742
- skip: _,
743
- action: F,
744
- document: U
745
- } = ir(r, h, w);
746
- h = F, w = _, g = U, A = [...g.clipboard];
747
- }
748
- if (Qt(h) && (g = rr(g, h, s)), w > 0 && !l) {
749
- let _ = w;
750
- "index" in h && (_ = qr(
751
- g.operations[h.scope],
752
- h.index,
753
- w
754
- )), g = Nt(
755
- g.initialState,
756
- g.operations,
757
- s,
758
- void 0,
759
- void 0,
760
- void 0,
761
- { [h.scope]: _ }
762
- // TODO reuse hash?
763
- );
764
- }
765
- return g = er(g, h, w), g = xt(g, (_) => {
766
- try {
767
- const F = s(
768
- _.state,
769
- h,
770
- p
771
- ), U = Xt(i) ? [...A] : [];
772
- if (F)
773
- return Ut({
774
- ...g,
775
- clipboard: [...U],
776
- state: F
777
- });
778
- _.clipboard = Ut([...U]);
779
- } catch (F) {
780
- const U = g.operations[h.scope].length - 1;
781
- _.operations[h.scope][U].error = F.message;
782
- }
783
- }), xt(g, (_) => {
784
- if ([gt, yt, Ft].includes(h.type))
785
- return _;
786
- const F = h.scope || "global", U = a && Object.prototype.hasOwnProperty.call(h, "hash") ? h.hash : Ht(_, F);
787
- _.operations[F][_.operations[F].length - 1].hash = U, !Qt(h) && h.attachments && h.attachments.forEach((L) => {
788
- const { hash: C, ...y } = L;
789
- _.attachments[C] = {
790
- ...y
791
- };
792
- });
793
- });
794
- }
795
- var Dt = { exports: {} };
796
- typeof Object.create == "function" ? Dt.exports = function(i, s) {
797
- s && (i.super_ = s, i.prototype = Object.create(s.prototype, {
798
- constructor: {
799
- value: i,
800
- enumerable: !1,
801
- writable: !0,
802
- configurable: !0
803
- }
804
- }));
805
- } : Dt.exports = function(i, s) {
806
- if (s) {
807
- i.super_ = s;
808
- var p = function() {
809
- };
810
- p.prototype = s.prototype, i.prototype = new p(), i.prototype.constructor = i;
811
- }
812
- };
813
- var ye = Dt.exports, Ct = { exports: {} }, we = {}, Bt = {};
814
- Bt.byteLength = ar;
815
- Bt.toByteArray = pr;
816
- Bt.fromByteArray = ur;
817
- var nt = [], rt = [], nr = typeof Uint8Array < "u" ? Uint8Array : Array, kt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
818
- for (var ut = 0, or = kt.length; ut < or; ++ut)
819
- nt[ut] = kt[ut], rt[kt.charCodeAt(ut)] = ut;
820
- rt[45] = 62;
821
- rt[95] = 63;
822
- function be(r) {
823
- var i = r.length;
824
- if (i % 4 > 0)
825
- throw new Error("Invalid string. Length must be a multiple of 4");
826
- var s = r.indexOf("=");
827
- s === -1 && (s = i);
828
- var p = s === i ? 0 : 4 - s % 4;
829
- return [s, p];
830
- }
831
- function ar(r) {
832
- var i = be(r), s = i[0], p = i[1];
833
- return (s + p) * 3 / 4 - p;
834
- }
835
- function sr(r, i, s) {
836
- return (i + s) * 3 / 4 - s;
837
- }
838
- function pr(r) {
839
- var i, s = be(r), p = s[0], f = s[1], u = new nr(sr(r, p, f)), l = 0, a = f > 0 ? p - 4 : p, h;
840
- for (h = 0; h < a; h += 4)
841
- i = rt[r.charCodeAt(h)] << 18 | rt[r.charCodeAt(h + 1)] << 12 | rt[r.charCodeAt(h + 2)] << 6 | rt[r.charCodeAt(h + 3)], u[l++] = i >> 16 & 255, u[l++] = i >> 8 & 255, u[l++] = i & 255;
842
- return f === 2 && (i = rt[r.charCodeAt(h)] << 2 | rt[r.charCodeAt(h + 1)] >> 4, u[l++] = i & 255), f === 1 && (i = rt[r.charCodeAt(h)] << 10 | rt[r.charCodeAt(h + 1)] << 4 | rt[r.charCodeAt(h + 2)] >> 2, u[l++] = i >> 8 & 255, u[l++] = i & 255), u;
843
- }
844
- function cr(r) {
845
- return nt[r >> 18 & 63] + nt[r >> 12 & 63] + nt[r >> 6 & 63] + nt[r & 63];
846
- }
847
- function lr(r, i, s) {
848
- for (var p, f = [], u = i; u < s; u += 3)
849
- p = (r[u] << 16 & 16711680) + (r[u + 1] << 8 & 65280) + (r[u + 2] & 255), f.push(cr(p));
850
- return f.join("");
851
- }
852
- function ur(r) {
853
- for (var i, s = r.length, p = s % 3, f = [], u = 16383, l = 0, a = s - p; l < a; l += u)
854
- f.push(lr(r, l, l + u > a ? a : l + u));
855
- return p === 1 ? (i = r[s - 1], f.push(
856
- nt[i >> 2] + nt[i << 4 & 63] + "=="
857
- )) : p === 2 && (i = (r[s - 2] << 8) + r[s - 1], f.push(
858
- nt[i >> 10] + nt[i >> 4 & 63] + nt[i << 2 & 63] + "="
859
- )), f.join("");
860
- }
861
- var Jt = {};
862
- /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
863
- Jt.read = function(r, i, s, p, f) {
864
- var u, l, a = f * 8 - p - 1, h = (1 << a) - 1, w = h >> 1, g = -7, A = s ? f - 1 : 0, _ = s ? -1 : 1, F = r[i + A];
865
- for (A += _, u = F & (1 << -g) - 1, F >>= -g, g += a; g > 0; u = u * 256 + r[i + A], A += _, g -= 8)
866
- ;
867
- for (l = u & (1 << -g) - 1, u >>= -g, g += p; g > 0; l = l * 256 + r[i + A], A += _, g -= 8)
868
- ;
869
- if (u === 0)
870
- u = 1 - w;
871
- else {
872
- if (u === h)
873
- return l ? NaN : (F ? -1 : 1) * (1 / 0);
874
- l = l + Math.pow(2, p), u = u - w;
875
- }
876
- return (F ? -1 : 1) * l * Math.pow(2, u - p);
877
- };
878
- Jt.write = function(r, i, s, p, f, u) {
879
- var l, a, h, w = u * 8 - f - 1, g = (1 << w) - 1, A = g >> 1, _ = f === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, F = p ? 0 : u - 1, U = p ? 1 : -1, L = i < 0 || i === 0 && 1 / i < 0 ? 1 : 0;
880
- for (i = Math.abs(i), isNaN(i) || i === 1 / 0 ? (a = isNaN(i) ? 1 : 0, l = g) : (l = Math.floor(Math.log(i) / Math.LN2), i * (h = Math.pow(2, -l)) < 1 && (l--, h *= 2), l + A >= 1 ? i += _ / h : i += _ * Math.pow(2, 1 - A), i * h >= 2 && (l++, h /= 2), l + A >= g ? (a = 0, l = g) : l + A >= 1 ? (a = (i * h - 1) * Math.pow(2, f), l = l + A) : (a = i * Math.pow(2, A - 1) * Math.pow(2, f), l = 0)); f >= 8; r[s + F] = a & 255, F += U, a /= 256, f -= 8)
881
- ;
882
- for (l = l << f | a, w += f; w > 0; r[s + F] = l & 255, F += U, l /= 256, w -= 8)
883
- ;
884
- r[s + F - U] |= L * 128;
885
- };
886
- /*!
887
- * The buffer module from node.js, for the browser.
888
- *
889
- * @author Feross Aboukhadijeh <https://feross.org>
890
- * @license MIT
891
- */
892
- (function(r) {
893
- var i = Bt, s = Jt, p = typeof Symbol == "function" && typeof Symbol.for == "function" ? Symbol.for("nodejs.util.inspect.custom") : null;
894
- r.Buffer = a, r.SlowBuffer = b, r.INSPECT_MAX_BYTES = 50;
895
- var f = 2147483647;
896
- r.kMaxLength = f, a.TYPED_ARRAY_SUPPORT = u(), !a.TYPED_ARRAY_SUPPORT && typeof console < "u" && typeof console.error == "function" && console.error(
897
- "This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."
898
- );
899
- function u() {
900
- try {
901
- var n = new Uint8Array(1), t = { foo: function() {
902
- return 42;
903
- } };
904
- return Object.setPrototypeOf(t, Uint8Array.prototype), Object.setPrototypeOf(n, t), n.foo() === 42;
905
- } catch {
906
- return !1;
907
- }
908
- }
909
- Object.defineProperty(a.prototype, "parent", {
910
- enumerable: !0,
911
- get: function() {
912
- if (a.isBuffer(this))
913
- return this.buffer;
914
- }
915
- }), Object.defineProperty(a.prototype, "offset", {
916
- enumerable: !0,
917
- get: function() {
918
- if (a.isBuffer(this))
919
- return this.byteOffset;
920
- }
921
- });
922
- function l(n) {
923
- if (n > f)
924
- throw new RangeError('The value "' + n + '" is invalid for option "size"');
925
- var t = new Uint8Array(n);
926
- return Object.setPrototypeOf(t, a.prototype), t;
927
- }
928
- function a(n, t, e) {
929
- if (typeof n == "number") {
930
- if (typeof t == "string")
931
- throw new TypeError(
932
- 'The "string" argument must be of type string. Received type number'
933
- );
934
- return A(n);
935
- }
936
- return h(n, t, e);
937
- }
938
- a.poolSize = 8192;
939
- function h(n, t, e) {
940
- if (typeof n == "string")
941
- return _(n, t);
942
- if (ArrayBuffer.isView(n))
943
- return U(n);
944
- if (n == null)
945
- throw new TypeError(
946
- "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof n
947
- );
948
- if (it(n, ArrayBuffer) || n && it(n.buffer, ArrayBuffer) || typeof SharedArrayBuffer < "u" && (it(n, SharedArrayBuffer) || n && it(n.buffer, SharedArrayBuffer)))
949
- return L(n, t, e);
950
- if (typeof n == "number")
951
- throw new TypeError(
952
- 'The "value" argument must not be of type number. Received type number'
953
- );
954
- var o = n.valueOf && n.valueOf();
955
- if (o != null && o !== n)
956
- return a.from(o, t, e);
957
- var c = C(n);
958
- if (c)
959
- return c;
960
- if (typeof Symbol < "u" && Symbol.toPrimitive != null && typeof n[Symbol.toPrimitive] == "function")
961
- return a.from(
962
- n[Symbol.toPrimitive]("string"),
963
- t,
964
- e
965
- );
966
- throw new TypeError(
967
- "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof n
968
- );
969
- }
970
- a.from = function(n, t, e) {
971
- return h(n, t, e);
972
- }, Object.setPrototypeOf(a.prototype, Uint8Array.prototype), Object.setPrototypeOf(a, Uint8Array);
973
- function w(n) {
974
- if (typeof n != "number")
975
- throw new TypeError('"size" argument must be of type number');
976
- if (n < 0)
977
- throw new RangeError('The value "' + n + '" is invalid for option "size"');
978
- }
979
- function g(n, t, e) {
980
- return w(n), n <= 0 ? l(n) : t !== void 0 ? typeof e == "string" ? l(n).fill(t, e) : l(n).fill(t) : l(n);
981
- }
982
- a.alloc = function(n, t, e) {
983
- return g(n, t, e);
984
- };
985
- function A(n) {
986
- return w(n), l(n < 0 ? 0 : y(n) | 0);
987
- }
988
- a.allocUnsafe = function(n) {
989
- return A(n);
990
- }, a.allocUnsafeSlow = function(n) {
991
- return A(n);
992
- };
993
- function _(n, t) {
994
- if ((typeof t != "string" || t === "") && (t = "utf8"), !a.isEncoding(t))
995
- throw new TypeError("Unknown encoding: " + t);
996
- var e = I(n, t) | 0, o = l(e), c = o.write(n, t);
997
- return c !== e && (o = o.slice(0, c)), o;
998
- }
999
- function F(n) {
1000
- for (var t = n.length < 0 ? 0 : y(n.length) | 0, e = l(t), o = 0; o < t; o += 1)
1001
- e[o] = n[o] & 255;
1002
- return e;
1003
- }
1004
- function U(n) {
1005
- if (it(n, Uint8Array)) {
1006
- var t = new Uint8Array(n);
1007
- return L(t.buffer, t.byteOffset, t.byteLength);
1008
- }
1009
- return F(n);
1010
- }
1011
- function L(n, t, e) {
1012
- if (t < 0 || n.byteLength < t)
1013
- throw new RangeError('"offset" is outside of buffer bounds');
1014
- if (n.byteLength < t + (e || 0))
1015
- throw new RangeError('"length" is outside of buffer bounds');
1016
- var o;
1017
- return t === void 0 && e === void 0 ? o = new Uint8Array(n) : e === void 0 ? o = new Uint8Array(n, t) : o = new Uint8Array(n, t, e), Object.setPrototypeOf(o, a.prototype), o;
1018
- }
1019
- function C(n) {
1020
- if (a.isBuffer(n)) {
1021
- var t = y(n.length) | 0, e = l(t);
1022
- return e.length === 0 || n.copy(e, 0, 0, t), e;
1023
- }
1024
- if (n.length !== void 0)
1025
- return typeof n.length != "number" || Tt(n.length) ? l(0) : F(n);
1026
- if (n.type === "Buffer" && Array.isArray(n.data))
1027
- return F(n.data);
1028
- }
1029
- function y(n) {
1030
- if (n >= f)
1031
- throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + f.toString(16) + " bytes");
1032
- return n | 0;
1033
- }
1034
- function b(n) {
1035
- return +n != n && (n = 0), a.alloc(+n);
1036
- }
1037
- a.isBuffer = function(t) {
1038
- return t != null && t._isBuffer === !0 && t !== a.prototype;
1039
- }, a.compare = function(t, e) {
1040
- if (it(t, Uint8Array) && (t = a.from(t, t.offset, t.byteLength)), it(e, Uint8Array) && (e = a.from(e, e.offset, e.byteLength)), !a.isBuffer(t) || !a.isBuffer(e))
1041
- throw new TypeError(
1042
- 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
1043
- );
1044
- if (t === e)
1045
- return 0;
1046
- for (var o = t.length, c = e.length, x = 0, d = Math.min(o, c); x < d; ++x)
1047
- if (t[x] !== e[x]) {
1048
- o = t[x], c = e[x];
1049
- break;
1050
- }
1051
- return o < c ? -1 : c < o ? 1 : 0;
1052
- }, a.isEncoding = function(t) {
1053
- switch (String(t).toLowerCase()) {
1054
- case "hex":
1055
- case "utf8":
1056
- case "utf-8":
1057
- case "ascii":
1058
- case "latin1":
1059
- case "binary":
1060
- case "base64":
1061
- case "ucs2":
1062
- case "ucs-2":
1063
- case "utf16le":
1064
- case "utf-16le":
1065
- return !0;
1066
- default:
1067
- return !1;
1068
- }
1069
- }, a.concat = function(t, e) {
1070
- if (!Array.isArray(t))
1071
- throw new TypeError('"list" argument must be an Array of Buffers');
1072
- if (t.length === 0)
1073
- return a.alloc(0);
1074
- var o;
1075
- if (e === void 0)
1076
- for (e = 0, o = 0; o < t.length; ++o)
1077
- e += t[o].length;
1078
- var c = a.allocUnsafe(e), x = 0;
1079
- for (o = 0; o < t.length; ++o) {
1080
- var d = t[o];
1081
- if (it(d, Uint8Array))
1082
- x + d.length > c.length ? a.from(d).copy(c, x) : Uint8Array.prototype.set.call(
1083
- c,
1084
- d,
1085
- x
1086
- );
1087
- else if (a.isBuffer(d))
1088
- d.copy(c, x);
1089
- else
1090
- throw new TypeError('"list" argument must be an Array of Buffers');
1091
- x += d.length;
1092
- }
1093
- return c;
1094
- };
1095
- function I(n, t) {
1096
- if (a.isBuffer(n))
1097
- return n.length;
1098
- if (ArrayBuffer.isView(n) || it(n, ArrayBuffer))
1099
- return n.byteLength;
1100
- if (typeof n != "string")
1101
- throw new TypeError(
1102
- 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof n
1103
- );
1104
- var e = n.length, o = arguments.length > 2 && arguments[2] === !0;
1105
- if (!o && e === 0)
1106
- return 0;
1107
- for (var c = !1; ; )
1108
- switch (t) {
1109
- case "ascii":
1110
- case "latin1":
1111
- case "binary":
1112
- return e;
1113
- case "utf8":
1114
- case "utf-8":
1115
- return H(n).length;
1116
- case "ucs2":
1117
- case "ucs-2":
1118
- case "utf16le":
1119
- case "utf-16le":
1120
- return e * 2;
1121
- case "hex":
1122
- return e >>> 1;
1123
- case "base64":
1124
- return st(n).length;
1125
- default:
1126
- if (c)
1127
- return o ? -1 : H(n).length;
1128
- t = ("" + t).toLowerCase(), c = !0;
1129
- }
1130
- }
1131
- a.byteLength = I;
1132
- function W(n, t, e) {
1133
- var o = !1;
1134
- if ((t === void 0 || t < 0) && (t = 0), t > this.length || ((e === void 0 || e > this.length) && (e = this.length), e <= 0) || (e >>>= 0, t >>>= 0, e <= t))
1135
- return "";
1136
- for (n || (n = "utf8"); ; )
1137
- switch (n) {
1138
- case "hex":
1139
- return S(this, t, e);
1140
- case "utf8":
1141
- case "utf-8":
1142
- return m(this, t, e);
1143
- case "ascii":
1144
- return j(this, t, e);
1145
- case "latin1":
1146
- case "binary":
1147
- return D(this, t, e);
1148
- case "base64":
1149
- return V(this, t, e);
1150
- case "ucs2":
1151
- case "ucs-2":
1152
- case "utf16le":
1153
- case "utf-16le":
1154
- return k(this, t, e);
1155
- default:
1156
- if (o)
1157
- throw new TypeError("Unknown encoding: " + n);
1158
- n = (n + "").toLowerCase(), o = !0;
1159
- }
1160
- }
1161
- a.prototype._isBuffer = !0;
1162
- function Y(n, t, e) {
1163
- var o = n[t];
1164
- n[t] = n[e], n[e] = o;
1165
- }
1166
- a.prototype.swap16 = function() {
1167
- var t = this.length;
1168
- if (t % 2 !== 0)
1169
- throw new RangeError("Buffer size must be a multiple of 16-bits");
1170
- for (var e = 0; e < t; e += 2)
1171
- Y(this, e, e + 1);
1172
- return this;
1173
- }, a.prototype.swap32 = function() {
1174
- var t = this.length;
1175
- if (t % 4 !== 0)
1176
- throw new RangeError("Buffer size must be a multiple of 32-bits");
1177
- for (var e = 0; e < t; e += 4)
1178
- Y(this, e, e + 3), Y(this, e + 1, e + 2);
1179
- return this;
1180
- }, a.prototype.swap64 = function() {
1181
- var t = this.length;
1182
- if (t % 8 !== 0)
1183
- throw new RangeError("Buffer size must be a multiple of 64-bits");
1184
- for (var e = 0; e < t; e += 8)
1185
- Y(this, e, e + 7), Y(this, e + 1, e + 6), Y(this, e + 2, e + 5), Y(this, e + 3, e + 4);
1186
- return this;
1187
- }, a.prototype.toString = function() {
1188
- var t = this.length;
1189
- return t === 0 ? "" : arguments.length === 0 ? m(this, 0, t) : W.apply(this, arguments);
1190
- }, a.prototype.toLocaleString = a.prototype.toString, a.prototype.equals = function(t) {
1191
- if (!a.isBuffer(t))
1192
- throw new TypeError("Argument must be a Buffer");
1193
- return this === t ? !0 : a.compare(this, t) === 0;
1194
- }, a.prototype.inspect = function() {
1195
- var t = "", e = r.INSPECT_MAX_BYTES;
1196
- return t = this.toString("hex", 0, e).replace(/(.{2})/g, "$1 ").trim(), this.length > e && (t += " ... "), "<Buffer " + t + ">";
1197
- }, p && (a.prototype[p] = a.prototype.inspect), a.prototype.compare = function(t, e, o, c, x) {
1198
- if (it(t, Uint8Array) && (t = a.from(t, t.offset, t.byteLength)), !a.isBuffer(t))
1199
- throw new TypeError(
1200
- 'The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof t
1201
- );
1202
- if (e === void 0 && (e = 0), o === void 0 && (o = t ? t.length : 0), c === void 0 && (c = 0), x === void 0 && (x = this.length), e < 0 || o > t.length || c < 0 || x > this.length)
1203
- throw new RangeError("out of range index");
1204
- if (c >= x && e >= o)
1205
- return 0;
1206
- if (c >= x)
1207
- return -1;
1208
- if (e >= o)
1209
- return 1;
1210
- if (e >>>= 0, o >>>= 0, c >>>= 0, x >>>= 0, this === t)
1211
- return 0;
1212
- for (var d = x - c, $ = o - e, M = Math.min(d, $), P = this.slice(c, x), Z = t.slice(e, o), q = 0; q < M; ++q)
1213
- if (P[q] !== Z[q]) {
1214
- d = P[q], $ = Z[q];
1215
- break;
1216
- }
1217
- return d < $ ? -1 : $ < d ? 1 : 0;
1218
- };
1219
- function G(n, t, e, o, c) {
1220
- if (n.length === 0)
1221
- return -1;
1222
- if (typeof e == "string" ? (o = e, e = 0) : e > 2147483647 ? e = 2147483647 : e < -2147483648 && (e = -2147483648), e = +e, Tt(e) && (e = c ? 0 : n.length - 1), e < 0 && (e = n.length + e), e >= n.length) {
1223
- if (c)
1224
- return -1;
1225
- e = n.length - 1;
1226
- } else if (e < 0)
1227
- if (c)
1228
- e = 0;
1229
- else
1230
- return -1;
1231
- if (typeof t == "string" && (t = a.from(t, o)), a.isBuffer(t))
1232
- return t.length === 0 ? -1 : R(n, t, e, o, c);
1233
- if (typeof t == "number")
1234
- return t = t & 255, typeof Uint8Array.prototype.indexOf == "function" ? c ? Uint8Array.prototype.indexOf.call(n, t, e) : Uint8Array.prototype.lastIndexOf.call(n, t, e) : R(n, [t], e, o, c);
1235
- throw new TypeError("val must be string, number or Buffer");
1236
- }
1237
- function R(n, t, e, o, c) {
1238
- var x = 1, d = n.length, $ = t.length;
1239
- if (o !== void 0 && (o = String(o).toLowerCase(), o === "ucs2" || o === "ucs-2" || o === "utf16le" || o === "utf-16le")) {
1240
- if (n.length < 2 || t.length < 2)
1241
- return -1;
1242
- x = 2, d /= 2, $ /= 2, e /= 2;
1243
- }
1244
- function M(Gt, Yt) {
1245
- return x === 1 ? Gt[Yt] : Gt.readUInt16BE(Yt * x);
1246
- }
1247
- var P;
1248
- if (c) {
1249
- var Z = -1;
1250
- for (P = e; P < d; P++)
1251
- if (M(n, P) === M(t, Z === -1 ? 0 : P - Z)) {
1252
- if (Z === -1 && (Z = P), P - Z + 1 === $)
1253
- return Z * x;
1254
- } else
1255
- Z !== -1 && (P -= P - Z), Z = -1;
1256
- } else
1257
- for (e + $ > d && (e = d - $), P = e; P >= 0; P--) {
1258
- for (var q = !0, vt = 0; vt < $; vt++)
1259
- if (M(n, P + vt) !== M(t, vt)) {
1260
- q = !1;
1261
- break;
1262
- }
1263
- if (q)
1264
- return P;
1265
- }
1266
- return -1;
1267
- }
1268
- a.prototype.includes = function(t, e, o) {
1269
- return this.indexOf(t, e, o) !== -1;
1270
- }, a.prototype.indexOf = function(t, e, o) {
1271
- return G(this, t, e, o, !0);
1272
- }, a.prototype.lastIndexOf = function(t, e, o) {
1273
- return G(this, t, e, o, !1);
1274
- };
1275
- function ct(n, t, e, o) {
1276
- e = Number(e) || 0;
1277
- var c = n.length - e;
1278
- o ? (o = Number(o), o > c && (o = c)) : o = c;
1279
- var x = t.length;
1280
- o > x / 2 && (o = x / 2);
1281
- for (var d = 0; d < o; ++d) {
1282
- var $ = parseInt(t.substr(d * 2, 2), 16);
1283
- if (Tt($))
1284
- return d;
1285
- n[e + d] = $;
1286
- }
1287
- return d;
1288
- }
1289
- function lt(n, t, e, o) {
1290
- return Et(H(t, n.length - e), n, e, o);
1291
- }
1292
- function ot(n, t, e, o) {
1293
- return Et(Q(t), n, e, o);
1294
- }
1295
- function at(n, t, e, o) {
1296
- return Et(st(t), n, e, o);
1297
- }
1298
- function It(n, t, e, o) {
1299
- return Et(tt(t, n.length - e), n, e, o);
1300
- }
1301
- a.prototype.write = function(t, e, o, c) {
1302
- if (e === void 0)
1303
- c = "utf8", o = this.length, e = 0;
1304
- else if (o === void 0 && typeof e == "string")
1305
- c = e, o = this.length, e = 0;
1306
- else if (isFinite(e))
1307
- e = e >>> 0, isFinite(o) ? (o = o >>> 0, c === void 0 && (c = "utf8")) : (c = o, o = void 0);
1308
- else
1309
- throw new Error(
1310
- "Buffer.write(string, encoding, offset[, length]) is no longer supported"
1311
- );
1312
- var x = this.length - e;
1313
- if ((o === void 0 || o > x) && (o = x), t.length > 0 && (o < 0 || e < 0) || e > this.length)
1314
- throw new RangeError("Attempt to write outside buffer bounds");
1315
- c || (c = "utf8");
1316
- for (var d = !1; ; )
1317
- switch (c) {
1318
- case "hex":
1319
- return ct(this, t, e, o);
1320
- case "utf8":
1321
- case "utf-8":
1322
- return lt(this, t, e, o);
1323
- case "ascii":
1324
- case "latin1":
1325
- case "binary":
1326
- return ot(this, t, e, o);
1327
- case "base64":
1328
- return at(this, t, e, o);
1329
- case "ucs2":
1330
- case "ucs-2":
1331
- case "utf16le":
1332
- case "utf-16le":
1333
- return It(this, t, e, o);
1334
- default:
1335
- if (d)
1336
- throw new TypeError("Unknown encoding: " + c);
1337
- c = ("" + c).toLowerCase(), d = !0;
1338
- }
1339
- }, a.prototype.toJSON = function() {
1340
- return {
1341
- type: "Buffer",
1342
- data: Array.prototype.slice.call(this._arr || this, 0)
1343
- };
1344
- };
1345
- function V(n, t, e) {
1346
- return t === 0 && e === n.length ? i.fromByteArray(n) : i.fromByteArray(n.slice(t, e));
1347
- }
1348
- function m(n, t, e) {
1349
- e = Math.min(n.length, e);
1350
- for (var o = [], c = t; c < e; ) {
1351
- var x = n[c], d = null, $ = x > 239 ? 4 : x > 223 ? 3 : x > 191 ? 2 : 1;
1352
- if (c + $ <= e) {
1353
- var M, P, Z, q;
1354
- switch ($) {
1355
- case 1:
1356
- x < 128 && (d = x);
1357
- break;
1358
- case 2:
1359
- M = n[c + 1], (M & 192) === 128 && (q = (x & 31) << 6 | M & 63, q > 127 && (d = q));
1360
- break;
1361
- case 3:
1362
- M = n[c + 1], P = n[c + 2], (M & 192) === 128 && (P & 192) === 128 && (q = (x & 15) << 12 | (M & 63) << 6 | P & 63, q > 2047 && (q < 55296 || q > 57343) && (d = q));
1363
- break;
1364
- case 4:
1365
- M = n[c + 1], P = n[c + 2], Z = n[c + 3], (M & 192) === 128 && (P & 192) === 128 && (Z & 192) === 128 && (q = (x & 15) << 18 | (M & 63) << 12 | (P & 63) << 6 | Z & 63, q > 65535 && q < 1114112 && (d = q));
1366
- }
1367
- }
1368
- d === null ? (d = 65533, $ = 1) : d > 65535 && (d -= 65536, o.push(d >>> 10 & 1023 | 55296), d = 56320 | d & 1023), o.push(d), c += $;
1369
- }
1370
- return T(o);
1371
- }
1372
- var E = 4096;
1373
- function T(n) {
1374
- var t = n.length;
1375
- if (t <= E)
1376
- return String.fromCharCode.apply(String, n);
1377
- for (var e = "", o = 0; o < t; )
1378
- e += String.fromCharCode.apply(
1379
- String,
1380
- n.slice(o, o += E)
1381
- );
1382
- return e;
1383
- }
1384
- function j(n, t, e) {
1385
- var o = "";
1386
- e = Math.min(n.length, e);
1387
- for (var c = t; c < e; ++c)
1388
- o += String.fromCharCode(n[c] & 127);
1389
- return o;
1390
- }
1391
- function D(n, t, e) {
1392
- var o = "";
1393
- e = Math.min(n.length, e);
1394
- for (var c = t; c < e; ++c)
1395
- o += String.fromCharCode(n[c]);
1396
- return o;
1397
- }
1398
- function S(n, t, e) {
1399
- var o = n.length;
1400
- (!t || t < 0) && (t = 0), (!e || e < 0 || e > o) && (e = o);
1401
- for (var c = "", x = t; x < e; ++x)
1402
- c += $e[n[x]];
1403
- return c;
1404
- }
1405
- function k(n, t, e) {
1406
- for (var o = n.slice(t, e), c = "", x = 0; x < o.length - 1; x += 2)
1407
- c += String.fromCharCode(o[x] + o[x + 1] * 256);
1408
- return c;
1409
- }
1410
- a.prototype.slice = function(t, e) {
1411
- var o = this.length;
1412
- t = ~~t, e = e === void 0 ? o : ~~e, t < 0 ? (t += o, t < 0 && (t = 0)) : t > o && (t = o), e < 0 ? (e += o, e < 0 && (e = 0)) : e > o && (e = o), e < t && (e = t);
1413
- var c = this.subarray(t, e);
1414
- return Object.setPrototypeOf(c, a.prototype), c;
1415
- };
1416
- function B(n, t, e) {
1417
- if (n % 1 !== 0 || n < 0)
1418
- throw new RangeError("offset is not uint");
1419
- if (n + t > e)
1420
- throw new RangeError("Trying to access beyond buffer length");
1421
- }
1422
- a.prototype.readUintLE = a.prototype.readUIntLE = function(t, e, o) {
1423
- t = t >>> 0, e = e >>> 0, o || B(t, e, this.length);
1424
- for (var c = this[t], x = 1, d = 0; ++d < e && (x *= 256); )
1425
- c += this[t + d] * x;
1426
- return c;
1427
- }, a.prototype.readUintBE = a.prototype.readUIntBE = function(t, e, o) {
1428
- t = t >>> 0, e = e >>> 0, o || B(t, e, this.length);
1429
- for (var c = this[t + --e], x = 1; e > 0 && (x *= 256); )
1430
- c += this[t + --e] * x;
1431
- return c;
1432
- }, a.prototype.readUint8 = a.prototype.readUInt8 = function(t, e) {
1433
- return t = t >>> 0, e || B(t, 1, this.length), this[t];
1434
- }, a.prototype.readUint16LE = a.prototype.readUInt16LE = function(t, e) {
1435
- return t = t >>> 0, e || B(t, 2, this.length), this[t] | this[t + 1] << 8;
1436
- }, a.prototype.readUint16BE = a.prototype.readUInt16BE = function(t, e) {
1437
- return t = t >>> 0, e || B(t, 2, this.length), this[t] << 8 | this[t + 1];
1438
- }, a.prototype.readUint32LE = a.prototype.readUInt32LE = function(t, e) {
1439
- return t = t >>> 0, e || B(t, 4, this.length), (this[t] | this[t + 1] << 8 | this[t + 2] << 16) + this[t + 3] * 16777216;
1440
- }, a.prototype.readUint32BE = a.prototype.readUInt32BE = function(t, e) {
1441
- return t = t >>> 0, e || B(t, 4, this.length), this[t] * 16777216 + (this[t + 1] << 16 | this[t + 2] << 8 | this[t + 3]);
1442
- }, a.prototype.readIntLE = function(t, e, o) {
1443
- t = t >>> 0, e = e >>> 0, o || B(t, e, this.length);
1444
- for (var c = this[t], x = 1, d = 0; ++d < e && (x *= 256); )
1445
- c += this[t + d] * x;
1446
- return x *= 128, c >= x && (c -= Math.pow(2, 8 * e)), c;
1447
- }, a.prototype.readIntBE = function(t, e, o) {
1448
- t = t >>> 0, e = e >>> 0, o || B(t, e, this.length);
1449
- for (var c = e, x = 1, d = this[t + --c]; c > 0 && (x *= 256); )
1450
- d += this[t + --c] * x;
1451
- return x *= 128, d >= x && (d -= Math.pow(2, 8 * e)), d;
1452
- }, a.prototype.readInt8 = function(t, e) {
1453
- return t = t >>> 0, e || B(t, 1, this.length), this[t] & 128 ? (255 - this[t] + 1) * -1 : this[t];
1454
- }, a.prototype.readInt16LE = function(t, e) {
1455
- t = t >>> 0, e || B(t, 2, this.length);
1456
- var o = this[t] | this[t + 1] << 8;
1457
- return o & 32768 ? o | 4294901760 : o;
1458
- }, a.prototype.readInt16BE = function(t, e) {
1459
- t = t >>> 0, e || B(t, 2, this.length);
1460
- var o = this[t + 1] | this[t] << 8;
1461
- return o & 32768 ? o | 4294901760 : o;
1462
- }, a.prototype.readInt32LE = function(t, e) {
1463
- return t = t >>> 0, e || B(t, 4, this.length), this[t] | this[t + 1] << 8 | this[t + 2] << 16 | this[t + 3] << 24;
1464
- }, a.prototype.readInt32BE = function(t, e) {
1465
- return t = t >>> 0, e || B(t, 4, this.length), this[t] << 24 | this[t + 1] << 16 | this[t + 2] << 8 | this[t + 3];
1466
- }, a.prototype.readFloatLE = function(t, e) {
1467
- return t = t >>> 0, e || B(t, 4, this.length), s.read(this, t, !0, 23, 4);
1468
- }, a.prototype.readFloatBE = function(t, e) {
1469
- return t = t >>> 0, e || B(t, 4, this.length), s.read(this, t, !1, 23, 4);
1470
- }, a.prototype.readDoubleLE = function(t, e) {
1471
- return t = t >>> 0, e || B(t, 8, this.length), s.read(this, t, !0, 52, 8);
1472
- }, a.prototype.readDoubleBE = function(t, e) {
1473
- return t = t >>> 0, e || B(t, 8, this.length), s.read(this, t, !1, 52, 8);
1474
- };
1475
- function O(n, t, e, o, c, x) {
1476
- if (!a.isBuffer(n))
1477
- throw new TypeError('"buffer" argument must be a Buffer instance');
1478
- if (t > c || t < x)
1479
- throw new RangeError('"value" argument is out of bounds');
1480
- if (e + o > n.length)
1481
- throw new RangeError("Index out of range");
1482
- }
1483
- a.prototype.writeUintLE = a.prototype.writeUIntLE = function(t, e, o, c) {
1484
- if (t = +t, e = e >>> 0, o = o >>> 0, !c) {
1485
- var x = Math.pow(2, 8 * o) - 1;
1486
- O(this, t, e, o, x, 0);
1487
- }
1488
- var d = 1, $ = 0;
1489
- for (this[e] = t & 255; ++$ < o && (d *= 256); )
1490
- this[e + $] = t / d & 255;
1491
- return e + o;
1492
- }, a.prototype.writeUintBE = a.prototype.writeUIntBE = function(t, e, o, c) {
1493
- if (t = +t, e = e >>> 0, o = o >>> 0, !c) {
1494
- var x = Math.pow(2, 8 * o) - 1;
1495
- O(this, t, e, o, x, 0);
1496
- }
1497
- var d = o - 1, $ = 1;
1498
- for (this[e + d] = t & 255; --d >= 0 && ($ *= 256); )
1499
- this[e + d] = t / $ & 255;
1500
- return e + o;
1501
- }, a.prototype.writeUint8 = a.prototype.writeUInt8 = function(t, e, o) {
1502
- return t = +t, e = e >>> 0, o || O(this, t, e, 1, 255, 0), this[e] = t & 255, e + 1;
1503
- }, a.prototype.writeUint16LE = a.prototype.writeUInt16LE = function(t, e, o) {
1504
- return t = +t, e = e >>> 0, o || O(this, t, e, 2, 65535, 0), this[e] = t & 255, this[e + 1] = t >>> 8, e + 2;
1505
- }, a.prototype.writeUint16BE = a.prototype.writeUInt16BE = function(t, e, o) {
1506
- return t = +t, e = e >>> 0, o || O(this, t, e, 2, 65535, 0), this[e] = t >>> 8, this[e + 1] = t & 255, e + 2;
1507
- }, a.prototype.writeUint32LE = a.prototype.writeUInt32LE = function(t, e, o) {
1508
- return t = +t, e = e >>> 0, o || O(this, t, e, 4, 4294967295, 0), this[e + 3] = t >>> 24, this[e + 2] = t >>> 16, this[e + 1] = t >>> 8, this[e] = t & 255, e + 4;
1509
- }, a.prototype.writeUint32BE = a.prototype.writeUInt32BE = function(t, e, o) {
1510
- return t = +t, e = e >>> 0, o || O(this, t, e, 4, 4294967295, 0), this[e] = t >>> 24, this[e + 1] = t >>> 16, this[e + 2] = t >>> 8, this[e + 3] = t & 255, e + 4;
1511
- }, a.prototype.writeIntLE = function(t, e, o, c) {
1512
- if (t = +t, e = e >>> 0, !c) {
1513
- var x = Math.pow(2, 8 * o - 1);
1514
- O(this, t, e, o, x - 1, -x);
1515
- }
1516
- var d = 0, $ = 1, M = 0;
1517
- for (this[e] = t & 255; ++d < o && ($ *= 256); )
1518
- t < 0 && M === 0 && this[e + d - 1] !== 0 && (M = 1), this[e + d] = (t / $ >> 0) - M & 255;
1519
- return e + o;
1520
- }, a.prototype.writeIntBE = function(t, e, o, c) {
1521
- if (t = +t, e = e >>> 0, !c) {
1522
- var x = Math.pow(2, 8 * o - 1);
1523
- O(this, t, e, o, x - 1, -x);
1524
- }
1525
- var d = o - 1, $ = 1, M = 0;
1526
- for (this[e + d] = t & 255; --d >= 0 && ($ *= 256); )
1527
- t < 0 && M === 0 && this[e + d + 1] !== 0 && (M = 1), this[e + d] = (t / $ >> 0) - M & 255;
1528
- return e + o;
1529
- }, a.prototype.writeInt8 = function(t, e, o) {
1530
- return t = +t, e = e >>> 0, o || O(this, t, e, 1, 127, -128), t < 0 && (t = 255 + t + 1), this[e] = t & 255, e + 1;
1531
- }, a.prototype.writeInt16LE = function(t, e, o) {
1532
- return t = +t, e = e >>> 0, o || O(this, t, e, 2, 32767, -32768), this[e] = t & 255, this[e + 1] = t >>> 8, e + 2;
1533
- }, a.prototype.writeInt16BE = function(t, e, o) {
1534
- return t = +t, e = e >>> 0, o || O(this, t, e, 2, 32767, -32768), this[e] = t >>> 8, this[e + 1] = t & 255, e + 2;
1535
- }, a.prototype.writeInt32LE = function(t, e, o) {
1536
- return t = +t, e = e >>> 0, o || O(this, t, e, 4, 2147483647, -2147483648), this[e] = t & 255, this[e + 1] = t >>> 8, this[e + 2] = t >>> 16, this[e + 3] = t >>> 24, e + 4;
1537
- }, a.prototype.writeInt32BE = function(t, e, o) {
1538
- return t = +t, e = e >>> 0, o || O(this, t, e, 4, 2147483647, -2147483648), t < 0 && (t = 4294967295 + t + 1), this[e] = t >>> 24, this[e + 1] = t >>> 16, this[e + 2] = t >>> 8, this[e + 3] = t & 255, e + 4;
1539
- };
1540
- function z(n, t, e, o, c, x) {
1541
- if (e + o > n.length)
1542
- throw new RangeError("Index out of range");
1543
- if (e < 0)
1544
- throw new RangeError("Index out of range");
1545
- }
1546
- function J(n, t, e, o, c) {
1547
- return t = +t, e = e >>> 0, c || z(n, t, e, 4), s.write(n, t, e, o, 23, 4), e + 4;
1548
- }
1549
- a.prototype.writeFloatLE = function(t, e, o) {
1550
- return J(this, t, e, !0, o);
1551
- }, a.prototype.writeFloatBE = function(t, e, o) {
1552
- return J(this, t, e, !1, o);
1553
- };
1554
- function N(n, t, e, o, c) {
1555
- return t = +t, e = e >>> 0, c || z(n, t, e, 8), s.write(n, t, e, o, 52, 8), e + 8;
1556
- }
1557
- a.prototype.writeDoubleLE = function(t, e, o) {
1558
- return N(this, t, e, !0, o);
1559
- }, a.prototype.writeDoubleBE = function(t, e, o) {
1560
- return N(this, t, e, !1, o);
1561
- }, a.prototype.copy = function(t, e, o, c) {
1562
- if (!a.isBuffer(t))
1563
- throw new TypeError("argument should be a Buffer");
1564
- if (o || (o = 0), !c && c !== 0 && (c = this.length), e >= t.length && (e = t.length), e || (e = 0), c > 0 && c < o && (c = o), c === o || t.length === 0 || this.length === 0)
1565
- return 0;
1566
- if (e < 0)
1567
- throw new RangeError("targetStart out of bounds");
1568
- if (o < 0 || o >= this.length)
1569
- throw new RangeError("Index out of range");
1570
- if (c < 0)
1571
- throw new RangeError("sourceEnd out of bounds");
1572
- c > this.length && (c = this.length), t.length - e < c - o && (c = t.length - e + o);
1573
- var x = c - o;
1574
- return this === t && typeof Uint8Array.prototype.copyWithin == "function" ? this.copyWithin(e, o, c) : Uint8Array.prototype.set.call(
1575
- t,
1576
- this.subarray(o, c),
1577
- e
1578
- ), x;
1579
- }, a.prototype.fill = function(t, e, o, c) {
1580
- if (typeof t == "string") {
1581
- if (typeof e == "string" ? (c = e, e = 0, o = this.length) : typeof o == "string" && (c = o, o = this.length), c !== void 0 && typeof c != "string")
1582
- throw new TypeError("encoding must be a string");
1583
- if (typeof c == "string" && !a.isEncoding(c))
1584
- throw new TypeError("Unknown encoding: " + c);
1585
- if (t.length === 1) {
1586
- var x = t.charCodeAt(0);
1587
- (c === "utf8" && x < 128 || c === "latin1") && (t = x);
1588
- }
1589
- } else
1590
- typeof t == "number" ? t = t & 255 : typeof t == "boolean" && (t = Number(t));
1591
- if (e < 0 || this.length < e || this.length < o)
1592
- throw new RangeError("Out of range index");
1593
- if (o <= e)
1594
- return this;
1595
- e = e >>> 0, o = o === void 0 ? this.length : o >>> 0, t || (t = 0);
1596
- var d;
1597
- if (typeof t == "number")
1598
- for (d = e; d < o; ++d)
1599
- this[d] = t;
1600
- else {
1601
- var $ = a.isBuffer(t) ? t : a.from(t, c), M = $.length;
1602
- if (M === 0)
1603
- throw new TypeError('The value "' + t + '" is invalid for argument "value"');
1604
- for (d = 0; d < o - e; ++d)
1605
- this[d + e] = $[d % M];
1606
- }
1607
- return this;
1608
- };
1609
- var K = /[^+/0-9A-Za-z-_]/g;
1610
- function X(n) {
1611
- if (n = n.split("=")[0], n = n.trim().replace(K, ""), n.length < 2)
1612
- return "";
1613
- for (; n.length % 4 !== 0; )
1614
- n = n + "=";
1615
- return n;
1616
- }
1617
- function H(n, t) {
1618
- t = t || 1 / 0;
1619
- for (var e, o = n.length, c = null, x = [], d = 0; d < o; ++d) {
1620
- if (e = n.charCodeAt(d), e > 55295 && e < 57344) {
1621
- if (!c) {
1622
- if (e > 56319) {
1623
- (t -= 3) > -1 && x.push(239, 191, 189);
1624
- continue;
1625
- } else if (d + 1 === o) {
1626
- (t -= 3) > -1 && x.push(239, 191, 189);
1627
- continue;
1628
- }
1629
- c = e;
1630
- continue;
1631
- }
1632
- if (e < 56320) {
1633
- (t -= 3) > -1 && x.push(239, 191, 189), c = e;
1634
- continue;
1635
- }
1636
- e = (c - 55296 << 10 | e - 56320) + 65536;
1637
- } else
1638
- c && (t -= 3) > -1 && x.push(239, 191, 189);
1639
- if (c = null, e < 128) {
1640
- if ((t -= 1) < 0)
1641
- break;
1642
- x.push(e);
1643
- } else if (e < 2048) {
1644
- if ((t -= 2) < 0)
1645
- break;
1646
- x.push(
1647
- e >> 6 | 192,
1648
- e & 63 | 128
1649
- );
1650
- } else if (e < 65536) {
1651
- if ((t -= 3) < 0)
1652
- break;
1653
- x.push(
1654
- e >> 12 | 224,
1655
- e >> 6 & 63 | 128,
1656
- e & 63 | 128
1657
- );
1658
- } else if (e < 1114112) {
1659
- if ((t -= 4) < 0)
1660
- break;
1661
- x.push(
1662
- e >> 18 | 240,
1663
- e >> 12 & 63 | 128,
1664
- e >> 6 & 63 | 128,
1665
- e & 63 | 128
1666
- );
1667
- } else
1668
- throw new Error("Invalid code point");
1669
- }
1670
- return x;
1671
- }
1672
- function Q(n) {
1673
- for (var t = [], e = 0; e < n.length; ++e)
1674
- t.push(n.charCodeAt(e) & 255);
1675
- return t;
1676
- }
1677
- function tt(n, t) {
1678
- for (var e, o, c, x = [], d = 0; d < n.length && !((t -= 2) < 0); ++d)
1679
- e = n.charCodeAt(d), o = e >> 8, c = e % 256, x.push(c), x.push(o);
1680
- return x;
1681
- }
1682
- function st(n) {
1683
- return i.toByteArray(X(n));
1684
- }
1685
- function Et(n, t, e, o) {
1686
- for (var c = 0; c < o && !(c + e >= t.length || c >= n.length); ++c)
1687
- t[c + e] = n[c];
1688
- return c;
1689
- }
1690
- function it(n, t) {
1691
- return n instanceof t || n != null && n.constructor != null && n.constructor.name != null && n.constructor.name === t.name;
1692
- }
1693
- function Tt(n) {
1694
- return n !== n;
1695
- }
1696
- var $e = function() {
1697
- for (var n = "0123456789abcdef", t = new Array(256), e = 0; e < 16; ++e)
1698
- for (var o = e * 16, c = 0; c < 16; ++c)
1699
- t[o + c] = n[e] + n[c];
1700
- return t;
1701
- }();
1702
- })(we);
1703
- /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
1704
- (function(r, i) {
1705
- var s = we, p = s.Buffer;
1706
- function f(l, a) {
1707
- for (var h in l)
1708
- a[h] = l[h];
1709
- }
1710
- p.from && p.alloc && p.allocUnsafe && p.allocUnsafeSlow ? r.exports = s : (f(s, i), i.Buffer = u);
1711
- function u(l, a, h) {
1712
- return p(l, a, h);
1713
- }
1714
- u.prototype = Object.create(p.prototype), f(p, u), u.from = function(l, a, h) {
1715
- if (typeof l == "number")
1716
- throw new TypeError("Argument must not be a number");
1717
- return p(l, a, h);
1718
- }, u.alloc = function(l, a, h) {
1719
- if (typeof l != "number")
1720
- throw new TypeError("Argument must be a number");
1721
- var w = p(l);
1722
- return a !== void 0 ? typeof h == "string" ? w.fill(a, h) : w.fill(a) : w.fill(0), w;
1723
- }, u.allocUnsafe = function(l) {
1724
- if (typeof l != "number")
1725
- throw new TypeError("Argument must be a number");
1726
- return p(l);
1727
- }, u.allocUnsafeSlow = function(l) {
1728
- if (typeof l != "number")
1729
- throw new TypeError("Argument must be a number");
1730
- return s.SlowBuffer(l);
1731
- };
1732
- })(Ct, Ct.exports);
1733
- var Wt = Ct.exports, Ee = Wt.Buffer;
1734
- function jt(r, i) {
1735
- this._block = Ee.alloc(r), this._finalSize = i, this._blockSize = r, this._len = 0;
1736
- }
1737
- jt.prototype.update = function(r, i) {
1738
- typeof r == "string" && (i = i || "utf8", r = Ee.from(r, i));
1739
- for (var s = this._block, p = this._blockSize, f = r.length, u = this._len, l = 0; l < f; ) {
1740
- for (var a = u % p, h = Math.min(f - l, p - a), w = 0; w < h; w++)
1741
- s[a + w] = r[l + w];
1742
- u += h, l += h, u % p === 0 && this._update(s);
1743
- }
1744
- return this._len += f, this;
1745
- };
1746
- jt.prototype.digest = function(r) {
1747
- var i = this._len % this._blockSize;
1748
- this._block[i] = 128, this._block.fill(0, i + 1), i >= this._finalSize && (this._update(this._block), this._block.fill(0));
1749
- var s = this._len * 8;
1750
- if (s <= 4294967295)
1751
- this._block.writeUInt32BE(s, this._blockSize - 4);
1752
- else {
1753
- var p = (s & 4294967295) >>> 0, f = (s - p) / 4294967296;
1754
- this._block.writeUInt32BE(f, this._blockSize - 8), this._block.writeUInt32BE(p, this._blockSize - 4);
1755
- }
1756
- this._update(this._block);
1757
- var u = this._hash();
1758
- return r ? u.toString(r) : u;
1759
- };
1760
- jt.prototype._update = function() {
1761
- throw new Error("_update must be implemented by subclass");
1762
- };
1763
- var ve = jt, fr = ye, Ae = ve, hr = Wt.Buffer, mr = [
1764
- 1518500249,
1765
- 1859775393,
1766
- -1894007588,
1767
- -899497514
1768
- ], xr = new Array(80);
1769
- function wt() {
1770
- this.init(), this._w = xr, Ae.call(this, 64, 56);
1771
- }
1772
- fr(wt, Ae);
1773
- wt.prototype.init = function() {
1774
- return this._a = 1732584193, this._b = 4023233417, this._c = 2562383102, this._d = 271733878, this._e = 3285377520, this;
1775
- };
1776
- function dr(r) {
1777
- return r << 1 | r >>> 31;
1778
- }
1779
- function gr(r) {
1780
- return r << 5 | r >>> 27;
1781
- }
1782
- function yr(r) {
1783
- return r << 30 | r >>> 2;
1784
- }
1785
- function wr(r, i, s, p) {
1786
- return r === 0 ? i & s | ~i & p : r === 2 ? i & s | i & p | s & p : i ^ s ^ p;
1787
- }
1788
- wt.prototype._update = function(r) {
1789
- for (var i = this._w, s = this._a | 0, p = this._b | 0, f = this._c | 0, u = this._d | 0, l = this._e | 0, a = 0; a < 16; ++a)
1790
- i[a] = r.readInt32BE(a * 4);
1791
- for (; a < 80; ++a)
1792
- i[a] = dr(i[a - 3] ^ i[a - 8] ^ i[a - 14] ^ i[a - 16]);
1793
- for (var h = 0; h < 80; ++h) {
1794
- var w = ~~(h / 20), g = gr(s) + wr(w, p, f, u) + l + i[h] + mr[w] | 0;
1795
- l = u, u = f, f = yr(p), p = s, s = g;
1796
- }
1797
- this._a = s + this._a | 0, this._b = p + this._b | 0, this._c = f + this._c | 0, this._d = u + this._d | 0, this._e = l + this._e | 0;
1798
- };
1799
- wt.prototype._hash = function() {
1800
- var r = hr.allocUnsafe(20);
1801
- return r.writeInt32BE(this._a | 0, 0), r.writeInt32BE(this._b | 0, 4), r.writeInt32BE(this._c | 0, 8), r.writeInt32BE(this._d | 0, 12), r.writeInt32BE(this._e | 0, 16), r;
1802
- };
1803
- var br = wt;
1804
- const Er = /* @__PURE__ */ qt(br);
1805
- var vr = ye, _e = ve, Ar = Wt.Buffer, _r = [
1806
- 1116352408,
1807
- 1899447441,
1808
- 3049323471,
1809
- 3921009573,
1810
- 961987163,
1811
- 1508970993,
1812
- 2453635748,
1813
- 2870763221,
1814
- 3624381080,
1815
- 310598401,
1816
- 607225278,
1817
- 1426881987,
1818
- 1925078388,
1819
- 2162078206,
1820
- 2614888103,
1821
- 3248222580,
1822
- 3835390401,
1823
- 4022224774,
1824
- 264347078,
1825
- 604807628,
1826
- 770255983,
1827
- 1249150122,
1828
- 1555081692,
1829
- 1996064986,
1830
- 2554220882,
1831
- 2821834349,
1832
- 2952996808,
1833
- 3210313671,
1834
- 3336571891,
1835
- 3584528711,
1836
- 113926993,
1837
- 338241895,
1838
- 666307205,
1839
- 773529912,
1840
- 1294757372,
1841
- 1396182291,
1842
- 1695183700,
1843
- 1986661051,
1844
- 2177026350,
1845
- 2456956037,
1846
- 2730485921,
1847
- 2820302411,
1848
- 3259730800,
1849
- 3345764771,
1850
- 3516065817,
1851
- 3600352804,
1852
- 4094571909,
1853
- 275423344,
1854
- 430227734,
1855
- 506948616,
1856
- 659060556,
1857
- 883997877,
1858
- 958139571,
1859
- 1322822218,
1860
- 1537002063,
1861
- 1747873779,
1862
- 1955562222,
1863
- 2024104815,
1864
- 2227730452,
1865
- 2361852424,
1866
- 2428436474,
1867
- 2756734187,
1868
- 3204031479,
1869
- 3329325298
1870
- ], Sr = new Array(64);
1871
- function bt() {
1872
- this.init(), this._w = Sr, _e.call(this, 64, 56);
1873
- }
1874
- vr(bt, _e);
1875
- bt.prototype.init = function() {
1876
- return this._a = 1779033703, this._b = 3144134277, this._c = 1013904242, this._d = 2773480762, this._e = 1359893119, this._f = 2600822924, this._g = 528734635, this._h = 1541459225, this;
1877
- };
1878
- function Fr(r, i, s) {
1879
- return s ^ r & (i ^ s);
1880
- }
1881
- function Br(r, i, s) {
1882
- return r & i | s & (r | i);
1883
- }
1884
- function jr(r) {
1885
- return (r >>> 2 | r << 30) ^ (r >>> 13 | r << 19) ^ (r >>> 22 | r << 10);
1886
- }
1887
- function Or(r) {
1888
- return (r >>> 6 | r << 26) ^ (r >>> 11 | r << 21) ^ (r >>> 25 | r << 7);
1889
- }
1890
- function Ir(r) {
1891
- return (r >>> 7 | r << 25) ^ (r >>> 18 | r << 14) ^ r >>> 3;
1892
- }
1893
- function Tr(r) {
1894
- return (r >>> 17 | r << 15) ^ (r >>> 19 | r << 13) ^ r >>> 10;
1895
- }
1896
- bt.prototype._update = function(r) {
1897
- for (var i = this._w, s = this._a | 0, p = this._b | 0, f = this._c | 0, u = this._d | 0, l = this._e | 0, a = this._f | 0, h = this._g | 0, w = this._h | 0, g = 0; g < 16; ++g)
1898
- i[g] = r.readInt32BE(g * 4);
1899
- for (; g < 64; ++g)
1900
- i[g] = Tr(i[g - 2]) + i[g - 7] + Ir(i[g - 15]) + i[g - 16] | 0;
1901
- for (var A = 0; A < 64; ++A) {
1902
- var _ = w + Or(l) + Fr(l, a, h) + _r[A] + i[A] | 0, F = jr(s) + Br(s, p, f) | 0;
1903
- w = h, h = a, a = l, l = u + _ | 0, u = f, f = p, p = s, s = _ + F | 0;
1904
- }
1905
- this._a = s + this._a | 0, this._b = p + this._b | 0, this._c = f + this._c | 0, this._d = u + this._d | 0, this._e = l + this._e | 0, this._f = a + this._f | 0, this._g = h + this._g | 0, this._h = w + this._h | 0;
1906
- };
1907
- bt.prototype._hash = function() {
1908
- var r = Ar.allocUnsafe(32);
1909
- return r.writeInt32BE(this._a, 0), r.writeInt32BE(this._b, 4), r.writeInt32BE(this._c, 8), r.writeInt32BE(this._d, 12), r.writeInt32BE(this._e, 16), r.writeInt32BE(this._f, 20), r.writeInt32BE(this._g, 24), r.writeInt32BE(this._h, 28), r;
1910
- };
1911
- var kr = bt;
1912
- const Ur = /* @__PURE__ */ qt(kr), Vt = new Error("File system not available.");
1913
- function $r(r, i, s) {
1914
- throw Vt;
1915
- }
1916
- function Se(r) {
1917
- throw Vt;
1918
- }
1919
- function Dr(r) {
1920
- throw Vt;
1921
- }
1922
- const Cr = async (r) => Se(), Nr = {
1923
- sha1: Er,
1924
- sha256: Ur
1925
- }, Ot = (r, i = "sha1") => {
1926
- if (!["sha1", "sha256"].includes(i))
1927
- throw new Error("Hashing algorithm not supported: Available: sha1, sha256");
1928
- const s = Nr[i];
1929
- return new s().update(r).digest("base64");
1930
- };
1931
- function Mr(r) {
1932
- return r.type === Ye && r.skip !== void 0 && r.skip > 0 && r.hash !== void 0;
1933
- }
1934
- function Xt(r) {
1935
- return [gt, yt].includes(r.type);
1936
- }
1937
- function Qt(r) {
1938
- return [xe, gt, yt, Ft, de].includes(r.type);
1939
- }
1940
- function ht(r, i, s, p, f = "global") {
1941
- if (!r)
1942
- throw new Error("Empty action type");
1943
- if (typeof r != "string")
1944
- throw new Error(`Invalid action type: ${JSON.stringify(r)}`);
1945
- const u = { type: r, input: i, scope: f };
1946
- s && (u.attachments = s);
1947
- try {
1948
- p == null || p().parse(u.input);
1949
- } catch (l) {
1950
- throw new Error(`Invalid action input: ${l}`);
1951
- }
1952
- return u;
1953
- }
1954
- function Rr(r, i = ge) {
1955
- return (s, p, f, u) => i(s, p, r, f, u);
1956
- }
1957
- const Lr = (r, i) => ({
1958
- name: "",
1959
- documentType: "",
1960
- revision: {
1961
- global: 0,
1962
- local: 0
1963
- },
1964
- created: (/* @__PURE__ */ new Date()).toISOString(),
1965
- lastModified: (/* @__PURE__ */ new Date()).toISOString(),
1966
- attachments: {},
1967
- ...r,
1968
- state: (i == null ? void 0 : i(r == null ? void 0 : r.state)) ?? (r == null ? void 0 : r.state) ?? { global: {}, local: {} }
1969
- }), zr = (r, i) => {
1970
- const s = Lr(
1971
- r,
1972
- i
1973
- );
1974
- return {
1975
- ...s,
1976
- initialState: s,
1977
- operations: { global: [], local: [] },
1978
- clipboard: []
1979
- };
1980
- }, Ht = (r, i = "global") => Ot(St(r.state[i] || "")), ri = (r, i = 1e3) => {
1981
- const s = Math.random() * i;
1982
- return Ot(`${(r ?? /* @__PURE__ */ new Date()).toISOString()}${s}`);
1983
- };
1984
- function _t(r) {
1985
- return Ne(Me(r, !0));
1986
- }
1987
- function Pr(r, i) {
1988
- const s = [...r];
1989
- let p = i || 0, f = s.length > 0 ? s[s.length - 1].index : 0;
1990
- const u = [];
1991
- for (const l of s.reverse()) {
1992
- if (p > 0) {
1993
- const w = f - l.index;
1994
- p -= w;
1995
- }
1996
- if (p < 0)
1997
- throw new Error("Invalid operation index, missing operations");
1998
- const a = {
1999
- ignore: p > 0,
2000
- operation: l
2001
- }, h = l.skip > 0 ? l.skip + 1 : 0;
2002
- if (h > 0 && h > p) {
2003
- const w = h - p;
2004
- p = p + w;
2005
- }
2006
- f = l.index, u.push(a);
2007
- }
2008
- return u.reverse();
2009
- }
2010
- function qr(r, i, s) {
2011
- const p = r.slice().sort((a, h) => a.skip - h.skip).sort((a, h) => a.index - h.index);
2012
- let f = s, u = 0, l = i;
2013
- for (const a of p.reverse()) {
2014
- const h = l - a.index;
2015
- if (f = f - h, f > -1)
2016
- u++, l = a.index;
2017
- else
2018
- break;
2019
- }
2020
- return u;
2021
- }
2022
- function ii(r) {
2023
- return Object.values(r).flatMap((i) => i).sort(
2024
- (i, s) => new Date(i.timestamp).getTime() - new Date(s.timestamp).getTime()
2025
- );
2026
- }
2027
- function Jr(r) {
2028
- return Object.values(r).flatMap((i) => i).sort(
2029
- (i, s) => new Date(i.operation.timestamp).getTime() - new Date(s.operation.timestamp).getTime()
2030
- );
2031
- }
2032
- function Nt(r, i, s, p, f, u = ge, l = {}, a) {
2033
- const h = Rr(s, u);
2034
- return Fe(
2035
- r,
2036
- i,
2037
- h,
2038
- p,
2039
- f,
2040
- l,
2041
- a
2042
- );
2043
- }
2044
- function Fe(r, i, s, p, f, u = {}, l) {
2045
- const a = (l == null ? void 0 : l.checkHashes) ?? !0, h = zr(r), w = Object.keys(i).reduce((U, L) => {
2046
- const C = L;
2047
- return {
2048
- ...U,
2049
- [C]: Pr(
2050
- i[C],
2051
- u[C]
2052
- )
2053
- };
2054
- }, {}), g = Jr(w), A = g.reduce(
2055
- (U, { ignore: L, operation: C }) => L ? s(U, Zt(C.scope), p, {
2056
- skip: C.skip,
2057
- ignoreSkipOperations: !0
2058
- // TODO: reuse hash?
2059
- }) : s(U, C, p, {
2060
- skip: C.skip,
2061
- ignoreSkipOperations: !0,
2062
- reuseHash: !a
2063
- }),
2064
- h
2065
- );
2066
- if (!a)
2067
- for (const U of Object.keys(A.state))
2068
- for (let L = g.length - 1; L >= 0; L--) {
2069
- const { ignore: C, operation: y } = g[L];
2070
- if (!(C || y.scope !== U)) {
2071
- if (y.hash !== Ht(A, U))
2072
- throw new Error(`Hash mismatch for scope ${U}`);
2073
- break;
2074
- }
2075
- }
2076
- const _ = Object.keys(
2077
- A.operations
2078
- ).reduce(
2079
- (U, L) => {
2080
- const C = L;
2081
- return {
2082
- ...U,
2083
- [C]: [
2084
- ...A.operations[C].map((y, b) => {
2085
- var I;
2086
- return {
2087
- ...y,
2088
- timestamp: ((I = i[C][b]) == null ? void 0 : I.timestamp) ?? y.timestamp
2089
- };
2090
- })
2091
- ]
2092
- };
2093
- },
2094
- { global: [], local: [] }
2095
- ), F = Object.values(_).reduce((U, L) => {
2096
- const C = L[L.length - 1];
2097
- return (C == null ? void 0 : C.timestamp) > U && (U = C.timestamp), U;
2098
- }, r.lastModified);
2099
- return { ...A, operations: _, lastModified: F };
2100
- }
2101
- function ni(r, i) {
2102
- return St(r) === St(i);
2103
- }
2104
- const Be = (r) => ht(
2105
- "SET_NAME",
2106
- r,
2107
- void 0,
2108
- zt,
2109
- void 0
2110
- ), je = (r = 1, i = "global") => ht(
2111
- "UNDO",
2112
- r,
2113
- void 0,
2114
- Pt,
2115
- i
2116
- ), Oe = (r = 1, i = "global") => ht(
2117
- "REDO",
2118
- r,
2119
- void 0,
2120
- Lt,
2121
- i
2122
- ), Ie = (r, i, s = "global") => ht(
2123
- "PRUNE",
2124
- { start: r, end: i },
2125
- void 0,
2126
- Rt,
2127
- s
2128
- ), Kt = (r, i) => ht(
2129
- "LOAD_STATE",
2130
- { state: r, operations: i },
2131
- void 0,
2132
- Mt
2133
- ), Zt = (r = "global") => ht("NOOP", {}, void 0, void 0, r), oi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2134
- __proto__: null,
2135
- loadState: Kt,
2136
- noop: Zt,
2137
- prune: Ie,
2138
- redo: Oe,
2139
- setName: Be,
2140
- undo: je
2141
- }, Symbol.toStringTag, { value: "Module" })), Te = { "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"] };
2142
- Object.freeze(Te);
2143
- var et = function(r, i, s, p) {
2144
- if (s === "a" && !p)
2145
- throw new TypeError("Private accessor was defined without a getter");
2146
- if (typeof i == "function" ? r !== i || !p : !i.has(r))
2147
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
2148
- return s === "m" ? p : s === "a" ? p.call(r) : p ? p.value : i.get(r);
2149
- }, ft, mt, pt;
2150
- class Wr {
2151
- constructor(...i) {
2152
- ft.set(this, /* @__PURE__ */ new Map()), mt.set(this, /* @__PURE__ */ new Map()), pt.set(this, /* @__PURE__ */ new Map());
2153
- for (const s of i)
2154
- this.define(s);
2155
- }
2156
- define(i, s = !1) {
2157
- for (let [p, f] of Object.entries(i)) {
2158
- p = p.toLowerCase(), f = f.map((a) => a.toLowerCase()), et(this, pt, "f").has(p) || et(this, pt, "f").set(p, /* @__PURE__ */ new Set());
2159
- const u = et(this, pt, "f").get(p);
2160
- let l = !0;
2161
- for (let a of f) {
2162
- const h = a.startsWith("*");
2163
- if (a = h ? a.slice(1) : a, u == null || u.add(a), l && et(this, mt, "f").set(p, a), l = !1, h)
2164
- continue;
2165
- const w = et(this, ft, "f").get(a);
2166
- if (w && w != p && !s)
2167
- throw new Error(`"${p} -> ${a}" conflicts with "${w} -> ${a}". Pass \`force=true\` to override this definition.`);
2168
- et(this, ft, "f").set(a, p);
2169
- }
2170
- }
2171
- return this;
2172
- }
2173
- getType(i) {
2174
- if (typeof i != "string")
2175
- return null;
2176
- const s = i.replace(/^.*[/\\]/, "").toLowerCase(), p = s.replace(/^.*\./, "").toLowerCase(), f = s.length < i.length;
2177
- return !(p.length < s.length - 1) && f ? null : et(this, ft, "f").get(p) ?? null;
2178
- }
2179
- getExtension(i) {
2180
- var s;
2181
- return typeof i != "string" ? null : (i = (s = i == null ? void 0 : i.split) == null ? void 0 : s.call(i, ";")[0], (i && et(this, mt, "f").get(i.trim().toLowerCase())) ?? null);
2182
- }
2183
- getAllExtensions(i) {
2184
- return typeof i != "string" ? null : et(this, pt, "f").get(i.toLowerCase()) ?? null;
2185
- }
2186
- _freeze() {
2187
- this.define = () => {
2188
- throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances");
2189
- }, Object.freeze(this);
2190
- for (const i of et(this, pt, "f").values())
2191
- Object.freeze(i);
2192
- return this;
2193
- }
2194
- _getTestState() {
2195
- return {
2196
- types: et(this, ft, "f"),
2197
- extensions: et(this, mt, "f")
2198
- };
2199
- }
2200
- }
2201
- ft = /* @__PURE__ */ new WeakMap(), mt = /* @__PURE__ */ new WeakMap(), pt = /* @__PURE__ */ new WeakMap();
2202
- const Vr = new Wr(Te)._freeze();
2203
- function Hr(r) {
2204
- const i = [], s = Object.keys(r);
2205
- for (const p of s) {
2206
- const f = r[p].sort((u, l) => u.index - l.index);
2207
- for (let u = 0; u < f.length; u++)
2208
- f[u].index !== u && i.push({
2209
- message: `Invalid operation index ${f[u].index} at position ${u}`,
2210
- details: {
2211
- position: u,
2212
- operation: f[u],
2213
- scope: f[u].scope
2214
- }
2215
- });
2216
- }
2217
- return i;
2218
- }
2219
- const ke = async (r) => {
2220
- const i = new ee(), { name: s, revision: p, documentType: f, created: u, lastModified: l } = r, a = {
2221
- name: s,
2222
- revision: p,
2223
- documentType: f,
2224
- created: u,
2225
- lastModified: l
2226
- };
2227
- return i.file("header.json", JSON.stringify(a, null, 2)), i.file(
2228
- "state.json",
2229
- JSON.stringify(r.initialState || {}, null, 2)
2230
- ), i.file("operations.json", JSON.stringify(r.operations, null, 2)), Object.keys(r.attachments).forEach((w) => {
2231
- const { data: g, ...A } = r.attachments[w];
2232
- i.file(w, g, {
2233
- base64: !0,
2234
- createFolders: !0,
2235
- comment: JSON.stringify(A)
2236
- });
2237
- }), i;
2238
- }, Kr = async (r, i, s, p) => {
2239
- await (await ke(r)).generateAsync({
2240
- type: "uint8array",
2241
- streamFiles: !0
2242
- });
2243
- const u = p ?? r.name, l = `.${s}.zip`;
2244
- return $r(
2245
- i,
2246
- u.endsWith(l) ? u : `${u}${l}`
2247
- );
2248
- }, ai = async (r, i) => {
2249
- const p = await (await ke(r)).generateAsync({ type: "blob" }), f = await i.createWritable();
2250
- await f.write(p), await f.close();
2251
- }, te = async (r, i, s) => {
2252
- const p = Se();
2253
- return Zr(p, i, s);
2254
- }, Zr = async (r, i, s) => {
2255
- const p = new ee();
2256
- return await p.loadAsync(r), Gr(p, i, s);
2257
- };
2258
- async function Gr(r, i, s) {
2259
- const p = r.file("state.json");
2260
- if (!p)
2261
- throw new Error("Initial state not found");
2262
- const f = await p.async("string"), u = JSON.parse(f), l = r.file("header.json");
2263
- let a;
2264
- l && (a = JSON.parse(await l.async("string")));
2265
- const h = r.file("operations.json");
2266
- if (!h)
2267
- throw new Error("Operations history not found");
2268
- const w = JSON.parse(
2269
- await h.async("string")
2270
- ), g = Hr(w);
2271
- if (g.length) {
2272
- const _ = g.map((F) => F.message);
2273
- throw new Error(_.join(`
2274
- `));
2275
- }
2276
- let A = Fe(
2277
- u,
2278
- w,
2279
- i,
2280
- void 0,
2281
- a,
2282
- {},
2283
- s
2284
- );
2285
- return a && (A = {
2286
- ...A,
2287
- ...a
2288
- }), A;
2289
- }
2290
- function Ue(r) {
2291
- const i = r.replace(/^.*\./, "") || void 0, s = r.replace(/^.*[/\\]/, "") || void 0;
2292
- return { extension: i, fileName: s };
2293
- }
2294
- async function si(r) {
2295
- const { buffer: i, mimeType: s = "application/octet-stream" } = await Dr(), p = Ue(r), f = i.toString("base64");
2296
- return {
2297
- data: f,
2298
- hash: Ot(f),
2299
- mimeType: s,
2300
- ...p
2301
- };
2302
- }
2303
- async function pi(r) {
2304
- const i = await Cr(), s = Vr.getType(r) || "application/octet-stream", p = Ue(r), f = i.toString("base64");
2305
- return { data: f, hash: Ot(f), mimeType: s, ...p };
2306
- }
2307
- class ci {
2308
- /**
2309
- * Constructs a BaseDocument instance with an initial state.
2310
- * @param reducer - The reducer function that updates the state.
2311
- * @param document - The initial state of the document.
2312
- */
2313
- constructor(i, s, p) {
2314
- At(this, "_document");
2315
- At(this, "_reducer");
2316
- At(this, "_signalDispatch");
2317
- this._reducer = i, this._document = s, this._signalDispatch = p;
2318
- }
2319
- /**
2320
- * Dispatches an action to update the state of the document.
2321
- * @param action - The action to dispatch.
2322
- * @returns The Document instance.
2323
- */
2324
- dispatch(i, s) {
2325
- return this._document = this._reducer(
2326
- this._document,
2327
- i,
2328
- this._signalDispatch,
2329
- s
2330
- ), this;
2331
- }
2332
- /**
2333
- * Saves the state of the document to a file.
2334
- * @param path - The file path where the state should be saved.
2335
- * @param extension - The file extension to use when saving the state.
2336
- * @returns The file path where the state was saved.
2337
- */
2338
- saveToFile(i, s, p) {
2339
- return Kr(this._document, i, s, p);
2340
- }
2341
- /**
2342
- * Loads the state of the document from a file.
2343
- * @param path - The file path where the state is stored.
2344
- */
2345
- async loadFromFile(i) {
2346
- this._document = await te(i, this._reducer);
2347
- }
2348
- /**
2349
- * Loads the state of the document from a file and returns it.
2350
- * @param path - The file path where the state is stored.
2351
- * @param reducer - The reducer function that updates the state.
2352
- * @returns The state of the document.
2353
- */
2354
- static async stateFromFile(i, s) {
2355
- return await te(i, s);
2356
- }
2357
- /**
2358
- * Gets the current state of the document.
2359
- */
2360
- get state() {
2361
- return _t(this._document.state);
2362
- }
2363
- /**
2364
- * Gets the list of operations performed on the document.
2365
- */
2366
- get operations() {
2367
- return _t(this._document.operations);
2368
- }
2369
- /**
2370
- * Gets the name of the document.
2371
- */
2372
- get name() {
2373
- return this._document.name;
2374
- }
2375
- /**
2376
- * Gets the type of document.
2377
- */
2378
- get documentType() {
2379
- return this._document.documentType;
2380
- }
2381
- /**
2382
- * Gets the timestamp of the date the document was created.
2383
- */
2384
- get created() {
2385
- return this._document.created;
2386
- }
2387
- /**
2388
- * Gets the timestamp of the date the document was last modified.
2389
- */
2390
- get lastModified() {
2391
- return this._document.lastModified;
2392
- }
2393
- /**
2394
- * Gets the global revision number of the document.
2395
- */
2396
- get revision() {
2397
- return this._document.revision.global;
2398
- }
2399
- getRevision(i) {
2400
- return this._document.revision[i];
2401
- }
2402
- /**
2403
- * Gets the initial state of the document.
2404
- */
2405
- get initialState() {
2406
- return _t(this._document.initialState);
2407
- }
2408
- /**
2409
- * Returns the current document as an object
2410
- */
2411
- toDocument() {
2412
- return _t(this._document);
2413
- }
2414
- /**
2415
- * Gets the attachment associated with the given key.
2416
- * @param attachment - The key of the attachment to retrieve.
2417
- */
2418
- getAttachment(i) {
2419
- return this._document.attachments[i];
2420
- }
2421
- /**
2422
- * Sets the name of the document.
2423
- * @param name - The new name of the document.
2424
- */
2425
- setName(i) {
2426
- return this.dispatch(Be(i)), this;
2427
- }
2428
- /**
2429
- * Reverts a number of actions from the document.
2430
- * @param count - The number of actions to revert.
2431
- */
2432
- undo(i) {
2433
- return this.dispatch(je(i)), this;
2434
- }
2435
- /**
2436
- * Reapplies a number of actions to the document.
2437
- * @param count - The number of actions to reapply.
2438
- */
2439
- redo(i) {
2440
- return this.dispatch(Oe(i)), this;
2441
- }
2442
- /**
2443
- * Removes a range of operations from the document.
2444
- * @param start - The starting index of the range to remove.
2445
- * @param end - The ending index of the range to remove.
2446
- */
2447
- prune(i, s) {
2448
- return this.dispatch(Ie(i, s)), this;
2449
- }
2450
- /**
2451
- * Loads a document state and a set of operations.
2452
- * @param state - The state to load.
2453
- * @param operations - The operations to apply to the document.
2454
- */
2455
- loadState(i, s) {
2456
- return this.dispatch(Kt(i, s)), this;
2457
- }
2458
- }
2459
- function li(r, i) {
2460
- i.forEach((s) => {
2461
- Object.getOwnPropertyNames(s.prototype).forEach((p) => {
2462
- Object.defineProperty(
2463
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
2464
- r.prototype,
2465
- p,
2466
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
2467
- Object.getOwnPropertyDescriptor(s.prototype, p) || /* @__PURE__ */ Object.create(null)
2468
- );
2469
- });
2470
- });
2471
- }
2472
- export {
2473
- Hr as A,
2474
- ci as B,
2475
- ge as C,
2476
- ir as D,
2477
- ei as E,
2478
- Lr as a,
2479
- zr as b,
2480
- Rr as c,
2481
- ai as d,
2482
- Zr as e,
2483
- ht as f,
2484
- li as g,
2485
- oi as h,
2486
- Qt as i,
2487
- qr as j,
2488
- ke as k,
2489
- te as l,
2490
- pi as m,
2491
- si as n,
2492
- Ht as o,
2493
- ri as p,
2494
- Mr as q,
2495
- ni as r,
2496
- Kr as s,
2497
- Xt as t,
2498
- Pr as u,
2499
- _t as v,
2500
- Fe as w,
2501
- Nt as x,
2502
- Jr as y,
2503
- ii as z
2504
- };