document-model 1.0.33 → 1.0.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/dist/browser/document-model.cjs +1 -1
  2. package/dist/browser/document-model.js +2 -2
  3. package/dist/browser/document.cjs +1 -1
  4. package/dist/browser/document.js +2 -2
  5. package/dist/browser/index.cjs +1 -1
  6. package/dist/browser/index.js +3 -3
  7. package/dist/browser/internal/{index-DTIvFQBH.js → index-368Qgjhp.js} +1 -1
  8. package/dist/{node/internal/index-C21AbOFE.js → browser/internal/index-A_QX9cy_.js} +1 -1
  9. package/dist/browser/internal/{index-i5s_5m9e.js → index-CDGYwLIP.js} +1 -1
  10. package/dist/{node/internal/index-CW5xQQ7a.js → browser/internal/index-CZWjb-hc.js} +1 -1
  11. package/dist/browser/internal/{object-CqQGngpx.js → object-B-Aw8ilC.js} +20 -20
  12. package/dist/browser/internal/{object-BOMJbn2Y.js → object-C8B-mq5Y.js} +1 -1
  13. package/dist/node/document-model.cjs +1 -1
  14. package/dist/node/document-model.js +2 -2
  15. package/dist/node/document.cjs +1 -1
  16. package/dist/node/document.js +2 -2
  17. package/dist/node/index.cjs +1 -1
  18. package/dist/node/index.js +3 -3
  19. package/dist/node/internal/{index-rIcx-JJZ.js → index-CEkeEja8.js} +1 -1
  20. package/dist/{browser/internal/index-CBO7uxzK.js → node/internal/index-D_eCXEyL.js} +1 -1
  21. package/dist/{browser/internal/index-CTCFa4de.js → node/internal/index-DjP2tO7C.js} +1 -1
  22. package/dist/node/internal/{index-CP5hMjbq.js → index-qa67kbhM.js} +1 -1
  23. package/dist/node/internal/object-B5Lf9AWl.js +2 -0
  24. package/dist/node/internal/{object-BIG1wTk-.js → object-CvntAblp.js} +48 -48
  25. package/package.json +1 -1
  26. package/dist/node/internal/object-C778ylvS.js +0 -2
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-BOMJbn2Y.js");require("immer");require("json-stringify-deterministic");require("jszip");const e=require("./internal/index-DTIvFQBH.js");require("zod");exports.Document=e.Document;exports.DocumentModel=e.DocumentModel$1;exports.actions=e.actions;exports.documentModel=e.documentModel;exports.module=e.module;exports.reducer=e.reducer;exports.utils=e.utils;exports.z=e.zod;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-C8B-mq5Y.js");require("immer");require("json-stringify-deterministic");require("jszip");const e=require("./internal/index-368Qgjhp.js");require("zod");exports.Document=e.Document;exports.DocumentModel=e.DocumentModel$1;exports.actions=e.actions;exports.documentModel=e.documentModel;exports.module=e.module;exports.reducer=e.reducer;exports.utils=e.utils;exports.z=e.zod;
@@ -1,8 +1,8 @@
1
- import "./internal/object-CqQGngpx.js";
1
+ import "./internal/object-B-Aw8ilC.js";
2
2
  import "immer";
3
3
  import "json-stringify-deterministic";
4
4
  import "jszip";
5
- import { b as i, a as u, c, d, m as p, r as l, u as n, z as D } from "./internal/index-i5s_5m9e.js";
5
+ import { b as i, a as u, c, d, m as p, r as l, u as n, z as D } from "./internal/index-CDGYwLIP.js";
6
6
  import "zod";
7
7
  export {
8
8
  i as Document,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal/object-BOMJbn2Y.js"),r=require("./internal/index-CTCFa4de.js");require("immer");require("json-stringify-deterministic");require("zod");require("jszip");exports.BaseDocument=e.BaseDocument;exports.actions=e.BaseActions;exports.applyMixins=e.applyMixins;exports.baseReducer=e.baseReducer;exports.processUndoRedo=e.processUndoRedo;exports.z=e.zod;exports.utils=r.index;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal/object-C8B-mq5Y.js"),r=require("./internal/index-CZWjb-hc.js");require("immer");require("json-stringify-deterministic");require("zod");require("jszip");exports.BaseDocument=e.BaseDocument;exports.actions=e.BaseActions;exports.applyMixins=e.applyMixins;exports.baseReducer=e.baseReducer;exports.processUndoRedo=e.processUndoRedo;exports.z=e.zod;exports.utils=r.index;
@@ -1,5 +1,5 @@
1
- import { B as p, h as t, g as m, A as c, C as n, D as d } from "./internal/object-CqQGngpx.js";
2
- import { i as x } from "./internal/index-CBO7uxzK.js";
1
+ import { B as p, h as t, g as m, A as c, C as n, D as d } from "./internal/object-B-Aw8ilC.js";
2
+ import { i as x } from "./internal/index-A_QX9cy_.js";
3
3
  import "immer";
4
4
  import "json-stringify-deterministic";
5
5
  import "zod";
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./internal/index-CTCFa4de.js"),o=require("./internal/index-DTIvFQBH.js");require("./internal/object-BOMJbn2Y.js");require("immer");require("json-stringify-deterministic");require("zod");require("jszip");const u={"powerhouse/document":e.Document,"powerhouse/document-model":o.DocumentModel},t={Document:e.Document,DocumentModel:o.DocumentModel};exports.Document=e.Document;exports.DocumentModel=o.DocumentModel;exports.DocumentModels=u;exports.default=t;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./internal/index-CZWjb-hc.js"),o=require("./internal/index-368Qgjhp.js");require("./internal/object-C8B-mq5Y.js");require("immer");require("json-stringify-deterministic");require("zod");require("jszip");const u={"powerhouse/document":e.Document,"powerhouse/document-model":o.DocumentModel},t={Document:e.Document,DocumentModel:o.DocumentModel};exports.Document=e.Document;exports.DocumentModel=o.DocumentModel;exports.DocumentModels=u;exports.default=t;
@@ -1,6 +1,6 @@
1
- import { D as o } from "./internal/index-CBO7uxzK.js";
2
- import { D as t } from "./internal/index-i5s_5m9e.js";
3
- import "./internal/object-CqQGngpx.js";
1
+ import { D as o } from "./internal/index-A_QX9cy_.js";
2
+ import { D as t } from "./internal/index-CDGYwLIP.js";
3
+ import "./internal/object-B-Aw8ilC.js";
4
4
  import "immer";
5
5
  import "json-stringify-deterministic";
6
6
  import "zod";
