document-model 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/dist/browser/cjs/document-model.js +1 -1
  2. package/dist/browser/cjs/document.js +1 -1
  3. package/dist/browser/cjs/index.js +1 -1
  4. package/dist/browser/cjs/internal/{index-DGWOisRG.js → index-BtACFrMg.js} +1 -1
  5. package/dist/{node/cjs/internal/index-B96klT84.js → browser/cjs/internal/index-BtOQeyI_.js} +1 -1
  6. package/dist/browser/cjs/internal/{object-DQmy6ar9.js → object-eLa06mce.js} +1 -1
  7. package/dist/browser/es/document-model.js +2 -2
  8. package/dist/browser/es/document.js +2 -2
  9. package/dist/browser/es/index.js +3 -3
  10. package/dist/browser/es/internal/{index-DynAX_OS.js → index-CZutz9-u.js} +1 -1
  11. package/dist/{node/es/internal/index-DEAJDDrx.js → browser/es/internal/index-DPuk-_bv.js} +1 -1
  12. package/dist/browser/es/internal/{object-DenwvByi.js → object-Cxp6e1kN.js} +1 -1
  13. package/dist/node/cjs/document-model.js +1 -1
  14. package/dist/node/cjs/document.js +1 -1
  15. package/dist/node/cjs/index.js +1 -1
  16. package/dist/{browser/cjs/internal/index-Dl3D9TzG.js → node/cjs/internal/index-C2-dv_r8.js} +1 -1
  17. package/dist/node/cjs/internal/{index-CtqbrEO2.js → index-DPBQS8BC.js} +1 -1
  18. package/dist/node/cjs/internal/{object-CXx7IaXb.js → object-_P8Ctu09.js} +1 -1
  19. package/dist/node/es/document-model.js +2 -2
  20. package/dist/node/es/document.js +2 -2
  21. package/dist/node/es/index.js +3 -3
  22. package/dist/node/es/internal/{index-pNw-lk-q.js → index-CpzdJD_a.js} +1 -1
  23. package/dist/{browser/es/internal/index-BnpyOR6R.js → node/es/internal/index-O3hyddph.js} +1 -1
  24. package/dist/node/es/internal/{object-2jyfnUeK.js → object-BegIqJta.js} +1 -1
  25. package/package.json +1 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-DQmy6ar9.js");require("immer");require("jszip");const e=require("./internal/index-DGWOisRG.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-eLa06mce.js");require("immer");require("jszip");const e=require("./internal/index-BtACFrMg.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 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal/object-DQmy6ar9.js"),o=require("./internal/index-Dl3D9TzG.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.updateDocument=e.updateDocument;exports.updateHeader=e.updateHeader;exports.z=e.zod;exports.utils=o.index;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal/object-eLa06mce.js"),o=require("./internal/index-BtOQeyI_.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.updateDocument=e.updateDocument;exports.updateHeader=e.updateHeader;exports.z=e.zod;exports.utils=o.index;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./internal/index-Dl3D9TzG.js"),o=require("./internal/index-DGWOisRG.js");require("./internal/object-DQmy6ar9.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
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./internal/index-BtOQeyI_.js"),o=require("./internal/index-BtACFrMg.js");require("./internal/object-eLa06mce.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,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-DQmy6ar9.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:`{
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-eLa06mce.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 +1 @@
1
- "use strict";const e=require("./object-CXx7IaXb.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,documentHelpers:e.documentHelpers,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,parseResultingState:e.parseResultingState,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,updateDocument:e.updateDocument,updateHeader:e.updateHeader,utils:t,z:e.zod},Symbol.toStringTag,{value:"Module"}));exports.Document=o;exports.index=t;
1
+ "use strict";const e=require("./object-eLa06mce.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,documentHelpers:e.documentHelpers,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,parseResultingState:e.parseResultingState,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,updateDocument:e.updateDocument,updateHeader:e.updateHeader,utils:t,z:e.zod},Symbol.toStringTag,{value:"Module"}));exports.Document=o;exports.index=t;
@@ -21,5 +21,5 @@ ${C}`),v.pop(),`{${I}}`}case"number":return isFinite(m)?String(m):E?E(m):"null";
21
21
  *
22
22
  * @author Feross Aboukhadijeh <https://feross.org>
23
23
  * @license MIT
