document-model 1.0.41 → 1.0.43

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 (110) hide show
  1. package/dist/browser/document-model.cjs +1 -1
  2. package/dist/browser/document-model.js +14 -15
  3. package/dist/browser/document.cjs +1 -1
  4. package/dist/browser/document.js +9 -10
  5. package/dist/browser/index.cjs +1 -1
  6. package/dist/browser/index.js +6 -7
  7. package/dist/browser/internal/{index-BWV1Osza.js → index-CDcO7NCS.js} +3 -4
  8. package/dist/browser/internal/{index-BD_7XeO5.js → index-CfgX2mMt.js} +1 -1
  9. package/dist/browser/internal/{index-BxGRRPwY.js → index-DhzefrNj.js} +1 -1
  10. package/dist/{node/internal/index-LEexvgqj.js → browser/internal/index-EdTViyyq.js} +1 -1
  11. package/dist/browser/internal/object-BkewFVld.js +25 -0
  12. package/dist/browser/internal/object-CrDRbO7a.js +2492 -0
  13. package/dist/node/document-model.cjs +1 -1
  14. package/dist/node/document-model.js +15 -16
  15. package/dist/node/document.cjs +1 -1
  16. package/dist/node/document.js +9 -10
  17. package/dist/node/index.cjs +1 -1
  18. package/dist/node/index.js +7 -8
  19. package/dist/node/internal/{index-Dh0vfIdX.js → index-BWW7KbVk.js} +2 -2
  20. package/dist/node/internal/{index-DeKx7EaE.js → index-Cz8HaIxu.js} +3 -4
  21. package/dist/{browser/internal/index-BNBYVtaF.js → node/internal/index-D_LMFQg7.js} +1 -1
  22. package/dist/node/internal/{index-LD_vrQff.js → index-fctxJxHD.js} +1 -1
  23. package/dist/node/internal/object-BDRv-l-h.js +1390 -0
  24. package/dist/node/internal/object-Br6jYeW0.js +20 -0
  25. package/dist/src/document/actions/creators.d.ts +47 -0
  26. package/dist/src/document/actions/index.d.ts +14 -0
  27. package/dist/src/document/actions/types.d.ts +15 -0
  28. package/dist/src/document/index.d.ts +6 -0
  29. package/dist/src/document/object.d.ts +1140 -0
  30. package/dist/src/document/reducer.d.ts +32 -0
  31. package/dist/src/document/schema/index.d.ts +2 -0
  32. package/dist/src/document/schema/types.d.ts +176 -0
  33. package/dist/src/document/schema/zod.d.ts +113 -0
  34. package/dist/src/document/signal.d.ts +29 -0
  35. package/dist/src/document/types.d.ts +245 -0
  36. package/dist/src/document/utils/base.d.ts +80 -0
  37. package/dist/src/document/utils/browser.d.ts +10 -0
  38. package/dist/src/document/utils/file.d.ts +47 -0
  39. package/dist/src/document/utils/index.d.ts +4 -0
  40. package/dist/src/document/utils/node.d.ts +9 -0
  41. package/dist/src/document/utils/validation.d.ts +2 -0
  42. package/dist/src/document-model/custom/reducers/header.d.ts +2 -0
  43. package/dist/src/document-model/custom/reducers/module.d.ts +2 -0
  44. package/dist/src/document-model/custom/reducers/operation-error.d.ts +2 -0
  45. package/dist/src/document-model/custom/reducers/operation-example.d.ts +2 -0
  46. package/dist/src/document-model/custom/reducers/operation.d.ts +2 -0
  47. package/dist/src/document-model/custom/reducers/state.d.ts +2 -0
  48. package/dist/src/document-model/custom/reducers/versioning.d.ts +7 -0
  49. package/dist/src/document-model/custom/utils.d.ts +7 -0
  50. package/dist/src/document-model/gen/actions.d.ts +15 -0
  51. package/dist/src/document-model/gen/creators.d.ts +7 -0
  52. package/dist/src/document-model/gen/document-model.d.ts +2 -0
  53. package/dist/src/document-model/gen/header/actions.d.ts +9 -0
  54. package/dist/src/document-model/gen/header/creators.d.ts +8 -0
  55. package/dist/src/document-model/gen/header/object.d.ts +12 -0
  56. package/dist/src/document-model/gen/header/operations.d.ts +10 -0
  57. package/dist/src/document-model/gen/index.d.ts +5 -0
  58. package/dist/src/document-model/gen/module/actions.d.ts +8 -0
  59. package/dist/src/document-model/gen/module/creators.d.ts +7 -0
  60. package/dist/src/document-model/gen/module/object.d.ts +11 -0
  61. package/dist/src/document-model/gen/module/operations.d.ts +9 -0
  62. package/dist/src/document-model/gen/object.d.ts +28 -0
  63. package/dist/src/document-model/gen/operation/actions.d.ts +13 -0
  64. package/dist/src/document-model/gen/operation/creators.d.ts +12 -0
  65. package/dist/src/document-model/gen/operation/object.d.ts +16 -0
  66. package/dist/src/document-model/gen/operation/operations.d.ts +14 -0
  67. package/dist/src/document-model/gen/operation-error/actions.d.ts +10 -0
  68. package/dist/src/document-model/gen/operation-error/creators.d.ts +9 -0
  69. package/dist/src/document-model/gen/operation-error/object.d.ts +13 -0
  70. package/dist/src/document-model/gen/operation-error/operations.d.ts +11 -0
  71. package/dist/src/document-model/gen/operation-example/actions.d.ts +7 -0
  72. package/dist/src/document-model/gen/operation-example/creators.d.ts +6 -0
  73. package/dist/src/document-model/gen/operation-example/object.d.ts +10 -0
  74. package/dist/src/document-model/gen/operation-example/operations.d.ts +8 -0
  75. package/dist/src/document-model/gen/reducer.d.ts +5 -0
  76. package/dist/src/document-model/gen/schema/index.d.ts +2 -0
  77. package/dist/src/document-model/gen/schema/types.d.ts +453 -0
  78. package/dist/src/document-model/gen/schema/zod.d.ts +453 -0
  79. package/dist/src/document-model/gen/state/actions.d.ts +9 -0
  80. package/dist/src/document-model/gen/state/creators.d.ts +8 -0
  81. package/dist/src/document-model/gen/state/object.d.ts +12 -0
  82. package/dist/src/document-model/gen/state/operations.d.ts +10 -0
  83. package/dist/src/document-model/gen/types.d.ts +8 -0
  84. package/dist/src/document-model/gen/utils.d.ts +6 -0
  85. package/dist/src/document-model/gen/versioning/actions.d.ts +8 -0
  86. package/dist/src/document-model/gen/versioning/creators.d.ts +7 -0
  87. package/dist/src/document-model/gen/versioning/object.d.ts +11 -0
  88. package/dist/src/document-model/gen/versioning/operations.d.ts +9 -0
  89. package/dist/src/document-model/index.d.ts +80 -0
  90. package/dist/src/index.d.ts +25 -0
  91. package/dist/test/document/event-vs-command.test.d.ts +1 -0
  92. package/dist/test/document/local.test.d.ts +1 -0
  93. package/dist/test/document/object.test.d.ts +1 -0
  94. package/dist/test/document/prune.test.d.ts +1 -0
  95. package/dist/test/document/reducer.test.d.ts +1 -0
  96. package/dist/test/document/skip-operations.test.d.ts +1 -0
  97. package/dist/test/document/undo-redo.test.d.ts +1 -0
  98. package/dist/test/document/utils.test.d.ts +1 -0
  99. package/dist/test/document-model/object.test.d.ts +1 -0
  100. package/dist/test/document-model/skip-operations.test.d.ts +1 -0
  101. package/dist/test/document-model/validation.test.d.ts +1 -0
  102. package/dist/test/document-model/zip.test.d.ts +1 -0
  103. package/dist/test/helpers.d.ts +34 -0
  104. package/dist/vite.config.d.ts +2 -0
  105. package/dist/vitest.config.d.ts +2 -0
  106. package/package.json +3 -2
  107. package/dist/browser/internal/object-DHqlosWD.js +0 -7
  108. package/dist/browser/internal/object-StihF423.js +0 -1999
  109. package/dist/node/internal/object-CKxJA706.js +0 -2
  110. package/dist/node/internal/object-CudRLU4J.js +0 -998
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-DHqlosWD.js");require("immer");require("json-stringify-deterministic");require("jszip");const e=require("./internal/index-BxGRRPwY.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.validateInitialState=e.validateInitialState;exports.validateModule=e.validateModule;exports.validateModuleOperation=e.validateModuleOperation;exports.validateModules=e.validateModules;exports.validateStateSchemaName=e.validateStateSchemaName;exports.z=e.zod;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-BkewFVld.js");require("immer");require("jszip");const e=require("./internal/index-DhzefrNj.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.validateInitialState=e.validateInitialState;exports.validateModule=e.validateModule;exports.validateModuleOperation=e.validateModuleOperation;exports.validateModules=e.validateModules;exports.validateStateSchemaName=e.validateStateSchemaName;exports.z=e.zod;
@@ -1,21 +1,20 @@
1
- import "./internal/object-StihF423.js";
1
+ import "./internal/object-CrDRbO7a.js";
2
2
  import "immer";
3
- import "json-stringify-deterministic";
4
3
  import "jszip";
5
- import { b as l, a as m, c as r, d as u, m as c, r as p, u as n, v, g as M, h as S, f, e as h, z as D } from "./internal/index-BWV1Osza.js";
4
+ import { b as i, a as l, c as m, d as r, m as u, r as c, u as n, v as p, g as v, h as M, f as S, e as f, z as h } from "./internal/index-CDcO7NCS.js";
6
5
  import "zod";