@@ -1,4 +1,4 @@
1
- "use strict";var mt=Object.defineProperty;var Et=(t,e,r)=>e in t?mt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var me=(t,e,r)=>(Et(t,typeof e!="symbol"?e+"":e,r),r);const s=require("./object-BOMJbn2Y.js");require("immer");require("json-stringify-deterministic");require("jszip");const o=require("zod"),ht=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),_={id:"powerhouse/document-model",name:"DocumentModel",extension:"phdm",description:"The Powerhouse Document Model describes the state and operations of a document type.",author:{name:"Powerhouse",website:"https://www.powerhouse.inc/"},specifications:[{version:1,changeLog:[],modules:[{name:"header",operations:[{name:"SetModelName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelId",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelExtension",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetAuthorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetAuthorWebsite",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"versioning",operations:[{name:"AddChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderChangeLogItems",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReleaseNewVersion",schema:null,id:"",description:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"module",operations:[{name:"AddModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModuleName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModuleDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderModules",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation-error",operations:[{name:"AddOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorCode",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderOperationErrors",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation-example",operations:[{name:"AddOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderOperationExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation",operations:[{name:"AddOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationReducer",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"MoveOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderModuleOperations",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"state",operations:[{name:"SetStateSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetInitialState",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"AddStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderStateExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""}],state:{global:{schema:"",initialValue:`{
1
+ "use strict";var mt=Object.defineProperty;var Et=(t,e,r)=>e in t?mt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var me=(t,e,r)=>(Et(t,typeof e!="symbol"?e+"":e,r),r);const s=require("./object-C8B-mq5Y.js");require("immer");require("json-stringify-deterministic");require("jszip");const o=require("zod"),ht=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),_={id:"powerhouse/document-model",name:"DocumentModel",extension:"phdm",description:"The Powerhouse Document Model describes the state and operations of a document type.",author:{name:"Powerhouse",website:"https://www.powerhouse.inc/"},specifications:[{version:1,changeLog:[],modules:[{name:"header",operations:[{name:"SetModelName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelId",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelExtension",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetAuthorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetAuthorWebsite",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"versioning",operations:[{name:"AddChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderChangeLogItems",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReleaseNewVersion",schema:null,id:"",description:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"module",operations:[{name:"AddModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModuleName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModuleDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderModules",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation-error",operations:[{name:"AddOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorCode",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderOperationErrors",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation-example",operations:[{name:"AddOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderOperationExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation",operations:[{name:"AddOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationReducer",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"MoveOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderModuleOperations",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"state",operations:[{name:"SetStateSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetInitialState",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"AddStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderStateExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""}],state:{global:{schema:"",initialValue:`{
2
2
  "id": "",
3
3
  "name": "",
4
4
  "extension": "",
@@ -1,4 +1,4 @@
1
- import { f as e, b as a, a as s, c as o, j as t, k as r, m as i, n, o as c, i as l, p, q as d, r as u, l as m, e as O, t as y, u as b, v as D, w as _, s as g, d as F, x as S, y as f, z as v, B as h, h as j, g as x, A as z, C as R, D as A } from "./object-BIG1wTk-.js";
1
+ import { f as e, b as a, a as s, c as o, j as t, k as r, m as i, n, o as c, i as l, p, q as d, r as u, l as m, e as O, t as y, u as b, v as D, w as _, s as g, d as F, x as S, y as f, z as v, B as h, h as j, g as x, A as z, C as R, D as A } from "./object-B-Aw8ilC.js";
2
2
  const B = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3
3
  __proto__: null,
4
4
  createAction: e,
@@ -1,7 +1,7 @@
1
1
  var ut = Object.defineProperty;
2
2
  var mt = (t, e, r) => e in t ? ut(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
3
  var ce = (t, e, r) => (mt(t, typeof e != "symbol" ? e + "" : e, r), r);
4
- import { c as Et, i as ht, a as Ot, b as gt, s as St, d as bt, l as ft, e as _t, f as s, B as l, g as It, h as Tt } from "./object-CqQGngpx.js";
4
+ import { c as Et, i as ht, a as Ot, b as gt, s as St, d as bt, l as ft, e as _t, f as s, B as l, g as It, h as Tt } from "./object-B-Aw8ilC.js";
5
5
  import "immer";
6
6
  import "json-stringify-deterministic";
7
7
  import "jszip";
@@ -1 +1 @@
1
- "use strict";const e=require("./object-C778ylvS.js"),o=Object.freeze(Object.defineProperty({__proto__:null,createAction:e.createAction,createDocument:e.createDocument,createExtendedState:e.createExtendedState,createReducer:e.createReducer,createZip:e.createZip,getLocalFile:e.getLocalFile,getRemoteFile:e.getRemoteFile,hashDocument:e.hashDocument,hashKey:e.hashKey,isBaseAction:e.isBaseAction,isNoopOperation:e.isNoopOperation,isSameDocument:e.isSameDocument,isUndoRedo:e.isUndoRedo,loadFromFile:e.loadFromFile,loadFromInput:e.loadFromInput,mapSkippedOperations:e.mapSkippedOperations,readOnly:e.readOnly,replayDocument:e.replayDocument,replayOperations:e.replayOperations,saveToFile:e.saveToFile,saveToFileHandle:e.saveToFileHandle,sortMappedOperations:e.sortMappedOperations,sortOperations:e.sortOperations,validateOperations:e.validateOperations},Symbol.toStringTag,{value:"Module"})),t=Object.freeze(Object.defineProperty({__proto__:null,BaseDocument:e.BaseDocument,actions:e.BaseActions,applyMixins:e.applyMixins,baseReducer:e.baseReducer,processUndoRedo:e.processUndoRedo,utils:o,z:e.zod},Symbol.toStringTag,{value:"Module"}));exports.Document=t;exports.index=o;
1
+ "use strict";const e=require("./object-C8B-mq5Y.js"),o=Object.freeze(Object.defineProperty({__proto__:null,createAction:e.createAction,createDocument:e.createDocument,createExtendedState:e.createExtendedState,createReducer:e.createReducer,createZip:e.createZip,getLocalFile:e.getLocalFile,getRemoteFile:e.getRemoteFile,hashDocument:e.hashDocument,hashKey:e.hashKey,isBaseAction:e.isBaseAction,isNoopOperation:e.isNoopOperation,isSameDocument:e.isSameDocument,isUndoRedo:e.isUndoRedo,loadFromFile:e.loadFromFile,loadFromInput:e.loadFromInput,mapSkippedOperations:e.mapSkippedOperations,readOnly:e.readOnly,replayDocument:e.replayDocument,replayOperations:e.replayOperations,saveToFile:e.saveToFile,saveToFileHandle:e.saveToFileHandle,sortMappedOperations:e.sortMappedOperations,sortOperations:e.sortOperations,validateOperations:e.validateOperations},Symbol.toStringTag,{value:"Module"})),t=Object.freeze(Object.defineProperty({__proto__:null,BaseDocument:e.BaseDocument,actions:e.BaseActions,applyMixins:e.applyMixins,baseReducer:e.baseReducer,processUndoRedo:e.processUndoRedo,utils:o,z:e.zod},Symbol.toStringTag,{value:"Module"}));exports.Document=t;exports.index=o;
@@ -5,7 +5,7 @@ import { produce as J, castDraft as at, castImmutable as Oe, freeze as Ue } from
5
5
  import pt from "json-stringify-deterministic";
6
6
  import { z as w } from "zod";
7
7
  import Dt from "jszip";
8
- const Nt = (n) => n != null, Te = w.any().refine((n) => Nt(n)), Mt = w.enum(["LOAD_STATE"]), Rt = w.enum(["PRUNE"]), Ct = w.enum(["REDO"]), Lt = w.enum(["SET_NAME"]), zt = w.enum(["UNDO"]);
8
+ const Mt = (n) => n != null, Te = w.any().refine((n) => Mt(n)), Nt = w.enum(["LOAD_STATE"]), Rt = w.enum(["PRUNE"]), Ct = w.enum(["REDO"]), Lt = w.enum(["SET_NAME"]), zt = w.enum(["UNDO"]);
9
9
  function De() {
10
10
  return w.object({
11
11
  __typename: w.literal("Action").optional(),
@@ -24,7 +24,7 @@ function Pt() {
24
24
  Zt()
25
25
  ]);
26
26
  }
27
- function Ne() {
27
+ function Me() {
28
28
  return w.object({
29
29
  __typename: w.literal("DocumentFile").optional(),
30
30
  data: w.string(),
@@ -36,7 +36,7 @@ function Ne() {
36
36
  function qt() {
37
37
  return w.object({
38
38
  input: w.lazy(() => ut()),
39
- type: Mt,
39
+ type: Nt,
40
40
  scope: H()
41
41
  });
42
42
  }
@@ -52,7 +52,7 @@ function $t() {
52
52
  name: w.string()
53
53
  });
54
54
  }
55
- function Me() {
55
+ function Ne() {
56
56
  return w.object({
57
57
  __typename: w.literal("Operation").optional(),
58
58
  hash: w.string(),
@@ -112,12 +112,12 @@ const Li = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
112
112
  __proto__: null,
113
113
  ActionSchema: De,
114
114
  BaseActionSchema: Pt,
115
- DocumentFileSchema: Ne,
115
+ DocumentFileSchema: Me,
116
116
  LoadStateActionInputSchema: ut,
117
117
  LoadStateActionSchema: qt,
118
118
  LoadStateActionStateInputSchema: $t,
119
- Load_StateSchema: Mt,
120
- OperationSchema: Me,
119
+ Load_StateSchema: Nt,
120
+ OperationSchema: Ne,
121
121
  OperationScopeSchema: H,
122
122
  PruneActionInputSchema: ft,
123
123
  PruneActionSchema: Wt,
@@ -133,7 +133,7 @@ const Li = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
133
133
  UndoActionSchema: Zt,
134
134
  UndoSchema: zt,
135
135
  definedNonNullAnySchema: Te,
136
- isDefinedNonNullAny: Nt
136
+ isDefinedNonNullAny: Mt
137
137
  }, Symbol.toStringTag, { value: "Module" }));
138
138
  function Ce(n, r) {
139
139
  return { ...n, name: r };
@@ -738,7 +738,7 @@ dt.write = function(n, r, p, c, u, f) {
738
738
  }
739
739
  }
740
740
  a.prototype._isBuffer = !0;
741
- function N(i, t, e) {
741
+ function M(i, t, e) {
742
742
  var o = i[t];
743
743
  i[t] = i[e], i[e] = o;
744
744
  }
@@ -747,21 +747,21 @@ dt.write = function(n, r, p, c, u, f) {
747
747
  if (t % 2 !== 0)
748
748
  throw new RangeError("Buffer size must be a multiple of 16-bits");
749
749
  for (var e = 0; e < t; e += 2)
750
- N(this, e, e + 1);
750
+ M(this, e, e + 1);
751
751
  return this;
752
752
  }, a.prototype.swap32 = function() {
753
753
  var t = this.length;
754
754
  if (t % 4 !== 0)
755
755
  throw new RangeError("Buffer size must be a multiple of 32-bits");
756
756
  for (var e = 0; e < t; e += 4)
757
- N(this, e, e + 3), N(this, e + 1, e + 2);
757
+ M(this, e, e + 3), M(this, e + 1, e + 2);
758
758
  return this;
759
759
  }, a.prototype.swap64 = function() {
760
760
  var t = this.length;
761
761
  if (t % 8 !== 0)
762
762
  throw new RangeError("Buffer size must be a multiple of 64-bits");
763
763
  for (var e = 0; e < t; e += 8)
764
- N(this, e, e + 7), N(this, e + 1, e + 6), N(this, e + 2, e + 5), N(this, e + 3, e + 4);
764
+ M(this, e, e + 7), M(this, e + 1, e + 6), M(this, e + 2, e + 5), M(this, e + 3, e + 4);
765
765
  return this;
766
766
  }, a.prototype.toString = function() {
767
767
  var t = this.length;
@@ -1555,7 +1555,7 @@ function ne(n, r, p, c, u, f = {}) {
1555
1555
  for (const E of b)
1556
1556
  E.timestamp > y && (y = E.timestamp);
1557
1557
  return y;
1558
- }, "0");
1558
+ }, n.lastModified);
1559
1559
  return { ...d, operations: v, lastModified: g };
1560
1560
  }
1561
1561
  function qi(n, r) {
@@ -1606,17 +1606,17 @@ var I = function(n, r, p, c) {
1606
1606
  if (typeof r == "function" ? n !== r || !c : !r.has(n))
1607
1607
  throw new TypeError("Cannot read private member from an object whose class did not declare it");
1608
1608
  return p === "m" ? c : p === "a" ? c.call(n) : c ? c.value : r.get(n);
1609
- }, L, W, M;
1609
+ }, L, W, N;
1610
1610
  class Bi {
1611
1611
  constructor(...r) {
1612
- L.set(this, /* @__PURE__ */ new Map()), W.set(this, /* @__PURE__ */ new Map()), M.set(this, /* @__PURE__ */ new Map());
1612
+ L.set(this, /* @__PURE__ */ new Map()), W.set(this, /* @__PURE__ */ new Map()), N.set(this, /* @__PURE__ */ new Map());
1613
1613
  for (const p of r)
1614
1614
  this.define(p);
1615
1615
  }
1616
1616
  define(r, p = !1) {
1617
1617
  for (let [c, u] of Object.entries(r)) {
1618
- c = c.toLowerCase(), u = u.map((a) => a.toLowerCase()), I(this, M, "f").has(c) || I(this, M, "f").set(c, /* @__PURE__ */ new Set());
1619
- const f = I(this, M, "f").get(c);
1618
+ c = c.toLowerCase(), u = u.map((a) => a.toLowerCase()), I(this, N, "f").has(c) || I(this, N, "f").set(c, /* @__PURE__ */ new Set());
1619
+ const f = I(this, N, "f").get(c);
1620
1620
  let l = !0;
1621
1621
  for (let a of u) {
1622
1622
  const x = a.startsWith("*");
@@ -1641,13 +1641,13 @@ class Bi {
1641
1641
  return typeof r != "string" ? null : (r = (p = r == null ? void 0 : r.split) == null ? void 0 : p.call(r, ";")[0], (r && I(this, W, "f").get(r.trim().toLowerCase())) ?? null);
1642
1642
  }
1643
1643
  getAllExtensions(r) {
1644
- return typeof r != "string" ? null : I(this, M, "f").get(r.toLowerCase()) ?? null;
1644
+ return typeof r != "string" ? null : I(this, N, "f").get(r.toLowerCase()) ?? null;
1645
1645
  }
1646
1646
  _freeze() {
1647
1647
  this.define = () => {
1648
1648
  throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances");
1649
1649
  }, Object.freeze(this);
1650
- for (const r of I(this, M, "f").values())
1650
+ for (const r of I(this, N, "f").values())
1651
1651
  Object.freeze(r);
1652
1652
  return this;
1653
1653
  }
@@ -1658,7 +1658,7 @@ class Bi {
1658
1658
  };
1659
1659
  }
1660
1660
  }
1661
- L = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new WeakMap(), M = /* @__PURE__ */ new WeakMap();
1661
+ L = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new WeakMap(), N = /* @__PURE__ */ new WeakMap();
1662
1662
  const ji = new Bi(ce)._freeze();
1663
1663
  function Ii(n) {
1664
1664
  const r = [], p = Object.keys(n);
@@ -3,5 +3,5 @@
3
3
  *
4
4
  * @author Feross Aboukhadijeh <https://feross.org>
5
5
  * @license MIT
6
- */(function(n){var r=et,p=yt,c=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=a,n.SlowBuffer=G,n.INSPECT_MAX_BYTES=50;var f=2147483647;n.kMaxLength=f,a.TYPED_ARRAY_SUPPORT=u(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function u(){try{var i=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(i,t),i.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function l(i){if(i>f)throw new RangeError('The value "'+i+'" is invalid for option "size"');var t=new Uint8Array(i);return Object.setPrototypeOf(t,a.prototype),t}function a(i,t,e){if(typeof i=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return g(i)}return x(i,t,e)}a.poolSize=8192;function x(i,t,e){if(typeof i=="string")return y(i,t);if(ArrayBuffer.isView(i))return E(i);if(i==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i);if(T(i,ArrayBuffer)||i&&T(i.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(T(i,SharedArrayBuffer)||i&&T(i.buffer,SharedArrayBuffer)))return U(i,t,e);if(typeof i=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var o=i.valueOf&&i.valueOf();if(o!=null&&o!==i)return a.from(o,t,e);var s=C(i);if(s)return s;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof i[Symbol.toPrimitive]=="function")return a.from(i[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i)}a.from=function(i,t,e){return x(i,t,e)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function d(i){if(typeof i!="number")throw new TypeError('"size" argument must be of type number');if(i<0)throw new RangeError('The value "'+i+'" is invalid for option "size"')}function v(i,t,e){return d(i),i<=0?l(i):t!==void 0?typeof e=="string"?l(i).fill(t,e):l(i).fill(t):l(i)}a.alloc=function(i,t,e){return v(i,t,e)};function g(i){return d(i),l(i<0?0:W(i)|0)}a.allocUnsafe=function(i){return g(i)},a.allocUnsafeSlow=function(i){return g(i)};function y(i,t){if((typeof t!="string"||t==="")&&(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var e=St(i,t)|0,o=l(e),s=o.write(i,t);return s!==e&&(o=o.slice(0,s)),o}function b(i){for(var t=i.length<0?0:W(i.length)|0,e=l(t),o=0;o<t;o+=1)e[o]=i[o]&255;return e}function E(i){if(T(i,Uint8Array)){var t=new Uint8Array(i);return U(t.buffer,t.byteOffset,t.byteLength)}return b(i)}function U(i,t,e){if(t<0||i.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(i.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');var o;return t===void 0&&e===void 0?o=new Uint8Array(i):e===void 0?o=new Uint8Array(i,t):o=new Uint8Array(i,t,e),Object.setPrototypeOf(o,a.prototype),o}function C(i){if(a.isBuffer(i)){var t=W(i.length)|0,e=l(t);return e.length===0||i.copy(e,0,0,t),e}if(i.length!==void 0)return typeof i.length!="number"||ot(i.length)?l(0):b(i);if(i.type==="Buffer"&&Array.isArray(i.data))return b(i.data)}function W(i){if(i>=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+" bytes");return i|0}function G(i){return+i!=i&&(i=0),a.alloc(+i)}a.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==a.prototype},a.compare=function(t,e){if(T(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),T(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var o=t.length,s=e.length,m=0,h=Math.min(o,s);m<h;++m)if(t[m]!==e[m]){o=t[m],s=e[m];break}return o<s?-1:s<o?1:0},a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return a.alloc(0);var o;if(e===void 0)for(e=0,o=0;o<t.length;++o)e+=t[o].length;var s=a.allocUnsafe(e),m=0;for(o=0;o<t.length;++o){var h=t[o];if(T(h,Uint8Array))m+h.length>s.length?a.from(h).copy(s,m):Uint8Array.prototype.set.call(s,h,m);else if(a.isBuffer(h))h.copy(s,m);else throw new TypeError('"list" argument must be an Array of Buffers');m+=h.length}return s};function St(i,t){if(a.isBuffer(i))return i.length;if(ArrayBuffer.isView(i)||T(i,ArrayBuffer))return i.byteLength;if(typeof i!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof i);var e=i.length,o=arguments.length>2&&arguments[2]===!0;if(!o&&e===0)return 0;for(var s=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return nt(i).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return zt(i).length;default:if(s)return o?-1:nt(i).length;t=(""+t).toLowerCase(),s=!0}}a.byteLength=St;function be(i,t,e){var o=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(i||(i="utf8");;)switch(i){case"hex":return Ie(this,t,e);case"utf8":case"utf-8":return jt(this,t,e);case"ascii":return je(this,t,e);case"latin1":case"binary":return Oe(this,t,e);case"base64":return ke(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ue(this,t,e);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(i+"").toLowerCase(),o=!0}}a.prototype._isBuffer=!0;function M(i,t,e){var o=i[t];i[t]=i[e],i[e]=o}a.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)M(this,e,e+1);return this},a.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)M(this,e,e+3),M(this,e+1,e+2);return this},a.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)M(this,e,e+7),M(this,e+1,e+6),M(this,e+2,e+5),M(this,e+3,e+4);return this},a.prototype.toString=function(){var t=this.length;return t===0?"":arguments.length===0?jt(this,0,t):be.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:a.compare(this,t)===0},a.prototype.inspect=function(){var t="",e=n.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"},c&&(a.prototype[c]=a.prototype.inspect),a.prototype.compare=function(t,e,o,s,m){if(T(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),o===void 0&&(o=t?t.length:0),s===void 0&&(s=0),m===void 0&&(m=this.length),e<0||o>t.length||s<0||m>this.length)throw new RangeError("out of range index");if(s>=m&&e>=o)return 0;if(s>=m)return-1;if(e>=o)return 1;if(e>>>=0,o>>>=0,s>>>=0,m>>>=0,this===t)return 0;for(var h=m-s,F=o-e,_=Math.min(h,F),A=this.slice(s,m),B=t.slice(e,o),S=0;S<_;++S)if(A[S]!==B[S]){h=A[S],F=B[S];break}return h<F?-1:F<h?1:0};function kt(i,t,e,o,s){if(i.length===0)return-1;if(typeof e=="string"?(o=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,ot(e)&&(e=s?0:i.length-1),e<0&&(e=i.length+e),e>=i.length){if(s)return-1;e=i.length-1}else if(e<0)if(s)e=0;else return-1;if(typeof t=="string"&&(t=a.from(t,o)),a.isBuffer(t))return t.length===0?-1:Bt(i,t,e,o,s);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?s?Uint8Array.prototype.indexOf.call(i,t,e):Uint8Array.prototype.lastIndexOf.call(i,t,e):Bt(i,[t],e,o,s);throw new TypeError("val must be string, number or Buffer")}function Bt(i,t,e,o,s){var m=1,h=i.length,F=t.length;if(o!==void 0&&(o=String(o).toLowerCase(),o==="ucs2"||o==="ucs-2"||o==="utf16le"||o==="utf-16le")){if(i.length<2||t.length<2)return-1;m=2,h/=2,F/=2,e/=2}function _(Dt,Mt){return m===1?Dt[Mt]:Dt.readUInt16BE(Mt*m)}var A;if(s){var B=-1;for(A=e;A<h;A++)if(_(i,A)===_(t,B===-1?0:A-B)){if(B===-1&&(B=A),A-B+1===F)return B*m}else B!==-1&&(A-=A-B),B=-1}else for(e+F>h&&(e=h-F),A=e;A>=0;A--){for(var S=!0,X=0;X<F;X++)if(_(i,A+X)!==_(t,X)){S=!1;break}if(S)return A}return-1}a.prototype.includes=function(t,e,o){return this.indexOf(t,e,o)!==-1},a.prototype.indexOf=function(t,e,o){return kt(this,t,e,o,!0)},a.prototype.lastIndexOf=function(t,e,o){return kt(this,t,e,o,!1)};function Ee(i,t,e,o){e=Number(e)||0;var s=i.length-e;o?(o=Number(o),o>s&&(o=s)):o=s;var m=t.length;o>m/2&&(o=m/2);for(var h=0;h<o;++h){var F=parseInt(t.substr(h*2,2),16);if(ot(F))return h;i[e+h]=F}return h}function Fe(i,t,e,o){return V(nt(t,i.length-e),i,e,o)}function _e(i,t,e,o){return V(De(t),i,e,o)}function Ae(i,t,e,o){return V(zt(t),i,e,o)}function Se(i,t,e,o){return V(Me(t,i.length-e),i,e,o)}a.prototype.write=function(t,e,o,s){if(e===void 0)s="utf8",o=this.length,e=0;else if(o===void 0&&typeof e=="string")s=e,o=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(o)?(o=o>>>0,s===void 0&&(s="utf8")):(s=o,o=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var m=this.length-e;if((o===void 0||o>m)&&(o=m),t.length>0&&(o<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");s||(s="utf8");for(var h=!1;;)switch(s){case"hex":return Ee(this,t,e,o);case"utf8":case"utf-8":return Fe(this,t,e,o);case"ascii":case"latin1":case"binary":return _e(this,t,e,o);case"base64":return Ae(this,t,e,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Se(this,t,e,o);default:if(h)throw new TypeError("Unknown encoding: "+s);s=(""+s).toLowerCase(),h=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ke(i,t,e){return t===0&&e===i.length?r.fromByteArray(i):r.fromByteArray(i.slice(t,e))}function jt(i,t,e){e=Math.min(i.length,e);for(var o=[],s=t;s<e;){var m=i[s],h=null,F=m>239?4:m>223?3:m>191?2:1;if(s+F<=e){var _,A,B,S;switch(F){case 1:m<128&&(h=m);break;case 2:_=i[s+1],(_&192)===128&&(S=(m&31)<<6|_&63,S>127&&(h=S));break;case 3:_=i[s+1],A=i[s+2],(_&192)===128&&(A&192)===128&&(S=(m&15)<<12|(_&63)<<6|A&63,S>2047&&(S<55296||S>57343)&&(h=S));break;case 4:_=i[s+1],A=i[s+2],B=i[s+3],(_&192)===128&&(A&192)===128&&(B&192)===128&&(S=(m&15)<<18|(_&63)<<12|(A&63)<<6|B&63,S>65535&&S<1114112&&(h=S))}}h===null?(h=65533,F=1):h>65535&&(h-=65536,o.push(h>>>10&1023|55296),h=56320|h&1023),o.push(h),s+=F}return Be(o)}var Ot=4096;function Be(i){var t=i.length;if(t<=Ot)return String.fromCharCode.apply(String,i);for(var e="",o=0;o<t;)e+=String.fromCharCode.apply(String,i.slice(o,o+=Ot));return e}function je(i,t,e){var o="";e=Math.min(i.length,e);for(var s=t;s<e;++s)o+=String.fromCharCode(i[s]&127);return o}function Oe(i,t,e){var o="";e=Math.min(i.length,e);for(var s=t;s<e;++s)o+=String.fromCharCode(i[s]);return o}function Ie(i,t,e){var o=i.length;(!t||t<0)&&(t=0),(!e||e<0||e>o)&&(e=o);for(var s="",m=t;m<e;++m)s+=Ne[i[m]];return s}function Ue(i,t,e){for(var o=i.slice(t,e),s="",m=0;m<o.length-1;m+=2)s+=String.fromCharCode(o[m]+o[m+1]*256);return s}a.prototype.slice=function(t,e){var o=this.length;t=~~t,e=e===void 0?o:~~e,t<0?(t+=o,t<0&&(t=0)):t>o&&(t=o),e<0?(e+=o,e<0&&(e=0)):e>o&&(e=o),e<t&&(e=t);var s=this.subarray(t,e);return Object.setPrototypeOf(s,a.prototype),s};function k(i,t,e){if(i%1!==0||i<0)throw new RangeError("offset is not uint");if(i+t>e)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(t,e,o){t=t>>>0,e=e>>>0,o||k(t,e,this.length);for(var s=this[t],m=1,h=0;++h<e&&(m*=256);)s+=this[t+h]*m;return s},a.prototype.readUintBE=a.prototype.readUIntBE=function(t,e,o){t=t>>>0,e=e>>>0,o||k(t,e,this.length);for(var s=this[t+--e],m=1;e>0&&(m*=256);)s+=this[t+--e]*m;return s},a.prototype.readUint8=a.prototype.readUInt8=function(t,e){return t=t>>>0,e||k(t,1,this.length),this[t]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||k(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||k(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||k(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||k(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,e,o){t=t>>>0,e=e>>>0,o||k(t,e,this.length);for(var s=this[t],m=1,h=0;++h<e&&(m*=256);)s+=this[t+h]*m;return m*=128,s>=m&&(s-=Math.pow(2,8*e)),s},a.prototype.readIntBE=function(t,e,o){t=t>>>0,e=e>>>0,o||k(t,e,this.length);for(var s=e,m=1,h=this[t+--s];s>0&&(m*=256);)h+=this[t+--s]*m;return m*=128,h>=m&&(h-=Math.pow(2,8*e)),h},a.prototype.readInt8=function(t,e){return t=t>>>0,e||k(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},a.prototype.readInt16LE=function(t,e){t=t>>>0,e||k(t,2,this.length);var o=this[t]|this[t+1]<<8;return o&32768?o|4294901760:o},a.prototype.readInt16BE=function(t,e){t=t>>>0,e||k(t,2,this.length);var o=this[t+1]|this[t]<<8;return o&32768?o|4294901760:o},a.prototype.readInt32LE=function(t,e){return t=t>>>0,e||k(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return t=t>>>0,e||k(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,e){return t=t>>>0,e||k(t,4,this.length),p.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return t=t>>>0,e||k(t,4,this.length),p.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||k(t,8,this.length),p.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||k(t,8,this.length),p.read(this,t,!1,52,8)};function j(i,t,e,o,s,m){if(!a.isBuffer(i))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>s||t<m)throw new RangeError('"value" argument is out of bounds');if(e+o>i.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(t,e,o,s){if(t=+t,e=e>>>0,o=o>>>0,!s){var m=Math.pow(2,8*o)-1;j(this,t,e,o,m,0)}var h=1,F=0;for(this[e]=t&255;++F<o&&(h*=256);)this[e+F]=t/h&255;return e+o},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(t,e,o,s){if(t=+t,e=e>>>0,o=o>>>0,!s){var m=Math.pow(2,8*o)-1;j(this,t,e,o,m,0)}var h=o-1,F=1;for(this[e+h]=t&255;--h>=0&&(F*=256);)this[e+h]=t/F&255;return e+o},a.prototype.writeUint8=a.prototype.writeUInt8=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,1,255,0),this[e]=t&255,e+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4},a.prototype.writeIntLE=function(t,e,o,s){if(t=+t,e=e>>>0,!s){var m=Math.pow(2,8*o-1);j(this,t,e,o,m-1,-m)}var h=0,F=1,_=0;for(this[e]=t&255;++h<o&&(F*=256);)t<0&&_===0&&this[e+h-1]!==0&&(_=1),this[e+h]=(t/F>>0)-_&255;return e+o},a.prototype.writeIntBE=function(t,e,o,s){if(t=+t,e=e>>>0,!s){var m=Math.pow(2,8*o-1);j(this,t,e,o,m-1,-m)}var h=o-1,F=1,_=0;for(this[e+h]=t&255;--h>=0&&(F*=256);)t<0&&_===0&&this[e+h+1]!==0&&(_=1),this[e+h]=(t/F>>0)-_&255;return e+o},a.prototype.writeInt8=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1},a.prototype.writeInt16LE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2},a.prototype.writeInt16BE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2},a.prototype.writeInt32LE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},a.prototype.writeInt32BE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function It(i,t,e,o,s,m){if(e+o>i.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function Ut(i,t,e,o,s){return t=+t,e=e>>>0,s||It(i,t,e,4),p.write(i,t,e,o,23,4),e+4}a.prototype.writeFloatLE=function(t,e,o){return Ut(this,t,e,!0,o)},a.prototype.writeFloatBE=function(t,e,o){return Ut(this,t,e,!1,o)};function Tt(i,t,e,o,s){return t=+t,e=e>>>0,s||It(i,t,e,8),p.write(i,t,e,o,52,8),e+8}a.prototype.writeDoubleLE=function(t,e,o){return Tt(this,t,e,!0,o)},a.prototype.writeDoubleBE=function(t,e,o){return Tt(this,t,e,!1,o)},a.prototype.copy=function(t,e,o,s){if(!a.isBuffer(t))throw new TypeError("argument should be a Buffer");if(o||(o=0),!s&&s!==0&&(s=this.length),e>=t.length&&(e=t.length),e||(e=0),s>0&&s<o&&(s=o),s===o||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(o<0||o>=this.length)throw new RangeError("Index out of range");if(s<0)throw new RangeError("sourceEnd out of bounds");s>this.length&&(s=this.length),t.length-e<s-o&&(s=t.length-e+o);var m=s-o;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,o,s):Uint8Array.prototype.set.call(t,this.subarray(o,s),e),m},a.prototype.fill=function(t,e,o,s){if(typeof t=="string"){if(typeof e=="string"?(s=e,e=0,o=this.length):typeof o=="string"&&(s=o,o=this.length),s!==void 0&&typeof s!="string")throw new TypeError("encoding must be a string");if(typeof s=="string"&&!a.isEncoding(s))throw new TypeError("Unknown encoding: "+s);if(t.length===1){var m=t.charCodeAt(0);(s==="utf8"&&m<128||s==="latin1")&&(t=m)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<o)throw new RangeError("Out of range index");if(o<=e)return this;e=e>>>0,o=o===void 0?this.length:o>>>0,t||(t=0);var h;if(typeof t=="number")for(h=e;h<o;++h)this[h]=t;else{var F=a.isBuffer(t)?t:a.from(t,s),_=F.length;if(_===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(h=0;h<o-e;++h)this[h+e]=F[h%_]}return this};var Te=/[^+/0-9A-Za-z-_]/g;function ze(i){if(i=i.split("=")[0],i=i.trim().replace(Te,""),i.length<2)return"";for(;i.length%4!==0;)i=i+"=";return i}function nt(i,t){t=t||1/0;for(var e,o=i.length,s=null,m=[],h=0;h<o;++h){if(e=i.charCodeAt(h),e>55295&&e<57344){if(!s){if(e>56319){(t-=3)>-1&&m.push(239,191,189);continue}else if(h+1===o){(t-=3)>-1&&m.push(239,191,189);continue}s=e;continue}if(e<56320){(t-=3)>-1&&m.push(239,191,189),s=e;continue}e=(s-55296<<10|e-56320)+65536}else s&&(t-=3)>-1&&m.push(239,191,189);if(s=null,e<128){if((t-=1)<0)break;m.push(e)}else if(e<2048){if((t-=2)<0)break;m.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;m.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;m.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return m}function De(i){for(var t=[],e=0;e<i.length;++e)t.push(i.charCodeAt(e)&255);return t}function Me(i,t){for(var e,o,s,m=[],h=0;h<i.length&&!((t-=2)<0);++h)e=i.charCodeAt(h),o=e>>8,s=e%256,m.push(s),m.push(o);return m}function zt(i){return r.toByteArray(ze(i))}function V(i,t,e,o){for(var s=0;s<o&&!(s+e>=t.length||s>=i.length);++s)t[s+e]=i[s];return s}function T(i,t){return i instanceof t||i!=null&&i.constructor!=null&&i.constructor.name!=null&&i.constructor.name===t.name}function ot(i){return i!==i}var Ne=function(){for(var i="0123456789abcdef",t=new Array(256),e=0;e<16;++e)for(var o=e*16,s=0;s<16;++s)t[o+s]=i[e]+i[s];return t}()})(te);/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(n,r){var p=te,c=p.Buffer;function f(l,a){for(var x in l)a[x]=l[x]}c.from&&c.alloc&&c.allocUnsafe&&c.allocUnsafeSlow?n.exports=p:(f(p,r),r.Buffer=u);function u(l,a,x){return c(l,a,x)}u.prototype=Object.create(c.prototype),f(c,u),u.from=function(l,a,x){if(typeof l=="number")throw new TypeError("Argument must not be a number");return c(l,a,x)},u.alloc=function(l,a,x){if(typeof l!="number")throw new TypeError("Argument must be a number");var d=c(l);return a!==void 0?typeof x=="string"?d.fill(a,x):d.fill(a):d.fill(0),d},u.allocUnsafe=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return c(l)},u.allocUnsafeSlow=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return p.SlowBuffer(l)}})(ct,ct.exports);var ie=ct.exports,re=ie.Buffer;function it(n,r){this._block=re.alloc(n),this._finalSize=r,this._blockSize=n,this._len=0}it.prototype.update=function(n,r){typeof n=="string"&&(r=r||"utf8",n=re.from(n,r));for(var p=this._block,c=this._blockSize,f=n.length,u=this._len,l=0;l<f;){for(var a=u%c,x=Math.min(f-l,c-a),d=0;d<x;d++)p[a+d]=n[l+d];u+=x,l+=x,u%c===0&&this._update(p)}return this._len+=f,this};it.prototype.digest=function(n){var r=this._len%this._blockSize;this._block[r]=128,this._block.fill(0,r+1),r>=this._finalSize&&(this._update(this._block),this._block.fill(0));var p=this._len*8;if(p<=4294967295)this._block.writeUInt32BE(p,this._blockSize-4);else{var c=(p&4294967295)>>>0,f=(p-c)/4294967296;this._block.writeUInt32BE(f,this._blockSize-8),this._block.writeUInt32BE(c,this._blockSize-4)}this._update(this._block);var u=this._hash();return n?u.toString(n):u};it.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var hi=it,xi=oi,ne=hi,di=ie.Buffer,wi=[1518500249,1859775393,-1894007588,-899497514],gi=new Array(80);function Y(){this.init(),this._w=gi,ne.call(this,64,56)}xi(Y,ne);Y.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function yi(n){return n<<1|n>>>31}function vi(n){return n<<5|n>>>27}function bi(n){return n<<30|n>>>2}function Ei(n,r,p,c){return n===0?r&p|~r&c:n===2?r&p|r&c|p&c:r^p^c}Y.prototype._update=function(n){for(var r=this._w,p=this._a|0,c=this._b|0,f=this._c|0,u=this._d|0,l=this._e|0,a=0;a<16;++a)r[a]=n.readInt32BE(a*4);for(;a<80;++a)r[a]=yi(r[a-3]^r[a-8]^r[a-14]^r[a-16]);for(var x=0;x<80;++x){var d=~~(x/20),v=vi(p)+Ei(d,c,f,u)+l+r[x]+wi[d]|0;l=u,u=f,f=bi(c),c=p,p=v}this._a=p+this._a|0,this._b=c+this._b|0,this._c=f+this._c|0,this._d=u+this._d|0,this._e=l+this._e|0};Y.prototype._hash=function(){var n=di.allocUnsafe(20);return n.writeInt32BE(this._a|0,0),n.writeInt32BE(this._b|0,4),n.writeInt32BE(this._c|0,8),n.writeInt32BE(this._d|0,12),n.writeInt32BE(this._e|0,16),n};var Fi=Y;const _i=ni(Fi),vt=new Error("File system not available.");function Ai(n,r,p){throw vt}function oe(n){throw vt}function Si(n){throw vt}const ki=async n=>oe();function Bi(n){let r="";for(let p=0;p<n.length;p+=2)r+=String.fromCharCode(parseInt(n.substr(p,2),16));return btoa(r)}const rt=(n,r="sha1")=>{if(r!=="sha1")throw new Error("Only sha1 algorithm is available.");const p=new _i;return Bi(p.update(n).digest("hex"))};function ae(n){return n.type===Xe&&n.skip!==void 0&&n.skip>0&&n.hash!==void 0}function lt(n){return[P,$].includes(n.type)}function ut(n){return[Vt,P,$,K,Xt].includes(n.type)}function R(n,r,p,c,f="global"){if(!n)throw new Error("Empty action type");if(typeof n!="string")throw new Error(`Invalid action type: ${n}`);const u={type:n,input:r,scope:f};p&&(u.attachments=p);try{c==null||c().parse(u.input)}catch(l){throw new Error(`Invalid action input: ${l}`)}return u}function pe(n,r=gt){return(p,c,f,u)=>r(p,c,n,f,u)}const se=(n,r)=>({name:"",documentType:"",revision:{global:0,local:0},created:new Date().toISOString(),lastModified:new Date().toISOString(),attachments:{},...n,state:(r==null?void 0:r(n==null?void 0:n.state))??(n==null?void 0:n.state)??{global:{},local:{}}}),ce=(n,r)=>{const p=se(n,r);return{...p,initialState:p,operations:{global:[],local:[]},clipboard:[]}},bt=(n,r="global")=>rt(pt(n.state[r])),ji=(n,r=1e3)=>{const p=Math.random()*r;return rt(`${(n??new Date).toISOString()}${p}`)};function J(n){return D.castImmutable(D.freeze(n,!0))}function le(n,r){const p=[...n];let c=r||0,f=p.length>0?p[p.length-1].index:0;const u=[];for(const l of p.reverse()){if(c>0){const d=f-l.index;c-=d}if(c<0)throw new Error("Invalid operation index, missing operations");const a={ignore:c>0,operation:l},x=l.skip>0?l.skip+1:0;if(x>0&&x>c){const d=x-c;c=c+d}f=l.index,u.push(a)}return u.reverse()}function Oi(n){return Object.values(n).flatMap(r=>r).sort((r,p)=>new Date(r.timestamp).getTime()-new Date(p.timestamp).getTime())}function ue(n){return Object.values(n).flatMap(r=>r).sort((r,p)=>new Date(r.operation.timestamp).getTime()-new Date(p.operation.timestamp).getTime())}function tt(n,r,p,c,f,u=gt,l={}){const a=pe(p,u);return Et(n,r,a,c,f,l)}function Et(n,r,p,c,f,u={}){const l=ce(n),a=Object.keys(r).reduce((y,b)=>{const E=b;return{...y,[E]:r[E].slice(0,f==null?void 0:f.revision[E])}},{}),x=Object.keys(a).reduce((y,b)=>{const E=b;return{...y,[E]:le(a[E],u[E])}},{}),d=ue(x).reduce((y,{ignore:b,operation:E})=>b?p(y,_t(E.scope),c,{skip:E.skip,ignoreSkipOperations:!0}):p(y,E,c,{skip:E.skip,ignoreSkipOperations:!0}),l),v=Object.keys(d.operations).reduce((y,b)=>{const E=b,U=f&&f.revision[E]<r[E].length?r[E].slice(f.revision[E]):[];return{...y,[E]:[...d.operations[E].map((C,W)=>{var G;return{...C,timestamp:((G=r[E][W])==null?void 0:G.timestamp)??C.timestamp}}),...U]}},{global:[],local:[]}),g=Object.values(v).reduce((y,b)=>{for(const E of b)E.timestamp>y&&(y=E.timestamp);return y},"0");return{...d,operations:v,lastModified:g}}function Ii(n,r){return pt(n)===pt(r)}const fe=n=>R("SET_NAME",n,void 0,dt,void 0),me=(n=1,r="global")=>R("UNDO",n,void 0,wt,r),he=(n=1,r="global")=>R("REDO",n,void 0,xt,r),xe=(n,r,p="global")=>R("PRUNE",{start:n,end:r},void 0,ht,p),Ft=(n,r)=>R("LOAD_STATE",{state:n,operations:r},void 0,mt),_t=(n="global")=>R("NOOP",{},void 0,void 0,n),Ui=Object.freeze(Object.defineProperty({__proto__:null,loadState:Ft,noop:_t,prune:xe,redo:he,setName:fe,undo:me},Symbol.toStringTag,{value:"Module"})),de={"application/andrew-inset":["ez"],"application/appinstaller":["appinstaller"],"application/applixware":["aw"],"application/appx":["appx"],"application/appxbundle":["appxbundle"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/automationml-aml+xml":["aml"],"application/automationml-amlx+zip":["amlx"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cpl+xml":["cpl"],"application/cu-seeme":["cu"],"application/cwl":["cwl"],"application/dash+xml":["mpd"],"application/dash-patch+xml":["mpp"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/express":["exp"],"application/fdf":["fdf"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["*js"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/media-policy-dataset+xml":["mpf"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["*mp4","*mpg4","mp4s","m4p"],"application/msix":["msix"],"application/msixbundle":["msixbundle"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-keys":["asc"],"application/pgp-signature":["sig","*asc"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/sql":["sql"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/trig":["trig"],"application/ttml+xml":["ttml"],"application/ubjson":["ubj"],"application/urc-ressheet+xml":["rsheet"],"application/urc-targetdesc+xml":["td"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/watcherinfo+xml":["wif"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xfdf":["xfdf"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["*xsl","xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/aac":["adts","aac"],"audio/adpcm":["adp"],"audio/amr":["amr"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx","opus"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/avci":["avci"],"image/avcs":["avcs"],"image/avif":["avif"],"image/bmp":["bmp","dib"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/dpx":["dpx"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm","jpgm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/ktx2":["ktx2"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/jt":["jt"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/prc":["prc"],"model/step+xml":["stpx"],"model/step+zip":["stpz"],"model/step-xml+zip":["stpxz"],"model/stl":["stl"],"model/u3d":["u3d"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/javascript":["js","mjs"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["md","markdown"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/spdx":["spdx"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/wgsl":["wgsl"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/iso.segment":["m4s"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","*jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]};Object.freeze(de);var O=function(n,r,p,c){if(p==="a"&&!c)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?n!==r||!c:!r.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return p==="m"?c:p==="a"?c.call(n):c?c.value:r.get(n)},q,H,N;class Ti{constructor(...r){q.set(this,new Map),H.set(this,new Map),N.set(this,new Map);for(const p of r)this.define(p)}define(r,p=!1){for(let[c,f]of Object.entries(r)){c=c.toLowerCase(),f=f.map(a=>a.toLowerCase()),O(this,N,"f").has(c)||O(this,N,"f").set(c,new Set);const u=O(this,N,"f").get(c);let l=!0;for(let a of f){const x=a.startsWith("*");if(a=x?a.slice(1):a,u==null||u.add(a),l&&O(this,H,"f").set(c,a),l=!1,x)continue;const d=O(this,q,"f").get(a);if(d&&d!=c&&!p)throw new Error(`"${c} -> ${a}" conflicts with "${d} -> ${a}". Pass \`force=true\` to override this definition.`);O(this,q,"f").set(a,c)}}return this}getType(r){if(typeof r!="string")return null;const p=r.replace(/^.*[/\\]/,"").toLowerCase(),c=p.replace(/^.*\./,"").toLowerCase(),f=p.length<r.length;return!(c.length<p.length-1)&&f?null:O(this,q,"f").get(c)??null}getExtension(r){var p;return typeof r!="string"?null:(r=(p=r==null?void 0:r.split)==null?void 0:p.call(r,";")[0],(r&&O(this,H,"f").get(r.trim().toLowerCase()))??null)}getAllExtensions(r){return typeof r!="string"?null:O(this,N,"f").get(r.toLowerCase())??null}_freeze(){this.define=()=>{throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances")},Object.freeze(this);for(const r of O(this,N,"f").values())Object.freeze(r);return this}_getTestState(){return{types:O(this,q,"f"),extensions:O(this,H,"f")}}}q=new WeakMap,H=new WeakMap,N=new WeakMap;const zi=new Ti(de)._freeze();function we(n){const r=[],p=Object.keys(n);for(const c of p){const f=n[c].sort((u,l)=>u.index-l.index);for(let u=0;u<f.length;u++)f[u].index!==u&&r.push({message:`Invalid operation index ${f[u].index} at position ${u}`,details:{position:u,operation:f[u],scope:f[u].scope}})}return r}const At=async n=>{const r=new Nt,{name:p,revision:c,documentType:f,created:u,lastModified:l}=n,a={name:p,revision:c,documentType:f,created:u,lastModified:l};return r.file("header.json",JSON.stringify(a,null,2)),r.file("state.json",JSON.stringify(n.initialState||{},null,2)),r.file("operations.json",JSON.stringify(n.operations,null,2)),Object.keys(n.attachments).forEach(d=>{const{data:v,...g}=n.attachments[d];r.file(d,v,{base64:!0,createFolders:!0,comment:JSON.stringify(g)})}),r},ge=async(n,r,p,c)=>{await(await At(n)).generateAsync({type:"uint8array",streamFiles:!0});const u=c??n.name,l=`.${p}.zip`;return Ai(r,u.endsWith(l)?u:`${u}${l}`)},Di=async(n,r)=>{const c=await(await At(n)).generateAsync({type:"blob"}),f=await r.createWritable();await f.write(c),await f.close()},ft=async(n,r)=>{const p=oe();return ye(p,r)},ye=async(n,r)=>{const p=new Nt;return await p.loadAsync(n),Mi(p,r)};async function Mi(n,r){const p=n.file("state.json");if(!p)throw new Error("Initial state not found");const c=await p.async("string"),f=JSON.parse(c),u=n.file("header.json");let l;u&&(l=JSON.parse(await u.async("string")));const a=n.file("operations.json");if(!a)throw new Error("Operations history not found");const x=JSON.parse(await a.async("string")),d=we(x);if(d.length){const g=d.map(y=>y.message);throw new Error(g.join(`
6
+ */(function(n){var r=et,p=yt,c=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=a,n.SlowBuffer=G,n.INSPECT_MAX_BYTES=50;var f=2147483647;n.kMaxLength=f,a.TYPED_ARRAY_SUPPORT=u(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function u(){try{var i=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(i,t),i.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function l(i){if(i>f)throw new RangeError('The value "'+i+'" is invalid for option "size"');var t=new Uint8Array(i);return Object.setPrototypeOf(t,a.prototype),t}function a(i,t,e){if(typeof i=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return g(i)}return x(i,t,e)}a.poolSize=8192;function x(i,t,e){if(typeof i=="string")return y(i,t);if(ArrayBuffer.isView(i))return E(i);if(i==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i);if(T(i,ArrayBuffer)||i&&T(i.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(T(i,SharedArrayBuffer)||i&&T(i.buffer,SharedArrayBuffer)))return U(i,t,e);if(typeof i=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var o=i.valueOf&&i.valueOf();if(o!=null&&o!==i)return a.from(o,t,e);var s=C(i);if(s)return s;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof i[Symbol.toPrimitive]=="function")return a.from(i[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i)}a.from=function(i,t,e){return x(i,t,e)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function d(i){if(typeof i!="number")throw new TypeError('"size" argument must be of type number');if(i<0)throw new RangeError('The value "'+i+'" is invalid for option "size"')}function v(i,t,e){return d(i),i<=0?l(i):t!==void 0?typeof e=="string"?l(i).fill(t,e):l(i).fill(t):l(i)}a.alloc=function(i,t,e){return v(i,t,e)};function g(i){return d(i),l(i<0?0:W(i)|0)}a.allocUnsafe=function(i){return g(i)},a.allocUnsafeSlow=function(i){return g(i)};function y(i,t){if((typeof t!="string"||t==="")&&(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var e=St(i,t)|0,o=l(e),s=o.write(i,t);return s!==e&&(o=o.slice(0,s)),o}function b(i){for(var t=i.length<0?0:W(i.length)|0,e=l(t),o=0;o<t;o+=1)e[o]=i[o]&255;return e}function E(i){if(T(i,Uint8Array)){var t=new Uint8Array(i);return U(t.buffer,t.byteOffset,t.byteLength)}return b(i)}function U(i,t,e){if(t<0||i.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(i.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');var o;return t===void 0&&e===void 0?o=new Uint8Array(i):e===void 0?o=new Uint8Array(i,t):o=new Uint8Array(i,t,e),Object.setPrototypeOf(o,a.prototype),o}function C(i){if(a.isBuffer(i)){var t=W(i.length)|0,e=l(t);return e.length===0||i.copy(e,0,0,t),e}if(i.length!==void 0)return typeof i.length!="number"||ot(i.length)?l(0):b(i);if(i.type==="Buffer"&&Array.isArray(i.data))return b(i.data)}function W(i){if(i>=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+" bytes");return i|0}function G(i){return+i!=i&&(i=0),a.alloc(+i)}a.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==a.prototype},a.compare=function(t,e){if(T(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),T(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var o=t.length,s=e.length,m=0,h=Math.min(o,s);m<h;++m)if(t[m]!==e[m]){o=t[m],s=e[m];break}return o<s?-1:s<o?1:0},a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return a.alloc(0);var o;if(e===void 0)for(e=0,o=0;o<t.length;++o)e+=t[o].length;var s=a.allocUnsafe(e),m=0;for(o=0;o<t.length;++o){var h=t[o];if(T(h,Uint8Array))m+h.length>s.length?a.from(h).copy(s,m):Uint8Array.prototype.set.call(s,h,m);else if(a.isBuffer(h))h.copy(s,m);else throw new TypeError('"list" argument must be an Array of Buffers');m+=h.length}return s};function St(i,t){if(a.isBuffer(i))return i.length;if(ArrayBuffer.isView(i)||T(i,ArrayBuffer))return i.byteLength;if(typeof i!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof i);var e=i.length,o=arguments.length>2&&arguments[2]===!0;if(!o&&e===0)return 0;for(var s=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return nt(i).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return zt(i).length;default:if(s)return o?-1:nt(i).length;t=(""+t).toLowerCase(),s=!0}}a.byteLength=St;function be(i,t,e){var o=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(i||(i="utf8");;)switch(i){case"hex":return Ie(this,t,e);case"utf8":case"utf-8":return jt(this,t,e);case"ascii":return je(this,t,e);case"latin1":case"binary":return Oe(this,t,e);case"base64":return ke(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ue(this,t,e);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(i+"").toLowerCase(),o=!0}}a.prototype._isBuffer=!0;function M(i,t,e){var o=i[t];i[t]=i[e],i[e]=o}a.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)M(this,e,e+1);return this},a.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)M(this,e,e+3),M(this,e+1,e+2);return this},a.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)M(this,e,e+7),M(this,e+1,e+6),M(this,e+2,e+5),M(this,e+3,e+4);return this},a.prototype.toString=function(){var t=this.length;return t===0?"":arguments.length===0?jt(this,0,t):be.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:a.compare(this,t)===0},a.prototype.inspect=function(){var t="",e=n.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"},c&&(a.prototype[c]=a.prototype.inspect),a.prototype.compare=function(t,e,o,s,m){if(T(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),o===void 0&&(o=t?t.length:0),s===void 0&&(s=0),m===void 0&&(m=this.length),e<0||o>t.length||s<0||m>this.length)throw new RangeError("out of range index");if(s>=m&&e>=o)return 0;if(s>=m)return-1;if(e>=o)return 1;if(e>>>=0,o>>>=0,s>>>=0,m>>>=0,this===t)return 0;for(var h=m-s,F=o-e,_=Math.min(h,F),A=this.slice(s,m),B=t.slice(e,o),S=0;S<_;++S)if(A[S]!==B[S]){h=A[S],F=B[S];break}return h<F?-1:F<h?1:0};function kt(i,t,e,o,s){if(i.length===0)return-1;if(typeof e=="string"?(o=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,ot(e)&&(e=s?0:i.length-1),e<0&&(e=i.length+e),e>=i.length){if(s)return-1;e=i.length-1}else if(e<0)if(s)e=0;else return-1;if(typeof t=="string"&&(t=a.from(t,o)),a.isBuffer(t))return t.length===0?-1:Bt(i,t,e,o,s);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?s?Uint8Array.prototype.indexOf.call(i,t,e):Uint8Array.prototype.lastIndexOf.call(i,t,e):Bt(i,[t],e,o,s);throw new TypeError("val must be string, number or Buffer")}function Bt(i,t,e,o,s){var m=1,h=i.length,F=t.length;if(o!==void 0&&(o=String(o).toLowerCase(),o==="ucs2"||o==="ucs-2"||o==="utf16le"||o==="utf-16le")){if(i.length<2||t.length<2)return-1;m=2,h/=2,F/=2,e/=2}function _(Dt,Mt){return m===1?Dt[Mt]:Dt.readUInt16BE(Mt*m)}var A;if(s){var B=-1;for(A=e;A<h;A++)if(_(i,A)===_(t,B===-1?0:A-B)){if(B===-1&&(B=A),A-B+1===F)return B*m}else B!==-1&&(A-=A-B),B=-1}else for(e+F>h&&(e=h-F),A=e;A>=0;A--){for(var S=!0,X=0;X<F;X++)if(_(i,A+X)!==_(t,X)){S=!1;break}if(S)return A}return-1}a.prototype.includes=function(t,e,o){return this.indexOf(t,e,o)!==-1},a.prototype.indexOf=function(t,e,o){return kt(this,t,e,o,!0)},a.prototype.lastIndexOf=function(t,e,o){return kt(this,t,e,o,!1)};function Ee(i,t,e,o){e=Number(e)||0;var s=i.length-e;o?(o=Number(o),o>s&&(o=s)):o=s;var m=t.length;o>m/2&&(o=m/2);for(var h=0;h<o;++h){var F=parseInt(t.substr(h*2,2),16);if(ot(F))return h;i[e+h]=F}return h}function Fe(i,t,e,o){return V(nt(t,i.length-e),i,e,o)}function _e(i,t,e,o){return V(De(t),i,e,o)}function Ae(i,t,e,o){return V(zt(t),i,e,o)}function Se(i,t,e,o){return V(Me(t,i.length-e),i,e,o)}a.prototype.write=function(t,e,o,s){if(e===void 0)s="utf8",o=this.length,e=0;else if(o===void 0&&typeof e=="string")s=e,o=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(o)?(o=o>>>0,s===void 0&&(s="utf8")):(s=o,o=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var m=this.length-e;if((o===void 0||o>m)&&(o=m),t.length>0&&(o<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");s||(s="utf8");for(var h=!1;;)switch(s){case"hex":return Ee(this,t,e,o);case"utf8":case"utf-8":return Fe(this,t,e,o);case"ascii":case"latin1":case"binary":return _e(this,t,e,o);case"base64":return Ae(this,t,e,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Se(this,t,e,o);default:if(h)throw new TypeError("Unknown encoding: "+s);s=(""+s).toLowerCase(),h=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ke(i,t,e){return t===0&&e===i.length?r.fromByteArray(i):r.fromByteArray(i.slice(t,e))}function jt(i,t,e){e=Math.min(i.length,e);for(var o=[],s=t;s<e;){var m=i[s],h=null,F=m>239?4:m>223?3:m>191?2:1;if(s+F<=e){var _,A,B,S;switch(F){case 1:m<128&&(h=m);break;case 2:_=i[s+1],(_&192)===128&&(S=(m&31)<<6|_&63,S>127&&(h=S));break;case 3:_=i[s+1],A=i[s+2],(_&192)===128&&(A&192)===128&&(S=(m&15)<<12|(_&63)<<6|A&63,S>2047&&(S<55296||S>57343)&&(h=S));break;case 4:_=i[s+1],A=i[s+2],B=i[s+3],(_&192)===128&&(A&192)===128&&(B&192)===128&&(S=(m&15)<<18|(_&63)<<12|(A&63)<<6|B&63,S>65535&&S<1114112&&(h=S))}}h===null?(h=65533,F=1):h>65535&&(h-=65536,o.push(h>>>10&1023|55296),h=56320|h&1023),o.push(h),s+=F}return Be(o)}var Ot=4096;function Be(i){var t=i.length;if(t<=Ot)return String.fromCharCode.apply(String,i);for(var e="",o=0;o<t;)e+=String.fromCharCode.apply(String,i.slice(o,o+=Ot));return e}function je(i,t,e){var o="";e=Math.min(i.length,e);for(var s=t;s<e;++s)o+=String.fromCharCode(i[s]&127);return o}function Oe(i,t,e){var o="";e=Math.min(i.length,e);for(var s=t;s<e;++s)o+=String.fromCharCode(i[s]);return o}function Ie(i,t,e){var o=i.length;(!t||t<0)&&(t=0),(!e||e<0||e>o)&&(e=o);for(var s="",m=t;m<e;++m)s+=Ne[i[m]];return s}function Ue(i,t,e){for(var o=i.slice(t,e),s="",m=0;m<o.length-1;m+=2)s+=String.fromCharCode(o[m]+o[m+1]*256);return s}a.prototype.slice=function(t,e){var o=this.length;t=~~t,e=e===void 0?o:~~e,t<0?(t+=o,t<0&&(t=0)):t>o&&(t=o),e<0?(e+=o,e<0&&(e=0)):e>o&&(e=o),e<t&&(e=t);var s=this.subarray(t,e);return Object.setPrototypeOf(s,a.prototype),s};function k(i,t,e){if(i%1!==0||i<0)throw new RangeError("offset is not uint");if(i+t>e)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(t,e,o){t=t>>>0,e=e>>>0,o||k(t,e,this.length);for(var s=this[t],m=1,h=0;++h<e&&(m*=256);)s+=this[t+h]*m;return s},a.prototype.readUintBE=a.prototype.readUIntBE=function(t,e,o){t=t>>>0,e=e>>>0,o||k(t,e,this.length);for(var s=this[t+--e],m=1;e>0&&(m*=256);)s+=this[t+--e]*m;return s},a.prototype.readUint8=a.prototype.readUInt8=function(t,e){return t=t>>>0,e||k(t,1,this.length),this[t]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||k(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||k(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||k(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||k(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,e,o){t=t>>>0,e=e>>>0,o||k(t,e,this.length);for(var s=this[t],m=1,h=0;++h<e&&(m*=256);)s+=this[t+h]*m;return m*=128,s>=m&&(s-=Math.pow(2,8*e)),s},a.prototype.readIntBE=function(t,e,o){t=t>>>0,e=e>>>0,o||k(t,e,this.length);for(var s=e,m=1,h=this[t+--s];s>0&&(m*=256);)h+=this[t+--s]*m;return m*=128,h>=m&&(h-=Math.pow(2,8*e)),h},a.prototype.readInt8=function(t,e){return t=t>>>0,e||k(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},a.prototype.readInt16LE=function(t,e){t=t>>>0,e||k(t,2,this.length);var o=this[t]|this[t+1]<<8;return o&32768?o|4294901760:o},a.prototype.readInt16BE=function(t,e){t=t>>>0,e||k(t,2,this.length);var o=this[t+1]|this[t]<<8;return o&32768?o|4294901760:o},a.prototype.readInt32LE=function(t,e){return t=t>>>0,e||k(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return t=t>>>0,e||k(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,e){return t=t>>>0,e||k(t,4,this.length),p.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return t=t>>>0,e||k(t,4,this.length),p.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||k(t,8,this.length),p.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||k(t,8,this.length),p.read(this,t,!1,52,8)};function j(i,t,e,o,s,m){if(!a.isBuffer(i))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>s||t<m)throw new RangeError('"value" argument is out of bounds');if(e+o>i.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(t,e,o,s){if(t=+t,e=e>>>0,o=o>>>0,!s){var m=Math.pow(2,8*o)-1;j(this,t,e,o,m,0)}var h=1,F=0;for(this[e]=t&255;++F<o&&(h*=256);)this[e+F]=t/h&255;return e+o},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(t,e,o,s){if(t=+t,e=e>>>0,o=o>>>0,!s){var m=Math.pow(2,8*o)-1;j(this,t,e,o,m,0)}var h=o-1,F=1;for(this[e+h]=t&255;--h>=0&&(F*=256);)this[e+h]=t/F&255;return e+o},a.prototype.writeUint8=a.prototype.writeUInt8=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,1,255,0),this[e]=t&255,e+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4},a.prototype.writeIntLE=function(t,e,o,s){if(t=+t,e=e>>>0,!s){var m=Math.pow(2,8*o-1);j(this,t,e,o,m-1,-m)}var h=0,F=1,_=0;for(this[e]=t&255;++h<o&&(F*=256);)t<0&&_===0&&this[e+h-1]!==0&&(_=1),this[e+h]=(t/F>>0)-_&255;return e+o},a.prototype.writeIntBE=function(t,e,o,s){if(t=+t,e=e>>>0,!s){var m=Math.pow(2,8*o-1);j(this,t,e,o,m-1,-m)}var h=o-1,F=1,_=0;for(this[e+h]=t&255;--h>=0&&(F*=256);)t<0&&_===0&&this[e+h+1]!==0&&(_=1),this[e+h]=(t/F>>0)-_&255;return e+o},a.prototype.writeInt8=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1},a.prototype.writeInt16LE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2},a.prototype.writeInt16BE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2},a.prototype.writeInt32LE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},a.prototype.writeInt32BE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function It(i,t,e,o,s,m){if(e+o>i.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function Ut(i,t,e,o,s){return t=+t,e=e>>>0,s||It(i,t,e,4),p.write(i,t,e,o,23,4),e+4}a.prototype.writeFloatLE=function(t,e,o){return Ut(this,t,e,!0,o)},a.prototype.writeFloatBE=function(t,e,o){return Ut(this,t,e,!1,o)};function Tt(i,t,e,o,s){return t=+t,e=e>>>0,s||It(i,t,e,8),p.write(i,t,e,o,52,8),e+8}a.prototype.writeDoubleLE=function(t,e,o){return Tt(this,t,e,!0,o)},a.prototype.writeDoubleBE=function(t,e,o){return Tt(this,t,e,!1,o)},a.prototype.copy=function(t,e,o,s){if(!a.isBuffer(t))throw new TypeError("argument should be a Buffer");if(o||(o=0),!s&&s!==0&&(s=this.length),e>=t.length&&(e=t.length),e||(e=0),s>0&&s<o&&(s=o),s===o||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(o<0||o>=this.length)throw new RangeError("Index out of range");if(s<0)throw new RangeError("sourceEnd out of bounds");s>this.length&&(s=this.length),t.length-e<s-o&&(s=t.length-e+o);var m=s-o;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,o,s):Uint8Array.prototype.set.call(t,this.subarray(o,s),e),m},a.prototype.fill=function(t,e,o,s){if(typeof t=="string"){if(typeof e=="string"?(s=e,e=0,o=this.length):typeof o=="string"&&(s=o,o=this.length),s!==void 0&&typeof s!="string")throw new TypeError("encoding must be a string");if(typeof s=="string"&&!a.isEncoding(s))throw new TypeError("Unknown encoding: "+s);if(t.length===1){var m=t.charCodeAt(0);(s==="utf8"&&m<128||s==="latin1")&&(t=m)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<o)throw new RangeError("Out of range index");if(o<=e)return this;e=e>>>0,o=o===void 0?this.length:o>>>0,t||(t=0);var h;if(typeof t=="number")for(h=e;h<o;++h)this[h]=t;else{var F=a.isBuffer(t)?t:a.from(t,s),_=F.length;if(_===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(h=0;h<o-e;++h)this[h+e]=F[h%_]}return this};var Te=/[^+/0-9A-Za-z-_]/g;function ze(i){if(i=i.split("=")[0],i=i.trim().replace(Te,""),i.length<2)return"";for(;i.length%4!==0;)i=i+"=";return i}function nt(i,t){t=t||1/0;for(var e,o=i.length,s=null,m=[],h=0;h<o;++h){if(e=i.charCodeAt(h),e>55295&&e<57344){if(!s){if(e>56319){(t-=3)>-1&&m.push(239,191,189);continue}else if(h+1===o){(t-=3)>-1&&m.push(239,191,189);continue}s=e;continue}if(e<56320){(t-=3)>-1&&m.push(239,191,189),s=e;continue}e=(s-55296<<10|e-56320)+65536}else s&&(t-=3)>-1&&m.push(239,191,189);if(s=null,e<128){if((t-=1)<0)break;m.push(e)}else if(e<2048){if((t-=2)<0)break;m.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;m.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;m.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return m}function De(i){for(var t=[],e=0;e<i.length;++e)t.push(i.charCodeAt(e)&255);return t}function Me(i,t){for(var e,o,s,m=[],h=0;h<i.length&&!((t-=2)<0);++h)e=i.charCodeAt(h),o=e>>8,s=e%256,m.push(s),m.push(o);return m}function zt(i){return r.toByteArray(ze(i))}function V(i,t,e,o){for(var s=0;s<o&&!(s+e>=t.length||s>=i.length);++s)t[s+e]=i[s];return s}function T(i,t){return i instanceof t||i!=null&&i.constructor!=null&&i.constructor.name!=null&&i.constructor.name===t.name}function ot(i){return i!==i}var Ne=function(){for(var i="0123456789abcdef",t=new Array(256),e=0;e<16;++e)for(var o=e*16,s=0;s<16;++s)t[o+s]=i[e]+i[s];return t}()})(te);/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(n,r){var p=te,c=p.Buffer;function f(l,a){for(var x in l)a[x]=l[x]}c.from&&c.alloc&&c.allocUnsafe&&c.allocUnsafeSlow?n.exports=p:(f(p,r),r.Buffer=u);function u(l,a,x){return c(l,a,x)}u.prototype=Object.create(c.prototype),f(c,u),u.from=function(l,a,x){if(typeof l=="number")throw new TypeError("Argument must not be a number");return c(l,a,x)},u.alloc=function(l,a,x){if(typeof l!="number")throw new TypeError("Argument must be a number");var d=c(l);return a!==void 0?typeof x=="string"?d.fill(a,x):d.fill(a):d.fill(0),d},u.allocUnsafe=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return c(l)},u.allocUnsafeSlow=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return p.SlowBuffer(l)}})(ct,ct.exports);var ie=ct.exports,re=ie.Buffer;function it(n,r){this._block=re.alloc(n),this._finalSize=r,this._blockSize=n,this._len=0}it.prototype.update=function(n,r){typeof n=="string"&&(r=r||"utf8",n=re.from(n,r));for(var p=this._block,c=this._blockSize,f=n.length,u=this._len,l=0;l<f;){for(var a=u%c,x=Math.min(f-l,c-a),d=0;d<x;d++)p[a+d]=n[l+d];u+=x,l+=x,u%c===0&&this._update(p)}return this._len+=f,this};it.prototype.digest=function(n){var r=this._len%this._blockSize;this._block[r]=128,this._block.fill(0,r+1),r>=this._finalSize&&(this._update(this._block),this._block.fill(0));var p=this._len*8;if(p<=4294967295)this._block.writeUInt32BE(p,this._blockSize-4);else{var c=(p&4294967295)>>>0,f=(p-c)/4294967296;this._block.writeUInt32BE(f,this._blockSize-8),this._block.writeUInt32BE(c,this._blockSize-4)}this._update(this._block);var u=this._hash();return n?u.toString(n):u};it.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var hi=it,xi=oi,ne=hi,di=ie.Buffer,wi=[1518500249,1859775393,-1894007588,-899497514],gi=new Array(80);function Y(){this.init(),this._w=gi,ne.call(this,64,56)}xi(Y,ne);Y.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function yi(n){return n<<1|n>>>31}function vi(n){return n<<5|n>>>27}function bi(n){return n<<30|n>>>2}function Ei(n,r,p,c){return n===0?r&p|~r&c:n===2?r&p|r&c|p&c:r^p^c}Y.prototype._update=function(n){for(var r=this._w,p=this._a|0,c=this._b|0,f=this._c|0,u=this._d|0,l=this._e|0,a=0;a<16;++a)r[a]=n.readInt32BE(a*4);for(;a<80;++a)r[a]=yi(r[a-3]^r[a-8]^r[a-14]^r[a-16]);for(var x=0;x<80;++x){var d=~~(x/20),v=vi(p)+Ei(d,c,f,u)+l+r[x]+wi[d]|0;l=u,u=f,f=bi(c),c=p,p=v}this._a=p+this._a|0,this._b=c+this._b|0,this._c=f+this._c|0,this._d=u+this._d|0,this._e=l+this._e|0};Y.prototype._hash=function(){var n=di.allocUnsafe(20);return n.writeInt32BE(this._a|0,0),n.writeInt32BE(this._b|0,4),n.writeInt32BE(this._c|0,8),n.writeInt32BE(this._d|0,12),n.writeInt32BE(this._e|0,16),n};var Fi=Y;const _i=ni(Fi),vt=new Error("File system not available.");function Ai(n,r,p){throw vt}function oe(n){throw vt}function Si(n){throw vt}const ki=async n=>oe();function Bi(n){let r="";for(let p=0;p<n.length;p+=2)r+=String.fromCharCode(parseInt(n.substr(p,2),16));return btoa(r)}const rt=(n,r="sha1")=>{if(r!=="sha1")throw new Error("Only sha1 algorithm is available.");const p=new _i;return Bi(p.update(n).digest("hex"))};function ae(n){return n.type===Xe&&n.skip!==void 0&&n.skip>0&&n.hash!==void 0}function lt(n){return[P,$].includes(n.type)}function ut(n){return[Vt,P,$,K,Xt].includes(n.type)}function R(n,r,p,c,f="global"){if(!n)throw new Error("Empty action type");if(typeof n!="string")throw new Error(`Invalid action type: ${n}`);const u={type:n,input:r,scope:f};p&&(u.attachments=p);try{c==null||c().parse(u.input)}catch(l){throw new Error(`Invalid action input: ${l}`)}return u}function pe(n,r=gt){return(p,c,f,u)=>r(p,c,n,f,u)}const se=(n,r)=>({name:"",documentType:"",revision:{global:0,local:0},created:new Date().toISOString(),lastModified:new Date().toISOString(),attachments:{},...n,state:(r==null?void 0:r(n==null?void 0:n.state))??(n==null?void 0:n.state)??{global:{},local:{}}}),ce=(n,r)=>{const p=se(n,r);return{...p,initialState:p,operations:{global:[],local:[]},clipboard:[]}},bt=(n,r="global")=>rt(pt(n.state[r])),ji=(n,r=1e3)=>{const p=Math.random()*r;return rt(`${(n??new Date).toISOString()}${p}`)};function J(n){return D.castImmutable(D.freeze(n,!0))}function le(n,r){const p=[...n];let c=r||0,f=p.length>0?p[p.length-1].index:0;const u=[];for(const l of p.reverse()){if(c>0){const d=f-l.index;c-=d}if(c<0)throw new Error("Invalid operation index, missing operations");const a={ignore:c>0,operation:l},x=l.skip>0?l.skip+1:0;if(x>0&&x>c){const d=x-c;c=c+d}f=l.index,u.push(a)}return u.reverse()}function Oi(n){return Object.values(n).flatMap(r=>r).sort((r,p)=>new Date(r.timestamp).getTime()-new Date(p.timestamp).getTime())}function ue(n){return Object.values(n).flatMap(r=>r).sort((r,p)=>new Date(r.operation.timestamp).getTime()-new Date(p.operation.timestamp).getTime())}function tt(n,r,p,c,f,u=gt,l={}){const a=pe(p,u);return Et(n,r,a,c,f,l)}function Et(n,r,p,c,f,u={}){const l=ce(n),a=Object.keys(r).reduce((y,b)=>{const E=b;return{...y,[E]:r[E].slice(0,f==null?void 0:f.revision[E])}},{}),x=Object.keys(a).reduce((y,b)=>{const E=b;return{...y,[E]:le(a[E],u[E])}},{}),d=ue(x).reduce((y,{ignore:b,operation:E})=>b?p(y,_t(E.scope),c,{skip:E.skip,ignoreSkipOperations:!0}):p(y,E,c,{skip:E.skip,ignoreSkipOperations:!0}),l),v=Object.keys(d.operations).reduce((y,b)=>{const E=b,U=f&&f.revision[E]<r[E].length?r[E].slice(f.revision[E]):[];return{...y,[E]:[...d.operations[E].map((C,W)=>{var G;return{...C,timestamp:((G=r[E][W])==null?void 0:G.timestamp)??C.timestamp}}),...U]}},{global:[],local:[]}),g=Object.values(v).reduce((y,b)=>{for(const E of b)E.timestamp>y&&(y=E.timestamp);return y},n.lastModified);return{...d,operations:v,lastModified:g}}function Ii(n,r){return pt(n)===pt(r)}const fe=n=>R("SET_NAME",n,void 0,dt,void 0),me=(n=1,r="global")=>R("UNDO",n,void 0,wt,r),he=(n=1,r="global")=>R("REDO",n,void 0,xt,r),xe=(n,r,p="global")=>R("PRUNE",{start:n,end:r},void 0,ht,p),Ft=(n,r)=>R("LOAD_STATE",{state:n,operations:r},void 0,mt),_t=(n="global")=>R("NOOP",{},void 0,void 0,n),Ui=Object.freeze(Object.defineProperty({__proto__:null,loadState:Ft,noop:_t,prune:xe,redo:he,setName:fe,undo:me},Symbol.toStringTag,{value:"Module"})),de={"application/andrew-inset":["ez"],"application/appinstaller":["appinstaller"],"application/applixware":["aw"],"application/appx":["appx"],"application/appxbundle":["appxbundle"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/automationml-aml+xml":["aml"],"application/automationml-amlx+zip":["amlx"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cpl+xml":["cpl"],"application/cu-seeme":["cu"],"application/cwl":["cwl"],"application/dash+xml":["mpd"],"application/dash-patch+xml":["mpp"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/express":["exp"],"application/fdf":["fdf"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["*js"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/media-policy-dataset+xml":["mpf"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["*mp4","*mpg4","mp4s","m4p"],"application/msix":["msix"],"application/msixbundle":["msixbundle"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-keys":["asc"],"application/pgp-signature":["sig","*asc"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/sql":["sql"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/trig":["trig"],"application/ttml+xml":["ttml"],"application/ubjson":["ubj"],"application/urc-ressheet+xml":["rsheet"],"application/urc-targetdesc+xml":["td"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/watcherinfo+xml":["wif"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xfdf":["xfdf"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["*xsl","xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/aac":["adts","aac"],"audio/adpcm":["adp"],"audio/amr":["amr"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx","opus"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/avci":["avci"],"image/avcs":["avcs"],"image/avif":["avif"],"image/bmp":["bmp","dib"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/dpx":["dpx"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm","jpgm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/ktx2":["ktx2"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/jt":["jt"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/prc":["prc"],"model/step+xml":["stpx"],"model/step+zip":["stpz"],"model/step-xml+zip":["stpxz"],"model/stl":["stl"],"model/u3d":["u3d"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/javascript":["js","mjs"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["md","markdown"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/spdx":["spdx"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/wgsl":["wgsl"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/iso.segment":["m4s"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","*jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]};Object.freeze(de);var O=function(n,r,p,c){if(p==="a"&&!c)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?n!==r||!c:!r.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return p==="m"?c:p==="a"?c.call(n):c?c.value:r.get(n)},q,H,N;class Ti{constructor(...r){q.set(this,new Map),H.set(this,new Map),N.set(this,new Map);for(const p of r)this.define(p)}define(r,p=!1){for(let[c,f]of Object.entries(r)){c=c.toLowerCase(),f=f.map(a=>a.toLowerCase()),O(this,N,"f").has(c)||O(this,N,"f").set(c,new Set);const u=O(this,N,"f").get(c);let l=!0;for(let a of f){const x=a.startsWith("*");if(a=x?a.slice(1):a,u==null||u.add(a),l&&O(this,H,"f").set(c,a),l=!1,x)continue;const d=O(this,q,"f").get(a);if(d&&d!=c&&!p)throw new Error(`"${c} -> ${a}" conflicts with "${d} -> ${a}". Pass \`force=true\` to override this definition.`);O(this,q,"f").set(a,c)}}return this}getType(r){if(typeof r!="string")return null;const p=r.replace(/^.*[/\\]/,"").toLowerCase(),c=p.replace(/^.*\./,"").toLowerCase(),f=p.length<r.length;return!(c.length<p.length-1)&&f?null:O(this,q,"f").get(c)??null}getExtension(r){var p;return typeof r!="string"?null:(r=(p=r==null?void 0:r.split)==null?void 0:p.call(r,";")[0],(r&&O(this,H,"f").get(r.trim().toLowerCase()))??null)}getAllExtensions(r){return typeof r!="string"?null:O(this,N,"f").get(r.toLowerCase())??null}_freeze(){this.define=()=>{throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances")},Object.freeze(this);for(const r of O(this,N,"f").values())Object.freeze(r);return this}_getTestState(){return{types:O(this,q,"f"),extensions:O(this,H,"f")}}}q=new WeakMap,H=new WeakMap,N=new WeakMap;const zi=new Ti(de)._freeze();function we(n){const r=[],p=Object.keys(n);for(const c of p){const f=n[c].sort((u,l)=>u.index-l.index);for(let u=0;u<f.length;u++)f[u].index!==u&&r.push({message:`Invalid operation index ${f[u].index} at position ${u}`,details:{position:u,operation:f[u],scope:f[u].scope}})}return r}const At=async n=>{const r=new Nt,{name:p,revision:c,documentType:f,created:u,lastModified:l}=n,a={name:p,revision:c,documentType:f,created:u,lastModified:l};return r.file("header.json",JSON.stringify(a,null,2)),r.file("state.json",JSON.stringify(n.initialState||{},null,2)),r.file("operations.json",JSON.stringify(n.operations,null,2)),Object.keys(n.attachments).forEach(d=>{const{data:v,...g}=n.attachments[d];r.file(d,v,{base64:!0,createFolders:!0,comment:JSON.stringify(g)})}),r},ge=async(n,r,p,c)=>{await(await At(n)).generateAsync({type:"uint8array",streamFiles:!0});const u=c??n.name,l=`.${p}.zip`;return Ai(r,u.endsWith(l)?u:`${u}${l}`)},Di=async(n,r)=>{const c=await(await At(n)).generateAsync({type:"blob"}),f=await r.createWritable();await f.write(c),await f.close()},ft=async(n,r)=>{const p=oe();return ye(p,r)},ye=async(n,r)=>{const p=new Nt;return await p.loadAsync(n),Mi(p,r)};async function Mi(n,r){const p=n.file("state.json");if(!p)throw new Error("Initial state not found");const c=await p.async("string"),f=JSON.parse(c),u=n.file("header.json");let l;u&&(l=JSON.parse(await u.async("string")));const a=n.file("operations.json");if(!a)throw new Error("Operations history not found");const x=JSON.parse(await a.async("string")),d=we(x);if(d.length){const g=d.map(y=>y.message);throw new Error(g.join(`
7
7
  `))}let v=Et(f,x,r,void 0,l);return l&&(v={...v,...l}),v}function ve(n){const r=n.replace(/^.*\./,"")||void 0,p=n.replace(/^.*[/\\]/,"")||void 0;return{extension:r,fileName:p}}async function Ni(n){const{buffer:r,mimeType:p="application/octet-stream"}=await Si(),c=ve(n),f=r.toString("base64");return{data:f,hash:rt(f),mimeType:p,...c}}async function Ri(n){const r=await ki(),p=zi.getType(n)||"application/octet-stream",c=ve(n),f=r.toString("base64");return{data:f,hash:rt(f),mimeType:p,...c}}class Ci{constructor(r,p,c){Q(this,"_document");Q(this,"_reducer");Q(this,"_signalDispatch");this._reducer=r,this._document=p,this._signalDispatch=c}dispatch(r,p){return this._document=this._reducer(this._document,r,this._signalDispatch,p),this}saveToFile(r,p,c){return ge(this._document,r,p,c)}async loadFromFile(r){this._document=await ft(r,this._reducer)}static async stateFromFile(r,p){return await ft(r,p)}get state(){return J(this._document.state)}get operations(){return J(this._document.operations)}get name(){return this._document.name}get documentType(){return this._document.documentType}get created(){return this._document.created}get lastModified(){return this._document.lastModified}get revision(){return this._document.revision.global}getRevision(r){return this._document.revision[r]}get initialState(){return J(this._document.initialState)}toDocument(){return J(this._document)}getAttachment(r){return this._document.attachments[r]}setName(r){return this.dispatch(fe(r)),this}undo(r){return this.dispatch(me(r)),this}redo(r){return this.dispatch(he(r)),this}prune(r,p){return this.dispatch(xe(r,p)),this}loadState(r,p){return this.dispatch(Ft(r,p)),this}}function Li(n,r){r.forEach(p=>{Object.getOwnPropertyNames(p.prototype).forEach(c=>{Object.defineProperty(n.prototype,c,Object.getOwnPropertyDescriptor(p.prototype,c)||Object.create(null))})})}exports.BaseActions=Ui;exports.BaseDocument=Ci;exports.applyMixins=Li;exports.baseReducer=gt;exports.createAction=R;exports.createDocument=ce;exports.createExtendedState=se;exports.createReducer=pe;exports.createZip=At;exports.getLocalFile=Ri;exports.getRemoteFile=Ni;exports.hashDocument=bt;exports.hashKey=ji;exports.isBaseAction=ut;exports.isNoopOperation=ae;exports.isSameDocument=Ii;exports.isUndoRedo=lt;exports.loadFromFile=ft;exports.loadFromInput=ye;exports.mapSkippedOperations=le;exports.processUndoRedo=Qt;exports.readOnly=J;exports.replayDocument=Et;exports.replayOperations=tt;exports.saveToFile=ge;exports.saveToFileHandle=Di;exports.sortMappedOperations=ue;exports.sortOperations=Oi;exports.validateOperations=we;exports.zod=Je;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-C778ylvS.js");require("immer");require("json-stringify-deterministic");require("crypto");require("fs");require("https");require("path");require("jszip");const e=require("./internal/index-CP5hMjbq.js");require("zod");exports.Document=e.Document;exports.DocumentModel=e.DocumentModel$1;exports.actions=e.actions;exports.documentModel=e.documentModel;exports.module=e.module;exports.reducer=e.reducer;exports.utils=e.utils;exports.z=e.zod;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-B5Lf9AWl.js");require("immer");require("json-stringify-deterministic");require("crypto");require("fs");require("https");require("path");require("jszip");const e=require("./internal/index-qa67kbhM.js");require("zod");exports.Document=e.Document;exports.DocumentModel=e.DocumentModel$1;exports.actions=e.actions;exports.documentModel=e.documentModel;exports.module=e.module;exports.reducer=e.reducer;exports.utils=e.utils;exports.z=e.zod;
@@ -1,4 +1,4 @@
1
- import "./internal/object-BIG1wTk-.js";
1
+ import "./internal/object-CvntAblp.js";
2
2
  import "immer";
3
3
  import "json-stringify-deterministic";
4
4
  import "crypto";
@@ -6,7 +6,7 @@ import "fs";
6
6
  import "https";
7
7
  import "path";
8
8
  import "jszip";
9
- import { b as d, a as l, c as n, d as D, m as M, r as b, u as f, z as x } from "./internal/index-rIcx-JJZ.js";
9
+ import { b as d, a as l, c as n, d as D, m as M, r as b, u as f, z as x } from "./internal/index-CEkeEja8.js";
10
10
  import "zod";
11
11
  export {
12
12
  d as Document,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal/object-C778ylvS.js"),r=require("./internal/index-CW5xQQ7a.js");require("immer");require("json-stringify-deterministic");require("zod");require("crypto");require("fs");require("https");require("path");require("jszip");exports.BaseDocument=e.BaseDocument;exports.actions=e.BaseActions;exports.applyMixins=e.applyMixins;exports.baseReducer=e.baseReducer;exports.processUndoRedo=e.processUndoRedo;exports.z=e.zod;exports.utils=r.index;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal/object-B5Lf9AWl.js"),r=require("./internal/index-DjP2tO7C.js");require("immer");require("json-stringify-deterministic");require("zod");require("crypto");require("fs");require("https");require("path");require("jszip");exports.BaseDocument=e.BaseDocument;exports.actions=e.BaseActions;exports.applyMixins=e.applyMixins;exports.baseReducer=e.baseReducer;exports.processUndoRedo=e.processUndoRedo;exports.z=e.zod;exports.utils=r.index;
@@ -1,5 +1,5 @@
1
- import { B as n, h as d, g as u, A as x, C as f, D as l } from "./internal/object-BIG1wTk-.js";
2
- import { i as D } from "./internal/index-C21AbOFE.js";
1
+ import { B as n, h as d, g as u, A as x, C as f, D as l } from "./internal/object-CvntAblp.js";
2
+ import { i as D } from "./internal/index-D_eCXEyL.js";
3
3
  import "immer";
4
4
  import "json-stringify-deterministic";
5
5
  import "zod";
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./internal/index-CW5xQQ7a.js"),o=require("./internal/index-CP5hMjbq.js");require("./internal/object-C778ylvS.js");require("immer");require("json-stringify-deterministic");require("zod");require("crypto");require("fs");require("https");require("path");require("jszip");const u={"powerhouse/document":e.Document,"powerhouse/document-model":o.DocumentModel},r={Document:e.Document,DocumentModel:o.DocumentModel};exports.Document=e.Document;exports.DocumentModel=o.DocumentModel;exports.DocumentModels=u;exports.default=r;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./internal/index-DjP2tO7C.js"),o=require("./internal/index-qa67kbhM.js");require("./internal/object-B5Lf9AWl.js");require("immer");require("json-stringify-deterministic");require("zod");require("crypto");require("fs");require("https");require("path");require("jszip");const u={"powerhouse/document":e.Document,"powerhouse/document-model":o.DocumentModel},r={Document:e.Document,DocumentModel:o.DocumentModel};exports.Document=e.Document;exports.DocumentModel=o.DocumentModel;exports.DocumentModels=u;exports.default=r;
@@ -1,6 +1,6 @@
1
- import { D as o } from "./internal/index-C21AbOFE.js";
2
- import { D as t } from "./internal/index-rIcx-JJZ.js";
3
- import "./internal/object-BIG1wTk-.js";
1
+ import { D as o } from "./internal/index-D_eCXEyL.js";
2
+ import { D as t } from "./internal/index-CEkeEja8.js";
3
+ import "./internal/object-CvntAblp.js";
4
4
  import "immer";
5
5
  import "json-stringify-deterministic";
6
6
  import "zod";
@@ -1,7 +1,7 @@
1
1
  var ut = Object.defineProperty;
2
2
  var mt = (t, e, r) => e in t ? ut(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
3
  var ce = (t, e, r) => (mt(t, typeof e != "symbol" ? e + "" : e, r), r);
4
- import { c as Et, i as ht, a as Ot, b as gt, s as St, d as bt, l as ft, e as _t, f as s, B as l, g as It, h as Tt } from "./object-BIG1wTk-.js";
4
+ import { c as Et, i as ht, a as Ot, b as gt, s as St, d as bt, l as ft, e as _t, f as s, B as l, g as It, h as Tt } from "./object-CvntAblp.js";
5
5
  import "immer";
6
6
  import "json-stringify-deterministic";
7
7
  import "crypto";
@@ -1,4 +1,4 @@
1
- import { f as e, b as a, a as s, c as o, j as t, k as r, m as i, n, o as c, i as l, p, q as d, r as u, l as m, e as O, t as y, u as b, v as D, w as _, s as g, d as F, x as S, y as f, z as v, B as h, h as j, g as x, A as z, C as R, D as A } from "./object-CqQGngpx.js";
1
+ import { f as e, b as a, a as s, c as o, j as t, k as r, m as i, n, o as c, i as l, p, q as d, r as u, l as m, e as O, t as y, u as b, v as D, w as _, s as g, d as F, x as S, y as f, z as v, B as h, h as j, g as x, A as z, C as R, D as A } from "./object-CvntAblp.js";
2
2
  const B = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3
3
  __proto__: null,
4
4
  createAction: e,
@@ -1 +1 @@
1
- "use strict";const e=require("./object-BOMJbn2Y.js"),o=Object.freeze(Object.defineProperty({__proto__:null,createAction:e.createAction,createDocument:e.createDocument,createExtendedState:e.createExtendedState,createReducer:e.createReducer,createZip:e.createZip,getLocalFile:e.getLocalFile,getRemoteFile:e.getRemoteFile,hashDocument:e.hashDocument,hashKey:e.hashKey,isBaseAction:e.isBaseAction,isNoopOperation:e.isNoopOperation,isSameDocument:e.isSameDocument,isUndoRedo:e.isUndoRedo,loadFromFile:e.loadFromFile,loadFromInput:e.loadFromInput,mapSkippedOperations:e.mapSkippedOperations,readOnly:e.readOnly,replayDocument:e.replayDocument,replayOperations:e.replayOperations,saveToFile:e.saveToFile,saveToFileHandle:e.saveToFileHandle,sortMappedOperations:e.sortMappedOperations,sortOperations:e.sortOperations,validateOperations:e.validateOperations},Symbol.toStringTag,{value:"Module"})),t=Object.freeze(Object.defineProperty({__proto__:null,BaseDocument:e.BaseDocument,actions:e.BaseActions,applyMixins:e.applyMixins,baseReducer:e.baseReducer,processUndoRedo:e.processUndoRedo,utils:o,z:e.zod},Symbol.toStringTag,{value:"Module"}));exports.Document=t;exports.index=o;
1
+ "use strict";const e=require("./object-B5Lf9AWl.js"),o=Object.freeze(Object.defineProperty({__proto__:null,createAction:e.createAction,createDocument:e.createDocument,createExtendedState:e.createExtendedState,createReducer:e.createReducer,createZip:e.createZip,getLocalFile:e.getLocalFile,getRemoteFile:e.getRemoteFile,hashDocument:e.hashDocument,hashKey:e.hashKey,isBaseAction:e.isBaseAction,isNoopOperation:e.isNoopOperation,isSameDocument:e.isSameDocument,isUndoRedo:e.isUndoRedo,loadFromFile:e.loadFromFile,loadFromInput:e.loadFromInput,mapSkippedOperations:e.mapSkippedOperations,readOnly:e.readOnly,replayDocument:e.replayDocument,replayOperations:e.replayOperations,saveToFile:e.saveToFile,saveToFileHandle:e.saveToFileHandle,sortMappedOperations:e.sortMappedOperations,sortOperations:e.sortOperations,validateOperations:e.validateOperations},Symbol.toStringTag,{value:"Module"})),t=Object.freeze(Object.defineProperty({__proto__:null,BaseDocument:e.BaseDocument,actions:e.BaseActions,applyMixins:e.applyMixins,baseReducer:e.baseReducer,processUndoRedo:e.processUndoRedo,utils:o,z:e.zod},Symbol.toStringTag,{value:"Module"}));exports.Document=t;exports.index=o;
@@ -1,4 +1,4 @@
1
- "use strict";var mt=Object.defineProperty;var Et=(t,e,r)=>e in t?mt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var me=(t,e,r)=>(Et(t,typeof e!="symbol"?e+"":e,r),r);const s=require("./object-C778ylvS.js");require("immer");require("json-stringify-deterministic");require("crypto");require("fs");require("https");require("path");require("jszip");const o=require("zod"),ht=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),_={id:"powerhouse/document-model",name:"DocumentModel",extension:"phdm",description:"The Powerhouse Document Model describes the state and operations of a document type.",author:{name:"Powerhouse",website:"https://www.powerhouse.inc/"},specifications:[{version:1,changeLog:[],modules:[{name:"header",operations:[{name:"SetModelName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelId",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelExtension",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetAuthorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetAuthorWebsite",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"versioning",operations:[{name:"AddChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderChangeLogItems",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReleaseNewVersion",schema:null,id:"",description:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"module",operations:[{name:"AddModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModuleName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModuleDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderModules",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation-error",operations:[{name:"AddOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorCode",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderOperationErrors",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation-example",operations:[{name:"AddOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderOperationExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation",operations:[{name:"AddOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationReducer",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"MoveOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderModuleOperations",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"state",operations:[{name:"SetStateSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetInitialState",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"AddStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderStateExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""}],state:{global:{schema:"",initialValue:`{
1
+ "use strict";var mt=Object.defineProperty;var Et=(t,e,r)=>e in t?mt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var me=(t,e,r)=>(Et(t,typeof e!="symbol"?e+"":e,r),r);const s=require("./object-B5Lf9AWl.js");require("immer");require("json-stringify-deterministic");require("crypto");require("fs");require("https");require("path");require("jszip");const o=require("zod"),ht=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),_={id:"powerhouse/document-model",name:"DocumentModel",extension:"phdm",description:"The Powerhouse Document Model describes the state and operations of a document type.",author:{name:"Powerhouse",website:"https://www.powerhouse.inc/"},specifications:[{version:1,changeLog:[],modules:[{name:"header",operations:[{name:"SetModelName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelId",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelExtension",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetAuthorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetAuthorWebsite",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"versioning",operations:[{name:"AddChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderChangeLogItems",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReleaseNewVersion",schema:null,id:"",description:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"module",operations:[{name:"AddModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModuleName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModuleDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderModules",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation-error",operations:[{name:"AddOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorCode",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderOperationErrors",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation-example",operations:[{name:"AddOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderOperationExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation",operations:[{name:"AddOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationReducer",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"MoveOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderModuleOperations",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"state",operations:[{name:"SetStateSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetInitialState",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"AddStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderStateExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""}],state:{global:{schema:"",initialValue:`{
2
2
  "id": "",
3
3
  "name": "",
4
4
  "extension": "",
@@ -0,0 +1,2 @@
1
+ "use strict";var Et=Object.defineProperty;var Nt=(e,t,i)=>t in e?Et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var E=(e,t,i)=>(Nt(e,typeof t!="symbol"?t+"":t,i),i);const h=require("immer"),A=require("json-stringify-deterministic"),c=require("zod"),Tt=require("crypto"),M=require("fs"),At=require("https"),Mt=require("path"),V=require("jszip"),G=e=>e!=null,Ft=c.z.any().refine(e=>G(e)),Q=c.z.enum(["LOAD_STATE"]),X=c.z.enum(["PRUNE"]),Y=c.z.enum(["REDO"]),tt=c.z.enum(["SET_NAME"]),et=c.z.enum(["UNDO"]);function It(){return c.z.object({__typename:c.z.literal("Action").optional(),type:c.z.string()})}function z(){return c.z.literal("global").or(c.z.literal("local"))}function it(){return c.z.union([nt(),ot(),st(),pt(),ct()])}function Pt(){return c.z.object({__typename:c.z.literal("DocumentFile").optional(),data:c.z.string(),extension:c.z.string().nullable(),fileName:c.z.string().nullable(),mimeType:c.z.string()})}function nt(){return c.z.object({input:c.z.lazy(()=>R()),type:Q,scope:z()})}function R(){return c.z.object({operations:c.z.number(),state:c.z.lazy(()=>at())})}function at(){return c.z.object({data:c.z.unknown().nullish(),name:c.z.string()})}function Rt(){return c.z.object({__typename:c.z.literal("Operation").optional(),hash:c.z.string(),index:c.z.number(),timestamp:c.z.string().datetime(),type:c.z.string()})}function ot(){return c.z.object({input:c.z.lazy(()=>q()),type:X,scope:z()})}function q(){return c.z.object({end:c.z.number().nullish(),start:c.z.number().nullish()})}const L=c.z.number;function st(){return c.z.object({input:L(),type:Y,scope:z()})}const U=c.z.string;function pt(){return c.z.object({input:U(),type:tt,scope:c.z.literal("global")})}function qt(){return c.z.object({__typename:c.z.literal("SetNameOperation").optional(),hash:c.z.string(),index:c.z.number(),input:c.z.string(),timestamp:c.z.string().datetime(),type:c.z.string()})}const $=c.z.number;function ct(){return c.z.object({input:$(),type:et,scope:z()})}const Lt=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:It,BaseActionSchema:it,DocumentFileSchema:Pt,LoadStateActionInputSchema:R,LoadStateActionSchema:nt,LoadStateActionStateInputSchema:at,Load_StateSchema:Q,OperationSchema:Rt,OperationScopeSchema:z,PruneActionInputSchema:q,PruneActionSchema:ot,PruneSchema:X,RedoActionInputSchema:L,RedoActionSchema:st,RedoSchema:Y,SetNameActionInputSchema:U,SetNameActionSchema:pt,SetNameOperationSchema:qt,Set_NameSchema:tt,UndoActionInputSchema:$,UndoActionSchema:ct,UndoSchema:et,definedNonNullAnySchema:Ft,isDefinedNonNullAny:G},Symbol.toStringTag,{value:"Module"}));function Ut(e,t){return{...e,name:t}}function $t(e,t,i){const n={skip:i,document:e},{scope:a}=t;return!a||t.skip===void 0?n:h.produce(n,s=>{const[o]=s.document.operations[a].slice(-1);t.skip&&t.skip>0&&(s.skip=t.skip),o.type==="NOOP"&&t.index===o.index&&s.skip>o.skip&&s.document.operations[a].pop()})}function Ct(e,t,i){const{scope:n,input:a}=t,s={document:e,action:t,skip:i};return h.produce(s,o=>{if(o.document.operations[n].length<1)throw new Error(`Cannot undo: no operations in history for scope "${n}"`);if(a<1)throw new Error("Invalid UNDO action: input value must be greater than 0");if(o.skip>0)throw new Error("Cannot undo: skip value from reducer cannot be used with UNDO action");const[p]=o.document.operations[n].slice(-1),l=p.type==="NOOP"&&p.skip>0;if(o.skip+=a,l&&(o.skip+=p.skip,o.document.operations[n].pop()),o.document.operations[n].length<o.skip)throw new Error("Cannot undo: you can't undo more operations than the ones in the scope history");const r=o.document.operations[n].length-1;let x=a,u=l?r-p.skip:r;for(;x>0&&u>=0;){const m=o.document.operations[n][u];m.type==="NOOP"&&m.skip>0?(u=u-(m.skip+1),o.skip+=m.skip+1):(o.document.clipboard.push({...m}),x--,u--)}o.action=Z(n)})}function Jt(e,t,i){const{scope:n,input:a}=t,s={document:e,action:t,skip:i};return h.produce(s,o=>{if(o.skip>0)throw new Error("Cannot redo: skip value from reducer cannot be used with REDO action");if(a>1)throw new Error("Cannot redo: you can only redo one operation at a time");if(a<1)throw new Error("Invalid REDO action: invalid redo input value");if(o.document.clipboard.length<1)throw new Error("Cannot redo: no operations in the clipboard");const p=o.document.clipboard.findLastIndex(r=>r.scope===n);if(p<0)throw new Error(`Cannot redo: no operations in clipboard for scope "${n}"`);const l=o.document.clipboard.splice(p,1)[0];o.action=h.castDraft({type:l.type,scope:l.scope,input:l.input})})}function Bt(e,t,i){const{scope:n}=t,a=e.operations[n];let{input:{start:s,end:o}}=t;s=s||0,o=o||a.length;const p=a.slice(s,o),l=a.slice(0,s),r=a.slice(o),x=N(e.initialState,{...e.operations,[n]:l.concat(p)},i),{name:u,state:m}=x,f=l.length,d=l.length?l[l.length-1].timestamp:r.length?r[0].timestamp:new Date().toISOString();return N(e.initialState,{...e.operations,[n]:[...l,{...W({name:u,state:m},p.length),timestamp:d,index:f,hash:J({state:m},"global")},...r.map((O,D)=>({...O,index:f+D+1}))]},i)}function Wt(e,t){return{...e,name:t.name,state:t.state??{global:{},local:{}}}}const rt="SET_NAME",y="UNDO",j="REDO",_="PRUNE",lt="LOAD_STATE",Zt="NOOP";function Ht(e,t){const i=e.revision[t.scope];return[y,j,_].includes(t.type)?i:i+1}function Kt(e,t){return{...e,revision:{...e.revision,[t.scope]:Ht(e,t)},lastModified:new Date().toISOString()}}function Vt(e,t,i=0){if([y,j,_].includes(t.type))return e;const{scope:n}=t,a=e.operations[n].slice(0,e.revision[n]);return a.push({...t,index:a.length,timestamp:new Date().toISOString(),hash:"",scope:n,skip:i}),{...e,operations:{...e.operations,[n]:a}}}function Gt(e,t,i=0){let n=Vt(e,t,i);return n=Kt(n,t),n}function Qt(e,t,i){switch(it().parse(t),t.type){case rt:return Ut(e,t.input);case _:return Bt(e,t,i);case lt:return Wt(e,t.input.state);default:return e}}function mt(e,t,i){switch(t.type){case y:return Ct(e,t,i);case j:return Jt(e,t,i);default:return{document:e,action:t,skip:i}}}function C(e,t,i,n,a={}){const{skip:s,ignoreSkipOperations:o=!1}=a;let p={...t},l=s||0,r=e,x=[...e.clipboard];if(ut(p)){const{document:u,skip:m}=$t(r,p,l);l=m,r=u}if(F(p)){const{skip:u,action:m,document:f}=mt(e,p,l);p=m,l=u,r=f,x=[...r.clipboard]}return I(p)&&(r=Qt(r,p,i)),l>0&&!o&&(r=N(r.initialState,r.operations,i,void 0,void 0,void 0,{[p.scope]:l})),r=Gt(r,p,l),r=h.produce(r,u=>{const m=i(u.state,p,n),f=F(t)?[...x]:[];if(m)return h.castDraft({...r,clipboard:[...f],state:m});u.clipboard=h.castDraft([...f])}),h.produce(r,u=>{if([y,j,_].includes(p.type))return u;const m=p.scope||"global";u.operations[m][u.operations[m].length-1].hash=J(u,m),!I(p)&&p.attachments&&p.attachments.forEach(f=>{const{hash:d,...O}=f;u.attachments[d]={...O}})})}function Xt(e,t,i){const n=Mt.join(e,t);return M.mkdirSync(e,{recursive:!0}),new Promise((a,s)=>{try{M.writeFile(n,i,{},o=>{o?s(o):a(n)})}catch(o){s(o)}})}function dt(e){return M.readFileSync(e)}function Yt(e){return new Promise((t,i)=>{At.get(e,n=>{const a=[],s=n.headers["content-type"];n.on("data",o=>{a.push(o)}),n.on("end",()=>{t({buffer:Buffer.concat(a),mimeType:s})})}).on("error",n=>{i(n)})})}const te=async e=>dt(e),T=(e,t="sha1")=>Tt.createHash(t).update(e).digest("base64");function ut(e){return e.type===Zt&&e.skip!==void 0&&e.skip>0&&e.hash!==void 0}function F(e){return[y,j].includes(e.type)}function I(e){return[rt,y,j,_,lt].includes(e.type)}function w(e,t,i,n,a="global"){if(!e)throw new Error("Empty action type");if(typeof e!="string")throw new Error(`Invalid action type: ${e}`);const s={type:e,input:t,scope:a};i&&(s.attachments=i);try{n==null||n().parse(s.input)}catch(o){throw new Error(`Invalid action input: ${o}`)}return s}function ft(e,t=C){return(i,n,a,s)=>t(i,n,e,a,s)}const xt=(e,t)=>({name:"",documentType:"",revision:{global:0,local:0},created:new Date().toISOString(),lastModified:new Date().toISOString(),attachments:{},...e,state:(t==null?void 0:t(e==null?void 0:e.state))??(e==null?void 0:e.state)??{global:{},local:{}}}),gt=(e,t)=>{const i=xt(e,t);return{...i,initialState:i,operations:{global:[],local:[]},clipboard:[]}},J=(e,t="global")=>T(A(e.state[t])),ee=(e,t=1e3)=>{const i=Math.random()*t;return T(`${(e??new Date).toISOString()}${i}`)};function k(e){return h.castImmutable(h.freeze(e,!0))}function ht(e,t){const i=[...e];let n=t||0,a=i.length>0?i[i.length-1].index:0;const s=[];for(const o of i.reverse()){if(n>0){const r=a-o.index;n-=r}if(n<0)throw new Error("Invalid operation index, missing operations");const p={ignore:n>0,operation:o},l=o.skip>0?o.skip+1:0;if(l>0&&l>n){const r=l-n;n=n+r}a=o.index,s.push(p)}return s.reverse()}function ie(e){return Object.values(e).flatMap(t=>t).sort((t,i)=>new Date(t.timestamp).getTime()-new Date(i.timestamp).getTime())}function bt(e){return Object.values(e).flatMap(t=>t).sort((t,i)=>new Date(t.operation.timestamp).getTime()-new Date(i.operation.timestamp).getTime())}function N(e,t,i,n,a,s=C,o={}){const p=ft(i,s);return B(e,t,p,n,a,o)}function B(e,t,i,n,a,s={}){const o=gt(e),p=Object.keys(t).reduce((m,f)=>{const d=f;return{...m,[d]:t[d].slice(0,a==null?void 0:a.revision[d])}},{}),l=Object.keys(p).reduce((m,f)=>{const d=f;return{...m,[d]:ht(p[d],s[d])}},{}),r=bt(l).reduce((m,{ignore:f,operation:d})=>f?i(m,Z(d.scope),n,{skip:d.skip,ignoreSkipOperations:!0}):i(m,d,n,{skip:d.skip,ignoreSkipOperations:!0}),o),x=Object.keys(r.operations).reduce((m,f)=>{const d=f,O=a&&a.revision[d]<t[d].length?t[d].slice(a.revision[d]):[];return{...m,[d]:[...r.operations[d].map((D,Dt)=>{var K;return{...D,timestamp:((K=t[d][Dt])==null?void 0:K.timestamp)??D.timestamp}}),...O]}},{global:[],local:[]}),u=Object.values(x).reduce((m,f)=>{for(const d of f)d.timestamp>m&&(m=d.timestamp);return m},e.lastModified);return{...r,operations:x,lastModified:u}}function ne(e,t){return A(e)===A(t)}const wt=e=>w("SET_NAME",e,void 0,U,void 0),vt=(e=1,t="global")=>w("UNDO",e,void 0,$,t),yt=(e=1,t="global")=>w("REDO",e,void 0,L,t),jt=(e,t,i="global")=>w("PRUNE",{start:e,end:t},void 0,q,i),W=(e,t)=>w("LOAD_STATE",{state:e,operations:t},void 0,R),Z=(e="global")=>w("NOOP",{},void 0,void 0,e),ae=Object.freeze(Object.defineProperty({__proto__:null,loadState:W,noop:Z,prune:jt,redo:yt,setName:wt,undo:vt},Symbol.toStringTag,{value:"Module"})),Ot={"application/andrew-inset":["ez"],"application/appinstaller":["appinstaller"],"application/applixware":["aw"],"application/appx":["appx"],"application/appxbundle":["appxbundle"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/automationml-aml+xml":["aml"],"application/automationml-amlx+zip":["amlx"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cpl+xml":["cpl"],"application/cu-seeme":["cu"],"application/cwl":["cwl"],"application/dash+xml":["mpd"],"application/dash-patch+xml":["mpp"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/express":["exp"],"application/fdf":["fdf"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["*js"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/media-policy-dataset+xml":["mpf"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["*mp4","*mpg4","mp4s","m4p"],"application/msix":["msix"],"application/msixbundle":["msixbundle"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-keys":["asc"],"application/pgp-signature":["sig","*asc"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/sql":["sql"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/trig":["trig"],"application/ttml+xml":["ttml"],"application/ubjson":["ubj"],"application/urc-ressheet+xml":["rsheet"],"application/urc-targetdesc+xml":["td"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/watcherinfo+xml":["wif"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xfdf":["xfdf"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["*xsl","xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/aac":["adts","aac"],"audio/adpcm":["adp"],"audio/amr":["amr"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx","opus"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/avci":["avci"],"image/avcs":["avcs"],"image/avif":["avif"],"image/bmp":["bmp","dib"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/dpx":["dpx"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm","jpgm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/ktx2":["ktx2"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/jt":["jt"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/prc":["prc"],"model/step+xml":["stpx"],"model/step+zip":["stpz"],"model/step-xml+zip":["stpxz"],"model/stl":["stl"],"model/u3d":["u3d"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/javascript":["js","mjs"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["md","markdown"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/spdx":["spdx"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/wgsl":["wgsl"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/iso.segment":["m4s"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","*jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]};Object.freeze(Ot);var g=function(e,t,i,n){if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?n:i==="a"?n.call(e):n?n.value:t.get(e)},v,S,b;class oe{constructor(...t){v.set(this,new Map),S.set(this,new Map),b.set(this,new Map);for(const i of t)this.define(i)}define(t,i=!1){for(let[n,a]of Object.entries(t)){n=n.toLowerCase(),a=a.map(p=>p.toLowerCase()),g(this,b,"f").has(n)||g(this,b,"f").set(n,new Set);const s=g(this,b,"f").get(n);let o=!0;for(let p of a){const l=p.startsWith("*");if(p=l?p.slice(1):p,s==null||s.add(p),o&&g(this,S,"f").set(n,p),o=!1,l)continue;const r=g(this,v,"f").get(p);if(r&&r!=n&&!i)throw new Error(`"${n} -> ${p}" conflicts with "${r} -> ${p}". Pass \`force=true\` to override this definition.`);g(this,v,"f").set(p,n)}}return this}getType(t){if(typeof t!="string")return null;const i=t.replace(/^.*[/\\]/,"").toLowerCase(),n=i.replace(/^.*\./,"").toLowerCase(),a=i.length<t.length;return!(n.length<i.length-1)&&a?null:g(this,v,"f").get(n)??null}getExtension(t){var i;return typeof t!="string"?null:(t=(i=t==null?void 0:t.split)==null?void 0:i.call(t,";")[0],(t&&g(this,S,"f").get(t.trim().toLowerCase()))??null)}getAllExtensions(t){return typeof t!="string"?null:g(this,b,"f").get(t.toLowerCase())??null}_freeze(){this.define=()=>{throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances")},Object.freeze(this);for(const t of g(this,b,"f").values())Object.freeze(t);return this}_getTestState(){return{types:g(this,v,"f"),extensions:g(this,S,"f")}}}v=new WeakMap,S=new WeakMap,b=new WeakMap;const se=new oe(Ot)._freeze();function kt(e){const t=[],i=Object.keys(e);for(const n of i){const a=e[n].sort((s,o)=>s.index-o.index);for(let s=0;s<a.length;s++)a[s].index!==s&&t.push({message:`Invalid operation index ${a[s].index} at position ${s}`,details:{position:s,operation:a[s],scope:a[s].scope}})}return t}const H=async e=>{const t=new V,{name:i,revision:n,documentType:a,created:s,lastModified:o}=e,p={name:i,revision:n,documentType:a,created:s,lastModified:o};return t.file("header.json",JSON.stringify(p,null,2)),t.file("state.json",JSON.stringify(e.initialState||{},null,2)),t.file("operations.json",JSON.stringify(e.operations,null,2)),Object.keys(e.attachments).forEach(r=>{const{data:x,...u}=e.attachments[r];t.file(r,x,{base64:!0,createFolders:!0,comment:JSON.stringify(u)})}),t},St=async(e,t,i,n)=>{const s=await(await H(e)).generateAsync({type:"uint8array",streamFiles:!0}),o=n??e.name,p=`.${i}.zip`;return Xt(t,o.endsWith(p)?o:`${o}${p}`,s)},pe=async(e,t)=>{const n=await(await H(e)).generateAsync({type:"blob"}),a=await t.createWritable();await a.write(n),await a.close()},P=async(e,t)=>{const i=dt(e);return zt(i,t)},zt=async(e,t)=>{const i=new V;return await i.loadAsync(e),ce(i,t)};async function ce(e,t){const i=e.file("state.json");if(!i)throw new Error("Initial state not found");const n=await i.async("string"),a=JSON.parse(n),s=e.file("header.json");let o;s&&(o=JSON.parse(await s.async("string")));const p=e.file("operations.json");if(!p)throw new Error("Operations history not found");const l=JSON.parse(await p.async("string")),r=kt(l);if(r.length){const u=r.map(m=>m.message);throw new Error(u.join(`
2
+ `))}let x=B(a,l,t,void 0,o);return o&&(x={...x,...o}),x}function _t(e){const t=e.replace(/^.*\./,"")||void 0,i=e.replace(/^.*[/\\]/,"")||void 0;return{extension:t,fileName:i}}async function re(e){const{buffer:t,mimeType:i="application/octet-stream"}=await Yt(e),n=_t(e),a=t.toString("base64");return{data:a,hash:T(a),mimeType:i,...n}}async function le(e){const t=await te(e),i=se.getType(e)||"application/octet-stream",n=_t(e),a=t.toString("base64");return{data:a,hash:T(a),mimeType:i,...n}}class me{constructor(t,i,n){E(this,"_document");E(this,"_reducer");E(this,"_signalDispatch");this._reducer=t,this._document=i,this._signalDispatch=n}dispatch(t,i){return this._document=this._reducer(this._document,t,this._signalDispatch,i),this}saveToFile(t,i,n){return St(this._document,t,i,n)}async loadFromFile(t){this._document=await P(t,this._reducer)}static async stateFromFile(t,i){return await P(t,i)}get state(){return k(this._document.state)}get operations(){return k(this._document.operations)}get name(){return this._document.name}get documentType(){return this._document.documentType}get created(){return this._document.created}get lastModified(){return this._document.lastModified}get revision(){return this._document.revision.global}getRevision(t){return this._document.revision[t]}get initialState(){return k(this._document.initialState)}toDocument(){return k(this._document)}getAttachment(t){return this._document.attachments[t]}setName(t){return this.dispatch(wt(t)),this}undo(t){return this.dispatch(vt(t)),this}redo(t){return this.dispatch(yt(t)),this}prune(t,i){return this.dispatch(jt(t,i)),this}loadState(t,i){return this.dispatch(W(t,i)),this}}function de(e,t){t.forEach(i=>{Object.getOwnPropertyNames(i.prototype).forEach(n=>{Object.defineProperty(e.prototype,n,Object.getOwnPropertyDescriptor(i.prototype,n)||Object.create(null))})})}exports.BaseActions=ae;exports.BaseDocument=me;exports.applyMixins=de;exports.baseReducer=C;exports.createAction=w;exports.createDocument=gt;exports.createExtendedState=xt;exports.createReducer=ft;exports.createZip=H;exports.getLocalFile=le;exports.getRemoteFile=re;exports.hashDocument=J;exports.hashKey=ee;exports.isBaseAction=I;exports.isNoopOperation=ut;exports.isSameDocument=ne;exports.isUndoRedo=F;exports.loadFromFile=P;exports.loadFromInput=zt;exports.mapSkippedOperations=ht;exports.processUndoRedo=mt;exports.readOnly=k;exports.replayDocument=B;exports.replayOperations=N;exports.saveToFile=St;exports.saveToFileHandle=pe;exports.sortMappedOperations=bt;exports.sortOperations=ie;exports.validateOperations=kt;exports.zod=Lt;
@@ -177,10 +177,10 @@ function Pt(e, t, i) {
177
177
  "Cannot undo: you can't undo more operations than the ones in the scope history"
178
178
  );
179
179
  const r = o.document.operations[a].length - 1;
180
- let x = n, d = l ? r - p.skip : r;
181
- for (; x > 0 && d >= 0; ) {
182
- const m = o.document.operations[a][d];
183
- m.type === "NOOP" && m.skip > 0 ? (d = d - (m.skip + 1), o.skip += m.skip + 1) : (o.document.clipboard.push({ ...m }), x--, d--);
180
+ let x = n, u = l ? r - p.skip : r;
181
+ for (; x > 0 && u >= 0; ) {
182
+ const m = o.document.operations[a][u];
183
+ m.type === "NOOP" && m.skip > 0 ? (u = u - (m.skip + 1), o.skip += m.skip + 1) : (o.document.clipboard.push({ ...m }), x--, u--);
184
184
  }
185
185
  o.action = $(a);
186
186
  });
@@ -232,7 +232,7 @@ function Ft(e, t, i) {
232
232
  [a]: l.concat(p)
233
233
  },
234
234
  i
235
- ), { name: d, state: m } = x, f = l.length, u = l.length ? l[l.length - 1].timestamp : r.length ? r[0].timestamp : (/* @__PURE__ */ new Date()).toISOString();
235
+ ), { name: u, state: m } = x, f = l.length, d = l.length ? l[l.length - 1].timestamp : r.length ? r[0].timestamp : (/* @__PURE__ */ new Date()).toISOString();
236
236
  return P(
237
237
  e.initialState,
238
238
  {
@@ -241,10 +241,10 @@ function Ft(e, t, i) {
241
241
  ...l,
242
242
  {
243
243
  ...U(
244
- { name: d, state: m },
244
+ { name: u, state: m },
245
245
  p.length
246
246
  ),
247
- timestamp: u,
247
+ timestamp: d,
248
248
  index: f,
249
249
  hash: lt({ state: m }, "global")
250
250
  },
@@ -328,16 +328,16 @@ function ct(e, t, i, a, n = {}) {
328
328
  const { skip: s, ignoreSkipOperations: o = !1 } = n;
329
329
  let p = { ...t }, l = s || 0, r = e, x = [...e.clipboard];
330
330
  if (Kt(p)) {
331
- const { document: d, skip: m } = Mt(r, p, l);
332
- l = m, r = d;
331
+ const { document: u, skip: m } = Mt(r, p, l);
332
+ l = m, r = u;
333
333
  }
334
334
  if (J(p)) {
335
335
  const {
336
- skip: d,
336
+ skip: u,
337
337
  action: m,
338
338
  document: f
339
339
  } = Wt(e, p, l);
340
- p = m, l = d, r = f, x = [...r.clipboard];
340
+ p = m, l = u, r = f, x = [...r.clipboard];
341
341
  }
342
342
  return W(p) && (r = Jt(r, p, i)), l > 0 && !o && (r = P(
343
343
  r.initialState,
@@ -347,9 +347,9 @@ function ct(e, t, i, a, n = {}) {
347
347
  void 0,
348
348
  void 0,
349
349
  { [p.scope]: l }
350
- )), r = Ct(r, p, l), r = k(r, (d) => {
350
+ )), r = Ct(r, p, l), r = k(r, (u) => {
351
351
  const m = i(
352
- d.state,
352
+ u.state,
353
353
  p,
354
354
  a
355
355
  ), f = J(t) ? [...x] : [];
@@ -359,14 +359,14 @@ function ct(e, t, i, a, n = {}) {
359
359
  clipboard: [...f],
360
360
  state: m
361
361
  });
362
- d.clipboard = A([...f]);
363
- }), k(r, (d) => {
362
+ u.clipboard = A([...f]);
363
+ }), k(r, (u) => {
364
364
  if ([w, v, _].includes(p.type))
365
- return d;
365
+ return u;
366
366
  const m = p.scope || "global";
367
- d.operations[m][d.operations[m].length - 1].hash = lt(d, m), !W(p) && p.attachments && p.attachments.forEach((f) => {
368
- const { hash: u, ...j } = f;
369
- d.attachments[u] = {
367
+ u.operations[m][u.operations[m].length - 1].hash = lt(u, m), !W(p) && p.attachments && p.attachments.forEach((f) => {
368
+ const { hash: d, ...j } = f;
369
+ u.attachments[d] = {
370
370
  ...j
371
371
  };
372
372
  });
@@ -504,29 +504,29 @@ function P(e, t, i, a, n, s = ct, o = {}) {
504
504
  }
505
505
  function mt(e, t, i, a, n, s = {}) {
506
506
  const o = Qt(e), p = Object.keys(t).reduce((m, f) => {
507
- const u = f;
507
+ const d = f;
508
508
  return {
509
509
  ...m,
510
- [u]: t[u].slice(0, n == null ? void 0 : n.revision[u])
510
+ [d]: t[d].slice(0, n == null ? void 0 : n.revision[d])
511
511
  };
512
512
  }, {}), l = Object.keys(p).reduce(
513
513
  (m, f) => {
514
- const u = f;
514
+ const d = f;
515
515
  return {
516
516
  ...m,
517
- [u]: Xt(
518
- p[u],
519
- s[u]
517
+ [d]: Xt(
518
+ p[d],
519
+ s[d]
520
520
  )
521
521
  };
522
522
  },
523
523
  {}
524
524
  ), r = Yt(l).reduce(
525
- (m, { ignore: f, operation: u }) => f ? i(m, $(u.scope), a, {
526
- skip: u.skip,
525
+ (m, { ignore: f, operation: d }) => f ? i(m, $(d.scope), a, {
526
+ skip: d.skip,
527
527
  ignoreSkipOperations: !0
528
- }) : i(m, u, a, {
529
- skip: u.skip,
528
+ }) : i(m, d, a, {
529
+ skip: d.skip,
530
530
  ignoreSkipOperations: !0
531
531
  }),
532
532
  o
@@ -534,15 +534,15 @@ function mt(e, t, i, a, n, s = {}) {
534
534
  r.operations
535
535
  ).reduce(
536
536
  (m, f) => {
537
- const u = f, j = n && n.revision[u] < t[u].length ? t[u].slice(n.revision[u]) : [];
537
+ const d = f, j = n && n.revision[d] < t[d].length ? t[d].slice(n.revision[d]) : [];
538
538
  return {
539
539
  ...m,
540
- [u]: [
541
- ...r.operations[u].map((E, wt) => {
540
+ [d]: [
541
+ ...r.operations[d].map((E, wt) => {
542
542
  var C;
543
543
  return {
544
544
  ...E,
545
- timestamp: ((C = t[u][wt]) == null ? void 0 : C.timestamp) ?? E.timestamp
545
+ timestamp: ((C = t[d][wt]) == null ? void 0 : C.timestamp) ?? E.timestamp
546
546
  };
547
547
  }),
548
548
  ...j
@@ -550,23 +550,23 @@ function mt(e, t, i, a, n, s = {}) {
550
550
  };
551
551
  },
552
552
  { global: [], local: [] }
553
- ), d = Object.values(x).reduce((m, f) => {
554
- for (const u of f)
555
- u.timestamp > m && (m = u.timestamp);
553
+ ), u = Object.values(x).reduce((m, f) => {
554
+ for (const d of f)
555
+ d.timestamp > m && (m = d.timestamp);
556
556
  return m;
557
- }, "0");
558
- return { ...r, operations: x, lastModified: d };
557
+ }, e.lastModified);
558
+ return { ...r, operations: x, lastModified: u };
559
559
  }
560
560
  function be(e, t) {
561
561
  return z(e) === z(t);
562
562
  }
563
- const ut = (e) => y(
563
+ const dt = (e) => y(
564
564
  "SET_NAME",
565
565
  e,
566
566
  void 0,
567
567
  q,
568
568
  void 0
569
- ), dt = (e = 1, t = "global") => y(
569
+ ), ut = (e = 1, t = "global") => y(
570
570
  "UNDO",
571
571
  e,
572
572
  void 0,
@@ -595,8 +595,8 @@ const ut = (e) => y(
595
595
  noop: $,
596
596
  prune: xt,
597
597
  redo: ft,
598
- setName: ut,
599
- undo: dt
598
+ setName: dt,
599
+ undo: ut
600
600
  }, Symbol.toStringTag, { value: "Module" })), gt = { "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"] };
601
601
  Object.freeze(gt);
602
602
  var g = function(e, t, i, a) {
@@ -687,11 +687,11 @@ const ht = async (e) => {
687
687
  "state.json",
688
688
  JSON.stringify(e.initialState || {}, null, 2)
689
689
  ), t.file("operations.json", JSON.stringify(e.operations, null, 2)), Object.keys(e.attachments).forEach((r) => {
690
- const { data: x, ...d } = e.attachments[r];
690
+ const { data: x, ...u } = e.attachments[r];
691
691
  t.file(r, x, {
692
692
  base64: !0,
693
693
  createFolders: !0,
694
- comment: JSON.stringify(d)
694
+ comment: JSON.stringify(u)
695
695
  });
696
696
  }), t;
697
697
  }, ae = async (e, t, i, a) => {
@@ -728,8 +728,8 @@ async function oe(e, t) {
728
728
  await p.async("string")
729
729
  ), r = ie(l);
730
730
  if (r.length) {
731
- const d = r.map((m) => m.message);
732
- throw new Error(d.join(`
731
+ const u = r.map((m) => m.message);
732
+ throw new Error(u.join(`
733
733
  `));
734
734
  }
735
735
  let x = mt(
@@ -880,14 +880,14 @@ class Oe {
880
880
  * @param name - The new name of the document.
881
881
  */
882
882
  setName(t) {
883
- return this.dispatch(ut(t)), this;
883
+ return this.dispatch(dt(t)), this;
884
884
  }
885
885
  /**
886
886
  * Reverts a number of actions from the document.
887
887
  * @param count - The number of actions to revert.
888
888
  */
889
889
  undo(t) {
890
- return this.dispatch(dt(t)), this;
890
+ return this.dispatch(ut(t)), this;
891
891
  }
892
892
  /**
893
893
  * Reapplies a number of actions to the document.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "document-model",
3
- "version": "1.0.33",
3
+ "version": "1.0.34",
4
4
  "license": "AGPL-3.0-only",
5
5
  "private": false,
6
6
  "files": [
@@ -1,2 +0,0 @@
1
- "use strict";var Et=Object.defineProperty;var Nt=(e,t,i)=>t in e?Et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var E=(e,t,i)=>(Nt(e,typeof t!="symbol"?t+"":t,i),i);const h=require("immer"),A=require("json-stringify-deterministic"),c=require("zod"),Tt=require("crypto"),F=require("fs"),At=require("https"),Ft=require("path"),V=require("jszip"),G=e=>e!=null,Mt=c.z.any().refine(e=>G(e)),Q=c.z.enum(["LOAD_STATE"]),X=c.z.enum(["PRUNE"]),Y=c.z.enum(["REDO"]),tt=c.z.enum(["SET_NAME"]),et=c.z.enum(["UNDO"]);function It(){return c.z.object({__typename:c.z.literal("Action").optional(),type:c.z.string()})}function z(){return c.z.literal("global").or(c.z.literal("local"))}function it(){return c.z.union([nt(),ot(),st(),pt(),ct()])}function Pt(){return c.z.object({__typename:c.z.literal("DocumentFile").optional(),data:c.z.string(),extension:c.z.string().nullable(),fileName:c.z.string().nullable(),mimeType:c.z.string()})}function nt(){return c.z.object({input:c.z.lazy(()=>R()),type:Q,scope:z()})}function R(){return c.z.object({operations:c.z.number(),state:c.z.lazy(()=>at())})}function at(){return c.z.object({data:c.z.unknown().nullish(),name:c.z.string()})}function Rt(){return c.z.object({__typename:c.z.literal("Operation").optional(),hash:c.z.string(),index:c.z.number(),timestamp:c.z.string().datetime(),type:c.z.string()})}function ot(){return c.z.object({input:c.z.lazy(()=>q()),type:X,scope:z()})}function q(){return c.z.object({end:c.z.number().nullish(),start:c.z.number().nullish()})}const L=c.z.number;function st(){return c.z.object({input:L(),type:Y,scope:z()})}const U=c.z.string;function pt(){return c.z.object({input:U(),type:tt,scope:c.z.literal("global")})}function qt(){return c.z.object({__typename:c.z.literal("SetNameOperation").optional(),hash:c.z.string(),index:c.z.number(),input:c.z.string(),timestamp:c.z.string().datetime(),type:c.z.string()})}const $=c.z.number;function ct(){return c.z.object({input:$(),type:et,scope:z()})}const Lt=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:It,BaseActionSchema:it,DocumentFileSchema:Pt,LoadStateActionInputSchema:R,LoadStateActionSchema:nt,LoadStateActionStateInputSchema:at,Load_StateSchema:Q,OperationSchema:Rt,OperationScopeSchema:z,PruneActionInputSchema:q,PruneActionSchema:ot,PruneSchema:X,RedoActionInputSchema:L,RedoActionSchema:st,RedoSchema:Y,SetNameActionInputSchema:U,SetNameActionSchema:pt,SetNameOperationSchema:qt,Set_NameSchema:tt,UndoActionInputSchema:$,UndoActionSchema:ct,UndoSchema:et,definedNonNullAnySchema:Mt,isDefinedNonNullAny:G},Symbol.toStringTag,{value:"Module"}));function Ut(e,t){return{...e,name:t}}function $t(e,t,i){const n={skip:i,document:e},{scope:a}=t;return!a||t.skip===void 0?n:h.produce(n,s=>{const[o]=s.document.operations[a].slice(-1);t.skip&&t.skip>0&&(s.skip=t.skip),o.type==="NOOP"&&t.index===o.index&&s.skip>o.skip&&s.document.operations[a].pop()})}function Ct(e,t,i){const{scope:n,input:a}=t,s={document:e,action:t,skip:i};return h.produce(s,o=>{if(o.document.operations[n].length<1)throw new Error(`Cannot undo: no operations in history for scope "${n}"`);if(a<1)throw new Error("Invalid UNDO action: input value must be greater than 0");if(o.skip>0)throw new Error("Cannot undo: skip value from reducer cannot be used with UNDO action");const[p]=o.document.operations[n].slice(-1),l=p.type==="NOOP"&&p.skip>0;if(o.skip+=a,l&&(o.skip+=p.skip,o.document.operations[n].pop()),o.document.operations[n].length<o.skip)throw new Error("Cannot undo: you can't undo more operations than the ones in the scope history");const r=o.document.operations[n].length-1;let x=a,u=l?r-p.skip:r;for(;x>0&&u>=0;){const m=o.document.operations[n][u];m.type==="NOOP"&&m.skip>0?(u=u-(m.skip+1),o.skip+=m.skip+1):(o.document.clipboard.push({...m}),x--,u--)}o.action=Z(n)})}function Jt(e,t,i){const{scope:n,input:a}=t,s={document:e,action:t,skip:i};return h.produce(s,o=>{if(o.skip>0)throw new Error("Cannot redo: skip value from reducer cannot be used with REDO action");if(a>1)throw new Error("Cannot redo: you can only redo one operation at a time");if(a<1)throw new Error("Invalid REDO action: invalid redo input value");if(o.document.clipboard.length<1)throw new Error("Cannot redo: no operations in the clipboard");const p=o.document.clipboard.findLastIndex(r=>r.scope===n);if(p<0)throw new Error(`Cannot redo: no operations in clipboard for scope "${n}"`);const l=o.document.clipboard.splice(p,1)[0];o.action=h.castDraft({type:l.type,scope:l.scope,input:l.input})})}function Bt(e,t,i){const{scope:n}=t,a=e.operations[n];let{input:{start:s,end:o}}=t;s=s||0,o=o||a.length;const p=a.slice(s,o),l=a.slice(0,s),r=a.slice(o),x=N(e.initialState,{...e.operations,[n]:l.concat(p)},i),{name:u,state:m}=x,f=l.length,d=l.length?l[l.length-1].timestamp:r.length?r[0].timestamp:new Date().toISOString();return N(e.initialState,{...e.operations,[n]:[...l,{...W({name:u,state:m},p.length),timestamp:d,index:f,hash:J({state:m},"global")},...r.map((O,D)=>({...O,index:f+D+1}))]},i)}function Wt(e,t){return{...e,name:t.name,state:t.state??{global:{},local:{}}}}const rt="SET_NAME",y="UNDO",j="REDO",_="PRUNE",lt="LOAD_STATE",Zt="NOOP";function Ht(e,t){const i=e.revision[t.scope];return[y,j,_].includes(t.type)?i:i+1}function Kt(e,t){return{...e,revision:{...e.revision,[t.scope]:Ht(e,t)},lastModified:new Date().toISOString()}}function Vt(e,t,i=0){if([y,j,_].includes(t.type))return e;const{scope:n}=t,a=e.operations[n].slice(0,e.revision[n]);return a.push({...t,index:a.length,timestamp:new Date().toISOString(),hash:"",scope:n,skip:i}),{...e,operations:{...e.operations,[n]:a}}}function Gt(e,t,i=0){let n=Vt(e,t,i);return n=Kt(n,t),n}function Qt(e,t,i){switch(it().parse(t),t.type){case rt:return Ut(e,t.input);case _:return Bt(e,t,i);case lt:return Wt(e,t.input.state);default:return e}}function mt(e,t,i){switch(t.type){case y:return Ct(e,t,i);case j:return Jt(e,t,i);default:return{document:e,action:t,skip:i}}}function C(e,t,i,n,a={}){const{skip:s,ignoreSkipOperations:o=!1}=a;let p={...t},l=s||0,r=e,x=[...e.clipboard];if(ut(p)){const{document:u,skip:m}=$t(r,p,l);l=m,r=u}if(M(p)){const{skip:u,action:m,document:f}=mt(e,p,l);p=m,l=u,r=f,x=[...r.clipboard]}return I(p)&&(r=Qt(r,p,i)),l>0&&!o&&(r=N(r.initialState,r.operations,i,void 0,void 0,void 0,{[p.scope]:l})),r=Gt(r,p,l),r=h.produce(r,u=>{const m=i(u.state,p,n),f=M(t)?[...x]:[];if(m)return h.castDraft({...r,clipboard:[...f],state:m});u.clipboard=h.castDraft([...f])}),h.produce(r,u=>{if([y,j,_].includes(p.type))return u;const m=p.scope||"global";u.operations[m][u.operations[m].length-1].hash=J(u,m),!I(p)&&p.attachments&&p.attachments.forEach(f=>{const{hash:d,...O}=f;u.attachments[d]={...O}})})}function Xt(e,t,i){const n=Ft.join(e,t);return F.mkdirSync(e,{recursive:!0}),new Promise((a,s)=>{try{F.writeFile(n,i,{},o=>{o?s(o):a(n)})}catch(o){s(o)}})}function dt(e){return F.readFileSync(e)}function Yt(e){return new Promise((t,i)=>{At.get(e,n=>{const a=[],s=n.headers["content-type"];n.on("data",o=>{a.push(o)}),n.on("end",()=>{t({buffer:Buffer.concat(a),mimeType:s})})}).on("error",n=>{i(n)})})}const te=async e=>dt(e),T=(e,t="sha1")=>Tt.createHash(t).update(e).digest("base64");function ut(e){return e.type===Zt&&e.skip!==void 0&&e.skip>0&&e.hash!==void 0}function M(e){return[y,j].includes(e.type)}function I(e){return[rt,y,j,_,lt].includes(e.type)}function w(e,t,i,n,a="global"){if(!e)throw new Error("Empty action type");if(typeof e!="string")throw new Error(`Invalid action type: ${e}`);const s={type:e,input:t,scope:a};i&&(s.attachments=i);try{n==null||n().parse(s.input)}catch(o){throw new Error(`Invalid action input: ${o}`)}return s}function ft(e,t=C){return(i,n,a,s)=>t(i,n,e,a,s)}const xt=(e,t)=>({name:"",documentType:"",revision:{global:0,local:0},created:new Date().toISOString(),lastModified:new Date().toISOString(),attachments:{},...e,state:(t==null?void 0:t(e==null?void 0:e.state))??(e==null?void 0:e.state)??{global:{},local:{}}}),gt=(e,t)=>{const i=xt(e,t);return{...i,initialState:i,operations:{global:[],local:[]},clipboard:[]}},J=(e,t="global")=>T(A(e.state[t])),ee=(e,t=1e3)=>{const i=Math.random()*t;return T(`${(e??new Date).toISOString()}${i}`)};function k(e){return h.castImmutable(h.freeze(e,!0))}function ht(e,t){const i=[...e];let n=t||0,a=i.length>0?i[i.length-1].index:0;const s=[];for(const o of i.reverse()){if(n>0){const r=a-o.index;n-=r}if(n<0)throw new Error("Invalid operation index, missing operations");const p={ignore:n>0,operation:o},l=o.skip>0?o.skip+1:0;if(l>0&&l>n){const r=l-n;n=n+r}a=o.index,s.push(p)}return s.reverse()}function ie(e){return Object.values(e).flatMap(t=>t).sort((t,i)=>new Date(t.timestamp).getTime()-new Date(i.timestamp).getTime())}function bt(e){return Object.values(e).flatMap(t=>t).sort((t,i)=>new Date(t.operation.timestamp).getTime()-new Date(i.operation.timestamp).getTime())}function N(e,t,i,n,a,s=C,o={}){const p=ft(i,s);return B(e,t,p,n,a,o)}function B(e,t,i,n,a,s={}){const o=gt(e),p=Object.keys(t).reduce((m,f)=>{const d=f;return{...m,[d]:t[d].slice(0,a==null?void 0:a.revision[d])}},{}),l=Object.keys(p).reduce((m,f)=>{const d=f;return{...m,[d]:ht(p[d],s[d])}},{}),r=bt(l).reduce((m,{ignore:f,operation:d})=>f?i(m,Z(d.scope),n,{skip:d.skip,ignoreSkipOperations:!0}):i(m,d,n,{skip:d.skip,ignoreSkipOperations:!0}),o),x=Object.keys(r.operations).reduce((m,f)=>{const d=f,O=a&&a.revision[d]<t[d].length?t[d].slice(a.revision[d]):[];return{...m,[d]:[...r.operations[d].map((D,Dt)=>{var K;return{...D,timestamp:((K=t[d][Dt])==null?void 0:K.timestamp)??D.timestamp}}),...O]}},{global:[],local:[]}),u=Object.values(x).reduce((m,f)=>{for(const d of f)d.timestamp>m&&(m=d.timestamp);return m},"0");return{...r,operations:x,lastModified:u}}function ne(e,t){return A(e)===A(t)}const wt=e=>w("SET_NAME",e,void 0,U,void 0),vt=(e=1,t="global")=>w("UNDO",e,void 0,$,t),yt=(e=1,t="global")=>w("REDO",e,void 0,L,t),jt=(e,t,i="global")=>w("PRUNE",{start:e,end:t},void 0,q,i),W=(e,t)=>w("LOAD_STATE",{state:e,operations:t},void 0,R),Z=(e="global")=>w("NOOP",{},void 0,void 0,e),ae=Object.freeze(Object.defineProperty({__proto__:null,loadState:W,noop:Z,prune:jt,redo:yt,setName:wt,undo:vt},Symbol.toStringTag,{value:"Module"})),Ot={"application/andrew-inset":["ez"],"application/appinstaller":["appinstaller"],"application/applixware":["aw"],"application/appx":["appx"],"application/appxbundle":["appxbundle"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/automationml-aml+xml":["aml"],"application/automationml-amlx+zip":["amlx"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cpl+xml":["cpl"],"application/cu-seeme":["cu"],"application/cwl":["cwl"],"application/dash+xml":["mpd"],"application/dash-patch+xml":["mpp"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/express":["exp"],"application/fdf":["fdf"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["*js"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/media-policy-dataset+xml":["mpf"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["*mp4","*mpg4","mp4s","m4p"],"application/msix":["msix"],"application/msixbundle":["msixbundle"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-keys":["asc"],"application/pgp-signature":["sig","*asc"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/sql":["sql"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/trig":["trig"],"application/ttml+xml":["ttml"],"application/ubjson":["ubj"],"application/urc-ressheet+xml":["rsheet"],"application/urc-targetdesc+xml":["td"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/watcherinfo+xml":["wif"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xfdf":["xfdf"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["*xsl","xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/aac":["adts","aac"],"audio/adpcm":["adp"],"audio/amr":["amr"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx","opus"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/avci":["avci"],"image/avcs":["avcs"],"image/avif":["avif"],"image/bmp":["bmp","dib"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/dpx":["dpx"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm","jpgm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/ktx2":["ktx2"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/jt":["jt"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/prc":["prc"],"model/step+xml":["stpx"],"model/step+zip":["stpz"],"model/step-xml+zip":["stpxz"],"model/stl":["stl"],"model/u3d":["u3d"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/javascript":["js","mjs"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["md","markdown"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/spdx":["spdx"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/wgsl":["wgsl"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/iso.segment":["m4s"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","*jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]};Object.freeze(Ot);var g=function(e,t,i,n){if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?n:i==="a"?n.call(e):n?n.value:t.get(e)},v,S,b;class oe{constructor(...t){v.set(this,new Map),S.set(this,new Map),b.set(this,new Map);for(const i of t)this.define(i)}define(t,i=!1){for(let[n,a]of Object.entries(t)){n=n.toLowerCase(),a=a.map(p=>p.toLowerCase()),g(this,b,"f").has(n)||g(this,b,"f").set(n,new Set);const s=g(this,b,"f").get(n);let o=!0;for(let p of a){const l=p.startsWith("*");if(p=l?p.slice(1):p,s==null||s.add(p),o&&g(this,S,"f").set(n,p),o=!1,l)continue;const r=g(this,v,"f").get(p);if(r&&r!=n&&!i)throw new Error(`"${n} -> ${p}" conflicts with "${r} -> ${p}". Pass \`force=true\` to override this definition.`);g(this,v,"f").set(p,n)}}return this}getType(t){if(typeof t!="string")return null;const i=t.replace(/^.*[/\\]/,"").toLowerCase(),n=i.replace(/^.*\./,"").toLowerCase(),a=i.length<t.length;return!(n.length<i.length-1)&&a?null:g(this,v,"f").get(n)??null}getExtension(t){var i;return typeof t!="string"?null:(t=(i=t==null?void 0:t.split)==null?void 0:i.call(t,";")[0],(t&&g(this,S,"f").get(t.trim().toLowerCase()))??null)}getAllExtensions(t){return typeof t!="string"?null:g(this,b,"f").get(t.toLowerCase())??null}_freeze(){this.define=()=>{throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances")},Object.freeze(this);for(const t of g(this,b,"f").values())Object.freeze(t);return this}_getTestState(){return{types:g(this,v,"f"),extensions:g(this,S,"f")}}}v=new WeakMap,S=new WeakMap,b=new WeakMap;const se=new oe(Ot)._freeze();function kt(e){const t=[],i=Object.keys(e);for(const n of i){const a=e[n].sort((s,o)=>s.index-o.index);for(let s=0;s<a.length;s++)a[s].index!==s&&t.push({message:`Invalid operation index ${a[s].index} at position ${s}`,details:{position:s,operation:a[s],scope:a[s].scope}})}return t}const H=async e=>{const t=new V,{name:i,revision:n,documentType:a,created:s,lastModified:o}=e,p={name:i,revision:n,documentType:a,created:s,lastModified:o};return t.file("header.json",JSON.stringify(p,null,2)),t.file("state.json",JSON.stringify(e.initialState||{},null,2)),t.file("operations.json",JSON.stringify(e.operations,null,2)),Object.keys(e.attachments).forEach(r=>{const{data:x,...u}=e.attachments[r];t.file(r,x,{base64:!0,createFolders:!0,comment:JSON.stringify(u)})}),t},St=async(e,t,i,n)=>{const s=await(await H(e)).generateAsync({type:"uint8array",streamFiles:!0}),o=n??e.name,p=`.${i}.zip`;return Xt(t,o.endsWith(p)?o:`${o}${p}`,s)},pe=async(e,t)=>{const n=await(await H(e)).generateAsync({type:"blob"}),a=await t.createWritable();await a.write(n),await a.close()},P=async(e,t)=>{const i=dt(e);return zt(i,t)},zt=async(e,t)=>{const i=new V;return await i.loadAsync(e),ce(i,t)};async function ce(e,t){const i=e.file("state.json");if(!i)throw new Error("Initial state not found");const n=await i.async("string"),a=JSON.parse(n),s=e.file("header.json");let o;s&&(o=JSON.parse(await s.async("string")));const p=e.file("operations.json");if(!p)throw new Error("Operations history not found");const l=JSON.parse(await p.async("string")),r=kt(l);if(r.length){const u=r.map(m=>m.message);throw new Error(u.join(`
2
- `))}let x=B(a,l,t,void 0,o);return o&&(x={...x,...o}),x}function _t(e){const t=e.replace(/^.*\./,"")||void 0,i=e.replace(/^.*[/\\]/,"")||void 0;return{extension:t,fileName:i}}async function re(e){const{buffer:t,mimeType:i="application/octet-stream"}=await Yt(e),n=_t(e),a=t.toString("base64");return{data:a,hash:T(a),mimeType:i,...n}}async function le(e){const t=await te(e),i=se.getType(e)||"application/octet-stream",n=_t(e),a=t.toString("base64");return{data:a,hash:T(a),mimeType:i,...n}}class me{constructor(t,i,n){E(this,"_document");E(this,"_reducer");E(this,"_signalDispatch");this._reducer=t,this._document=i,this._signalDispatch=n}dispatch(t,i){return this._document=this._reducer(this._document,t,this._signalDispatch,i),this}saveToFile(t,i,n){return St(this._document,t,i,n)}async loadFromFile(t){this._document=await P(t,this._reducer)}static async stateFromFile(t,i){return await P(t,i)}get state(){return k(this._document.state)}get operations(){return k(this._document.operations)}get name(){return this._document.name}get documentType(){return this._document.documentType}get created(){return this._document.created}get lastModified(){return this._document.lastModified}get revision(){return this._document.revision.global}getRevision(t){return this._document.revision[t]}get initialState(){return k(this._document.initialState)}toDocument(){return k(this._document)}getAttachment(t){return this._document.attachments[t]}setName(t){return this.dispatch(wt(t)),this}undo(t){return this.dispatch(vt(t)),this}redo(t){return this.dispatch(yt(t)),this}prune(t,i){return this.dispatch(jt(t,i)),this}loadState(t,i){return this.dispatch(W(t,i)),this}}function de(e,t){t.forEach(i=>{Object.getOwnPropertyNames(i.prototype).forEach(n=>{Object.defineProperty(e.prototype,n,Object.getOwnPropertyDescriptor(i.prototype,n)||Object.create(null))})})}exports.BaseActions=ae;exports.BaseDocument=me;exports.applyMixins=de;exports.baseReducer=C;exports.createAction=w;exports.createDocument=gt;exports.createExtendedState=xt;exports.createReducer=ft;exports.createZip=H;exports.getLocalFile=le;exports.getRemoteFile=re;exports.hashDocument=J;exports.hashKey=ee;exports.isBaseAction=I;exports.isNoopOperation=ut;exports.isSameDocument=ne;exports.isUndoRedo=M;exports.loadFromFile=P;exports.loadFromInput=zt;exports.mapSkippedOperations=ht;exports.processUndoRedo=mt;exports.readOnly=k;exports.replayDocument=B;exports.replayOperations=N;exports.saveToFile=St;exports.saveToFileHandle=pe;exports.sortMappedOperations=bt;exports.sortOperations=ie;exports.validateOperations=kt;exports.zod=Lt;