24
- */(function(i){var r=Tt,o=Yt,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 l=2147483647;i.kMaxLength=l,a.TYPED_ARRAY_SUPPORT=f(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function f(){try{var n=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(n,t),n.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function c(n){if(n>l)throw new RangeError('The value "'+n+'" is invalid for option "size"');var t=new Uint8Array(n);return Object.setPrototypeOf(t,a.prototype),t}function a(n,t,e){if(typeof n=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return b(n)}return h(n,t,e)}a.poolSize=8192;function h(n,t,e){if(typeof n=="string")return O(n,t);if(ArrayBuffer.isView(n))return U(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(nt(n,ArrayBuffer)||n&&nt(n.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(nt(n,SharedArrayBuffer)||n&&nt(n.buffer,SharedArrayBuffer)))return q(n,t,e);if(typeof n=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var s=n.valueOf&&n.valueOf();if(s!=null&&s!==n)return a.from(s,t,e);var u=Y(n);if(u)return u;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof n[Symbol.toPrimitive]=="function")return a.from(n[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n)}a.from=function(n,t,e){return h(n,t,e)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function g(n){if(typeof n!="number")throw new TypeError('"size" argument must be of type number');if(n<0)throw new RangeError('The value "'+n+'" is invalid for option "size"')}function y(n,t,e){return g(n),n<=0?c(n):t!==void 0?typeof e=="string"?c(n).fill(t,e):c(n).fill(t):c(n)}a.alloc=function(n,t,e){return y(n,t,e)};function b(n){return g(n),c(n<0?0:w(n)|0)}a.allocUnsafe=function(n){return b(n)},a.allocUnsafeSlow=function(n){return b(n)};function O(n,t){if((typeof t!="string"||t==="")&&(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var e=S(n,t)|0,s=c(e),u=s.write(n,t);return u!==e&&(s=s.slice(0,u)),s}function j(n){for(var t=n.length<0?0:w(n.length)|0,e=c(t),s=0;s<t;s+=1)e[s]=n[s]&255;return e}function U(n){if(nt(n,Uint8Array)){var t=new Uint8Array(n);return q(t.buffer,t.byteOffset,t.byteLength)}return j(n)}function q(n,t,e){if(t<0||n.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(n.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');var s;return t===void 0&&e===void 0?s=new Uint8Array(n):e===void 0?s=new Uint8Array(n,t):s=new Uint8Array(n,t,e),Object.setPrototypeOf(s,a.prototype),s}function Y(n){if(a.isBuffer(n)){var t=w(n.length)|0,e=c(t);return e.length===0||n.copy(e,0,0,t),e}if(n.length!==void 0)return typeof n.length!="number"||Nt(n.length)?c(0):j(n);if(n.type==="Buffer"&&Array.isArray(n.data))return j(n.data)}function w(n){if(n>=l)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+l.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(nt(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),nt(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var s=t.length,u=e.length,d=0,x=Math.min(s,u);d<x;++d)if(t[d]!==e[d]){s=t[d],u=e[d];break}return s<u?-1:u<s?1:0},a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return a.alloc(0);var s;if(e===void 0)for(e=0,s=0;s<t.length;++s)e+=t[s].length;var u=a.allocUnsafe(e),d=0;for(s=0;s<t.length;++s){var x=t[s];if(nt(x,Uint8Array))d+x.length>u.length?a.from(x).copy(u,d):Uint8Array.prototype.set.call(u,x,d);else if(a.isBuffer(x))x.copy(u,d);else throw new TypeError('"list" argument must be an Array of Buffers');d+=x.length}return u};function S(n,t){if(a.isBuffer(n))return n.length;if(ArrayBuffer.isView(n)||nt(n,ArrayBuffer))return n.byteLength;if(typeof n!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof n);var e=n.length,s=arguments.length>2&&arguments[2]===!0;if(!s&&e===0)return 0;for(var u=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return X(n).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return ut(n).length;default:if(u)return s?-1:X(n).length;t=(""+t).toLowerCase(),u=!0}}a.byteLength=S;function z(n,t,e){var s=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(n||(n="utf8");;)switch(n){case"hex":return A(this,t,e);case"utf8":case"utf-8":return m(this,t,e);case"ascii":return B(this,t,e);case"latin1":case"binary":return C(this,t,e);case"base64":return W(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,e);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),s=!0}}a.prototype._isBuffer=!0;function J(n,t,e){var s=n[t];n[t]=n[e],n[e]=s}a.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)J(this,e,e+1);return this},a.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)J(this,e,e+3),J(this,e+1,e+2);return this},a.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)J(this,e,e+7),J(this,e+1,e+6),J(this,e+2,e+5),J(this,e+3,e+4);return this},a.prototype.toString=function(){var t=this.length;return t===0?"":arguments.length===0?m(this,0,t):z.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,s,u,d){if(nt(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),s===void 0&&(s=t?t.length:0),u===void 0&&(u=0),d===void 0&&(d=this.length),e<0||s>t.length||u<0||d>this.length)throw new RangeError("out of range index");if(u>=d&&e>=s)return 0;if(u>=d)return-1;if(e>=s)return 1;if(e>>>=0,s>>>=0,u>>>=0,d>>>=0,this===t)return 0;for(var x=d-u,k=s-e,N=Math.min(x,k),L=this.slice(u,d),Z=t.slice(e,s),P=0;P<N;++P)if(L[P]!==Z[P]){x=L[P],k=Z[P];break}return x<k?-1:k<x?1:0};function V(n,t,e,s,u){if(n.length===0)return-1;if(typeof e=="string"?(s=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,Nt(e)&&(e=u?0:n.length-1),e<0&&(e=n.length+e),e>=n.length){if(u)return-1;e=n.length-1}else if(e<0)if(u)e=0;else return-1;if(typeof t=="string"&&(t=a.from(t,s)),a.isBuffer(t))return t.length===0?-1:M(n,t,e,s,u);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?u?Uint8Array.prototype.indexOf.call(n,t,e):Uint8Array.prototype.lastIndexOf.call(n,t,e):M(n,[t],e,s,u);throw new TypeError("val must be string, number or Buffer")}function M(n,t,e,s,u){var d=1,x=n.length,k=t.length;if(s!==void 0&&(s=String(s).toLowerCase(),s==="ucs2"||s==="ucs-2"||s==="utf16le"||s==="utf-16le")){if(n.length<2||t.length<2)return-1;d=2,x/=2,k/=2,e/=2}function N(ce,le){return d===1?ce[le]:ce.readUInt16BE(le*d)}var L;if(u){var Z=-1;for(L=e;L<x;L++)if(N(n,L)===N(t,Z===-1?0:L-Z)){if(Z===-1&&(Z=L),L-Z+1===k)return Z*d}else Z!==-1&&(L-=L-Z),Z=-1}else for(e+k>x&&(e=x-k),L=e;L>=0;L--){for(var P=!0,Ft=0;Ft<k;Ft++)if(N(n,L+Ft)!==N(t,Ft)){P=!1;break}if(P)return L}return-1}a.prototype.includes=function(t,e,s){return this.indexOf(t,e,s)!==-1},a.prototype.indexOf=function(t,e,s){return V(this,t,e,s,!0)},a.prototype.lastIndexOf=function(t,e,s){return V(this,t,e,s,!1)};function mt(n,t,e,s){e=Number(e)||0;var u=n.length-e;s?(s=Number(s),s>u&&(s=u)):s=u;var d=t.length;s>d/2&&(s=d/2);for(var x=0;x<s;++x){var k=parseInt(t.substr(x*2,2),16);if(Nt(k))return x;n[e+x]=k}return x}function dt(n,t,e,s){return Ot(X(t,n.length-e),n,e,s)}function ct(n,t,e,s){return Ot(tt(t),n,e,s)}function lt(n,t,e,s){return Ot(ut(t),n,e,s)}function $t(n,t,e,s){return Ot(et(t,n.length-e),n,e,s)}a.prototype.write=function(t,e,s,u){if(e===void 0)u="utf8",s=this.length,e=0;else if(s===void 0&&typeof e=="string")u=e,s=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(s)?(s=s>>>0,u===void 0&&(u="utf8")):(u=s,s=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var d=this.length-e;if((s===void 0||s>d)&&(s=d),t.length>0&&(s<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");u||(u="utf8");for(var x=!1;;)switch(u){case"hex":return mt(this,t,e,s);case"utf8":case"utf-8":return dt(this,t,e,s);case"ascii":case"latin1":case"binary":return ct(this,t,e,s);case"base64":return lt(this,t,e,s);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $t(this,t,e,s);default:if(x)throw new TypeError("Unknown encoding: "+u);u=(""+u).toLowerCase(),x=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function W(n,t,e){return t===0&&e===n.length?r.fromByteArray(n):r.fromByteArray(n.slice(t,e))}function m(n,t,e){e=Math.min(n.length,e);for(var s=[],u=t;u<e;){var d=n[u],x=null,k=d>239?4:d>223?3:d>191?2:1;if(u+k<=e){var N,L,Z,P;switch(k){case 1:d<128&&(x=d);break;case 2:N=n[u+1],(N&192)===128&&(P=(d&31)<<6|N&63,P>127&&(x=P));break;case 3:N=n[u+1],L=n[u+2],(N&192)===128&&(L&192)===128&&(P=(d&15)<<12|(N&63)<<6|L&63,P>2047&&(P<55296||P>57343)&&(x=P));break;case 4:N=n[u+1],L=n[u+2],Z=n[u+3],(N&192)===128&&(L&192)===128&&(Z&192)===128&&(P=(d&15)<<18|(N&63)<<12|(L&63)<<6|Z&63,P>65535&&P<1114112&&(x=P))}}x===null?(x=65533,k=1):x>65535&&(x-=65536,s.push(x>>>10&1023|55296),x=56320|x&1023),s.push(x),u+=k}return D(s)}var v=4096;function D(n){var t=n.length;if(t<=v)return String.fromCharCode.apply(String,n);for(var e="",s=0;s<t;)e+=String.fromCharCode.apply(String,n.slice(s,s+=v));return e}function B(n,t,e){var s="";e=Math.min(n.length,e);for(var u=t;u<e;++u)s+=String.fromCharCode(n[u]&127);return s}function C(n,t,e){var s="";e=Math.min(n.length,e);for(var u=t;u<e;++u)s+=String.fromCharCode(n[u]);return s}function A(n,t,e){var s=n.length;(!t||t<0)&&(t=0),(!e||e<0||e>s)&&(e=s);for(var u="",d=t;d<e;++d)u+=ri[n[d]];return u}function T(n,t,e){for(var s=n.slice(t,e),u="",d=0;d<s.length-1;d+=2)u+=String.fromCharCode(s[d]+s[d+1]*256);return u}a.prototype.slice=function(t,e){var s=this.length;t=~~t,e=e===void 0?s:~~e,t<0?(t+=s,t<0&&(t=0)):t>s&&(t=s),e<0?(e+=s,e<0&&(e=0)):e>s&&(e=s),e<t&&(e=t);var u=this.subarray(t,e);return Object.setPrototypeOf(u,a.prototype),u};function F(n,t,e){if(n%1!==0||n<0)throw new RangeError("offset is not uint");if(n+t>e)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(t,e,s){t=t>>>0,e=e>>>0,s||F(t,e,this.length);for(var u=this[t],d=1,x=0;++x<e&&(d*=256);)u+=this[t+x]*d;return u},a.prototype.readUintBE=a.prototype.readUIntBE=function(t,e,s){t=t>>>0,e=e>>>0,s||F(t,e,this.length);for(var u=this[t+--e],d=1;e>0&&(d*=256);)u+=this[t+--e]*d;return u},a.prototype.readUint8=a.prototype.readUInt8=function(t,e){return t=t>>>0,e||F(t,1,this.length),this[t]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||F(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||F(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||F(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||F(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,e,s){t=t>>>0,e=e>>>0,s||F(t,e,this.length);for(var u=this[t],d=1,x=0;++x<e&&(d*=256);)u+=this[t+x]*d;return d*=128,u>=d&&(u-=Math.pow(2,8*e)),u},a.prototype.readIntBE=function(t,e,s){t=t>>>0,e=e>>>0,s||F(t,e,this.length);for(var u=e,d=1,x=this[t+--u];u>0&&(d*=256);)x+=this[t+--u]*d;return d*=128,x>=d&&(x-=Math.pow(2,8*e)),x},a.prototype.readInt8=function(t,e){return t=t>>>0,e||F(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},a.prototype.readInt16LE=function(t,e){t=t>>>0,e||F(t,2,this.length);var s=this[t]|this[t+1]<<8;return s&32768?s|4294901760:s},a.prototype.readInt16BE=function(t,e){t=t>>>0,e||F(t,2,this.length);var s=this[t+1]|this[t]<<8;return s&32768?s|4294901760:s},a.prototype.readInt32LE=function(t,e){return t=t>>>0,e||F(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||F(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||F(t,4,this.length),o.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return t=t>>>0,e||F(t,4,this.length),o.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||F(t,8,this.length),o.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||F(t,8,this.length),o.read(this,t,!1,52,8)};function I(n,t,e,s,u,d){if(!a.isBuffer(n))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>u||t<d)throw new RangeError('"value" argument is out of bounds');if(e+s>n.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(t,e,s,u){if(t=+t,e=e>>>0,s=s>>>0,!u){var d=Math.pow(2,8*s)-1;I(this,t,e,s,d,0)}var x=1,k=0;for(this[e]=t&255;++k<s&&(x*=256);)this[e+k]=t/x&255;return e+s},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(t,e,s,u){if(t=+t,e=e>>>0,s=s>>>0,!u){var d=Math.pow(2,8*s)-1;I(this,t,e,s,d,0)}var x=s-1,k=1;for(this[e+x]=t&255;--x>=0&&(k*=256);)this[e+x]=t/k&255;return e+s},a.prototype.writeUint8=a.prototype.writeUInt8=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,1,255,0),this[e]=t&255,e+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4},a.prototype.writeIntLE=function(t,e,s,u){if(t=+t,e=e>>>0,!u){var d=Math.pow(2,8*s-1);I(this,t,e,s,d-1,-d)}var x=0,k=1,N=0;for(this[e]=t&255;++x<s&&(k*=256);)t<0&&N===0&&this[e+x-1]!==0&&(N=1),this[e+x]=(t/k>>0)-N&255;return e+s},a.prototype.writeIntBE=function(t,e,s,u){if(t=+t,e=e>>>0,!u){var d=Math.pow(2,8*s-1);I(this,t,e,s,d-1,-d)}var x=s-1,k=1,N=0;for(this[e+x]=t&255;--x>=0&&(k*=256);)t<0&&N===0&&this[e+x+1]!==0&&(N=1),this[e+x]=(t/k>>0)-N&255;return e+s},a.prototype.writeInt8=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1},a.prototype.writeInt16LE=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2},a.prototype.writeInt16BE=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2},a.prototype.writeInt32LE=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},a.prototype.writeInt32BE=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function R(n,t,e,s,u,d){if(e+s>n.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function H(n,t,e,s,u){return t=+t,e=e>>>0,u||R(n,t,e,4),o.write(n,t,e,s,23,4),e+4}a.prototype.writeFloatLE=function(t,e,s){return H(this,t,e,!0,s)},a.prototype.writeFloatBE=function(t,e,s){return H(this,t,e,!1,s)};function $(n,t,e,s,u){return t=+t,e=e>>>0,u||R(n,t,e,8),o.write(n,t,e,s,52,8),e+8}a.prototype.writeDoubleLE=function(t,e,s){return $(this,t,e,!0,s)},a.prototype.writeDoubleBE=function(t,e,s){return $(this,t,e,!1,s)},a.prototype.copy=function(t,e,s,u){if(!a.isBuffer(t))throw new TypeError("argument should be a Buffer");if(s||(s=0),!u&&u!==0&&(u=this.length),e>=t.length&&(e=t.length),e||(e=0),u>0&&u<s&&(u=s),u===s||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(s<0||s>=this.length)throw new RangeError("Index out of range");if(u<0)throw new RangeError("sourceEnd out of bounds");u>this.length&&(u=this.length),t.length-e<u-s&&(u=t.length-e+s);var d=u-s;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,s,u):Uint8Array.prototype.set.call(t,this.subarray(s,u),e),d},a.prototype.fill=function(t,e,s,u){if(typeof t=="string"){if(typeof e=="string"?(u=e,e=0,s=this.length):typeof s=="string"&&(u=s,s=this.length),u!==void 0&&typeof u!="string")throw new TypeError("encoding must be a string");if(typeof u=="string"&&!a.isEncoding(u))throw new TypeError("Unknown encoding: "+u);if(t.length===1){var d=t.charCodeAt(0);(u==="utf8"&&d<128||u==="latin1")&&(t=d)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<s)throw new RangeError("Out of range index");if(s<=e)return this;e=e>>>0,s=s===void 0?this.length:s>>>0,t||(t=0);var x;if(typeof t=="number")for(x=e;x<s;++x)this[x]=t;else{var k=a.isBuffer(t)?t:a.from(t,u),N=k.length;if(N===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(x=0;x<s-e;++x)this[x+e]=k[x%N]}return this};var K=/[^+/0-9A-Za-z-_]/g;function Q(n){if(n=n.split("=")[0],n=n.trim().replace(K,""),n.length<2)return"";for(;n.length%4!==0;)n=n+"=";return n}function X(n,t){t=t||1/0;for(var e,s=n.length,u=null,d=[],x=0;x<s;++x){if(e=n.charCodeAt(x),e>55295&&e<57344){if(!u){if(e>56319){(t-=3)>-1&&d.push(239,191,189);continue}else if(x+1===s){(t-=3)>-1&&d.push(239,191,189);continue}u=e;continue}if(e<56320){(t-=3)>-1&&d.push(239,191,189),u=e;continue}e=(u-55296<<10|e-56320)+65536}else u&&(t-=3)>-1&&d.push(239,191,189);if(u=null,e<128){if((t-=1)<0)break;d.push(e)}else if(e<2048){if((t-=2)<0)break;d.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;d.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;d.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return d}function tt(n){for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e)&255);return t}function et(n,t){for(var e,s,u,d=[],x=0;x<n.length&&!((t-=2)<0);++x)e=n.charCodeAt(x),s=e>>8,u=e%256,d.push(u),d.push(s);return d}function ut(n){return r.toByteArray(Q(n))}function Ot(n,t,e,s){for(var u=0;u<s&&!(u+e>=t.length||u>=n.length);++u)t[u+e]=n[u];return u}function nt(n,t){return n instanceof t||n!=null&&n.constructor!=null&&n.constructor.name!=null&&n.constructor.name===t.name}function Nt(n){return n!==n}var ri=function(){for(var n="0123456789abcdef",t=new Array(256),e=0;e<16;++e)for(var s=e*16,u=0;u<16;++u)t[s+u]=n[e]+n[u];return t}()})(je);/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(i,r){var o=je,p=o.Buffer;function l(c,a){for(var h in c)a[h]=c[h]}p.from&&p.alloc&&p.allocUnsafe&&p.allocUnsafeSlow?i.exports=o:(l(o,r),r.Buffer=f);function f(c,a,h){return p(c,a,h)}f.prototype=Object.create(p.prototype),l(p,f),f.from=function(c,a,h){if(typeof c=="number")throw new TypeError("Argument must not be a number");return p(c,a,h)},f.alloc=function(c,a,h){if(typeof c!="number")throw new TypeError("Argument must be a number");var g=p(c);return a!==void 0?typeof h=="string"?g.fill(a,h):g.fill(a):g.fill(0),g},f.allocUnsafe=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return p(c)},f.allocUnsafeSlow=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return o.SlowBuffer(c)}})(Pt,Pt.exports);var Qt=Pt.exports,Te=Qt.Buffer;function kt(i,r){this._block=Te.alloc(i),this._finalSize=r,this._blockSize=i,this._len=0}kt.prototype.update=function(i,r){typeof i=="string"&&(r=r||"utf8",i=Te.from(i,r));for(var o=this._block,p=this._blockSize,l=i.length,f=this._len,c=0;c<l;){for(var a=f%p,h=Math.min(l-c,p-a),g=0;g<h;g++)o[a+g]=i[c+g];f+=h,c+=h,f%p===0&&this._update(o)}return this._len+=l,this};kt.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 o=this._len*8;if(o<=4294967295)this._block.writeUInt32BE(o,this._blockSize-4);else{var p=(o&4294967295)>>>0,l=(o-p)/4294967296;this._block.writeUInt32BE(l,this._blockSize-8),this._block.writeUInt32BE(p,this._blockSize-4)}this._update(this._block);var f=this._hash();return i?f.toString(i):f};kt.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var ke=kt,Ui=Ie,Ue=ke,Ci=Qt.Buffer,$i=[1518500249,1859775393,-1894007588,-899497514],Ni=new Array(80);function _t(){this.init(),this._w=Ni,Ue.call(this,64,56)}Ui(_t,Ue);_t.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function zi(i){return i<<1|i>>>31}function Mi(i){return i<<5|i>>>27}function Ri(i){return i<<30|i>>>2}function Li(i,r,o,p){return i===0?r&o|~r&p:i===2?r&o|r&p|o&p:r^o^p}_t.prototype._update=function(i){for(var r=this._w,o=this._a|0,p=this._b|0,l=this._c|0,f=this._d|0,c=this._e|0,a=0;a<16;++a)r[a]=i.readInt32BE(a*4);for(;a<80;++a)r[a]=zi(r[a-3]^r[a-8]^r[a-14]^r[a-16]);for(var h=0;h<80;++h){var g=~~(h/20),y=Mi(o)+Li(g,p,l,f)+c+r[h]+$i[g]|0;c=f,f=l,l=Ri(p),p=o,o=y}this._a=o+this._a|0,this._b=p+this._b|0,this._c=l+this._c|0,this._d=f+this._d|0,this._e=c+this._e|0};_t.prototype._hash=function(){var i=Ci.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 Pi=_t;const qi=Zt(Pi);var Hi=Ie,Ce=ke,Ji=Qt.Buffer,Vi=[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],Wi=new Array(64);function At(){this.init(),this._w=Wi,Ce.call(this,64,56)}Hi(At,Ce);At.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 Xi(i,r,o){return o^i&(r^o)}function Ki(i,r,o){return i&r|o&(i|r)}function Gi(i){return(i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10)}function Zi(i){return(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7)}function Yi(i){return(i>>>7|i<<25)^(i>>>18|i<<14)^i>>>3}function Qi(i){return(i>>>17|i<<15)^(i>>>19|i<<13)^i>>>10}At.prototype._update=function(i){for(var r=this._w,o=this._a|0,p=this._b|0,l=this._c|0,f=this._d|0,c=this._e|0,a=this._f|0,h=this._g|0,g=this._h|0,y=0;y<16;++y)r[y]=i.readInt32BE(y*4);for(;y<64;++y)r[y]=Qi(r[y-2])+r[y-7]+Yi(r[y-15])+r[y-16]|0;for(var b=0;b<64;++b){var O=g+Zi(c)+Xi(c,a,h)+Vi[b]+r[b]|0,j=Gi(o)+Ki(o,p,l)|0;g=h,h=a,a=c,c=f+O|0,f=l,l=p,p=o,o=O+j|0}this._a=o+this._a|0,this._b=p+this._b|0,this._c=l+this._c|0,this._d=f+this._d|0,this._e=c+this._e|0,this._f=a+this._f|0,this._g=h+this._g|0,this._h=g+this._h|0};At.prototype._hash=function(){var i=Ji.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 tr=At;const er=Zt(tr),te=new Error("File system not available.");function ir(i,r,o){throw te}function $e(i){throw te}function rr(i){throw te}const nr=async i=>$e(),or={sha1:qi,sha256:er},Ut=(i,r="sha1")=>{if(!["sha1","sha256"].includes(r))throw new Error("Hashing algorithm not supported: Available: sha1, sha256");const o=or[r];return new o().update(i).digest("base64")};function Ne(i){const r=[],o=Object.keys(i);for(const p of o){const l=i[p].sort((f,c)=>f.index-c.index);for(let f=0;f<l.length;f++)l[f].index!==f&&r.push({message:`Invalid operation index ${l[f].index} at position ${f}`,details:{position:f,operation:l[f],scope:l[f].scope}})}return r}const ee=async i=>{const r=new fe,{name:o,revision:p,documentType:l,created:f,lastModified:c}=i,a={name:o,revision:p,documentType:l,created:f,lastModified:c};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:y,...b}=i.attachments[g];r.file(g,y,{base64:!0,createFolders:!0,comment:JSON.stringify(b)})}),r},ze=async(i,r,o,p)=>{await(await ee(i)).generateAsync({type:"uint8array",streamFiles:!0});const f=p??i.name,c=`.${o}.zip`;return ir(r,f.endsWith(c)?f:`${f}${c}`)},ar=async(i,r)=>{const p=await(await ee(i)).generateAsync({type:"blob"}),l=await r.createWritable();await l.write(p),await l.close()},qt=async(i,r,o)=>{const p=$e();return Me(p,r,o)},Me=async(i,r,o)=>{const p=new fe;return await p.loadAsync(i),sr(p,r,o)};async function sr(i,r,o){const p=i.file("state.json");if(!p)throw new Error("Initial state not found");const l=await p.async("string"),f=JSON.parse(l),c=i.file("header.json");let a;c&&(a=JSON.parse(await c.async("string")));const h=i.file("operations.json");if(!h)throw new Error("Operations history not found");const g=JSON.parse(await h.async("string")),y=Ne(g);if(y.length){const O=y.map(j=>j.message);throw new Error(O.join(`
24
+ */(function(i){var r=Tt,o=Yt,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 l=2147483647;i.kMaxLength=l,a.TYPED_ARRAY_SUPPORT=f(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function f(){try{var n=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(n,t),n.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function c(n){if(n>l)throw new RangeError('The value "'+n+'" is invalid for option "size"');var t=new Uint8Array(n);return Object.setPrototypeOf(t,a.prototype),t}function a(n,t,e){if(typeof n=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return b(n)}return h(n,t,e)}a.poolSize=8192;function h(n,t,e){if(typeof n=="string")return O(n,t);if(ArrayBuffer.isView(n))return U(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(nt(n,ArrayBuffer)||n&&nt(n.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(nt(n,SharedArrayBuffer)||n&&nt(n.buffer,SharedArrayBuffer)))return q(n,t,e);if(typeof n=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var s=n.valueOf&&n.valueOf();if(s!=null&&s!==n)return a.from(s,t,e);var u=Y(n);if(u)return u;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof n[Symbol.toPrimitive]=="function")return a.from(n[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n)}a.from=function(n,t,e){return h(n,t,e)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function g(n){if(typeof n!="number")throw new TypeError('"size" argument must be of type number');if(n<0)throw new RangeError('The value "'+n+'" is invalid for option "size"')}function y(n,t,e){return g(n),n<=0?c(n):t!==void 0?typeof e=="string"?c(n).fill(t,e):c(n).fill(t):c(n)}a.alloc=function(n,t,e){return y(n,t,e)};function b(n){return g(n),c(n<0?0:w(n)|0)}a.allocUnsafe=function(n){return b(n)},a.allocUnsafeSlow=function(n){return b(n)};function O(n,t){if((typeof t!="string"||t==="")&&(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var e=S(n,t)|0,s=c(e),u=s.write(n,t);return u!==e&&(s=s.slice(0,u)),s}function j(n){for(var t=n.length<0?0:w(n.length)|0,e=c(t),s=0;s<t;s+=1)e[s]=n[s]&255;return e}function U(n){if(nt(n,Uint8Array)){var t=new Uint8Array(n);return q(t.buffer,t.byteOffset,t.byteLength)}return j(n)}function q(n,t,e){if(t<0||n.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(n.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');var s;return t===void 0&&e===void 0?s=new Uint8Array(n):e===void 0?s=new Uint8Array(n,t):s=new Uint8Array(n,t,e),Object.setPrototypeOf(s,a.prototype),s}function Y(n){if(a.isBuffer(n)){var t=w(n.length)|0,e=c(t);return e.length===0||n.copy(e,0,0,t),e}if(n.length!==void 0)return typeof n.length!="number"||Nt(n.length)?c(0):j(n);if(n.type==="Buffer"&&Array.isArray(n.data))return j(n.data)}function w(n){if(n>=l)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+l.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(nt(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),nt(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var s=t.length,u=e.length,d=0,x=Math.min(s,u);d<x;++d)if(t[d]!==e[d]){s=t[d],u=e[d];break}return s<u?-1:u<s?1:0},a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return a.alloc(0);var s;if(e===void 0)for(e=0,s=0;s<t.length;++s)e+=t[s].length;var u=a.allocUnsafe(e),d=0;for(s=0;s<t.length;++s){var x=t[s];if(nt(x,Uint8Array))d+x.length>u.length?a.from(x).copy(u,d):Uint8Array.prototype.set.call(u,x,d);else if(a.isBuffer(x))x.copy(u,d);else throw new TypeError('"list" argument must be an Array of Buffers');d+=x.length}return u};function S(n,t){if(a.isBuffer(n))return n.length;if(ArrayBuffer.isView(n)||nt(n,ArrayBuffer))return n.byteLength;if(typeof n!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof n);var e=n.length,s=arguments.length>2&&arguments[2]===!0;if(!s&&e===0)return 0;for(var u=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return X(n).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return ut(n).length;default:if(u)return s?-1:X(n).length;t=(""+t).toLowerCase(),u=!0}}a.byteLength=S;function z(n,t,e){var s=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(n||(n="utf8");;)switch(n){case"hex":return A(this,t,e);case"utf8":case"utf-8":return m(this,t,e);case"ascii":return B(this,t,e);case"latin1":case"binary":return C(this,t,e);case"base64":return W(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,e);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),s=!0}}a.prototype._isBuffer=!0;function J(n,t,e){var s=n[t];n[t]=n[e],n[e]=s}a.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)J(this,e,e+1);return this},a.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)J(this,e,e+3),J(this,e+1,e+2);return this},a.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)J(this,e,e+7),J(this,e+1,e+6),J(this,e+2,e+5),J(this,e+3,e+4);return this},a.prototype.toString=function(){var t=this.length;return t===0?"":arguments.length===0?m(this,0,t):z.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,s,u,d){if(nt(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),s===void 0&&(s=t?t.length:0),u===void 0&&(u=0),d===void 0&&(d=this.length),e<0||s>t.length||u<0||d>this.length)throw new RangeError("out of range index");if(u>=d&&e>=s)return 0;if(u>=d)return-1;if(e>=s)return 1;if(e>>>=0,s>>>=0,u>>>=0,d>>>=0,this===t)return 0;for(var x=d-u,k=s-e,N=Math.min(x,k),L=this.slice(u,d),Z=t.slice(e,s),P=0;P<N;++P)if(L[P]!==Z[P]){x=L[P],k=Z[P];break}return x<k?-1:k<x?1:0};function V(n,t,e,s,u){if(n.length===0)return-1;if(typeof e=="string"?(s=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,Nt(e)&&(e=u?0:n.length-1),e<0&&(e=n.length+e),e>=n.length){if(u)return-1;e=n.length-1}else if(e<0)if(u)e=0;else return-1;if(typeof t=="string"&&(t=a.from(t,s)),a.isBuffer(t))return t.length===0?-1:M(n,t,e,s,u);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?u?Uint8Array.prototype.indexOf.call(n,t,e):Uint8Array.prototype.lastIndexOf.call(n,t,e):M(n,[t],e,s,u);throw new TypeError("val must be string, number or Buffer")}function M(n,t,e,s,u){var d=1,x=n.length,k=t.length;if(s!==void 0&&(s=String(s).toLowerCase(),s==="ucs2"||s==="ucs-2"||s==="utf16le"||s==="utf-16le")){if(n.length<2||t.length<2)return-1;d=2,x/=2,k/=2,e/=2}function N(ce,le){return d===1?ce[le]:ce.readUInt16BE(le*d)}var L;if(u){var Z=-1;for(L=e;L<x;L++)if(N(n,L)===N(t,Z===-1?0:L-Z)){if(Z===-1&&(Z=L),L-Z+1===k)return Z*d}else Z!==-1&&(L-=L-Z),Z=-1}else for(e+k>x&&(e=x-k),L=e;L>=0;L--){for(var P=!0,Ft=0;Ft<k;Ft++)if(N(n,L+Ft)!==N(t,Ft)){P=!1;break}if(P)return L}return-1}a.prototype.includes=function(t,e,s){return this.indexOf(t,e,s)!==-1},a.prototype.indexOf=function(t,e,s){return V(this,t,e,s,!0)},a.prototype.lastIndexOf=function(t,e,s){return V(this,t,e,s,!1)};function mt(n,t,e,s){e=Number(e)||0;var u=n.length-e;s?(s=Number(s),s>u&&(s=u)):s=u;var d=t.length;s>d/2&&(s=d/2);for(var x=0;x<s;++x){var k=parseInt(t.substr(x*2,2),16);if(Nt(k))return x;n[e+x]=k}return x}function dt(n,t,e,s){return Ot(X(t,n.length-e),n,e,s)}function ct(n,t,e,s){return Ot(tt(t),n,e,s)}function lt(n,t,e,s){return Ot(ut(t),n,e,s)}function $t(n,t,e,s){return Ot(et(t,n.length-e),n,e,s)}a.prototype.write=function(t,e,s,u){if(e===void 0)u="utf8",s=this.length,e=0;else if(s===void 0&&typeof e=="string")u=e,s=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(s)?(s=s>>>0,u===void 0&&(u="utf8")):(u=s,s=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var d=this.length-e;if((s===void 0||s>d)&&(s=d),t.length>0&&(s<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");u||(u="utf8");for(var x=!1;;)switch(u){case"hex":return mt(this,t,e,s);case"utf8":case"utf-8":return dt(this,t,e,s);case"ascii":case"latin1":case"binary":return ct(this,t,e,s);case"base64":return lt(this,t,e,s);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $t(this,t,e,s);default:if(x)throw new TypeError("Unknown encoding: "+u);u=(""+u).toLowerCase(),x=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function W(n,t,e){return t===0&&e===n.length?r.fromByteArray(n):r.fromByteArray(n.slice(t,e))}function m(n,t,e){e=Math.min(n.length,e);for(var s=[],u=t;u<e;){var d=n[u],x=null,k=d>239?4:d>223?3:d>191?2:1;if(u+k<=e){var N,L,Z,P;switch(k){case 1:d<128&&(x=d);break;case 2:N=n[u+1],(N&192)===128&&(P=(d&31)<<6|N&63,P>127&&(x=P));break;case 3:N=n[u+1],L=n[u+2],(N&192)===128&&(L&192)===128&&(P=(d&15)<<12|(N&63)<<6|L&63,P>2047&&(P<55296||P>57343)&&(x=P));break;case 4:N=n[u+1],L=n[u+2],Z=n[u+3],(N&192)===128&&(L&192)===128&&(Z&192)===128&&(P=(d&15)<<18|(N&63)<<12|(L&63)<<6|Z&63,P>65535&&P<1114112&&(x=P))}}x===null?(x=65533,k=1):x>65535&&(x-=65536,s.push(x>>>10&1023|55296),x=56320|x&1023),s.push(x),u+=k}return D(s)}var v=4096;function D(n){var t=n.length;if(t<=v)return String.fromCharCode.apply(String,n);for(var e="",s=0;s<t;)e+=String.fromCharCode.apply(String,n.slice(s,s+=v));return e}function B(n,t,e){var s="";e=Math.min(n.length,e);for(var u=t;u<e;++u)s+=String.fromCharCode(n[u]&127);return s}function C(n,t,e){var s="";e=Math.min(n.length,e);for(var u=t;u<e;++u)s+=String.fromCharCode(n[u]);return s}function A(n,t,e){var s=n.length;(!t||t<0)&&(t=0),(!e||e<0||e>s)&&(e=s);for(var u="",d=t;d<e;++d)u+=ri[n[d]];return u}function T(n,t,e){for(var s=n.slice(t,e),u="",d=0;d<s.length-1;d+=2)u+=String.fromCharCode(s[d]+s[d+1]*256);return u}a.prototype.slice=function(t,e){var s=this.length;t=~~t,e=e===void 0?s:~~e,t<0?(t+=s,t<0&&(t=0)):t>s&&(t=s),e<0?(e+=s,e<0&&(e=0)):e>s&&(e=s),e<t&&(e=t);var u=this.subarray(t,e);return Object.setPrototypeOf(u,a.prototype),u};function F(n,t,e){if(n%1!==0||n<0)throw new RangeError("offset is not uint");if(n+t>e)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(t,e,s){t=t>>>0,e=e>>>0,s||F(t,e,this.length);for(var u=this[t],d=1,x=0;++x<e&&(d*=256);)u+=this[t+x]*d;return u},a.prototype.readUintBE=a.prototype.readUIntBE=function(t,e,s){t=t>>>0,e=e>>>0,s||F(t,e,this.length);for(var u=this[t+--e],d=1;e>0&&(d*=256);)u+=this[t+--e]*d;return u},a.prototype.readUint8=a.prototype.readUInt8=function(t,e){return t=t>>>0,e||F(t,1,this.length),this[t]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||F(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||F(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||F(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||F(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,e,s){t=t>>>0,e=e>>>0,s||F(t,e,this.length);for(var u=this[t],d=1,x=0;++x<e&&(d*=256);)u+=this[t+x]*d;return d*=128,u>=d&&(u-=Math.pow(2,8*e)),u},a.prototype.readIntBE=function(t,e,s){t=t>>>0,e=e>>>0,s||F(t,e,this.length);for(var u=e,d=1,x=this[t+--u];u>0&&(d*=256);)x+=this[t+--u]*d;return d*=128,x>=d&&(x-=Math.pow(2,8*e)),x},a.prototype.readInt8=function(t,e){return t=t>>>0,e||F(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},a.prototype.readInt16LE=function(t,e){t=t>>>0,e||F(t,2,this.length);var s=this[t]|this[t+1]<<8;return s&32768?s|4294901760:s},a.prototype.readInt16BE=function(t,e){t=t>>>0,e||F(t,2,this.length);var s=this[t+1]|this[t]<<8;return s&32768?s|4294901760:s},a.prototype.readInt32LE=function(t,e){return t=t>>>0,e||F(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||F(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||F(t,4,this.length),o.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return t=t>>>0,e||F(t,4,this.length),o.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||F(t,8,this.length),o.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||F(t,8,this.length),o.read(this,t,!1,52,8)};function I(n,t,e,s,u,d){if(!a.isBuffer(n))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>u||t<d)throw new RangeError('"value" argument is out of bounds');if(e+s>n.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(t,e,s,u){if(t=+t,e=e>>>0,s=s>>>0,!u){var d=Math.pow(2,8*s)-1;I(this,t,e,s,d,0)}var x=1,k=0;for(this[e]=t&255;++k<s&&(x*=256);)this[e+k]=t/x&255;return e+s},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(t,e,s,u){if(t=+t,e=e>>>0,s=s>>>0,!u){var d=Math.pow(2,8*s)-1;I(this,t,e,s,d,0)}var x=s-1,k=1;for(this[e+x]=t&255;--x>=0&&(k*=256);)this[e+x]=t/k&255;return e+s},a.prototype.writeUint8=a.prototype.writeUInt8=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,1,255,0),this[e]=t&255,e+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4},a.prototype.writeIntLE=function(t,e,s,u){if(t=+t,e=e>>>0,!u){var d=Math.pow(2,8*s-1);I(this,t,e,s,d-1,-d)}var x=0,k=1,N=0;for(this[e]=t&255;++x<s&&(k*=256);)t<0&&N===0&&this[e+x-1]!==0&&(N=1),this[e+x]=(t/k>>0)-N&255;return e+s},a.prototype.writeIntBE=function(t,e,s,u){if(t=+t,e=e>>>0,!u){var d=Math.pow(2,8*s-1);I(this,t,e,s,d-1,-d)}var x=s-1,k=1,N=0;for(this[e+x]=t&255;--x>=0&&(k*=256);)t<0&&N===0&&this[e+x+1]!==0&&(N=1),this[e+x]=(t/k>>0)-N&255;return e+s},a.prototype.writeInt8=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1},a.prototype.writeInt16LE=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2},a.prototype.writeInt16BE=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2},a.prototype.writeInt32LE=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},a.prototype.writeInt32BE=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function R(n,t,e,s,u,d){if(e+s>n.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function H(n,t,e,s,u){return t=+t,e=e>>>0,u||R(n,t,e,4),o.write(n,t,e,s,23,4),e+4}a.prototype.writeFloatLE=function(t,e,s){return H(this,t,e,!0,s)},a.prototype.writeFloatBE=function(t,e,s){return H(this,t,e,!1,s)};function $(n,t,e,s,u){return t=+t,e=e>>>0,u||R(n,t,e,8),o.write(n,t,e,s,52,8),e+8}a.prototype.writeDoubleLE=function(t,e,s){return $(this,t,e,!0,s)},a.prototype.writeDoubleBE=function(t,e,s){return $(this,t,e,!1,s)},a.prototype.copy=function(t,e,s,u){if(!a.isBuffer(t))throw new TypeError("argument should be a Buffer");if(s||(s=0),!u&&u!==0&&(u=this.length),e>=t.length&&(e=t.length),e||(e=0),u>0&&u<s&&(u=s),u===s||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(s<0||s>=this.length)throw new RangeError("Index out of range");if(u<0)throw new RangeError("sourceEnd out of bounds");u>this.length&&(u=this.length),t.length-e<u-s&&(u=t.length-e+s);var d=u-s;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,s,u):Uint8Array.prototype.set.call(t,this.subarray(s,u),e),d},a.prototype.fill=function(t,e,s,u){if(typeof t=="string"){if(typeof e=="string"?(u=e,e=0,s=this.length):typeof s=="string"&&(u=s,s=this.length),u!==void 0&&typeof u!="string")throw new TypeError("encoding must be a string");if(typeof u=="string"&&!a.isEncoding(u))throw new TypeError("Unknown encoding: "+u);if(t.length===1){var d=t.charCodeAt(0);(u==="utf8"&&d<128||u==="latin1")&&(t=d)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<s)throw new RangeError("Out of range index");if(s<=e)return this;e=e>>>0,s=s===void 0?this.length:s>>>0,t||(t=0);var x;if(typeof t=="number")for(x=e;x<s;++x)this[x]=t;else{var k=a.isBuffer(t)?t:a.from(t,u),N=k.length;if(N===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(x=0;x<s-e;++x)this[x+e]=k[x%N]}return this};var K=/[^+/0-9A-Za-z-_]/g;function Q(n){if(n=n.split("=")[0],n=n.trim().replace(K,""),n.length<2)return"";for(;n.length%4!==0;)n=n+"=";return n}function X(n,t){t=t||1/0;for(var e,s=n.length,u=null,d=[],x=0;x<s;++x){if(e=n.charCodeAt(x),e>55295&&e<57344){if(!u){if(e>56319){(t-=3)>-1&&d.push(239,191,189);continue}else if(x+1===s){(t-=3)>-1&&d.push(239,191,189);continue}u=e;continue}if(e<56320){(t-=3)>-1&&d.push(239,191,189),u=e;continue}e=(u-55296<<10|e-56320)+65536}else u&&(t-=3)>-1&&d.push(239,191,189);if(u=null,e<128){if((t-=1)<0)break;d.push(e)}else if(e<2048){if((t-=2)<0)break;d.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;d.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;d.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return d}function tt(n){for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e)&255);return t}function et(n,t){for(var e,s,u,d=[],x=0;x<n.length&&!((t-=2)<0);++x)e=n.charCodeAt(x),s=e>>8,u=e%256,d.push(u),d.push(s);return d}function ut(n){return r.toByteArray(Q(n))}function Ot(n,t,e,s){for(var u=0;u<s&&!(u+e>=t.length||u>=n.length);++u)t[u+e]=n[u];return u}function nt(n,t){return n instanceof t||n!=null&&n.constructor!=null&&n.constructor.name!=null&&n.constructor.name===t.name}function Nt(n){return n!==n}var ri=function(){for(var n="0123456789abcdef",t=new Array(256),e=0;e<16;++e)for(var s=e*16,u=0;u<16;++u)t[s+u]=n[e]+n[u];return t}()})(je);/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(i,r){var o=je,p=o.Buffer;function l(c,a){for(var h in c)a[h]=c[h]}p.from&&p.alloc&&p.allocUnsafe&&p.allocUnsafeSlow?i.exports=o:(l(o,r),r.Buffer=f);function f(c,a,h){return p(c,a,h)}f.prototype=Object.create(p.prototype),l(p,f),f.from=function(c,a,h){if(typeof c=="number")throw new TypeError("Argument must not be a number");return p(c,a,h)},f.alloc=function(c,a,h){if(typeof c!="number")throw new TypeError("Argument must be a number");var g=p(c);return a!==void 0?typeof h=="string"?g.fill(a,h):g.fill(a):g.fill(0),g},f.allocUnsafe=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return p(c)},f.allocUnsafeSlow=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return o.SlowBuffer(c)}})(Pt,Pt.exports);var Qt=Pt.exports,Te=Qt.Buffer;function kt(i,r){this._block=Te.alloc(i),this._finalSize=r,this._blockSize=i,this._len=0}kt.prototype.update=function(i,r){typeof i=="string"&&(r=r||"utf8",i=Te.from(i,r));for(var o=this._block,p=this._blockSize,l=i.length,f=this._len,c=0;c<l;){for(var a=f%p,h=Math.min(l-c,p-a),g=0;g<h;g++)o[a+g]=i[c+g];f+=h,c+=h,f%p===0&&this._update(o)}return this._len+=l,this};kt.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 o=this._len*8;if(o<=4294967295)this._block.writeUInt32BE(o,this._blockSize-4);else{var p=(o&4294967295)>>>0,l=(o-p)/4294967296;this._block.writeUInt32BE(l,this._blockSize-8),this._block.writeUInt32BE(p,this._blockSize-4)}this._update(this._block);var f=this._hash();return i?f.toString(i):f};kt.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var ke=kt,Ui=Ie,Ue=ke,Ci=Qt.Buffer,$i=[1518500249,1859775393,-1894007588,-899497514],Ni=new Array(80);function _t(){this.init(),this._w=Ni,Ue.call(this,64,56)}Ui(_t,Ue);_t.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function zi(i){return i<<1|i>>>31}function Mi(i){return i<<5|i>>>27}function Ri(i){return i<<30|i>>>2}function Li(i,r,o,p){return i===0?r&o|~r&p:i===2?r&o|r&p|o&p:r^o^p}_t.prototype._update=function(i){for(var r=this._w,o=this._a|0,p=this._b|0,l=this._c|0,f=this._d|0,c=this._e|0,a=0;a<16;++a)r[a]=i.readInt32BE(a*4);for(;a<80;++a)r[a]=zi(r[a-3]^r[a-8]^r[a-14]^r[a-16]);for(var h=0;h<80;++h){var g=~~(h/20),y=Mi(o)+Li(g,p,l,f)+c+r[h]+$i[g]|0;c=f,f=l,l=Ri(p),p=o,o=y}this._a=o+this._a|0,this._b=p+this._b|0,this._c=l+this._c|0,this._d=f+this._d|0,this._e=c+this._e|0};_t.prototype._hash=function(){var i=Ci.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 Pi=_t;const qi=Zt(Pi);var Hi=Ie,Ce=ke,Ji=Qt.Buffer,Vi=[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],Wi=new Array(64);function At(){this.init(),this._w=Wi,Ce.call(this,64,56)}Hi(At,Ce);At.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 Xi(i,r,o){return o^i&(r^o)}function Ki(i,r,o){return i&r|o&(i|r)}function Gi(i){return(i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10)}function Zi(i){return(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7)}function Yi(i){return(i>>>7|i<<25)^(i>>>18|i<<14)^i>>>3}function Qi(i){return(i>>>17|i<<15)^(i>>>19|i<<13)^i>>>10}At.prototype._update=function(i){for(var r=this._w,o=this._a|0,p=this._b|0,l=this._c|0,f=this._d|0,c=this._e|0,a=this._f|0,h=this._g|0,g=this._h|0,y=0;y<16;++y)r[y]=i.readInt32BE(y*4);for(;y<64;++y)r[y]=Qi(r[y-2])+r[y-7]+Yi(r[y-15])+r[y-16]|0;for(var b=0;b<64;++b){var O=g+Zi(c)+Xi(c,a,h)+Vi[b]+r[b]|0,j=Gi(o)+Ki(o,p,l)|0;g=h,h=a,a=c,c=f+O|0,f=l,l=p,p=o,o=O+j|0}this._a=o+this._a|0,this._b=p+this._b|0,this._c=l+this._c|0,this._d=f+this._d|0,this._e=c+this._e|0,this._f=a+this._f|0,this._g=h+this._g|0,this._h=g+this._h|0};At.prototype._hash=function(){var i=Ji.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 tr=At;const er=Zt(tr),te=new Error("File system not available.");function ir(i,r,o){throw te}function $e(i){throw te}function rr(i){throw te}const nr=async i=>$e(),or={sha1:qi,sha256:er},Ut=(i,r="sha1")=>{if(!["sha1","sha256"].includes(r))throw new Error("Hashing algorithm not supported: Available: sha1, sha256");const o=or[r];return new o().update(i).digest("base64")};function Ne(i){const r=[],o=Object.keys(i);for(const p of o){const l=i[p].sort((f,c)=>f.index-c.index);for(let f=0;f<l.length;f++)l[f].index!==f&&r.push({message:`Invalid operation index ${l[f].index} at position ${f}`,details:{position:f,operation:l[f],scope:l[f].scope}})}return r}const ee=async i=>{const r=new fe,{name:o,revision:p,documentType:l,created:f,lastModified:c}=i,a={name:o,revision:p,documentType:l,created:f,lastModified:c};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)),i.attachments&&Object.keys(i.attachments).forEach(g=>{const{data:y,...b}=i.attachments[g];r.file(g,y,{base64:!0,createFolders:!0,comment:JSON.stringify(b)})}),r},ze=async(i,r,o,p)=>{await(await ee(i)).generateAsync({type:"uint8array",streamFiles:!0});const f=p??i.name,c=`.${o}.zip`;return ir(r,f.endsWith(c)?f:`${f}${c}`)},ar=async(i,r)=>{const p=await(await ee(i)).generateAsync({type:"blob"}),l=await r.createWritable();await l.write(p),await l.close()},qt=async(i,r,o)=>{const p=$e();return Me(p,r,o)},Me=async(i,r,o)=>{const p=new fe;return await p.loadAsync(i),sr(p,r,o)};async function sr(i,r,o){const p=i.file("state.json");if(!p)throw new Error("Initial state not found");const l=await p.async("string"),f=JSON.parse(l),c=i.file("header.json");let a;c&&(a=JSON.parse(await c.async("string")));const h=i.file("operations.json");if(!h)throw new Error("Operations history not found");const g=JSON.parse(await h.async("string")),y=Ne(g);if(y.length){const O=y.map(j=>j.message);throw new Error(O.join(`
25
25
  `))}let b=ae(f,g,r,void 0,a,{},o);return a&&(b={...b,...a}),b}function Re(i){const r=i.replace(/^.*\./,"")||void 0,o=i.replace(/^.*[/\\]/,"")||void 0;return{extension:r,fileName:o}}async function pr(i){const{buffer:r,mimeType:o="application/octet-stream"}=await rr(),p=Re(i),l=r.toString("base64");return{data:l,hash:Ut(l),mimeType:o,...p}}async function cr(i){const r=await nr(),o=Ai.getType(i)||"application/octet-stream",p=Re(i),l=r.toString("base64");return{data:l,hash:Ut(l),mimeType:o,...p}}var Le=(i=>(i.UNEXPECTED_INDEX="UNEXPECTED_INDEX",i))(Le||{}),Pe=(i=>(i.DUPLICATED_INDEX="DUPLICATED_INDEX",i.MISSING_INDEX="MISSING_INDEX",i))(Pe||{});function ie(i){const r=[];let o=-1;for(const p of i){const l=p.index-p.skip;l!==o+1&&r.push({operation:{index:p.index,skip:p.skip},issue:"UNEXPECTED_INDEX",category:l>o+1?"MISSING_INDEX":"DUPLICATED_INDEX",message:`Expected index ${o+1} with skip 0 or equivalent, got index ${p.index} with skip ${p.skip}`}),o=p.index}return r}function st(i){var p,l,f;const r=[];let o=i.length-1;for(;o>-1;){r.unshift(i[o]);const c=(((p=i[o])==null?void 0:p.index)||0)-(((l=i[o])==null?void 0:l.skip)||0)-1;let a=o-1;for(;a>-1&&(((f=i[a])==null?void 0:f.index)||0)>c;)a--;o=a}return r}function lr(i){const r=[...i],o=r[r.length-1];return o&&(o.type==="NOOP"?r.push({...o,index:o.index,type:"NOOP",skip:Je(i)}):r.push({type:"NOOP",index:o.index+1,timestamp:new Date().toISOString(),input:{},skip:1,scope:o.scope,hash:o.hash})),r}function pt(i){return i.slice().sort((r,o)=>r.skip-o.skip).sort((r,o)=>r.index-o.index)}const ur=(i,r,o)=>[...r,...o].sort((p,l)=>new Date(p.timestamp).getTime()-new Date(l.timestamp).getTime()).map((p,l)=>({...p,index:i.index+l,skip:l===0?i.skip:0})),fr=(i,r,o)=>[...r,...o].sort((p,l)=>new Date(p.timestamp).getTime()-new Date(l.timestamp).getTime()).sort((p,l)=>p.index-l.index).map((p,l)=>({...p,index:i.index+l,skip:l===0?i.skip:0}));function re(i,r){return yt(i)===yt(r)}function hr(i,r){const o=st(pt(i.slice())),p=st(pt(r.slice()));if(o.length<1)return[p,[]];const l=[];let f=!1;for(;p.length>0;){const c=p[0];let a=o.shift();for(;a&&qe(a,c);)l.push(a),a=o.shift();if(a?f||(re(a,c)?(p.shift(),l.push(a)):(o.unshift(a),f=!0)):f=!0,f){let h=p.shift();for(;h;)l.push(h),h=p.shift()}}if(!f){let c=o.shift();for(;c;)l.push(c),c=o.shift()}return[st(l),o]}function qe(i,r){return i.index<r.index||i.index===r.index&&i.id===r.id&&i.skip<r.skip}function He(i,r){const o=[],p=[],l=[],f=Math.max(i.length,r.length);let c=!1;for(let a=0;a<f;a++){const h=i[a],g=r[a];h&&g?!c&&re(h,g)?o.push(h):(c=!0,p.push(h),l.push(g)):h?p.push(h):g&&l.push(g)}return[o,p,l]}function mr(i,r,o){const[p,l,f]=He(st(i),st(r)),c=Mt(p),a=1+Math.max(c,Mt(l),Mt(f)),h=We(f,l),g=o({index:a,skip:a-(c+1)},l,h);return p.concat(g)}function Mt(i){const r=i[i.length-1];return r?r.index:-1}function Je(i){var p,l,f;if(i.length<1)return-1;const r=st(i);let o=(((p=r[r.length-1])==null?void 0:p.skip)||0)+1;return r.length>1&&(o+=((l=r[r.length-2])==null?void 0:l.skip)||0),(((f=r[r.length-1])==null?void 0:f.index)||-1)<o?-1:o}const dr=i=>ie(st(pt(i))),xr=i=>i.reduce((o,p)=>{var l;return o[p.scope]||(o[p.scope]=[]),(l=o[p.scope])==null||l.push(p),o},{}),gr=(i,r)=>{var h;const o={integrityIssues:[],validOperations:[],invalidOperations:[],duplicatedOperations:[]},p=pt(i),l=pt(r),f=ie([...p,...l]),a=(h=[...f.filter(g=>g.category==="MISSING_INDEX")].sort((g,y)=>y.operation.index-g.operation.index).pop())==null?void 0:h.operation;for(const g of l){if(a&&g.index>=a.index){o.invalidOperations.push(g);continue}if(f.some(b=>b.operation.index===g.index&&b.operation.skip===g.skip&&b.category==="DUPLICATED_INDEX")){o.duplicatedOperations.push(g);continue}o.validOperations.push(g)}return o.integrityIssues.push(...f),o};function yr(i,r){return i.filter(o=>!r.some(p=>o.type==="NOOP"&&o.skip===0&&o.index===p.index||o.index===p.index&&o.skip===p.skip&&o.scope===p.scope&&o.hash===p.hash&&o.type===p.type))}function Ve(i,r){const[o]=pt(i).slice(-1),p=(o==null?void 0:o.index)??-1,l=p+1,f={...r,index:r.index??l};if(f.index<p)throw new Error(`The skip header operation index must be greater than or equal to ${p}`);return(st(pt([...i,f]))||[]).slice(0,-1)}function Ht(i){return{...Object.entries(i).reduce((o,p)=>{const[l,f]=p;return{...o,[l]:st(pt(f))}},{})}}function We(i,r){return i.filter(o=>o.id?!r.some(p=>p.id===o.id):!0)}const wr=Object.freeze(Object.defineProperty({__proto__:null,IntegrityIssueSubType:Pe,IntegrityIssueType:Le,addUndo:lr,attachBranch:hr,checkCleanedOperationsIntegrity:ie,checkOperationsIntegrity:dr,filterDuplicatedOperations:We,garbageCollect:st,garbageCollectDocumentOperations:Ht,groupOperationsByScope:xr,merge:mr,nextSkipNumber:Je,operationsAreEqual:re,precedes:qe,prepareOperations:gr,removeExistingOperations:yr,reshuffleByTimestamp:ur,reshuffleByTimestampAndIndex:fr,skipHeaderOperations:Ve,sortOperations:pt,split:He},Symbol.toStringTag,{value:"Module"}));function Er(i,r){let o;return"index"in r?o={...r}:o=i.operations[r.scope].at(-1),((o==null?void 0:o.index)??-1)+1}function ne(i,r){return{...i,revision:{...i.revision,[r.scope]:Er(i,r)},lastModified:new Date().toISOString()}}function br(i,r,o=0){if([St,vt,Dt].includes(r.type))return i;const{scope:p}=r,l=i.operations[p].slice();let f;const c=l.at(-1);let a=((c==null?void 0:c.index)??-1)+1;if("index"in r){if(r.index-o>a)throw new Error(`Missing operations: expected ${a} with skip 0 or equivalent, got index ${r.index} with skip ${o}`);a=r.index,f=r.id}else f=gi();return l.push({...r,id:f,index:a,timestamp:new Date().toISOString(),hash:"",scope:p,skip:o,error:void 0}),{...i,operations:{...i.operations,[p]:l}}}function Xe(i,r,o=0){let p=br(i,r,o);return p=ne(p,r),p}function Sr(i,r,o){switch(we().parse(r),r.type){case Oe:return yi(i,r.input);case Dt:return bi(i,r,o);case Fe:return Si(i,r.input.state);default:return i}}function vr(i,r,o){switch(r.type){case St:return wi(i,r,o);case vt:return Ei(i,r,o);default:return{document:i,action:r,skip:o}}}function _r(i,r,o,p,l=!1,f=se){const c=r.scope,a=i.operations[c].at(-1);if(!a)return i;const h=Ht({...i.operations,[c]:Ve(i.operations[c],a)});let g;const y=h[c].at(-1);if(l&&(y!=null&&y.resultingState))g=f(y.resultingState);else{const{state:b}=jt(i.initialState,h,o,void 0,void 0,void 0,void 0,{reuseHash:!0,reuseOperationResultingState:l,operationResultingStateParser:f});g=b[c]}return{...i,state:{...i.state,[c]:g},operations:Ht({...i.operations})}}function oe(i,r,o,p,l={}){const{skip:f,ignoreSkipOperations:c=!1,reuseHash:a=!1,reuseOperationResultingState:h=!1,operationResultingStateParser:g}=l,y={...r},b=f||0;let O={...i};const j=!c&&(b>0||"index"in y&&y.skip>0);return Jt(y)&&(O=Sr(O,y,o)),O=Xe(O,y,b),j&&(O=_r(O,y,o,b,h,g)),O=ot.produce(O,U=>{try{const q=o(U.state,y,p);if(q)return ot.castDraft({...O,state:q})}catch(q){const Y=O.operations[y.scope].length-1;U.operations[y.scope][Y].error=q.message,U.operations[y.scope][Y].skip=0,j&&(U.state=ot.castDraft({...i.state}),U.operations=ot.castDraft({...i.operations,[y.scope]:[...i.operations[y.scope],{...U.operations[y.scope][Y]}]}))}}),ot.produce(O,U=>{if([St,vt,Dt].includes(y.type))return U;const q=y.scope||"global",Y=a&&Object.prototype.hasOwnProperty.call(y,"hash")?y.hash:Ct(U,q),w=U.operations[q].at(-1);w&&(w.hash=Y,h&&(w.resultingState=U.state[q]),!Jt(y)&&y.attachments&&y.attachments.forEach(E=>{const{hash:S,...z}=E;U.attachments[S]={...z}}))})}function Ar(i){return i.type===vi&&i.skip!==void 0&&i.skip>0&&i.hash!==void 0}function Or(i){return[St,vt].includes(i.type)}function Jt(i){return[Oe,St,vt,Dt,Fe].includes(i.type)}function ht(i,r,o,p,l="global"){if(!i)throw new Error("Empty action type");if(typeof i!="string")throw new Error(`Invalid action type: ${JSON.stringify(i)}`);const f={type:i,input:r,scope:l};o&&(f.attachments=o);try{p==null||p().parse(f.input)}catch(c){throw new Error(`Invalid action input: ${c}`)}return f}function Ke(i,r=oe){return(o,p,l,f)=>r(o,p,i,l,f)}const Ge=(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:{}}}),Ze=(i,r)=>{const o=Ge(i,r);return{...o,initialState:o,operations:{global:[],local:[]},clipboard:[]}},Ct=(i,r="global")=>Ut(yt(i.state[r]||"")),Fr=(i,r=1e3)=>{const o=Math.random()*r;return Ut(`${(i??new Date).toISOString()}${o}`)};function Et(i){return ot.castImmutable(ot.freeze(i,!0))}function Br(i,r){const o=[...i];let p=r||0,l=o.length>0?o[o.length-1].index:0;const f=[];for(const c of o.reverse()){if(p>0){const g=l-c.index;p-=g}if(p<0)throw new Error("Invalid operation index, missing operations");const a={ignore:p>0,operation:c},h=c.skip>0?c.skip+1:0;if(h>0&&h>p){const g=h-p;p=p+g}l=c.index,f.push(a)}return f.reverse()}function Ir(i,r,o){const p=i.slice().sort((a,h)=>a.skip-h.skip).sort((a,h)=>a.index-h.index);let l=o,f=0,c=r;for(const a of p.reverse()){const h=c-a.index;if(l=l-h,l>-1)f++,c=a.index;else break}return f}function jr(i){return Object.values(i).flatMap(r=>r).sort((r,o)=>new Date(r.timestamp).getTime()-new Date(o.timestamp).getTime())}function Dr(i){return Object.values(i).flatMap(r=>r).sort((r,o)=>new Date(r.operation.timestamp).getTime()-new Date(o.operation.timestamp).getTime())}function jt(i,r,o,p,l,f=oe,c={},a){const h=Ke(o,f);return ae(i,r,h,p,l,c,a)}function ae(i,r,o,p,l,f={},c){const{checkHashes:a=!0,reuseOperationResultingState:h,operationResultingStateParser:g=se}=c||{};let y=i;const b=[],O={global:[],local:[]};if(h)for(const[w,E]of Object.entries(r)){const S=E.findLastIndex(J=>!!J.resultingState);if(S<0){b.push(...E);continue}const z=E[S];try{const J=g(z.resultingState);y={...y,state:{...y.state,[w]:J}},O[w].push(...E.slice(0,S+1)),b.push(...E.slice(S+1))}catch{b.push(...E)}}else b.push(...Object.values(r).flat());const j=Ze(y);j.initialState=i,j.operations=O;let U=j;if(b.length)U=b.reduce((w,E)=>o(w,E,p,{skip:E.skip,ignoreSkipOperations:!0,reuseHash:!a}),j);else for(const w of Object.values(O)){const E=w.at(-1);E&&(U=ne(U,E))}if(!a)for(const w of Object.keys(U.state))for(let E=b.length-1;E>=0;E--){const S=b[E];if(S.scope===w){if(S.hash!==Ct(U,w))throw new Error(`Hash mismatch for scope ${w}`);break}}const q=Object.keys(U.operations).reduce((w,E)=>{const S=E;return{...w,[S]:[...U.operations[S].map((z,J)=>{var V;return{...z,timestamp:((V=r[S][J])==null?void 0:V.timestamp)??z.timestamp}})]}},{global:[],local:[]}),Y=Object.values(q).reduce((w,E)=>{const S=E[E.length-1];return(S==null?void 0:S.timestamp)>w&&(w=S.timestamp),w},i.lastModified);return{...U,operations:q,lastModified:Y}}function Tr(i,r){return yt(i)===yt(r)}function se(i){const r=typeof i;if(r==="string")return JSON.parse(i);if(r==="object")return i;throw new Error(`Providing resulting state is of type: ${r}`)}const Ye=i=>ht("SET_NAME",i,void 0,Kt,void 0),Qe=(i=1,r="global")=>ht("UNDO",i,void 0,Gt,r),ti=(i=1,r="global")=>ht("REDO",i,void 0,Xt,r),ei=(i,r,o="global")=>ht("PRUNE",{start:i,end:r},void 0,Wt,o),pe=(i,r)=>ht("LOAD_STATE",{state:i,operations:r},void 0,Vt),ii=(i="global")=>ht("NOOP",{},void 0,void 0,i),kr=Object.freeze(Object.defineProperty({__proto__:null,loadState:pe,noop:ii,prune:ei,redo:ti,setName:Ye,undo:Qe},Symbol.toStringTag,{value:"Module"}));class Ur{constructor(r,o,p){Bt(this,"_document");Bt(this,"_reducer");Bt(this,"_signalDispatch");this._reducer=r,this._document=o,this._signalDispatch=p}dispatch(r,o){return this._document=this._reducer(this._document,r,this._signalDispatch,o),this}saveToFile(r,o,p){return ze(this._document,r,o,p)}async loadFromFile(r){this._document=await qt(r,this._reducer)}static async stateFromFile(r,o){return await qt(r,o)}get state(){return Et(this._document.state)}get operations(){return Et(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 Et(this._document.initialState)}toDocument(){return Et(this._document)}getAttachment(r){return this._document.attachments[r]}setName(r){return this.dispatch(Ye(r)),this}undo(r){return this.dispatch(Qe(r)),this}redo(r){return this.dispatch(ti(r)),this}prune(r,o){return this.dispatch(ei(r,o)),this}loadState(r,o){return this.dispatch(pe(r,o)),this}}function Cr(i,r){r.forEach(o=>{Object.getOwnPropertyNames(o.prototype).forEach(p=>{Object.defineProperty(i.prototype,p,Object.getOwnPropertyDescriptor(o.prototype,p)||Object.create(null))})})}exports.BaseActions=kr;exports.BaseDocument=Ur;exports.applyMixins=Cr;exports.baseReducer=oe;exports.calculateSkipsLeft=Ir;exports.createAction=ht;exports.createDocument=Ze;exports.createExtendedState=Ge;exports.createReducer=Ke;exports.createZip=ee;exports.documentHelpers=wr;exports.getLocalFile=cr;exports.getRemoteFile=pr;exports.hashDocument=Ct;exports.hashKey=Fr;exports.isBaseAction=Jt;exports.isNoopOperation=Ar;exports.isSameDocument=Tr;exports.isUndoRedo=Or;exports.loadFromFile=qt;exports.loadFromInput=Me;exports.mapSkippedOperations=Br;exports.parseResultingState=se;exports.processUndoRedo=vr;exports.readOnly=Et;exports.replayDocument=ae;exports.replayOperations=jt;exports.saveToFile=ze;exports.saveToFileHandle=ar;exports.sortMappedOperations=Dr;exports.sortOperations=jr;exports.updateDocument=Xe;exports.updateHeader=ne;exports.validateOperations=Ne;exports.zod=ui;
@@ -1,7 +1,7 @@
1
- import "./internal/object-DenwvByi.js";
1
+ import "./internal/object-Cxp6e1kN.js";
2
2
  import "immer";
3
3
  import "jszip";
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-DynAX_OS.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-CZutz9-u.js";
5
5
  import "zod";
6
6
  export {
7
7
  i as Document,
@@ -1,5 +1,5 @@
1
- import { B as p, h as r, g as i, E as m, F as d, G as u, H as c, I as n } from "./internal/object-DenwvByi.js";
2
- import { i as f } from "./internal/index-BnpyOR6R.js";
1
+ import { B as p, h as r, g as i, E as m, F as d, G as u, H as c, I as n } from "./internal/object-Cxp6e1kN.js";
2
+ import { i as f } from "./internal/index-DPuk-_bv.js";
3
3
  import "immer";
4
4
  import "zod";
5
5
  import "jszip";
@@ -1,6 +1,6 @@
1
- import { D as o } from "./internal/index-BnpyOR6R.js";
2
- import { D as e } from "./internal/index-DynAX_OS.js";
3
- import "./internal/object-DenwvByi.js";
1
+ import { D as o } from "./internal/index-DPuk-_bv.js";
2
+ import { D as e } from "./internal/index-CZutz9-u.js";
3
+ import "./internal/object-Cxp6e1kN.js";
4
4
  import "immer";
5
5
  import "zod";
6
6
  import "jszip";
@@ -1,7 +1,7 @@
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-DenwvByi.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-Cxp6e1kN.js";
5
5
  import "immer";
6
6
  import "jszip";
7
7
  import { z as o } from "zod";
@@ -1,4 +1,4 @@
1
- import { j as e, f as a, b as s, a as t, c as o, k as r, m as n, n as i, o as p, p as c, q as l, i as d, r as u, t as m, u as O, l as y, e as D, v as S, w as b, x as g, y as F, z as _, s as f, d as v, A as R, C as h, D as j, B as x, h as z, g as A, E as B, F as H, G as M, H as T, I as k } from "./object-2jyfnUeK.js";
1
+ import { j as e, f as a, b as s, a as t, c as o, k as r, m as n, n as i, o as p, p as c, q as l, i as d, r as u, t as m, u as O, l as y, e as D, v as S, w as b, x as g, y as F, z as _, s as f, d as v, A as R, C as h, D as j, B as x, h as z, g as A, E as B, F as H, G as M, H as T, I as k } from "./object-Cxp6e1kN.js";
2
2
  const E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3
3
  __proto__: null,
4
4
  calculateSkipsLeft: e,
@@ -1905,7 +1905,7 @@ const ke = async (i) => {
1905
1905
  return r.file("header.json", JSON.stringify(a, null, 2)), r.file(
1906
1906
  "state.json",
1907
1907
  JSON.stringify(i.initialState || {}, null, 2)
1908
- ), r.file("operations.json", JSON.stringify(i.operations, null, 2)), Object.keys(i.attachments).forEach((g) => {
1908
+ ), r.file("operations.json", JSON.stringify(i.operations, null, 2)), i.attachments && Object.keys(i.attachments).forEach((g) => {
1909
1909
  const { data: y, ...b } = i.attachments[g];
1910
1910
  r.file(g, y, {
1911
1911
  base64: !0,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-CXx7IaXb.js");require("immer");require("jszip");require("crypto");require("fs");require("https");require("path");const e=require("./internal/index-CtqbrEO2.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-_P8Ctu09.js");require("immer");require("jszip");require("crypto");require("fs");require("https");require("path");const e=require("./internal/index-DPBQS8BC.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 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal/object-CXx7IaXb.js"),r=require("./internal/index-B96klT84.js");require("immer");require("zod");require("jszip");require("crypto");require("fs");require("https");require("path");exports.BaseDocument=e.BaseDocument;exports.actions=e.BaseActions;exports.applyMixins=e.applyMixins;exports.baseReducer=e.baseReducer;exports.processUndoRedo=e.processUndoRedo;exports.updateDocument=e.updateDocument;exports.updateHeader=e.updateHeader;exports.z=e.zod;exports.utils=r.index;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal/object-_P8Ctu09.js"),r=require("./internal/index-C2-dv_r8.js");require("immer");require("zod");require("jszip");require("crypto");require("fs");require("https");require("path");exports.BaseDocument=e.BaseDocument;exports.actions=e.BaseActions;exports.applyMixins=e.applyMixins;exports.baseReducer=e.baseReducer;exports.processUndoRedo=e.processUndoRedo;exports.updateDocument=e.updateDocument;exports.updateHeader=e.updateHeader;exports.z=e.zod;exports.utils=r.index;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./internal/index-B96klT84.js"),o=require("./internal/index-CtqbrEO2.js");require("./internal/object-CXx7IaXb.js");require("immer");require("zod");require("jszip");require("crypto");require("fs");require("https");require("path");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-C2-dv_r8.js"),o=require("./internal/index-DPBQS8BC.js");require("./internal/object-_P8Ctu09.js");require("immer");require("zod");require("jszip");require("crypto");require("fs");require("https");require("path");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 +1 @@
1
- "use strict";const e=require("./object-DQmy6ar9.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,documentHelpers:e.documentHelpers,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,parseResultingState:e.parseResultingState,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,updateDocument:e.updateDocument,updateHeader:e.updateHeader,utils:t,z:e.zod},Symbol.toStringTag,{value:"Module"}));exports.Document=o;exports.index=t;
1
+ "use strict";const e=require("./object-_P8Ctu09.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,documentHelpers:e.documentHelpers,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,parseResultingState:e.parseResultingState,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,updateDocument:e.updateDocument,updateHeader:e.updateHeader,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-CXx7IaXb.js");require("immer");require("jszip");require("crypto");require("fs");require("https");require("path");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-_P8Ctu09.js");require("immer");require("jszip");require("crypto");require("fs");require("https");require("path");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": "",
@@ -16,5 +16,5 @@ ${y}`,C=Math.min(s.length,z);let F=0;for(;F<C-1;F++){const V=Q(String(F),s[F],g,
16
16
  ${j}`,g.pop(),`[${E}]`}let x=Object.keys(s);const S=x.length;if(S===0)return"{}";if(M<g.length+1)return'"[Object]"';y+=O;const $=`,
17
17
  ${y}`;let T="",v="",I=Math.min(S,z);m(s)&&(T+=u(s,$,z),x=x.slice(s.length),I-=s.length,v=$),L&&(x=r(x)),g.push(s);for(let E=0;E<I;E++){const R=x[E],C=Q(R,s[R],g,O,y);C!==void 0&&(T+=`${v}${a(R)}: ${C}`,v=$)}if(S>z){const E=S-z;T+=`${v}"...": "${_(E)} not stringified"`,v=$}return v!==""&&(T=`
18
18
  ${y}${T}
19
- ${j}`),g.pop(),`{${T}}`}case"number":return isFinite(s)?String(s):l?l(s):"null";case"boolean":return s===!0?"true":"false";case"undefined":return;case"bigint":if(k)return String(s);default:return l?l(s):void 0}}function Y(A,s,g){switch(typeof s){case"string":return a(s);case"object":{if(s===null)return"null";if(typeof s.toJSON=="function"){if(s=s.toJSON(A),typeof s!="object")return Y(A,s,g);if(s===null)return"null"}if(g.indexOf(s)!==-1)return d;let O="";if(Array.isArray(s)){if(s.length===0)return"[]";if(M<g.length+1)return'"[Array]"';g.push(s);const $=Math.min(s.length,z);let T=0;for(;T<$-1;T++){const I=Y(String(T),s[T],g);O+=I!==void 0?I:"null",O+=","}const v=Y(String(T),s[T],g);if(O+=v!==void 0?v:"null",s.length-1>z){const I=s.length-z-1;O+=`,"... ${_(I)} not stringified"`}return g.pop(),`[${O}]`}let y=Object.keys(s);const j=y.length;if(j===0)return"{}";if(M<g.length+1)return'"[Object]"';let x="",S=Math.min(j,z);m(s)&&(O+=u(s,",",z),y=y.slice(s.length),S-=s.length,x=","),L&&(y=r(y)),g.push(s);for(let $=0;$<S;$++){const T=y[$],v=Y(T,s[T],g);v!==void 0&&(O+=`${x}${a(T)}:${v}`,x=",")}if(j>z){const $=j-z;O+=`${x}"...":"${_($)} not stringified"`}return g.pop(),`{${O}}`}case"number":return isFinite(s)?String(s):l?l(s):"null";case"boolean":return s===!0?"true":"false";case"undefined":return;case"bigint":if(k)return String(s);default:return l?l(s):void 0}}function ye(A,s,g){if(arguments.length>1){let O="";if(typeof g=="number"?O=" ".repeat(Math.min(g,10)):typeof g=="string"&&(O=g.slice(0,10)),s!=null){if(typeof s=="function")return st("",{"":A},[],s,O,"");if(Array.isArray(s))return rt("",A,[],D(s),O,"")}if(O.length!==0)return Q("",A,[],O,"")}return Y("",A,[])}return ye}})(ht,ht.exports);var _e=ht.exports;const Z=ve(_e);Z.configure;let ct;const Ie=new Uint8Array(16);function Ne(){if(!ct&&(ct=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ct))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ct(Ie)}const N=[];for(let t=0;t<256;++t)N.push((t+256).toString(16).slice(1));function Ae(t,e=0){return N[t[e+0]]+N[t[e+1]]+N[t[e+2]]+N[t[e+3]]+"-"+N[t[e+4]]+N[t[e+5]]+"-"+N[t[e+6]]+N[t[e+7]]+"-"+N[t[e+8]]+N[t[e+9]]+"-"+N[t[e+10]]+N[t[e+11]]+N[t[e+12]]+N[t[e+13]]+N[t[e+14]]+N[t[e+15]]}const Pe=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Nt={randomUUID:Pe};function Me(t,e,n){if(Nt.randomUUID&&!e&&!t)return Nt.randomUUID();t=t||{};const i=t.random||(t.rng||Ne)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e){n=n||0;for(let o=0;o<16;++o)e[n+o]=i[o];return e}return Ae(i)}function Re(t,e){return{...t,name:e}}function Fe(t,e,n){const{scope:i,input:o}=e,a={document:t,action:e,skip:n};return H.produce(a,r=>{if(r.document.operations[i].length<1)throw new Error(`Cannot undo: no operations in history for scope "${i}"`);if(o<1)throw new Error("Invalid UNDO action: input value must be greater than 0");if(r.skip>0)throw new Error("Cannot undo: skip value from reducer cannot be used with UNDO action");const p=r.document.operations[i].at(-1),m=p&&p.type==="NOOP"&&p.skip>0;if(r.skip+=o,m){r.skip+=p.skip;const w=r.document.operations[i][r.document.operations[i].length-2];w&&p.index-w.index===1&&r.document.operations[i].pop()}if(r.document.operations[i].length<r.skip)throw new Error("Cannot undo: you can't undo more operations than the ones in the scope history");const u=r.document.operations[i].length-1;let h=o,b=m?u-p.skip:u;for(;h>0&&b>=0;){const w=r.document.operations[i][b];if(!w){h--,b--;continue}w.type==="NOOP"&&w.skip>0?(b=b-(w.skip+1),r.skip+=w.skip+1):(r.document.clipboard.push({...w}),h--,b--)}r.action=xe(i)})}function Ue(t,e,n){const{scope:i,input:o}=e,a={document:t,action:e,skip:n};return H.produce(a,r=>{if(r.skip>0)throw new Error("Cannot redo: skip value from reducer cannot be used with REDO action");if(o>1)throw new Error("Cannot redo: you can only redo one operation at a time");if(o<1)throw new Error("Invalid REDO action: invalid redo input value");if(r.document.clipboard.length<1)throw new Error("Cannot redo: no operations in the clipboard");const p=r.document.clipboard.findLastIndex(u=>u.scope===i);if(p<0)throw new Error(`Cannot redo: no operations in clipboard for scope "${i}"`);const m=r.document.clipboard.splice(p,1)[0];r.action=H.castDraft({type:m.type,scope:m.scope,input:m.input})})}function Le(t,e,n){const{scope:i}=e,o=t.operations[i];let{input:{start:a,end:r}}=e;a=a||0,r=r||o.length;const p=o.slice(a,r),m=o.slice(0,a),u=o.slice(r),h=lt(t.initialState,{...t.operations,[i]:m.concat(p)},n),{name:b,state:w}=h,_=m.length,D=m.length?m[m.length-1].timestamp:u.length?u[0].timestamp:new Date().toISOString();return lt(t.initialState,{...t.operations,[i]:[...m,{...It({name:b,state:w},p.length),timestamp:D,index:_,hash:dt({state:w},"global")},...u.map((P,U)=>({...P,index:_+U+1}))]},n)}function qe(t,e){return{...t,name:e.name,state:e.state??{global:{},local:{}}}}const Kt="SET_NAME",it="UNDO",ot="REDO",mt="PRUNE",Wt="LOAD_STATE",Ce="NOOP",Gt={"application/andrew-inset":["ez"],"application/appinstaller":["appinstaller"],"application/applixware":["aw"],"application/appx":["appx"],"application/appxbundle":["appxbundle"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/automationml-aml+xml":["aml"],"application/automationml-amlx+zip":["amlx"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cpl+xml":["cpl"],"application/cu-seeme":["cu"],"application/cwl":["cwl"],"application/dash+xml":["mpd"],"application/dash-patch+xml":["mpp"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/express":["exp"],"application/fdf":["fdf"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["*js"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/media-policy-dataset+xml":["mpf"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["*mp4","*mpg4","mp4s","m4p"],"application/msix":["msix"],"application/msixbundle":["msixbundle"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-keys":["asc"],"application/pgp-signature":["sig","*asc"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/sql":["sql"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/trig":["trig"],"application/ttml+xml":["ttml"],"application/ubjson":["ubj"],"application/urc-ressheet+xml":["rsheet"],"application/urc-targetdesc+xml":["td"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/watcherinfo+xml":["wif"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xfdf":["xfdf"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["*xsl","xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/aac":["adts","aac"],"audio/adpcm":["adp"],"audio/amr":["amr"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx","opus"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/avci":["avci"],"image/avcs":["avcs"],"image/avif":["avif"],"image/bmp":["bmp","dib"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/dpx":["dpx"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm","jpgm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/ktx2":["ktx2"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/jt":["jt"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/prc":["prc"],"model/step+xml":["stpx"],"model/step+zip":["stpz"],"model/step-xml+zip":["stpxz"],"model/stl":["stl"],"model/u3d":["u3d"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/javascript":["js","mjs"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["md","markdown"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/spdx":["spdx"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/wgsl":["wgsl"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/iso.segment":["m4s"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","*jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]};Object.freeze(Gt);var q=function(t,e,n,i){if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?i:n==="a"?i.call(t):i?i.value:e.get(t)},G,tt,K;class Je{constructor(...e){G.set(this,new Map),tt.set(this,new Map),K.set(this,new Map);for(const n of e)this.define(n)}define(e,n=!1){for(let[i,o]of Object.entries(e)){i=i.toLowerCase(),o=o.map(p=>p.toLowerCase()),q(this,K,"f").has(i)||q(this,K,"f").set(i,new Set);const a=q(this,K,"f").get(i);let r=!0;for(let p of o){const m=p.startsWith("*");if(p=m?p.slice(1):p,a==null||a.add(p),r&&q(this,tt,"f").set(i,p),r=!1,m)continue;const u=q(this,G,"f").get(p);if(u&&u!=i&&!n)throw new Error(`"${i} -> ${p}" conflicts with "${u} -> ${p}". Pass \`force=true\` to override this definition.`);q(this,G,"f").set(p,i)}}return this}getType(e){if(typeof e!="string")return null;const n=e.replace(/^.*[/\\]/,"").toLowerCase(),i=n.replace(/^.*\./,"").toLowerCase(),o=n.length<e.length;return!(i.length<n.length-1)&&o?null:q(this,G,"f").get(i)??null}getExtension(e){var n;return typeof e!="string"?null:(e=(n=e==null?void 0:e.split)==null?void 0:n.call(e,";")[0],(e&&q(this,tt,"f").get(e.trim().toLowerCase()))??null)}getAllExtensions(e){return typeof e!="string"?null:q(this,K,"f").get(e.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 e of q(this,K,"f").values())Object.freeze(e);return this}_getTestState(){return{types:q(this,G,"f"),extensions:q(this,tt,"f")}}}G=new WeakMap,tt=new WeakMap,K=new WeakMap;const Ve=new Je(Gt)._freeze();function He(t,e,n){const i=je.join(t,e);return gt.mkdirSync(t,{recursive:!0}),new Promise((o,a)=>{try{gt.writeFile(i,n,{},r=>{r?a(r):o(i)})}catch(r){a(r)}})}function Zt(t){return gt.readFileSync(t)}function Be(t){return new Promise((e,n)=>{Se.get(t,i=>{const o=[],a=i.headers["content-type"];i.on("data",r=>{o.push(r)}),i.on("end",()=>{e({buffer:Buffer.concat(o),mimeType:a})})}).on("error",i=>{n(i)})})}const Xe=async t=>Zt(t),ut=(t,e="sha1")=>Oe.createHash(e).update(t).digest("base64");function Qt(t){const e=[],n=Object.keys(t);for(const i of n){const o=t[i].sort((a,r)=>a.index-r.index);for(let a=0;a<o.length;a++)o[a].index!==a&&e.push({message:`Invalid operation index ${o[a].index} at position ${a}`,details:{position:a,operation:o[a],scope:o[a].scope}})}return e}const Dt=async t=>{const e=new At,{name:n,revision:i,documentType:o,created:a,lastModified:r}=t,p={name:n,revision:i,documentType:o,created:a,lastModified:r};return e.file("header.json",JSON.stringify(p,null,2)),e.file("state.json",JSON.stringify(t.initialState||{},null,2)),e.file("operations.json",JSON.stringify(t.operations,null,2)),Object.keys(t.attachments).forEach(u=>{const{data:h,...b}=t.attachments[u];e.file(u,h,{base64:!0,createFolders:!0,comment:JSON.stringify(b)})}),e},Yt=async(t,e,n,i)=>{const a=await(await Dt(t)).generateAsync({type:"uint8array",streamFiles:!0}),r=i??t.name,p=`.${n}.zip`;return He(e,r.endsWith(p)?r:`${r}${p}`,a)},Ke=async(t,e)=>{const i=await(await Dt(t)).generateAsync({type:"blob"}),o=await e.createWritable();await o.write(i),await o.close()},xt=async(t,e,n)=>{const i=Zt(t);return te(i,e,n)},te=async(t,e,n)=>{const i=new At;return await i.loadAsync(t),We(i,e,n)};async function We(t,e,n){const i=t.file("state.json");if(!i)throw new Error("Initial state not found");const o=await i.async("string"),a=JSON.parse(o),r=t.file("header.json");let p;r&&(p=JSON.parse(await r.async("string")));const m=t.file("operations.json");if(!m)throw new Error("Operations history not found");const u=JSON.parse(await m.async("string")),h=Qt(u);if(h.length){const w=h.map(_=>_.message);throw new Error(w.join(`
19
+ ${j}`),g.pop(),`{${T}}`}case"number":return isFinite(s)?String(s):l?l(s):"null";case"boolean":return s===!0?"true":"false";case"undefined":return;case"bigint":if(k)return String(s);default:return l?l(s):void 0}}function Y(A,s,g){switch(typeof s){case"string":return a(s);case"object":{if(s===null)return"null";if(typeof s.toJSON=="function"){if(s=s.toJSON(A),typeof s!="object")return Y(A,s,g);if(s===null)return"null"}if(g.indexOf(s)!==-1)return d;let O="";if(Array.isArray(s)){if(s.length===0)return"[]";if(M<g.length+1)return'"[Array]"';g.push(s);const $=Math.min(s.length,z);let T=0;for(;T<$-1;T++){const I=Y(String(T),s[T],g);O+=I!==void 0?I:"null",O+=","}const v=Y(String(T),s[T],g);if(O+=v!==void 0?v:"null",s.length-1>z){const I=s.length-z-1;O+=`,"... ${_(I)} not stringified"`}return g.pop(),`[${O}]`}let y=Object.keys(s);const j=y.length;if(j===0)return"{}";if(M<g.length+1)return'"[Object]"';let x="",S=Math.min(j,z);m(s)&&(O+=u(s,",",z),y=y.slice(s.length),S-=s.length,x=","),L&&(y=r(y)),g.push(s);for(let $=0;$<S;$++){const T=y[$],v=Y(T,s[T],g);v!==void 0&&(O+=`${x}${a(T)}:${v}`,x=",")}if(j>z){const $=j-z;O+=`${x}"...":"${_($)} not stringified"`}return g.pop(),`{${O}}`}case"number":return isFinite(s)?String(s):l?l(s):"null";case"boolean":return s===!0?"true":"false";case"undefined":return;case"bigint":if(k)return String(s);default:return l?l(s):void 0}}function ye(A,s,g){if(arguments.length>1){let O="";if(typeof g=="number"?O=" ".repeat(Math.min(g,10)):typeof g=="string"&&(O=g.slice(0,10)),s!=null){if(typeof s=="function")return st("",{"":A},[],s,O,"");if(Array.isArray(s))return rt("",A,[],D(s),O,"")}if(O.length!==0)return Q("",A,[],O,"")}return Y("",A,[])}return ye}})(ht,ht.exports);var _e=ht.exports;const Z=ve(_e);Z.configure;let ct;const Ie=new Uint8Array(16);function Ne(){if(!ct&&(ct=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ct))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ct(Ie)}const N=[];for(let t=0;t<256;++t)N.push((t+256).toString(16).slice(1));function Ae(t,e=0){return N[t[e+0]]+N[t[e+1]]+N[t[e+2]]+N[t[e+3]]+"-"+N[t[e+4]]+N[t[e+5]]+"-"+N[t[e+6]]+N[t[e+7]]+"-"+N[t[e+8]]+N[t[e+9]]+"-"+N[t[e+10]]+N[t[e+11]]+N[t[e+12]]+N[t[e+13]]+N[t[e+14]]+N[t[e+15]]}const Pe=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Nt={randomUUID:Pe};function Me(t,e,n){if(Nt.randomUUID&&!e&&!t)return Nt.randomUUID();t=t||{};const i=t.random||(t.rng||Ne)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e){n=n||0;for(let o=0;o<16;++o)e[n+o]=i[o];return e}return Ae(i)}function Re(t,e){return{...t,name:e}}function Fe(t,e,n){const{scope:i,input:o}=e,a={document:t,action:e,skip:n};return H.produce(a,r=>{if(r.document.operations[i].length<1)throw new Error(`Cannot undo: no operations in history for scope "${i}"`);if(o<1)throw new Error("Invalid UNDO action: input value must be greater than 0");if(r.skip>0)throw new Error("Cannot undo: skip value from reducer cannot be used with UNDO action");const p=r.document.operations[i].at(-1),m=p&&p.type==="NOOP"&&p.skip>0;if(r.skip+=o,m){r.skip+=p.skip;const w=r.document.operations[i][r.document.operations[i].length-2];w&&p.index-w.index===1&&r.document.operations[i].pop()}if(r.document.operations[i].length<r.skip)throw new Error("Cannot undo: you can't undo more operations than the ones in the scope history");const u=r.document.operations[i].length-1;let h=o,b=m?u-p.skip:u;for(;h>0&&b>=0;){const w=r.document.operations[i][b];if(!w){h--,b--;continue}w.type==="NOOP"&&w.skip>0?(b=b-(w.skip+1),r.skip+=w.skip+1):(r.document.clipboard.push({...w}),h--,b--)}r.action=xe(i)})}function Ue(t,e,n){const{scope:i,input:o}=e,a={document:t,action:e,skip:n};return H.produce(a,r=>{if(r.skip>0)throw new Error("Cannot redo: skip value from reducer cannot be used with REDO action");if(o>1)throw new Error("Cannot redo: you can only redo one operation at a time");if(o<1)throw new Error("Invalid REDO action: invalid redo input value");if(r.document.clipboard.length<1)throw new Error("Cannot redo: no operations in the clipboard");const p=r.document.clipboard.findLastIndex(u=>u.scope===i);if(p<0)throw new Error(`Cannot redo: no operations in clipboard for scope "${i}"`);const m=r.document.clipboard.splice(p,1)[0];r.action=H.castDraft({type:m.type,scope:m.scope,input:m.input})})}function Le(t,e,n){const{scope:i}=e,o=t.operations[i];let{input:{start:a,end:r}}=e;a=a||0,r=r||o.length;const p=o.slice(a,r),m=o.slice(0,a),u=o.slice(r),h=lt(t.initialState,{...t.operations,[i]:m.concat(p)},n),{name:b,state:w}=h,_=m.length,D=m.length?m[m.length-1].timestamp:u.length?u[0].timestamp:new Date().toISOString();return lt(t.initialState,{...t.operations,[i]:[...m,{...It({name:b,state:w},p.length),timestamp:D,index:_,hash:dt({state:w},"global")},...u.map((P,U)=>({...P,index:_+U+1}))]},n)}function qe(t,e){return{...t,name:e.name,state:e.state??{global:{},local:{}}}}const Kt="SET_NAME",it="UNDO",ot="REDO",mt="PRUNE",Wt="LOAD_STATE",Ce="NOOP",Gt={"application/andrew-inset":["ez"],"application/appinstaller":["appinstaller"],"application/applixware":["aw"],"application/appx":["appx"],"application/appxbundle":["appxbundle"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/automationml-aml+xml":["aml"],"application/automationml-amlx+zip":["amlx"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cpl+xml":["cpl"],"application/cu-seeme":["cu"],"application/cwl":["cwl"],"application/dash+xml":["mpd"],"application/dash-patch+xml":["mpp"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/express":["exp"],"application/fdf":["fdf"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["*js"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/media-policy-dataset+xml":["mpf"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["*mp4","*mpg4","mp4s","m4p"],"application/msix":["msix"],"application/msixbundle":["msixbundle"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-keys":["asc"],"application/pgp-signature":["sig","*asc"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/sql":["sql"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/trig":["trig"],"application/ttml+xml":["ttml"],"application/ubjson":["ubj"],"application/urc-ressheet+xml":["rsheet"],"application/urc-targetdesc+xml":["td"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/watcherinfo+xml":["wif"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xfdf":["xfdf"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["*xsl","xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/aac":["adts","aac"],"audio/adpcm":["adp"],"audio/amr":["amr"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx","opus"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/avci":["avci"],"image/avcs":["avcs"],"image/avif":["avif"],"image/bmp":["bmp","dib"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/dpx":["dpx"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm","jpgm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/ktx2":["ktx2"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/jt":["jt"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/prc":["prc"],"model/step+xml":["stpx"],"model/step+zip":["stpz"],"model/step-xml+zip":["stpxz"],"model/stl":["stl"],"model/u3d":["u3d"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/javascript":["js","mjs"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["md","markdown"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/spdx":["spdx"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/wgsl":["wgsl"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/iso.segment":["m4s"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","*jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]};Object.freeze(Gt);var q=function(t,e,n,i){if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?i:n==="a"?i.call(t):i?i.value:e.get(t)},G,tt,K;class Je{constructor(...e){G.set(this,new Map),tt.set(this,new Map),K.set(this,new Map);for(const n of e)this.define(n)}define(e,n=!1){for(let[i,o]of Object.entries(e)){i=i.toLowerCase(),o=o.map(p=>p.toLowerCase()),q(this,K,"f").has(i)||q(this,K,"f").set(i,new Set);const a=q(this,K,"f").get(i);let r=!0;for(let p of o){const m=p.startsWith("*");if(p=m?p.slice(1):p,a==null||a.add(p),r&&q(this,tt,"f").set(i,p),r=!1,m)continue;const u=q(this,G,"f").get(p);if(u&&u!=i&&!n)throw new Error(`"${i} -> ${p}" conflicts with "${u} -> ${p}". Pass \`force=true\` to override this definition.`);q(this,G,"f").set(p,i)}}return this}getType(e){if(typeof e!="string")return null;const n=e.replace(/^.*[/\\]/,"").toLowerCase(),i=n.replace(/^.*\./,"").toLowerCase(),o=n.length<e.length;return!(i.length<n.length-1)&&o?null:q(this,G,"f").get(i)??null}getExtension(e){var n;return typeof e!="string"?null:(e=(n=e==null?void 0:e.split)==null?void 0:n.call(e,";")[0],(e&&q(this,tt,"f").get(e.trim().toLowerCase()))??null)}getAllExtensions(e){return typeof e!="string"?null:q(this,K,"f").get(e.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 e of q(this,K,"f").values())Object.freeze(e);return this}_getTestState(){return{types:q(this,G,"f"),extensions:q(this,tt,"f")}}}G=new WeakMap,tt=new WeakMap,K=new WeakMap;const Ve=new Je(Gt)._freeze();function He(t,e,n){const i=je.join(t,e);return gt.mkdirSync(t,{recursive:!0}),new Promise((o,a)=>{try{gt.writeFile(i,n,{},r=>{r?a(r):o(i)})}catch(r){a(r)}})}function Zt(t){return gt.readFileSync(t)}function Be(t){return new Promise((e,n)=>{Se.get(t,i=>{const o=[],a=i.headers["content-type"];i.on("data",r=>{o.push(r)}),i.on("end",()=>{e({buffer:Buffer.concat(o),mimeType:a})})}).on("error",i=>{n(i)})})}const Xe=async t=>Zt(t),ut=(t,e="sha1")=>Oe.createHash(e).update(t).digest("base64");function Qt(t){const e=[],n=Object.keys(t);for(const i of n){const o=t[i].sort((a,r)=>a.index-r.index);for(let a=0;a<o.length;a++)o[a].index!==a&&e.push({message:`Invalid operation index ${o[a].index} at position ${a}`,details:{position:a,operation:o[a],scope:o[a].scope}})}return e}const Dt=async t=>{const e=new At,{name:n,revision:i,documentType:o,created:a,lastModified:r}=t,p={name:n,revision:i,documentType:o,created:a,lastModified:r};return e.file("header.json",JSON.stringify(p,null,2)),e.file("state.json",JSON.stringify(t.initialState||{},null,2)),e.file("operations.json",JSON.stringify(t.operations,null,2)),t.attachments&&Object.keys(t.attachments).forEach(u=>{const{data:h,...b}=t.attachments[u];e.file(u,h,{base64:!0,createFolders:!0,comment:JSON.stringify(b)})}),e},Yt=async(t,e,n,i)=>{const a=await(await Dt(t)).generateAsync({type:"uint8array",streamFiles:!0}),r=i??t.name,p=`.${n}.zip`;return He(e,r.endsWith(p)?r:`${r}${p}`,a)},Ke=async(t,e)=>{const i=await(await Dt(t)).generateAsync({type:"blob"}),o=await e.createWritable();await o.write(i),await o.close()},xt=async(t,e,n)=>{const i=Zt(t);return te(i,e,n)},te=async(t,e,n)=>{const i=new At;return await i.loadAsync(t),We(i,e,n)};async function We(t,e,n){const i=t.file("state.json");if(!i)throw new Error("Initial state not found");const o=await i.async("string"),a=JSON.parse(o),r=t.file("header.json");let p;r&&(p=JSON.parse(await r.async("string")));const m=t.file("operations.json");if(!m)throw new Error("Operations history not found");const u=JSON.parse(await m.async("string")),h=Qt(u);if(h.length){const w=h.map(_=>_.message);throw new Error(w.join(`
20
20
  `))}let b=vt(a,u,e,void 0,p,{},n);return p&&(b={...b,...p}),b}function ee(t){const e=t.replace(/^.*\./,"")||void 0,n=t.replace(/^.*[/\\]/,"")||void 0;return{extension:e,fileName:n}}async function Ge(t){const{buffer:e,mimeType:n="application/octet-stream"}=await Be(t),i=ee(t),o=e.toString("base64");return{data:o,hash:ut(o),mimeType:n,...i}}async function Ze(t){const e=await Xe(t),n=Ve.getType(t)||"application/octet-stream",i=ee(t),o=e.toString("base64");return{data:o,hash:ut(o),mimeType:n,...i}}var ne=(t=>(t.UNEXPECTED_INDEX="UNEXPECTED_INDEX",t))(ne||{}),ie=(t=>(t.DUPLICATED_INDEX="DUPLICATED_INDEX",t.MISSING_INDEX="MISSING_INDEX",t))(ie||{});function $t(t){const e=[];let n=-1;for(const i of t){const o=i.index-i.skip;o!==n+1&&e.push({operation:{index:i.index,skip:i.skip},issue:"UNEXPECTED_INDEX",category:o>n+1?"MISSING_INDEX":"DUPLICATED_INDEX",message:`Expected index ${n+1} with skip 0 or equivalent, got index ${i.index} with skip ${i.skip}`}),n=i.index}return e}function B(t){var i,o,a;const e=[];let n=t.length-1;for(;n>-1;){e.unshift(t[n]);const r=(((i=t[n])==null?void 0:i.index)||0)-(((o=t[n])==null?void 0:o.skip)||0)-1;let p=n-1;for(;p>-1&&(((a=t[p])==null?void 0:a.index)||0)>r;)p--;n=p}return e}function Qe(t){const e=[...t],n=e[e.length-1];return n&&(n.type==="NOOP"?e.push({...n,index:n.index,type:"NOOP",skip:re(t)}):e.push({type:"NOOP",index:n.index+1,timestamp:new Date().toISOString(),input:{},skip:1,scope:n.scope,hash:n.hash})),e}function X(t){return t.slice().sort((e,n)=>e.skip-n.skip).sort((e,n)=>e.index-n.index)}const Ye=(t,e,n)=>[...e,...n].sort((i,o)=>new Date(i.timestamp).getTime()-new Date(o.timestamp).getTime()).map((i,o)=>({...i,index:t.index+o,skip:o===0?t.skip:0})),tn=(t,e,n)=>[...e,...n].sort((i,o)=>new Date(i.timestamp).getTime()-new Date(o.timestamp).getTime()).sort((i,o)=>i.index-o.index).map((i,o)=>({...i,index:t.index+o,skip:o===0?t.skip:0}));function kt(t,e){return Z(t)===Z(e)}function en(t,e){const n=B(X(t.slice())),i=B(X(e.slice()));if(n.length<1)return[i,[]];const o=[];let a=!1;for(;i.length>0;){const r=i[0];let p=n.shift();for(;p&&oe(p,r);)o.push(p),p=n.shift();if(p?a||(kt(p,r)?(i.shift(),o.push(p)):(n.unshift(p),a=!0)):a=!0,a){let m=i.shift();for(;m;)o.push(m),m=i.shift()}}if(!a){let r=n.shift();for(;r;)o.push(r),r=n.shift()}return[B(o),n]}function oe(t,e){return t.index<e.index||t.index===e.index&&t.id===e.id&&t.skip<e.skip}function se(t,e){const n=[],i=[],o=[],a=Math.max(t.length,e.length);let r=!1;for(let p=0;p<a;p++){const m=t[p],u=e[p];m&&u?!r&&kt(m,u)?n.push(m):(r=!0,i.push(m),o.push(u)):m?i.push(m):u&&o.push(u)}return[n,i,o]}function nn(t,e,n){const[i,o,a]=se(B(t),B(e)),r=ft(i),p=1+Math.max(r,ft(o),ft(a)),m=pe(a,o),u=n({index:p,skip:p-(r+1)},o,m);return i.concat(u)}function ft(t){const e=t[t.length-1];return e?e.index:-1}function re(t){var i,o,a;if(t.length<1)return-1;const e=B(t);let n=(((i=e[e.length-1])==null?void 0:i.skip)||0)+1;return e.length>1&&(n+=((o=e[e.length-2])==null?void 0:o.skip)||0),(((a=e[e.length-1])==null?void 0:a.index)||-1)<n?-1:n}const on=t=>$t(B(X(t))),sn=t=>t.reduce((n,i)=>{var o;return n[i.scope]||(n[i.scope]=[]),(o=n[i.scope])==null||o.push(i),n},{}),rn=(t,e)=>{var m;const n={integrityIssues:[],validOperations:[],invalidOperations:[],duplicatedOperations:[]},i=X(t),o=X(e),a=$t([...i,...o]),p=(m=[...a.filter(u=>u.category==="MISSING_INDEX")].sort((u,h)=>h.operation.index-u.operation.index).pop())==null?void 0:m.operation;for(const u of o){if(p&&u.index>=p.index){n.invalidOperations.push(u);continue}if(a.some(b=>b.operation.index===u.index&&b.operation.skip===u.skip&&b.category==="DUPLICATED_INDEX")){n.duplicatedOperations.push(u);continue}n.validOperations.push(u)}return n.integrityIssues.push(...a),n};function an(t,e){return t.filter(n=>!e.some(i=>n.type==="NOOP"&&n.skip===0&&n.index===i.index||n.index===i.index&&n.skip===i.skip&&n.scope===i.scope&&n.hash===i.hash&&n.type===i.type))}function ae(t,e){const[n]=X(t).slice(-1),i=(n==null?void 0:n.index)??-1,o=i+1,a={...e,index:e.index??o};if(a.index<i)throw new Error(`The skip header operation index must be greater than or equal to ${i}`);return(B(X([...t,a]))||[]).slice(0,-1)}function yt(t){return{...Object.entries(t).reduce((n,i)=>{const[o,a]=i;return{...n,[o]:B(X(a))}},{})}}function pe(t,e){return t.filter(n=>n.id?!e.some(i=>i.id===n.id):!0)}const pn=Object.freeze(Object.defineProperty({__proto__:null,IntegrityIssueSubType:ie,IntegrityIssueType:ne,addUndo:Qe,attachBranch:en,checkCleanedOperationsIntegrity:$t,checkOperationsIntegrity:on,filterDuplicatedOperations:pe,garbageCollect:B,garbageCollectDocumentOperations:yt,groupOperationsByScope:sn,merge:nn,nextSkipNumber:re,operationsAreEqual:kt,precedes:oe,prepareOperations:rn,removeExistingOperations:an,reshuffleByTimestamp:Ye,reshuffleByTimestampAndIndex:tn,skipHeaderOperations:ae,sortOperations:X,split:se},Symbol.toStringTag,{value:"Module"}));function cn(t,e){let n;return"index"in e?n={...e}:n=t.operations[e.scope].at(-1),((n==null?void 0:n.index)??-1)+1}function zt(t,e){return{...t,revision:{...t.revision,[e.scope]:cn(t,e)},lastModified:new Date().toISOString()}}function ln(t,e,n=0){if([it,ot,mt].includes(e.type))return t;const{scope:i}=e,o=t.operations[i].slice();let a;const r=o.at(-1);let p=((r==null?void 0:r.index)??-1)+1;if("index"in e){if(e.index-n>p)throw new Error(`Missing operations: expected ${p} with skip 0 or equivalent, got index ${e.index} with skip ${n}`);p=e.index,a=e.id}else a=Me();return o.push({...e,id:a,index:p,timestamp:new Date().toISOString(),hash:"",scope:i,skip:n,error:void 0}),{...t,operations:{...t.operations,[i]:o}}}function ce(t,e,n=0){let i=ln(t,e,n);return i=zt(i,e),i}function mn(t,e,n){switch(qt().parse(e),e.type){case Kt:return Re(t,e.input);case mt:return Le(t,e,n);case Wt:return qe(t,e.input.state);default:return t}}function un(t,e,n){switch(e.type){case it:return Fe(t,e,n);case ot:return Ue(t,e,n);default:return{document:t,action:e,skip:n}}}function dn(t,e,n,i,o=!1,a=_t){const r=e.scope,p=t.operations[r].at(-1);if(!p)return t;const m=yt({...t.operations,[r]:ae(t.operations[r],p)});let u;const h=m[r].at(-1);if(o&&(h!=null&&h.resultingState))u=a(h.resultingState);else{const{state:b}=lt(t.initialState,m,n,void 0,void 0,void 0,void 0,{reuseHash:!0,reuseOperationResultingState:o,operationResultingStateParser:a});u=b[r]}return{...t,state:{...t.state,[r]:u},operations:yt({...t.operations})}}function Tt(t,e,n,i,o={}){const{skip:a,ignoreSkipOperations:r=!1,reuseHash:p=!1,reuseOperationResultingState:m=!1,operationResultingStateParser:u}=o,h={...e},b=a||0;let w={...t};const _=!r&&(b>0||"index"in h&&h.skip>0);return bt(h)&&(w=mn(w,h,n)),w=ce(w,h,b),_&&(w=dn(w,h,n,b,m,u)),w=H.produce(w,D=>{try{const P=n(D.state,h,i);if(P)return H.castDraft({...w,state:P})}catch(P){const U=w.operations[h.scope].length-1;D.operations[h.scope][U].error=P.message,D.operations[h.scope][U].skip=0,_&&(D.state=H.castDraft({...t.state}),D.operations=H.castDraft({...t.operations,[h.scope]:[...t.operations[h.scope],{...D.operations[h.scope][U]}]}))}}),H.produce(w,D=>{if([it,ot,mt].includes(h.type))return D;const P=h.scope||"global",U=p&&Object.prototype.hasOwnProperty.call(h,"hash")?h.hash:dt(D,P),c=D.operations[P].at(-1);c&&(c.hash=U,m&&(c.resultingState=D.state[P]),!bt(h)&&h.attachments&&h.attachments.forEach(l=>{const{hash:d,...k}=l;D.attachments[d]={...k}}))})}function fn(t){return t.type===Ce&&t.skip!==void 0&&t.skip>0&&t.hash!==void 0}function gn(t){return[it,ot].includes(t.type)}function bt(t){return[Kt,it,ot,mt,Wt].includes(t.type)}function W(t,e,n,i,o="global"){if(!t)throw new Error("Empty action type");if(typeof t!="string")throw new Error(`Invalid action type: ${JSON.stringify(t)}`);const a={type:t,input:e,scope:o};n&&(a.attachments=n);try{i==null||i().parse(a.input)}catch(r){throw new Error(`Invalid action input: ${r}`)}return a}function le(t,e=Tt){return(n,i,o,a)=>e(n,i,t,o,a)}const me=(t,e)=>({name:"",documentType:"",revision:{global:0,local:0},created:new Date().toISOString(),lastModified:new Date().toISOString(),attachments:{},...t,state:(e==null?void 0:e(t==null?void 0:t.state))??(t==null?void 0:t.state)??{global:{},local:{}}}),ue=(t,e)=>{const n=me(t,e);return{...n,initialState:n,operations:{global:[],local:[]},clipboard:[]}},dt=(t,e="global")=>ut(Z(t.state[e]||"")),hn=(t,e=1e3)=>{const n=Math.random()*e;return ut(`${(t??new Date).toISOString()}${n}`)};function et(t){return H.castImmutable(H.freeze(t,!0))}function xn(t,e){const n=[...t];let i=e||0,o=n.length>0?n[n.length-1].index:0;const a=[];for(const r of n.reverse()){if(i>0){const u=o-r.index;i-=u}if(i<0)throw new Error("Invalid operation index, missing operations");const p={ignore:i>0,operation:r},m=r.skip>0?r.skip+1:0;if(m>0&&m>i){const u=m-i;i=i+u}o=r.index,a.push(p)}return a.reverse()}function yn(t,e,n){const i=t.slice().sort((p,m)=>p.skip-m.skip).sort((p,m)=>p.index-m.index);let o=n,a=0,r=e;for(const p of i.reverse()){const m=r-p.index;if(o=o-m,o>-1)a++,r=p.index;else break}return a}function bn(t){return Object.values(t).flatMap(e=>e).sort((e,n)=>new Date(e.timestamp).getTime()-new Date(n.timestamp).getTime())}function wn(t){return Object.values(t).flatMap(e=>e).sort((e,n)=>new Date(e.operation.timestamp).getTime()-new Date(n.operation.timestamp).getTime())}function lt(t,e,n,i,o,a=Tt,r={},p){const m=le(n,a);return vt(t,e,m,i,o,r,p)}function vt(t,e,n,i,o,a={},r){const{checkHashes:p=!0,reuseOperationResultingState:m,operationResultingStateParser:u=_t}=r||{};let h=t;const b=[],w={global:[],local:[]};if(m)for(const[c,l]of Object.entries(e)){const d=l.findLastIndex(L=>!!L.resultingState);if(d<0){b.push(...l);continue}const k=l[d];try{const L=u(k.resultingState);h={...h,state:{...h.state,[c]:L}},w[c].push(...l.slice(0,d+1)),b.push(...l.slice(d+1))}catch{b.push(...l)}}else b.push(...Object.values(e).flat());const _=ue(h);_.initialState=t,_.operations=w;let D=_;if(b.length)D=b.reduce((c,l)=>n(c,l,i,{skip:l.skip,ignoreSkipOperations:!0,reuseHash:!p}),_);else for(const c of Object.values(w)){const l=c.at(-1);l&&(D=zt(D,l))}if(!p)for(const c of Object.keys(D.state))for(let l=b.length-1;l>=0;l--){const d=b[l];if(d.scope===c){if(d.hash!==dt(D,c))throw new Error(`Hash mismatch for scope ${c}`);break}}const P=Object.keys(D.operations).reduce((c,l)=>{const d=l;return{...c,[d]:[...D.operations[d].map((k,L)=>{var M;return{...k,timestamp:((M=e[d][L])==null?void 0:M.timestamp)??k.timestamp}})]}},{global:[],local:[]}),U=Object.values(P).reduce((c,l)=>{const d=l[l.length-1];return(d==null?void 0:d.timestamp)>c&&(c=d.timestamp),c},t.lastModified);return{...D,operations:P,lastModified:U}}function On(t,e){return Z(t)===Z(e)}function _t(t){const e=typeof t;if(e==="string")return JSON.parse(t);if(e==="object")return t;throw new Error(`Providing resulting state is of type: ${e}`)}const de=t=>W("SET_NAME",t,void 0,jt,void 0),fe=(t=1,e="global")=>W("UNDO",t,void 0,Et,e),ge=(t=1,e="global")=>W("REDO",t,void 0,St,e),he=(t,e,n="global")=>W("PRUNE",{start:t,end:e},void 0,Ot,n),It=(t,e)=>W("LOAD_STATE",{state:t,operations:e},void 0,wt),xe=(t="global")=>W("NOOP",{},void 0,void 0,t),Sn=Object.freeze(Object.defineProperty({__proto__:null,loadState:It,noop:xe,prune:he,redo:ge,setName:de,undo:fe},Symbol.toStringTag,{value:"Module"}));class jn{constructor(e,n,i){pt(this,"_document");pt(this,"_reducer");pt(this,"_signalDispatch");this._reducer=e,this._document=n,this._signalDispatch=i}dispatch(e,n){return this._document=this._reducer(this._document,e,this._signalDispatch,n),this}saveToFile(e,n,i){return Yt(this._document,e,n,i)}async loadFromFile(e){this._document=await xt(e,this._reducer)}static async stateFromFile(e,n){return await xt(e,n)}get state(){return et(this._document.state)}get operations(){return et(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(e){return this._document.revision[e]}get initialState(){return et(this._document.initialState)}toDocument(){return et(this._document)}getAttachment(e){return this._document.attachments[e]}setName(e){return this.dispatch(de(e)),this}undo(e){return this.dispatch(fe(e)),this}redo(e){return this.dispatch(ge(e)),this}prune(e,n){return this.dispatch(he(e,n)),this}loadState(e,n){return this.dispatch(It(e,n)),this}}function En(t,e){e.forEach(n=>{Object.getOwnPropertyNames(n.prototype).forEach(i=>{Object.defineProperty(t.prototype,i,Object.getOwnPropertyDescriptor(n.prototype,i)||Object.create(null))})})}exports.BaseActions=Sn;exports.BaseDocument=jn;exports.applyMixins=En;exports.baseReducer=Tt;exports.calculateSkipsLeft=yn;exports.createAction=W;exports.createDocument=ue;exports.createExtendedState=me;exports.createReducer=le;exports.createZip=Dt;exports.documentHelpers=pn;exports.getLocalFile=Ze;exports.getRemoteFile=Ge;exports.hashDocument=dt;exports.hashKey=hn;exports.isBaseAction=bt;exports.isNoopOperation=fn;exports.isSameDocument=On;exports.isUndoRedo=gn;exports.loadFromFile=xt;exports.loadFromInput=te;exports.mapSkippedOperations=xn;exports.parseResultingState=_t;exports.processUndoRedo=un;exports.readOnly=et;exports.replayDocument=vt;exports.replayOperations=lt;exports.saveToFile=Yt;exports.saveToFileHandle=Ke;exports.sortMappedOperations=wn;exports.sortOperations=bn;exports.updateDocument=ce;exports.updateHeader=zt;exports.validateOperations=Qt;exports.zod=Te;
@@ -1,11 +1,11 @@
1
- import "./internal/object-2jyfnUeK.js";
1
+ import "./internal/object-BegIqJta.js";
2
2
  import "immer";
3
3
  import "jszip";
4
4
  import "crypto";
5
5
  import "fs";
6
6
  import "https";
7
7
  import "path";
8
- import { b as p, a as u, c, d as n, m as v, r as M, u as S, v as f, g as h, h as D, f as b, e as g, z as x } from "./internal/index-pNw-lk-q.js";
8
+ import { b as p, a as u, c, d as n, m as v, r as M, u as S, v as f, g as h, h as D, f as b, e as g, z as x } from "./internal/index-CpzdJD_a.js";
9
9
  import "zod";
10
10
  export {
11
11
  p as Document,
@@ -1,5 +1,5 @@
1
- import { B as d, h as u, g as c, E as n, F as x, G as f, H as l, I as B } from "./internal/object-2jyfnUeK.js";
2
- import { i as H } from "./internal/index-DEAJDDrx.js";
1
+ import { B as d, h as u, g as c, E as n, F as x, G as f, H as l, I as B } from "./internal/object-BegIqJta.js";
2
+ import { i as H } from "./internal/index-O3hyddph.js";
3
3
  import "immer";
4
4
  import "zod";
5
5
  import "jszip";
@@ -1,6 +1,6 @@
1
- import { D as o } from "./internal/index-DEAJDDrx.js";
2
- import { D as t } from "./internal/index-pNw-lk-q.js";
3
- import "./internal/object-2jyfnUeK.js";
1
+ import { D as o } from "./internal/index-O3hyddph.js";
2
+ import { D as t } from "./internal/index-CpzdJD_a.js";
3
+ import "./internal/object-BegIqJta.js";
4
4
  import "immer";
5
5
  import "zod";
6
6
  import "jszip";
@@ -1,7 +1,7 @@
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-2jyfnUeK.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-BegIqJta.js";
5
5
  import "immer";
6
6
  import "jszip";
7
7
  import "crypto";
@@ -1,4 +1,4 @@
1
- import { j as e, f as a, b as s, a as t, c as o, k as r, m as n, n as i, o as p, p as c, q as l, i as d, r as u, t as m, u as O, l as y, e as D, v as S, w as b, x as g, y as F, z as _, s as f, d as v, A as R, C as h, D as j, B as x, h as z, g as A, E as B, F as H, G as M, H as T, I as k } from "./object-DenwvByi.js";
1
+ import { j as e, f as a, b as s, a as t, c as o, k as r, m as n, n as i, o as p, p as c, q as l, i as d, r as u, t as m, u as O, l as y, e as D, v as S, w as b, x as g, y as F, z as _, s as f, d as v, A as R, C as h, D as j, B as x, h as z, g as A, E as B, F as H, G as M, H as T, I as k } from "./object-BegIqJta.js";
2
2
  const E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3
3
  __proto__: null,
4
4
  calculateSkipsLeft: e,
@@ -803,7 +803,7 @@ const Kt = async (t) => {
803
803
  return e.file("header.json", JSON.stringify(p, null, 2)), e.file(
804
804
  "state.json",
805
805
  JSON.stringify(t.initialState || {}, null, 2)
806
- ), e.file("operations.json", JSON.stringify(t.operations, null, 2)), Object.keys(t.attachments).forEach((u) => {
806
+ ), e.file("operations.json", JSON.stringify(t.operations, null, 2)), t.attachments && Object.keys(t.attachments).forEach((u) => {
807
807
  const { data: h, ...b } = t.attachments[u];
808
808
  e.file(u, h, {
809
809
  base64: !0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "document-model",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "license": "AGPL-3.0-only",
5
5
  "private": false,
6
6
  "files": [