7
6
  export {
8
- l as Document,
9
- m as DocumentModel,
10
- r as actions,
11
- u as documentModel,
12
- c as module,
13
- p as reducer,
7
+ i as Document,
8
+ l as DocumentModel,
9
+ m as actions,
10
+ r as documentModel,
11
+ u as module,
12
+ c as reducer,
14
13
  n as utils,
15
- v as validateInitialState,
16
- M as validateModule,
17
- S as validateModuleOperation,
18
- f as validateModules,
19
- h as validateStateSchemaName,
20
- D as z
14
+ p as validateInitialState,
15
+ v as validateModule,
16
+ M as validateModuleOperation,
17
+ S as validateModules,
18
+ f as validateStateSchemaName,
19
+ h as z
21
20
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal/object-DHqlosWD.js"),r=require("./internal/index-BD_7XeO5.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-BkewFVld.js"),o=require("./internal/index-CfgX2mMt.js");require("immer");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=o.index;
@@ -1,15 +1,14 @@
1
- import { B as p, h as t, g as m, C as c, D as n, E as d } from "./internal/object-StihF423.js";
2
- import { i as x } from "./internal/index-BNBYVtaF.js";
1
+ import { B as i, h as p, g as t, C as m, D as c, E as n } from "./internal/object-CrDRbO7a.js";
2
+ import { i as u } from "./internal/index-EdTViyyq.js";
3
3
  import "immer";
4
- import "json-stringify-deterministic";
5
4
  import "zod";
6
5
  import "jszip";
7
6
  export {
8
- p as BaseDocument,
9
- t as actions,
10
- m as applyMixins,
11
- c as baseReducer,
12
- n as processUndoRedo,
13
- x as utils,
14
- d as z
7
+ i as BaseDocument,
8
+ p as actions,
9
+ t as applyMixins,
10
+ m as baseReducer,
11
+ c as processUndoRedo,
12
+ u as utils,
13
+ n as z
15
14
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./internal/index-BD_7XeO5.js"),o=require("./internal/index-BxGRRPwY.js");require("./internal/object-DHqlosWD.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-CfgX2mMt.js"),o=require("./internal/index-DhzefrNj.js");require("./internal/object-BkewFVld.js");require("immer");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,17 +1,16 @@
1
- import { D as o } from "./internal/index-BNBYVtaF.js";
2
- import { D as t } from "./internal/index-BWV1Osza.js";
3
- import "./internal/object-StihF423.js";
1
+ import { D as o } from "./internal/index-EdTViyyq.js";
2
+ import { D as e } from "./internal/index-CDcO7NCS.js";
3
+ import "./internal/object-CrDRbO7a.js";
4
4
  import "immer";
5
- import "json-stringify-deterministic";
6
5
  import "zod";
7
6
  import "jszip";
8
7
  const u = {
9
8
  "powerhouse/document": o,
10
- "powerhouse/document-model": t
11
- }, c = { Document: o, DocumentModel: t };
9
+ "powerhouse/document-model": e
10
+ }, c = { Document: o, DocumentModel: e };
12
11
  export {
13
12
  o as Document,
14
- t as DocumentModel,
13
+ e as DocumentModel,
15
14
  u as DocumentModels,
16
15
  c as default
17
16
  };
@@ -1,9 +1,8 @@
1
1
  var Rt = Object.defineProperty;
2
2
  var xt = (t, e, r) => e in t ? Rt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
3
  var Ee = (t, e, r) => (xt(t, typeof e != "symbol" ? e + "" : e, r), r);
4
- import { c as At, i as Mt, a as Dt, b as Nt, s as Lt, d as Pt, l as Ct, e as jt, f as a, B as c, g as yt, h as wt } from "./object-StihF423.js";
4
+ import { c as At, i as Mt, a as Dt, b as Nt, s as Lt, d as Pt, l as Ct, e as jt, f as a, B as c, g as yt, h as wt } from "./object-CrDRbO7a.js";
5
5
  import "immer";
6
- import "json-stringify-deterministic";
7
6
  import "jszip";
8
7
  import { z as o } from "zod";
9
8
  const kt = new RegExp("([\\p{Ll}\\d])(\\p{Lu})", "gu"), Ut = new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])", "gu"), vt = new RegExp("(\\d)\\p{Ll}|(\\p{L})\\d", "u"), Ft = /[^\p{L}\d]+/giu, he = "$1\0$2", Oe = "";
@@ -2071,7 +2070,7 @@ const ur = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2071
2070
  actions: It,
2072
2071
  utils: _t,
2073
2072
  documentModel: Ie
2074
- }, br = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2073
+ }, fr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2075
2074
  __proto__: null,
2076
2075
  Document: bt,
2077
2076
  DocumentModel: me,
@@ -2088,7 +2087,7 @@ const ur = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2088
2087
  z: Kt
2089
2088
  }, Symbol.toStringTag, { value: "Module" }));
