document-model 1.0.50 → 1.0.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/cjs/document-model.js +1 -1
- package/dist/browser/cjs/document.js +1 -1
- package/dist/browser/cjs/index.js +1 -1
- package/dist/{node/cjs/internal/index-CRjFLQNR.js → browser/cjs/internal/index-BVWyYyNE.js} +1 -1
- package/dist/browser/cjs/internal/{index-CPJM383s.js → index-CnVGNZ9_.js} +1 -1
- package/dist/browser/cjs/internal/object-5l5_pTNL.js +25 -0
- package/dist/browser/es/document-model.js +2 -2
- package/dist/browser/es/document.js +2 -2
- package/dist/browser/es/index.js +3 -3
- package/dist/browser/es/internal/{index-tEH7iGUj.js → index-CF0d1_Cg.js} +1 -1
- package/dist/browser/es/internal/{index-BzIVYv7p.js → index-aS_vqu4O.js} +1 -1
- package/dist/browser/es/internal/{object-Dev4WFVH.js → object-BdaEhPk1.js} +770 -771
- package/dist/browser/src/document/object.d.ts +35 -0
- package/dist/browser/src/document/types.d.ts +2 -0
- package/dist/node/cjs/document-model.js +1 -1
- package/dist/node/cjs/document.js +1 -1
- package/dist/node/cjs/index.js +1 -1
- package/dist/{browser/cjs/internal/index-REU04m7f.js → node/cjs/internal/index-B9gc2lPN.js} +1 -1
- package/dist/node/cjs/internal/{index-BX95XaQ_.js → index-JtuONOcD.js} +1 -1
- package/dist/node/cjs/internal/object-D6wRzEDN.js +20 -0
- package/dist/node/es/document-model.js +2 -2
- package/dist/node/es/document.js +2 -2
- package/dist/node/es/index.js +3 -3
- package/dist/node/es/internal/{index-BzNCX_-9.js → index-BclkoIYP.js} +1 -1
- package/dist/node/es/internal/{index-DpH4_29z.js → index-EY0PPZnJ.js} +1 -1
- package/dist/node/es/internal/{object-BFkXGmt6.js → object-BxC3xMqY.js} +509 -510
- package/dist/node/src/document/object.d.ts +35 -0
- package/dist/node/src/document/types.d.ts +2 -0
- package/package.json +1 -1
- package/dist/browser/cjs/internal/object-DkoS83BB.js +0 -25
- package/dist/node/cjs/internal/object-CGt7Qacd.js +0 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-5l5_pTNL.js");require("immer");require("jszip");const e=require("./internal/index-CnVGNZ9_.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-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal/object-5l5_pTNL.js"),o=require("./internal/index-BVWyYyNE.js");require("immer");require("zod");require("jszip");exports.BaseDocument=e.BaseDocument;exports.actions=e.BaseActions;exports.applyMixins=e.applyMixins;exports.baseReducer=e.baseReducer;exports.processUndoRedo=e.processUndoRedo;exports.z=e.zod;exports.utils=o.index;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./internal/index-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./internal/index-BVWyYyNE.js"),o=require("./internal/index-CnVGNZ9_.js");require("./internal/object-5l5_pTNL.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 +1 @@
|
|
|
1
|
-
"use strict";const e=require("./object-
|
|
1
|
+
"use strict";const e=require("./object-5l5_pTNL.js"),t=Object.freeze(Object.defineProperty({__proto__:null,calculateSkipsLeft:e.calculateSkipsLeft,createAction:e.createAction,createDocument:e.createDocument,createExtendedState:e.createExtendedState,createReducer:e.createReducer,createZip:e.createZip,getLocalFile:e.getLocalFile,getRemoteFile:e.getRemoteFile,hashDocument:e.hashDocument,hashKey:e.hashKey,isBaseAction:e.isBaseAction,isNoopOperation:e.isNoopOperation,isSameDocument:e.isSameDocument,isUndoRedo:e.isUndoRedo,loadFromFile:e.loadFromFile,loadFromInput:e.loadFromInput,mapSkippedOperations:e.mapSkippedOperations,readOnly:e.readOnly,replayDocument:e.replayDocument,replayOperations:e.replayOperations,saveToFile:e.saveToFile,saveToFileHandle:e.saveToFileHandle,sortMappedOperations:e.sortMappedOperations,sortOperations:e.sortOperations,validateOperations:e.validateOperations},Symbol.toStringTag,{value:"Module"})),o=Object.freeze(Object.defineProperty({__proto__:null,BaseDocument:e.BaseDocument,actions:e.BaseActions,applyMixins:e.applyMixins,baseReducer:e.baseReducer,processUndoRedo:e.processUndoRedo,utils:t,z:e.zod},Symbol.toStringTag,{value:"Module"}));exports.Document=o;exports.index=t;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Tt=Object.defineProperty;var Rt=(t,e,r)=>e in t?Tt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var be=(t,e,r)=>(Rt(t,typeof e!="symbol"?e+"":e,r),r);const s=require("./object-
|
|
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-5l5_pTNL.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": "",
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";var We=Object.defineProperty;var He=(r,i,s)=>i in r?We(r,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[i]=s;var St=(r,i,s)=>(He(r,typeof i!="symbol"?i+"":i,s),s);const ot=require("immer"),v=require("zod"),ie=require("jszip"),ne=r=>r!=null,Ve=v.z.any().refine(r=>ne(r)),oe=v.z.enum(["LOAD_STATE"]),ae=v.z.enum(["PRUNE"]),se=v.z.enum(["REDO"]),pe=v.z.enum(["SET_NAME"]),ce=v.z.enum(["UNDO"]);function Ke(){return v.z.object({__typename:v.z.literal("Action").optional(),type:v.z.string()})}function gt(){return v.z.literal("global").or(v.z.literal("local"))}function le(){return v.z.union([ue(),he(),me(),xe(),de()])}function Ze(){return v.z.object({__typename:v.z.literal("DocumentFile").optional(),data:v.z.string(),extension:v.z.string().nullable(),fileName:v.z.string().nullable(),mimeType:v.z.string()})}function ue(){return v.z.object({input:v.z.lazy(()=>Lt()),type:oe,scope:gt()})}function Lt(){return v.z.object({operations:v.z.number(),state:v.z.lazy(()=>fe())})}function fe(){return v.z.object({data:v.z.unknown().nullish(),name:v.z.string()})}function Ge(){return v.z.object({__typename:v.z.literal("Operation").optional(),hash:v.z.string(),index:v.z.number(),timestamp:v.z.string().datetime(),type:v.z.string()})}function he(){return v.z.object({input:v.z.lazy(()=>Pt()),type:ae,scope:gt()})}function Pt(){return v.z.object({end:v.z.number().nullish(),start:v.z.number().nullish()})}const qt=v.z.number;function me(){return v.z.object({input:qt(),type:se,scope:gt()})}const Jt=v.z.string;function xe(){return v.z.object({input:Jt(),type:pe,scope:v.z.literal("global")})}function Ye(){return v.z.object({__typename:v.z.literal("SetNameOperation").optional(),hash:v.z.string(),index:v.z.number(),input:v.z.string(),timestamp:v.z.string().datetime(),type:v.z.string()})}const Wt=v.z.number;function de(){return v.z.object({input:Wt(),type:ce,scope:gt()})}const Xe=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:Ke,BaseActionSchema:le,DocumentFileSchema:Ze,LoadStateActionInputSchema:Lt,LoadStateActionSchema:ue,LoadStateActionStateInputSchema:fe,Load_StateSchema:oe,OperationSchema:Ge,OperationScopeSchema:gt,PruneActionInputSchema:Pt,PruneActionSchema:he,PruneSchema:ae,RedoActionInputSchema:qt,RedoActionSchema:me,RedoSchema:se,SetNameActionInputSchema:Jt,SetNameActionSchema:xe,SetNameOperationSchema:Ye,Set_NameSchema:pe,UndoActionInputSchema:Wt,UndoActionSchema:de,UndoSchema:ce,definedNonNullAnySchema:Ve,isDefinedNonNullAny:ne},Symbol.toStringTag,{value:"Module"}));function Ht(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var $t={exports:{}};(function(r,i){const{hasOwnProperty:s}=Object.prototype,p=C();p.configure=C,p.stringify=p,p.default=p,i.stringify=p,i.configure=C,r.exports=p;const f=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/;function u(y){return y.length<5e3&&!f.test(y)?`"${y}"`:JSON.stringify(y)}function l(y){if(y.length>200)return y.sort();for(let b=1;b<y.length;b++){const I=y[b];let W=b;for(;W!==0&&y[W-1]>I;)y[W]=y[W-1],W--;y[W]=I}return y}const a=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function h(y){return a.call(y)!==void 0&&y.length!==0}function w(y,b,I){y.length<I&&(I=y.length);const W=b===","?"":" ";let Y=`"0":${W}${y[0]}`;for(let G=1;G<I;G++)Y+=`${b}"${G}":${W}${y[G]}`;return Y}function g(y){if(s.call(y,"circularValue")){const b=y.circularValue;if(typeof b=="string")return`"${b}"`;if(b==null)return b;if(b===Error||b===TypeError)return{toString(){throw new TypeError("Converting circular structure to JSON")}};throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined')}return'"[Circular]"'}function A(y,b){let I;if(s.call(y,b)&&(I=y[b],typeof I!="boolean"))throw new TypeError(`The "${b}" argument must be of type boolean`);return I===void 0?!0:I}function S(y,b){let I;if(s.call(y,b)){if(I=y[b],typeof I!="number")throw new TypeError(`The "${b}" argument must be of type number`);if(!Number.isInteger(I))throw new TypeError(`The "${b}" argument must be an integer`);if(I<1)throw new RangeError(`The "${b}" argument must be >= 1`)}return I===void 0?1/0:I}function F(y){return y===1?"1 item":`${y} items`}function D(y){const b=new Set;for(const I of y)(typeof I=="string"||typeof I=="number")&&b.add(String(I));return b}function R(y){if(s.call(y,"strict")){const b=y.strict;if(typeof b!="boolean")throw new TypeError('The "strict" argument must be of type boolean');if(b)return I=>{let W=`Object can not safely be stringified. Received type ${typeof I}`;throw typeof I!="function"&&(W+=` (${I.toString()})`),new Error(W)}}}function C(y){y={...y};const b=R(y);b&&(y.bigint===void 0&&(y.bigint=!1),"circularValue"in y||(y.circularValue=Error));const I=g(y),W=A(y,"bigint"),Y=A(y,"deterministic"),G=S(y,"maximumDepth"),M=S(y,"maximumBreadth");function ut(H,m,E,T,O,$){let _=m[H];switch(typeof _=="object"&&_!==null&&typeof _.toJSON=="function"&&(_=_.toJSON(H)),_=T.call(m,H,_),typeof _){case"string":return u(_);case"object":{if(_===null)return"null";if(E.indexOf(_)!==-1)return I;let k="",B=",";const j=$;if(Array.isArray(_)){if(_.length===0)return"[]";if(G<E.length+1)return'"[Array]"';E.push(_),O!==""&&($+=O,k+=`
|
|
2
|
+
${$}`,B=`,
|
|
3
|
+
${$}`);const V=Math.min(_.length,M);let Q=0;for(;Q<V-1;Q++){const pt=ut(String(Q),_,E,T,O,$);k+=pt!==void 0?pt:"null",k+=B}const tt=ut(String(Q),_,E,T,O,$);if(k+=tt!==void 0?tt:"null",_.length-1>M){const pt=_.length-M-1;k+=`${B}"... ${F(pt)} not stringified"`}return O!==""&&(k+=`
|
|
4
|
+
${j}`),E.pop(),`[${k}]`}let L=Object.keys(_);const J=L.length;if(J===0)return"{}";if(G<E.length+1)return'"[Object]"';let z="",K="";O!==""&&($+=O,B=`,
|
|
5
|
+
${$}`,z=" ");const X=Math.min(J,M);Y&&!h(_)&&(L=l(L)),E.push(_);for(let V=0;V<X;V++){const Q=L[V],tt=ut(Q,_,E,T,O,$);tt!==void 0&&(k+=`${K}${u(Q)}:${z}${tt}`,K=B)}if(J>M){const V=J-M;k+=`${K}"...":${z}"${F(V)} not stringified"`,K=B}return O!==""&&K.length>1&&(k=`
|
|
6
|
+
${$}${k}
|
|
7
|
+
${j}`),E.pop(),`{${k}}`}case"number":return isFinite(_)?String(_):b?b(_):"null";case"boolean":return _===!0?"true":"false";case"undefined":return;case"bigint":if(W)return String(_);default:return b?b(_):void 0}}function ft(H,m,E,T,O,$){switch(typeof m=="object"&&m!==null&&typeof m.toJSON=="function"&&(m=m.toJSON(H)),typeof m){case"string":return u(m);case"object":{if(m===null)return"null";if(E.indexOf(m)!==-1)return I;const _=$;let k="",B=",";if(Array.isArray(m)){if(m.length===0)return"[]";if(G<E.length+1)return'"[Array]"';E.push(m),O!==""&&($+=O,k+=`
|
|
8
|
+
${$}`,B=`,
|
|
9
|
+
${$}`);const J=Math.min(m.length,M);let z=0;for(;z<J-1;z++){const X=ft(String(z),m[z],E,T,O,$);k+=X!==void 0?X:"null",k+=B}const K=ft(String(z),m[z],E,T,O,$);if(k+=K!==void 0?K:"null",m.length-1>M){const X=m.length-M-1;k+=`${B}"... ${F(X)} not stringified"`}return O!==""&&(k+=`
|
|
10
|
+
${_}`),E.pop(),`[${k}]`}E.push(m);let j="";O!==""&&($+=O,B=`,
|
|
11
|
+
${$}`,j=" ");let L="";for(const J of T){const z=ft(J,m[J],E,T,O,$);z!==void 0&&(k+=`${L}${u(J)}:${j}${z}`,L=B)}return O!==""&&L.length>1&&(k=`
|
|
12
|
+
${$}${k}
|
|
13
|
+
${_}`),E.pop(),`{${k}}`}case"number":return isFinite(m)?String(m):b?b(m):"null";case"boolean":return m===!0?"true":"false";case"undefined":return;case"bigint":if(W)return String(m);default:return b?b(m):void 0}}function at(H,m,E,T,O){switch(typeof m){case"string":return u(m);case"object":{if(m===null)return"null";if(typeof m.toJSON=="function"){if(m=m.toJSON(H),typeof m!="object")return at(H,m,E,T,O);if(m===null)return"null"}if(E.indexOf(m)!==-1)return I;const $=O;if(Array.isArray(m)){if(m.length===0)return"[]";if(G<E.length+1)return'"[Array]"';E.push(m),O+=T;let z=`
|
|
14
|
+
${O}`;const K=`,
|
|
15
|
+
${O}`,X=Math.min(m.length,M);let V=0;for(;V<X-1;V++){const tt=at(String(V),m[V],E,T,O);z+=tt!==void 0?tt:"null",z+=K}const Q=at(String(V),m[V],E,T,O);if(z+=Q!==void 0?Q:"null",m.length-1>M){const tt=m.length-M-1;z+=`${K}"... ${F(tt)} not stringified"`}return z+=`
|
|
16
|
+
${$}`,E.pop(),`[${z}]`}let _=Object.keys(m);const k=_.length;if(k===0)return"{}";if(G<E.length+1)return'"[Object]"';O+=T;const B=`,
|
|
17
|
+
${O}`;let j="",L="",J=Math.min(k,M);h(m)&&(j+=w(m,B,M),_=_.slice(m.length),J-=m.length,L=B),Y&&(_=l(_)),E.push(m);for(let z=0;z<J;z++){const K=_[z],X=at(K,m[K],E,T,O);X!==void 0&&(j+=`${L}${u(K)}: ${X}`,L=B)}if(k>M){const z=k-M;j+=`${L}"...": "${F(z)} not stringified"`,L=B}return L!==""&&(j=`
|
|
18
|
+
${O}${j}
|
|
19
|
+
${$}`),E.pop(),`{${j}}`}case"number":return isFinite(m)?String(m):b?b(m):"null";case"boolean":return m===!0?"true":"false";case"undefined":return;case"bigint":if(W)return String(m);default:return b?b(m):void 0}}function st(H,m,E){switch(typeof m){case"string":return u(m);case"object":{if(m===null)return"null";if(typeof m.toJSON=="function"){if(m=m.toJSON(H),typeof m!="object")return st(H,m,E);if(m===null)return"null"}if(E.indexOf(m)!==-1)return I;let T="";if(Array.isArray(m)){if(m.length===0)return"[]";if(G<E.length+1)return'"[Array]"';E.push(m);const B=Math.min(m.length,M);let j=0;for(;j<B-1;j++){const J=st(String(j),m[j],E);T+=J!==void 0?J:"null",T+=","}const L=st(String(j),m[j],E);if(T+=L!==void 0?L:"null",m.length-1>M){const J=m.length-M-1;T+=`,"... ${F(J)} not stringified"`}return E.pop(),`[${T}]`}let O=Object.keys(m);const $=O.length;if($===0)return"{}";if(G<E.length+1)return'"[Object]"';let _="",k=Math.min($,M);h(m)&&(T+=w(m,",",M),O=O.slice(m.length),k-=m.length,_=","),Y&&(O=l(O)),E.push(m);for(let B=0;B<k;B++){const j=O[B],L=st(j,m[j],E);L!==void 0&&(T+=`${_}${u(j)}:${L}`,_=",")}if($>M){const B=$-M;T+=`${_}"...":"${F(B)} not stringified"`}return E.pop(),`{${T}}`}case"number":return isFinite(m)?String(m):b?b(m):"null";case"boolean":return m===!0?"true":"false";case"undefined":return;case"bigint":if(W)return String(m);default:return b?b(m):void 0}}function kt(H,m,E){if(arguments.length>1){let T="";if(typeof E=="number"?T=" ".repeat(Math.min(E,10)):typeof E=="string"&&(T=E.slice(0,10)),m!=null){if(typeof m=="function")return ut("",{"":H},[],m,T,"");if(Array.isArray(m))return ft("",H,[],D(m),T,"")}if(T.length!==0)return at("",H,[],T,"")}return st("",H,[])}return kt}})($t,$t.exports);var Qe=$t.exports;const _t=Ht(Qe);_t.configure;function tr(r,i){return{...r,name:i}}function er(r,i,s){const p={skip:s,document:r},{scope:f}=i;return!f||i.skip===void 0?p:ot.produce(p,u=>{const[l]=u.document.operations[f].slice(-1);i.skip&&i.skip>0&&(u.skip=i.skip),l.type==="NOOP"&&i.index===l.index&&u.skip>l.skip&&u.document.operations[f].pop()})}function rr(r,i,s){const{scope:p,input:f}=i,u={document:r,action:i,skip:s};return ot.produce(u,l=>{if(l.document.operations[p].length<1)throw new Error(`Cannot undo: no operations in history for scope "${p}"`);if(f<1)throw new Error("Invalid UNDO action: input value must be greater than 0");if(l.skip>0)throw new Error("Cannot undo: skip value from reducer cannot be used with UNDO action");const[a]=l.document.operations[p].slice(-1),h=a.type==="NOOP"&&a.skip>0;if(l.skip+=f,h){l.skip+=a.skip;const S=l.document.operations[p][l.document.operations[p].length-2];S&&a.index-S.index===1&&l.document.operations[p].pop()}if(l.document.operations[p].length<l.skip)throw new Error("Cannot undo: you can't undo more operations than the ones in the scope history");const w=l.document.operations[p].length-1;let g=f,A=h?w-a.skip:w;for(;g>0&&A>=0;){const S=l.document.operations[p][A];if(!S){g--,A--;continue}S.type==="NOOP"&&S.skip>0?(A=A-(S.skip+1),l.skip+=S.skip+1):(l.document.clipboard.push({...S}),g--,A--)}l.action=Qt(p)})}function ir(r,i,s){const{scope:p,input:f}=i,u={document:r,action:i,skip:s};return ot.produce(u,l=>{if(l.skip>0)throw new Error("Cannot redo: skip value from reducer cannot be used with REDO action");if(f>1)throw new Error("Cannot redo: you can only redo one operation at a time");if(f<1)throw new Error("Invalid REDO action: invalid redo input value");if(l.document.clipboard.length<1)throw new Error("Cannot redo: no operations in the clipboard");const a=l.document.clipboard.findLastIndex(w=>w.scope===p);if(a<0)throw new Error(`Cannot redo: no operations in clipboard for scope "${p}"`);const h=l.document.clipboard.splice(a,1)[0];l.action=ot.castDraft({type:h.type,scope:h.scope,input:h.input})})}function nr(r,i,s){const{scope:p}=i,f=r.operations[p];let{input:{start:u,end:l}}=i;u=u||0,l=l||f.length;const a=f.slice(u,l),h=f.slice(0,u),w=f.slice(l),g=Ft(r.initialState,{...r.operations,[p]:h.concat(a)},s),{name:A,state:S}=g,F=h.length,D=h.length?h[h.length-1].timestamp:w.length?w[0].timestamp:new Date().toISOString();return Ft(r.initialState,{...r.operations,[p]:[...h,{...Xt({name:A,state:S},a.length),timestamp:D,index:F,hash:Tt({state:S},"global")},...w.map((R,C)=>({...R,index:F+C+1}))]},s)}function or(r,i){return{...r,name:i.name,state:i.state??{global:{},local:{}}}}const ge="SET_NAME",yt="UNDO",wt="REDO",Bt="PRUNE",ye="LOAD_STATE",ar="NOOP";function sr(r,i){let s;return"index"in i?s={...i}:s=r.operations[i.scope].slice(-1)[0],((s==null?void 0:s.index)??-1)+1}function pr(r,i){return{...r,revision:{...r.revision,[i.scope]:sr(r,i)},lastModified:new Date().toISOString()}}function cr(r,i,s=0){if([yt,wt,Bt].includes(i.type))return r;const{scope:p}=i,f=r.operations[p].slice(0,r.revision[p]),u=[...f].pop();let l=((u==null?void 0:u.index)??-1)+1;if("index"in i){if(i.index>l+s)throw new Error(`Missing operations: expected ${l} with skip 0 or equivalent, got index ${i.index} with skip ${s}`);l=i.index}return f.push({...i,index:l,timestamp:new Date().toISOString(),hash:"",scope:p,skip:s,error:void 0}),{...r,operations:{...r.operations,[p]:f}}}function lr(r,i,s=0){let p=cr(r,i,s);return p=pr(p,i),p}function ur(r,i,s){switch(le().parse(i),i.type){case ge:return tr(r,i.input);case Bt:return nr(r,i,s);case ye:return or(r,i.input.state);default:return r}}function we(r,i,s){switch(i.type){case yt:return rr(r,i,s);case wt:return ir(r,i,s);default:return{document:r,action:i,skip:s}}}function Vt(r,i,s,p,f={}){const{skip:u,ignoreSkipOperations:l=!1,reuseHash:a=!1}=f;let h={...i},w=u||0,g=r,A=[...r.clipboard];if(Oe(h)){const{document:S,skip:F}=er(g,h,w);w=F,g=S}if(Nt(h)){const{skip:S,action:F,document:D}=we(r,h,w);h=F,w=S,g=D,A=[...g.clipboard]}if(Mt(h)&&(g=ur(g,h,s)),w>0&&!l){let S=w;"index"in h&&(S=De(g.operations[h.scope],h.index,w)),g=Ft(g.initialState,g.operations,s,void 0,void 0,void 0,{[h.scope]:S})}return g=lr(g,h,w),g=ot.produce(g,S=>{try{const F=s(S.state,h,p),D=Nt(i)?[...A]:[];if(F)return ot.castDraft({...g,clipboard:[...D],state:F});S.clipboard=ot.castDraft([...D])}catch(F){const D=g.operations[h.scope].length-1;S.operations[h.scope][D].error=F.message,console.error(`Error thrown in reducer. Action: ${JSON.stringify(h)}, Error:`,F)}}),ot.produce(g,S=>{if([yt,wt,Bt].includes(h.type))return S;const F=h.scope||"global",D=a&&Object.prototype.hasOwnProperty.call(h,"hash")?h.hash:Tt(S,F);S.operations[F][S.operations[F].length-1].hash=D,!Mt(h)&&h.attachments&&h.attachments.forEach(R=>{const{hash:C,...y}=R;S.attachments[C]={...y}})})}var Ct={exports:{}};typeof Object.create=="function"?Ct.exports=function(i,s){s&&(i.super_=s,i.prototype=Object.create(s.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}))}:Ct.exports=function(i,s){if(s){i.super_=s;var p=function(){};p.prototype=s.prototype,i.prototype=new p,i.prototype.constructor=i}};var be=Ct.exports,zt={exports:{}},Ee={},Ot={};Ot.byteLength=mr;Ot.toByteArray=dr;Ot.fromByteArray=wr;var nt=[],rt=[],fr=typeof Uint8Array<"u"?Uint8Array:Array,Ut="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var ht=0,hr=Ut.length;ht<hr;++ht)nt[ht]=Ut[ht],rt[Ut.charCodeAt(ht)]=ht;rt[45]=62;rt[95]=63;function ve(r){var i=r.length;if(i%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var s=r.indexOf("=");s===-1&&(s=i);var p=s===i?0:4-s%4;return[s,p]}function mr(r){var i=ve(r),s=i[0],p=i[1];return(s+p)*3/4-p}function xr(r,i,s){return(i+s)*3/4-s}function dr(r){var i,s=ve(r),p=s[0],f=s[1],u=new fr(xr(r,p,f)),l=0,a=f>0?p-4:p,h;for(h=0;h<a;h+=4)i=rt[r.charCodeAt(h)]<<18|rt[r.charCodeAt(h+1)]<<12|rt[r.charCodeAt(h+2)]<<6|rt[r.charCodeAt(h+3)],u[l++]=i>>16&255,u[l++]=i>>8&255,u[l++]=i&255;return f===2&&(i=rt[r.charCodeAt(h)]<<2|rt[r.charCodeAt(h+1)]>>4,u[l++]=i&255),f===1&&(i=rt[r.charCodeAt(h)]<<10|rt[r.charCodeAt(h+1)]<<4|rt[r.charCodeAt(h+2)]>>2,u[l++]=i>>8&255,u[l++]=i&255),u}function gr(r){return nt[r>>18&63]+nt[r>>12&63]+nt[r>>6&63]+nt[r&63]}function yr(r,i,s){for(var p,f=[],u=i;u<s;u+=3)p=(r[u]<<16&16711680)+(r[u+1]<<8&65280)+(r[u+2]&255),f.push(gr(p));return f.join("")}function wr(r){for(var i,s=r.length,p=s%3,f=[],u=16383,l=0,a=s-p;l<a;l+=u)f.push(yr(r,l,l+u>a?a:l+u));return p===1?(i=r[s-1],f.push(nt[i>>2]+nt[i<<4&63]+"==")):p===2&&(i=(r[s-2]<<8)+r[s-1],f.push(nt[i>>10]+nt[i>>4&63]+nt[i<<2&63]+"=")),f.join("")}var Kt={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Kt.read=function(r,i,s,p,f){var u,l,a=f*8-p-1,h=(1<<a)-1,w=h>>1,g=-7,A=s?f-1:0,S=s?-1:1,F=r[i+A];for(A+=S,u=F&(1<<-g)-1,F>>=-g,g+=a;g>0;u=u*256+r[i+A],A+=S,g-=8);for(l=u&(1<<-g)-1,u>>=-g,g+=p;g>0;l=l*256+r[i+A],A+=S,g-=8);if(u===0)u=1-w;else{if(u===h)return l?NaN:(F?-1:1)*(1/0);l=l+Math.pow(2,p),u=u-w}return(F?-1:1)*l*Math.pow(2,u-p)};Kt.write=function(r,i,s,p,f,u){var l,a,h,w=u*8-f-1,g=(1<<w)-1,A=g>>1,S=f===23?Math.pow(2,-24)-Math.pow(2,-77):0,F=p?0:u-1,D=p?1:-1,R=i<0||i===0&&1/i<0?1:0;for(i=Math.abs(i),isNaN(i)||i===1/0?(a=isNaN(i)?1:0,l=g):(l=Math.floor(Math.log(i)/Math.LN2),i*(h=Math.pow(2,-l))<1&&(l--,h*=2),l+A>=1?i+=S/h:i+=S*Math.pow(2,1-A),i*h>=2&&(l++,h/=2),l+A>=g?(a=0,l=g):l+A>=1?(a=(i*h-1)*Math.pow(2,f),l=l+A):(a=i*Math.pow(2,A-1)*Math.pow(2,f),l=0));f>=8;r[s+F]=a&255,F+=D,a/=256,f-=8);for(l=l<<f|a,w+=f;w>0;r[s+F]=l&255,F+=D,l/=256,w-=8);r[s+F-D]|=R*128};/*!
|
|
20
|
+
* The buffer module from node.js, for the browser.
|
|
21
|
+
*
|
|
22
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
23
|
+
* @license MIT
|
|
24
|
+
*/(function(r){var i=Ot,s=Kt,p=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;r.Buffer=a,r.SlowBuffer=b,r.INSPECT_MAX_BYTES=50;var f=2147483647;r.kMaxLength=f,a.TYPED_ARRAY_SUPPORT=u(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function u(){try{var n=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(n,t),n.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function l(n){if(n>f)throw new RangeError('The value "'+n+'" is invalid for option "size"');var t=new Uint8Array(n);return Object.setPrototypeOf(t,a.prototype),t}function a(n,t,e){if(typeof n=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return A(n)}return h(n,t,e)}a.poolSize=8192;function h(n,t,e){if(typeof n=="string")return S(n,t);if(ArrayBuffer.isView(n))return D(n);if(n==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n);if(it(n,ArrayBuffer)||n&&it(n.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(it(n,SharedArrayBuffer)||n&&it(n.buffer,SharedArrayBuffer)))return R(n,t,e);if(typeof n=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var o=n.valueOf&&n.valueOf();if(o!=null&&o!==n)return a.from(o,t,e);var c=C(n);if(c)return c;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof n[Symbol.toPrimitive]=="function")return a.from(n[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n)}a.from=function(n,t,e){return h(n,t,e)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function w(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 g(n,t,e){return w(n),n<=0?l(n):t!==void 0?typeof e=="string"?l(n).fill(t,e):l(n).fill(t):l(n)}a.alloc=function(n,t,e){return g(n,t,e)};function A(n){return w(n),l(n<0?0:y(n)|0)}a.allocUnsafe=function(n){return A(n)},a.allocUnsafeSlow=function(n){return A(n)};function S(n,t){if((typeof t!="string"||t==="")&&(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var e=I(n,t)|0,o=l(e),c=o.write(n,t);return c!==e&&(o=o.slice(0,c)),o}function F(n){for(var t=n.length<0?0:y(n.length)|0,e=l(t),o=0;o<t;o+=1)e[o]=n[o]&255;return e}function D(n){if(it(n,Uint8Array)){var t=new Uint8Array(n);return R(t.buffer,t.byteOffset,t.byteLength)}return F(n)}function R(n,t,e){if(t<0||n.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(n.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');var o;return t===void 0&&e===void 0?o=new Uint8Array(n):e===void 0?o=new Uint8Array(n,t):o=new Uint8Array(n,t,e),Object.setPrototypeOf(o,a.prototype),o}function C(n){if(a.isBuffer(n)){var t=y(n.length)|0,e=l(t);return e.length===0||n.copy(e,0,0,t),e}if(n.length!==void 0)return typeof n.length!="number"||Dt(n.length)?l(0):F(n);if(n.type==="Buffer"&&Array.isArray(n.data))return F(n.data)}function y(n){if(n>=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+" bytes");return n|0}function b(n){return+n!=n&&(n=0),a.alloc(+n)}a.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==a.prototype},a.compare=function(t,e){if(it(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),it(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var o=t.length,c=e.length,x=0,d=Math.min(o,c);x<d;++x)if(t[x]!==e[x]){o=t[x],c=e[x];break}return o<c?-1:c<o?1:0},a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return a.alloc(0);var o;if(e===void 0)for(e=0,o=0;o<t.length;++o)e+=t[o].length;var c=a.allocUnsafe(e),x=0;for(o=0;o<t.length;++o){var d=t[o];if(it(d,Uint8Array))x+d.length>c.length?a.from(d).copy(c,x):Uint8Array.prototype.set.call(c,d,x);else if(a.isBuffer(d))d.copy(c,x);else throw new TypeError('"list" argument must be an Array of Buffers');x+=d.length}return c};function I(n,t){if(a.isBuffer(n))return n.length;if(ArrayBuffer.isView(n)||it(n,ArrayBuffer))return n.byteLength;if(typeof n!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof n);var e=n.length,o=arguments.length>2&&arguments[2]===!0;if(!o&&e===0)return 0;for(var c=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return V(n).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return pt(n).length;default:if(c)return o?-1:V(n).length;t=(""+t).toLowerCase(),c=!0}}a.byteLength=I;function W(n,t,e){var o=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(n||(n="utf8");;)switch(n){case"hex":return _(this,t,e);case"utf8":case"utf-8":return m(this,t,e);case"ascii":return O(this,t,e);case"latin1":case"binary":return $(this,t,e);case"base64":return H(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),o=!0}}a.prototype._isBuffer=!0;function Y(n,t,e){var o=n[t];n[t]=n[e],n[e]=o}a.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)Y(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)Y(this,e,e+3),Y(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)Y(this,e,e+7),Y(this,e+1,e+6),Y(this,e+2,e+5),Y(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):W.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:a.compare(this,t)===0},a.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"},p&&(a.prototype[p]=a.prototype.inspect),a.prototype.compare=function(t,e,o,c,x){if(it(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),o===void 0&&(o=t?t.length:0),c===void 0&&(c=0),x===void 0&&(x=this.length),e<0||o>t.length||c<0||x>this.length)throw new RangeError("out of range index");if(c>=x&&e>=o)return 0;if(c>=x)return-1;if(e>=o)return 1;if(e>>>=0,o>>>=0,c>>>=0,x>>>=0,this===t)return 0;for(var d=x-c,U=o-e,N=Math.min(d,U),P=this.slice(c,x),Z=t.slice(e,o),q=0;q<N;++q)if(P[q]!==Z[q]){d=P[q],U=Z[q];break}return d<U?-1:U<d?1:0};function G(n,t,e,o,c){if(n.length===0)return-1;if(typeof e=="string"?(o=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,Dt(e)&&(e=c?0:n.length-1),e<0&&(e=n.length+e),e>=n.length){if(c)return-1;e=n.length-1}else if(e<0)if(c)e=0;else return-1;if(typeof t=="string"&&(t=a.from(t,o)),a.isBuffer(t))return t.length===0?-1:M(n,t,e,o,c);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?c?Uint8Array.prototype.indexOf.call(n,t,e):Uint8Array.prototype.lastIndexOf.call(n,t,e):M(n,[t],e,o,c);throw new TypeError("val must be string, number or Buffer")}function M(n,t,e,o,c){var x=1,d=n.length,U=t.length;if(o!==void 0&&(o=String(o).toLowerCase(),o==="ucs2"||o==="ucs-2"||o==="utf16le"||o==="utf-16le")){if(n.length<2||t.length<2)return-1;x=2,d/=2,U/=2,e/=2}function N(ee,re){return x===1?ee[re]:ee.readUInt16BE(re*x)}var P;if(c){var Z=-1;for(P=e;P<d;P++)if(N(n,P)===N(t,Z===-1?0:P-Z)){if(Z===-1&&(Z=P),P-Z+1===U)return Z*x}else Z!==-1&&(P-=P-Z),Z=-1}else for(e+U>d&&(e=d-U),P=e;P>=0;P--){for(var q=!0,At=0;At<U;At++)if(N(n,P+At)!==N(t,At)){q=!1;break}if(q)return P}return-1}a.prototype.includes=function(t,e,o){return this.indexOf(t,e,o)!==-1},a.prototype.indexOf=function(t,e,o){return G(this,t,e,o,!0)},a.prototype.lastIndexOf=function(t,e,o){return G(this,t,e,o,!1)};function ut(n,t,e,o){e=Number(e)||0;var c=n.length-e;o?(o=Number(o),o>c&&(o=c)):o=c;var x=t.length;o>x/2&&(o=x/2);for(var d=0;d<o;++d){var U=parseInt(t.substr(d*2,2),16);if(Dt(U))return d;n[e+d]=U}return d}function ft(n,t,e,o){return vt(V(t,n.length-e),n,e,o)}function at(n,t,e,o){return vt(Q(t),n,e,o)}function st(n,t,e,o){return vt(pt(t),n,e,o)}function kt(n,t,e,o){return vt(tt(t,n.length-e),n,e,o)}a.prototype.write=function(t,e,o,c){if(e===void 0)c="utf8",o=this.length,e=0;else if(o===void 0&&typeof e=="string")c=e,o=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(o)?(o=o>>>0,c===void 0&&(c="utf8")):(c=o,o=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var x=this.length-e;if((o===void 0||o>x)&&(o=x),t.length>0&&(o<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");c||(c="utf8");for(var d=!1;;)switch(c){case"hex":return ut(this,t,e,o);case"utf8":case"utf-8":return ft(this,t,e,o);case"ascii":case"latin1":case"binary":return at(this,t,e,o);case"base64":return st(this,t,e,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return kt(this,t,e,o);default:if(d)throw new TypeError("Unknown encoding: "+c);c=(""+c).toLowerCase(),d=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function H(n,t,e){return t===0&&e===n.length?i.fromByteArray(n):i.fromByteArray(n.slice(t,e))}function m(n,t,e){e=Math.min(n.length,e);for(var o=[],c=t;c<e;){var x=n[c],d=null,U=x>239?4:x>223?3:x>191?2:1;if(c+U<=e){var N,P,Z,q;switch(U){case 1:x<128&&(d=x);break;case 2:N=n[c+1],(N&192)===128&&(q=(x&31)<<6|N&63,q>127&&(d=q));break;case 3:N=n[c+1],P=n[c+2],(N&192)===128&&(P&192)===128&&(q=(x&15)<<12|(N&63)<<6|P&63,q>2047&&(q<55296||q>57343)&&(d=q));break;case 4:N=n[c+1],P=n[c+2],Z=n[c+3],(N&192)===128&&(P&192)===128&&(Z&192)===128&&(q=(x&15)<<18|(N&63)<<12|(P&63)<<6|Z&63,q>65535&&q<1114112&&(d=q))}}d===null?(d=65533,U=1):d>65535&&(d-=65536,o.push(d>>>10&1023|55296),d=56320|d&1023),o.push(d),c+=U}return T(o)}var E=4096;function T(n){var t=n.length;if(t<=E)return String.fromCharCode.apply(String,n);for(var e="",o=0;o<t;)e+=String.fromCharCode.apply(String,n.slice(o,o+=E));return e}function O(n,t,e){var o="";e=Math.min(n.length,e);for(var c=t;c<e;++c)o+=String.fromCharCode(n[c]&127);return o}function $(n,t,e){var o="";e=Math.min(n.length,e);for(var c=t;c<e;++c)o+=String.fromCharCode(n[c]);return o}function _(n,t,e){var o=n.length;(!t||t<0)&&(t=0),(!e||e<0||e>o)&&(e=o);for(var c="",x=t;x<e;++x)c+=Je[n[x]];return c}function k(n,t,e){for(var o=n.slice(t,e),c="",x=0;x<o.length-1;x+=2)c+=String.fromCharCode(o[x]+o[x+1]*256);return c}a.prototype.slice=function(t,e){var o=this.length;t=~~t,e=e===void 0?o:~~e,t<0?(t+=o,t<0&&(t=0)):t>o&&(t=o),e<0?(e+=o,e<0&&(e=0)):e>o&&(e=o),e<t&&(e=t);var c=this.subarray(t,e);return Object.setPrototypeOf(c,a.prototype),c};function B(n,t,e){if(n%1!==0||n<0)throw new RangeError("offset is not uint");if(n+t>e)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(t,e,o){t=t>>>0,e=e>>>0,o||B(t,e,this.length);for(var c=this[t],x=1,d=0;++d<e&&(x*=256);)c+=this[t+d]*x;return c},a.prototype.readUintBE=a.prototype.readUIntBE=function(t,e,o){t=t>>>0,e=e>>>0,o||B(t,e,this.length);for(var c=this[t+--e],x=1;e>0&&(x*=256);)c+=this[t+--e]*x;return c},a.prototype.readUint8=a.prototype.readUInt8=function(t,e){return t=t>>>0,e||B(t,1,this.length),this[t]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||B(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||B(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||B(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||B(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,e,o){t=t>>>0,e=e>>>0,o||B(t,e,this.length);for(var c=this[t],x=1,d=0;++d<e&&(x*=256);)c+=this[t+d]*x;return x*=128,c>=x&&(c-=Math.pow(2,8*e)),c},a.prototype.readIntBE=function(t,e,o){t=t>>>0,e=e>>>0,o||B(t,e,this.length);for(var c=e,x=1,d=this[t+--c];c>0&&(x*=256);)d+=this[t+--c]*x;return x*=128,d>=x&&(d-=Math.pow(2,8*e)),d},a.prototype.readInt8=function(t,e){return t=t>>>0,e||B(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},a.prototype.readInt16LE=function(t,e){t=t>>>0,e||B(t,2,this.length);var o=this[t]|this[t+1]<<8;return o&32768?o|4294901760:o},a.prototype.readInt16BE=function(t,e){t=t>>>0,e||B(t,2,this.length);var o=this[t+1]|this[t]<<8;return o&32768?o|4294901760:o},a.prototype.readInt32LE=function(t,e){return t=t>>>0,e||B(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return t=t>>>0,e||B(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,e){return t=t>>>0,e||B(t,4,this.length),s.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return t=t>>>0,e||B(t,4,this.length),s.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||B(t,8,this.length),s.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||B(t,8,this.length),s.read(this,t,!1,52,8)};function j(n,t,e,o,c,x){if(!a.isBuffer(n))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>c||t<x)throw new RangeError('"value" argument is out of bounds');if(e+o>n.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(t,e,o,c){if(t=+t,e=e>>>0,o=o>>>0,!c){var x=Math.pow(2,8*o)-1;j(this,t,e,o,x,0)}var d=1,U=0;for(this[e]=t&255;++U<o&&(d*=256);)this[e+U]=t/d&255;return e+o},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(t,e,o,c){if(t=+t,e=e>>>0,o=o>>>0,!c){var x=Math.pow(2,8*o)-1;j(this,t,e,o,x,0)}var d=o-1,U=1;for(this[e+d]=t&255;--d>=0&&(U*=256);)this[e+d]=t/U&255;return e+o},a.prototype.writeUint8=a.prototype.writeUInt8=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,1,255,0),this[e]=t&255,e+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4},a.prototype.writeIntLE=function(t,e,o,c){if(t=+t,e=e>>>0,!c){var x=Math.pow(2,8*o-1);j(this,t,e,o,x-1,-x)}var d=0,U=1,N=0;for(this[e]=t&255;++d<o&&(U*=256);)t<0&&N===0&&this[e+d-1]!==0&&(N=1),this[e+d]=(t/U>>0)-N&255;return e+o},a.prototype.writeIntBE=function(t,e,o,c){if(t=+t,e=e>>>0,!c){var x=Math.pow(2,8*o-1);j(this,t,e,o,x-1,-x)}var d=o-1,U=1,N=0;for(this[e+d]=t&255;--d>=0&&(U*=256);)t<0&&N===0&&this[e+d+1]!==0&&(N=1),this[e+d]=(t/U>>0)-N&255;return e+o},a.prototype.writeInt8=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1},a.prototype.writeInt16LE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2},a.prototype.writeInt16BE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2},a.prototype.writeInt32LE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},a.prototype.writeInt32BE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function L(n,t,e,o,c,x){if(e+o>n.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function J(n,t,e,o,c){return t=+t,e=e>>>0,c||L(n,t,e,4),s.write(n,t,e,o,23,4),e+4}a.prototype.writeFloatLE=function(t,e,o){return J(this,t,e,!0,o)},a.prototype.writeFloatBE=function(t,e,o){return J(this,t,e,!1,o)};function z(n,t,e,o,c){return t=+t,e=e>>>0,c||L(n,t,e,8),s.write(n,t,e,o,52,8),e+8}a.prototype.writeDoubleLE=function(t,e,o){return z(this,t,e,!0,o)},a.prototype.writeDoubleBE=function(t,e,o){return z(this,t,e,!1,o)},a.prototype.copy=function(t,e,o,c){if(!a.isBuffer(t))throw new TypeError("argument should be a Buffer");if(o||(o=0),!c&&c!==0&&(c=this.length),e>=t.length&&(e=t.length),e||(e=0),c>0&&c<o&&(c=o),c===o||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(o<0||o>=this.length)throw new RangeError("Index out of range");if(c<0)throw new RangeError("sourceEnd out of bounds");c>this.length&&(c=this.length),t.length-e<c-o&&(c=t.length-e+o);var x=c-o;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,o,c):Uint8Array.prototype.set.call(t,this.subarray(o,c),e),x},a.prototype.fill=function(t,e,o,c){if(typeof t=="string"){if(typeof e=="string"?(c=e,e=0,o=this.length):typeof o=="string"&&(c=o,o=this.length),c!==void 0&&typeof c!="string")throw new TypeError("encoding must be a string");if(typeof c=="string"&&!a.isEncoding(c))throw new TypeError("Unknown encoding: "+c);if(t.length===1){var x=t.charCodeAt(0);(c==="utf8"&&x<128||c==="latin1")&&(t=x)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<o)throw new RangeError("Out of range index");if(o<=e)return this;e=e>>>0,o=o===void 0?this.length:o>>>0,t||(t=0);var d;if(typeof t=="number")for(d=e;d<o;++d)this[d]=t;else{var U=a.isBuffer(t)?t:a.from(t,c),N=U.length;if(N===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(d=0;d<o-e;++d)this[d+e]=U[d%N]}return this};var K=/[^+/0-9A-Za-z-_]/g;function X(n){if(n=n.split("=")[0],n=n.trim().replace(K,""),n.length<2)return"";for(;n.length%4!==0;)n=n+"=";return n}function V(n,t){t=t||1/0;for(var e,o=n.length,c=null,x=[],d=0;d<o;++d){if(e=n.charCodeAt(d),e>55295&&e<57344){if(!c){if(e>56319){(t-=3)>-1&&x.push(239,191,189);continue}else if(d+1===o){(t-=3)>-1&&x.push(239,191,189);continue}c=e;continue}if(e<56320){(t-=3)>-1&&x.push(239,191,189),c=e;continue}e=(c-55296<<10|e-56320)+65536}else c&&(t-=3)>-1&&x.push(239,191,189);if(c=null,e<128){if((t-=1)<0)break;x.push(e)}else if(e<2048){if((t-=2)<0)break;x.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;x.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;x.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return x}function Q(n){for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e)&255);return t}function tt(n,t){for(var e,o,c,x=[],d=0;d<n.length&&!((t-=2)<0);++d)e=n.charCodeAt(d),o=e>>8,c=e%256,x.push(c),x.push(o);return x}function pt(n){return i.toByteArray(X(n))}function vt(n,t,e,o){for(var c=0;c<o&&!(c+e>=t.length||c>=n.length);++c)t[c+e]=n[c];return c}function it(n,t){return n instanceof t||n!=null&&n.constructor!=null&&n.constructor.name!=null&&n.constructor.name===t.name}function Dt(n){return n!==n}var Je=function(){for(var n="0123456789abcdef",t=new Array(256),e=0;e<16;++e)for(var o=e*16,c=0;c<16;++c)t[o+c]=n[e]+n[c];return t}()})(Ee);/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(r,i){var s=Ee,p=s.Buffer;function f(l,a){for(var h in l)a[h]=l[h]}p.from&&p.alloc&&p.allocUnsafe&&p.allocUnsafeSlow?r.exports=s:(f(s,i),i.Buffer=u);function u(l,a,h){return p(l,a,h)}u.prototype=Object.create(p.prototype),f(p,u),u.from=function(l,a,h){if(typeof l=="number")throw new TypeError("Argument must not be a number");return p(l,a,h)},u.alloc=function(l,a,h){if(typeof l!="number")throw new TypeError("Argument must be a number");var w=p(l);return a!==void 0?typeof h=="string"?w.fill(a,h):w.fill(a):w.fill(0),w},u.allocUnsafe=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return p(l)},u.allocUnsafeSlow=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return s.SlowBuffer(l)}})(zt,zt.exports);var Zt=zt.exports,Ae=Zt.Buffer;function jt(r,i){this._block=Ae.alloc(r),this._finalSize=i,this._blockSize=r,this._len=0}jt.prototype.update=function(r,i){typeof r=="string"&&(i=i||"utf8",r=Ae.from(r,i));for(var s=this._block,p=this._blockSize,f=r.length,u=this._len,l=0;l<f;){for(var a=u%p,h=Math.min(f-l,p-a),w=0;w<h;w++)s[a+w]=r[l+w];u+=h,l+=h,u%p===0&&this._update(s)}return this._len+=f,this};jt.prototype.digest=function(r){var i=this._len%this._blockSize;this._block[i]=128,this._block.fill(0,i+1),i>=this._finalSize&&(this._update(this._block),this._block.fill(0));var s=this._len*8;if(s<=4294967295)this._block.writeUInt32BE(s,this._blockSize-4);else{var p=(s&4294967295)>>>0,f=(s-p)/4294967296;this._block.writeUInt32BE(f,this._blockSize-8),this._block.writeUInt32BE(p,this._blockSize-4)}this._update(this._block);var u=this._hash();return r?u.toString(r):u};jt.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var Se=jt,br=be,_e=Se,Er=Zt.Buffer,vr=[1518500249,1859775393,-1894007588,-899497514],Ar=new Array(80);function bt(){this.init(),this._w=Ar,_e.call(this,64,56)}br(bt,_e);bt.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Sr(r){return r<<1|r>>>31}function _r(r){return r<<5|r>>>27}function Fr(r){return r<<30|r>>>2}function Br(r,i,s,p){return r===0?i&s|~i&p:r===2?i&s|i&p|s&p:i^s^p}bt.prototype._update=function(r){for(var i=this._w,s=this._a|0,p=this._b|0,f=this._c|0,u=this._d|0,l=this._e|0,a=0;a<16;++a)i[a]=r.readInt32BE(a*4);for(;a<80;++a)i[a]=Sr(i[a-3]^i[a-8]^i[a-14]^i[a-16]);for(var h=0;h<80;++h){var w=~~(h/20),g=_r(s)+Br(w,p,f,u)+l+i[h]+vr[w]|0;l=u,u=f,f=Fr(p),p=s,s=g}this._a=s+this._a|0,this._b=p+this._b|0,this._c=f+this._c|0,this._d=u+this._d|0,this._e=l+this._e|0};bt.prototype._hash=function(){var r=Er.allocUnsafe(20);return r.writeInt32BE(this._a|0,0),r.writeInt32BE(this._b|0,4),r.writeInt32BE(this._c|0,8),r.writeInt32BE(this._d|0,12),r.writeInt32BE(this._e|0,16),r};var Or=bt;const jr=Ht(Or);var Ir=be,Fe=Se,Tr=Zt.Buffer,kr=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],Dr=new Array(64);function Et(){this.init(),this._w=Dr,Fe.call(this,64,56)}Ir(Et,Fe);Et.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function Ur(r,i,s){return s^r&(i^s)}function $r(r,i,s){return r&i|s&(r|i)}function Cr(r){return(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10)}function zr(r){return(r>>>6|r<<26)^(r>>>11|r<<21)^(r>>>25|r<<7)}function Nr(r){return(r>>>7|r<<25)^(r>>>18|r<<14)^r>>>3}function Mr(r){return(r>>>17|r<<15)^(r>>>19|r<<13)^r>>>10}Et.prototype._update=function(r){for(var i=this._w,s=this._a|0,p=this._b|0,f=this._c|0,u=this._d|0,l=this._e|0,a=this._f|0,h=this._g|0,w=this._h|0,g=0;g<16;++g)i[g]=r.readInt32BE(g*4);for(;g<64;++g)i[g]=Mr(i[g-2])+i[g-7]+Nr(i[g-15])+i[g-16]|0;for(var A=0;A<64;++A){var S=w+zr(l)+Ur(l,a,h)+kr[A]+i[A]|0,F=Cr(s)+$r(s,p,f)|0;w=h,h=a,a=l,l=u+S|0,u=f,f=p,p=s,s=S+F|0}this._a=s+this._a|0,this._b=p+this._b|0,this._c=f+this._c|0,this._d=u+this._d|0,this._e=l+this._e|0,this._f=a+this._f|0,this._g=h+this._g|0,this._h=w+this._h|0};Et.prototype._hash=function(){var r=Tr.allocUnsafe(32);return r.writeInt32BE(this._a,0),r.writeInt32BE(this._b,4),r.writeInt32BE(this._c,8),r.writeInt32BE(this._d,12),r.writeInt32BE(this._e,16),r.writeInt32BE(this._f,20),r.writeInt32BE(this._g,24),r.writeInt32BE(this._h,28),r};var Rr=Et;const Lr=Ht(Rr),Gt=new Error("File system not available.");function Pr(r,i,s){throw Gt}function Be(r){throw Gt}function qr(r){throw Gt}const Jr=async r=>Be(),Wr={sha1:jr,sha256:Lr},It=(r,i="sha1")=>{if(!["sha1","sha256"].includes(i))throw new Error("Hashing algorithm not supported: Available: sha1, sha256");const s=Wr[i];return new s().update(r).digest("base64")};function Oe(r){return r.type===ar&&r.skip!==void 0&&r.skip>0&&r.hash!==void 0}function Nt(r){return[yt,wt].includes(r.type)}function Mt(r){return[ge,yt,wt,Bt,ye].includes(r.type)}function lt(r,i,s,p,f="global"){if(!r)throw new Error("Empty action type");if(typeof r!="string")throw new Error(`Invalid action type: ${JSON.stringify(r)}`);const u={type:r,input:i,scope:f};s&&(u.attachments=s);try{p==null||p().parse(u.input)}catch(l){throw new Error(`Invalid action input: ${l}`)}return u}function je(r,i=Vt){return(s,p,f,u)=>i(s,p,r,f,u)}const Ie=(r,i)=>({name:"",documentType:"",revision:{global:0,local:0},created:new Date().toISOString(),lastModified:new Date().toISOString(),attachments:{},...r,state:(i==null?void 0:i(r==null?void 0:r.state))??(r==null?void 0:r.state)??{global:{},local:{}}}),Te=(r,i)=>{const s=Ie(r,i);return{...s,initialState:s,operations:{global:[],local:[]},clipboard:[]}},Tt=(r,i="global")=>It(_t(r.state[i]||"")),Hr=(r,i=1e3)=>{const s=Math.random()*i;return It(`${(r??new Date).toISOString()}${s}`)};function xt(r){return ot.castImmutable(ot.freeze(r,!0))}function ke(r,i){const s=[...r];let p=i||0,f=s.length>0?s[s.length-1].index:0;const u=[];for(const l of s.reverse()){if(p>0){const w=f-l.index;p-=w}if(p<0)throw new Error("Invalid operation index, missing operations");const a={ignore:p>0,operation:l},h=l.skip>0?l.skip+1:0;if(h>0&&h>p){const w=h-p;p=p+w}f=l.index,u.push(a)}return u.reverse()}function De(r,i,s){const p=r.slice().sort((a,h)=>a.skip-h.skip).sort((a,h)=>a.index-h.index);let f=s,u=0,l=i;for(const a of p.reverse()){const h=l-a.index;if(f=f-h,f>-1)u++,l=a.index;else break}return u}function Vr(r){return Object.values(r).flatMap(i=>i).sort((i,s)=>new Date(i.timestamp).getTime()-new Date(s.timestamp).getTime())}function Ue(r){return Object.values(r).flatMap(i=>i).sort((i,s)=>new Date(i.operation.timestamp).getTime()-new Date(s.operation.timestamp).getTime())}function Ft(r,i,s,p,f,u=Vt,l={},a){const h=je(s,u);return Yt(r,i,h,p,f,l,a)}function Yt(r,i,s,p,f,u={},l){const a=(l==null?void 0:l.checkHashes)??!0,h=Te(r),w=Object.keys(i).reduce((D,R)=>{const C=R;return{...D,[C]:ke(i[C],u[C])}},{}),g=Ue(w),A=g.reduce((D,{ignore:R,operation:C})=>R?s(D,Qt(C.scope),p,{skip:C.skip,ignoreSkipOperations:!0}):s(D,C,p,{skip:C.skip,ignoreSkipOperations:!0,reuseHash:!a}),h);if(!a)for(const D of Object.keys(A.state))for(let R=g.length-1;R>=0;R--){const{ignore:C,operation:y}=g[R];if(!(C||y.scope!==D)){if(y.hash!==Tt(A,D))throw new Error(`Hash mismatch for scope ${D}`);break}}const S=Object.keys(A.operations).reduce((D,R)=>{const C=R;return{...D,[C]:[...A.operations[C].map((y,b)=>{var I;return{...y,timestamp:((I=i[C][b])==null?void 0:I.timestamp)??y.timestamp}})]}},{global:[],local:[]}),F=Object.values(S).reduce((D,R)=>{const C=R[R.length-1];return(C==null?void 0:C.timestamp)>D&&(D=C.timestamp),D},r.lastModified);return{...A,operations:S,lastModified:F}}function Kr(r,i){return _t(r)===_t(i)}const $e=r=>lt("SET_NAME",r,void 0,Jt,void 0),Ce=(r=1,i="global")=>lt("UNDO",r,void 0,Wt,i),ze=(r=1,i="global")=>lt("REDO",r,void 0,qt,i),Ne=(r,i,s="global")=>lt("PRUNE",{start:r,end:i},void 0,Pt,s),Xt=(r,i)=>lt("LOAD_STATE",{state:r,operations:i},void 0,Lt),Qt=(r="global")=>lt("NOOP",{},void 0,void 0,r),Zr=Object.freeze(Object.defineProperty({__proto__:null,loadState:Xt,noop:Qt,prune:Ne,redo:ze,setName:$e,undo:Ce},Symbol.toStringTag,{value:"Module"})),Me={"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(Me);var et=function(r,i,s,p){if(s==="a"&&!p)throw new TypeError("Private accessor was defined without a getter");if(typeof i=="function"?r!==i||!p:!i.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return s==="m"?p:s==="a"?p.call(r):p?p.value:i.get(r)},mt,dt,ct;class Gr{constructor(...i){mt.set(this,new Map),dt.set(this,new Map),ct.set(this,new Map);for(const s of i)this.define(s)}define(i,s=!1){for(let[p,f]of Object.entries(i)){p=p.toLowerCase(),f=f.map(a=>a.toLowerCase()),et(this,ct,"f").has(p)||et(this,ct,"f").set(p,new Set);const u=et(this,ct,"f").get(p);let l=!0;for(let a of f){const h=a.startsWith("*");if(a=h?a.slice(1):a,u==null||u.add(a),l&&et(this,dt,"f").set(p,a),l=!1,h)continue;const w=et(this,mt,"f").get(a);if(w&&w!=p&&!s)throw new Error(`"${p} -> ${a}" conflicts with "${w} -> ${a}". Pass \`force=true\` to override this definition.`);et(this,mt,"f").set(a,p)}}return this}getType(i){if(typeof i!="string")return null;const s=i.replace(/^.*[/\\]/,"").toLowerCase(),p=s.replace(/^.*\./,"").toLowerCase(),f=s.length<i.length;return!(p.length<s.length-1)&&f?null:et(this,mt,"f").get(p)??null}getExtension(i){var s;return typeof i!="string"?null:(i=(s=i==null?void 0:i.split)==null?void 0:s.call(i,";")[0],(i&&et(this,dt,"f").get(i.trim().toLowerCase()))??null)}getAllExtensions(i){return typeof i!="string"?null:et(this,ct,"f").get(i.toLowerCase())??null}_freeze(){this.define=()=>{throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances")},Object.freeze(this);for(const i of et(this,ct,"f").values())Object.freeze(i);return this}_getTestState(){return{types:et(this,mt,"f"),extensions:et(this,dt,"f")}}}mt=new WeakMap,dt=new WeakMap,ct=new WeakMap;const Yr=new Gr(Me)._freeze();function Re(r){const i=[],s=Object.keys(r);for(const p of s){const f=r[p].sort((u,l)=>u.index-l.index);for(let u=0;u<f.length;u++)f[u].index!==u&&i.push({message:`Invalid operation index ${f[u].index} at position ${u}`,details:{position:u,operation:f[u],scope:f[u].scope}})}return i}const te=async r=>{const i=new ie,{name:s,revision:p,documentType:f,created:u,lastModified:l}=r,a={name:s,revision:p,documentType:f,created:u,lastModified:l};return i.file("header.json",JSON.stringify(a,null,2)),i.file("state.json",JSON.stringify(r.initialState||{},null,2)),i.file("operations.json",JSON.stringify(r.operations,null,2)),Object.keys(r.attachments).forEach(w=>{const{data:g,...A}=r.attachments[w];i.file(w,g,{base64:!0,createFolders:!0,comment:JSON.stringify(A)})}),i},Le=async(r,i,s,p)=>{await(await te(r)).generateAsync({type:"uint8array",streamFiles:!0});const u=p??r.name,l=`.${s}.zip`;return Pr(i,u.endsWith(l)?u:`${u}${l}`)},Xr=async(r,i)=>{const p=await(await te(r)).generateAsync({type:"blob"}),f=await i.createWritable();await f.write(p),await f.close()},Rt=async(r,i,s)=>{const p=Be();return Pe(p,i,s)},Pe=async(r,i,s)=>{const p=new ie;return await p.loadAsync(r),Qr(p,i,s)};async function Qr(r,i,s){const p=r.file("state.json");if(!p)throw new Error("Initial state not found");const f=await p.async("string"),u=JSON.parse(f),l=r.file("header.json");let a;l&&(a=JSON.parse(await l.async("string")));const h=r.file("operations.json");if(!h)throw new Error("Operations history not found");const w=JSON.parse(await h.async("string")),g=Re(w);if(g.length){const S=g.map(F=>F.message);throw new Error(S.join(`
|
|
25
|
+
`))}let A=Yt(u,w,i,void 0,a,{},s);return a&&(A={...A,...a}),A}function qe(r){const i=r.replace(/^.*\./,"")||void 0,s=r.replace(/^.*[/\\]/,"")||void 0;return{extension:i,fileName:s}}async function ti(r){const{buffer:i,mimeType:s="application/octet-stream"}=await qr(),p=qe(r),f=i.toString("base64");return{data:f,hash:It(f),mimeType:s,...p}}async function ei(r){const i=await Jr(),s=Yr.getType(r)||"application/octet-stream",p=qe(r),f=i.toString("base64");return{data:f,hash:It(f),mimeType:s,...p}}class ri{constructor(i,s,p){St(this,"_document");St(this,"_reducer");St(this,"_signalDispatch");this._reducer=i,this._document=s,this._signalDispatch=p}dispatch(i,s){return this._document=this._reducer(this._document,i,this._signalDispatch,s),this}saveToFile(i,s,p){return Le(this._document,i,s,p)}async loadFromFile(i){this._document=await Rt(i,this._reducer)}static async stateFromFile(i,s){return await Rt(i,s)}get state(){return xt(this._document.state)}get operations(){return xt(this._document.operations)}get name(){return this._document.name}get documentType(){return this._document.documentType}get created(){return this._document.created}get lastModified(){return this._document.lastModified}get revision(){return this._document.revision.global}getRevision(i){return this._document.revision[i]}get initialState(){return xt(this._document.initialState)}toDocument(){return xt(this._document)}getAttachment(i){return this._document.attachments[i]}setName(i){return this.dispatch($e(i)),this}undo(i){return this.dispatch(Ce(i)),this}redo(i){return this.dispatch(ze(i)),this}prune(i,s){return this.dispatch(Ne(i,s)),this}loadState(i,s){return this.dispatch(Xt(i,s)),this}}function ii(r,i){i.forEach(s=>{Object.getOwnPropertyNames(s.prototype).forEach(p=>{Object.defineProperty(r.prototype,p,Object.getOwnPropertyDescriptor(s.prototype,p)||Object.create(null))})})}exports.BaseActions=Zr;exports.BaseDocument=ri;exports.applyMixins=ii;exports.baseReducer=Vt;exports.calculateSkipsLeft=De;exports.createAction=lt;exports.createDocument=Te;exports.createExtendedState=Ie;exports.createReducer=je;exports.createZip=te;exports.getLocalFile=ei;exports.getRemoteFile=ti;exports.hashDocument=Tt;exports.hashKey=Hr;exports.isBaseAction=Mt;exports.isNoopOperation=Oe;exports.isSameDocument=Kr;exports.isUndoRedo=Nt;exports.loadFromFile=Rt;exports.loadFromInput=Pe;exports.mapSkippedOperations=ke;exports.processUndoRedo=we;exports.readOnly=xt;exports.replayDocument=Yt;exports.replayOperations=Ft;exports.saveToFile=Le;exports.saveToFileHandle=Xr;exports.sortMappedOperations=Ue;exports.sortOperations=Vr;exports.validateOperations=Re;exports.zod=Xe;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./internal/object-
|
|
1
|
+
import "./internal/object-BdaEhPk1.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-
|
|
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-aS_vqu4O.js";
|
|
5
5
|
import "zod";
|
|
6
6
|
export {
|
|
7
7
|
i as Document,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as i, h as p, g as t, C as m, D as c, E as n } from "./internal/object-
|
|
2
|
-
import { i as u } from "./internal/index-
|
|
1
|
+
import { B as i, h as p, g as t, C as m, D as c, E as n } from "./internal/object-BdaEhPk1.js";
|
|
2
|
+
import { i as u } from "./internal/index-CF0d1_Cg.js";
|
|
3
3
|
import "immer";
|
|
4
4
|
import "zod";
|
|
5
5
|
import "jszip";
|
package/dist/browser/es/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as o } from "./internal/index-
|
|
2
|
-
import { D as e } from "./internal/index-
|
|
3
|
-
import "./internal/object-
|
|
1
|
+
import { D as o } from "./internal/index-CF0d1_Cg.js";
|
|
2
|
+
import { D as e } from "./internal/index-aS_vqu4O.js";
|
|
3
|
+
import "./internal/object-BdaEhPk1.js";
|
|
4
4
|
import "immer";
|
|
5
5
|
import "zod";
|
|
6
6
|
import "jszip";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { j as e, f as a, b as s, a as o, c as t, k as r, m as i, n, o as c, p as l, i as p, q as d, r as u, t as m, l as O, e as y, u as b, v as D, w as S, x as _, s as f, d as g, y as F, z as v, A as h, B as j, h as x, g as z, C as R, D as A, E as B } from "./object-
|
|
1
|
+
import { j as e, f as a, b as s, a as o, c as t, k as r, m as i, n, o as c, p as l, i as p, q as d, r as u, t as m, l as O, e as y, u as b, v as D, w as S, x as _, s as f, d as g, y as F, z as v, A as h, B as j, h as x, g as z, C as R, D as A, E as B } from "./object-BdaEhPk1.js";
|
|
2
2
|
const M = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3
3
|
__proto__: null,
|
|
4
4
|
calculateSkipsLeft: e,
|
|
@@ -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-
|
|
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-BdaEhPk1.js";
|
|
5
5
|
import "immer";
|
|
6
6
|
import "jszip";
|
|
7
7
|
import { z as o } from "zod";
|