document-model 2.10.0 → 2.11.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 +2 -2
- package/dist/browser/cjs/document.js +2 -2
- package/dist/browser/cjs/index.js +2 -2
- package/dist/{node/cjs/internal/index-C-PLtWC-.js → browser/cjs/internal/index-B62DRxDu.js} +3 -2
- package/dist/browser/cjs/internal/index-B62DRxDu.js.map +1 -0
- package/dist/browser/cjs/internal/{index-CzQJ-QEl.js → index-hPntrUvN.js} +2 -2
- package/dist/browser/cjs/internal/{index-CzQJ-QEl.js.map → index-hPntrUvN.js.map} +1 -1
- package/dist/browser/cjs/internal/{object-7HaOcSJT.js → object-BdIbCX0K.js} +9 -2
- package/dist/browser/cjs/internal/object-BdIbCX0K.js.map +1 -0
- package/dist/browser/es/document-model.js +2 -2
- package/dist/browser/es/document.js +8 -8
- package/dist/browser/es/index.js +2 -2
- package/dist/browser/es/internal/{index-BC9vqWum.js → index-CPWf201E.js} +3 -2
- package/dist/browser/es/internal/index-CPWf201E.js.map +1 -0
- package/dist/browser/es/internal/{index-Bx0Cqbbj.js → index-D_fwH6L3.js} +2 -2
- package/dist/browser/es/internal/{index-Bx0Cqbbj.js.map → index-D_fwH6L3.js.map} +1 -1
- package/dist/browser/es/internal/{object-C0mdRngQ.js → object-oB7gkKNr.js} +34 -27
- package/dist/browser/es/internal/object-oB7gkKNr.js.map +1 -0
- package/dist/browser/src/document/reducer.d.ts.map +1 -1
- package/dist/browser/src/document/utils/base.d.ts +1 -0
- package/dist/browser/src/document/utils/base.d.ts.map +1 -1
- package/dist/node/cjs/document-model.js +3 -3
- package/dist/node/cjs/document.js +2 -2
- package/dist/node/cjs/index.js +2 -2
- package/dist/node/cjs/internal/{index-C9U6XZGR.js → index-Bsyn7lZ0.js} +3 -3
- package/dist/node/cjs/internal/{index-C9U6XZGR.js.map → index-Bsyn7lZ0.js.map} +1 -1
- package/dist/{browser/cjs/internal/index-caIc0sFL.js → node/cjs/internal/index-DozfRrse.js} +3 -2
- package/dist/node/cjs/internal/index-DozfRrse.js.map +1 -0
- package/dist/node/cjs/internal/{object-CEHSqR4q.js → object-DqFXYK4g.js} +9 -2
- package/dist/node/cjs/internal/object-DqFXYK4g.js.map +1 -0
- package/dist/node/es/document-model.js +3 -3
- package/dist/node/es/document.js +8 -8
- package/dist/node/es/index.js +2 -2
- package/dist/node/es/internal/{index-DMRiWhIW.js → index-Bf87b5UD.js} +3 -2
- package/dist/node/es/internal/index-Bf87b5UD.js.map +1 -0
- package/dist/node/es/internal/{index-CptzZsxD.js → index-D4oqm7Ua.js} +3 -3
- package/dist/node/es/internal/{index-CptzZsxD.js.map → index-D4oqm7Ua.js.map} +1 -1
- package/dist/node/es/internal/{object-CnIwQbbO.js → object-2XgKQb4s.js} +34 -27
- package/dist/node/es/internal/object-2XgKQb4s.js.map +1 -0
- package/dist/node/src/document/reducer.d.ts.map +1 -1
- package/dist/node/src/document/utils/base.d.ts +1 -0
- package/dist/node/src/document/utils/base.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/browser/cjs/internal/index-caIc0sFL.js.map +0 -1
- package/dist/browser/cjs/internal/object-7HaOcSJT.js.map +0 -1
- package/dist/browser/es/internal/index-BC9vqWum.js.map +0 -1
- package/dist/browser/es/internal/object-C0mdRngQ.js.map +0 -1
- package/dist/node/cjs/internal/index-C-PLtWC-.js.map +0 -1
- package/dist/node/cjs/internal/object-CEHSqR4q.js.map +0 -1
- package/dist/node/es/internal/index-DMRiWhIW.js.map +0 -1
- package/dist/node/es/internal/object-CnIwQbbO.js.map +0 -1
- package/dist/src/document/actions/creators.d.ts +0 -48
- package/dist/src/document/actions/creators.d.ts.map +0 -1
- package/dist/src/document/actions/index.d.ts +0 -15
- package/dist/src/document/actions/index.d.ts.map +0 -1
- package/dist/src/document/actions/types.d.ts +0 -16
- package/dist/src/document/actions/types.d.ts.map +0 -1
- package/dist/src/document/index.d.ts +0 -7
- package/dist/src/document/index.d.ts.map +0 -1
- package/dist/src/document/object.d.ts +0 -126
- package/dist/src/document/object.d.ts.map +0 -1
- package/dist/src/document/reducer.d.ts +0 -66
- package/dist/src/document/reducer.d.ts.map +0 -1
- package/dist/src/document/schema/index.d.ts +0 -3
- package/dist/src/document/schema/index.d.ts.map +0 -1
- package/dist/src/document/schema/types.d.ts +0 -177
- package/dist/src/document/schema/types.d.ts.map +0 -1
- package/dist/src/document/schema/zod.d.ts +0 -117
- package/dist/src/document/schema/zod.d.ts.map +0 -1
- package/dist/src/document/signal.d.ts +0 -30
- package/dist/src/document/signal.d.ts.map +0 -1
- package/dist/src/document/types.d.ts +0 -273
- package/dist/src/document/types.d.ts.map +0 -1
- package/dist/src/document/utils/base.d.ts +0 -88
- package/dist/src/document/utils/base.d.ts.map +0 -1
- package/dist/src/document/utils/browser.d.ts +0 -10
- package/dist/src/document/utils/browser.d.ts.map +0 -1
- package/dist/src/document/utils/crypto.d.ts +0 -10
- package/dist/src/document/utils/crypto.d.ts.map +0 -1
- package/dist/src/document/utils/document-helpers.d.ts +0 -74
- package/dist/src/document/utils/document-helpers.d.ts.map +0 -1
- package/dist/src/document/utils/file.d.ts +0 -49
- package/dist/src/document/utils/file.d.ts.map +0 -1
- package/dist/src/document/utils/index.d.ts +0 -7
- package/dist/src/document/utils/index.d.ts.map +0 -1
- package/dist/src/document/utils/node.d.ts +0 -10
- package/dist/src/document/utils/node.d.ts.map +0 -1
- package/dist/src/document/utils/validation.d.ts +0 -3
- package/dist/src/document/utils/validation.d.ts.map +0 -1
- package/dist/src/document-model/custom/reducers/header.d.ts +0 -3
- package/dist/src/document-model/custom/reducers/header.d.ts.map +0 -1
- package/dist/src/document-model/custom/reducers/module.d.ts +0 -3
- package/dist/src/document-model/custom/reducers/module.d.ts.map +0 -1
- package/dist/src/document-model/custom/reducers/operation-error.d.ts +0 -3
- package/dist/src/document-model/custom/reducers/operation-error.d.ts.map +0 -1
- package/dist/src/document-model/custom/reducers/operation-example.d.ts +0 -3
- package/dist/src/document-model/custom/reducers/operation-example.d.ts.map +0 -1
- package/dist/src/document-model/custom/reducers/operation.d.ts +0 -3
- package/dist/src/document-model/custom/reducers/operation.d.ts.map +0 -1
- package/dist/src/document-model/custom/reducers/state.d.ts +0 -3
- package/dist/src/document-model/custom/reducers/state.d.ts.map +0 -1
- package/dist/src/document-model/custom/reducers/versioning.d.ts +0 -8
- package/dist/src/document-model/custom/reducers/versioning.d.ts.map +0 -1
- package/dist/src/document-model/custom/utils.d.ts +0 -8
- package/dist/src/document-model/custom/utils.d.ts.map +0 -1
- package/dist/src/document-model/gen/actions.d.ts +0 -16
- package/dist/src/document-model/gen/actions.d.ts.map +0 -1
- package/dist/src/document-model/gen/creators.d.ts +0 -8
- package/dist/src/document-model/gen/creators.d.ts.map +0 -1
- package/dist/src/document-model/gen/document-model.d.ts +0 -3
- package/dist/src/document-model/gen/document-model.d.ts.map +0 -1
- package/dist/src/document-model/gen/header/actions.d.ts +0 -10
- package/dist/src/document-model/gen/header/actions.d.ts.map +0 -1
- package/dist/src/document-model/gen/header/creators.d.ts +0 -9
- package/dist/src/document-model/gen/header/creators.d.ts.map +0 -1
- package/dist/src/document-model/gen/header/object.d.ts +0 -13
- package/dist/src/document-model/gen/header/object.d.ts.map +0 -1
- package/dist/src/document-model/gen/header/operations.d.ts +0 -11
- package/dist/src/document-model/gen/header/operations.d.ts.map +0 -1
- package/dist/src/document-model/gen/index.d.ts +0 -6
- package/dist/src/document-model/gen/index.d.ts.map +0 -1
- package/dist/src/document-model/gen/module/actions.d.ts +0 -9
- package/dist/src/document-model/gen/module/actions.d.ts.map +0 -1
- package/dist/src/document-model/gen/module/creators.d.ts +0 -8
- package/dist/src/document-model/gen/module/creators.d.ts.map +0 -1
- package/dist/src/document-model/gen/module/object.d.ts +0 -12
- package/dist/src/document-model/gen/module/object.d.ts.map +0 -1
- package/dist/src/document-model/gen/module/operations.d.ts +0 -10
- package/dist/src/document-model/gen/module/operations.d.ts.map +0 -1
- package/dist/src/document-model/gen/object.d.ts +0 -29
- package/dist/src/document-model/gen/object.d.ts.map +0 -1
- package/dist/src/document-model/gen/operation/actions.d.ts +0 -14
- package/dist/src/document-model/gen/operation/actions.d.ts.map +0 -1
- package/dist/src/document-model/gen/operation/creators.d.ts +0 -13
- package/dist/src/document-model/gen/operation/creators.d.ts.map +0 -1
- package/dist/src/document-model/gen/operation/object.d.ts +0 -17
- package/dist/src/document-model/gen/operation/object.d.ts.map +0 -1
- package/dist/src/document-model/gen/operation/operations.d.ts +0 -15
- package/dist/src/document-model/gen/operation/operations.d.ts.map +0 -1
- package/dist/src/document-model/gen/operation-error/actions.d.ts +0 -11
- package/dist/src/document-model/gen/operation-error/actions.d.ts.map +0 -1
- package/dist/src/document-model/gen/operation-error/creators.d.ts +0 -10
- package/dist/src/document-model/gen/operation-error/creators.d.ts.map +0 -1
- package/dist/src/document-model/gen/operation-error/object.d.ts +0 -14
- package/dist/src/document-model/gen/operation-error/object.d.ts.map +0 -1
- package/dist/src/document-model/gen/operation-error/operations.d.ts +0 -12
- package/dist/src/document-model/gen/operation-error/operations.d.ts.map +0 -1
- package/dist/src/document-model/gen/operation-example/actions.d.ts +0 -8
- package/dist/src/document-model/gen/operation-example/actions.d.ts.map +0 -1
- package/dist/src/document-model/gen/operation-example/creators.d.ts +0 -7
- package/dist/src/document-model/gen/operation-example/creators.d.ts.map +0 -1
- package/dist/src/document-model/gen/operation-example/object.d.ts +0 -11
- package/dist/src/document-model/gen/operation-example/object.d.ts.map +0 -1
- package/dist/src/document-model/gen/operation-example/operations.d.ts +0 -9
- package/dist/src/document-model/gen/operation-example/operations.d.ts.map +0 -1
- package/dist/src/document-model/gen/reducer.d.ts +0 -6
- package/dist/src/document-model/gen/reducer.d.ts.map +0 -1
- package/dist/src/document-model/gen/schema/index.d.ts +0 -3
- package/dist/src/document-model/gen/schema/index.d.ts.map +0 -1
- package/dist/src/document-model/gen/schema/types.d.ts +0 -454
- package/dist/src/document-model/gen/schema/types.d.ts.map +0 -1
- package/dist/src/document-model/gen/schema/zod.d.ts +0 -454
- package/dist/src/document-model/gen/schema/zod.d.ts.map +0 -1
- package/dist/src/document-model/gen/state/actions.d.ts +0 -10
- package/dist/src/document-model/gen/state/actions.d.ts.map +0 -1
- package/dist/src/document-model/gen/state/creators.d.ts +0 -9
- package/dist/src/document-model/gen/state/creators.d.ts.map +0 -1
- package/dist/src/document-model/gen/state/object.d.ts +0 -13
- package/dist/src/document-model/gen/state/object.d.ts.map +0 -1
- package/dist/src/document-model/gen/state/operations.d.ts +0 -11
- package/dist/src/document-model/gen/state/operations.d.ts.map +0 -1
- package/dist/src/document-model/gen/types.d.ts +0 -9
- package/dist/src/document-model/gen/types.d.ts.map +0 -1
- package/dist/src/document-model/gen/utils.d.ts +0 -7
- package/dist/src/document-model/gen/utils.d.ts.map +0 -1
- package/dist/src/document-model/gen/versioning/actions.d.ts +0 -9
- package/dist/src/document-model/gen/versioning/actions.d.ts.map +0 -1
- package/dist/src/document-model/gen/versioning/creators.d.ts +0 -8
- package/dist/src/document-model/gen/versioning/creators.d.ts.map +0 -1
- package/dist/src/document-model/gen/versioning/object.d.ts +0 -12
- package/dist/src/document-model/gen/versioning/object.d.ts.map +0 -1
- package/dist/src/document-model/gen/versioning/operations.d.ts +0 -10
- package/dist/src/document-model/gen/versioning/operations.d.ts.map +0 -1
- package/dist/src/document-model/index.d.ts +0 -81
- package/dist/src/document-model/index.d.ts.map +0 -1
- package/dist/src/index.d.ts +0 -25
- package/dist/src/index.d.ts.map +0 -1
- package/dist/test/document/crypto.test.d.ts +0 -2
- package/dist/test/document/crypto.test.d.ts.map +0 -1
- package/dist/test/document/event-vs-command.test.d.ts +0 -2
- package/dist/test/document/event-vs-command.test.d.ts.map +0 -1
- package/dist/test/document/local.test.d.ts +0 -2
- package/dist/test/document/local.test.d.ts.map +0 -1
- package/dist/test/document/object.test.d.ts +0 -2
- package/dist/test/document/object.test.d.ts.map +0 -1
- package/dist/test/document/operation-id.test.d.ts +0 -2
- package/dist/test/document/operation-id.test.d.ts.map +0 -1
- package/dist/test/document/prune.test.d.ts +0 -2
- package/dist/test/document/prune.test.d.ts.map +0 -1
- package/dist/test/document/reducer.test.d.ts +0 -2
- package/dist/test/document/reducer.test.d.ts.map +0 -1
- package/dist/test/document/skip-operations.test.d.ts +0 -2
- package/dist/test/document/skip-operations.test.d.ts.map +0 -1
- package/dist/test/document/undo-redo.test.d.ts +0 -2
- package/dist/test/document/undo-redo.test.d.ts.map +0 -1
- package/dist/test/document/utils.test.d.ts +0 -2
- package/dist/test/document/utils.test.d.ts.map +0 -1
- package/dist/test/document-helpers/addUndo.test.d.ts +0 -2
- package/dist/test/document-helpers/addUndo.test.d.ts.map +0 -1
- package/dist/test/document-helpers/attachBranch.test.d.ts +0 -2
- package/dist/test/document-helpers/attachBranch.test.d.ts.map +0 -1
- package/dist/test/document-helpers/checkCleanedOperationsIntegrity.test.d.ts +0 -2
- package/dist/test/document-helpers/checkCleanedOperationsIntegrity.test.d.ts.map +0 -1
- package/dist/test/document-helpers/conflictResolution.test.d.ts +0 -2
- package/dist/test/document-helpers/conflictResolution.test.d.ts.map +0 -1
- package/dist/test/document-helpers/filterDuplicatedOperations.test.d.ts +0 -2
- package/dist/test/document-helpers/filterDuplicatedOperations.test.d.ts.map +0 -1
- package/dist/test/document-helpers/garbageCollect.test.d.ts +0 -2
- package/dist/test/document-helpers/garbageCollect.test.d.ts.map +0 -1
- package/dist/test/document-helpers/groupOperationsByScope.test.d.ts +0 -2
- package/dist/test/document-helpers/groupOperationsByScope.test.d.ts.map +0 -1
- package/dist/test/document-helpers/merge.test.d.ts +0 -2
- package/dist/test/document-helpers/merge.test.d.ts.map +0 -1
- package/dist/test/document-helpers/nextSkipNumber.test.d.ts +0 -2
- package/dist/test/document-helpers/nextSkipNumber.test.d.ts.map +0 -1
- package/dist/test/document-helpers/prepareOperations.test.d.ts +0 -2
- package/dist/test/document-helpers/prepareOperations.test.d.ts.map +0 -1
- package/dist/test/document-helpers/removeExistingOperations.test.d.ts +0 -2
- package/dist/test/document-helpers/removeExistingOperations.test.d.ts.map +0 -1
- package/dist/test/document-helpers/reshuffleByTimestamp.test.d.ts +0 -2
- package/dist/test/document-helpers/reshuffleByTimestamp.test.d.ts.map +0 -1
- package/dist/test/document-helpers/reshuffleByTimestampAndIndex.test.d.ts +0 -2
- package/dist/test/document-helpers/reshuffleByTimestampAndIndex.test.d.ts.map +0 -1
- package/dist/test/document-helpers/skipHeaderOperations.test.d.ts +0 -2
- package/dist/test/document-helpers/skipHeaderOperations.test.d.ts.map +0 -1
- package/dist/test/document-helpers/sortOperations.test.d.ts +0 -2
- package/dist/test/document-helpers/sortOperations.test.d.ts.map +0 -1
- package/dist/test/document-helpers/split.test.d.ts +0 -2
- package/dist/test/document-helpers/split.test.d.ts.map +0 -1
- package/dist/test/document-helpers/utils.d.ts +0 -8
- package/dist/test/document-helpers/utils.d.ts.map +0 -1
- package/dist/test/document-model/object.test.d.ts +0 -2
- package/dist/test/document-model/object.test.d.ts.map +0 -1
- package/dist/test/document-model/replay.test.d.ts +0 -2
- package/dist/test/document-model/replay.test.d.ts.map +0 -1
- package/dist/test/document-model/skip-operations.test.d.ts +0 -2
- package/dist/test/document-model/skip-operations.test.d.ts.map +0 -1
- package/dist/test/document-model/validation.test.d.ts +0 -2
- package/dist/test/document-model/validation.test.d.ts.map +0 -1
- package/dist/test/document-model/zip.test.d.ts +0 -2
- package/dist/test/document-model/zip.test.d.ts.map +0 -1
- package/dist/test/helpers.d.ts +0 -40
- package/dist/test/helpers.d.ts.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/vite.config.d.ts +0 -3
- package/dist/vite.config.d.ts.map +0 -1
- package/dist/vitest.config.d.ts +0 -3
- package/dist/vitest.config.d.ts.map +0 -1
|
@@ -1864,7 +1864,7 @@ function updateHeader(document, action) {
|
|
|
1864
1864
|
...document.revision,
|
|
1865
1865
|
[action.scope]: getNextRevision(document, action)
|
|
1866
1866
|
},
|
|
1867
|
-
lastModified: (
|
|
1867
|
+
lastModified: getDocumentLastModified(document)
|
|
1868
1868
|
};
|
|
1869
1869
|
}
|
|
1870
1870
|
function updateOperations(document, action, skip = 0, reuseLastOperationIndex = false) {
|
|
@@ -2307,6 +2307,12 @@ function sortMappedOperations(operations) {
|
|
|
2307
2307
|
(a, b) => new Date(a.operation.timestamp).getTime() - new Date(b.operation.timestamp).getTime()
|
|
2308
2308
|
);
|
|
2309
2309
|
}
|
|
2310
|
+
function getDocumentLastModified(document) {
|
|
2311
|
+
var _a;
|
|
2312
|
+
const sortedOperations = sortOperations(document.operations);
|
|
2313
|
+
const timestamp = ((_a = sortedOperations.at(-1)) == null ? void 0 : _a.timestamp) || document.initialState.lastModified;
|
|
2314
|
+
return timestamp;
|
|
2315
|
+
}
|
|
2310
2316
|
function replayOperations(initialState, clearedOperations, reducer, dispatch, header, documentReducer = baseReducer, skipHeaderOperations2 = {}, options) {
|
|
2311
2317
|
const wrappedReducer = createReducer(reducer, documentReducer);
|
|
2312
2318
|
return replayDocument(
|
|
@@ -2660,25 +2666,26 @@ function applyMixins(derivedCtor, constructors) {
|
|
|
2660
2666
|
});
|
|
2661
2667
|
}
|
|
2662
2668
|
export {
|
|
2663
|
-
|
|
2669
|
+
isNoopOperation as A,
|
|
2664
2670
|
BaseDocument as B,
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2671
|
+
isSameDocument as C,
|
|
2672
|
+
isUndo as D,
|
|
2673
|
+
isUndoRedo as E,
|
|
2674
|
+
mapSkippedOperations as F,
|
|
2675
|
+
parseResultingState as G,
|
|
2676
|
+
readOnly as H,
|
|
2677
|
+
replayDocument as I,
|
|
2678
|
+
replayOperations as J,
|
|
2679
|
+
sortMappedOperations as K,
|
|
2680
|
+
sortOperations as L,
|
|
2681
|
+
validateOperations as M,
|
|
2682
|
+
verifyOperationSignature as N,
|
|
2683
|
+
baseReducer as O,
|
|
2684
|
+
mutableBaseReducer as P,
|
|
2685
|
+
processUndoRedo as Q,
|
|
2686
|
+
updateDocument as R,
|
|
2687
|
+
updateHeader as S,
|
|
2688
|
+
zod as T,
|
|
2682
2689
|
createExtendedState as a,
|
|
2683
2690
|
createDocument as b,
|
|
2684
2691
|
createReducer as c,
|
|
@@ -2698,12 +2705,12 @@ export {
|
|
|
2698
2705
|
createZip as q,
|
|
2699
2706
|
documentHelpers as r,
|
|
2700
2707
|
saveToFile as s,
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
+
getDocumentLastModified as t,
|
|
2709
|
+
getLocalFile as u,
|
|
2710
|
+
getRemoteFile as v,
|
|
2711
|
+
getUnixTimestamp as w,
|
|
2712
|
+
hashDocument as x,
|
|
2713
|
+
hashKey as y,
|
|
2714
|
+
hex2ab as z
|
|
2708
2715
|
};
|
|
2709
|
-
//# sourceMappingURL=object-
|
|
2716
|
+
//# sourceMappingURL=object-oB7gkKNr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object-oB7gkKNr.js","sources":["../../../../src/document/schema/zod.ts","../../../../../../node_modules/.pnpm/safe-stable-stringify@2.5.0/node_modules/safe-stable-stringify/index.js","../../../../../../node_modules/.pnpm/safe-stable-stringify@2.5.0/node_modules/safe-stable-stringify/esm/wrapper.js","../../../../../../node_modules/.pnpm/uuid@9.0.1/node_modules/uuid/dist/esm-browser/rng.js","../../../../../../node_modules/.pnpm/uuid@9.0.1/node_modules/uuid/dist/esm-browser/stringify.js","../../../../../../node_modules/.pnpm/uuid@9.0.1/node_modules/uuid/dist/esm-browser/native.js","../../../../../../node_modules/.pnpm/uuid@9.0.1/node_modules/uuid/dist/esm-browser/v4.js","../../../../../../node_modules/.pnpm/sha1-uint8array@0.10.7/node_modules/sha1-uint8array/dist/sha1-uint8array.mjs","../../../../src/document/utils/browser.ts","../../../../src/document/utils/crypto.ts","../../../../../../node_modules/.pnpm/mime@4.0.4/node_modules/mime/dist/types/standard.js","../../../../../../node_modules/.pnpm/mime@4.0.4/node_modules/mime/dist/src/Mime.js","../../../../../../node_modules/.pnpm/mime@4.0.4/node_modules/mime/dist/src/index_lite.js","../../../../src/document/utils/validation.ts","../../../../src/document/utils/document-helpers.ts","../../../../src/document/utils/file.ts","../../../../src/document/actions/index.ts","../../../../src/document/actions/types.ts","../../../../src/document/reducer.ts","../../../../src/document/utils/base.ts","../../../../src/document/actions/creators.ts","../../../../src/document/object.ts"],"sourcesContent":["import { z } from \"zod\";\nimport {\n Action,\n DocumentFile,\n Load_State,\n LoadStateAction,\n LoadStateActionInput,\n LoadStateActionStateInput,\n Operation,\n Prune,\n PruneAction,\n PruneActionInput,\n Redo,\n RedoAction,\n Set_Name,\n SetNameAction,\n SetNameOperation,\n Undo,\n UndoAction,\n} from \".\";\nimport { OperationScope } from \"../types\";\n\ntype Properties<T> = Required<{\n [K in keyof T]: z.ZodType<T[K], any, T[K]>;\n}>;\n\ntype definedNonNullAny = {};\n\nexport const isDefinedNonNullAny = (v: any): v is definedNonNullAny =>\n v !== undefined && v !== null;\n\nexport const definedNonNullAnySchema = z\n .any()\n .refine((v) => isDefinedNonNullAny(v));\n\nexport const Load_StateSchema = z.enum([\"LOAD_STATE\"]);\n\nexport const PruneSchema = z.enum([\"PRUNE\"]);\n\nexport const RedoSchema = z.enum([\"REDO\"]);\n\nexport const Set_NameSchema = z.enum([\"SET_NAME\"]);\n\nexport const UndoSchema = z.enum([\"UNDO\"]);\n\nexport function ActionSchema(): z.ZodObject<Properties<Action>> {\n return z.object({\n __typename: z.literal(\"Action\").optional(),\n type: z.string(),\n });\n}\n\nexport function OperationScopeSchema(): z.ZodType<OperationScope> {\n return z.literal(\"global\").or(z.literal(\"local\"));\n}\n\nexport function BaseActionSchema() {\n return z.union([\n LoadStateActionSchema(),\n PruneActionSchema(),\n RedoActionSchema(),\n SetNameActionSchema(),\n UndoActionSchema(),\n ]);\n}\n\nexport function DocumentFileSchema(): z.ZodObject<Properties<DocumentFile>> {\n return z.object({\n __typename: z.literal(\"DocumentFile\").optional(),\n data: z.string(),\n extension: z.string().nullable(),\n fileName: z.string().nullable(),\n mimeType: z.string(),\n });\n}\n\nexport function LoadStateActionSchema(): z.ZodObject<\n Properties<LoadStateAction>\n> {\n return z.object({\n input: z.lazy(() => LoadStateActionInputSchema()),\n type: Load_StateSchema,\n scope: OperationScopeSchema(),\n });\n}\n\nexport function LoadStateActionInputSchema(): z.ZodObject<\n Properties<LoadStateActionInput>\n> {\n return z.object({\n operations: z.number(),\n state: z.lazy(() => LoadStateActionStateInputSchema()),\n });\n}\n\nexport function LoadStateActionStateInputSchema(): z.ZodObject<\n Properties<LoadStateActionStateInput>\n> {\n return z.object({\n data: z.unknown().nullish(),\n name: z.string(),\n });\n}\n\nexport function OperationSchema(): z.ZodObject<Properties<Operation>> {\n return z.object({\n __typename: z.literal(\"Operation\").optional(),\n hash: z.string(),\n index: z.number(),\n timestamp: z.string().datetime(),\n type: z.string(),\n });\n}\n\nexport function PruneActionSchema(): z.ZodObject<Properties<PruneAction>> {\n return z.object({\n input: z.lazy(() => PruneActionInputSchema()),\n type: PruneSchema,\n scope: OperationScopeSchema(),\n });\n}\n\nexport function PruneActionInputSchema(): z.ZodObject<\n Properties<PruneActionInput>\n> {\n return z.object({\n end: z.number().nullish(),\n start: z.number().nullish(),\n });\n}\n\nexport const RedoActionInputSchema = z.number;\n\nexport function RedoActionSchema(): z.ZodObject<Properties<RedoAction>> {\n return z.object({\n input: RedoActionInputSchema(),\n type: RedoSchema,\n scope: OperationScopeSchema(),\n });\n}\n\nexport const SetNameActionInputSchema = z.string;\n\nexport function SetNameActionSchema(): z.ZodObject<Properties<SetNameAction>> {\n return z.object({\n input: SetNameActionInputSchema(),\n type: Set_NameSchema,\n scope: z.literal(\"global\"),\n });\n}\n\nexport function SetNameOperationSchema(): z.ZodObject<\n Properties<SetNameOperation>\n> {\n return z.object({\n __typename: z.literal(\"SetNameOperation\").optional(),\n hash: z.string(),\n index: z.number(),\n input: z.string(),\n timestamp: z.string().datetime(),\n type: z.string(),\n });\n}\n\nexport const UndoActionInputSchema = z.number;\n\nexport function UndoActionSchema(): z.ZodObject<Properties<UndoAction>> {\n return z.object({\n input: UndoActionInputSchema(),\n type: UndoSchema,\n scope: OperationScopeSchema(),\n });\n}\n","'use strict'\n\nconst { hasOwnProperty } = Object.prototype\n\nconst stringify = configure()\n\n// @ts-expect-error\nstringify.configure = configure\n// @ts-expect-error\nstringify.stringify = stringify\n\n// @ts-expect-error\nstringify.default = stringify\n\n// @ts-expect-error used for named export\nexports.stringify = stringify\n// @ts-expect-error used for named export\nexports.configure = configure\n\nmodule.exports = stringify\n\n// eslint-disable-next-line no-control-regex\nconst strEscapeSequencesRegExp = /[\\u0000-\\u001f\\u0022\\u005c\\ud800-\\udfff]/\n\n// Escape C0 control characters, double quotes, the backslash and every code\n// unit with a numeric value in the inclusive range 0xD800 to 0xDFFF.\nfunction strEscape (str) {\n // Some magic numbers that worked out fine while benchmarking with v8 8.0\n if (str.length < 5000 && !strEscapeSequencesRegExp.test(str)) {\n return `\"${str}\"`\n }\n return JSON.stringify(str)\n}\n\nfunction sort (array, comparator) {\n // Insertion sort is very efficient for small input sizes, but it has a bad\n // worst case complexity. Thus, use native array sort for bigger values.\n if (array.length > 2e2 || comparator) {\n return array.sort(comparator)\n }\n for (let i = 1; i < array.length; i++) {\n const currentValue = array[i]\n let position = i\n while (position !== 0 && array[position - 1] > currentValue) {\n array[position] = array[position - 1]\n position--\n }\n array[position] = currentValue\n }\n return array\n}\n\nconst typedArrayPrototypeGetSymbolToStringTag =\n Object.getOwnPropertyDescriptor(\n Object.getPrototypeOf(\n Object.getPrototypeOf(\n new Int8Array()\n )\n ),\n Symbol.toStringTag\n ).get\n\nfunction isTypedArrayWithEntries (value) {\n return typedArrayPrototypeGetSymbolToStringTag.call(value) !== undefined && value.length !== 0\n}\n\nfunction stringifyTypedArray (array, separator, maximumBreadth) {\n if (array.length < maximumBreadth) {\n maximumBreadth = array.length\n }\n const whitespace = separator === ',' ? '' : ' '\n let res = `\"0\":${whitespace}${array[0]}`\n for (let i = 1; i < maximumBreadth; i++) {\n res += `${separator}\"${i}\":${whitespace}${array[i]}`\n }\n return res\n}\n\nfunction getCircularValueOption (options) {\n if (hasOwnProperty.call(options, 'circularValue')) {\n const circularValue = options.circularValue\n if (typeof circularValue === 'string') {\n return `\"${circularValue}\"`\n }\n if (circularValue == null) {\n return circularValue\n }\n if (circularValue === Error || circularValue === TypeError) {\n return {\n toString () {\n throw new TypeError('Converting circular structure to JSON')\n }\n }\n }\n throw new TypeError('The \"circularValue\" argument must be of type string or the value null or undefined')\n }\n return '\"[Circular]\"'\n}\n\nfunction getDeterministicOption (options) {\n let value\n if (hasOwnProperty.call(options, 'deterministic')) {\n value = options.deterministic\n if (typeof value !== 'boolean' && typeof value !== 'function') {\n throw new TypeError('The \"deterministic\" argument must be of type boolean or comparator function')\n }\n }\n return value === undefined ? true : value\n}\n\nfunction getBooleanOption (options, key) {\n let value\n if (hasOwnProperty.call(options, key)) {\n value = options[key]\n if (typeof value !== 'boolean') {\n throw new TypeError(`The \"${key}\" argument must be of type boolean`)\n }\n }\n return value === undefined ? true : value\n}\n\nfunction getPositiveIntegerOption (options, key) {\n let value\n if (hasOwnProperty.call(options, key)) {\n value = options[key]\n if (typeof value !== 'number') {\n throw new TypeError(`The \"${key}\" argument must be of type number`)\n }\n if (!Number.isInteger(value)) {\n throw new TypeError(`The \"${key}\" argument must be an integer`)\n }\n if (value < 1) {\n throw new RangeError(`The \"${key}\" argument must be >= 1`)\n }\n }\n return value === undefined ? Infinity : value\n}\n\nfunction getItemCount (number) {\n if (number === 1) {\n return '1 item'\n }\n return `${number} items`\n}\n\nfunction getUniqueReplacerSet (replacerArray) {\n const replacerSet = new Set()\n for (const value of replacerArray) {\n if (typeof value === 'string' || typeof value === 'number') {\n replacerSet.add(String(value))\n }\n }\n return replacerSet\n}\n\nfunction getStrictOption (options) {\n if (hasOwnProperty.call(options, 'strict')) {\n const value = options.strict\n if (typeof value !== 'boolean') {\n throw new TypeError('The \"strict\" argument must be of type boolean')\n }\n if (value) {\n return (value) => {\n let message = `Object can not safely be stringified. Received type ${typeof value}`\n if (typeof value !== 'function') message += ` (${value.toString()})`\n throw new Error(message)\n }\n }\n }\n}\n\nfunction configure (options) {\n options = { ...options }\n const fail = getStrictOption(options)\n if (fail) {\n if (options.bigint === undefined) {\n options.bigint = false\n }\n if (!('circularValue' in options)) {\n options.circularValue = Error\n }\n }\n const circularValue = getCircularValueOption(options)\n const bigint = getBooleanOption(options, 'bigint')\n const deterministic = getDeterministicOption(options)\n const comparator = typeof deterministic === 'function' ? deterministic : undefined\n const maximumDepth = getPositiveIntegerOption(options, 'maximumDepth')\n const maximumBreadth = getPositiveIntegerOption(options, 'maximumBreadth')\n\n function stringifyFnReplacer (key, parent, stack, replacer, spacer, indentation) {\n let value = parent[key]\n\n if (typeof value === 'object' && value !== null && typeof value.toJSON === 'function') {\n value = value.toJSON(key)\n }\n value = replacer.call(parent, key, value)\n\n switch (typeof value) {\n case 'string':\n return strEscape(value)\n case 'object': {\n if (value === null) {\n return 'null'\n }\n if (stack.indexOf(value) !== -1) {\n return circularValue\n }\n\n let res = ''\n let join = ','\n const originalIndentation = indentation\n\n if (Array.isArray(value)) {\n if (value.length === 0) {\n return '[]'\n }\n if (maximumDepth < stack.length + 1) {\n return '\"[Array]\"'\n }\n stack.push(value)\n if (spacer !== '') {\n indentation += spacer\n res += `\\n${indentation}`\n join = `,\\n${indentation}`\n }\n const maximumValuesToStringify = Math.min(value.length, maximumBreadth)\n let i = 0\n for (; i < maximumValuesToStringify - 1; i++) {\n const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation)\n res += tmp !== undefined ? tmp : 'null'\n res += join\n }\n const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation)\n res += tmp !== undefined ? tmp : 'null'\n if (value.length - 1 > maximumBreadth) {\n const removedKeys = value.length - maximumBreadth - 1\n res += `${join}\"... ${getItemCount(removedKeys)} not stringified\"`\n }\n if (spacer !== '') {\n res += `\\n${originalIndentation}`\n }\n stack.pop()\n return `[${res}]`\n }\n\n let keys = Object.keys(value)\n const keyLength = keys.length\n if (keyLength === 0) {\n return '{}'\n }\n if (maximumDepth < stack.length + 1) {\n return '\"[Object]\"'\n }\n let whitespace = ''\n let separator = ''\n if (spacer !== '') {\n indentation += spacer\n join = `,\\n${indentation}`\n whitespace = ' '\n }\n const maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth)\n if (deterministic && !isTypedArrayWithEntries(value)) {\n keys = sort(keys, comparator)\n }\n stack.push(value)\n for (let i = 0; i < maximumPropertiesToStringify; i++) {\n const key = keys[i]\n const tmp = stringifyFnReplacer(key, value, stack, replacer, spacer, indentation)\n if (tmp !== undefined) {\n res += `${separator}${strEscape(key)}:${whitespace}${tmp}`\n separator = join\n }\n }\n if (keyLength > maximumBreadth) {\n const removedKeys = keyLength - maximumBreadth\n res += `${separator}\"...\":${whitespace}\"${getItemCount(removedKeys)} not stringified\"`\n separator = join\n }\n if (spacer !== '' && separator.length > 1) {\n res = `\\n${indentation}${res}\\n${originalIndentation}`\n }\n stack.pop()\n return `{${res}}`\n }\n case 'number':\n return isFinite(value) ? String(value) : fail ? fail(value) : 'null'\n case 'boolean':\n return value === true ? 'true' : 'false'\n case 'undefined':\n return undefined\n case 'bigint':\n if (bigint) {\n return String(value)\n }\n // fallthrough\n default:\n return fail ? fail(value) : undefined\n }\n }\n\n function stringifyArrayReplacer (key, value, stack, replacer, spacer, indentation) {\n if (typeof value === 'object' && value !== null && typeof value.toJSON === 'function') {\n value = value.toJSON(key)\n }\n\n switch (typeof value) {\n case 'string':\n return strEscape(value)\n case 'object': {\n if (value === null) {\n return 'null'\n }\n if (stack.indexOf(value) !== -1) {\n return circularValue\n }\n\n const originalIndentation = indentation\n let res = ''\n let join = ','\n\n if (Array.isArray(value)) {\n if (value.length === 0) {\n return '[]'\n }\n if (maximumDepth < stack.length + 1) {\n return '\"[Array]\"'\n }\n stack.push(value)\n if (spacer !== '') {\n indentation += spacer\n res += `\\n${indentation}`\n join = `,\\n${indentation}`\n }\n const maximumValuesToStringify = Math.min(value.length, maximumBreadth)\n let i = 0\n for (; i < maximumValuesToStringify - 1; i++) {\n const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation)\n res += tmp !== undefined ? tmp : 'null'\n res += join\n }\n const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation)\n res += tmp !== undefined ? tmp : 'null'\n if (value.length - 1 > maximumBreadth) {\n const removedKeys = value.length - maximumBreadth - 1\n res += `${join}\"... ${getItemCount(removedKeys)} not stringified\"`\n }\n if (spacer !== '') {\n res += `\\n${originalIndentation}`\n }\n stack.pop()\n return `[${res}]`\n }\n stack.push(value)\n let whitespace = ''\n if (spacer !== '') {\n indentation += spacer\n join = `,\\n${indentation}`\n whitespace = ' '\n }\n let separator = ''\n for (const key of replacer) {\n const tmp = stringifyArrayReplacer(key, value[key], stack, replacer, spacer, indentation)\n if (tmp !== undefined) {\n res += `${separator}${strEscape(key)}:${whitespace}${tmp}`\n separator = join\n }\n }\n if (spacer !== '' && separator.length > 1) {\n res = `\\n${indentation}${res}\\n${originalIndentation}`\n }\n stack.pop()\n return `{${res}}`\n }\n case 'number':\n return isFinite(value) ? String(value) : fail ? fail(value) : 'null'\n case 'boolean':\n return value === true ? 'true' : 'false'\n case 'undefined':\n return undefined\n case 'bigint':\n if (bigint) {\n return String(value)\n }\n // fallthrough\n default:\n return fail ? fail(value) : undefined\n }\n }\n\n function stringifyIndent (key, value, stack, spacer, indentation) {\n switch (typeof value) {\n case 'string':\n return strEscape(value)\n case 'object': {\n if (value === null) {\n return 'null'\n }\n if (typeof value.toJSON === 'function') {\n value = value.toJSON(key)\n // Prevent calling `toJSON` again.\n if (typeof value !== 'object') {\n return stringifyIndent(key, value, stack, spacer, indentation)\n }\n if (value === null) {\n return 'null'\n }\n }\n if (stack.indexOf(value) !== -1) {\n return circularValue\n }\n const originalIndentation = indentation\n\n if (Array.isArray(value)) {\n if (value.length === 0) {\n return '[]'\n }\n if (maximumDepth < stack.length + 1) {\n return '\"[Array]\"'\n }\n stack.push(value)\n indentation += spacer\n let res = `\\n${indentation}`\n const join = `,\\n${indentation}`\n const maximumValuesToStringify = Math.min(value.length, maximumBreadth)\n let i = 0\n for (; i < maximumValuesToStringify - 1; i++) {\n const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation)\n res += tmp !== undefined ? tmp : 'null'\n res += join\n }\n const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation)\n res += tmp !== undefined ? tmp : 'null'\n if (value.length - 1 > maximumBreadth) {\n const removedKeys = value.length - maximumBreadth - 1\n res += `${join}\"... ${getItemCount(removedKeys)} not stringified\"`\n }\n res += `\\n${originalIndentation}`\n stack.pop()\n return `[${res}]`\n }\n\n let keys = Object.keys(value)\n const keyLength = keys.length\n if (keyLength === 0) {\n return '{}'\n }\n if (maximumDepth < stack.length + 1) {\n return '\"[Object]\"'\n }\n indentation += spacer\n const join = `,\\n${indentation}`\n let res = ''\n let separator = ''\n let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth)\n if (isTypedArrayWithEntries(value)) {\n res += stringifyTypedArray(value, join, maximumBreadth)\n keys = keys.slice(value.length)\n maximumPropertiesToStringify -= value.length\n separator = join\n }\n if (deterministic) {\n keys = sort(keys, comparator)\n }\n stack.push(value)\n for (let i = 0; i < maximumPropertiesToStringify; i++) {\n const key = keys[i]\n const tmp = stringifyIndent(key, value[key], stack, spacer, indentation)\n if (tmp !== undefined) {\n res += `${separator}${strEscape(key)}: ${tmp}`\n separator = join\n }\n }\n if (keyLength > maximumBreadth) {\n const removedKeys = keyLength - maximumBreadth\n res += `${separator}\"...\": \"${getItemCount(removedKeys)} not stringified\"`\n separator = join\n }\n if (separator !== '') {\n res = `\\n${indentation}${res}\\n${originalIndentation}`\n }\n stack.pop()\n return `{${res}}`\n }\n case 'number':\n return isFinite(value) ? String(value) : fail ? fail(value) : 'null'\n case 'boolean':\n return value === true ? 'true' : 'false'\n case 'undefined':\n return undefined\n case 'bigint':\n if (bigint) {\n return String(value)\n }\n // fallthrough\n default:\n return fail ? fail(value) : undefined\n }\n }\n\n function stringifySimple (key, value, stack) {\n switch (typeof value) {\n case 'string':\n return strEscape(value)\n case 'object': {\n if (value === null) {\n return 'null'\n }\n if (typeof value.toJSON === 'function') {\n value = value.toJSON(key)\n // Prevent calling `toJSON` again\n if (typeof value !== 'object') {\n return stringifySimple(key, value, stack)\n }\n if (value === null) {\n return 'null'\n }\n }\n if (stack.indexOf(value) !== -1) {\n return circularValue\n }\n\n let res = ''\n\n const hasLength = value.length !== undefined\n if (hasLength && Array.isArray(value)) {\n if (value.length === 0) {\n return '[]'\n }\n if (maximumDepth < stack.length + 1) {\n return '\"[Array]\"'\n }\n stack.push(value)\n const maximumValuesToStringify = Math.min(value.length, maximumBreadth)\n let i = 0\n for (; i < maximumValuesToStringify - 1; i++) {\n const tmp = stringifySimple(String(i), value[i], stack)\n res += tmp !== undefined ? tmp : 'null'\n res += ','\n }\n const tmp = stringifySimple(String(i), value[i], stack)\n res += tmp !== undefined ? tmp : 'null'\n if (value.length - 1 > maximumBreadth) {\n const removedKeys = value.length - maximumBreadth - 1\n res += `,\"... ${getItemCount(removedKeys)} not stringified\"`\n }\n stack.pop()\n return `[${res}]`\n }\n\n let keys = Object.keys(value)\n const keyLength = keys.length\n if (keyLength === 0) {\n return '{}'\n }\n if (maximumDepth < stack.length + 1) {\n return '\"[Object]\"'\n }\n let separator = ''\n let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth)\n if (hasLength && isTypedArrayWithEntries(value)) {\n res += stringifyTypedArray(value, ',', maximumBreadth)\n keys = keys.slice(value.length)\n maximumPropertiesToStringify -= value.length\n separator = ','\n }\n if (deterministic) {\n keys = sort(keys, comparator)\n }\n stack.push(value)\n for (let i = 0; i < maximumPropertiesToStringify; i++) {\n const key = keys[i]\n const tmp = stringifySimple(key, value[key], stack)\n if (tmp !== undefined) {\n res += `${separator}${strEscape(key)}:${tmp}`\n separator = ','\n }\n }\n if (keyLength > maximumBreadth) {\n const removedKeys = keyLength - maximumBreadth\n res += `${separator}\"...\":\"${getItemCount(removedKeys)} not stringified\"`\n }\n stack.pop()\n return `{${res}}`\n }\n case 'number':\n return isFinite(value) ? String(value) : fail ? fail(value) : 'null'\n case 'boolean':\n return value === true ? 'true' : 'false'\n case 'undefined':\n return undefined\n case 'bigint':\n if (bigint) {\n return String(value)\n }\n // fallthrough\n default:\n return fail ? fail(value) : undefined\n }\n }\n\n function stringify (value, replacer, space) {\n if (arguments.length > 1) {\n let spacer = ''\n if (typeof space === 'number') {\n spacer = ' '.repeat(Math.min(space, 10))\n } else if (typeof space === 'string') {\n spacer = space.slice(0, 10)\n }\n if (replacer != null) {\n if (typeof replacer === 'function') {\n return stringifyFnReplacer('', { '': value }, [], replacer, spacer, '')\n }\n if (Array.isArray(replacer)) {\n return stringifyArrayReplacer('', value, [], getUniqueReplacerSet(replacer), spacer, '')\n }\n }\n if (spacer.length !== 0) {\n return stringifyIndent('', value, [], spacer, '')\n }\n }\n return stringifySimple('', value, [])\n }\n\n return stringify\n}\n","import cjsModule from '../index.js'\n\nexport const configure = cjsModule.configure\n\nexport const stringify = cjsModule\nexport default cjsModule\n","// Unique ID creation requires a high quality random # generator. In the browser we therefore\n// require the crypto API and do not support built-in fallback to lower quality random number\n// generators (like Math.random()).\nlet getRandomValues;\nconst rnds8 = new Uint8Array(16);\nexport default function rng() {\n // lazy load so that environments that need to polyfill have a chance to do so\n if (!getRandomValues) {\n // getRandomValues needs to be invoked in a context where \"this\" is a Crypto implementation.\n getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);\n\n if (!getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n }\n\n return getRandomValues(rnds8);\n}","import validate from './validate.js';\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n\nconst byteToHex = [];\n\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\n\nexport function unsafeStringify(arr, offset = 0) {\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];\n}\n\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\nexport default stringify;","const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nexport default {\n randomUUID\n};","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\n\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n\n options = options || {};\n const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n\n rnds[6] = rnds[6] & 0x0f | 0x40;\n rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n\n return buf;\n }\n\n return unsafeStringify(rnds);\n}\n\nexport default v4;","/**\n * sha1-uint8array.ts\n */\nconst K = [\n 0x5a827999 | 0,\n 0x6ed9eba1 | 0,\n 0x8f1bbcdc | 0,\n 0xca62c1d6 | 0,\n];\nconst algorithms = {\n sha1: 1,\n};\nexport function createHash(algorithm) {\n if (algorithm && !algorithms[algorithm] && !algorithms[algorithm.toLowerCase()]) {\n throw new Error(\"Digest method not supported\");\n }\n return new Hash();\n}\nclass Hash {\n constructor() {\n this.A = 0x67452301 | 0;\n this.B = 0xefcdab89 | 0;\n this.C = 0x98badcfe | 0;\n this.D = 0x10325476 | 0;\n this.E = 0xc3d2e1f0 | 0;\n this._size = 0;\n this._sp = 0; // surrogate pair\n if (!sharedBuffer || sharedOffset >= 8000 /* N.allocTotal */) {\n sharedBuffer = new ArrayBuffer(8000 /* N.allocTotal */);\n sharedOffset = 0;\n }\n this._byte = new Uint8Array(sharedBuffer, sharedOffset, 80 /* N.allocBytes */);\n this._word = new Int32Array(sharedBuffer, sharedOffset, 20 /* N.allocWords */);\n sharedOffset += 80 /* N.allocBytes */;\n }\n update(data) {\n // data: string\n if (\"string\" === typeof data) {\n return this._utf8(data);\n }\n // data: undefined\n if (data == null) {\n throw new TypeError(\"Invalid type: \" + typeof data);\n }\n const byteOffset = data.byteOffset;\n const length = data.byteLength;\n let blocks = (length / 64 /* N.inputBytes */) | 0;\n let offset = 0;\n // longer than 1 block\n if (blocks && !(byteOffset & 3) && !(this._size % 64 /* N.inputBytes */)) {\n const block = new Int32Array(data.buffer, byteOffset, blocks * 16 /* N.inputWords */);\n while (blocks--) {\n this._int32(block, offset >> 2);\n offset += 64 /* N.inputBytes */;\n }\n this._size += offset;\n }\n // data: TypedArray | DataView\n const BYTES_PER_ELEMENT = data.BYTES_PER_ELEMENT;\n if (BYTES_PER_ELEMENT !== 1 && data.buffer) {\n const rest = new Uint8Array(data.buffer, byteOffset + offset, length - offset);\n return this._uint8(rest);\n }\n // no more bytes\n if (offset === length)\n return this;\n // data: Uint8Array | Int8Array\n return this._uint8(data, offset);\n }\n _uint8(data, offset) {\n const { _byte, _word } = this;\n const length = data.length;\n offset = offset | 0;\n while (offset < length) {\n const start = this._size % 64 /* N.inputBytes */;\n let index = start;\n while (offset < length && index < 64 /* N.inputBytes */) {\n _byte[index++] = data[offset++];\n }\n if (index >= 64 /* N.inputBytes */) {\n this._int32(_word);\n }\n this._size += index - start;\n }\n return this;\n }\n _utf8(text) {\n const { _byte, _word } = this;\n const length = text.length;\n let surrogate = this._sp;\n for (let offset = 0; offset < length;) {\n const start = this._size % 64 /* N.inputBytes */;\n let index = start;\n while (offset < length && index < 64 /* N.inputBytes */) {\n let code = text.charCodeAt(offset++) | 0;\n if (code < 0x80) {\n // ASCII characters\n _byte[index++] = code;\n }\n else if (code < 0x800) {\n // 2 bytes\n _byte[index++] = 0xC0 | (code >>> 6);\n _byte[index++] = 0x80 | (code & 0x3F);\n }\n else if (code < 0xD800 || code > 0xDFFF) {\n // 3 bytes\n _byte[index++] = 0xE0 | (code >>> 12);\n _byte[index++] = 0x80 | ((code >>> 6) & 0x3F);\n _byte[index++] = 0x80 | (code & 0x3F);\n }\n else if (surrogate) {\n // 4 bytes - surrogate pair\n code = ((surrogate & 0x3FF) << 10) + (code & 0x3FF) + 0x10000;\n _byte[index++] = 0xF0 | (code >>> 18);\n _byte[index++] = 0x80 | ((code >>> 12) & 0x3F);\n _byte[index++] = 0x80 | ((code >>> 6) & 0x3F);\n _byte[index++] = 0x80 | (code & 0x3F);\n surrogate = 0;\n }\n else {\n surrogate = code;\n }\n }\n if (index >= 64 /* N.inputBytes */) {\n this._int32(_word);\n _word[0] = _word[16 /* N.inputWords */];\n }\n this._size += index - start;\n }\n this._sp = surrogate;\n return this;\n }\n _int32(data, offset) {\n let { A, B, C, D, E } = this;\n let i = 0;\n offset = offset | 0;\n while (i < 16 /* N.inputWords */) {\n W[i++] = swap32(data[offset++]);\n }\n for (i = 16 /* N.inputWords */; i < 80 /* N.workWords */; i++) {\n W[i] = rotate1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]);\n }\n for (i = 0; i < 80 /* N.workWords */; i++) {\n const S = (i / 20) | 0;\n const T = (rotate5(A) + ft(S, B, C, D) + E + W[i] + K[S]) | 0;\n E = D;\n D = C;\n C = rotate30(B);\n B = A;\n A = T;\n }\n this.A = (A + this.A) | 0;\n this.B = (B + this.B) | 0;\n this.C = (C + this.C) | 0;\n this.D = (D + this.D) | 0;\n this.E = (E + this.E) | 0;\n }\n digest(encoding) {\n const { _byte, _word } = this;\n let i = (this._size % 64 /* N.inputBytes */) | 0;\n _byte[i++] = 0x80;\n // pad 0 for current word\n while (i & 3) {\n _byte[i++] = 0;\n }\n i >>= 2;\n if (i > 14 /* N.highIndex */) {\n while (i < 16 /* N.inputWords */) {\n _word[i++] = 0;\n }\n i = 0;\n this._int32(_word);\n }\n // pad 0 for rest words\n while (i < 16 /* N.inputWords */) {\n _word[i++] = 0;\n }\n // input size\n const bits64 = this._size * 8;\n const low32 = (bits64 & 0xffffffff) >>> 0;\n const high32 = (bits64 - low32) / 0x100000000;\n if (high32)\n _word[14 /* N.highIndex */] = swap32(high32);\n if (low32)\n _word[15 /* N.lowIndex */] = swap32(low32);\n this._int32(_word);\n return (encoding === \"hex\") ? this._hex() : this._bin();\n }\n _hex() {\n const { A, B, C, D, E } = this;\n return hex32(A) + hex32(B) + hex32(C) + hex32(D) + hex32(E);\n }\n _bin() {\n const { A, B, C, D, E, _byte, _word } = this;\n _word[0] = swap32(A);\n _word[1] = swap32(B);\n _word[2] = swap32(C);\n _word[3] = swap32(D);\n _word[4] = swap32(E);\n return _byte.slice(0, 20);\n }\n}\nconst W = new Int32Array(80 /* N.workWords */);\nlet sharedBuffer;\nlet sharedOffset = 0;\nconst hex32 = num => (num + 0x100000000).toString(16).substr(-8);\nconst swapLE = (c => (((c << 24) & 0xff000000) | ((c << 8) & 0xff0000) | ((c >> 8) & 0xff00) | ((c >> 24) & 0xff)));\nconst swapBE = (c => c);\nconst swap32 = isBE() ? swapBE : swapLE;\nconst rotate1 = num => (num << 1) | (num >>> 31);\nconst rotate5 = num => (num << 5) | (num >>> 27);\nconst rotate30 = num => (num << 30) | (num >>> 2);\nfunction ft(s, b, c, d) {\n if (s === 0)\n return (b & c) | ((~b) & d);\n if (s === 2)\n return (b & c) | (b & d) | (c & d);\n return b ^ c ^ d;\n}\nfunction isBE() {\n const buf = new Uint8Array(new Uint16Array([0xFEFF]).buffer); // BOM\n return (buf[0] === 0xFE);\n}\n","import type { Buffer } from \"buffer\";\nimport { createHash as createSha1Hash } from \"sha1-uint8array\";\n\nconst FileSystemError = new Error(\"File system not available.\");\n\nexport function writeFile(\n path: string,\n name: string,\n stream: Uint8Array,\n): Promise<string> {\n throw FileSystemError;\n}\n\nexport function readFile(path: string) {\n throw FileSystemError;\n}\n\nexport function fetchFile(\n url: string,\n): Promise<{ data: Buffer; mimeType?: string }> {\n throw FileSystemError;\n}\n\nexport const getFile = async (file: string) => {\n return readFile(file);\n};\n\nexport const hash = (\n data: string | Uint8Array | ArrayBufferView | DataView,\n algorithm = \"sha1\",\n) => {\n if (![\"sha1\"].includes(algorithm)) {\n throw new Error(\"Hashing algorithm not supported: Available: sha1\");\n }\n\n const hash = hashUIntArray(data);\n return uint8ArrayToBase64(hash);\n};\n\nfunction uint8ArrayToBase64(uint8Array: Uint8Array) {\n // Convert the Uint8Array to a binary string\n let binaryString = \"\";\n for (let i = 0; i < uint8Array.length; i++) {\n binaryString += String.fromCharCode(uint8Array[i]);\n }\n\n // Encode the binary string to base64\n const base64String = btoa(binaryString);\n return base64String;\n}\n\nfunction hashUIntArray(\n data: string | Uint8Array | ArrayBufferView,\n algorithm = \"sha1\",\n) {\n if (![\"sha1\"].includes(algorithm)) {\n throw new Error(\"Hashing algorithm not supported: Available: sha1\");\n }\n return createSha1Hash(\"sha1\")\n .update(data as string)\n .digest();\n}\n","import stringifyJson from \"safe-stable-stringify\";\nimport type {\n Action,\n ActionSigner,\n BaseAction,\n Document,\n Operation,\n OperationSignatureContext,\n OperationSigningHandler,\n OperationVerificationHandler,\n Reducer,\n Signature,\n} from \"../types\";\nimport { hash } from \"./node\";\n\nexport function getUnixTimestamp(date: Date | string): string {\n return (new Date(date).getTime() / 1000).toFixed(0);\n}\n\nexport function buildOperationSignatureParams({\n documentId,\n signer,\n operation,\n previousStateHash,\n}: OperationSignatureContext): [string, string, string, string] {\n const { timestamp, scope, id, type } = operation;\n return [\n getUnixTimestamp(timestamp), // timestamp,\n signer.app.key, // signer public key\n hash(\n // hash (docID, scope, operationID, operationName, operationInput)\n [documentId, scope, id, type, stringifyJson(operation.input)].join(\"\"),\n ),\n previousStateHash, // state hash that the operation was applied to\n ];\n}\n\nconst textEncode = new TextEncoder();\n\nexport function buildOperationSignatureMessage(\n params: [string, string, string, string],\n): Uint8Array {\n const message = params.join(\"\");\n const prefix = \"\\x19Signed Operation:\\n\" + message.length.toString();\n return textEncode.encode(prefix + message);\n}\n\nexport function ab2hex(ab: ArrayBuffer | ArrayBufferView): string {\n const view = ArrayBuffer.isView(ab) ? ab : new Uint8Array(ab);\n return Array.prototype.map\n .call(view, (x: number) => (\"00\" + x.toString(16)).slice(-2))\n .join(\"\");\n}\n\nexport function hex2ab(hex: string) {\n return new Uint8Array(\n hex.match(/[\\da-f]{2}/gi)?.map(function (h) {\n return parseInt(h, 16);\n }) ?? [],\n );\n}\n\nexport async function buildOperationSignature(\n context: OperationSignatureContext,\n signMethod: OperationSigningHandler,\n): Promise<Signature> {\n const params = buildOperationSignatureParams(context);\n const message = buildOperationSignatureMessage(params);\n const signature = await signMethod(message);\n return [...params, `0x${ab2hex(signature)}`];\n}\n\nexport async function buildSignedOperation<T, A extends Action, L>(\n action: A | Operation<A>,\n reducer: Reducer<T, A, L>,\n document: Document<T, A, L>,\n context: Omit<OperationSignatureContext, \"operation\" | \"previousStateHash\">,\n signHandler: OperationSigningHandler,\n): Promise<Operation<A | BaseAction>> {\n const result = reducer(document, action, undefined, {\n reuseHash: true,\n reuseOperationResultingState: true,\n });\n const operation = result.operations[action.scope].at(-1);\n if (!operation) {\n throw new Error(\"Action was not applied\");\n }\n\n const previousStateHash = result.operations[action.scope].at(-2)?.hash ?? \"\";\n const signature = await buildOperationSignature(\n {\n ...context,\n operation,\n previousStateHash,\n },\n signHandler,\n );\n\n return {\n ...operation,\n context: {\n ...operation.context,\n signer: {\n ...operation.context?.signer,\n ...context.signer,\n signatures: [...(context.signer.signatures ?? []), signature],\n },\n },\n };\n}\n\nexport async function verifyOperationSignature<T, A extends Action, L>(\n signature: Signature,\n signer: Omit<ActionSigner, \"signatures\">,\n verifyHandler: OperationVerificationHandler,\n): Promise<boolean> {\n const publicKey = signer.app.key;\n const params = signature.slice(0, 4) as [string, string, string, string];\n const signatureBytes = hex2ab(signature[4]);\n const expectedMessage = buildOperationSignatureMessage(params);\n return verifyHandler(publicKey, signatureBytes, expectedMessage);\n}\n","const types = { \"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\"] };\nObject.freeze(types);\nexport default types;\n//# sourceMappingURL=standard.js.map","var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n};\nvar _Mime_extensionToType, _Mime_typeToExtension, _Mime_typeToExtensions;\nclass Mime {\n constructor(...args) {\n _Mime_extensionToType.set(this, new Map());\n _Mime_typeToExtension.set(this, new Map());\n _Mime_typeToExtensions.set(this, new Map());\n for (const arg of args) {\n this.define(arg);\n }\n }\n define(typeMap, force = false) {\n for (let [type, extensions] of Object.entries(typeMap)) {\n type = type.toLowerCase();\n extensions = extensions.map((ext) => ext.toLowerCase());\n if (!__classPrivateFieldGet(this, _Mime_typeToExtensions, \"f\").has(type)) {\n __classPrivateFieldGet(this, _Mime_typeToExtensions, \"f\").set(type, new Set());\n }\n const allExtensions = __classPrivateFieldGet(this, _Mime_typeToExtensions, \"f\").get(type);\n let first = true;\n for (let extension of extensions) {\n const starred = extension.startsWith('*');\n extension = starred ? extension.slice(1) : extension;\n allExtensions?.add(extension);\n if (first) {\n __classPrivateFieldGet(this, _Mime_typeToExtension, \"f\").set(type, extension);\n }\n first = false;\n if (starred)\n continue;\n const currentType = __classPrivateFieldGet(this, _Mime_extensionToType, \"f\").get(extension);\n if (currentType && currentType != type && !force) {\n throw new Error(`\"${type} -> ${extension}\" conflicts with \"${currentType} -> ${extension}\". Pass \\`force=true\\` to override this definition.`);\n }\n __classPrivateFieldGet(this, _Mime_extensionToType, \"f\").set(extension, type);\n }\n }\n return this;\n }\n getType(path) {\n if (typeof path !== 'string')\n return null;\n const last = path.replace(/^.*[/\\\\]/, '').toLowerCase();\n const ext = last.replace(/^.*\\./, '').toLowerCase();\n const hasPath = last.length < path.length;\n const hasDot = ext.length < last.length - 1;\n if (!hasDot && hasPath)\n return null;\n return __classPrivateFieldGet(this, _Mime_extensionToType, \"f\").get(ext) ?? null;\n }\n getExtension(type) {\n if (typeof type !== 'string')\n return null;\n type = type?.split?.(';')[0];\n return ((type && __classPrivateFieldGet(this, _Mime_typeToExtension, \"f\").get(type.trim().toLowerCase())) ?? null);\n }\n getAllExtensions(type) {\n if (typeof type !== 'string')\n return null;\n return __classPrivateFieldGet(this, _Mime_typeToExtensions, \"f\").get(type.toLowerCase()) ?? null;\n }\n _freeze() {\n this.define = () => {\n throw new Error('define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances');\n };\n Object.freeze(this);\n for (const extensions of __classPrivateFieldGet(this, _Mime_typeToExtensions, \"f\").values()) {\n Object.freeze(extensions);\n }\n return this;\n }\n _getTestState() {\n return {\n types: __classPrivateFieldGet(this, _Mime_extensionToType, \"f\"),\n extensions: __classPrivateFieldGet(this, _Mime_typeToExtension, \"f\"),\n };\n }\n}\n_Mime_extensionToType = new WeakMap(), _Mime_typeToExtension = new WeakMap(), _Mime_typeToExtensions = new WeakMap();\nexport default Mime;\n//# sourceMappingURL=Mime.js.map","import standardTypes from '../types/standard.js';\nimport Mime from './Mime.js';\nexport { default as Mime } from './Mime.js';\nexport default new Mime(standardTypes)._freeze();\n//# sourceMappingURL=index_lite.js.map","import {\n DocumentOperations,\n Action,\n ValidationError,\n OperationScope,\n} from \"../types\";\n\nexport function validateOperations<A extends Action>(\n operations: DocumentOperations<A>,\n) {\n const errors: ValidationError[] = [];\n const scopes = Object.keys(operations) as OperationScope[];\n\n for (const scope of scopes) {\n const ops = operations[scope].sort((a, b) => a.index - b.index);\n\n let opIndex = -1;\n\n for (let i = 0; i < ops.length; i++) {\n opIndex = opIndex + 1 + ops[i].skip;\n if (ops[i].index !== opIndex) {\n errors.push({\n message: `Invalid operation index ${ops[i].index} at position ${i}`,\n details: {\n position: i,\n operation: ops[i],\n scope: ops[i].scope,\n },\n });\n }\n }\n }\n\n return errors;\n}\n","import {\n Operation,\n OperationScope,\n Action,\n DocumentOperations,\n} from \"../types\";\nimport stringify from \"safe-stable-stringify\";\n\nexport type OperationIndex = {\n index: number;\n skip: number;\n};\n\nexport enum IntegrityIssueType {\n UNEXPECTED_INDEX = \"UNEXPECTED_INDEX\",\n}\n\nexport enum IntegrityIssueSubType {\n DUPLICATED_INDEX = \"DUPLICATED_INDEX\",\n MISSING_INDEX = \"MISSING_INDEX\",\n}\n\ntype IntegrityIssue = {\n operation: OperationIndex;\n issue: IntegrityIssueType;\n category: IntegrityIssueSubType;\n message: string;\n};\n\ntype Reshuffle = (\n startIndex: OperationIndex,\n opsA: Operation[],\n opsB: Operation[],\n) => Operation[];\n\nexport function checkCleanedOperationsIntegrity(\n sortedOperations: Operation[],\n): IntegrityIssue[] {\n const result: IntegrityIssue[] = [];\n\n // 1:1 1\n // 0:0 0 -> 1:0 1 -> 2:0 -> 3:0 -> 4:0 -> 5:0\n // 0:0 0 -> 2:1 1 -> 3:0 -> 4:0 -> 5:0\n // 0:0 0 -> 3:2 1 -> 4:0 -> 5:0\n // 0:0 0 -> 3:2 1 -> 5:1\n\n // 0:3 (expected 0, got -3)\n // 1:2 (expected 0, got -1)\n // 0:0 -> 1:1\n // 0:0 -> 2:2\n // 0:0 -> 3:2 -> 5:2\n\n let currentIndex = -1;\n for (const nextOperation of sortedOperations) {\n const nextIndex = nextOperation.index - nextOperation.skip;\n\n if (nextIndex !== currentIndex + 1) {\n result.push({\n operation: {\n index: nextOperation.index,\n skip: nextOperation.skip,\n },\n issue: IntegrityIssueType.UNEXPECTED_INDEX,\n category:\n nextIndex > currentIndex + 1\n ? IntegrityIssueSubType.MISSING_INDEX\n : IntegrityIssueSubType.DUPLICATED_INDEX,\n message: `Expected index ${currentIndex + 1} with skip 0 or equivalent, got index ${nextOperation.index} with skip ${nextOperation.skip}`,\n });\n }\n\n currentIndex = nextOperation.index;\n }\n\n return result;\n}\n\n// [] -> []\n// [0:0] -> [0:0]\n\n// 0:0 1:0 2:0 => 0:0 1:0 2:0, removals 0, no issues\n// 0:0 1:1 2:0 => 1:1 2:0, removals 1, no issues\n\n// 0:0 1:1 2:0 3:1 => 1:1 3:1, removals 2, no issues\n// 0:0 1:1 2:0 3:3 => 3:3\n\n// 1:1 2:0 3:0 => 1:1 2:0 3:0, removals 0, no issues\n// 1:0 0:0 2:0 => 2:0, removals 2, issues [UNEXPECTED_INDEX, INDEX_OUT_OF_ORDER]\n// 0:0 1:0 2:0 => 0:0 1:0 2:0, removals 0, no issues\n// 0:0 1:0 2:0 => 0:0 1:0 2:0, removals 0, no issues\n// 0:0 1:0 2:0 => 0:0 1:0 2:0, removals 0, no issues\n\nexport function garbageCollect<A extends OperationIndex>(\n sortedOperations: A[],\n): A[] {\n const result: A[] = [];\n\n let i = sortedOperations.length - 1;\n\n while (i > -1) {\n result.unshift(sortedOperations[i]);\n const skipUntil =\n (sortedOperations[i]?.index || 0) - (sortedOperations[i]?.skip || 0) - 1;\n\n let j = i - 1;\n while (j > -1 && (sortedOperations[j]?.index || 0) > skipUntil) {\n j--;\n }\n\n i = j;\n }\n\n return result;\n}\n\nexport function addUndo(sortedOperations: Operation[]): Operation[] {\n const operationsCopy = [...sortedOperations];\n const latestOperation = operationsCopy[operationsCopy.length - 1];\n\n if (!latestOperation) return operationsCopy;\n\n if (latestOperation.type === \"NOOP\") {\n operationsCopy.push({\n ...latestOperation,\n index: latestOperation.index,\n type: \"NOOP\",\n skip: nextSkipNumber(sortedOperations),\n });\n } else {\n operationsCopy.push({\n type: \"NOOP\",\n index: latestOperation.index + 1,\n timestamp: new Date().toISOString(),\n input: {},\n skip: 1,\n scope: latestOperation.scope,\n hash: latestOperation.hash,\n });\n }\n\n return operationsCopy;\n}\n\n// [0:0 2:0 1:0 3:3 3:1] => [0:0 1:0 2:0 3:1 3:3]\n// Sort by index _and_ skip number\nexport function sortOperations<A extends OperationIndex>(operations: A[]): A[] {\n return operations\n .slice()\n .sort((a, b) => a.skip - b.skip)\n .sort((a, b) => a.index - b.index);\n}\n\n// [0:0, 1:0, 2:0, A3:0, A4:0, A5:0] + [0:0, 1:0, 2:0, B3:0, B4:2, B5:0]\n// GC => [0:0, 1:0, 2:0, A3:0, A4:0, A5:0] + [0:0, 1:0, B4:2, B5:0]\n// Split => [0:0, 1:0] + [2:0, A3:0, A4:0, A5:0] + [B4:2, B5:0]\n// Reshuffle(6:4) => [6:4, 7:0, 8:0, 9:0, 10:0, 11:0]\n// merge => [0:0, 1:0, 6:4, 7:0, 8:0, 9:0, 10:0, 11:0]\nexport const reshuffleByTimestamp: Reshuffle = (startIndex, opsA, opsB) => {\n return [...opsA, ...opsB]\n .sort(\n (a, b) =>\n new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime(),\n )\n .map((op, i) => ({\n ...op,\n index: startIndex.index + i,\n skip: i === 0 ? startIndex.skip : 0,\n }));\n};\n\nexport const reshuffleByTimestampAndIndex: Reshuffle = (\n startIndex,\n opsA,\n opsB,\n) => {\n return [...opsA, ...opsB]\n .sort(\n (a, b) =>\n new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime(),\n )\n .sort((a, b) => a.index - b.index)\n .map((op, i) => ({\n ...op,\n index: startIndex.index + i,\n skip: i === 0 ? startIndex.skip : 0,\n }));\n};\n\n// TODO: implement better operation equality function\nexport function operationsAreEqual(op1: Operation, op2: Operation) {\n return stringify(op1) === stringify(op2);\n}\n\n// [T0:0 T1:0 T2:0 T3:0] + [B4:0 B5:0] = [T0:0 T1:0 T2:0 T3:0 B4:0 B5:0]\n// [T0:0 T1:0 T2:0 T3:0] + [B3:0 B4:0] = [T0:0 T1:0 T2:0 B3:0 B4:0]\n// [T0:0 T1:0 T2:0 T3:0] + [B2:0 B3:0] = [T0:0 T1:0 B2:0 B3:0]\n\n// [T0:0 T1:0 T2:0 T3:0] + [B4:0 B4:2] = [T0:0 T1:0 T2:0 T3:0 B4:0 B4:2]\n// [T0:0 T1:0 T2:0 T3:0] + [B3:0 B3:2] = [T0:0 T1:0 T2:0 B3:0 B3:2]\n// [T0:0 T1:0 T2:0 T3:0] + [B2:3 B3:0] = [T0:0 T1:0 B2:3 B3:0]\n\nexport function attachBranch(\n trunk: Operation[],\n newBranch: Operation[],\n): [Operation[], Operation[]] {\n const trunkCopy = garbageCollect(sortOperations(trunk.slice()));\n const newOperations = garbageCollect(sortOperations(newBranch.slice()));\n if (trunkCopy.length < 1) {\n return [newOperations, []];\n }\n\n const result: Operation[] = [];\n let enteredBranch = false;\n\n while (newOperations.length > 0) {\n const newOperationCandidate = newOperations[0];\n\n let nextTrunkOperation = trunkCopy.shift();\n while (\n nextTrunkOperation &&\n precedes(nextTrunkOperation, newOperationCandidate)\n ) {\n result.push(nextTrunkOperation);\n nextTrunkOperation = trunkCopy.shift();\n }\n\n if (!nextTrunkOperation) {\n enteredBranch = true;\n } else if (!enteredBranch) {\n if (operationsAreEqual(nextTrunkOperation, newOperationCandidate)) {\n newOperations.shift();\n result.push(nextTrunkOperation);\n } else {\n trunkCopy.unshift(nextTrunkOperation);\n enteredBranch = true;\n }\n }\n\n if (enteredBranch) {\n let nextAppend = newOperations.shift();\n while (nextAppend) {\n result.push(nextAppend);\n nextAppend = newOperations.shift();\n }\n }\n }\n\n if (!enteredBranch) {\n let nextAppend = trunkCopy.shift();\n while (nextAppend) {\n result.push(nextAppend);\n nextAppend = trunkCopy.shift();\n }\n }\n\n return [garbageCollect(result), trunkCopy];\n}\n\nexport function precedes(op1: Operation, op2: Operation) {\n return (\n op1.index < op2.index ||\n (op1.index === op2.index && op1.id === op2.id && op1.skip < op2.skip)\n );\n}\n\nexport function split(\n sortedTargetOperations: Operation[],\n sortedMergeOperations: Operation[],\n): [Operation[], Operation[], Operation[]] {\n const commonOperations: Operation[] = [];\n const targetDiffOperations: Operation[] = [];\n const mergeDiffOperations: Operation[] = [];\n\n // get bigger array length\n const maxLength = Math.max(\n sortedTargetOperations.length,\n sortedMergeOperations.length,\n );\n\n let splitHappened = false;\n for (let i = 0; i < maxLength; i++) {\n const targetOperation = sortedTargetOperations[i];\n const mergeOperation = sortedMergeOperations[i];\n\n if (targetOperation && mergeOperation) {\n if (\n !splitHappened &&\n operationsAreEqual(targetOperation, mergeOperation)\n ) {\n commonOperations.push(targetOperation);\n } else {\n splitHappened = true;\n targetDiffOperations.push(targetOperation);\n mergeDiffOperations.push(mergeOperation);\n }\n } else if (targetOperation) {\n targetDiffOperations.push(targetOperation);\n } else if (mergeOperation) {\n mergeDiffOperations.push(mergeOperation);\n }\n }\n\n return [commonOperations, targetDiffOperations, mergeDiffOperations];\n}\n\n// [0:0, 1:0, 2:0, A3:0, A4:0, A5:0] + [0:0, 1:0, 2:0, B3:0, B4:2, B5:0]\n// GC => [0:0, 1:0, 2:0, A3:0, A4:0, A5:0] + [0:0, 1:0, B4:2, B5:0]\n// Split => [0:0, 1:0] + [2:0, A3:0, A4:0, A5:0] + [B4:2, B5:0]\n// Reshuffle(6:4) => [6:4, 7:0, 8:0, 9:0, 10:0, 11:0]\n// merge => [0:0, 1:0, 6:4, 7:0, 8:0, 9:0, 10:0, 11:0]\nexport function merge(\n sortedTargetOperations: Operation[],\n sortedMergeOperations: Operation[],\n reshuffle: Reshuffle,\n): Operation[] {\n const [_commonOperations, _targetOperations, _mergeOperations] = split(\n garbageCollect(sortedTargetOperations),\n garbageCollect(sortedMergeOperations),\n );\n\n const maxCommonIndex = getMaxIndex(_commonOperations);\n const nextIndex =\n 1 +\n Math.max(\n maxCommonIndex,\n getMaxIndex(_targetOperations),\n getMaxIndex(_mergeOperations),\n );\n\n const filteredMergeOperations = filterDuplicatedOperations(\n _mergeOperations,\n _targetOperations,\n );\n\n const newOperationHistory = reshuffle(\n {\n index: nextIndex,\n skip: nextIndex - (maxCommonIndex + 1),\n },\n _targetOperations,\n filteredMergeOperations,\n );\n\n return _commonOperations.concat(newOperationHistory);\n}\n\nfunction getMaxIndex(sortedOperations: Operation[]) {\n const lastElement = sortedOperations[sortedOperations.length - 1];\n if (!lastElement) {\n return -1;\n }\n\n return lastElement.index;\n}\n\n// [] => -1\n// [0:0] => -1\n// [0:0 1:0] => 1\n// [0:0 1:1] => -1\n// [1:1] => -1\n// [0:0 1:0 2:0] => 1\n// [0:0 1:0 2:0 2:1] => 2\n// [0:0 1:0 2:0 2:1 2:2] => -1\n// [0:0 1:1 2:0] => 2\n// [0:0 1:1 2:2] => -1\n// [0:0 1:1 2:0 3:0] => 1\n// [0:0 1:1 2:0 3:1] => 3\n// [0:0 1:1 2:0 3:3] => -1\n// [50:50 100:50 150:50 151:0 152:0 153:0 154:3] => 53\n\nexport function nextSkipNumber<A extends OperationIndex>(\n sortedOperations: A[],\n): number {\n if (sortedOperations.length < 1) {\n return -1;\n }\n\n const cleanedOperations = garbageCollect(sortedOperations);\n\n let nextSkip =\n (cleanedOperations[cleanedOperations.length - 1]?.skip || 0) + 1;\n\n if (cleanedOperations.length > 1) {\n nextSkip += cleanedOperations[cleanedOperations.length - 2]?.skip || 0;\n }\n\n return (cleanedOperations[cleanedOperations.length - 1]?.index || -1) <\n nextSkip\n ? -1\n : nextSkip;\n}\n\nexport const checkOperationsIntegrity = (\n operations: Operation[],\n): IntegrityIssue[] => {\n return checkCleanedOperationsIntegrity(\n garbageCollect(sortOperations(operations)),\n );\n};\n\nexport type OperationsByScope = Partial<Record<OperationScope, Operation[]>>;\n\nexport const groupOperationsByScope = (\n operations: Operation[],\n): OperationsByScope => {\n const result = operations.reduce<OperationsByScope>((acc, operation) => {\n if (!acc[operation.scope]) {\n acc[operation.scope] = [];\n }\n\n acc[operation.scope]?.push(operation);\n\n return acc;\n }, {});\n\n return result;\n};\n\ntype PrepareOperationsResult = {\n validOperations: Operation[];\n invalidOperations: Operation[];\n duplicatedOperations: Operation[];\n integrityIssues: IntegrityIssue[];\n};\n\nexport const prepareOperations = (\n operationsHistory: Operation[],\n newOperations: Operation[],\n): PrepareOperationsResult => {\n const result: PrepareOperationsResult = {\n integrityIssues: [],\n validOperations: [],\n invalidOperations: [],\n duplicatedOperations: [],\n };\n\n const sortedOperationsHistory = sortOperations(operationsHistory);\n const sortedOperations = sortOperations(newOperations);\n\n const integrityErrors = checkCleanedOperationsIntegrity([\n ...sortedOperationsHistory,\n ...sortedOperations,\n ]);\n\n const missingIndexErrors = integrityErrors.filter(\n (integrityIssue) =>\n integrityIssue.category === IntegrityIssueSubType.MISSING_INDEX,\n );\n\n // get the integrity error with the lowest index operation\n const firstMissingIndexOperation = [...missingIndexErrors]\n .sort((a, b) => b.operation.index - a.operation.index)\n .pop()?.operation;\n\n for (const newOperation of sortedOperations) {\n // Operation is missing index or it follows an operation that is missing index\n if (\n firstMissingIndexOperation &&\n newOperation.index >= firstMissingIndexOperation.index\n ) {\n result.invalidOperations.push(newOperation);\n continue;\n }\n\n // check if operation is duplicated\n const isDuplicatedOperation = integrityErrors.some((integrityError) => {\n return (\n integrityError.operation.index === newOperation.index &&\n integrityError.operation.skip === newOperation.skip &&\n integrityError.category === IntegrityIssueSubType.DUPLICATED_INDEX\n );\n });\n\n // add to duplicated operations if it is duplicated\n if (isDuplicatedOperation) {\n result.duplicatedOperations.push(newOperation);\n continue;\n }\n\n // otherwise, add to valid operations\n result.validOperations.push(newOperation);\n }\n\n result.integrityIssues.push(...integrityErrors);\n return result;\n};\n\nexport function removeExistingOperations(\n newOperations: Operation[],\n operationsHistory: Operation[],\n): Operation[] {\n return newOperations.filter((newOperation) => {\n return !operationsHistory.some((historyOperation) => {\n return (\n (newOperation.type === \"NOOP\" &&\n newOperation.skip === 0 &&\n newOperation.index === historyOperation.index) ||\n (newOperation.index === historyOperation.index &&\n newOperation.skip === historyOperation.skip &&\n newOperation.scope === historyOperation.scope &&\n newOperation.hash === historyOperation.hash &&\n newOperation.type === historyOperation.type)\n );\n });\n });\n}\n\nexport type SkipHeaderOperationIndex = Partial<Pick<OperationIndex, \"index\">> &\n Pick<OperationIndex, \"skip\">;\n\n/**\n * Skips header operations and returns the remaining operations.\n *\n * @param operations - The array of operations.\n * @param skipHeaderOperation - The skip header operation index.\n * @returns The remaining operations after skipping header operations.\n */\nexport function skipHeaderOperations<A extends OperationIndex>(\n operations: A[],\n skipHeaderOperation: SkipHeaderOperationIndex,\n): A[] {\n const [lastOperation] = sortOperations(operations).slice(-1);\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const lastIndex = lastOperation?.index ?? -1;\n const nextIndex = lastIndex + 1;\n\n const skipOperationIndex = {\n ...skipHeaderOperation,\n index: skipHeaderOperation.index ?? nextIndex,\n };\n\n if (skipOperationIndex.index < lastIndex) {\n throw new Error(\n `The skip header operation index must be greater than or equal to ${lastIndex}`,\n );\n }\n\n const clearedOperations = garbageCollect(\n sortOperations([...operations, skipOperationIndex]),\n );\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n return (clearedOperations || []).slice(0, -1) as A[];\n}\n\nexport function garbageCollectDocumentOperations<A extends Action>(\n documentOperations: DocumentOperations<A>,\n): DocumentOperations<A> {\n const clearedOperations = Object.entries(documentOperations).reduce(\n (acc, entry) => {\n const [scope, ops] = entry;\n\n return {\n ...acc,\n [scope as OperationScope]: garbageCollect(sortOperations(ops)),\n };\n },\n {},\n );\n\n return {\n ...clearedOperations,\n } as DocumentOperations<A>;\n}\n\n/**\n * Filters out duplicated operations from the target operations array based on their IDs.\n * If an operation has an ID, it is considered duplicated if there is another operation in the source operations array with the same ID.\n * If an operation does not have an ID, it is considered unique and will not be filtered out.\n * @param targetOperations - The array of target operations to filter.\n * @param sourceOperations - The array of source operations to compare against.\n * @returns An array of operations with duplicates filtered out.\n */\nexport function filterDuplicatedOperations(\n targetOperations: Operation[],\n sourceOperations: Operation[],\n): Operation[] {\n return targetOperations.filter((op) => {\n if (op.id) {\n return !sourceOperations.some((targetOp) => targetOp.id === op.id);\n }\n\n return true;\n });\n}\n\nexport function filterDocumentOperationsResultingState<A extends Action>(\n documentOperations?: DocumentOperations<A>,\n) {\n if (!documentOperations) {\n return {};\n }\n\n const entries = Object.entries(documentOperations);\n\n return entries.reduce<DocumentOperations<A>>(\n (acc, [scope, operations]) => ({\n ...acc,\n [scope]: operations.map((op) => {\n const { resultingState, ...restProps } = op;\n\n return restProps;\n }),\n }),\n {} as DocumentOperations<A>,\n );\n}\n\n/**\n * Calculates the difference between two arrays of operations.\n * Returns an array of operations that are present in `clearedOperationsA` but not in `clearedOperationsB`.\n *\n * @template A - The type of the operations.\n * @param {A[]} clearedOperationsA - The first array of operations.\n * @param {A[]} clearedOperationsB - The second array of operations.\n * @returns {A[]} - The difference between the two arrays of operations.\n */\nexport function diffOperations<A extends OperationIndex>(\n clearedOperationsA: A[],\n clearedOperationsB: A[],\n): A[] {\n return clearedOperationsA.filter(\n (operationA) =>\n !clearedOperationsB.some(\n (operationB) => operationA.index === operationB.index,\n ),\n );\n}\n","import JSZip from \"jszip\";\nimport mime from \"mime/lite\";\nimport type {\n Action,\n Attachment,\n AttachmentInput,\n Document,\n DocumentHeader,\n DocumentOperations,\n ExtendedState,\n Reducer,\n} from \"../types\";\nimport { fetchFile, getFile, hash, readFile, writeFile } from \"./node\";\nimport { replayDocument, ReplayDocumentOptions } from \"./base\";\nimport { validateOperations } from \"./validation\";\nimport {\n filterDocumentOperationsResultingState,\n garbageCollectDocumentOperations,\n} from \"./document-helpers\";\n\nexport type FileInput = string | number[] | Uint8Array | ArrayBuffer | Blob;\n\nexport const createZip = async (document: Document) => {\n // create zip file\n const zip = new JSZip();\n\n const { name, revision, documentType, created, lastModified } = document;\n const header: DocumentHeader = {\n name,\n revision,\n documentType,\n created,\n lastModified,\n };\n zip.file(\"header.json\", JSON.stringify(header, null, 2));\n zip.file(\"state.json\", JSON.stringify(document.initialState || {}, null, 2));\n zip.file(\"current-state.json\", JSON.stringify(document.state || {}, null, 2));\n zip.file(\n \"operations.json\",\n JSON.stringify(\n filterDocumentOperationsResultingState(document.operations),\n null,\n 2,\n ),\n );\n\n if (document.attachments) {\n const attachments = Object.keys(document.attachments);\n attachments.forEach((key) => {\n const { data, ...attributes } = document.attachments[key];\n zip.file(key, data, {\n base64: true,\n createFolders: true,\n comment: JSON.stringify(attributes),\n });\n });\n }\n\n return zip;\n};\n\n/**\n * Saves a document to a ZIP file.\n *\n * @remarks\n * This function creates a ZIP file containing the document's state, operations,\n * and file attachments. The file is saved to the specified path.\n *\n * @param document - The document to save to the file.\n * @param path - The path to save the file to.\n * @param extension - The extension to use for the file.\n * @returns A promise that resolves to the path of the saved file.\n */\nexport const saveToFile = async (\n document: Document,\n path: string,\n extension: string,\n name?: string,\n): Promise<string> => {\n // create zip file\n const zip = await createZip(document);\n const file = await zip.generateAsync({\n type: \"uint8array\",\n streamFiles: true,\n });\n const fileName = name ?? document.name;\n const fileExtension = `.${extension}.zip`;\n\n return writeFile(\n path,\n fileName.endsWith(fileExtension) ? fileName : `${fileName}${fileExtension}`,\n file,\n );\n};\n\nexport const saveToFileHandle = async (\n document: Document,\n input: FileSystemFileHandle,\n) => {\n const zip = await createZip(document);\n const blob = await zip.generateAsync({ type: \"blob\" });\n const writable = await input.createWritable();\n await writable.write(blob);\n await writable.close();\n};\n\n/**\n * Loads a document from a ZIP file.\n *\n * @remarks\n * This function reads a ZIP file and returns the document state after\n * applying all the operations. The reducer is used to apply the operations.\n *\n * @typeParam S - The type of the state object.\n * @typeParam A - The type of the actions that can be applied to the state object.\n *\n * @param path - The path to the ZIP file.\n * @param reducer - The reducer to apply the operations to the state object.\n * @returns A promise that resolves to the document state after applying all the operations.\n * @throws An error if the initial state or the operations history is not found in the ZIP file.\n */\nexport const loadFromFile = async <S, A extends Action, L>(\n path: string,\n reducer: Reducer<S, A, L>,\n options?: ReplayDocumentOptions,\n) => {\n const file = readFile(path);\n return loadFromInput(file, reducer, options);\n};\n\nexport const loadFromInput = async <S, A extends Action, L>(\n input: FileInput,\n reducer: Reducer<S, A, L>,\n options?: ReplayDocumentOptions,\n) => {\n const zip = new JSZip();\n await zip.loadAsync(input);\n return loadFromZip(zip, reducer, options);\n};\n\nasync function loadFromZip<S, A extends Action, L>(\n zip: JSZip,\n reducer: Reducer<S, A, L>,\n options?: ReplayDocumentOptions,\n) {\n const initialStateZip = zip.file(\"state.json\");\n if (!initialStateZip) {\n throw new Error(\"Initial state not found\");\n }\n const initialStateStr = await initialStateZip.async(\"string\");\n const initialState = JSON.parse(initialStateStr) as ExtendedState<S, L>;\n\n const headerZip = zip.file(\"header.json\");\n let header: DocumentHeader | undefined = undefined;\n if (headerZip) {\n header = JSON.parse(await headerZip.async(\"string\")) as DocumentHeader;\n }\n\n const operationsZip = zip.file(\"operations.json\");\n if (!operationsZip) {\n throw new Error(\"Operations history not found\");\n }\n\n const operations = JSON.parse(\n await operationsZip.async(\"string\"),\n ) as DocumentOperations<A>;\n\n const clearedOperations = garbageCollectDocumentOperations(operations);\n\n const operationsError = validateOperations(clearedOperations);\n if (operationsError.length) {\n const errorMessages = operationsError.map((err) => err.message);\n throw new Error(errorMessages.join(\"\\n\"));\n }\n\n let result = replayDocument(\n initialState,\n clearedOperations,\n reducer,\n undefined,\n header,\n {},\n options,\n );\n if (header) {\n result = {\n ...result,\n ...header,\n };\n }\n return result;\n}\n\nfunction getFileAttributes(\n file: string,\n): Omit<Attachment, \"data\" | \"mimeType\"> {\n const extension = file.replace(/^.*\\./, \"\") || undefined;\n const fileName = file.replace(/^.*[/\\\\]/, \"\") || undefined;\n return { extension, fileName };\n}\n\n/**\n * Fetches an attachment from a URL and returns its base64-encoded data and MIME type.\n * @param url - The URL of the attachment to fetch.\n * @returns A Promise that resolves to an object containing the base64-encoded data and MIME type of the attachment.\n */\nexport async function getRemoteFile(url: string): Promise<AttachmentInput> {\n const { buffer, mimeType = \"application/octet-stream\" } =\n await fetchFile(url);\n const attributes = getFileAttributes(url);\n const data = buffer.toString(\"base64\");\n return {\n data,\n hash: hash(data),\n mimeType,\n ...attributes,\n };\n}\n\n/**\n * Reads an attachment from a file and returns its base64-encoded data and MIME type.\n * @param path - The path of the attachment file to read.\n * @returns A Promise that resolves to an object containing the base64-encoded data and MIME type of the attachment.\n */\nexport async function getLocalFile(path: string): Promise<AttachmentInput> {\n const buffer = await getFile(path);\n const mimeType = mime.getType(path) || \"application/octet-stream\";\n const attributes = getFileAttributes(path);\n const data = buffer.toString(\"base64\");\n return { data, hash: hash(data), mimeType, ...attributes };\n}\n","import { castDraft, create } from \"mutative\";\nimport {\n Action,\n Document,\n ImmutableStateReducer,\n Operation,\n PruneAction,\n RedoAction,\n State,\n UndoAction,\n UndoRedoProcessResult,\n} from \"../types\";\nimport { hashDocument, replayOperations } from \"../utils/base\";\nimport { loadState, noop } from \"./creators\";\nimport { documentHelpers } from \"../utils\";\n\n// updates the name of the document\nexport function setNameOperation<T>(document: T, name: string): T {\n return { ...document, name };\n}\n\nexport function noopOperation<T, A extends Action, L>(\n document: Document<T, A, L>,\n action: Partial<Operation>,\n skip: number,\n) {\n const defaultValues = {\n skip,\n document,\n };\n\n const { scope } = action;\n\n if (!scope) return defaultValues;\n if (action.skip === undefined) return defaultValues;\n\n return create(defaultValues, (draft) => {\n const lastOperation = draft.document.operations[scope].at(-1);\n\n if (action.skip && action.skip > 0) {\n draft.skip = action.skip;\n }\n\n if (\n lastOperation &&\n lastOperation.type === \"NOOP\" &&\n action.index === lastOperation.index &&\n draft.skip > lastOperation.skip\n ) {\n draft.document.operations[scope].pop();\n }\n });\n}\n\nexport function undoOperation<T, A extends Action, L>(\n document: Document<T, A, L>,\n action: UndoAction,\n skip: number,\n): UndoRedoProcessResult<T, A, L> {\n // const scope = action.scope;\n const { scope, input } = action;\n\n const defaultResult: UndoRedoProcessResult<T, A, L> = {\n document,\n action,\n skip,\n reuseLastOperationIndex: false,\n };\n\n return create(defaultResult, (draft) => {\n const operations = [...document.operations[scope]];\n const sortedOperations = documentHelpers.sortOperations(operations);\n\n draft.action = noop(scope);\n\n const lastOperation = sortedOperations.at(-1);\n let nextIndex = lastOperation?.index ?? -1;\n\n const isNewNoop = lastOperation?.type !== \"NOOP\";\n\n if (isNewNoop) {\n nextIndex = nextIndex + 1;\n } else {\n draft.reuseLastOperationIndex = true;\n }\n\n const nextOperationHistory = isNewNoop\n ? [...sortedOperations, { index: nextIndex, skip: 0 }]\n : sortedOperations;\n\n draft.skip = documentHelpers.nextSkipNumber(nextOperationHistory);\n\n if (lastOperation && draft.skip > lastOperation.skip + 1) {\n // there's an overlap with a previous skip operation\n // (add 1 to the skip value because we are adding a new operation to the history)\n draft.skip = draft.skip + 1;\n }\n\n if (draft.skip < 0) {\n throw new Error(\n `Cannot undo: you can't undo more operations than the ones in the scope history`,\n );\n }\n });\n}\n\nexport function redoOperation<T, A extends Action, L>(\n document: Document<T, A, L>,\n action: RedoAction,\n skip: number,\n): UndoRedoProcessResult<T, A, L> {\n const { scope, input } = action;\n\n const defaultResult: UndoRedoProcessResult<T, A, L> = {\n document,\n action,\n skip,\n reuseLastOperationIndex: false,\n };\n\n return create(defaultResult, (draft) => {\n if (draft.skip > 0) {\n throw new Error(\n `Cannot redo: skip value from reducer cannot be used with REDO action`,\n );\n }\n\n if (input > 1) {\n throw new Error(`Cannot redo: you can only redo one operation at a time`);\n }\n\n if (input < 1) {\n throw new Error(`Invalid REDO action: invalid redo input value`);\n }\n\n if (draft.document.clipboard.length < 1) {\n throw new Error(`Cannot redo: no operations in the clipboard`);\n }\n\n const operationIndex = draft.document.clipboard.findLastIndex(\n (op) => op.scope === scope,\n );\n if (operationIndex < 0) {\n throw new Error(\n `Cannot redo: no operations in clipboard for scope \"${scope}\"`,\n );\n }\n\n const operation = draft.document.clipboard.splice(operationIndex, 1)[0];\n\n draft.action = castDraft({\n type: operation.type,\n scope: operation.scope,\n input: operation.input,\n } as A);\n });\n}\n\nexport function pruneOperation<T, A extends Action, L>(\n document: Document<T, A, L>,\n action: PruneAction,\n wrappedReducer: ImmutableStateReducer<T, A, L>,\n): Document<T, A, L> {\n const { scope } = action;\n const operations = document.operations[scope];\n\n let {\n input: { start, end },\n } = action;\n start = start || 0;\n end = end || operations.length;\n\n const actionsToPrune = operations.slice(start, end);\n const actionsToKeepStart = operations.slice(0, start);\n const actionsToKeepEnd = operations.slice(end);\n\n // runs all operations from the initial state to\n // the end of prune to get name and data\n const newDocument = replayOperations(\n document.initialState,\n {\n ...document.operations,\n [scope]: actionsToKeepStart.concat(actionsToPrune),\n },\n wrappedReducer,\n );\n\n const { name, state: newState } = newDocument;\n\n // the new operation has the index of the first pruned operation\n const loadStateIndex = actionsToKeepStart.length;\n\n // if and operation is pruned then reuses the timestamp of the last operation\n // if not then assigns the timestamp of the following unpruned operation\n const loadStateTimestamp = actionsToKeepStart.length\n ? actionsToKeepStart[actionsToKeepStart.length - 1].timestamp\n : actionsToKeepEnd.length\n ? actionsToKeepEnd[0].timestamp\n : new Date().toISOString();\n\n // replaces pruned operations with LOAD_STATE\n return replayOperations(\n document.initialState,\n {\n ...document.operations,\n [scope]: [\n ...actionsToKeepStart,\n {\n ...loadState({ name, state: newState }, actionsToPrune.length),\n timestamp: loadStateTimestamp,\n index: loadStateIndex,\n hash: hashDocument({ state: newState }, \"global\"),\n },\n ...actionsToKeepEnd\n // updates the index for all the following operations\n .map((action, index) => ({\n ...action,\n index: loadStateIndex + index + 1,\n })),\n ],\n },\n wrappedReducer,\n );\n}\n\nexport function loadStateOperation<T, A extends Action, L>(\n oldDocument: Document<T, A, L>,\n newDocument: { name: string; state?: State<T, L> },\n): Document<T, A, L> {\n return {\n ...oldDocument,\n name: newDocument.name,\n state: newDocument.state ?? ({ global: {}, local: {} } as State<T, L>),\n };\n}\n\nexport * from \"./creators\";\n","import type { Action } from \"../types\";\nimport type {\n LoadStateActionInput,\n PruneActionInput,\n RedoAction as _RedoAction,\n SetNameAction as _SetNameAction,\n UndoAction as _UndoAction,\n} from \"../schema/types\";\n\nexport const SET_NAME = \"SET_NAME\";\nexport const UNDO = \"UNDO\";\nexport const REDO = \"REDO\";\nexport const PRUNE = \"PRUNE\";\nexport const LOAD_STATE = \"LOAD_STATE\";\nexport const NOOP = \"NOOP\";\n\nexport type LoadStateAction = Action<\"LOAD_STATE\", LoadStateActionInput>;\nexport type PruneAction = Action<\"PRUNE\", PruneActionInput>;\nexport type RedoAction = Action<\"REDO\", _RedoAction[\"input\"]>;\nexport type SetNameAction = Action<\"SET_NAME\", _SetNameAction[\"input\"]>;\nexport type UndoAction = Action<\"UNDO\", _UndoAction[\"input\"]>;\nexport type NOOPAction = Action<\"NOOP\">;\n\nexport type BaseAction =\n | LoadStateAction\n | PruneAction\n | RedoAction\n | SetNameAction\n | UndoAction\n | NOOPAction;\n","import { create, castDraft, Draft, unsafe } from \"mutative\";\nimport { v4 as uuid } from \"uuid\";\nimport {\n loadStateOperation,\n pruneOperation,\n redoOperation,\n setNameOperation,\n undoOperation,\n} from \"./actions\";\nimport {\n BaseAction,\n LOAD_STATE,\n PRUNE,\n REDO,\n SET_NAME,\n UNDO,\n} from \"./actions/types\";\nimport { UndoRedoAction, z } from \"./schema\";\nimport {\n Action,\n Document,\n ImmutableStateReducer,\n Operation,\n OperationScope,\n ReducerOptions,\n State,\n} from \"./types\";\nimport {\n isBaseAction,\n hashDocument,\n replayOperations,\n isUndoRedo,\n isUndo,\n getDocumentLastModified,\n parseResultingState,\n} from \"./utils/base\";\nimport { SignalDispatch } from \"./signal\";\nimport * as documentHelpers from \"./utils/document-helpers\";\n\n/**\n * Gets the next revision number based on the provided action.\n *\n * @param state The current state of the document.\n * @param action The action being applied to the document.\n * @returns The next revision number.\n */\nfunction getNextRevision(\n document: Document,\n action: Action | Operation,\n): number {\n let latestOperation: Operation | undefined;\n\n if (\"index\" in action) {\n latestOperation = { ...action };\n } else {\n latestOperation = document.operations[action.scope].at(-1);\n }\n\n return (latestOperation?.index ?? -1) + 1;\n}\n\n/**\n * Updates the document header with the latest revision number and\n * date of last modification.\n *\n * @param state The current state of the document.\n * @param action The action being applied to the document.\n * @returns The updated document state.\n */\nexport function updateHeader<T extends Document>(\n document: T,\n action: Action,\n): T {\n return {\n ...document,\n revision: {\n ...document.revision,\n [action.scope]: getNextRevision(document, action),\n },\n lastModified: getDocumentLastModified(document),\n };\n}\n\n/**\n * Updates the operations history of the document based on the provided action.\n *\n * @param state The current state of the document.\n * @param action The action being applied to the document.\n * @param skip The number of operations to skip before applying the action.\n * @param reuseLastOperationIndex Whether to reuse the last operation index (used when a an UNDO operation is performed after an existing one).\n * @returns The updated document state.\n */\nfunction updateOperations<T extends Document>(\n document: T,\n action: Action | Operation,\n skip = 0,\n reuseLastOperationIndex = false,\n): T {\n // UNDO, REDO and PRUNE are meta operations\n // that alter the operations history themselves\n if ([UNDO, REDO, PRUNE].includes(action.type)) {\n return document;\n }\n\n const { scope } = action;\n const operations = document.operations[scope].slice();\n let operationId: string | undefined;\n\n const latestOperation = operations.at(-1);\n const lastOperationIndex = latestOperation?.index ?? -1;\n\n let nextIndex = reuseLastOperationIndex\n ? lastOperationIndex\n : lastOperationIndex + 1;\n\n let timestamp = new Date().toISOString();\n\n if (\"index\" in action) {\n if (action.index - skip > nextIndex) {\n throw new Error(\n `Missing operations: expected ${nextIndex} with skip 0 or equivalent, got index ${action.index} with skip ${skip}`,\n );\n }\n\n nextIndex = action.index;\n operationId = action.id;\n\n timestamp = action.timestamp;\n } else {\n operationId = \"id\" in action ? (action.id as string) : uuid();\n }\n\n operations.push({\n ...action,\n id: operationId,\n index: nextIndex,\n timestamp,\n hash: \"\",\n scope,\n skip,\n error: undefined,\n });\n\n // adds the action to the operations history with\n // the latest index and current timestamp\n return {\n ...document,\n operations: { ...document.operations, [scope]: operations },\n };\n}\n\n/**\n * Updates the document state based on the provided action.\n *\n * @param state The current state of the document.\n * @param action The action being applied to the document.\n * @param skip The number of operations to skip before applying the action.\n * @param reuseLastOperationIndex Whether to reuse the last operation index (used when a an UNDO operation is performed after an existing one).\n * @returns The updated document state.\n */\nexport function updateDocument<T extends Document>(\n document: T,\n action: Action,\n skip = 0,\n reuseLastOperationIndex = false,\n) {\n let newDocument = updateOperations(\n document,\n action,\n skip,\n reuseLastOperationIndex,\n );\n newDocument = updateHeader(newDocument, action);\n return newDocument;\n}\n\n/**\n * The base document reducer function that wraps a custom reducer function.\n *\n * @param state The current state of the document.\n * @param action The action being applied to the document.\n * @param wrappedReducer The custom reducer function being wrapped by the base reducer.\n * @returns The updated document state.\n */\nfunction _baseReducer<T, A extends Action, L>(\n document: Document<T, A, L>,\n action: BaseAction,\n wrappedReducer: ImmutableStateReducer<T, A, L>,\n): Document<T, A, L> {\n // throws if action is not valid base action\n z.BaseActionSchema().parse(action);\n\n switch (action.type) {\n case SET_NAME:\n return setNameOperation(document, action.input);\n case PRUNE:\n return pruneOperation(document, action, wrappedReducer);\n case LOAD_STATE:\n return loadStateOperation(document, action.input.state);\n default:\n return document;\n }\n}\n\ntype UndoRedoProcessResult<T, A extends Action, L> = {\n document: Document<T, A, L>;\n action: A | BaseAction;\n skip: number;\n reuseLastOperationIndex: boolean;\n};\n\n/**\n * Processes an UNDO or REDO action.\n *\n * @param document The current state of the document.\n * @param action The action being applied to the document.\n * @param skip The number of operations to skip before applying the action.\n * @returns The updated document, calculated skip value and transformed action (if apply).\n */\nexport function processUndoRedo<T, A extends Action, L>(\n document: Document<T, A, L>,\n action: UndoRedoAction,\n skip: number,\n): UndoRedoProcessResult<T, A, L> {\n switch (action.type) {\n case UNDO:\n return undoOperation(document, action, skip);\n case REDO:\n return redoOperation(document, action, skip);\n default:\n return { document, action, skip, reuseLastOperationIndex: false };\n }\n}\n\n/**\n * Processes a skip operation on a document.\n *\n * @template T - The type of the document state.\n * @template A - The type of the document actions.\n * @template L - The type of the document labels.\n * @param {Document<T, A, L>} document - The document to process the skip operation on.\n * @param {A | BaseAction | Operation} action - The action or operation to process.\n * @param {ImmutableStateReducer<T, A, L>} customReducer - The custom reducer function for the document state.\n * @param {number} skipValue - The value to skip.\n * @returns {Document<T, A, L>} - The updated document after processing the skip operation.\n */\nfunction processSkipOperation<\n T,\n A extends Action,\n L,\n D extends Document<T, A, L>,\n>(\n document: D,\n action: A | BaseAction | Operation,\n customReducer: ImmutableStateReducer<T, A, L>,\n skipValue: number,\n reuseOperationResultingState = false,\n resultingStateParser = parseResultingState,\n): D {\n const scope = action.scope;\n\n const latestOperation = document.operations[scope].at(-1);\n\n if (!latestOperation) return document;\n\n const documentOperations = documentHelpers.garbageCollectDocumentOperations({\n ...document.operations,\n [scope]: documentHelpers.skipHeaderOperations(\n document.operations[scope],\n latestOperation,\n ),\n });\n\n let scopeState: T | L | undefined = undefined;\n const lastRemainingOperation = documentOperations[scope].at(-1);\n\n // if the last operation has the resulting state and\n // reuseOperationResultingState is true then reuses it\n // instead of replaying the operations from the beginning\n if (reuseOperationResultingState && lastRemainingOperation?.resultingState) {\n scopeState = resultingStateParser(lastRemainingOperation.resultingState) as\n | T\n | L;\n } else {\n const { state } = replayOperations(\n document.initialState,\n documentOperations,\n customReducer,\n undefined,\n undefined,\n undefined,\n undefined,\n {\n reuseHash: true,\n reuseOperationResultingState,\n operationResultingStateParser: resultingStateParser,\n },\n );\n scopeState = state[scope];\n }\n\n return {\n ...document,\n state: {\n ...document.state,\n [scope]: scopeState,\n },\n operations: documentHelpers.garbageCollectDocumentOperations({\n ...document.operations,\n }),\n };\n}\n\nfunction processUndoOperation<\n T,\n A extends Action,\n L,\n D extends Document<T, A, L>,\n>(\n document: D,\n scope: OperationScope,\n customReducer: ImmutableStateReducer<T, A, L>,\n reuseOperationResultingState = false,\n resultingStateParser = parseResultingState,\n): Document<T, A, L> {\n const operations = [...document.operations[scope]];\n const sortedOperations = documentHelpers.sortOperations(operations);\n\n sortedOperations.pop();\n\n const documentOperations = documentHelpers.garbageCollectDocumentOperations({\n ...document.operations,\n });\n\n const clearedOperations = [...documentOperations[scope]];\n const diff = documentHelpers.diffOperations(\n documentHelpers.garbageCollect(sortedOperations),\n clearedOperations,\n );\n\n const doc = replayOperations(\n document.initialState,\n documentOperations,\n customReducer,\n undefined,\n undefined,\n undefined,\n undefined,\n {\n reuseHash: true,\n reuseOperationResultingState,\n operationResultingStateParser: resultingStateParser,\n },\n );\n\n const clipboard = documentHelpers\n .sortOperations(\n [...document.clipboard, ...diff].filter((op) => op.type !== \"NOOP\"),\n )\n .reverse();\n\n return { ...doc, clipboard };\n}\n\n/**\n * Base document reducer that wraps a custom document reducer and handles\n * document-level actions such as undo, redo, prune, and set name.\n *\n * @template T - The type of the state of the custom reducer.\n * @template A - The type of the actions of the custom reducer.\n * @param state - The current state of the document.\n * @param action - The action object to apply to the state.\n * @param customReducer - The custom reducer that implements the application logic\n * specific to the document's state.\n * @returns The new state of the document.\n */\nexport function baseReducer<T, A extends Action, L>(\n document: Document<T, A, L>,\n action: A | BaseAction | Operation,\n customReducer: ImmutableStateReducer<T, A, L>,\n dispatch?: SignalDispatch,\n options: ReducerOptions = {},\n) {\n const {\n skip,\n ignoreSkipOperations = false,\n reuseHash = false,\n reuseOperationResultingState = false,\n operationResultingStateParser,\n } = options;\n\n let _action = { ...action };\n let skipValue = skip || 0;\n let newDocument: Document<T, A, L> = { ...document };\n let reuseLastOperationIndex = false;\n\n const shouldProcessSkipOperation =\n !ignoreSkipOperations &&\n (skipValue > 0 || (\"index\" in _action && _action.skip > 0));\n\n if (isUndoRedo(_action)) {\n const {\n skip: calculatedSkip,\n action: transformedAction,\n document: processedDocument,\n reuseLastOperationIndex: reuseIndex,\n } = processUndoRedo(document, _action, skipValue);\n\n _action = transformedAction;\n skipValue = calculatedSkip;\n newDocument = processedDocument;\n reuseLastOperationIndex = reuseIndex;\n } else {\n newDocument = {\n ...newDocument,\n clipboard: [],\n };\n }\n\n // if the action is one the base document actions (SET_NAME, UNDO, REDO, PRUNE)\n // then runs the base reducer first\n if (isBaseAction(_action)) {\n newDocument = _baseReducer(newDocument, _action, customReducer);\n }\n\n // updates the document revision number, last modified date\n // and operation history\n newDocument = updateDocument(\n newDocument,\n _action,\n skipValue,\n reuseLastOperationIndex,\n );\n\n const isUndoAction = isUndo(action);\n\n if (isUndoAction) {\n const result = processUndoOperation(\n newDocument,\n action.scope,\n customReducer,\n );\n\n return result;\n }\n\n if (shouldProcessSkipOperation) {\n newDocument = processSkipOperation(\n newDocument,\n _action,\n customReducer,\n skipValue,\n reuseOperationResultingState,\n operationResultingStateParser,\n );\n }\n\n // wraps the custom reducer with Mutative to avoid\n // mutation bugs and allow writing reducers with\n // mutating code\n newDocument = create(newDocument, (draft) => {\n // the reducer runs on a immutable version of\n // provided state\n try {\n const newState = customReducer(draft.state, _action as A, dispatch);\n\n // const clipboardValue = isUndoRedo(action) ? [...clipboard] : [];\n\n // if the reducer creates a new state object instead\n // of mutating the draft then returns the new state\n if (newState) {\n // Object.assign(draft.state, newState);\n unsafe(() => {\n // casts new state as draft to comply with typescript\n draft.state = castDraft(newState);\n // clipboard: [...clipboardValue],\n });\n } else {\n // unsafe(() => {\n // draft.clipboard = castDraft([...clipboardValue]);\n // });\n }\n } catch (error) {\n // if the reducer throws an error then we should keep the previous state (before replayOperations)\n // and remove skip number from action/operation\n const lastOperationIndex =\n newDocument.operations[_action.scope].length - 1;\n draft.operations[_action.scope][lastOperationIndex].error = (\n error as Error\n ).message;\n\n draft.operations[_action.scope][lastOperationIndex].skip = 0;\n\n if (shouldProcessSkipOperation) {\n draft.state = castDraft<State<T, L>>({ ...document.state });\n draft.operations = castDraft({\n ...document.operations,\n [_action.scope]: [\n ...document.operations[_action.scope],\n {\n ...draft.operations[_action.scope][lastOperationIndex],\n },\n ],\n });\n }\n }\n });\n // updates the document history\n // meta operations are not added to the operations history\n if ([UNDO, REDO, PRUNE].includes(_action.type)) {\n return newDocument;\n }\n\n // if reuseHash is true, checks if the action has\n // an hash and uses it instead of generating it\n const scope = _action.scope || \"global\";\n const hash =\n reuseHash && Object.prototype.hasOwnProperty.call(_action, \"hash\")\n ? (_action as Operation).hash\n : hashDocument(newDocument, scope);\n\n // updates the last operation with the hash of the resulting state\n const lastOperation = newDocument.operations[scope].at(-1);\n if (lastOperation) {\n lastOperation.hash = hash;\n\n if (reuseOperationResultingState) {\n lastOperation.resultingState = newDocument.state[scope];\n }\n\n // if the action has attachments then adds them to the document\n if (!isBaseAction(_action) && _action.attachments) {\n _action.attachments.forEach((attachment) => {\n const { hash, ...file } = attachment;\n newDocument.attachments[hash] = {\n ...file,\n };\n });\n }\n }\n\n return newDocument;\n}\n\n/**\n * Base document reducer that wraps a custom document reducer and handles\n * document-level actions such as undo, redo, prune, and set name.\n *\n * @template T - The type of the state of the custom reducer.\n * @template A - The type of the actions of the custom reducer.\n * @param state - The current state of the document.\n * @param action - The action object to apply to the state.\n * @param customReducer - The custom reducer that implements the application logic\n * specific to the document's state.\n * @returns The new state of the document.\n */\nexport function mutableBaseReducer<T, A extends Action, L>(\n document: Document<T, A, L>,\n action: A | BaseAction | Operation,\n customReducer: ImmutableStateReducer<T, A, L>,\n dispatch?: SignalDispatch,\n options: ReducerOptions = {},\n) {\n const {\n skip,\n ignoreSkipOperations = false,\n reuseHash = false,\n reuseOperationResultingState = false,\n operationResultingStateParser,\n } = options;\n\n const _action = { ...action };\n const skipValue = skip || 0;\n let newDocument: Document<T, A, L> = { ...document };\n // let clipboard = [...document.clipboard];\n\n const shouldProcessSkipOperation =\n !ignoreSkipOperations &&\n (skipValue > 0 || (\"index\" in _action && _action.skip > 0));\n\n // if the action is one the base document actions (SET_NAME, UNDO, REDO, PRUNE)\n // then runs the base reducer first\n if (isBaseAction(_action)) {\n newDocument = _baseReducer(newDocument, _action, customReducer);\n }\n\n // updates the document revision number, last modified date\n // and operation history\n newDocument = updateDocument(newDocument, _action, skipValue);\n\n if (shouldProcessSkipOperation) {\n newDocument = processSkipOperation(\n newDocument,\n _action,\n customReducer,\n skipValue,\n reuseOperationResultingState,\n operationResultingStateParser,\n );\n }\n\n try {\n const newState = customReducer(\n newDocument.state as Draft<State<T, L>>,\n _action as A,\n dispatch,\n );\n if (newState) {\n newDocument.state = newState;\n }\n } catch (error) {\n // if the reducer throws an error then we should keep the previous state (before replayOperations)\n // and remove skip number from action/operation\n const lastOperationIndex = newDocument.operations[_action.scope].length - 1;\n newDocument.operations[_action.scope][lastOperationIndex].error = (\n error as Error\n ).message;\n newDocument.operations[_action.scope][lastOperationIndex].skip = 0;\n\n if (shouldProcessSkipOperation) {\n newDocument.state = { ...document.state };\n newDocument.operations = {\n ...document.operations,\n [_action.scope]: [\n ...document.operations[_action.scope],\n {\n ...newDocument.operations[_action.scope][lastOperationIndex],\n },\n ],\n };\n }\n }\n\n if ([UNDO, REDO, PRUNE].includes(_action.type)) {\n return newDocument;\n }\n\n // if reuseHash is true, checks if the action has\n // an hash and uses it instead of generating it\n const scope = _action.scope || \"global\";\n const hash =\n reuseHash && Object.prototype.hasOwnProperty.call(_action, \"hash\")\n ? (_action as Operation).hash\n : hashDocument(newDocument, scope);\n\n // updates the last operation with the hash of the resulting state\n const lastOperation = newDocument.operations[scope].at(-1);\n if (lastOperation) {\n lastOperation.hash = hash;\n\n if (reuseOperationResultingState) {\n lastOperation.resultingState = newDocument.state[scope];\n }\n\n // if the action has attachments then adds them to the document\n if (!isBaseAction(_action) && _action.attachments) {\n _action.attachments.forEach((attachment) => {\n const { hash, ...file } = attachment;\n newDocument.attachments[hash] = {\n ...file,\n };\n });\n }\n }\n return newDocument;\n}\n","import stringifyJson from \"safe-stable-stringify\";\nimport { baseReducer, mutableBaseReducer, updateHeader } from \"../reducer\";\nimport {\n Action,\n BaseAction,\n UndoRedoAction,\n Document,\n ExtendedState,\n ImmutableStateReducer,\n Reducer,\n OperationScope,\n State,\n CreateState,\n PartialState,\n DocumentOperations,\n DocumentHeader,\n DocumentOperationsIgnoreMap,\n Operation,\n MappedOperation,\n ReducerOptions,\n UndoAction,\n} from \"../types\";\nimport { hash } from \"./node\";\nimport {\n LOAD_STATE,\n PRUNE,\n REDO,\n SET_NAME,\n UNDO,\n NOOP,\n} from \"../actions/types\";\nimport { SignalDispatch } from \"../signal\";\n\nexport function isNoopOperation(op: Partial<Operation>): boolean {\n return (\n op.type === NOOP &&\n op.skip !== undefined &&\n op.skip > 0 &&\n op.hash !== undefined\n );\n}\n\nexport function isUndoRedo(action: Action): action is UndoRedoAction {\n return [UNDO, REDO].includes(action.type);\n}\n\nexport function isUndo(action: Action): action is UndoAction {\n return action.type === UNDO;\n}\n\nexport function isBaseAction(action: Action): action is BaseAction {\n return [SET_NAME, UNDO, REDO, PRUNE, LOAD_STATE].includes(action.type);\n}\n\n/**\n * Helper function to be used by action creators.\n *\n * @remarks\n * Creates an action with the given type and input properties. The input\n * properties default to an empty object.\n *\n * @typeParam A - Type of the action to be returned.\n *\n * @param type - The type of the action.\n * @param input - The input properties of the action.\n * @param attachments - The attachments included in the action.\n * @param validator - The validator to use for the input properties.\n * @param scope - The scope of the action, can either be 'global' or 'local'.\n * @param skip - The number of operations to skip before this new action is applied.\n *\n * @throws Error if the type is empty or not a string.\n *\n * @returns The new action.\n */\nexport function createAction<A extends Action>(\n type: A[\"type\"],\n input?: A[\"input\"],\n attachments?: Action[\"attachments\"],\n validator?: () => { parse(v: unknown): A[\"input\"] },\n scope: OperationScope = \"global\",\n): A {\n if (!type) {\n throw new Error(\"Empty action type\");\n }\n\n if (typeof type !== \"string\") {\n throw new Error(`Invalid action type: ${JSON.stringify(type)}`);\n }\n\n const action: Action = { type, input, scope };\n\n if (attachments) {\n action.attachments = attachments;\n }\n\n try {\n validator?.().parse(action.input);\n } catch (error) {\n throw new Error(`Invalid action input: ${error}`);\n }\n\n return action as A;\n}\n\n/**\n * Helper function to create a document model reducer.\n *\n * @remarks\n * This function creates a new reducer that wraps the provided `reducer` with\n * `documentReducer`, adding support for document actions:\n * - `SET_NAME`\n * - `UNDO`\n * - `REDO`\n * - `PRUNE`\n *\n * It also updates the document-related attributes on every operation.\n *\n * @param reducer - The custom reducer to wrap.\n * @param documentReducer - The document reducer to use.\n *\n * @returns The new reducer.\n */\nexport function createReducer<\n S = unknown,\n A extends Action = Action,\n L = unknown,\n>(\n reducer: ImmutableStateReducer<S, A, L>,\n documentReducer = baseReducer,\n): Reducer<S, A, L> {\n return (document, action, dispatch, options) => {\n return documentReducer(document, action, reducer, dispatch, options);\n };\n}\n\nexport function createUnsafeReducer<\n S = unknown,\n A extends Action = Action,\n L = unknown,\n>(\n reducer: ImmutableStateReducer<S, A, L>,\n documentReducer = mutableBaseReducer,\n): Reducer<S, A, L> {\n return (document, action, dispatch, options) => {\n return documentReducer(document, action, reducer, dispatch, options);\n };\n}\n\nexport const createExtendedState = <S, L>(\n initialState?: Partial<ExtendedState<PartialState<S>, PartialState<L>>>,\n createState?: CreateState<S, L>,\n): ExtendedState<S, L> => {\n return {\n name: \"\",\n documentType: \"\",\n revision: {\n global: 0,\n local: 0,\n },\n created: new Date().toISOString(),\n lastModified: new Date().toISOString(),\n attachments: {},\n ...initialState,\n state:\n createState?.(initialState?.state) ??\n ((initialState?.state ?? { global: {}, local: {} }) as State<S, L>),\n };\n};\n\n/**\n * Builds the initial document state from the provided data.\n *\n * @typeParam T - The type of the data.\n * @typeParam A - The type of the actions.\n *\n * @param initialState - The initial state of the document. The `data` property\n * is required, but all other properties are optional.\n *\n * @returns The new document state.\n */\nexport const createDocument = <S, A extends Action, L = unknown>(\n initialState?: Partial<ExtendedState<PartialState<S>, PartialState<L>>>,\n createState?: (\n state?: Partial<State<PartialState<S>, PartialState<L>>>,\n ) => State<S, L>,\n): Document<S, A, L> => {\n const state: ExtendedState<S, L> = createExtendedState(\n initialState,\n createState,\n );\n return {\n ...state,\n initialState: state,\n operations: { global: [], local: [] },\n clipboard: [],\n };\n};\n\n// export const stringifyJson = configureStringify\n\nexport const hashDocument = (\n document: Pick<Document, \"state\">,\n scope: OperationScope = \"global\",\n) => {\n return hash(stringifyJson(document.state[scope] || \"\"));\n};\n\nexport const hashKey = (date?: Date, randomLimit = 1000) => {\n const random = Math.random() * randomLimit;\n return hash(`${(date ?? new Date()).toISOString()}${random}`);\n};\n\nexport function readOnly<T>(value: T): Readonly<T> {\n return Object.freeze(value);\n}\n\n/**\n * Maps skipped operations in an array of operations.\n * Skipped operations are operations that are ignored during processing.\n * @param operations - The array of operations to map.\n * @param skippedHeadOperations - The number of operations to skip at the head of the array of operations.\n * @returns An array of mapped operations with ignore flag indicating if the operation is skipped.\n * @throws Error if the operation index is invalid and there are missing operations.\n */\nexport function mapSkippedOperations<A extends Action>(\n operations: Operation<BaseAction | A>[],\n skippedHeadOperations?: number,\n): MappedOperation<A>[] {\n const ops = [...operations];\n\n let skipped = skippedHeadOperations || 0;\n let latestOpIndex = ops.length > 0 ? ops[ops.length - 1].index : 0;\n\n const scopeOpsWithIgnore = [] as MappedOperation<A>[];\n\n for (const operation of ops.reverse()) {\n if (skipped > 0) {\n const operationsDiff = latestOpIndex - operation.index;\n skipped -= operationsDiff;\n }\n\n if (skipped < 0) {\n throw new Error(\"Invalid operation index, missing operations\");\n }\n\n const mappedOp = {\n ignore: skipped > 0,\n operation,\n };\n\n // here we add 1 to the skip number because we want to get the number of\n // operations that we want to move the pointer back to get the latest valid operation\n // operation.skip = 1 means that we want to move the pointer back 2 operations to get to the latest valid operation\n const operationSkip = operation.skip > 0 ? operation.skip + 1 : 0;\n\n if (operationSkip > 0 && operationSkip > skipped) {\n const skipDiff = operationSkip - skipped;\n skipped = skipped + skipDiff;\n }\n\n latestOpIndex = operation.index;\n scopeOpsWithIgnore.push(mappedOp);\n }\n\n return scopeOpsWithIgnore.reverse();\n}\n\n// Flattens the operations from all scopes into\n// a single array and sorts them by timestamp\nexport function sortOperations<A extends Action>(\n operations: DocumentOperations<A>,\n) {\n return Object.values(operations)\n .flatMap((array) => array)\n .sort(\n (a, b) =>\n new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime(),\n );\n}\n\n// Flattens the mapped operations (with ignore flag) from all scopes into\n// a single array and sorts them by timestamp\nexport function sortMappedOperations<A extends Action>(\n operations: DocumentOperationsIgnoreMap<A>,\n) {\n return Object.values(operations)\n .flatMap((array) => array)\n .sort(\n (a, b) =>\n new Date(a.operation.timestamp).getTime() -\n new Date(b.operation.timestamp).getTime(),\n );\n}\n\n// gets the last modified timestamp of a document from\n// it's operations, falling back to the initial state\nexport function getDocumentLastModified(document: Document) {\n const sortedOperations = sortOperations(document.operations);\n const timestamp =\n sortedOperations.at(-1)?.timestamp || document.initialState.lastModified;\n return timestamp;\n}\n\n// Runs the operations on the initial data using the\n// provided reducer, wrapped with the document reducer.\n// This rebuilds the document according to the provided actions.\nexport function replayOperations<T, A extends Action, L>(\n initialState: ExtendedState<T, L>,\n clearedOperations: DocumentOperations<A>,\n reducer: ImmutableStateReducer<T, A, L>,\n dispatch?: SignalDispatch,\n header?: DocumentHeader,\n documentReducer = baseReducer,\n skipHeaderOperations: SkipHeaderOperations = {},\n options?: ReducerOptions,\n): Document<T, A, L> {\n // wraps the provided custom reducer with the\n // base document reducer\n const wrappedReducer = createReducer(reducer, documentReducer);\n\n return replayDocument(\n initialState,\n clearedOperations,\n wrappedReducer,\n dispatch,\n header,\n skipHeaderOperations,\n options,\n );\n}\n\nexport type SkipHeaderOperations = Partial<Record<OperationScope, number>>;\n\nexport type ReplayDocumentOptions = {\n // if false then reuses the hash from the operations\n // and only checks the final hash of each scope\n checkHashes?: boolean;\n // if true then looks for the latest operation with\n // a resulting state and uses it as a starting point\n reuseOperationResultingState?: boolean;\n // Optional parser for the operation resulting state, uses JSON.parse by default\n operationResultingStateParser?: (state: unknown) => object;\n};\n\n// Runs the operations on the initial data using the\n// provided document reducer.\n// This rebuilds the document according to the provided actions.\nexport function replayDocument<T, A extends Action, L>(\n initialState: ExtendedState<T, L>,\n operations: DocumentOperations<A>,\n reducer: Reducer<T, A, L>,\n dispatch?: SignalDispatch,\n header?: DocumentHeader,\n skipHeaderOperations: SkipHeaderOperations = {},\n options?: ReplayDocumentOptions,\n): Document<T, A, L> {\n const {\n checkHashes = true,\n reuseOperationResultingState,\n operationResultingStateParser = parseResultingState,\n } = options || {};\n\n let documentState = initialState;\n const operationsToReplay = [] as Operation<A | BaseAction>[];\n const initialOperations: DocumentOperations<A> = {\n global: [],\n local: [],\n };\n\n // if operation resulting state is to be used then\n // looks for the last operation with state of each\n // scope to use it as the starting point and only\n // replay operations that follow it\n if (reuseOperationResultingState) {\n for (const [scope, scopeOperations] of Object.entries(operations)) {\n const index = scopeOperations.findLastIndex((s) => !!s.resultingState);\n if (index < 0) {\n operationsToReplay.push(...scopeOperations);\n continue;\n }\n const opWithState = scopeOperations[index];\n try {\n const scopeState = operationResultingStateParser(\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-unnecessary-type-assertion\n opWithState.resultingState!,\n );\n documentState = {\n ...documentState,\n state: {\n ...documentState.state,\n // TODO how to deal with attachments?\n [scope]: scopeState,\n },\n };\n initialOperations[scope as keyof DocumentOperations<A>].push(\n ...scopeOperations.slice(0, index + 1),\n );\n operationsToReplay.push(...scopeOperations.slice(index + 1));\n } catch {\n /* if parsing fails then keeps replays all scope operations */\n operationsToReplay.push(...scopeOperations);\n }\n }\n } else {\n operationsToReplay.push(...Object.values(operations).flat());\n }\n\n // builds a new document from the initial data\n const document = createDocument<T, A, L>(documentState);\n document.initialState = initialState;\n document.operations = initialOperations;\n\n let result = document;\n // if there are operations left without resulting state\n // then replays them\n if (operationsToReplay.length) {\n result = operationsToReplay.reduce((document, operation) => {\n const doc = reducer(document, operation, dispatch, {\n skip: operation.skip,\n ignoreSkipOperations: true,\n reuseHash: !checkHashes,\n });\n\n return doc;\n }, document);\n }\n // if not then updates the document header according\n // to the latest operation of each scope\n else {\n for (const scopeOperations of Object.values(initialOperations)) {\n const lastOperation = scopeOperations.at(-1);\n if (lastOperation) {\n result = updateHeader(result, lastOperation);\n }\n }\n }\n\n // if hash generation was skipped then checks if the hash\n // of each scope matches the hash of last operation\n if (!checkHashes) {\n for (const scope of Object.keys(result.state)) {\n for (let i = operationsToReplay.length - 1; i >= 0; i--) {\n const operation = operationsToReplay[i];\n\n if (operation.scope !== scope) {\n continue;\n }\n if (operation.hash !== hashDocument(result, scope)) {\n throw new Error(`Hash mismatch for scope ${scope}`);\n } else {\n break;\n }\n }\n }\n }\n\n // reuses operation timestamp if provided\n const resultOperations: DocumentOperations<A> = Object.keys(\n result.operations,\n ).reduce(\n (acc, key) => {\n const scope = key as keyof DocumentOperations<A>;\n return {\n ...acc,\n [scope]: [\n ...result.operations[scope].map((operation, index) => {\n return {\n ...operation,\n timestamp:\n operations[scope][index]?.timestamp ?? operation.timestamp,\n };\n }),\n ],\n };\n },\n { global: [], local: [] },\n );\n // gets the last modified timestamp from the latest operation\n const lastModified = Object.values(resultOperations).reduce((acc, curr) => {\n const operation = curr.at(-1);\n if (operation && operation.timestamp > acc) {\n acc = operation.timestamp;\n }\n return acc;\n }, initialState.lastModified);\n\n return { ...result, operations: resultOperations, lastModified };\n}\n\nexport function isSameDocument(documentA: Document, documentB: Document) {\n return stringifyJson(documentA) === stringifyJson(documentB);\n}\n\nexport function parseResultingState(state: unknown) {\n const stateType = typeof state;\n if (stateType === \"string\") {\n return JSON.parse(state as string) as object;\n } else if (stateType === \"object\") {\n return state as object;\n } else {\n throw new Error(`Providing resulting state is of type: ${stateType}`);\n }\n}\n","import { ExtendedState, OperationScope, z } from \"../types\";\nimport { createAction } from \"../utils/base\";\nimport {\n LoadStateAction,\n PruneAction,\n RedoAction,\n SetNameAction,\n UndoAction,\n NOOPAction,\n} from \"./types\";\n\n/**\n * Changes the name of the document.\n *\n * @param name - The name to be set in the document.\n * @category Actions\n */\nexport const setName = (name: string) =>\n createAction<SetNameAction>(\n \"SET_NAME\",\n name,\n undefined,\n z.SetNameActionInputSchema,\n undefined,\n );\n\n/**\n * Cancels the last `count` operations.\n *\n * @param count - Number of operations to cancel\n * @category Actions\n */\nexport const undo = (skip = 1, scope: OperationScope = \"global\") =>\n createAction<UndoAction>(\n \"UNDO\",\n skip,\n undefined,\n z.UndoActionInputSchema,\n scope,\n );\n\n/**\n * Cancels the last `count` {@link undo | UNDO} operations.\n *\n * @param count - Number of UNDO operations to cancel\n * @category Actions\n */\nexport const redo = (count = 1, scope: OperationScope = \"global\") =>\n createAction<RedoAction>(\n \"REDO\",\n count,\n undefined,\n z.RedoActionInputSchema,\n scope,\n );\n\n/**\n * Joins multiple operations into a single {@link loadState | LOAD_STATE} operation.\n *\n * @remarks\n * Useful to keep operations history smaller. Operations to prune are selected by index,\n * similar to the {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice | slice} method in Arrays.\n *\n * @param start - Index of the first operation to prune\n * @param end - Index of the last operation to prune\n * @category Actions\n */\nexport const prune = (\n start?: number | undefined,\n end?: number | undefined,\n scope: OperationScope = \"global\",\n) =>\n createAction<PruneAction>(\n \"PRUNE\",\n { start, end },\n undefined,\n z.PruneActionInputSchema,\n scope,\n );\n\n/**\n * Replaces the state of the document.\n *\n * @remarks\n * This action shouldn't be used directly. It is dispatched by the {@link prune} action.\n *\n * @param state - State to be set in the document.\n * @param operations - Number of operations that were removed from the previous state.\n * @category Actions\n */\nexport const loadState = <S, T>(\n state: Pick<ExtendedState<S, T>, \"state\" | \"name\">,\n operations: number,\n) =>\n createAction<LoadStateAction>(\n \"LOAD_STATE\",\n { state, operations },\n undefined,\n z.LoadStateActionInputSchema,\n );\n\nexport const noop = (scope: OperationScope = \"global\") =>\n createAction<NOOPAction>(\"NOOP\", {}, undefined, undefined, scope);\n","import { loadState, prune, redo, setName, undo } from \"./actions\";\nimport type { BaseAction } from \"./actions/types\";\nimport type { SignalDispatch } from \"./signal\";\nimport type {\n Action,\n AttachmentRef,\n Document,\n ExtendedState,\n OperationScope,\n Reducer,\n ReducerOptions,\n} from \"./types\";\nimport { loadFromFile, readOnly, saveToFile } from \"./utils\";\n\n/**\n * This is an abstract class representing a document and provides methods\n * for creating and manipulating documents.\n * @typeparam T - The type of data stored in the document.\n * @typeparam A - The type of action the document can take.\n */\nexport abstract class BaseDocument<T, A extends Action, L = unknown> {\n protected _document: Document<T, A, L>;\n private _reducer: Reducer<T, A, L>;\n private _signalDispatch?: SignalDispatch;\n\n /**\n * Constructs a BaseDocument instance with an initial state.\n * @param reducer - The reducer function that updates the state.\n * @param document - The initial state of the document.\n */\n constructor(\n reducer: Reducer<T, A, L>,\n document: Document<T, A, L>,\n signalDispatch?: SignalDispatch,\n ) {\n this._reducer = reducer;\n this._document = document;\n this._signalDispatch = signalDispatch;\n }\n\n /**\n * Dispatches an action to update the state of the document.\n * @param action - The action to dispatch.\n * @returns The Document instance.\n */\n protected dispatch(action: A | BaseAction, options?: ReducerOptions) {\n this._document = this._reducer(\n this._document,\n action,\n this._signalDispatch,\n options,\n );\n return this;\n }\n\n /**\n * Saves the state of the document to a file.\n * @param path - The file path where the state should be saved.\n * @param extension - The file extension to use when saving the state.\n * @returns The file path where the state was saved.\n */\n protected saveToFile(path: string, extension: string, name?: string) {\n return saveToFile(this._document, path, extension, name);\n }\n\n /**\n * Loads the state of the document from a file.\n * @param path - The file path where the state is stored.\n */\n async loadFromFile(path: string) {\n this._document = await loadFromFile<T, A, L>(path, this._reducer);\n }\n\n /**\n * Loads the state of the document from a file and returns it.\n * @param path - The file path where the state is stored.\n * @param reducer - The reducer function that updates the state.\n * @returns The state of the document.\n */\n protected static async stateFromFile<T, A extends Action, L>(\n path: string,\n reducer: Reducer<T, A, L>,\n ) {\n const state = await loadFromFile<T, A, L>(path, reducer);\n return state;\n }\n\n /**\n * Gets the current state of the document.\n */\n get state() {\n return readOnly(this._document.state);\n }\n\n /**\n * Gets the list of operations performed on the document.\n */\n get operations() {\n return readOnly(this._document.operations);\n }\n\n /**\n * Gets the name of the document.\n */\n get name() {\n return this._document.name;\n }\n\n /**\n * Gets the type of document.\n */\n get documentType() {\n return this._document.documentType;\n }\n\n /**\n * Gets the timestamp of the date the document was created.\n */\n get created() {\n return this._document.created;\n }\n\n /**\n * Gets the timestamp of the date the document was last modified.\n */\n get lastModified() {\n return this._document.lastModified;\n }\n\n /**\n * Gets the global revision number of the document.\n */\n get revision() {\n return this._document.revision.global;\n }\n\n getRevision(scope: OperationScope) {\n return this._document.revision[scope];\n }\n\n /**\n * Gets the initial state of the document.\n */\n get initialState() {\n return readOnly(this._document.initialState);\n }\n\n /**\n * Returns the current document as an object\n */\n public toDocument() {\n return readOnly(this._document);\n }\n\n /**\n * Gets the attachment associated with the given key.\n * @param attachment - The key of the attachment to retrieve.\n */\n public getAttachment(attachment: AttachmentRef) {\n return this._document.attachments[attachment];\n }\n\n /**\n * Sets the name of the document.\n * @param name - The new name of the document.\n */\n public setName(name: string) {\n this.dispatch(setName(name));\n return this;\n }\n\n /**\n * Reverts a number of actions from the document.\n * @param count - The number of actions to revert.\n */\n public undo(count: number) {\n this.dispatch(undo(count));\n return this;\n }\n\n /**\n * Reapplies a number of actions to the document.\n * @param count - The number of actions to reapply.\n */\n public redo(count: number) {\n this.dispatch(redo(count));\n return this;\n }\n /**\n * Removes a range of operations from the document.\n * @param start - The starting index of the range to remove.\n * @param end - The ending index of the range to remove.\n */\n public prune(start?: number | undefined, end?: number | undefined) {\n this.dispatch(prune(start, end));\n return this;\n }\n\n /**\n * Loads a document state and a set of operations.\n * @param state - The state to load.\n * @param operations - The operations to apply to the document.\n */\n public loadState(\n state: Pick<ExtendedState<T, L>, \"state\" | \"name\">,\n operations: number,\n ) {\n this.dispatch(loadState(state, operations));\n return this;\n }\n}\n/**\n * Applies multiple mixins to a base class.\n * Used to have separate mixins to group methods by actions.\n *\n * @remarks\n * {@link https://www.typescriptlang.org/docs/handbook/mixins.html#alternative-pattern}\n *\n * @param derivedCtor - The class to apply the mixins to.\n * @param constructors - The constructors of the mixins.\n */\n\nexport function applyMixins(derivedCtor: any, constructors: any[]) {\n constructors.forEach((baseCtor) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {\n Object.defineProperty(\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n derivedCtor.prototype,\n name,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access\n Object.getOwnPropertyDescriptor(baseCtor.prototype, name) ||\n Object.create(null),\n );\n });\n });\n}\n"],"names":["value","tmp","key","res","join","stringify","hash","createSha1Hash","stringifyJson","standardTypes","IntegrityIssueType","IntegrityIssueSubType","sortOperations","documentHelpers.sortOperations","documentHelpers.nextSkipNumber","action","uuid","z.BaseActionSchema","documentHelpers.garbageCollectDocumentOperations","documentHelpers.skipHeaderOperations","documentHelpers.diffOperations","documentHelpers.garbageCollect","skipHeaderOperations","document","z.SetNameActionInputSchema","z.UndoActionInputSchema","z.RedoActionInputSchema","z.PruneActionInputSchema","z.LoadStateActionInputSchema"],"mappings":";;;;;;AA4BO,MAAM,sBAAsB,CAAC,MAClC,MAAM,UAAa,MAAM;AAEd,MAAA,0BAA0B,EACpC,MACA,OAAO,CAAC,MAAM,oBAAoB,CAAC,CAAC;AAEhC,MAAM,m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