2090
2089
  export {
2091
- br as D,
2090
+ fr as D,
2092
2091
  me as a,
2093
2092
  bt as b,
2094
2093
  It as c,
@@ -1 +1 @@
1
- "use strict";const e=require("./object-DHqlosWD.js"),t=Object.freeze(Object.defineProperty({__proto__:null,calculateSkipsLeft:e.calculateSkipsLeft,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"})),o=Object.freeze(Object.defineProperty({__proto__:null,BaseDocument:e.BaseDocument,actions:e.BaseActions,applyMixins:e.applyMixins,baseReducer:e.baseReducer,processUndoRedo:e.processUndoRedo,utils:t,z:e.zod},Symbol.toStringTag,{value:"Module"}));exports.Document=o;exports.index=t;
1
+ "use strict";const e=require("./object-BkewFVld.js"),t=Object.freeze(Object.defineProperty({__proto__:null,calculateSkipsLeft:e.calculateSkipsLeft,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"})),o=Object.freeze(Object.defineProperty({__proto__:null,BaseDocument:e.BaseDocument,actions:e.BaseActions,applyMixins:e.applyMixins,baseReducer:e.baseReducer,processUndoRedo:e.processUndoRedo,utils:t,z:e.zod},Symbol.toStringTag,{value:"Module"}));exports.Document=o;exports.index=t;
@@ -1,4 +1,4 @@
1
- "use strict";var Tt=Object.defineProperty;var Rt=(t,e,r)=>e in t?Tt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var be=(t,e,r)=>(Rt(t,typeof e!="symbol"?e+"":e,r),r);const s=require("./object-DHqlosWD.js");require("immer");require("json-stringify-deterministic");require("jszip");const o=require("zod"),xt=new RegExp("([\\p{Ll}\\d])(\\p{Lu})","gu"),Mt=new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])","gu"),Dt=new RegExp("(\\d)\\p{Ll}|(\\p{L})\\d","u"),Nt=/[^\p{L}\d]+/giu,_e="$1\0$2",Ae="";function ze(t){let e=t.trim();e=e.replace(xt,_e).replace(Mt,_e),e=e.replace(Nt,"\0");let r=0,n=e.length;for(;e.charAt(r)==="\0";)r++;if(r===n)return[];for(;e.charAt(n-1)==="\0";)n--;return e.slice(r,n).split(/\0/g)}function Lt(t){const e=ze(t);for(let r=0;r<e.length;r++){const n=e[r],i=Dt.exec(n);if(i){const a=i.index+(i[1]??i[2]).length;e.splice(r,1,n.slice(0,a),n.slice(a))}}return e}function Ie(t,e){const[r,n,i]=wt(t,e),a=Pt(e==null?void 0:e.locale),l=jt(e==null?void 0:e.locale),d=e!=null&&e.mergeAmbiguousCharacters?Ct(a,l):yt(a,l);return r+n.map(d).join((e==null?void 0:e.delimiter)??"")+i}function Pt(t){return t===!1?e=>e.toLowerCase():e=>e.toLocaleLowerCase(t)}function jt(t){return t===!1?e=>e.toUpperCase():e=>e.toLocaleUpperCase(t)}function Ct(t,e){return r=>`${e(r[0])}${t(r.slice(1))}`}function yt(t,e){return(r,n)=>{const i=r[0];return(n>0&&i>="0"&&i<="9"?"_"+i:e(i))+t(r.slice(1))}}function wt(t,e={}){const r=e.split??(e.separateNumbers?Lt:ze),n=e.prefixCharacters??Ae,i=e.suffixCharacters??Ae;let a=0,l=t.length;for(;a<t.length;){const d=t.charAt(a);if(!n.includes(d))break;a++}for(;l>a;){const d=l-1,zt=t.charAt(d);if(!i.includes(zt))break;l=d}return[t.slice(0,a),r(t.slice(a,l)),t.slice(l)]}function T(t,e=!1){const r=[];if(e&&t==="")return r;try{const n=JSON.parse(t);!e&&!Object.keys(n).length&&r.push({message:"Initial state cannot be empty",details:{initialState:t}})}catch{r.push({message:"Invalid initial state",details:{initialState:t}})}return r}function R(t,e,r="",n=!0){const i=[];if(!n&&!t)return i.push({message:"State schema is required",details:{schema:t}}),i;if(n&&!t)return i;const a=`type ${Ie(e)}${Ie(r)}State`;return t.includes(a)||i.push({message:`Invalid state schema name. Expected ${a}`,details:{schema:t}}),i}function x(t){const e=[];t.length||e.push({message:"Modules are required",details:{modules:t}});const r=t.reduce((n,i)=>[...n,...b(i)],[]);return[...e,...r]}function b(t){const e=[];t.name||e.push({message:"Module name is required",details:{module:t}}),t.operations.length||e.push({message:"Module operations are required",details:{module:t}});const r=t.operations.reduce((n,i)=>[...n,..._(i)],[]);return[...e,...r]}function _(t){const e=[];return t.name||e.push({message:"Operation name is required",details:{operation:t}}),t.schema||e.push({message:"Operation schema is required",details:{operation:t}}),e}const kt=Object.freeze(Object.defineProperty({__proto__:null,validateInitialState:T,validateModule:b,validateModuleOperation:_,validateModules:x,validateStateSchemaName:R},Symbol.toStringTag,{value:"Module"})),M={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 Tt=Object.defineProperty;var Rt=(t,e,r)=>e in t?Tt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var be=(t,e,r)=>(Rt(t,typeof e!="symbol"?e+"":e,r),r);const s=require("./object-BkewFVld.js");require("immer");require("jszip");const o=require("zod"),xt=new RegExp("([\\p{Ll}\\d])(\\p{Lu})","gu"),Mt=new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])","gu"),Dt=new RegExp("(\\d)\\p{Ll}|(\\p{L})\\d","u"),Nt=/[^\p{L}\d]+/giu,_e="$1\0$2",Ae="";function ze(t){let e=t.trim();e=e.replace(xt,_e).replace(Mt,_e),e=e.replace(Nt,"\0");let r=0,n=e.length;for(;e.charAt(r)==="\0";)r++;if(r===n)return[];for(;e.charAt(n-1)==="\0";)n--;return e.slice(r,n).split(/\0/g)}function Lt(t){const e=ze(t);for(let r=0;r<e.length;r++){const n=e[r],i=Dt.exec(n);if(i){const a=i.index+(i[1]??i[2]).length;e.splice(r,1,n.slice(0,a),n.slice(a))}}return e}function Ie(t,e){const[r,n,i]=wt(t,e),a=Pt(e==null?void 0:e.locale),l=jt(e==null?void 0:e.locale),d=e!=null&&e.mergeAmbiguousCharacters?Ct(a,l):yt(a,l);return r+n.map(d).join((e==null?void 0:e.delimiter)??"")+i}function Pt(t){return t===!1?e=>e.toLowerCase():e=>e.toLocaleLowerCase(t)}function jt(t){return t===!1?e=>e.toUpperCase():e=>e.toLocaleUpperCase(t)}function Ct(t,e){return r=>`${e(r[0])}${t(r.slice(1))}`}function yt(t,e){return(r,n)=>{const i=r[0];return(n>0&&i>="0"&&i<="9"?"_"+i:e(i))+t(r.slice(1))}}function wt(t,e={}){const r=e.split??(e.separateNumbers?Lt:ze),n=e.prefixCharacters??Ae,i=e.suffixCharacters??Ae;let a=0,l=t.length;for(;a<t.length;){const d=t.charAt(a);if(!n.includes(d))break;a++}for(;l>a;){const d=l-1,zt=t.charAt(d);if(!i.includes(zt))break;l=d}return[t.slice(0,a),r(t.slice(a,l)),t.slice(l)]}function T(t,e=!1){const r=[];if(e&&t==="")return r;try{const n=JSON.parse(t);!e&&!Object.keys(n).length&&r.push({message:"Initial state cannot be empty",details:{initialState:t}})}catch{r.push({message:"Invalid initial state",details:{initialState:t}})}return r}function R(t,e,r="",n=!0){const i=[];if(!n&&!t)return i.push({message:"State schema is required",details:{schema:t}}),i;if(n&&!t)return i;const a=`type ${Ie(e)}${Ie(r)}State`;return t.includes(a)||i.push({message:`Invalid state schema name. Expected ${a}`,details:{schema:t}}),i}function x(t){const e=[];t.length||e.push({message:"Modules are required",details:{modules:t}});const r=t.reduce((n,i)=>[...n,...b(i)],[]);return[...e,...r]}function b(t){const e=[];t.name||e.push({message:"Module name is required",details:{module:t}}),t.operations.length||e.push({message:"Module operations are required",details:{module:t}});const r=t.operations.reduce((n,i)=>[...n,..._(i)],[]);return[...e,...r]}function _(t){const e=[];return t.name||e.push({message:"Operation name is required",details:{operation:t}}),t.schema||e.push({message:"Operation schema is required",details:{operation:t}}),e}const kt=Object.freeze(Object.defineProperty({__proto__:null,validateInitialState:T,validateModule:b,validateModuleOperation:_,validateModules:x,validateStateSchemaName:R},Symbol.toStringTag,{value:"Module"})),M={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 { j as e, f as a, b as s, a as o, c as t, k as r, m as i, n, o as c, p as l, i as p, q as d, r as u, t as m, l as O, e as y, u as b, v as D, w as S, x as _, s as f, d as g, y as F, z as v, A as h, B as j, h as x, g as z, C as R, D as A, E as B } from "./object-CudRLU4J.js";
1
+ import { j as e, f as a, b as s, a as o, c as t, k as r, m as i, n, o as c, p as l, i as p, q as d, r as u, t as m, l as O, e as y, u as b, v as D, w as S, x as _, s as f, d as g, y as F, z as v, A as h, B as j, h as x, g as z, C as R, D as A, E as B } from "./object-CrDRbO7a.js";
2
2
  const M = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3
3
  __proto__: null,
4
4
  calculateSkipsLeft: e,
@@ -0,0 +1,25 @@
1
+ "use strict";var We=Object.defineProperty;var Ve=(i,r,s)=>r in i?We(i,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[r]=s;var St=(i,r,s)=>(Ve(i,typeof r!="symbol"?r+"":r,s),s);const ot=require("immer"),S=require("zod"),ie=require("jszip"),ne=i=>i!=null,Ke=S.z.any().refine(i=>ne(i)),oe=S.z.enum(["LOAD_STATE"]),ae=S.z.enum(["PRUNE"]),se=S.z.enum(["REDO"]),pe=S.z.enum(["SET_NAME"]),ce=S.z.enum(["UNDO"]);function He(){return S.z.object({__typename:S.z.literal("Action").optional(),type:S.z.string()})}function gt(){return S.z.literal("global").or(S.z.literal("local"))}function le(){return S.z.union([ue(),he(),me(),xe(),de()])}function Ze(){return S.z.object({__typename:S.z.literal("DocumentFile").optional(),data:S.z.string(),extension:S.z.string().nullable(),fileName:S.z.string().nullable(),mimeType:S.z.string()})}function ue(){return S.z.object({input:S.z.lazy(()=>Rt()),type:oe,scope:gt()})}function Rt(){return S.z.object({operations:S.z.number(),state:S.z.lazy(()=>fe())})}function fe(){return S.z.object({data:S.z.unknown().nullish(),name:S.z.string()})}function Ge(){return S.z.object({__typename:S.z.literal("Operation").optional(),hash:S.z.string(),index:S.z.number(),timestamp:S.z.string().datetime(),type:S.z.string()})}function he(){return S.z.object({input:S.z.lazy(()=>Lt()),type:ae,scope:gt()})}function Lt(){return S.z.object({end:S.z.number().nullish(),start:S.z.number().nullish()})}const Pt=S.z.number;function me(){return S.z.object({input:Pt(),type:se,scope:gt()})}const qt=S.z.string;function xe(){return S.z.object({input:qt(),type:pe,scope:S.z.literal("global")})}function Ye(){return S.z.object({__typename:S.z.literal("SetNameOperation").optional(),hash:S.z.string(),index:S.z.number(),input:S.z.string(),timestamp:S.z.string().datetime(),type:S.z.string()})}const Jt=S.z.number;function de(){return S.z.object({input:Jt(),type:ce,scope:gt()})}const Xe=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:He,BaseActionSchema:le,DocumentFileSchema:Ze,LoadStateActionInputSchema:Rt,LoadStateActionSchema:ue,LoadStateActionStateInputSchema:fe,Load_StateSchema:oe,OperationSchema:Ge,OperationScopeSchema:gt,PruneActionInputSchema:Lt,PruneActionSchema:he,PruneSchema:ae,RedoActionInputSchema:Pt,RedoActionSchema:me,RedoSchema:se,SetNameActionInputSchema:qt,SetNameActionSchema:xe,SetNameOperationSchema:Ye,Set_NameSchema:pe,UndoActionInputSchema:Jt,UndoActionSchema:de,UndoSchema:ce,definedNonNullAnySchema:Ke,isDefinedNonNullAny:ne},Symbol.toStringTag,{value:"Module"}));function Wt(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Ut={exports:{}};(function(i,r){const{hasOwnProperty:s}=Object.prototype,p=rt();p.configure=rt,p.stringify=p,p.default=p,r.stringify=p,r.configure=rt,i.exports=p;const f=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/;function u(y){return y.length<5e3&&!f.test(y)?`"${y}"`:JSON.stringify(y)}function l(y){if(y.length>200)return y.sort();for(let E=1;E<y.length;E++){const k=y[E];let q=E;for(;q!==0&&y[q-1]>k;)y[q]=y[q-1],q--;y[q]=k}return y}const a=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function x(y){return a.call(y)!==void 0&&y.length!==0}function g(y,E,k){y.length<k&&(k=y.length);const q=E===","?"":" ";let Z=`"0":${q}${y[0]}`;for(let H=1;H<k;H++)Z+=`${E}"${H}":${q}${y[H]}`;return Z}function A(y){if(s.call(y,"circularValue")){const E=y.circularValue;if(typeof E=="string")return`"${E}"`;if(E==null)return E;if(E===Error||E===TypeError)return{toString(){throw new TypeError("Converting circular structure to JSON")}};throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined')}return'"[Circular]"'}function w(y,E){let k;if(s.call(y,E)&&(k=y[E],typeof k!="boolean"))throw new TypeError(`The "${E}" argument must be of type boolean`);return k===void 0?!0:k}function b(y,E){let k;if(s.call(y,E)){if(k=y[E],typeof k!="number")throw new TypeError(`The "${E}" argument must be of type number`);if(!Number.isInteger(k))throw new TypeError(`The "${E}" argument must be an integer`);if(k<1)throw new RangeError(`The "${E}" argument must be >= 1`)}return k===void 0?1/0:k}function F(y){return y===1?"1 item":`${y} items`}function I(y){const E=new Set;for(const k of y)(typeof k=="string"||typeof k=="number")&&E.add(String(k));return E}function G(y){if(s.call(y,"strict")){const E=y.strict;if(typeof E!="boolean")throw new TypeError('The "strict" argument must be of type boolean');if(E)return k=>{let q=`Object can not safely be stringified. Received type ${typeof k}`;throw typeof k!="function"&&(q+=` (${k.toString()})`),new Error(q)}}}function rt(y){y={...y};const E=G(y);E&&(y.bigint===void 0&&(y.bigint=!1),"circularValue"in y||(y.circularValue=Error));const k=A(y),q=w(y,"bigint"),Z=w(y,"deterministic"),H=b(y,"maximumDepth"),M=b(y,"maximumBreadth");function ut(J,h,v,T,O,$){let _=h[J];switch(typeof _=="object"&&_!==null&&typeof _.toJSON=="function"&&(_=_.toJSON(J)),_=T.call(h,J,_),typeof _){case"string":return u(_);case"object":{if(_===null)return"null";if(v.indexOf(_)!==-1)return k;let D="",B=",";const j=$;if(Array.isArray(_)){if(_.length===0)return"[]";if(H<v.length+1)return'"[Array]"';v.push(_),O!==""&&($+=O,D+=`
2
+ ${$}`,B=`,
3
+ ${$}`);const W=Math.min(_.length,M);let X=0;for(;X<W-1;X++){const pt=ut(String(X),_,v,T,O,$);D+=pt!==void 0?pt:"null",D+=B}const Q=ut(String(X),_,v,T,O,$);if(D+=Q!==void 0?Q:"null",_.length-1>M){const pt=_.length-M-1;D+=`${B}"... ${F(pt)} not stringified"`}return O!==""&&(D+=`
4
+ ${j}`),v.pop(),`[${D}]`}let N=Object.keys(_);const P=N.length;if(P===0)return"{}";if(H<v.length+1)return'"[Object]"';let C="",V="";O!==""&&($+=O,B=`,
5
+ ${$}`,C=" ");const Y=Math.min(P,M);Z&&!x(_)&&(N=l(N)),v.push(_);for(let W=0;W<Y;W++){const X=N[W],Q=ut(X,_,v,T,O,$);Q!==void 0&&(D+=`${V}${u(X)}:${C}${Q}`,V=B)}if(P>M){const W=P-M;D+=`${V}"...":${C}"${F(W)} not stringified"`,V=B}return O!==""&&V.length>1&&(D=`
6
+ ${$}${D}
7
+ ${j}`),v.pop(),`{${D}}`}case"number":return isFinite(_)?String(_):E?E(_):"null";case"boolean":return _===!0?"true":"false";case"undefined":return;case"bigint":if(q)return String(_);default:return E?E(_):void 0}}function ft(J,h,v,T,O,$){switch(typeof h=="object"&&h!==null&&typeof h.toJSON=="function"&&(h=h.toJSON(J)),typeof h){case"string":return u(h);case"object":{if(h===null)return"null";if(v.indexOf(h)!==-1)return k;const _=$;let D="",B=",";if(Array.isArray(h)){if(h.length===0)return"[]";if(H<v.length+1)return'"[Array]"';v.push(h),O!==""&&($+=O,D+=`
8
+ ${$}`,B=`,
9
+ ${$}`);const P=Math.min(h.length,M);let C=0;for(;C<P-1;C++){const Y=ft(String(C),h[C],v,T,O,$);D+=Y!==void 0?Y:"null",D+=B}const V=ft(String(C),h[C],v,T,O,$);if(D+=V!==void 0?V:"null",h.length-1>M){const Y=h.length-M-1;D+=`${B}"... ${F(Y)} not stringified"`}return O!==""&&(D+=`
10
+ ${_}`),v.pop(),`[${D}]`}v.push(h);let j="";O!==""&&($+=O,B=`,
11
+ ${$}`,j=" ");let N="";for(const P of T){const C=ft(P,h[P],v,T,O,$);C!==void 0&&(D+=`${N}${u(P)}:${j}${C}`,N=B)}return O!==""&&N.length>1&&(D=`
12
+ ${$}${D}
13
+ ${_}`),v.pop(),`{${D}}`}case"number":return isFinite(h)?String(h):E?E(h):"null";case"boolean":return h===!0?"true":"false";case"undefined":return;case"bigint":if(q)return String(h);default:return E?E(h):void 0}}function at(J,h,v,T,O){switch(typeof h){case"string":return u(h);case"object":{if(h===null)return"null";if(typeof h.toJSON=="function"){if(h=h.toJSON(J),typeof h!="object")return at(J,h,v,T,O);if(h===null)return"null"}if(v.indexOf(h)!==-1)return k;const $=O;if(Array.isArray(h)){if(h.length===0)return"[]";if(H<v.length+1)return'"[Array]"';v.push(h),O+=T;let C=`
14
+ ${O}`;const V=`,
15
+ ${O}`,Y=Math.min(h.length,M);let W=0;for(;W<Y-1;W++){const Q=at(String(W),h[W],v,T,O);C+=Q!==void 0?Q:"null",C+=V}const X=at(String(W),h[W],v,T,O);if(C+=X!==void 0?X:"null",h.length-1>M){const Q=h.length-M-1;C+=`${V}"... ${F(Q)} not stringified"`}return C+=`
16
+ ${$}`,v.pop(),`[${C}]`}let _=Object.keys(h);const D=_.length;if(D===0)return"{}";if(H<v.length+1)return'"[Object]"';O+=T;const B=`,
17
+ ${O}`;let j="",N="",P=Math.min(D,M);x(h)&&(j+=g(h,B,M),_=_.slice(h.length),P-=h.length,N=B),Z&&(_=l(_)),v.push(h);for(let C=0;C<P;C++){const V=_[C],Y=at(V,h[V],v,T,O);Y!==void 0&&(j+=`${N}${u(V)}: ${Y}`,N=B)}if(D>M){const C=D-M;j+=`${N}"...": "${F(C)} not stringified"`,N=B}return N!==""&&(j=`
18
+ ${O}${j}
19
+ ${$}`),v.pop(),`{${j}}`}case"number":return isFinite(h)?String(h):E?E(h):"null";case"boolean":return h===!0?"true":"false";case"undefined":return;case"bigint":if(q)return String(h);default:return E?E(h):void 0}}function st(J,h,v){switch(typeof h){case"string":return u(h);case"object":{if(h===null)return"null";if(typeof h.toJSON=="function"){if(h=h.toJSON(J),typeof h!="object")return st(J,h,v);if(h===null)return"null"}if(v.indexOf(h)!==-1)return k;let T="";if(Array.isArray(h)){if(h.length===0)return"[]";if(H<v.length+1)return'"[Array]"';v.push(h);const B=Math.min(h.length,M);let j=0;for(;j<B-1;j++){const P=st(String(j),h[j],v);T+=P!==void 0?P:"null",T+=","}const N=st(String(j),h[j],v);if(T+=N!==void 0?N:"null",h.length-1>M){const P=h.length-M-1;T+=`,"... ${F(P)} not stringified"`}return v.pop(),`[${T}]`}let O=Object.keys(h);const $=O.length;if($===0)return"{}";if(H<v.length+1)return'"[Object]"';let _="",D=Math.min($,M);x(h)&&(T+=g(h,",",M),O=O.slice(h.length),D-=h.length,_=","),Z&&(O=l(O)),v.push(h);for(let B=0;B<D;B++){const j=O[B],N=st(j,h[j],v);N!==void 0&&(T+=`${_}${u(j)}:${N}`,_=",")}if($>M){const B=$-M;T+=`${_}"...":"${F(B)} not stringified"`}return v.pop(),`{${T}}`}case"number":return isFinite(h)?String(h):E?E(h):"null";case"boolean":return h===!0?"true":"false";case"undefined":return;case"bigint":if(q)return String(h);default:return E?E(h):void 0}}function Tt(J,h,v){if(arguments.length>1){let T="";if(typeof v=="number"?T=" ".repeat(Math.min(v,10)):typeof v=="string"&&(T=v.slice(0,10)),h!=null){if(typeof h=="function")return ut("",{"":J},[],h,T,"");if(Array.isArray(h))return ft("",J,[],I(h),T,"")}if(T.length!==0)return at("",J,[],T,"")}return st("",J,[])}return Tt}})(Ut,Ut.exports);var Qe=Ut.exports;const _t=Wt(Qe);_t.configure;function tr(i,r){return{...i,name:r}}function er(i,r,s){const p={skip:s,document:i},{scope:f}=r;return!f||r.skip===void 0?p:ot.produce(p,u=>{const[l]=u.document.operations[f].slice(-1);r.skip&&r.skip>0&&(u.skip=r.skip),l.type==="NOOP"&&r.index===l.index&&u.skip>l.skip&&u.document.operations[f].pop()})}function rr(i,r,s){const{scope:p,input:f}=r,u={document:i,action:r,skip:s};return ot.produce(u,l=>{if(l.document.operations[p].length<1)throw new Error(`Cannot undo: no operations in history for scope "${p}"`);if(f<1)throw new Error("Invalid UNDO action: input value must be greater than 0");if(l.skip>0)throw new Error("Cannot undo: skip value from reducer cannot be used with UNDO action");const[a]=l.document.operations[p].slice(-1),x=a.type==="NOOP"&&a.skip>0;if(l.skip+=f,x){l.skip+=a.skip;const b=l.document.operations[p][l.document.operations[p].length-2];b&&a.index-b.index===1&&l.document.operations[p].pop()}if(l.document.operations[p].length<l.skip)throw new Error("Cannot undo: you can't undo more operations than the ones in the scope history");const g=l.document.operations[p].length-1;let A=f,w=x?g-a.skip:g;for(;A>0&&w>=0;){const b=l.document.operations[p][w];if(!b){A--,w--;continue}b.type==="NOOP"&&b.skip>0?(w=w-(b.skip+1),l.skip+=b.skip+1):(l.document.clipboard.push({...b}),A--,w--)}l.action=Qt(p)})}function ir(i,r,s){const{scope:p,input:f}=r,u={document:i,action:r,skip:s};return ot.produce(u,l=>{if(l.skip>0)throw new Error("Cannot redo: skip value from reducer cannot be used with REDO action");if(f>1)throw new Error("Cannot redo: you can only redo one operation at a time");if(f<1)throw new Error("Invalid REDO action: invalid redo input value");if(l.document.clipboard.length<1)throw new Error("Cannot redo: no operations in the clipboard");const a=l.document.clipboard.findLastIndex(g=>g.scope===p);if(a<0)throw new Error(`Cannot redo: no operations in clipboard for scope "${p}"`);const x=l.document.clipboard.splice(a,1)[0];l.action=ot.castDraft({type:x.type,scope:x.scope,input:x.input})})}function nr(i,r,s){const{scope:p}=r,f=i.operations[p];let{input:{start:u,end:l}}=r;u=u||0,l=l||f.length;const a=f.slice(u,l),x=f.slice(0,u),g=f.slice(l),A=Ft(i.initialState,{...i.operations,[p]:x.concat(a)},s),{name:w,state:b}=A,F=x.length,I=x.length?x[x.length-1].timestamp:g.length?g[0].timestamp:new Date().toISOString();return Ft(i.initialState,{...i.operations,[p]:[...x,{...Xt({name:w,state:b},a.length),timestamp:I,index:F,hash:Gt({state:b},"global")},...g.map((G,rt)=>({...G,index:F+rt+1}))]},s)}function or(i,r){return{...i,name:r.name,state:r.state??{global:{},local:{}}}}const ge="SET_NAME",yt="UNDO",wt="REDO",Bt="PRUNE",ye="LOAD_STATE",ar="NOOP";function sr(i,r){let s;return"index"in r?s={...r}:s=i.operations[r.scope].slice(-1)[0],((s==null?void 0:s.index)??-1)+1}function pr(i,r){return{...i,revision:{...i.revision,[r.scope]:sr(i,r)},lastModified:new Date().toISOString()}}function cr(i,r,s=0){if([yt,wt,Bt].includes(r.type))return i;const{scope:p}=r,f=i.operations[p].slice(0,i.revision[p]),u=[...f].pop();let l=((u==null?void 0:u.index)??-1)+1;if("index"in r){if(r.index>l+s)throw new Error(`Missing operations: expected ${l} with skip 0 or equivalent, got index ${r.index} with skip ${s}`);l=r.index}return f.push({...r,index:l,timestamp:new Date().toISOString(),hash:"",scope:p,skip:s}),{...i,operations:{...i.operations,[p]:f}}}function lr(i,r,s=0){let p=cr(i,r,s);return p=pr(p,r),p}function ur(i,r,s){switch(le().parse(r),r.type){case ge:return tr(i,r.input);case Bt:return nr(i,r,s);case ye:return or(i,r.input.state);default:return i}}function we(i,r,s){switch(r.type){case yt:return rr(i,r,s);case wt:return ir(i,r,s);default:return{document:i,action:r,skip:s}}}function Vt(i,r,s,p,f={}){const{skip:u,ignoreSkipOperations:l=!1}=f;let a={...r},x=u||0,g=i,A=[...i.clipboard];if(Oe(a)){const{document:w,skip:b}=er(g,a,x);x=b,g=w}if(zt(a)){const{skip:w,action:b,document:F}=we(i,a,x);a=b,x=w,g=F,A=[...g.clipboard]}if(Mt(a)&&(g=ur(g,a,s)),x>0&&!l){let w=x;"index"in a&&(w=De(g.operations[a.scope],a.index,x)),g=Ft(g.initialState,g.operations,s,void 0,void 0,void 0,{[a.scope]:w})}return g=lr(g,a,x),g=ot.produce(g,w=>{const b=s(w.state,a,p),F=zt(r)?[...A]:[];if(b)return ot.castDraft({...g,clipboard:[...F],state:b});w.clipboard=ot.castDraft([...F])}),ot.produce(g,w=>{if([yt,wt,Bt].includes(a.type))return w;const b=a.scope||"global";w.operations[b][w.operations[b].length-1].hash=Gt(w,b),!Mt(a)&&a.attachments&&a.attachments.forEach(F=>{const{hash:I,...G}=F;w.attachments[I]={...G}})})}var $t={exports:{}};typeof Object.create=="function"?$t.exports=function(r,s){s&&(r.super_=s,r.prototype=Object.create(s.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}))}:$t.exports=function(r,s){if(s){r.super_=s;var p=function(){};p.prototype=s.prototype,r.prototype=new p,r.prototype.constructor=r}};var be=$t.exports,Ct={exports:{}},Ee={},Ot={};Ot.byteLength=mr;Ot.toByteArray=dr;Ot.fromByteArray=wr;var nt=[],et=[],fr=typeof Uint8Array<"u"?Uint8Array:Array,Dt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var ht=0,hr=Dt.length;ht<hr;++ht)nt[ht]=Dt[ht],et[Dt.charCodeAt(ht)]=ht;et[45]=62;et[95]=63;function ve(i){var r=i.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var s=i.indexOf("=");s===-1&&(s=r);var p=s===r?0:4-s%4;return[s,p]}function mr(i){var r=ve(i),s=r[0],p=r[1];return(s+p)*3/4-p}function xr(i,r,s){return(r+s)*3/4-s}function dr(i){var r,s=ve(i),p=s[0],f=s[1],u=new fr(xr(i,p,f)),l=0,a=f>0?p-4:p,x;for(x=0;x<a;x+=4)r=et[i.charCodeAt(x)]<<18|et[i.charCodeAt(x+1)]<<12|et[i.charCodeAt(x+2)]<<6|et[i.charCodeAt(x+3)],u[l++]=r>>16&255,u[l++]=r>>8&255,u[l++]=r&255;return f===2&&(r=et[i.charCodeAt(x)]<<2|et[i.charCodeAt(x+1)]>>4,u[l++]=r&255),f===1&&(r=et[i.charCodeAt(x)]<<10|et[i.charCodeAt(x+1)]<<4|et[i.charCodeAt(x+2)]>>2,u[l++]=r>>8&255,u[l++]=r&255),u}function gr(i){return nt[i>>18&63]+nt[i>>12&63]+nt[i>>6&63]+nt[i&63]}function yr(i,r,s){for(var p,f=[],u=r;u<s;u+=3)p=(i[u]<<16&16711680)+(i[u+1]<<8&65280)+(i[u+2]&255),f.push(gr(p));return f.join("")}function wr(i){for(var r,s=i.length,p=s%3,f=[],u=16383,l=0,a=s-p;l<a;l+=u)f.push(yr(i,l,l+u>a?a:l+u));return p===1?(r=i[s-1],f.push(nt[r>>2]+nt[r<<4&63]+"==")):p===2&&(r=(i[s-2]<<8)+i[s-1],f.push(nt[r>>10]+nt[r>>4&63]+nt[r<<2&63]+"=")),f.join("")}var Kt={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Kt.read=function(i,r,s,p,f){var u,l,a=f*8-p-1,x=(1<<a)-1,g=x>>1,A=-7,w=s?f-1:0,b=s?-1:1,F=i[r+w];for(w+=b,u=F&(1<<-A)-1,F>>=-A,A+=a;A>0;u=u*256+i[r+w],w+=b,A-=8);for(l=u&(1<<-A)-1,u>>=-A,A+=p;A>0;l=l*256+i[r+w],w+=b,A-=8);if(u===0)u=1-g;else{if(u===x)return l?NaN:(F?-1:1)*(1/0);l=l+Math.pow(2,p),u=u-g}return(F?-1:1)*l*Math.pow(2,u-p)};Kt.write=function(i,r,s,p,f,u){var l,a,x,g=u*8-f-1,A=(1<<g)-1,w=A>>1,b=f===23?Math.pow(2,-24)-Math.pow(2,-77):0,F=p?0:u-1,I=p?1:-1,G=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(a=isNaN(r)?1:0,l=A):(l=Math.floor(Math.log(r)/Math.LN2),r*(x=Math.pow(2,-l))<1&&(l--,x*=2),l+w>=1?r+=b/x:r+=b*Math.pow(2,1-w),r*x>=2&&(l++,x/=2),l+w>=A?(a=0,l=A):l+w>=1?(a=(r*x-1)*Math.pow(2,f),l=l+w):(a=r*Math.pow(2,w-1)*Math.pow(2,f),l=0));f>=8;i[s+F]=a&255,F+=I,a/=256,f-=8);for(l=l<<f|a,g+=f;g>0;i[s+F]=l&255,F+=I,l/=256,g-=8);i[s+F-I]|=G*128};/*!
20
+ * The buffer module from node.js, for the browser.
21
+ *
22
+ * @author Feross Aboukhadijeh <https://feross.org>
23
+ * @license MIT
24
+ */(function(i){var r=Ot,s=Kt,p=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;i.Buffer=a,i.SlowBuffer=E,i.INSPECT_MAX_BYTES=50;var f=2147483647;i.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 n=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(n,t),n.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function l(n){if(n>f)throw new RangeError('The value "'+n+'" is invalid for option "size"');var t=new Uint8Array(n);return Object.setPrototypeOf(t,a.prototype),t}function a(n,t,e){if(typeof n=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return w(n)}return x(n,t,e)}a.poolSize=8192;function x(n,t,e){if(typeof n=="string")return b(n,t);if(ArrayBuffer.isView(n))return I(n);if(n==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n);if(it(n,ArrayBuffer)||n&&it(n.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(it(n,SharedArrayBuffer)||n&&it(n.buffer,SharedArrayBuffer)))return G(n,t,e);if(typeof n=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var o=n.valueOf&&n.valueOf();if(o!=null&&o!==n)return a.from(o,t,e);var c=rt(n);if(c)return c;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof n[Symbol.toPrimitive]=="function")return a.from(n[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n)}a.from=function(n,t,e){return x(n,t,e)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function g(n){if(typeof n!="number")throw new TypeError('"size" argument must be of type number');if(n<0)throw new RangeError('The value "'+n+'" is invalid for option "size"')}function A(n,t,e){return g(n),n<=0?l(n):t!==void 0?typeof e=="string"?l(n).fill(t,e):l(n).fill(t):l(n)}a.alloc=function(n,t,e){return A(n,t,e)};function w(n){return g(n),l(n<0?0:y(n)|0)}a.allocUnsafe=function(n){return w(n)},a.allocUnsafeSlow=function(n){return w(n)};function b(n,t){if((typeof t!="string"||t==="")&&(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var e=k(n,t)|0,o=l(e),c=o.write(n,t);return c!==e&&(o=o.slice(0,c)),o}function F(n){for(var t=n.length<0?0:y(n.length)|0,e=l(t),o=0;o<t;o+=1)e[o]=n[o]&255;return e}function I(n){if(it(n,Uint8Array)){var t=new Uint8Array(n);return G(t.buffer,t.byteOffset,t.byteLength)}return F(n)}function G(n,t,e){if(t<0||n.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(n.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');var o;return t===void 0&&e===void 0?o=new Uint8Array(n):e===void 0?o=new Uint8Array(n,t):o=new Uint8Array(n,t,e),Object.setPrototypeOf(o,a.prototype),o}function rt(n){if(a.isBuffer(n)){var t=y(n.length)|0,e=l(t);return e.length===0||n.copy(e,0,0,t),e}if(n.length!==void 0)return typeof n.length!="number"||kt(n.length)?l(0):F(n);if(n.type==="Buffer"&&Array.isArray(n.data))return F(n.data)}function y(n){if(n>=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+" bytes");return n|0}function E(n){return+n!=n&&(n=0),a.alloc(+n)}a.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==a.prototype},a.compare=function(t,e){if(it(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),it(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var o=t.length,c=e.length,m=0,d=Math.min(o,c);m<d;++m)if(t[m]!==e[m]){o=t[m],c=e[m];break}return o<c?-1:c<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 c=a.allocUnsafe(e),m=0;for(o=0;o<t.length;++o){var d=t[o];if(it(d,Uint8Array))m+d.length>c.length?a.from(d).copy(c,m):Uint8Array.prototype.set.call(c,d,m);else if(a.isBuffer(d))d.copy(c,m);else throw new TypeError('"list" argument must be an Array of Buffers');m+=d.length}return c};function k(n,t){if(a.isBuffer(n))return n.length;if(ArrayBuffer.isView(n)||it(n,ArrayBuffer))return n.byteLength;if(typeof n!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof n);var e=n.length,o=arguments.length>2&&arguments[2]===!0;if(!o&&e===0)return 0;for(var c=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return W(n).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return pt(n).length;default:if(c)return o?-1:W(n).length;t=(""+t).toLowerCase(),c=!0}}a.byteLength=k;function q(n,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(n||(n="utf8");;)switch(n){case"hex":return _(this,t,e);case"utf8":case"utf-8":return h(this,t,e);case"ascii":return O(this,t,e);case"latin1":case"binary":return $(this,t,e);case"base64":return J(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return D(this,t,e);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),o=!0}}a.prototype._isBuffer=!0;function Z(n,t,e){var o=n[t];n[t]=n[e],n[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)Z(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)Z(this,e,e+3),Z(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)Z(this,e,e+7),Z(this,e+1,e+6),Z(this,e+2,e+5),Z(this,e+3,e+4);return this},a.prototype.toString=function(){var t=this.length;return t===0?"":arguments.length===0?h(this,0,t):q.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=i.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"},p&&(a.prototype[p]=a.prototype.inspect),a.prototype.compare=function(t,e,o,c,m){if(it(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),o===void 0&&(o=t?t.length:0),c===void 0&&(c=0),m===void 0&&(m=this.length),e<0||o>t.length||c<0||m>this.length)throw new RangeError("out of range index");if(c>=m&&e>=o)return 0;if(c>=m)return-1;if(e>=o)return 1;if(e>>>=0,o>>>=0,c>>>=0,m>>>=0,this===t)return 0;for(var d=m-c,U=o-e,z=Math.min(d,U),R=this.slice(c,m),K=t.slice(e,o),L=0;L<z;++L)if(R[L]!==K[L]){d=R[L],U=K[L];break}return d<U?-1:U<d?1:0};function H(n,t,e,o,c){if(n.length===0)return-1;if(typeof e=="string"?(o=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,kt(e)&&(e=c?0:n.length-1),e<0&&(e=n.length+e),e>=n.length){if(c)return-1;e=n.length-1}else if(e<0)if(c)e=0;else return-1;if(typeof t=="string"&&(t=a.from(t,o)),a.isBuffer(t))return t.length===0?-1:M(n,t,e,o,c);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?c?Uint8Array.prototype.indexOf.call(n,t,e):Uint8Array.prototype.lastIndexOf.call(n,t,e):M(n,[t],e,o,c);throw new TypeError("val must be string, number or Buffer")}function M(n,t,e,o,c){var m=1,d=n.length,U=t.length;if(o!==void 0&&(o=String(o).toLowerCase(),o==="ucs2"||o==="ucs-2"||o==="utf16le"||o==="utf-16le")){if(n.length<2||t.length<2)return-1;m=2,d/=2,U/=2,e/=2}function z(ee,re){return m===1?ee[re]:ee.readUInt16BE(re*m)}var R;if(c){var K=-1;for(R=e;R<d;R++)if(z(n,R)===z(t,K===-1?0:R-K)){if(K===-1&&(K=R),R-K+1===U)return K*m}else K!==-1&&(R-=R-K),K=-1}else for(e+U>d&&(e=d-U),R=e;R>=0;R--){for(var L=!0,At=0;At<U;At++)if(z(n,R+At)!==z(t,At)){L=!1;break}if(L)return R}return-1}a.prototype.includes=function(t,e,o){return this.indexOf(t,e,o)!==-1},a.prototype.indexOf=function(t,e,o){return H(this,t,e,o,!0)},a.prototype.lastIndexOf=function(t,e,o){return H(this,t,e,o,!1)};function ut(n,t,e,o){e=Number(e)||0;var c=n.length-e;o?(o=Number(o),o>c&&(o=c)):o=c;var m=t.length;o>m/2&&(o=m/2);for(var d=0;d<o;++d){var U=parseInt(t.substr(d*2,2),16);if(kt(U))return d;n[e+d]=U}return d}function ft(n,t,e,o){return vt(W(t,n.length-e),n,e,o)}function at(n,t,e,o){return vt(X(t),n,e,o)}function st(n,t,e,o){return vt(pt(t),n,e,o)}function Tt(n,t,e,o){return vt(Q(t,n.length-e),n,e,o)}a.prototype.write=function(t,e,o,c){if(e===void 0)c="utf8",o=this.length,e=0;else if(o===void 0&&typeof e=="string")c=e,o=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(o)?(o=o>>>0,c===void 0&&(c="utf8")):(c=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");c||(c="utf8");for(var d=!1;;)switch(c){case"hex":return ut(this,t,e,o);case"utf8":case"utf-8":return ft(this,t,e,o);case"ascii":case"latin1":case"binary":return at(this,t,e,o);case"base64":return st(this,t,e,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Tt(this,t,e,o);default:if(d)throw new TypeError("Unknown encoding: "+c);c=(""+c).toLowerCase(),d=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function J(n,t,e){return t===0&&e===n.length?r.fromByteArray(n):r.fromByteArray(n.slice(t,e))}function h(n,t,e){e=Math.min(n.length,e);for(var o=[],c=t;c<e;){var m=n[c],d=null,U=m>239?4:m>223?3:m>191?2:1;if(c+U<=e){var z,R,K,L;switch(U){case 1:m<128&&(d=m);break;case 2:z=n[c+1],(z&192)===128&&(L=(m&31)<<6|z&63,L>127&&(d=L));break;case 3:z=n[c+1],R=n[c+2],(z&192)===128&&(R&192)===128&&(L=(m&15)<<12|(z&63)<<6|R&63,L>2047&&(L<55296||L>57343)&&(d=L));break;case 4:z=n[c+1],R=n[c+2],K=n[c+3],(z&192)===128&&(R&192)===128&&(K&192)===128&&(L=(m&15)<<18|(z&63)<<12|(R&63)<<6|K&63,L>65535&&L<1114112&&(d=L))}}d===null?(d=65533,U=1):d>65535&&(d-=65536,o.push(d>>>10&1023|55296),d=56320|d&1023),o.push(d),c+=U}return T(o)}var v=4096;function T(n){var t=n.length;if(t<=v)return String.fromCharCode.apply(String,n);for(var e="",o=0;o<t;)e+=String.fromCharCode.apply(String,n.slice(o,o+=v));return e}function O(n,t,e){var o="";e=Math.min(n.length,e);for(var c=t;c<e;++c)o+=String.fromCharCode(n[c]&127);return o}function $(n,t,e){var o="";e=Math.min(n.length,e);for(var c=t;c<e;++c)o+=String.fromCharCode(n[c]);return o}function _(n,t,e){var o=n.length;(!t||t<0)&&(t=0),(!e||e<0||e>o)&&(e=o);for(var c="",m=t;m<e;++m)c+=Je[n[m]];return c}function D(n,t,e){for(var o=n.slice(t,e),c="",m=0;m<o.length-1;m+=2)c+=String.fromCharCode(o[m]+o[m+1]*256);return c}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 c=this.subarray(t,e);return Object.setPrototypeOf(c,a.prototype),c};function B(n,t,e){if(n%1!==0||n<0)throw new RangeError("offset is not uint");if(n+t>e)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(t,e,o){t=t>>>0,e=e>>>0,o||B(t,e,this.length);for(var c=this[t],m=1,d=0;++d<e&&(m*=256);)c+=this[t+d]*m;return c},a.prototype.readUintBE=a.prototype.readUIntBE=function(t,e,o){t=t>>>0,e=e>>>0,o||B(t,e,this.length);for(var c=this[t+--e],m=1;e>0&&(m*=256);)c+=this[t+--e]*m;return c},a.prototype.readUint8=a.prototype.readUInt8=function(t,e){return t=t>>>0,e||B(t,1,this.length),this[t]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||B(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||B(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||B(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||B(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||B(t,e,this.length);for(var c=this[t],m=1,d=0;++d<e&&(m*=256);)c+=this[t+d]*m;return m*=128,c>=m&&(c-=Math.pow(2,8*e)),c},a.prototype.readIntBE=function(t,e,o){t=t>>>0,e=e>>>0,o||B(t,e,this.length);for(var c=e,m=1,d=this[t+--c];c>0&&(m*=256);)d+=this[t+--c]*m;return m*=128,d>=m&&(d-=Math.pow(2,8*e)),d},a.prototype.readInt8=function(t,e){return t=t>>>0,e||B(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},a.prototype.readInt16LE=function(t,e){t=t>>>0,e||B(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||B(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||B(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||B(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||B(t,4,this.length),s.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return t=t>>>0,e||B(t,4,this.length),s.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||B(t,8,this.length),s.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||B(t,8,this.length),s.read(this,t,!1,52,8)};function j(n,t,e,o,c,m){if(!a.isBuffer(n))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>c||t<m)throw new RangeError('"value" argument is out of bounds');if(e+o>n.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(t,e,o,c){if(t=+t,e=e>>>0,o=o>>>0,!c){var m=Math.pow(2,8*o)-1;j(this,t,e,o,m,0)}var d=1,U=0;for(this[e]=t&255;++U<o&&(d*=256);)this[e+U]=t/d&255;return e+o},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(t,e,o,c){if(t=+t,e=e>>>0,o=o>>>0,!c){var m=Math.pow(2,8*o)-1;j(this,t,e,o,m,0)}var d=o-1,U=1;for(this[e+d]=t&255;--d>=0&&(U*=256);)this[e+d]=t/U&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,c){if(t=+t,e=e>>>0,!c){var m=Math.pow(2,8*o-1);j(this,t,e,o,m-1,-m)}var d=0,U=1,z=0;for(this[e]=t&255;++d<o&&(U*=256);)t<0&&z===0&&this[e+d-1]!==0&&(z=1),this[e+d]=(t/U>>0)-z&255;return e+o},a.prototype.writeIntBE=function(t,e,o,c){if(t=+t,e=e>>>0,!c){var m=Math.pow(2,8*o-1);j(this,t,e,o,m-1,-m)}var d=o-1,U=1,z=0;for(this[e+d]=t&255;--d>=0&&(U*=256);)t<0&&z===0&&this[e+d+1]!==0&&(z=1),this[e+d]=(t/U>>0)-z&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 N(n,t,e,o,c,m){if(e+o>n.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function P(n,t,e,o,c){return t=+t,e=e>>>0,c||N(n,t,e,4),s.write(n,t,e,o,23,4),e+4}a.prototype.writeFloatLE=function(t,e,o){return P(this,t,e,!0,o)},a.prototype.writeFloatBE=function(t,e,o){return P(this,t,e,!1,o)};function C(n,t,e,o,c){return t=+t,e=e>>>0,c||N(n,t,e,8),s.write(n,t,e,o,52,8),e+8}a.prototype.writeDoubleLE=function(t,e,o){return C(this,t,e,!0,o)},a.prototype.writeDoubleBE=function(t,e,o){return C(this,t,e,!1,o)},a.prototype.copy=function(t,e,o,c){if(!a.isBuffer(t))throw new TypeError("argument should be a Buffer");if(o||(o=0),!c&&c!==0&&(c=this.length),e>=t.length&&(e=t.length),e||(e=0),c>0&&c<o&&(c=o),c===o||t.length===0||this.length===0)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(c<0)throw new RangeError("sourceEnd out of bounds");c>this.length&&(c=this.length),t.length-e<c-o&&(c=t.length-e+o);var m=c-o;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,o,c):Uint8Array.prototype.set.call(t,this.subarray(o,c),e),m},a.prototype.fill=function(t,e,o,c){if(typeof t=="string"){if(typeof e=="string"?(c=e,e=0,o=this.length):typeof o=="string"&&(c=o,o=this.length),c!==void 0&&typeof c!="string")throw new TypeError("encoding must be a string");if(typeof c=="string"&&!a.isEncoding(c))throw new TypeError("Unknown encoding: "+c);if(t.length===1){var m=t.charCodeAt(0);(c==="utf8"&&m<128||c==="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 d;if(typeof t=="number")for(d=e;d<o;++d)this[d]=t;else{var U=a.isBuffer(t)?t:a.from(t,c),z=U.length;if(z===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(d=0;d<o-e;++d)this[d+e]=U[d%z]}return this};var V=/[^+/0-9A-Za-z-_]/g;function Y(n){if(n=n.split("=")[0],n=n.trim().replace(V,""),n.length<2)return"";for(;n.length%4!==0;)n=n+"=";return n}function W(n,t){t=t||1/0;for(var e,o=n.length,c=null,m=[],d=0;d<o;++d){if(e=n.charCodeAt(d),e>55295&&e<57344){if(!c){if(e>56319){(t-=3)>-1&&m.push(239,191,189);continue}else if(d+1===o){(t-=3)>-1&&m.push(239,191,189);continue}c=e;continue}if(e<56320){(t-=3)>-1&&m.push(239,191,189),c=e;continue}e=(c-55296<<10|e-56320)+65536}else c&&(t-=3)>-1&&m.push(239,191,189);if(c=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 X(n){for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e)&255);return t}function Q(n,t){for(var e,o,c,m=[],d=0;d<n.length&&!((t-=2)<0);++d)e=n.charCodeAt(d),o=e>>8,c=e%256,m.push(c),m.push(o);return m}function pt(n){return r.toByteArray(Y(n))}function vt(n,t,e,o){for(var c=0;c<o&&!(c+e>=t.length||c>=n.length);++c)t[c+e]=n[c];return c}function it(n,t){return n instanceof t||n!=null&&n.constructor!=null&&n.constructor.name!=null&&n.constructor.name===t.name}function kt(n){return n!==n}var Je=function(){for(var n="0123456789abcdef",t=new Array(256),e=0;e<16;++e)for(var o=e*16,c=0;c<16;++c)t[o+c]=n[e]+n[c];return t}()})(Ee);/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(i,r){var s=Ee,p=s.Buffer;function f(l,a){for(var x in l)a[x]=l[x]}p.from&&p.alloc&&p.allocUnsafe&&p.allocUnsafeSlow?i.exports=s:(f(s,r),r.Buffer=u);function u(l,a,x){return p(l,a,x)}u.prototype=Object.create(p.prototype),f(p,u),u.from=function(l,a,x){if(typeof l=="number")throw new TypeError("Argument must not be a number");return p(l,a,x)},u.alloc=function(l,a,x){if(typeof l!="number")throw new TypeError("Argument must be a number");var g=p(l);return a!==void 0?typeof x=="string"?g.fill(a,x):g.fill(a):g.fill(0),g},u.allocUnsafe=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return p(l)},u.allocUnsafeSlow=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return s.SlowBuffer(l)}})(Ct,Ct.exports);var Ht=Ct.exports,Ae=Ht.Buffer;function jt(i,r){this._block=Ae.alloc(i),this._finalSize=r,this._blockSize=i,this._len=0}jt.prototype.update=function(i,r){typeof i=="string"&&(r=r||"utf8",i=Ae.from(i,r));for(var s=this._block,p=this._blockSize,f=i.length,u=this._len,l=0;l<f;){for(var a=u%p,x=Math.min(f-l,p-a),g=0;g<x;g++)s[a+g]=i[l+g];u+=x,l+=x,u%p===0&&this._update(s)}return this._len+=f,this};jt.prototype.digest=function(i){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 s=this._len*8;if(s<=4294967295)this._block.writeUInt32BE(s,this._blockSize-4);else{var p=(s&4294967295)>>>0,f=(s-p)/4294967296;this._block.writeUInt32BE(f,this._blockSize-8),this._block.writeUInt32BE(p,this._blockSize-4)}this._update(this._block);var u=this._hash();return i?u.toString(i):u};jt.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var Se=jt,br=be,_e=Se,Er=Ht.Buffer,vr=[1518500249,1859775393,-1894007588,-899497514],Ar=new Array(80);function bt(){this.init(),this._w=Ar,_e.call(this,64,56)}br(bt,_e);bt.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Sr(i){return i<<1|i>>>31}function _r(i){return i<<5|i>>>27}function Fr(i){return i<<30|i>>>2}function Br(i,r,s,p){return i===0?r&s|~r&p:i===2?r&s|r&p|s&p:r^s^p}bt.prototype._update=function(i){for(var r=this._w,s=this._a|0,p=this._b|0,f=this._c|0,u=this._d|0,l=this._e|0,a=0;a<16;++a)r[a]=i.readInt32BE(a*4);for(;a<80;++a)r[a]=Sr(r[a-3]^r[a-8]^r[a-14]^r[a-16]);for(var x=0;x<80;++x){var g=~~(x/20),A=_r(s)+Br(g,p,f,u)+l+r[x]+vr[g]|0;l=u,u=f,f=Fr(p),p=s,s=A}this._a=s+this._a|0,this._b=p+this._b|0,this._c=f+this._c|0,this._d=u+this._d|0,this._e=l+this._e|0};bt.prototype._hash=function(){var i=Er.allocUnsafe(20);return i.writeInt32BE(this._a|0,0),i.writeInt32BE(this._b|0,4),i.writeInt32BE(this._c|0,8),i.writeInt32BE(this._d|0,12),i.writeInt32BE(this._e|0,16),i};var Or=bt;const jr=Wt(Or);var Ir=be,Fe=Se,Tr=Ht.Buffer,kr=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],Dr=new Array(64);function Et(){this.init(),this._w=Dr,Fe.call(this,64,56)}Ir(Et,Fe);Et.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function Ur(i,r,s){return s^i&(r^s)}function $r(i,r,s){return i&r|s&(i|r)}function Cr(i){return(i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10)}function zr(i){return(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7)}function Mr(i){return(i>>>7|i<<25)^(i>>>18|i<<14)^i>>>3}function Nr(i){return(i>>>17|i<<15)^(i>>>19|i<<13)^i>>>10}Et.prototype._update=function(i){for(var r=this._w,s=this._a|0,p=this._b|0,f=this._c|0,u=this._d|0,l=this._e|0,a=this._f|0,x=this._g|0,g=this._h|0,A=0;A<16;++A)r[A]=i.readInt32BE(A*4);for(;A<64;++A)r[A]=Nr(r[A-2])+r[A-7]+Mr(r[A-15])+r[A-16]|0;for(var w=0;w<64;++w){var b=g+zr(l)+Ur(l,a,x)+kr[w]+r[w]|0,F=Cr(s)+$r(s,p,f)|0;g=x,x=a,a=l,l=u+b|0,u=f,f=p,p=s,s=b+F|0}this._a=s+this._a|0,this._b=p+this._b|0,this._c=f+this._c|0,this._d=u+this._d|0,this._e=l+this._e|0,this._f=a+this._f|0,this._g=x+this._g|0,this._h=g+this._h|0};Et.prototype._hash=function(){var i=Tr.allocUnsafe(32);return i.writeInt32BE(this._a,0),i.writeInt32BE(this._b,4),i.writeInt32BE(this._c,8),i.writeInt32BE(this._d,12),i.writeInt32BE(this._e,16),i.writeInt32BE(this._f,20),i.writeInt32BE(this._g,24),i.writeInt32BE(this._h,28),i};var Rr=Et;const Lr=Wt(Rr),Zt=new Error("File system not available.");function Pr(i,r,s){throw Zt}function Be(i){throw Zt}function qr(i){throw Zt}const Jr=async i=>Be(),Wr={sha1:jr,sha256:Lr},It=(i,r="sha1")=>{if(!["sha1","sha256"].includes(r))throw new Error("Hashing algorithm not supported: Available: sha1, sha256");const s=Wr[r];return new s().update(i).digest("base64")};function Oe(i){return i.type===ar&&i.skip!==void 0&&i.skip>0&&i.hash!==void 0}function zt(i){return[yt,wt].includes(i.type)}function Mt(i){return[ge,yt,wt,Bt,ye].includes(i.type)}function lt(i,r,s,p,f="global"){if(!i)throw new Error("Empty action type");if(typeof i!="string")throw new Error(`Invalid action type: ${i}`);const u={type:i,input:r,scope:f};s&&(u.attachments=s);try{p==null||p().parse(u.input)}catch(l){throw new Error(`Invalid action input: ${l}`)}return u}function je(i,r=Vt){return(s,p,f,u)=>r(s,p,i,f,u)}const Ie=(i,r)=>({name:"",documentType:"",revision:{global:0,local:0},created:new Date().toISOString(),lastModified:new Date().toISOString(),attachments:{},...i,state:(r==null?void 0:r(i==null?void 0:i.state))??(i==null?void 0:i.state)??{global:{},local:{}}}),Te=(i,r)=>{const s=Ie(i,r);return{...s,initialState:s,operations:{global:[],local:[]},clipboard:[]}},Gt=(i,r="global")=>It(_t(i.state[r]||"")),Vr=(i,r=1e3)=>{const s=Math.random()*r;return It(`${(i??new Date).toISOString()}${s}`)};function xt(i){return ot.castImmutable(ot.freeze(i,!0))}function ke(i,r){const s=[...i];let p=r||0,f=s.length>0?s[s.length-1].index:0;const u=[];for(const l of s.reverse()){if(p>0){const g=f-l.index;p-=g}if(p<0)throw new Error("Invalid operation index, missing operations");const a={ignore:p>0,operation:l},x=l.skip>0?l.skip+1:0;if(x>0&&x>p){const g=x-p;p=p+g}f=l.index,u.push(a)}return u.reverse()}function De(i,r,s){const p=i.slice().sort((a,x)=>a.skip-x.skip).sort((a,x)=>a.index-x.index);let f=s,u=0,l=r;for(const a of p.reverse()){const x=l-a.index;if(f=f-x,f>-1)u++,l=a.index;else break}return u}function Kr(i){return Object.values(i).flatMap(r=>r).sort((r,s)=>new Date(r.timestamp).getTime()-new Date(s.timestamp).getTime())}function Ue(i){return Object.values(i).flatMap(r=>r).sort((r,s)=>new Date(r.operation.timestamp).getTime()-new Date(s.operation.timestamp).getTime())}function Ft(i,r,s,p,f,u=Vt,l={}){const a=je(s,u);return Yt(i,r,a,p,f,l)}function Yt(i,r,s,p,f,u={}){const l=Te(i),a=Object.keys(r).reduce((b,F)=>{const I=F;return{...b,[I]:r[I].slice(0,f==null?void 0:f.revision[I])}},{}),x=Object.keys(a).reduce((b,F)=>{const I=F;return{...b,[I]:ke(a[I],u[I])}},{}),g=Ue(x).reduce((b,{ignore:F,operation:I})=>F?s(b,Qt(I.scope),p,{skip:I.skip,ignoreSkipOperations:!0}):s(b,I,p,{skip:I.skip,ignoreSkipOperations:!0}),l),A=Object.keys(g.operations).reduce((b,F)=>{const I=F,G=f&&f.revision[I]<r[I].length?r[I].slice(f.revision[I]):[];return{...b,[I]:[...g.operations[I].map((rt,y)=>{var E;return{...rt,timestamp:((E=r[I][y])==null?void 0:E.timestamp)??rt.timestamp}}),...G]}},{global:[],local:[]}),w=Object.values(A).reduce((b,F)=>{for(const I of F)I.timestamp>b&&(b=I.timestamp);return b},i.lastModified);return{...g,operations:A,lastModified:w}}function Hr(i,r){return _t(i)===_t(r)}const $e=i=>lt("SET_NAME",i,void 0,qt,void 0),Ce=(i=1,r="global")=>lt("UNDO",i,void 0,Jt,r),ze=(i=1,r="global")=>lt("REDO",i,void 0,Pt,r),Me=(i,r,s="global")=>lt("PRUNE",{start:i,end:r},void 0,Lt,s),Xt=(i,r)=>lt("LOAD_STATE",{state:i,operations:r},void 0,Rt),Qt=(i="global")=>lt("NOOP",{},void 0,void 0,i),Zr=Object.freeze(Object.defineProperty({__proto__:null,loadState:Xt,noop:Qt,prune:Me,redo:ze,setName:$e,undo:Ce},Symbol.toStringTag,{value:"Module"})),Ne={"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(Ne);var tt=function(i,r,s,p){if(s==="a"&&!p)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?i!==r||!p:!r.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return s==="m"?p:s==="a"?p.call(i):p?p.value:r.get(i)},mt,dt,ct;class Gr{constructor(...r){mt.set(this,new Map),dt.set(this,new Map),ct.set(this,new Map);for(const s of r)this.define(s)}define(r,s=!1){for(let[p,f]of Object.entries(r)){p=p.toLowerCase(),f=f.map(a=>a.toLowerCase()),tt(this,ct,"f").has(p)||tt(this,ct,"f").set(p,new Set);const u=tt(this,ct,"f").get(p);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&&tt(this,dt,"f").set(p,a),l=!1,x)continue;const g=tt(this,mt,"f").get(a);if(g&&g!=p&&!s)throw new Error(`"${p} -> ${a}" conflicts with "${g} -> ${a}". Pass \`force=true\` to override this definition.`);tt(this,mt,"f").set(a,p)}}return this}getType(r){if(typeof r!="string")return null;const s=r.replace(/^.*[/\\]/,"").toLowerCase(),p=s.replace(/^.*\./,"").toLowerCase(),f=s.length<r.length;return!(p.length<s.length-1)&&f?null:tt(this,mt,"f").get(p)??null}getExtension(r){var s;return typeof r!="string"?null:(r=(s=r==null?void 0:r.split)==null?void 0:s.call(r,";")[0],(r&&tt(this,dt,"f").get(r.trim().toLowerCase()))??null)}getAllExtensions(r){return typeof r!="string"?null:tt(this,ct,"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 tt(this,ct,"f").values())Object.freeze(r);return this}_getTestState(){return{types:tt(this,mt,"f"),extensions:tt(this,dt,"f")}}}mt=new WeakMap,dt=new WeakMap,ct=new WeakMap;const Yr=new Gr(Ne)._freeze();function Re(i){const r=[],s=Object.keys(i);for(const p of s){const f=i[p].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 te=async i=>{const r=new ie,{name:s,revision:p,documentType:f,created:u,lastModified:l}=i,a={name:s,revision:p,documentType:f,created:u,lastModified:l};return r.file("header.json",JSON.stringify(a,null,2)),r.file("state.json",JSON.stringify(i.initialState||{},null,2)),r.file("operations.json",JSON.stringify(i.operations,null,2)),Object.keys(i.attachments).forEach(g=>{const{data:A,...w}=i.attachments[g];r.file(g,A,{base64:!0,createFolders:!0,comment:JSON.stringify(w)})}),r},Le=async(i,r,s,p)=>{await(await te(i)).generateAsync({type:"uint8array",streamFiles:!0});const u=p??i.name,l=`.${s}.zip`;return Pr(r,u.endsWith(l)?u:`${u}${l}`)},Xr=async(i,r)=>{const p=await(await te(i)).generateAsync({type:"blob"}),f=await r.createWritable();await f.write(p),await f.close()},Nt=async(i,r)=>{const s=Be();return Pe(s,r)},Pe=async(i,r)=>{const s=new ie;return await s.loadAsync(i),Qr(s,r)};async function Qr(i,r){const s=i.file("state.json");if(!s)throw new Error("Initial state not found");const p=await s.async("string"),f=JSON.parse(p),u=i.file("header.json");let l;u&&(l=JSON.parse(await u.async("string")));const a=i.file("operations.json");if(!a)throw new Error("Operations history not found");const x=JSON.parse(await a.async("string")),g=Re(x);if(g.length){const w=g.map(b=>b.message);throw new Error(w.join(`
25
+ `))}let A=Yt(f,x,r,void 0,l);return l&&(A={...A,...l}),A}function qe(i){const r=i.replace(/^.*\./,"")||void 0,s=i.replace(/^.*[/\\]/,"")||void 0;return{extension:r,fileName:s}}async function ti(i){const{buffer:r,mimeType:s="application/octet-stream"}=await qr(),p=qe(i),f=r.toString("base64");return{data:f,hash:It(f),mimeType:s,...p}}async function ei(i){const r=await Jr(),s=Yr.getType(i)||"application/octet-stream",p=qe(i),f=r.toString("base64");return{data:f,hash:It(f),mimeType:s,...p}}class ri{constructor(r,s,p){St(this,"_document");St(this,"_reducer");St(this,"_signalDispatch");this._reducer=r,this._document=s,this._signalDispatch=p}dispatch(r,s){return this._document=this._reducer(this._document,r,this._signalDispatch,s),this}saveToFile(r,s,p){return Le(this._document,r,s,p)}async loadFromFile(r){this._document=await Nt(r,this._reducer)}static async stateFromFile(r,s){return await Nt(r,s)}get state(){return xt(this._document.state)}get operations(){return xt(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 xt(this._document.initialState)}toDocument(){return xt(this._document)}getAttachment(r){return this._document.attachments[r]}setName(r){return this.dispatch($e(r)),this}undo(r){return this.dispatch(Ce(r)),this}redo(r){return this.dispatch(ze(r)),this}prune(r,s){return this.dispatch(Me(r,s)),this}loadState(r,s){return this.dispatch(Xt(r,s)),this}}function ii(i,r){r.forEach(s=>{Object.getOwnPropertyNames(s.prototype).forEach(p=>{Object.defineProperty(i.prototype,p,Object.getOwnPropertyDescriptor(s.prototype,p)||Object.create(null))})})}exports.BaseActions=Zr;exports.BaseDocument=ri;exports.applyMixins=ii;exports.baseReducer=Vt;exports.calculateSkipsLeft=De;exports.createAction=lt;exports.createDocument=Te;exports.createExtendedState=Ie;exports.createReducer=je;exports.createZip=te;exports.getLocalFile=ei;exports.getRemoteFile=ti;exports.hashDocument=Gt;exports.hashKey=Vr;exports.isBaseAction=Mt;exports.isNoopOperation=Oe;exports.isSameDocument=Hr;exports.isUndoRedo=zt;exports.loadFromFile=Nt;exports.loadFromInput=Pe;exports.mapSkippedOperations=ke;exports.processUndoRedo=we;exports.readOnly=xt;exports.replayDocument=Yt;exports.replayOperations=Ft;exports.saveToFile=Le;exports.saveToFileHandle=Xr;exports.sortMappedOperations=Ue;exports.sortOperations=Kr;exports.validateOperations=Re;exports.zod=Xe;