document-model 1.1.0-experimental.3 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/cjs/document-model.js +1 -1
- package/dist/browser/cjs/document.js +1 -1
- package/dist/browser/cjs/index.js +1 -1
- package/dist/browser/cjs/internal/{index-dwAOfmBp.js → index-Bqu_Uzaf.js} +1 -1
- package/dist/browser/cjs/internal/{index-DMRH7zDy.js → index-DD_uV5_l.js} +1 -1
- package/dist/browser/cjs/internal/object-CHFtJl_E.js +25 -0
- package/dist/browser/es/document-model.js +2 -2
- package/dist/browser/es/document.js +9 -7
- package/dist/browser/es/index.js +3 -3
- package/dist/browser/es/internal/{index-DQztOVJu.js → index-C9_nWw6z.js} +1 -1
- package/dist/browser/es/internal/index-CNILoLzv.js +46 -0
- package/dist/browser/es/internal/{object-iTBekDVP.js → object-CJvDhUxl.js} +1003 -965
- package/dist/browser/src/document/object.d.ts +35 -0
- package/dist/browser/src/document/reducer.d.ts +17 -0
- package/dist/browser/src/document/types.d.ts +2 -0
- package/dist/browser/src/document/utils/document-helpers.d.ts +9 -0
- package/dist/node/cjs/document-model.js +1 -1
- package/dist/node/cjs/document.js +1 -1
- package/dist/node/cjs/index.js +1 -1
- package/dist/node/cjs/internal/{index-BNFVmPew.js → index-DSsY5px9.js} +1 -1
- package/dist/node/cjs/internal/{index-FvRO8SnG.js → index-eJODAZgf.js} +1 -1
- package/dist/node/cjs/internal/object-9bv72oJK.js +20 -0
- package/dist/node/es/document-model.js +2 -2
- package/dist/node/es/document.js +10 -8
- package/dist/node/es/index.js +3 -3
- package/dist/node/es/internal/index-Dug-2E00.js +46 -0
- package/dist/node/es/internal/{index-DOpbr_uw.js → index-nccvxxIw.js} +1 -1
- package/dist/node/es/internal/{object-C2s2eZ08.js → object-B9OVOSMl.js} +668 -630
- package/dist/node/src/document/object.d.ts +35 -0
- package/dist/node/src/document/reducer.d.ts +17 -0
- package/dist/node/src/document/types.d.ts +2 -0
- package/dist/node/src/document/utils/document-helpers.d.ts +9 -0
- package/package.json +3 -1
- package/dist/browser/cjs/internal/object-C-PazS9q.js +0 -25
- package/dist/browser/es/internal/index-BVJxzkIs.js +0 -44
- package/dist/node/cjs/internal/object-Xvr4kDQj.js +0 -20
- package/dist/node/es/internal/index-BIrQOTP_.js +0 -44
|
@@ -90,6 +90,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
90
90
|
readonly skip: number;
|
|
91
91
|
readonly error?: string | undefined;
|
|
92
92
|
readonly resultingState?: unknown;
|
|
93
|
+
readonly id?: string | undefined;
|
|
93
94
|
} | {
|
|
94
95
|
readonly type: "PRUNE";
|
|
95
96
|
readonly input: {
|
|
@@ -124,6 +125,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
124
125
|
readonly skip: number;
|
|
125
126
|
readonly error?: string | undefined;
|
|
126
127
|
readonly resultingState?: unknown;
|
|
128
|
+
readonly id?: string | undefined;
|
|
127
129
|
} | {
|
|
128
130
|
readonly type: "REDO";
|
|
129
131
|
readonly input: number;
|
|
@@ -155,6 +157,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
155
157
|
readonly skip: number;
|
|
156
158
|
readonly error?: string | undefined;
|
|
157
159
|
readonly resultingState?: unknown;
|
|
160
|
+
readonly id?: string | undefined;
|
|
158
161
|
} | {
|
|
159
162
|
readonly type: "SET_NAME";
|
|
160
163
|
readonly input: string;
|
|
@@ -186,6 +189,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
186
189
|
readonly skip: number;
|
|
187
190
|
readonly error?: string | undefined;
|
|
188
191
|
readonly resultingState?: unknown;
|
|
192
|
+
readonly id?: string | undefined;
|
|
189
193
|
} | {
|
|
190
194
|
readonly type: "UNDO";
|
|
191
195
|
readonly input: number;
|
|
@@ -217,6 +221,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
217
221
|
readonly skip: number;
|
|
218
222
|
readonly error?: string | undefined;
|
|
219
223
|
readonly resultingState?: unknown;
|
|
224
|
+
readonly id?: string | undefined;
|
|
220
225
|
} | {
|
|
221
226
|
readonly type: "NOOP";
|
|
222
227
|
readonly input: unknown;
|
|
@@ -248,6 +253,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
248
253
|
readonly skip: number;
|
|
249
254
|
readonly error?: string | undefined;
|
|
250
255
|
readonly resultingState?: unknown;
|
|
256
|
+
readonly id?: string | undefined;
|
|
251
257
|
} | import("immer").Immutable<A & {
|
|
252
258
|
index: number;
|
|
253
259
|
timestamp: string;
|
|
@@ -255,6 +261,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
255
261
|
skip: number;
|
|
256
262
|
error?: string | undefined;
|
|
257
263
|
resultingState?: unknown;
|
|
264
|
+
id?: string | undefined;
|
|
258
265
|
}>)[];
|
|
259
266
|
readonly local: readonly ({
|
|
260
267
|
readonly type: "LOAD_STATE";
|
|
@@ -293,6 +300,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
293
300
|
readonly skip: number;
|
|
294
301
|
readonly error?: string | undefined;
|
|
295
302
|
readonly resultingState?: unknown;
|
|
303
|
+
readonly id?: string | undefined;
|
|
296
304
|
} | {
|
|
297
305
|
readonly type: "PRUNE";
|
|
298
306
|
readonly input: {
|
|
@@ -327,6 +335,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
327
335
|
readonly skip: number;
|
|
328
336
|
readonly error?: string | undefined;
|
|
329
337
|
readonly resultingState?: unknown;
|
|
338
|
+
readonly id?: string | undefined;
|
|
330
339
|
} | {
|
|
331
340
|
readonly type: "REDO";
|
|
332
341
|
readonly input: number;
|
|
@@ -358,6 +367,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
358
367
|
readonly skip: number;
|
|
359
368
|
readonly error?: string | undefined;
|
|
360
369
|
readonly resultingState?: unknown;
|
|
370
|
+
readonly id?: string | undefined;
|
|
361
371
|
} | {
|
|
362
372
|
readonly type: "SET_NAME";
|
|
363
373
|
readonly input: string;
|
|
@@ -389,6 +399,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
389
399
|
readonly skip: number;
|
|
390
400
|
readonly error?: string | undefined;
|
|
391
401
|
readonly resultingState?: unknown;
|
|
402
|
+
readonly id?: string | undefined;
|
|
392
403
|
} | {
|
|
393
404
|
readonly type: "UNDO";
|
|
394
405
|
readonly input: number;
|
|
@@ -420,6 +431,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
420
431
|
readonly skip: number;
|
|
421
432
|
readonly error?: string | undefined;
|
|
422
433
|
readonly resultingState?: unknown;
|
|
434
|
+
readonly id?: string | undefined;
|
|
423
435
|
} | {
|
|
424
436
|
readonly type: "NOOP";
|
|
425
437
|
readonly input: unknown;
|
|
@@ -451,6 +463,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
451
463
|
readonly skip: number;
|
|
452
464
|
readonly error?: string | undefined;
|
|
453
465
|
readonly resultingState?: unknown;
|
|
466
|
+
readonly id?: string | undefined;
|
|
454
467
|
} | import("immer").Immutable<A & {
|
|
455
468
|
index: number;
|
|
456
469
|
timestamp: string;
|
|
@@ -458,6 +471,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
458
471
|
skip: number;
|
|
459
472
|
error?: string | undefined;
|
|
460
473
|
resultingState?: unknown;
|
|
474
|
+
id?: string | undefined;
|
|
461
475
|
}>)[];
|
|
462
476
|
};
|
|
463
477
|
/**
|
|
@@ -568,6 +582,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
568
582
|
readonly skip: number;
|
|
569
583
|
readonly error?: string | undefined;
|
|
570
584
|
readonly resultingState?: unknown;
|
|
585
|
+
readonly id?: string | undefined;
|
|
571
586
|
} | {
|
|
572
587
|
readonly type: "PRUNE";
|
|
573
588
|
readonly input: {
|
|
@@ -602,6 +617,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
602
617
|
readonly skip: number;
|
|
603
618
|
readonly error?: string | undefined;
|
|
604
619
|
readonly resultingState?: unknown;
|
|
620
|
+
readonly id?: string | undefined;
|
|
605
621
|
} | {
|
|
606
622
|
readonly type: "REDO";
|
|
607
623
|
readonly input: number;
|
|
@@ -633,6 +649,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
633
649
|
readonly skip: number;
|
|
634
650
|
readonly error?: string | undefined;
|
|
635
651
|
readonly resultingState?: unknown;
|
|
652
|
+
readonly id?: string | undefined;
|
|
636
653
|
} | {
|
|
637
654
|
readonly type: "SET_NAME";
|
|
638
655
|
readonly input: string;
|
|
@@ -664,6 +681,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
664
681
|
readonly skip: number;
|
|
665
682
|
readonly error?: string | undefined;
|
|
666
683
|
readonly resultingState?: unknown;
|
|
684
|
+
readonly id?: string | undefined;
|
|
667
685
|
} | {
|
|
668
686
|
readonly type: "UNDO";
|
|
669
687
|
readonly input: number;
|
|
@@ -695,6 +713,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
695
713
|
readonly skip: number;
|
|
696
714
|
readonly error?: string | undefined;
|
|
697
715
|
readonly resultingState?: unknown;
|
|
716
|
+
readonly id?: string | undefined;
|
|
698
717
|
} | {
|
|
699
718
|
readonly type: "NOOP";
|
|
700
719
|
readonly input: unknown;
|
|
@@ -726,6 +745,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
726
745
|
readonly skip: number;
|
|
727
746
|
readonly error?: string | undefined;
|
|
728
747
|
readonly resultingState?: unknown;
|
|
748
|
+
readonly id?: string | undefined;
|
|
729
749
|
} | import("immer").Immutable<A & {
|
|
730
750
|
index: number;
|
|
731
751
|
timestamp: string;
|
|
@@ -733,6 +753,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
733
753
|
skip: number;
|
|
734
754
|
error?: string | undefined;
|
|
735
755
|
resultingState?: unknown;
|
|
756
|
+
id?: string | undefined;
|
|
736
757
|
}>)[];
|
|
737
758
|
readonly local: readonly ({
|
|
738
759
|
readonly type: "LOAD_STATE";
|
|
@@ -771,6 +792,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
771
792
|
readonly skip: number;
|
|
772
793
|
readonly error?: string | undefined;
|
|
773
794
|
readonly resultingState?: unknown;
|
|
795
|
+
readonly id?: string | undefined;
|
|
774
796
|
} | {
|
|
775
797
|
readonly type: "PRUNE";
|
|
776
798
|
readonly input: {
|
|
@@ -805,6 +827,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
805
827
|
readonly skip: number;
|
|
806
828
|
readonly error?: string | undefined;
|
|
807
829
|
readonly resultingState?: unknown;
|
|
830
|
+
readonly id?: string | undefined;
|
|
808
831
|
} | {
|
|
809
832
|
readonly type: "REDO";
|
|
810
833
|
readonly input: number;
|
|
@@ -836,6 +859,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
836
859
|
readonly skip: number;
|
|
837
860
|
readonly error?: string | undefined;
|
|
838
861
|
readonly resultingState?: unknown;
|
|
862
|
+
readonly id?: string | undefined;
|
|
839
863
|
} | {
|
|
840
864
|
readonly type: "SET_NAME";
|
|
841
865
|
readonly input: string;
|
|
@@ -867,6 +891,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
867
891
|
readonly skip: number;
|
|
868
892
|
readonly error?: string | undefined;
|
|
869
893
|
readonly resultingState?: unknown;
|
|
894
|
+
readonly id?: string | undefined;
|
|
870
895
|
} | {
|
|
871
896
|
readonly type: "UNDO";
|
|
872
897
|
readonly input: number;
|
|
@@ -898,6 +923,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
898
923
|
readonly skip: number;
|
|
899
924
|
readonly error?: string | undefined;
|
|
900
925
|
readonly resultingState?: unknown;
|
|
926
|
+
readonly id?: string | undefined;
|
|
901
927
|
} | {
|
|
902
928
|
readonly type: "NOOP";
|
|
903
929
|
readonly input: unknown;
|
|
@@ -929,6 +955,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
929
955
|
readonly skip: number;
|
|
930
956
|
readonly error?: string | undefined;
|
|
931
957
|
readonly resultingState?: unknown;
|
|
958
|
+
readonly id?: string | undefined;
|
|
932
959
|
} | import("immer").Immutable<A & {
|
|
933
960
|
index: number;
|
|
934
961
|
timestamp: string;
|
|
@@ -936,6 +963,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
936
963
|
skip: number;
|
|
937
964
|
error?: string | undefined;
|
|
938
965
|
resultingState?: unknown;
|
|
966
|
+
id?: string | undefined;
|
|
939
967
|
}>)[];
|
|
940
968
|
};
|
|
941
969
|
readonly initialState: {
|
|
@@ -997,6 +1025,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
997
1025
|
readonly skip: number;
|
|
998
1026
|
readonly error?: string | undefined;
|
|
999
1027
|
readonly resultingState?: unknown;
|
|
1028
|
+
readonly id?: string | undefined;
|
|
1000
1029
|
} | {
|
|
1001
1030
|
readonly type: "PRUNE";
|
|
1002
1031
|
readonly input: {
|
|
@@ -1031,6 +1060,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
1031
1060
|
readonly skip: number;
|
|
1032
1061
|
readonly error?: string | undefined;
|
|
1033
1062
|
readonly resultingState?: unknown;
|
|
1063
|
+
readonly id?: string | undefined;
|
|
1034
1064
|
} | {
|
|
1035
1065
|
readonly type: "REDO";
|
|
1036
1066
|
readonly input: number;
|
|
@@ -1062,6 +1092,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
1062
1092
|
readonly skip: number;
|
|
1063
1093
|
readonly error?: string | undefined;
|
|
1064
1094
|
readonly resultingState?: unknown;
|
|
1095
|
+
readonly id?: string | undefined;
|
|
1065
1096
|
} | {
|
|
1066
1097
|
readonly type: "SET_NAME";
|
|
1067
1098
|
readonly input: string;
|
|
@@ -1093,6 +1124,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
1093
1124
|
readonly skip: number;
|
|
1094
1125
|
readonly error?: string | undefined;
|
|
1095
1126
|
readonly resultingState?: unknown;
|
|
1127
|
+
readonly id?: string | undefined;
|
|
1096
1128
|
} | {
|
|
1097
1129
|
readonly type: "UNDO";
|
|
1098
1130
|
readonly input: number;
|
|
@@ -1124,6 +1156,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
1124
1156
|
readonly skip: number;
|
|
1125
1157
|
readonly error?: string | undefined;
|
|
1126
1158
|
readonly resultingState?: unknown;
|
|
1159
|
+
readonly id?: string | undefined;
|
|
1127
1160
|
} | {
|
|
1128
1161
|
readonly type: "NOOP";
|
|
1129
1162
|
readonly input: unknown;
|
|
@@ -1155,6 +1188,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
1155
1188
|
readonly skip: number;
|
|
1156
1189
|
readonly error?: string | undefined;
|
|
1157
1190
|
readonly resultingState?: unknown;
|
|
1191
|
+
readonly id?: string | undefined;
|
|
1158
1192
|
} | import("immer").Immutable<A & {
|
|
1159
1193
|
index: number;
|
|
1160
1194
|
timestamp: string;
|
|
@@ -1162,6 +1196,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
1162
1196
|
skip: number;
|
|
1163
1197
|
error?: string | undefined;
|
|
1164
1198
|
resultingState?: unknown;
|
|
1199
|
+
id?: string | undefined;
|
|
1165
1200
|
}>)[];
|
|
1166
1201
|
};
|
|
1167
1202
|
/**
|
|
@@ -2,6 +2,23 @@ import { BaseAction } from './actions/types';
|
|
|
2
2
|
import { UndoRedoAction } from './schema';
|
|
3
3
|
import { Action, Document, ImmutableStateReducer, Operation, ReducerOptions, State } from './types';
|
|
4
4
|
import { SignalDispatch } from './signal';
|
|
5
|
+
/**
|
|
6
|
+
* Updates the document header with the latest revision number and
|
|
7
|
+
* date of last modification.
|
|
8
|
+
*
|
|
9
|
+
* @param state The current state of the document.
|
|
10
|
+
* @param action The action being applied to the document.
|
|
11
|
+
* @returns The updated document state.
|
|
12
|
+
*/
|
|
13
|
+
export declare function updateHeader<T extends Document>(document: T, action: Action): T;
|
|
14
|
+
/**
|
|
15
|
+
* Updates the document state based on the provided action.
|
|
16
|
+
*
|
|
17
|
+
* @param state The current state of the document.
|
|
18
|
+
* @param action The action being applied to the document.
|
|
19
|
+
* @returns The updated document state.
|
|
20
|
+
*/
|
|
21
|
+
export declare function updateDocument<T extends Document>(document: T, action: Action, skip?: number): T;
|
|
5
22
|
type UndoRedoProcessResult<T, A extends Action, L> = {
|
|
6
23
|
document: Document<T, A, L>;
|
|
7
24
|
action: A | BaseAction;
|
|
@@ -108,6 +108,8 @@ export type Operation<A extends Action = Action> = A & {
|
|
|
108
108
|
error?: string;
|
|
109
109
|
/** The resulting state after the operation */
|
|
110
110
|
resultingState?: unknown;
|
|
111
|
+
/** Unique operation id */
|
|
112
|
+
id?: string;
|
|
111
113
|
};
|
|
112
114
|
/**
|
|
113
115
|
* The base attributes of a {@link Document}.
|
|
@@ -50,4 +50,13 @@ export type SkipHeaderOperationIndex = Partial<Pick<OperationIndex, 'index'>> &
|
|
|
50
50
|
*/
|
|
51
51
|
export declare function skipHeaderOperations<A extends OperationIndex>(operations: A[], skipHeaderOperation: SkipHeaderOperationIndex): A[];
|
|
52
52
|
export declare function garbageCollectDocumentOperations<A extends Action>(documentOperations: DocumentOperations<A>): DocumentOperations<A>;
|
|
53
|
+
/**
|
|
54
|
+
* Filters out duplicated operations from the target operations array based on their IDs.
|
|
55
|
+
* If an operation has an ID, it is considered duplicated if there is another operation in the source operations array with the same ID.
|
|
56
|
+
* If an operation does not have an ID, it is considered unique and will not be filtered out.
|
|
57
|
+
* @param targetOperations - The array of target operations to filter.
|
|
58
|
+
* @param sourceOperations - The array of source operations to compare against.
|
|
59
|
+
* @returns An array of operations with duplicates filtered out.
|
|
60
|
+
*/
|
|
61
|
+
export declare function filterDuplicatedOperations(targetOperations: Operation[], sourceOperations: Operation[]): Operation[];
|
|
53
62
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "document-model",
|
|
3
|
-
"version": "1.1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"private": false,
|
|
6
6
|
"files": [
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
"@types/mime": "^3.0.4",
|
|
65
65
|
"@types/node": "^20.11.17",
|
|
66
66
|
"@types/react": "^18.2.48",
|
|
67
|
+
"@types/uuid": "^9.0.8",
|
|
67
68
|
"@typescript-eslint/eslint-plugin": "^6.19.0",
|
|
68
69
|
"@typescript-eslint/parser": "^6.19.0",
|
|
69
70
|
"eslint": "^8.56.0",
|
|
@@ -90,6 +91,7 @@
|
|
|
90
91
|
"jszip": "^3.10.1",
|
|
91
92
|
"mime": "^4.0.1",
|
|
92
93
|
"safe-stable-stringify": "^2.4.3",
|
|
94
|
+
"uuid": "^9.0.1",
|
|
93
95
|
"zod": "^3.22.4"
|
|
94
96
|
}
|
|
95
97
|
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";var Ye=Object.defineProperty;var Qe=(r,i,o)=>i in r?Ye(r,i,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[i]=o;var Ot=(r,i,o)=>(Qe(r,typeof i!="symbol"?i+"":i,o),o);const nt=require("immer"),_=require("zod"),pe=require("jszip"),ce=r=>r!=null,tr=_.z.any().refine(r=>ce(r)),le=_.z.enum(["LOAD_STATE"]),ue=_.z.enum(["PRUNE"]),fe=_.z.enum(["REDO"]),he=_.z.enum(["SET_NAME"]),me=_.z.enum(["UNDO"]);function er(){return _.z.object({__typename:_.z.literal("Action").optional(),type:_.z.string()})}function Et(){return _.z.literal("global").or(_.z.literal("local"))}function xe(){return _.z.union([de(),ye(),we(),Ee(),be()])}function rr(){return _.z.object({__typename:_.z.literal("DocumentFile").optional(),data:_.z.string(),extension:_.z.string().nullable(),fileName:_.z.string().nullable(),mimeType:_.z.string()})}function de(){return _.z.object({input:_.z.lazy(()=>Ht()),type:le,scope:Et()})}function Ht(){return _.z.object({operations:_.z.number(),state:_.z.lazy(()=>ge())})}function ge(){return _.z.object({data:_.z.unknown().nullish(),name:_.z.string()})}function ir(){return _.z.object({__typename:_.z.literal("Operation").optional(),hash:_.z.string(),index:_.z.number(),timestamp:_.z.string().datetime(),type:_.z.string()})}function ye(){return _.z.object({input:_.z.lazy(()=>Jt()),type:ue,scope:Et()})}function Jt(){return _.z.object({end:_.z.number().nullish(),start:_.z.number().nullish()})}const Wt=_.z.number;function we(){return _.z.object({input:Wt(),type:fe,scope:Et()})}const Xt=_.z.string;function Ee(){return _.z.object({input:Xt(),type:he,scope:_.z.literal("global")})}function nr(){return _.z.object({__typename:_.z.literal("SetNameOperation").optional(),hash:_.z.string(),index:_.z.number(),input:_.z.string(),timestamp:_.z.string().datetime(),type:_.z.string()})}const Vt=_.z.number;function be(){return _.z.object({input:Vt(),type:me,scope:Et()})}const or=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:er,BaseActionSchema:xe,DocumentFileSchema:rr,LoadStateActionInputSchema:Ht,LoadStateActionSchema:de,LoadStateActionStateInputSchema:ge,Load_StateSchema:le,OperationSchema:ir,OperationScopeSchema:Et,PruneActionInputSchema:Jt,PruneActionSchema:ye,PruneSchema:ue,RedoActionInputSchema:Wt,RedoActionSchema:we,RedoSchema:fe,SetNameActionInputSchema:Xt,SetNameActionSchema:Ee,SetNameOperationSchema:nr,Set_NameSchema:he,UndoActionInputSchema:Vt,UndoActionSchema:be,UndoSchema:me,definedNonNullAnySchema:tr,isDefinedNonNullAny:ce},Symbol.toStringTag,{value:"Module"}));function Kt(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var zt={exports:{}};(function(r,i){const{hasOwnProperty:o}=Object.prototype,p=Z();p.configure=Z,p.stringify=p,p.default=p,i.stringify=p,i.configure=Z,r.exports=p;const u=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/;function f(w){return w.length<5e3&&!u.test(w)?`"${w}"`:JSON.stringify(w)}function c(w){if(w.length>200)return w.sort();for(let E=1;E<w.length;E++){const S=w[E];let M=E;for(;M!==0&&w[M-1]>S;)w[M]=w[M-1],M--;w[M]=S}return w}const a=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function h(w){return a.call(w)!==void 0&&w.length!==0}function g(w,E,S){w.length<S&&(S=w.length);const M=E===","?"":" ";let J=`"0":${M}${w[0]}`;for(let W=1;W<S;W++)J+=`${E}"${W}":${M}${w[W]}`;return J}function y(w){if(o.call(w,"circularValue")){const E=w.circularValue;if(typeof E=="string")return`"${E}"`;if(E==null)return E;if(E===Error||E===TypeError)return{toString(){throw new TypeError("Converting circular structure to JSON")}};throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined')}return'"[Circular]"'}function b(w,E){let S;if(o.call(w,E)&&(S=w[E],typeof S!="boolean"))throw new TypeError(`The "${E}" argument must be of type boolean`);return S===void 0?!0:S}function F(w,E){let S;if(o.call(w,E)){if(S=w[E],typeof S!="number")throw new TypeError(`The "${E}" argument must be of type number`);if(!Number.isInteger(S))throw new TypeError(`The "${E}" argument must be an integer`);if(S<1)throw new RangeError(`The "${E}" argument must be >= 1`)}return S===void 0?1/0:S}function j(w){return w===1?"1 item":`${w} items`}function $(w){const E=new Set;for(const S of w)(typeof S=="string"||typeof S=="number")&&E.add(String(S));return E}function q(w){if(o.call(w,"strict")){const E=w.strict;if(typeof E!="boolean")throw new TypeError('The "strict" argument must be of type boolean');if(E)return S=>{let M=`Object can not safely be stringified. Received type ${typeof S}`;throw typeof S!="function"&&(M+=` (${S.toString()})`),new Error(M)}}}function Z(w){w={...w};const E=q(w);E&&(w.bigint===void 0&&(w.bigint=!1),"circularValue"in w||(w.circularValue=Error));const S=y(w),M=b(w,"bigint"),J=b(w,"deterministic"),W=F(w,"maximumDepth"),z=F(w,"maximumBreadth");function ht(X,m,v,D,B,U){let A=m[X];switch(typeof A=="object"&&A!==null&&typeof A.toJSON=="function"&&(A=A.toJSON(X)),A=D.call(m,X,A),typeof A){case"string":return f(A);case"object":{if(A===null)return"null";if(v.indexOf(A)!==-1)return S;let T="",O=",";const I=U;if(Array.isArray(A)){if(A.length===0)return"[]";if(W<v.length+1)return'"[Array]"';v.push(A),B!==""&&(U+=B,T+=`
|
|
2
|
-
${U}`,O=`,
|
|
3
|
-
${U}`);const V=Math.min(A.length,z);let Q=0;for(;Q<V-1;Q++){const lt=ht(String(Q),A,v,D,B,U);T+=lt!==void 0?lt:"null",T+=O}const tt=ht(String(Q),A,v,D,B,U);if(T+=tt!==void 0?tt:"null",A.length-1>z){const lt=A.length-z-1;T+=`${O}"... ${j(lt)} not stringified"`}return B!==""&&(T+=`
|
|
4
|
-
${I}`),v.pop(),`[${T}]`}let R=Object.keys(A);const H=R.length;if(H===0)return"{}";if(W<v.length+1)return'"[Object]"';let C="",K="";B!==""&&(U+=B,O=`,
|
|
5
|
-
${U}`,C=" ");const Y=Math.min(H,z);J&&!h(A)&&(R=c(R)),v.push(A);for(let V=0;V<Y;V++){const Q=R[V],tt=ht(Q,A,v,D,B,U);tt!==void 0&&(T+=`${K}${f(Q)}:${C}${tt}`,K=O)}if(H>z){const V=H-z;T+=`${K}"...":${C}"${j(V)} not stringified"`,K=O}return B!==""&&K.length>1&&(T=`
|
|
6
|
-
${U}${T}
|
|
7
|
-
${I}`),v.pop(),`{${T}}`}case"number":return isFinite(A)?String(A):E?E(A):"null";case"boolean":return A===!0?"true":"false";case"undefined":return;case"bigint":if(M)return String(A);default:return E?E(A):void 0}}function mt(X,m,v,D,B,U){switch(typeof m=="object"&&m!==null&&typeof m.toJSON=="function"&&(m=m.toJSON(X)),typeof m){case"string":return f(m);case"object":{if(m===null)return"null";if(v.indexOf(m)!==-1)return S;const A=U;let T="",O=",";if(Array.isArray(m)){if(m.length===0)return"[]";if(W<v.length+1)return'"[Array]"';v.push(m),B!==""&&(U+=B,T+=`
|
|
8
|
-
${U}`,O=`,
|
|
9
|
-
${U}`);const H=Math.min(m.length,z);let C=0;for(;C<H-1;C++){const Y=mt(String(C),m[C],v,D,B,U);T+=Y!==void 0?Y:"null",T+=O}const K=mt(String(C),m[C],v,D,B,U);if(T+=K!==void 0?K:"null",m.length-1>z){const Y=m.length-z-1;T+=`${O}"... ${j(Y)} not stringified"`}return B!==""&&(T+=`
|
|
10
|
-
${A}`),v.pop(),`[${T}]`}v.push(m);let I="";B!==""&&(U+=B,O=`,
|
|
11
|
-
${U}`,I=" ");let R="";for(const H of D){const C=mt(H,m[H],v,D,B,U);C!==void 0&&(T+=`${R}${f(H)}:${I}${C}`,R=O)}return B!==""&&R.length>1&&(T=`
|
|
12
|
-
${U}${T}
|
|
13
|
-
${A}`),v.pop(),`{${T}}`}case"number":return isFinite(m)?String(m):E?E(m):"null";case"boolean":return m===!0?"true":"false";case"undefined":return;case"bigint":if(M)return String(m);default:return E?E(m):void 0}}function pt(X,m,v,D,B){switch(typeof m){case"string":return f(m);case"object":{if(m===null)return"null";if(typeof m.toJSON=="function"){if(m=m.toJSON(X),typeof m!="object")return pt(X,m,v,D,B);if(m===null)return"null"}if(v.indexOf(m)!==-1)return S;const U=B;if(Array.isArray(m)){if(m.length===0)return"[]";if(W<v.length+1)return'"[Array]"';v.push(m),B+=D;let C=`
|
|
14
|
-
${B}`;const K=`,
|
|
15
|
-
${B}`,Y=Math.min(m.length,z);let V=0;for(;V<Y-1;V++){const tt=pt(String(V),m[V],v,D,B);C+=tt!==void 0?tt:"null",C+=K}const Q=pt(String(V),m[V],v,D,B);if(C+=Q!==void 0?Q:"null",m.length-1>z){const tt=m.length-z-1;C+=`${K}"... ${j(tt)} not stringified"`}return C+=`
|
|
16
|
-
${U}`,v.pop(),`[${C}]`}let A=Object.keys(m);const T=A.length;if(T===0)return"{}";if(W<v.length+1)return'"[Object]"';B+=D;const O=`,
|
|
17
|
-
${B}`;let I="",R="",H=Math.min(T,z);h(m)&&(I+=g(m,O,z),A=A.slice(m.length),H-=m.length,R=O),J&&(A=c(A)),v.push(m);for(let C=0;C<H;C++){const K=A[C],Y=pt(K,m[K],v,D,B);Y!==void 0&&(I+=`${R}${f(K)}: ${Y}`,R=O)}if(T>z){const C=T-z;I+=`${R}"...": "${j(C)} not stringified"`,R=O}return R!==""&&(I=`
|
|
18
|
-
${B}${I}
|
|
19
|
-
${U}`),v.pop(),`{${I}}`}case"number":return isFinite(m)?String(m):E?E(m):"null";case"boolean":return m===!0?"true":"false";case"undefined":return;case"bigint":if(M)return String(m);default:return E?E(m):void 0}}function ct(X,m,v){switch(typeof m){case"string":return f(m);case"object":{if(m===null)return"null";if(typeof m.toJSON=="function"){if(m=m.toJSON(X),typeof m!="object")return ct(X,m,v);if(m===null)return"null"}if(v.indexOf(m)!==-1)return S;let D="";if(Array.isArray(m)){if(m.length===0)return"[]";if(W<v.length+1)return'"[Array]"';v.push(m);const O=Math.min(m.length,z);let I=0;for(;I<O-1;I++){const H=ct(String(I),m[I],v);D+=H!==void 0?H:"null",D+=","}const R=ct(String(I),m[I],v);if(D+=R!==void 0?R:"null",m.length-1>z){const H=m.length-z-1;D+=`,"... ${j(H)} not stringified"`}return v.pop(),`[${D}]`}let B=Object.keys(m);const U=B.length;if(U===0)return"{}";if(W<v.length+1)return'"[Object]"';let A="",T=Math.min(U,z);h(m)&&(D+=g(m,",",z),B=B.slice(m.length),T-=m.length,A=","),J&&(B=c(B)),v.push(m);for(let O=0;O<T;O++){const I=B[O],R=ct(I,m[I],v);R!==void 0&&(D+=`${A}${f(I)}:${R}`,A=",")}if(U>z){const O=U-z;D+=`${A}"...":"${j(O)} not stringified"`}return v.pop(),`{${D}}`}case"number":return isFinite(m)?String(m):E?E(m):"null";case"boolean":return m===!0?"true":"false";case"undefined":return;case"bigint":if(M)return String(m);default:return E?E(m):void 0}}function Ut(X,m,v){if(arguments.length>1){let D="";if(typeof v=="number"?D=" ".repeat(Math.min(v,10)):typeof v=="string"&&(D=v.slice(0,10)),m!=null){if(typeof m=="function")return ht("",{"":X},[],m,D,"");if(Array.isArray(m))return mt("",X,[],$(m),D,"")}if(D.length!==0)return pt("",X,[],D,"")}return ct("",X,[])}return Ut}})(zt,zt.exports);var ar=zt.exports;const gt=Kt(ar);gt.configure;function sr(r,i){return{...r,name:i}}function pr(r,i,o){const{scope:p,input:u}=i,f={document:r,action:i,skip:o};return nt.produce(f,c=>{if(c.document.operations[p].length<1)throw new Error(`Cannot undo: no operations in history for scope "${p}"`);if(u<1)throw new Error("Invalid UNDO action: input value must be greater than 0");if(c.skip>0)throw new Error("Cannot undo: skip value from reducer cannot be used with UNDO action");const a=c.document.operations[p].at(-1),h=a&&a.type==="NOOP"&&a.skip>0;if(c.skip+=u,h){c.skip+=a.skip;const F=c.document.operations[p][c.document.operations[p].length-2];F&&a.index-F.index===1&&c.document.operations[p].pop()}if(c.document.operations[p].length<c.skip)throw new Error("Cannot undo: you can't undo more operations than the ones in the scope history");const g=c.document.operations[p].length-1;let y=u,b=h?g-a.skip:g;for(;y>0&&b>=0;){const F=c.document.operations[p][b];if(!F){y--,b--;continue}F.type==="NOOP"&&F.skip>0?(b=b-(F.skip+1),c.skip+=F.skip+1):(c.document.clipboard.push({...F}),y--,b--)}c.action=Ge(p)})}function cr(r,i,o){const{scope:p,input:u}=i,f={document:r,action:i,skip:o};return nt.produce(f,c=>{if(c.skip>0)throw new Error("Cannot redo: skip value from reducer cannot be used with REDO action");if(u>1)throw new Error("Cannot redo: you can only redo one operation at a time");if(u<1)throw new Error("Invalid REDO action: invalid redo input value");if(c.document.clipboard.length<1)throw new Error("Cannot redo: no operations in the clipboard");const a=c.document.clipboard.findLastIndex(g=>g.scope===p);if(a<0)throw new Error(`Cannot redo: no operations in clipboard for scope "${p}"`);const h=c.document.clipboard.splice(a,1)[0];c.action=nt.castDraft({type:h.type,scope:h.scope,input:h.input})})}function lr(r,i,o){const{scope:p}=i,u=r.operations[p];let{input:{start:f,end:c}}=i;f=f||0,c=c||u.length;const a=u.slice(f,c),h=u.slice(0,f),g=u.slice(c),y=Bt(r.initialState,{...r.operations,[p]:h.concat(a)},o),{name:b,state:F}=y,j=h.length,$=h.length?h[h.length-1].timestamp:g.length?g[0].timestamp:new Date().toISOString();return Bt(r.initialState,{...r.operations,[p]:[...h,{...oe({name:b,state:F},a.length),timestamp:$,index:j,hash:kt({state:F},"global")},...g.map((q,Z)=>({...q,index:j+Z+1}))]},o)}function ur(r,i){return{...r,name:i.name,state:i.state??{global:{},local:{}}}}const Se="SET_NAME",bt="UNDO",St="REDO",It="PRUNE",ve="LOAD_STATE",fr="NOOP",_e={"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"]};Object.freeze(_e);var et=function(r,i,o,p){if(o==="a"&&!p)throw new TypeError("Private accessor was defined without a getter");if(typeof i=="function"?r!==i||!p:!i.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return o==="m"?p:o==="a"?p.call(r):p?p.value:i.get(r)},dt,yt,ut;class hr{constructor(...i){dt.set(this,new Map),yt.set(this,new Map),ut.set(this,new Map);for(const o of i)this.define(o)}define(i,o=!1){for(let[p,u]of Object.entries(i)){p=p.toLowerCase(),u=u.map(a=>a.toLowerCase()),et(this,ut,"f").has(p)||et(this,ut,"f").set(p,new Set);const f=et(this,ut,"f").get(p);let c=!0;for(let a of u){const h=a.startsWith("*");if(a=h?a.slice(1):a,f==null||f.add(a),c&&et(this,yt,"f").set(p,a),c=!1,h)continue;const g=et(this,dt,"f").get(a);if(g&&g!=p&&!o)throw new Error(`"${p} -> ${a}" conflicts with "${g} -> ${a}". Pass \`force=true\` to override this definition.`);et(this,dt,"f").set(a,p)}}return this}getType(i){if(typeof i!="string")return null;const o=i.replace(/^.*[/\\]/,"").toLowerCase(),p=o.replace(/^.*\./,"").toLowerCase(),u=o.length<i.length;return!(p.length<o.length-1)&&u?null:et(this,dt,"f").get(p)??null}getExtension(i){var o;return typeof i!="string"?null:(i=(o=i==null?void 0:i.split)==null?void 0:o.call(i,";")[0],(i&&et(this,yt,"f").get(i.trim().toLowerCase()))??null)}getAllExtensions(i){return typeof i!="string"?null:et(this,ut,"f").get(i.toLowerCase())??null}_freeze(){this.define=()=>{throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances")},Object.freeze(this);for(const i of et(this,ut,"f").values())Object.freeze(i);return this}_getTestState(){return{types:et(this,dt,"f"),extensions:et(this,yt,"f")}}}dt=new WeakMap,yt=new WeakMap,ut=new WeakMap;const mr=new hr(_e)._freeze();var Mt={exports:{}};typeof Object.create=="function"?Mt.exports=function(i,o){o&&(i.super_=o,i.prototype=Object.create(o.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}))}:Mt.exports=function(i,o){if(o){i.super_=o;var p=function(){};p.prototype=o.prototype,i.prototype=new p,i.prototype.constructor=i}};var Ae=Mt.exports,Rt={exports:{}},Fe={},jt={};jt.byteLength=gr;jt.toByteArray=wr;jt.fromByteArray=Sr;var ot=[],rt=[],xr=typeof Uint8Array<"u"?Uint8Array:Array,$t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var xt=0,dr=$t.length;xt<dr;++xt)ot[xt]=$t[xt],rt[$t.charCodeAt(xt)]=xt;rt[45]=62;rt[95]=63;function Oe(r){var i=r.length;if(i%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var o=r.indexOf("=");o===-1&&(o=i);var p=o===i?0:4-o%4;return[o,p]}function gr(r){var i=Oe(r),o=i[0],p=i[1];return(o+p)*3/4-p}function yr(r,i,o){return(i+o)*3/4-o}function wr(r){var i,o=Oe(r),p=o[0],u=o[1],f=new xr(yr(r,p,u)),c=0,a=u>0?p-4:p,h;for(h=0;h<a;h+=4)i=rt[r.charCodeAt(h)]<<18|rt[r.charCodeAt(h+1)]<<12|rt[r.charCodeAt(h+2)]<<6|rt[r.charCodeAt(h+3)],f[c++]=i>>16&255,f[c++]=i>>8&255,f[c++]=i&255;return u===2&&(i=rt[r.charCodeAt(h)]<<2|rt[r.charCodeAt(h+1)]>>4,f[c++]=i&255),u===1&&(i=rt[r.charCodeAt(h)]<<10|rt[r.charCodeAt(h+1)]<<4|rt[r.charCodeAt(h+2)]>>2,f[c++]=i>>8&255,f[c++]=i&255),f}function Er(r){return ot[r>>18&63]+ot[r>>12&63]+ot[r>>6&63]+ot[r&63]}function br(r,i,o){for(var p,u=[],f=i;f<o;f+=3)p=(r[f]<<16&16711680)+(r[f+1]<<8&65280)+(r[f+2]&255),u.push(Er(p));return u.join("")}function Sr(r){for(var i,o=r.length,p=o%3,u=[],f=16383,c=0,a=o-p;c<a;c+=f)u.push(br(r,c,c+f>a?a:c+f));return p===1?(i=r[o-1],u.push(ot[i>>2]+ot[i<<4&63]+"==")):p===2&&(i=(r[o-2]<<8)+r[o-1],u.push(ot[i>>10]+ot[i>>4&63]+ot[i<<2&63]+"=")),u.join("")}var Gt={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Gt.read=function(r,i,o,p,u){var f,c,a=u*8-p-1,h=(1<<a)-1,g=h>>1,y=-7,b=o?u-1:0,F=o?-1:1,j=r[i+b];for(b+=F,f=j&(1<<-y)-1,j>>=-y,y+=a;y>0;f=f*256+r[i+b],b+=F,y-=8);for(c=f&(1<<-y)-1,f>>=-y,y+=p;y>0;c=c*256+r[i+b],b+=F,y-=8);if(f===0)f=1-g;else{if(f===h)return c?NaN:(j?-1:1)*(1/0);c=c+Math.pow(2,p),f=f-g}return(j?-1:1)*c*Math.pow(2,f-p)};Gt.write=function(r,i,o,p,u,f){var c,a,h,g=f*8-u-1,y=(1<<g)-1,b=y>>1,F=u===23?Math.pow(2,-24)-Math.pow(2,-77):0,j=p?0:f-1,$=p?1:-1,q=i<0||i===0&&1/i<0?1:0;for(i=Math.abs(i),isNaN(i)||i===1/0?(a=isNaN(i)?1:0,c=y):(c=Math.floor(Math.log(i)/Math.LN2),i*(h=Math.pow(2,-c))<1&&(c--,h*=2),c+b>=1?i+=F/h:i+=F*Math.pow(2,1-b),i*h>=2&&(c++,h/=2),c+b>=y?(a=0,c=y):c+b>=1?(a=(i*h-1)*Math.pow(2,u),c=c+b):(a=i*Math.pow(2,b-1)*Math.pow(2,u),c=0));u>=8;r[o+j]=a&255,j+=$,a/=256,u-=8);for(c=c<<u|a,g+=u;g>0;r[o+j]=c&255,j+=$,c/=256,g-=8);r[o+j-$]|=q*128};/*!
|
|
20
|
-
* The buffer module from node.js, for the browser.
|
|
21
|
-
*
|
|
22
|
-
* @author Feross Aboukhadijeh <https://feross.org>
|
|
23
|
-
* @license MIT
|
|
24
|
-
*/(function(r){var i=jt,o=Gt,p=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;r.Buffer=a,r.SlowBuffer=E,r.INSPECT_MAX_BYTES=50;var u=2147483647;r.kMaxLength=u,a.TYPED_ARRAY_SUPPORT=f(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function f(){try{var n=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(n,t),n.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function c(n){if(n>u)throw new RangeError('The value "'+n+'" is invalid for option "size"');var t=new Uint8Array(n);return Object.setPrototypeOf(t,a.prototype),t}function a(n,t,e){if(typeof n=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return b(n)}return h(n,t,e)}a.poolSize=8192;function h(n,t,e){if(typeof n=="string")return F(n,t);if(ArrayBuffer.isView(n))return $(n);if(n==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n);if(it(n,ArrayBuffer)||n&&it(n.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(it(n,SharedArrayBuffer)||n&&it(n.buffer,SharedArrayBuffer)))return q(n,t,e);if(typeof n=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var s=n.valueOf&&n.valueOf();if(s!=null&&s!==n)return a.from(s,t,e);var l=Z(n);if(l)return l;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof n[Symbol.toPrimitive]=="function")return a.from(n[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n)}a.from=function(n,t,e){return h(n,t,e)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function g(n){if(typeof n!="number")throw new TypeError('"size" argument must be of type number');if(n<0)throw new RangeError('The value "'+n+'" is invalid for option "size"')}function y(n,t,e){return g(n),n<=0?c(n):t!==void 0?typeof e=="string"?c(n).fill(t,e):c(n).fill(t):c(n)}a.alloc=function(n,t,e){return y(n,t,e)};function b(n){return g(n),c(n<0?0:w(n)|0)}a.allocUnsafe=function(n){return b(n)},a.allocUnsafeSlow=function(n){return b(n)};function F(n,t){if((typeof t!="string"||t==="")&&(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var e=S(n,t)|0,s=c(e),l=s.write(n,t);return l!==e&&(s=s.slice(0,l)),s}function j(n){for(var t=n.length<0?0:w(n.length)|0,e=c(t),s=0;s<t;s+=1)e[s]=n[s]&255;return e}function $(n){if(it(n,Uint8Array)){var t=new Uint8Array(n);return q(t.buffer,t.byteOffset,t.byteLength)}return j(n)}function q(n,t,e){if(t<0||n.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(n.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');var s;return t===void 0&&e===void 0?s=new Uint8Array(n):e===void 0?s=new Uint8Array(n,t):s=new Uint8Array(n,t,e),Object.setPrototypeOf(s,a.prototype),s}function Z(n){if(a.isBuffer(n)){var t=w(n.length)|0,e=c(t);return e.length===0||n.copy(e,0,0,t),e}if(n.length!==void 0)return typeof n.length!="number"||Ct(n.length)?c(0):j(n);if(n.type==="Buffer"&&Array.isArray(n.data))return j(n.data)}function w(n){if(n>=u)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u.toString(16)+" bytes");return n|0}function E(n){return+n!=n&&(n=0),a.alloc(+n)}a.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==a.prototype},a.compare=function(t,e){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))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var s=t.length,l=e.length,x=0,d=Math.min(s,l);x<d;++x)if(t[x]!==e[x]){s=t[x],l=e[x];break}return s<l?-1:l<s?1:0},a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return a.alloc(0);var s;if(e===void 0)for(e=0,s=0;s<t.length;++s)e+=t[s].length;var l=a.allocUnsafe(e),x=0;for(s=0;s<t.length;++s){var d=t[s];if(it(d,Uint8Array))x+d.length>l.length?a.from(d).copy(l,x):Uint8Array.prototype.set.call(l,d,x);else if(a.isBuffer(d))d.copy(l,x);else throw new TypeError('"list" argument must be an Array of Buffers');x+=d.length}return l};function S(n,t){if(a.isBuffer(n))return n.length;if(ArrayBuffer.isView(n)||it(n,ArrayBuffer))return n.byteLength;if(typeof n!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof n);var e=n.length,s=arguments.length>2&&arguments[2]===!0;if(!s&&e===0)return 0;for(var l=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return V(n).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return lt(n).length;default:if(l)return s?-1:V(n).length;t=(""+t).toLowerCase(),l=!0}}a.byteLength=S;function M(n,t,e){var s=!1;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))return"";for(n||(n="utf8");;)switch(n){case"hex":return A(this,t,e);case"utf8":case"utf-8":return m(this,t,e);case"ascii":return B(this,t,e);case"latin1":case"binary":return U(this,t,e);case"base64":return X(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,e);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),s=!0}}a.prototype._isBuffer=!0;function J(n,t,e){var s=n[t];n[t]=n[e],n[e]=s}a.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)J(this,e,e+1);return this},a.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)J(this,e,e+3),J(this,e+1,e+2);return this},a.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)J(this,e,e+7),J(this,e+1,e+6),J(this,e+2,e+5),J(this,e+3,e+4);return this},a.prototype.toString=function(){var t=this.length;return t===0?"":arguments.length===0?m(this,0,t):M.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:a.compare(this,t)===0},a.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"},p&&(a.prototype[p]=a.prototype.inspect),a.prototype.compare=function(t,e,s,l,x){if(it(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),s===void 0&&(s=t?t.length:0),l===void 0&&(l=0),x===void 0&&(x=this.length),e<0||s>t.length||l<0||x>this.length)throw new RangeError("out of range index");if(l>=x&&e>=s)return 0;if(l>=x)return-1;if(e>=s)return 1;if(e>>>=0,s>>>=0,l>>>=0,x>>>=0,this===t)return 0;for(var d=x-l,k=s-e,N=Math.min(d,k),L=this.slice(l,x),G=t.slice(e,s),P=0;P<N;++P)if(L[P]!==G[P]){d=L[P],k=G[P];break}return d<k?-1:k<d?1:0};function W(n,t,e,s,l){if(n.length===0)return-1;if(typeof e=="string"?(s=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,Ct(e)&&(e=l?0:n.length-1),e<0&&(e=n.length+e),e>=n.length){if(l)return-1;e=n.length-1}else if(e<0)if(l)e=0;else return-1;if(typeof t=="string"&&(t=a.from(t,s)),a.isBuffer(t))return t.length===0?-1:z(n,t,e,s,l);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?l?Uint8Array.prototype.indexOf.call(n,t,e):Uint8Array.prototype.lastIndexOf.call(n,t,e):z(n,[t],e,s,l);throw new TypeError("val must be string, number or Buffer")}function z(n,t,e,s,l){var x=1,d=n.length,k=t.length;if(s!==void 0&&(s=String(s).toLowerCase(),s==="ucs2"||s==="ucs-2"||s==="utf16le"||s==="utf-16le")){if(n.length<2||t.length<2)return-1;x=2,d/=2,k/=2,e/=2}function N(ae,se){return x===1?ae[se]:ae.readUInt16BE(se*x)}var L;if(l){var G=-1;for(L=e;L<d;L++)if(N(n,L)===N(t,G===-1?0:L-G)){if(G===-1&&(G=L),L-G+1===k)return G*x}else G!==-1&&(L-=L-G),G=-1}else for(e+k>d&&(e=d-k),L=e;L>=0;L--){for(var P=!0,Ft=0;Ft<k;Ft++)if(N(n,L+Ft)!==N(t,Ft)){P=!1;break}if(P)return L}return-1}a.prototype.includes=function(t,e,s){return this.indexOf(t,e,s)!==-1},a.prototype.indexOf=function(t,e,s){return W(this,t,e,s,!0)},a.prototype.lastIndexOf=function(t,e,s){return W(this,t,e,s,!1)};function ht(n,t,e,s){e=Number(e)||0;var l=n.length-e;s?(s=Number(s),s>l&&(s=l)):s=l;var x=t.length;s>x/2&&(s=x/2);for(var d=0;d<s;++d){var k=parseInt(t.substr(d*2,2),16);if(Ct(k))return d;n[e+d]=k}return d}function mt(n,t,e,s){return At(V(t,n.length-e),n,e,s)}function pt(n,t,e,s){return At(Q(t),n,e,s)}function ct(n,t,e,s){return At(lt(t),n,e,s)}function Ut(n,t,e,s){return At(tt(t,n.length-e),n,e,s)}a.prototype.write=function(t,e,s,l){if(e===void 0)l="utf8",s=this.length,e=0;else if(s===void 0&&typeof e=="string")l=e,s=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(s)?(s=s>>>0,l===void 0&&(l="utf8")):(l=s,s=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var x=this.length-e;if((s===void 0||s>x)&&(s=x),t.length>0&&(s<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");l||(l="utf8");for(var d=!1;;)switch(l){case"hex":return ht(this,t,e,s);case"utf8":case"utf-8":return mt(this,t,e,s);case"ascii":case"latin1":case"binary":return pt(this,t,e,s);case"base64":return ct(this,t,e,s);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ut(this,t,e,s);default:if(d)throw new TypeError("Unknown encoding: "+l);l=(""+l).toLowerCase(),d=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function X(n,t,e){return t===0&&e===n.length?i.fromByteArray(n):i.fromByteArray(n.slice(t,e))}function m(n,t,e){e=Math.min(n.length,e);for(var s=[],l=t;l<e;){var x=n[l],d=null,k=x>239?4:x>223?3:x>191?2:1;if(l+k<=e){var N,L,G,P;switch(k){case 1:x<128&&(d=x);break;case 2:N=n[l+1],(N&192)===128&&(P=(x&31)<<6|N&63,P>127&&(d=P));break;case 3:N=n[l+1],L=n[l+2],(N&192)===128&&(L&192)===128&&(P=(x&15)<<12|(N&63)<<6|L&63,P>2047&&(P<55296||P>57343)&&(d=P));break;case 4:N=n[l+1],L=n[l+2],G=n[l+3],(N&192)===128&&(L&192)===128&&(G&192)===128&&(P=(x&15)<<18|(N&63)<<12|(L&63)<<6|G&63,P>65535&&P<1114112&&(d=P))}}d===null?(d=65533,k=1):d>65535&&(d-=65536,s.push(d>>>10&1023|55296),d=56320|d&1023),s.push(d),l+=k}return D(s)}var v=4096;function D(n){var t=n.length;if(t<=v)return String.fromCharCode.apply(String,n);for(var e="",s=0;s<t;)e+=String.fromCharCode.apply(String,n.slice(s,s+=v));return e}function B(n,t,e){var s="";e=Math.min(n.length,e);for(var l=t;l<e;++l)s+=String.fromCharCode(n[l]&127);return s}function U(n,t,e){var s="";e=Math.min(n.length,e);for(var l=t;l<e;++l)s+=String.fromCharCode(n[l]);return s}function A(n,t,e){var s=n.length;(!t||t<0)&&(t=0),(!e||e<0||e>s)&&(e=s);for(var l="",x=t;x<e;++x)l+=Ze[n[x]];return l}function T(n,t,e){for(var s=n.slice(t,e),l="",x=0;x<s.length-1;x+=2)l+=String.fromCharCode(s[x]+s[x+1]*256);return l}a.prototype.slice=function(t,e){var s=this.length;t=~~t,e=e===void 0?s:~~e,t<0?(t+=s,t<0&&(t=0)):t>s&&(t=s),e<0?(e+=s,e<0&&(e=0)):e>s&&(e=s),e<t&&(e=t);var l=this.subarray(t,e);return Object.setPrototypeOf(l,a.prototype),l};function O(n,t,e){if(n%1!==0||n<0)throw new RangeError("offset is not uint");if(n+t>e)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(t,e,s){t=t>>>0,e=e>>>0,s||O(t,e,this.length);for(var l=this[t],x=1,d=0;++d<e&&(x*=256);)l+=this[t+d]*x;return l},a.prototype.readUintBE=a.prototype.readUIntBE=function(t,e,s){t=t>>>0,e=e>>>0,s||O(t,e,this.length);for(var l=this[t+--e],x=1;e>0&&(x*=256);)l+=this[t+--e]*x;return l},a.prototype.readUint8=a.prototype.readUInt8=function(t,e){return t=t>>>0,e||O(t,1,this.length),this[t]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||O(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||O(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||O(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||O(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,e,s){t=t>>>0,e=e>>>0,s||O(t,e,this.length);for(var l=this[t],x=1,d=0;++d<e&&(x*=256);)l+=this[t+d]*x;return x*=128,l>=x&&(l-=Math.pow(2,8*e)),l},a.prototype.readIntBE=function(t,e,s){t=t>>>0,e=e>>>0,s||O(t,e,this.length);for(var l=e,x=1,d=this[t+--l];l>0&&(x*=256);)d+=this[t+--l]*x;return x*=128,d>=x&&(d-=Math.pow(2,8*e)),d},a.prototype.readInt8=function(t,e){return t=t>>>0,e||O(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},a.prototype.readInt16LE=function(t,e){t=t>>>0,e||O(t,2,this.length);var s=this[t]|this[t+1]<<8;return s&32768?s|4294901760:s},a.prototype.readInt16BE=function(t,e){t=t>>>0,e||O(t,2,this.length);var s=this[t+1]|this[t]<<8;return s&32768?s|4294901760:s},a.prototype.readInt32LE=function(t,e){return t=t>>>0,e||O(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return t=t>>>0,e||O(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,e){return t=t>>>0,e||O(t,4,this.length),o.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return t=t>>>0,e||O(t,4,this.length),o.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||O(t,8,this.length),o.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||O(t,8,this.length),o.read(this,t,!1,52,8)};function I(n,t,e,s,l,x){if(!a.isBuffer(n))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>l||t<x)throw new RangeError('"value" argument is out of bounds');if(e+s>n.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(t,e,s,l){if(t=+t,e=e>>>0,s=s>>>0,!l){var x=Math.pow(2,8*s)-1;I(this,t,e,s,x,0)}var d=1,k=0;for(this[e]=t&255;++k<s&&(d*=256);)this[e+k]=t/d&255;return e+s},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(t,e,s,l){if(t=+t,e=e>>>0,s=s>>>0,!l){var x=Math.pow(2,8*s)-1;I(this,t,e,s,x,0)}var d=s-1,k=1;for(this[e+d]=t&255;--d>=0&&(k*=256);)this[e+d]=t/k&255;return e+s},a.prototype.writeUint8=a.prototype.writeUInt8=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,1,255,0),this[e]=t&255,e+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(t,e,s){return t=+t,e=e>>>0,s||I(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},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(t,e,s){return t=+t,e=e>>>0,s||I(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},a.prototype.writeIntLE=function(t,e,s,l){if(t=+t,e=e>>>0,!l){var x=Math.pow(2,8*s-1);I(this,t,e,s,x-1,-x)}var d=0,k=1,N=0;for(this[e]=t&255;++d<s&&(k*=256);)t<0&&N===0&&this[e+d-1]!==0&&(N=1),this[e+d]=(t/k>>0)-N&255;return e+s},a.prototype.writeIntBE=function(t,e,s,l){if(t=+t,e=e>>>0,!l){var x=Math.pow(2,8*s-1);I(this,t,e,s,x-1,-x)}var d=s-1,k=1,N=0;for(this[e+d]=t&255;--d>=0&&(k*=256);)t<0&&N===0&&this[e+d+1]!==0&&(N=1),this[e+d]=(t/k>>0)-N&255;return e+s},a.prototype.writeInt8=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1},a.prototype.writeInt16LE=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2},a.prototype.writeInt16BE=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2},a.prototype.writeInt32LE=function(t,e,s){return t=+t,e=e>>>0,s||I(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},a.prototype.writeInt32BE=function(t,e,s){return t=+t,e=e>>>0,s||I(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};function R(n,t,e,s,l,x){if(e+s>n.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function H(n,t,e,s,l){return t=+t,e=e>>>0,l||R(n,t,e,4),o.write(n,t,e,s,23,4),e+4}a.prototype.writeFloatLE=function(t,e,s){return H(this,t,e,!0,s)},a.prototype.writeFloatBE=function(t,e,s){return H(this,t,e,!1,s)};function C(n,t,e,s,l){return t=+t,e=e>>>0,l||R(n,t,e,8),o.write(n,t,e,s,52,8),e+8}a.prototype.writeDoubleLE=function(t,e,s){return C(this,t,e,!0,s)},a.prototype.writeDoubleBE=function(t,e,s){return C(this,t,e,!1,s)},a.prototype.copy=function(t,e,s,l){if(!a.isBuffer(t))throw new TypeError("argument should be a Buffer");if(s||(s=0),!l&&l!==0&&(l=this.length),e>=t.length&&(e=t.length),e||(e=0),l>0&&l<s&&(l=s),l===s||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(s<0||s>=this.length)throw new RangeError("Index out of range");if(l<0)throw new RangeError("sourceEnd out of bounds");l>this.length&&(l=this.length),t.length-e<l-s&&(l=t.length-e+s);var x=l-s;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,s,l):Uint8Array.prototype.set.call(t,this.subarray(s,l),e),x},a.prototype.fill=function(t,e,s,l){if(typeof t=="string"){if(typeof e=="string"?(l=e,e=0,s=this.length):typeof s=="string"&&(l=s,s=this.length),l!==void 0&&typeof l!="string")throw new TypeError("encoding must be a string");if(typeof l=="string"&&!a.isEncoding(l))throw new TypeError("Unknown encoding: "+l);if(t.length===1){var x=t.charCodeAt(0);(l==="utf8"&&x<128||l==="latin1")&&(t=x)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<s)throw new RangeError("Out of range index");if(s<=e)return this;e=e>>>0,s=s===void 0?this.length:s>>>0,t||(t=0);var d;if(typeof t=="number")for(d=e;d<s;++d)this[d]=t;else{var k=a.isBuffer(t)?t:a.from(t,l),N=k.length;if(N===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(d=0;d<s-e;++d)this[d+e]=k[d%N]}return this};var K=/[^+/0-9A-Za-z-_]/g;function Y(n){if(n=n.split("=")[0],n=n.trim().replace(K,""),n.length<2)return"";for(;n.length%4!==0;)n=n+"=";return n}function V(n,t){t=t||1/0;for(var e,s=n.length,l=null,x=[],d=0;d<s;++d){if(e=n.charCodeAt(d),e>55295&&e<57344){if(!l){if(e>56319){(t-=3)>-1&&x.push(239,191,189);continue}else if(d+1===s){(t-=3)>-1&&x.push(239,191,189);continue}l=e;continue}if(e<56320){(t-=3)>-1&&x.push(239,191,189),l=e;continue}e=(l-55296<<10|e-56320)+65536}else l&&(t-=3)>-1&&x.push(239,191,189);if(l=null,e<128){if((t-=1)<0)break;x.push(e)}else if(e<2048){if((t-=2)<0)break;x.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;x.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;x.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return x}function Q(n){for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e)&255);return t}function tt(n,t){for(var e,s,l,x=[],d=0;d<n.length&&!((t-=2)<0);++d)e=n.charCodeAt(d),s=e>>8,l=e%256,x.push(l),x.push(s);return x}function lt(n){return i.toByteArray(Y(n))}function At(n,t,e,s){for(var l=0;l<s&&!(l+e>=t.length||l>=n.length);++l)t[l+e]=n[l];return l}function it(n,t){return n instanceof t||n!=null&&n.constructor!=null&&n.constructor.name!=null&&n.constructor.name===t.name}function Ct(n){return n!==n}var Ze=function(){for(var n="0123456789abcdef",t=new Array(256),e=0;e<16;++e)for(var s=e*16,l=0;l<16;++l)t[s+l]=n[e]+n[l];return t}()})(Fe);/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(r,i){var o=Fe,p=o.Buffer;function u(c,a){for(var h in c)a[h]=c[h]}p.from&&p.alloc&&p.allocUnsafe&&p.allocUnsafeSlow?r.exports=o:(u(o,i),i.Buffer=f);function f(c,a,h){return p(c,a,h)}f.prototype=Object.create(p.prototype),u(p,f),f.from=function(c,a,h){if(typeof c=="number")throw new TypeError("Argument must not be a number");return p(c,a,h)},f.alloc=function(c,a,h){if(typeof c!="number")throw new TypeError("Argument must be a number");var g=p(c);return a!==void 0?typeof h=="string"?g.fill(a,h):g.fill(a):g.fill(0),g},f.allocUnsafe=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return p(c)},f.allocUnsafeSlow=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return o.SlowBuffer(c)}})(Rt,Rt.exports);var Zt=Rt.exports,Be=Zt.Buffer;function Dt(r,i){this._block=Be.alloc(r),this._finalSize=i,this._blockSize=r,this._len=0}Dt.prototype.update=function(r,i){typeof r=="string"&&(i=i||"utf8",r=Be.from(r,i));for(var o=this._block,p=this._blockSize,u=r.length,f=this._len,c=0;c<u;){for(var a=f%p,h=Math.min(u-c,p-a),g=0;g<h;g++)o[a+g]=r[c+g];f+=h,c+=h,f%p===0&&this._update(o)}return this._len+=u,this};Dt.prototype.digest=function(r){var i=this._len%this._blockSize;this._block[i]=128,this._block.fill(0,i+1),i>=this._finalSize&&(this._update(this._block),this._block.fill(0));var o=this._len*8;if(o<=4294967295)this._block.writeUInt32BE(o,this._blockSize-4);else{var p=(o&4294967295)>>>0,u=(o-p)/4294967296;this._block.writeUInt32BE(u,this._blockSize-8),this._block.writeUInt32BE(p,this._blockSize-4)}this._update(this._block);var f=this._hash();return r?f.toString(r):f};Dt.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var Ie=Dt,vr=Ae,je=Ie,_r=Zt.Buffer,Ar=[1518500249,1859775393,-1894007588,-899497514],Fr=new Array(80);function vt(){this.init(),this._w=Fr,je.call(this,64,56)}vr(vt,je);vt.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Or(r){return r<<1|r>>>31}function Br(r){return r<<5|r>>>27}function Ir(r){return r<<30|r>>>2}function jr(r,i,o,p){return r===0?i&o|~i&p:r===2?i&o|i&p|o&p:i^o^p}vt.prototype._update=function(r){for(var i=this._w,o=this._a|0,p=this._b|0,u=this._c|0,f=this._d|0,c=this._e|0,a=0;a<16;++a)i[a]=r.readInt32BE(a*4);for(;a<80;++a)i[a]=Or(i[a-3]^i[a-8]^i[a-14]^i[a-16]);for(var h=0;h<80;++h){var g=~~(h/20),y=Br(o)+jr(g,p,u,f)+c+i[h]+Ar[g]|0;c=f,f=u,u=Ir(p),p=o,o=y}this._a=o+this._a|0,this._b=p+this._b|0,this._c=u+this._c|0,this._d=f+this._d|0,this._e=c+this._e|0};vt.prototype._hash=function(){var r=_r.allocUnsafe(20);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};var Dr=vt;const Tr=Kt(Dr);var kr=Ae,De=Ie,Ur=Zt.Buffer,Cr=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],$r=new Array(64);function _t(){this.init(),this._w=$r,De.call(this,64,56)}kr(_t,De);_t.prototype.init=function(){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};function Nr(r,i,o){return o^r&(i^o)}function zr(r,i,o){return r&i|o&(r|i)}function Mr(r){return(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10)}function Rr(r){return(r>>>6|r<<26)^(r>>>11|r<<21)^(r>>>25|r<<7)}function Lr(r){return(r>>>7|r<<25)^(r>>>18|r<<14)^r>>>3}function Pr(r){return(r>>>17|r<<15)^(r>>>19|r<<13)^r>>>10}_t.prototype._update=function(r){for(var i=this._w,o=this._a|0,p=this._b|0,u=this._c|0,f=this._d|0,c=this._e|0,a=this._f|0,h=this._g|0,g=this._h|0,y=0;y<16;++y)i[y]=r.readInt32BE(y*4);for(;y<64;++y)i[y]=Pr(i[y-2])+i[y-7]+Lr(i[y-15])+i[y-16]|0;for(var b=0;b<64;++b){var F=g+Rr(c)+Nr(c,a,h)+Cr[b]+i[b]|0,j=Mr(o)+zr(o,p,u)|0;g=h,h=a,a=c,c=f+F|0,f=u,u=p,p=o,o=F+j|0}this._a=o+this._a|0,this._b=p+this._b|0,this._c=u+this._c|0,this._d=f+this._d|0,this._e=c+this._e|0,this._f=a+this._f|0,this._g=h+this._g|0,this._h=g+this._h|0};_t.prototype._hash=function(){var r=Ur.allocUnsafe(32);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};var qr=_t;const Hr=Kt(qr),Yt=new Error("File system not available.");function Jr(r,i,o){throw Yt}function Te(r){throw Yt}function Wr(r){throw Yt}const Xr=async r=>Te(),Vr={sha1:Tr,sha256:Hr},Tt=(r,i="sha1")=>{if(!["sha1","sha256"].includes(i))throw new Error("Hashing algorithm not supported: Available: sha1, sha256");const o=Vr[i];return new o().update(r).digest("base64")};function ke(r){const i=[],o=Object.keys(r);for(const p of o){const u=r[p].sort((f,c)=>f.index-c.index);for(let f=0;f<u.length;f++)u[f].index!==f&&i.push({message:`Invalid operation index ${u[f].index} at position ${f}`,details:{position:f,operation:u[f],scope:u[f].scope}})}return i}const Qt=async r=>{const i=new pe,{name:o,revision:p,documentType:u,created:f,lastModified:c}=r,a={name:o,revision:p,documentType:u,created:f,lastModified:c};return i.file("header.json",JSON.stringify(a,null,2)),i.file("state.json",JSON.stringify(r.initialState||{},null,2)),i.file("operations.json",JSON.stringify(r.operations,null,2)),Object.keys(r.attachments).forEach(g=>{const{data:y,...b}=r.attachments[g];i.file(g,y,{base64:!0,createFolders:!0,comment:JSON.stringify(b)})}),i},Ue=async(r,i,o,p)=>{await(await Qt(r)).generateAsync({type:"uint8array",streamFiles:!0});const f=p??r.name,c=`.${o}.zip`;return Jr(i,f.endsWith(c)?f:`${f}${c}`)},Kr=async(r,i)=>{const p=await(await Qt(r)).generateAsync({type:"blob"}),u=await i.createWritable();await u.write(p),await u.close()},Lt=async(r,i,o)=>{const p=Te();return Ce(p,i,o)},Ce=async(r,i,o)=>{const p=new pe;return await p.loadAsync(r),Gr(p,i,o)};async function Gr(r,i,o){const p=r.file("state.json");if(!p)throw new Error("Initial state not found");const u=await p.async("string"),f=JSON.parse(u),c=r.file("header.json");let a;c&&(a=JSON.parse(await c.async("string")));const h=r.file("operations.json");if(!h)throw new Error("Operations history not found");const g=JSON.parse(await h.async("string")),y=ke(g);if(y.length){const F=y.map(j=>j.message);throw new Error(F.join(`
|
|
25
|
-
`))}let b=ie(f,g,i,void 0,a,{},o);return a&&(b={...b,...a}),b}function $e(r){const i=r.replace(/^.*\./,"")||void 0,o=r.replace(/^.*[/\\]/,"")||void 0;return{extension:i,fileName:o}}async function Zr(r){const{buffer:i,mimeType:o="application/octet-stream"}=await Wr(),p=$e(r),u=i.toString("base64");return{data:u,hash:Tt(u),mimeType:o,...p}}async function Yr(r){const i=await Xr(),o=mr.getType(r)||"application/octet-stream",p=$e(r),u=i.toString("base64");return{data:u,hash:Tt(u),mimeType:o,...p}}var Ne=(r=>(r.UNEXPECTED_INDEX="UNEXPECTED_INDEX",r))(Ne||{}),ze=(r=>(r.DUPLICATED_INDEX="DUPLICATED_INDEX",r.MISSING_INDEX="MISSING_INDEX",r))(ze||{});function te(r){const i=[];let o=-1;for(const p of r){const u=p.index-p.skip;u!==o+1&&i.push({operation:{index:p.index,skip:p.skip},issue:"UNEXPECTED_INDEX",category:u>o+1?"MISSING_INDEX":"DUPLICATED_INDEX",message:`Expected index ${o+1} with skip 0 or equivalent, got index ${p.index} with skip ${p.skip}`}),o=p.index}return i}function at(r){var p,u,f;const i=[];let o=r.length-1;for(;o>-1;){i.unshift(r[o]);const c=(((p=r[o])==null?void 0:p.index)||0)-(((u=r[o])==null?void 0:u.skip)||0)-1;let a=o-1;for(;a>-1&&(((f=r[a])==null?void 0:f.index)||0)>c;)a--;o=a}return i}function Qr(r){const i=[...r],o=i[i.length-1];return o&&(o.type==="NOOP"?i.push({...o,index:o.index,type:"NOOP",skip:Le(r)}):i.push({type:"NOOP",index:o.index+1,timestamp:new Date().toISOString(),input:{},skip:1,scope:o.scope,hash:o.hash})),i}function st(r){return r.slice().sort((i,o)=>i.skip-o.skip).sort((i,o)=>i.index-o.index)}const ti=(r,i,o)=>[...i,...o].sort((p,u)=>new Date(p.timestamp).getTime()-new Date(u.timestamp).getTime()).map((p,u)=>({...p,index:r.index+u,skip:u===0?r.skip:0})),ei=(r,i,o)=>[...i,...o].sort((p,u)=>new Date(p.timestamp).getTime()-new Date(u.timestamp).getTime()).sort((p,u)=>p.index-u.index).map((p,u)=>({...p,index:r.index+u,skip:u===0?r.skip:0}));function ee(r,i){return gt(r)===gt(i)}function ri(r,i){const o=at(st(r.slice())),p=at(st(i.slice()));if(o.length<1)return[p,[]];const u=[];let f=!1;for(;p.length>0;){const c=p[0];let a=o.shift();for(;a&&Me(a,c);)u.push(a),a=o.shift();if(a?f||(ee(a,c)?(p.shift(),u.push(a)):(o.unshift(a),f=!0)):f=!0,f){let h=p.shift();for(;h;)u.push(h),h=p.shift()}}if(!f){let c=o.shift();for(;c;)u.push(c),c=o.shift()}return[at(u),o]}function Me(r,i){return r.index<i.index||r.index===i.index&&r.skip<i.skip}function Re(r,i){const o=[],p=[],u=[],f=Math.max(r.length,i.length);let c=!1;for(let a=0;a<f;a++){const h=r[a],g=i[a];h&&g?!c&&ee(h,g)?o.push(h):(c=!0,p.push(h),u.push(g)):h?p.push(h):g&&u.push(g)}return[o,p,u]}function ii(r,i,o){const[p,u,f]=Re(at(r),at(i)),c=Nt(p),a=1+Math.max(c,Nt(u),Nt(f)),h=o({index:a,skip:a-(c+1)},u,f);return p.concat(h)}function Nt(r){const i=r[r.length-1];return i?i.index:-1}function Le(r){var p,u,f;if(r.length<1)return-1;const i=at(r);let o=(((p=i[i.length-1])==null?void 0:p.skip)||0)+1;return i.length>1&&(o+=((u=i[i.length-2])==null?void 0:u.skip)||0),(((f=i[i.length-1])==null?void 0:f.index)||-1)<o?-1:o}const ni=r=>te(at(st(r))),oi=r=>r.reduce((o,p)=>{var u;return o[p.scope]||(o[p.scope]=[]),(u=o[p.scope])==null||u.push(p),o},{}),ai=(r,i)=>{var h;const o={integrityIssues:[],validOperations:[],invalidOperations:[],duplicatedOperations:[]},p=st(r),u=st(i),f=te([...p,...u]),a=(h=[...f.filter(g=>g.category==="MISSING_INDEX")].sort((g,y)=>y.operation.index-g.operation.index).pop())==null?void 0:h.operation;for(const g of u){if(a&&g.index>=a.index){o.invalidOperations.push(g);continue}if(f.some(b=>b.operation.index===g.index&&b.operation.skip===g.skip&&b.category==="DUPLICATED_INDEX")){o.duplicatedOperations.push(g);continue}o.validOperations.push(g)}return o.integrityIssues.push(...f),o};function si(r,i){return r.filter(o=>!i.some(p=>o.type==="NOOP"&&o.skip===0&&o.index===p.index||o.index===p.index&&o.skip===p.skip&&o.scope===p.scope&&o.hash===p.hash&&o.type===p.type))}function Pe(r,i){const[o]=st(r).slice(-1),p=(o==null?void 0:o.index)??-1,u=p+1,f={...i,index:i.index??u};if(f.index<p)throw new Error(`The skip header operation index must be greater than or equal to ${p}`);return(at(st([...r,f]))||[]).slice(0,-1)}function Pt(r){return{...Object.entries(r).reduce((o,p)=>{const[u,f]=p;return{...o,[u]:at(st(f))}},{})}}const pi=Object.freeze(Object.defineProperty({__proto__:null,IntegrityIssueSubType:ze,IntegrityIssueType:Ne,addUndo:Qr,attachBranch:ri,checkCleanedOperationsIntegrity:te,checkOperationsIntegrity:ni,garbageCollect:at,garbageCollectDocumentOperations:Pt,groupOperationsByScope:oi,merge:ii,nextSkipNumber:Le,operationsAreEqual:ee,precedes:Me,prepareOperations:ai,removeExistingOperations:si,reshuffleByTimestamp:ti,reshuffleByTimestampAndIndex:ei,skipHeaderOperations:Pe,sortOperations:st,split:Re},Symbol.toStringTag,{value:"Module"}));function ci(r,i){let o;return"index"in i?o={...i}:o=r.operations[i.scope].at(-1),((o==null?void 0:o.index)??-1)+1}function li(r,i){return{...r,revision:{...r.revision,[i.scope]:ci(r,i)},lastModified:new Date().toISOString()}}function ui(r,i,o=0,p=!1){if([bt,St,It].includes(i.type))return r;const{scope:u}=i,f=r.operations[u].slice(),c=f.at(-1);let a=((c==null?void 0:c.index)??-1)+1;if("index"in i){if(i.index-o>a)throw new Error(`Missing operations: expected ${a} with skip 0 or equivalent, got index ${i.index} with skip ${o}`);a=i.index}const h={...i,index:a,timestamp:new Date().toISOString(),hash:"",scope:u,skip:o,error:void 0};return p&&(h.resultingState=r.state[u]),f.push(h),{...r,operations:{...r.operations,[u]:f}}}function fi(r,i,o=0,p=!1){let u=ui(r,i,o,p);return u=li(u,i),u}function hi(r,i,o){switch(xe().parse(i),i.type){case Se:return sr(r,i.input);case It:return lr(r,i,o);case ve:return ur(r,i.input.state);default:return r}}function mi(r,i,o){switch(i.type){case bt:return pr(r,i,o);case St:return cr(r,i,o);default:return{document:r,action:i,skip:o}}}function xi(r,i,o,p,u=!1,f=ne){const c=i.scope,a=r.operations[c].at(-1);if(!a)return r;const h=Pt({...r.operations,[c]:Pe(r.operations[c],a)});let g;const y=h[c].at(-1);if(u&&(y!=null&&y.resultingState))g=f(y.resultingState);else{const{state:b}=Bt(r.initialState,h,o,void 0,void 0,void 0,void 0,{reuseHash:!0,reuseOperationResultingState:u,operationResultingStateParser:f});g=b[c]}return{...r,state:{...r.state,[c]:g},operations:Pt({...r.operations})}}function re(r,i,o,p,u={}){const{skip:f,ignoreSkipOperations:c=!1,reuseHash:a=!1,reuseOperationResultingState:h=!1,operationResultingStateParser:g}=u,y={...i},b=f||0;let F={...r};const j=!c&&(b>0||"index"in y&&y.skip>0);return qt(y)&&(F=hi(F,y,o)),F=fi(F,y,b,h),j&&(F=xi(F,y,o,b,h,g)),F=nt.produce(F,$=>{try{const q=o($.state,y,p);if(q)return nt.castDraft({...F,state:q})}catch(q){const Z=F.operations[y.scope].length-1;$.operations[y.scope][Z].error=q.message,$.operations[y.scope][Z].skip=0,j&&($.state=nt.castDraft({...r.state}),$.operations=nt.castDraft({...r.operations,[y.scope]:[...r.operations[y.scope],{...$.operations[y.scope][Z]}]}))}}),nt.produce(F,$=>{if([bt,St,It].includes(y.type))return $;const q=y.scope||"global",Z=a&&Object.prototype.hasOwnProperty.call(y,"hash")?y.hash:kt($,q);$.operations[q][$.operations[q].length-1].hash=Z,!qt(y)&&y.attachments&&y.attachments.forEach(w=>{const{hash:E,...S}=w;$.attachments[E]={...S}})})}function di(r){return r.type===fr&&r.skip!==void 0&&r.skip>0&&r.hash!==void 0}function gi(r){return[bt,St].includes(r.type)}function qt(r){return[Se,bt,St,It,ve].includes(r.type)}function ft(r,i,o,p,u="global"){if(!r)throw new Error("Empty action type");if(typeof r!="string")throw new Error(`Invalid action type: ${JSON.stringify(r)}`);const f={type:r,input:i,scope:u};o&&(f.attachments=o);try{p==null||p().parse(f.input)}catch(c){throw new Error(`Invalid action input: ${c}`)}return f}function qe(r,i=re){return(o,p,u,f)=>i(o,p,r,u,f)}const He=(r,i)=>({name:"",documentType:"",revision:{global:0,local:0},created:new Date().toISOString(),lastModified:new Date().toISOString(),attachments:{},...r,state:(i==null?void 0:i(r==null?void 0:r.state))??(r==null?void 0:r.state)??{global:{},local:{}}}),Je=(r,i)=>{const o=He(r,i);return{...o,initialState:o,operations:{global:[],local:[]},clipboard:[]}},kt=(r,i="global")=>Tt(gt(r.state[i]||"")),yi=(r,i=1e3)=>{const o=Math.random()*i;return Tt(`${(r??new Date).toISOString()}${o}`)};function wt(r){return nt.castImmutable(nt.freeze(r,!0))}function wi(r,i){const o=[...r];let p=i||0,u=o.length>0?o[o.length-1].index:0;const f=[];for(const c of o.reverse()){if(p>0){const g=u-c.index;p-=g}if(p<0)throw new Error("Invalid operation index, missing operations");const a={ignore:p>0,operation:c},h=c.skip>0?c.skip+1:0;if(h>0&&h>p){const g=h-p;p=p+g}u=c.index,f.push(a)}return f.reverse()}function Ei(r,i,o){const p=r.slice().sort((a,h)=>a.skip-h.skip).sort((a,h)=>a.index-h.index);let u=o,f=0,c=i;for(const a of p.reverse()){const h=c-a.index;if(u=u-h,u>-1)f++,c=a.index;else break}return f}function bi(r){return Object.values(r).flatMap(i=>i).sort((i,o)=>new Date(i.timestamp).getTime()-new Date(o.timestamp).getTime())}function Si(r){return Object.values(r).flatMap(i=>i).sort((i,o)=>new Date(i.operation.timestamp).getTime()-new Date(o.operation.timestamp).getTime())}function Bt(r,i,o,p,u,f=re,c={},a){const h=qe(o,f);return ie(r,i,h,p,u,c,a)}function ie(r,i,o,p,u,f={},c){const{checkHashes:a=!0,reuseOperationResultingState:h,operationResultingStateParser:g=ne}=c||{};let y=r;const b=[],F={global:[],local:[]};if(h)for(const[w,E]of Object.entries(i)){const S=E.findLastIndex(J=>!!J.resultingState);if(S<0){b.push(...E);continue}const M=E[S];try{const J=g(M.resultingState);y={...y,state:{...y.state,[w]:J}},F[w].push(...E.slice(0,S+1)),b.push(...E.slice(S+1))}catch{b.push(...E)}}else b.push(...Object.values(i).flat());const j=Je(y);j.initialState=r,j.operations=F;const $=b.reduce((w,E)=>o(w,E,p,{skip:E.skip,ignoreSkipOperations:!0,reuseHash:!a}),j);if(!a)for(const w of Object.keys($.state))for(let E=b.length-1;E>=0;E--){const S=b[E];if(S.scope===w){if(S.hash!==kt($,w))throw new Error(`Hash mismatch for scope ${w}`);break}}const q=Object.keys($.operations).reduce((w,E)=>{const S=E;return{...w,[S]:[...$.operations[S].map((M,J)=>{var W;return{...M,timestamp:((W=i[S][J])==null?void 0:W.timestamp)??M.timestamp}})]}},{global:[],local:[]}),Z=Object.values(q).reduce((w,E)=>{const S=E[E.length-1];return(S==null?void 0:S.timestamp)>w&&(w=S.timestamp),w},r.lastModified);return{...$,operations:q,lastModified:Z}}function vi(r,i){return gt(r)===gt(i)}function ne(r){const i=typeof r;if(i==="string")return JSON.parse(r);if(i==="object")return r;throw new Error(`Providing resulting state is of type: ${i}`)}const We=r=>ft("SET_NAME",r,void 0,Xt,void 0),Xe=(r=1,i="global")=>ft("UNDO",r,void 0,Vt,i),Ve=(r=1,i="global")=>ft("REDO",r,void 0,Wt,i),Ke=(r,i,o="global")=>ft("PRUNE",{start:r,end:i},void 0,Jt,o),oe=(r,i)=>ft("LOAD_STATE",{state:r,operations:i},void 0,Ht),Ge=(r="global")=>ft("NOOP",{},void 0,void 0,r),_i=Object.freeze(Object.defineProperty({__proto__:null,loadState:oe,noop:Ge,prune:Ke,redo:Ve,setName:We,undo:Xe},Symbol.toStringTag,{value:"Module"}));class Ai{constructor(i,o,p){Ot(this,"_document");Ot(this,"_reducer");Ot(this,"_signalDispatch");this._reducer=i,this._document=o,this._signalDispatch=p}dispatch(i,o){return this._document=this._reducer(this._document,i,this._signalDispatch,o),this}saveToFile(i,o,p){return Ue(this._document,i,o,p)}async loadFromFile(i){this._document=await Lt(i,this._reducer)}static async stateFromFile(i,o){return await Lt(i,o)}get state(){return wt(this._document.state)}get operations(){return wt(this._document.operations)}get name(){return this._document.name}get documentType(){return this._document.documentType}get created(){return this._document.created}get lastModified(){return this._document.lastModified}get revision(){return this._document.revision.global}getRevision(i){return this._document.revision[i]}get initialState(){return wt(this._document.initialState)}toDocument(){return wt(this._document)}getAttachment(i){return this._document.attachments[i]}setName(i){return this.dispatch(We(i)),this}undo(i){return this.dispatch(Xe(i)),this}redo(i){return this.dispatch(Ve(i)),this}prune(i,o){return this.dispatch(Ke(i,o)),this}loadState(i,o){return this.dispatch(oe(i,o)),this}}function Fi(r,i){i.forEach(o=>{Object.getOwnPropertyNames(o.prototype).forEach(p=>{Object.defineProperty(r.prototype,p,Object.getOwnPropertyDescriptor(o.prototype,p)||Object.create(null))})})}exports.BaseActions=_i;exports.BaseDocument=Ai;exports.applyMixins=Fi;exports.baseReducer=re;exports.calculateSkipsLeft=Ei;exports.createAction=ft;exports.createDocument=Je;exports.createExtendedState=He;exports.createReducer=qe;exports.createZip=Qt;exports.documentHelpers=pi;exports.getLocalFile=Yr;exports.getRemoteFile=Zr;exports.hashDocument=kt;exports.hashKey=yi;exports.isBaseAction=qt;exports.isNoopOperation=di;exports.isSameDocument=vi;exports.isUndoRedo=gi;exports.loadFromFile=Lt;exports.loadFromInput=Ce;exports.mapSkippedOperations=wi;exports.parseResultingState=ne;exports.processUndoRedo=mi;exports.readOnly=wt;exports.replayDocument=ie;exports.replayOperations=Bt;exports.saveToFile=Ue;exports.saveToFileHandle=Kr;exports.sortMappedOperations=Si;exports.sortOperations=bi;exports.validateOperations=ke;exports.zod=or;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { j as e, f as a, b as s, a as t, c as o, k as r, m as i, n, o as l, p as c, q as p, i as d, r as u, t as m, u as O, l as y, e as S, v as b, w as g, x as D, y as F, z as _, s as f, d as v, A as R, C as h, D as j, B as x, h as z, g as A, E as B, F as M, G as T } from "./object-iTBekDVP.js";
|
|
2
|
-
const k = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3
|
-
__proto__: null,
|
|
4
|
-
calculateSkipsLeft: e,
|
|
5
|
-
createAction: a,
|
|
6
|
-
createDocument: s,
|
|
7
|
-
createExtendedState: t,
|
|
8
|
-
createReducer: o,
|
|
9
|
-
createZip: r,
|
|
10
|
-
documentHelpers: i,
|
|
11
|
-
getLocalFile: n,
|
|
12
|
-
getRemoteFile: l,
|
|
13
|
-
hashDocument: c,
|
|
14
|
-
hashKey: p,
|
|
15
|
-
isBaseAction: d,
|
|
16
|
-
isNoopOperation: u,
|
|
17
|
-
isSameDocument: m,
|
|
18
|
-
isUndoRedo: O,
|
|
19
|
-
loadFromFile: y,
|
|
20
|
-
loadFromInput: S,
|
|
21
|
-
mapSkippedOperations: b,
|
|
22
|
-
parseResultingState: g,
|
|
23
|
-
readOnly: D,
|
|
24
|
-
replayDocument: F,
|
|
25
|
-
replayOperations: _,
|
|
26
|
-
saveToFile: f,
|
|
27
|
-
saveToFileHandle: v,
|
|
28
|
-
sortMappedOperations: R,
|
|
29
|
-
sortOperations: h,
|
|
30
|
-
validateOperations: j
|
|
31
|
-
}, Symbol.toStringTag, { value: "Module" })), H = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
32
|
-
__proto__: null,
|
|
33
|
-
BaseDocument: x,
|
|
34
|
-
actions: z,
|
|
35
|
-
applyMixins: A,
|
|
36
|
-
baseReducer: B,
|
|
37
|
-
processUndoRedo: M,
|
|
38
|
-
utils: k,
|
|
39
|
-
z: T
|
|
40
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
41
|
-
export {
|
|
42
|
-
H as D,
|
|
43
|
-
k as i
|
|
44
|
-
};
|