document-model 1.0.16 → 1.0.18

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 (63) hide show
  1. package/dist/browser/document/schema/zod.d.ts +24 -0
  2. package/dist/browser/document/types.d.ts +8 -7
  3. package/dist/browser/document/utils/base.d.ts +4 -4
  4. package/dist/browser/document-model/gen/header/object.d.ts +2 -2
  5. package/dist/browser/document-model/gen/module/object.d.ts +2 -2
  6. package/dist/browser/document-model/gen/object.d.ts +4 -4
  7. package/dist/browser/document-model/gen/operation/object.d.ts +2 -2
  8. package/dist/browser/document-model/gen/operation-error/object.d.ts +2 -2
  9. package/dist/browser/document-model/gen/operation-example/object.d.ts +2 -2
  10. package/dist/browser/document-model/gen/reducer.d.ts +2 -2
  11. package/dist/browser/document-model/gen/schema/types.d.ts +12 -5
  12. package/dist/browser/document-model/gen/schema/zod.d.ts +20 -1
  13. package/dist/browser/document-model/gen/state/object.d.ts +2 -2
  14. package/dist/browser/document-model/gen/types.d.ts +3 -3
  15. package/dist/browser/document-model/gen/utils.d.ts +4 -2
  16. package/dist/browser/document-model/gen/versioning/object.d.ts +2 -2
  17. package/dist/browser/document-model/index.d.ts +9 -9
  18. package/dist/browser/document-model.cjs +1 -1
  19. package/dist/browser/document-model.js +2 -2
  20. package/dist/browser/document.cjs +1 -1
  21. package/dist/browser/document.js +2 -2
  22. package/dist/browser/index.cjs +1 -1
  23. package/dist/browser/index.js +3 -3
  24. package/dist/browser/internal/{index-37753e74.js → index-10a12861.js} +520 -441
  25. package/dist/{node/internal/index-0e7af6c6.js → browser/internal/index-2aee8ea9.js} +1 -1
  26. package/dist/{node/internal/index-124bda95.js → browser/internal/index-a1282d5c.js} +1 -1
  27. package/dist/browser/internal/index-ec8cd58f.js +22 -0
  28. package/dist/browser/internal/object-24df9d92.js +6 -0
  29. package/dist/browser/internal/{object-17aee7a9.js → object-7e8eaff4.js} +377 -365
  30. package/dist/node/document/schema/zod.d.ts +24 -0
  31. package/dist/node/document/types.d.ts +8 -7
  32. package/dist/node/document/utils/base.d.ts +4 -4
  33. package/dist/node/document-model/gen/header/object.d.ts +2 -2
  34. package/dist/node/document-model/gen/module/object.d.ts +2 -2
  35. package/dist/node/document-model/gen/object.d.ts +4 -4
  36. package/dist/node/document-model/gen/operation/object.d.ts +2 -2
  37. package/dist/node/document-model/gen/operation-error/object.d.ts +2 -2
  38. package/dist/node/document-model/gen/operation-example/object.d.ts +2 -2
  39. package/dist/node/document-model/gen/reducer.d.ts +2 -2
  40. package/dist/node/document-model/gen/schema/types.d.ts +12 -5
  41. package/dist/node/document-model/gen/schema/zod.d.ts +20 -1
  42. package/dist/node/document-model/gen/state/object.d.ts +2 -2
  43. package/dist/node/document-model/gen/types.d.ts +3 -3
  44. package/dist/node/document-model/gen/utils.d.ts +4 -2
  45. package/dist/node/document-model/gen/versioning/object.d.ts +2 -2
  46. package/dist/node/document-model/index.d.ts +9 -9
  47. package/dist/node/document-model.cjs +1 -1
  48. package/dist/node/document-model.js +2 -2
  49. package/dist/node/document.cjs +1 -1
  50. package/dist/node/document.js +2 -2
  51. package/dist/node/index.cjs +1 -1
  52. package/dist/node/index.js +3 -3
  53. package/dist/node/internal/{index-9037f83a.js → index-09364517.js} +520 -441
  54. package/dist/node/internal/index-284511b8.js +22 -0
  55. package/dist/{browser/internal/index-f5587600.js → node/internal/index-2d4783d9.js} +1 -1
  56. package/dist/{browser/internal/index-9b4d67fc.js → node/internal/index-5ef0c6b0.js} +1 -1
  57. package/dist/node/internal/object-21f3d2ee.js +1 -0
  58. package/dist/node/internal/{object-f7cd4777.js → object-c32ea0a0.js} +154 -142
  59. package/package.json +1 -1
  60. package/dist/browser/internal/index-a5150e7e.js +0 -22
  61. package/dist/browser/internal/object-28a1a8bf.js +0 -6
  62. package/dist/node/internal/index-417115f1.js +0 -22
  63. package/dist/node/internal/object-f3dd289e.js +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "document-model",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "license": "AGPL-3.0-only",
5
5
  "private": false,
6
6
  "files": [
@@ -1,22 +0,0 @@
1
- "use strict";var dt=Object.defineProperty;var ut=(t,e,n)=>e in t?dt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var de=(t,e,n)=>(ut(t,typeof e!="symbol"?e+"":e,n),n);const s=require("./object-28a1a8bf.js");require("json-stringify-deterministic");require("immer");require("jszip");const r=require("zod"),mt=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),f={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:{schema:"",initialValue:`{
2
- "id": "",
3
- "name": "",
4
- "extension": "",
5
- "description": "",
6
- "author": {
7
- "name": "",
8
- "website": ""
9
- },
10
- "specifications": [
11
- {
12
- "version": 1,
13
- "changeLog": [],
14
- "state": {
15
- "schema": "",
16
- "initialValue": "",
17
- "examples": []
18
- },
19
- "modules": []
20
- }
21
- ]
22
- }`,examples:[]}}]},ue=t=>t!=null,Et=r.z.any().refine(t=>ue(t));function _(){return r.z.object({__typename:r.z.literal("AddChangeLogItemInput").optional(),content:r.z.string(),id:r.z.string(),insertBefore:r.z.string().nullable()})}function A(){return r.z.object({description:r.z.string().nullish(),id:r.z.string(),name:r.z.string()})}function z(){return r.z.object({errorCode:r.z.string().nullish(),errorDescription:r.z.string().nullish(),errorName:r.z.string().nullish(),errorTemplate:r.z.string().nullish(),id:r.z.string(),operationId:r.z.string()})}function I(){return r.z.object({example:r.z.string(),id:r.z.string(),operationId:r.z.string()})}function T(){return r.z.object({description:r.z.string().nullish(),id:r.z.string(),moduleId:r.z.string(),name:r.z.string(),reducer:r.z.string().nullish(),schema:r.z.string().nullish(),template:r.z.string().nullish(),scope:r.z.literal("local").or(r.z.literal("global")).nullish()})}function b(){return r.z.object({example:r.z.string(),id:r.z.string(),insertBefore:r.z.string().nullish()})}function me(){return r.z.object({__typename:r.z.literal("Author").optional(),name:r.z.string(),website:r.z.string().nullable()})}function R(){return r.z.object({__typename:r.z.literal("CodeExample").optional(),id:r.z.string(),value:r.z.string()})}function D(){return r.z.object({__typename:r.z.literal("DeleteChangeLogItemInput").optional(),id:r.z.string()})}function M(){return r.z.object({id:r.z.string()})}function x(){return r.z.object({id:r.z.string()})}function N(){return r.z.object({id:r.z.string()})}function L(){return r.z.object({id:r.z.string()})}function P(){return r.z.object({id:r.z.string()})}function ht(){return r.z.union([_(),A(),z(),I(),T(),b(),D(),M(),x(),N(),L(),P(),j(),C(),k(),y(),w(),U(),v(),F(),H(),V(),X(),G(),B(),W(),$(),q(),J(),K(),Q(),Y(),Z(),ee(),te(),re(),oe(),ne(),ie(),se(),ae()])}function Ot(){return r.z.object({__typename:r.z.literal("DocumentModelState").optional(),author:me(),description:r.z.string(),extension:r.z.string(),id:r.z.string(),name:r.z.string(),specifications:r.z.array(Ee())})}function Ee(){return r.z.object({__typename:r.z.literal("DocumentSpecification").optional(),changeLog:r.z.array(r.z.string()),modules:r.z.array(he()),state:fe(),version:r.z.number()})}function he(){return r.z.object({__typename:r.z.literal("Module").optional(),description:r.z.string().nullable(),id:r.z.string(),name:r.z.string(),operations:r.z.array(Oe())})}function j(){return r.z.object({newModuleId:r.z.string(),operationId:r.z.string()})}function Oe(){return r.z.object({__typename:r.z.literal("Operation").optional(),description:r.z.string().nullable(),errors:r.z.array(ge()),examples:r.z.array(R()),id:r.z.string(),name:r.z.string().nullable(),reducer:r.z.string().nullable(),schema:r.z.string().nullable(),template:r.z.string().nullable(),scope:r.z.literal("local").or(r.z.literal("global"))})}function ge(){return r.z.object({__typename:r.z.literal("OperationError").optional(),code:r.z.string().nullable(),description:r.z.string().nullable(),id:r.z.string(),name:r.z.string().nullable(),template:r.z.string().nullable()})}function C(){return r.z.object({__typename:r.z.literal("ReorderChangeLogItemsInput").optional(),order:r.z.array(r.z.string())})}function k(){return r.z.object({moduleId:r.z.string(),order:r.z.array(r.z.string())})}function y(){return r.z.object({order:r.z.array(r.z.string())})}function w(){return r.z.object({operationId:r.z.string(),order:r.z.array(r.z.string())})}function U(){return r.z.object({operationId:r.z.string(),order:r.z.array(r.z.string())})}function v(){return r.z.object({order:r.z.array(r.z.string())})}function F(){return r.z.object({authorName:r.z.string()})}function H(){return r.z.object({authorWebsite:r.z.string()})}function V(){return r.z.object({initialValue:r.z.string()})}function X(){return r.z.object({description:r.z.string()})}function G(){return r.z.object({extension:r.z.string()})}function B(){return r.z.object({id:r.z.string()})}function W(){return r.z.object({name:r.z.string()})}function $(){return r.z.object({description:r.z.string().nullish(),id:r.z.string()})}function q(){return r.z.object({id:r.z.string(),name:r.z.string().nullish()})}function J(){return r.z.object({description:r.z.string().nullish(),id:r.z.string()})}function K(){return r.z.object({errorCode:r.z.string().nullish(),id:r.z.string()})}function Q(){return r.z.object({errorDescription:r.z.string().nullish(),id:r.z.string()})}function Y(){return r.z.object({errorName:r.z.string().nullish(),id:r.z.string()})}function Z(){return r.z.object({errorTemplate:r.z.string().nullish(),id:r.z.string()})}function ee(){return r.z.object({id:r.z.string(),name:r.z.string().nullish()})}function Se(){return r.z.object({id:r.z.string(),scope:r.z.literal("global").or(r.z.literal("local"))})}function te(){return r.z.object({id:r.z.string(),reducer:r.z.string().nullish()})}function re(){return r.z.object({id:r.z.string(),schema:r.z.string().nullish()})}function oe(){return r.z.object({id:r.z.string(),template:r.z.string().nullish()})}function ne(){return r.z.object({schema:r.z.string()})}function fe(){return r.z.object({__typename:r.z.literal("State").optional(),examples:r.z.array(R()),initialValue:r.z.string(),schema:r.z.string()})}function ie(){return r.z.object({__typename:r.z.literal("UpdateChangeLogItemInput").optional(),id:r.z.string(),newContent:r.z.string()})}function se(){return r.z.object({example:r.z.string(),id:r.z.string()})}function ae(){return r.z.object({id:r.z.string(),newExample:r.z.string()})}const _e=Object.freeze(Object.defineProperty({__proto__:null,AddChangeLogItemInputSchema:_,AddModuleInputSchema:A,AddOperationErrorInputSchema:z,AddOperationExampleInputSchema:I,AddOperationInputSchema:T,AddStateExampleInputSchema:b,AuthorSchema:me,CodeExampleSchema:R,DeleteChangeLogItemInputSchema:D,DeleteModuleInputSchema:M,DeleteOperationErrorInputSchema:x,DeleteOperationExampleInputSchema:N,DeleteOperationInputSchema:L,DeleteStateExampleInputSchema:P,DocumentModelInputSchema:ht,DocumentModelStateSchema:Ot,DocumentSpecificationSchema:Ee,ModuleSchema:he,MoveOperationInputSchema:j,OperationErrorSchema:ge,OperationSchema:Oe,ReorderChangeLogItemsInputSchema:C,ReorderModuleOperationsInputSchema:k,ReorderModulesInputSchema:y,ReorderOperationErrorsInputSchema:w,ReorderOperationExamplesInputSchema:U,ReorderStateExamplesInputSchema:v,SetAuthorNameInputSchema:F,SetAuthorWebsiteInputSchema:H,SetInitialStateInputSchema:V,SetModelDescriptionInputSchema:X,SetModelExtensionInputSchema:G,SetModelIdInputSchema:B,SetModelNameInputSchema:W,SetModuleDescriptionInputSchema:$,SetModuleNameInputSchema:q,SetOperationDescriptionInputSchema:J,SetOperationErrorCodeInputSchema:K,SetOperationErrorDescriptionInputSchema:Q,SetOperationErrorNameInputSchema:Y,SetOperationErrorTemplateInputSchema:Z,SetOperationNameInputSchema:ee,SetOperationReducerInputSchema:te,SetOperationSchemaInputSchema:re,SetOperationScopeInputSchema:Se,SetOperationTemplateInputSchema:oe,SetStateSchemaInputSchema:ne,StateSchema:fe,UpdateChangeLogItemInputSchema:ie,UpdateOperationExampleInputSchema:se,UpdateStateExampleInputSchema:ae,definedNonNullAnySchema:Et,isDefinedNonNullAny:ue},Symbol.toStringTag,{value:"Module"})),c={setModelNameOperation(t,e){t.name=e.input.name},setModelIdOperation(t,e){t.id=e.input.id},setModelExtensionOperation(t,e){t.extension=e.input.extension},setModelDescriptionOperation(t,e){t.description=e.input.description},setAuthorNameOperation(t,e){t.author=t.author||{name:"",website:null},t.author.name=e.input.authorName},setAuthorWebsiteOperation(t,e){t.author=t.author||{name:"",website:null},t.author.website=e.input.authorWebsite}},E={addChangeLogItemOperation(t,e){throw new Error('Reducer "addChangeLogItemOperation" not yet implemented')},updateChangeLogItemOperation(t,e){throw new Error('Reducer "updateChangeLogItemOperation" not yet implemented')},deleteChangeLogItemOperation(t,e){throw new Error('Reducer "deleteChangeLogItemOperation" not yet implemented')},reorderChangeLogItemsOperation(t,e){throw new Error('Reducer "reorderChangeLogItemsOperation" not yet implemented')},releaseNewVersionOperation(t,e){throw new Error('Reducer "releaseNewVersionOperation" not yet implemented')}},gt=t=>{const e={};return t.forEach((n,o)=>e[n]=o),(n,o)=>(e[o.id]||999999)-(e[n.id]||999999)},h={addModuleOperation(t,e){t.specifications[t.specifications.length-1].modules.push({id:e.input.id,name:e.input.name,description:e.input.description||"",operations:[]})},setModuleNameOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)n.modules[o].id===e.input.id&&(n.modules[o].name=e.input.name||"")},setModuleDescriptionOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)n.modules[o].id===e.input.id&&(n.modules[o].description=e.input.description||"")},deleteModuleOperation(t,e){const n=t.specifications[t.specifications.length-1];n.modules=n.modules.filter(o=>o.id!=e.input.id)},reorderModulesOperation(t,e){t.specifications[t.specifications.length-1].modules.sort(gt(e.input.order))}},St=t=>{const e={};return t.forEach((n,o)=>e[n]=o),(n,o)=>(e[o.id]||999999)-(e[n.id]||999999)},l={addOperationErrorOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.operationId&&n.modules[o].operations[i].errors.push({id:e.input.id,name:e.input.errorName||"",code:e.input.errorCode||"",description:e.input.errorDescription||"",template:e.input.errorTemplate||""})},setOperationErrorCodeOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)for(let a=0;a<n.modules[o].operations[i].errors.length;a++)n.modules[o].operations[i].errors[a].id==e.input.id&&(n.modules[o].operations[i].errors[a].code=e.input.errorCode||"")},setOperationErrorNameOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)for(let a=0;a<n.modules[o].operations[i].errors.length;a++)n.modules[o].operations[i].errors[a].id==e.input.id&&(n.modules[o].operations[i].errors[a].name=e.input.errorName||"")},setOperationErrorDescriptionOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)for(let a=0;a<n.modules[o].operations[i].errors.length;a++)n.modules[o].operations[i].errors[a].id==e.input.id&&(n.modules[o].operations[i].errors[a].description=e.input.errorDescription||"")},setOperationErrorTemplateOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)for(let a=0;a<n.modules[o].operations[i].errors.length;a++)n.modules[o].operations[i].errors[a].id==e.input.id&&(n.modules[o].operations[i].errors[a].template=e.input.errorTemplate||"")},deleteOperationErrorOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].errors=n.modules[o].operations[i].errors.filter(a=>a.id!=e.input.id)},reorderOperationErrorsOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.operationId&&n.modules[o].operations[i].errors.sort(St(e.input.order))}},ft=t=>{const e={};return t.forEach((n,o)=>e[n]=o),(n,o)=>(e[o.id]||999999)-(e[n.id]||999999)},g={addOperationExampleOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.operationId&&n.modules[o].operations[i].examples.push({id:e.input.id,value:e.input.example})},updateOperationExampleOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)for(let a=0;a<n.modules[o].operations[i].examples.length;a++)n.modules[o].operations[i].examples[a].id==e.input.id&&(n.modules[o].operations[i].examples[a].value=e.input.example)},deleteOperationExampleOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].examples=n.modules[o].operations[i].examples.filter(a=>a.id!=e.input.id)},reorderOperationExamplesOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.operationId&&n.modules[o].operations[i].examples.sort(ft(e.input.order))}},_t=t=>{const e={};return t.forEach((n,o)=>e[n]=o),(n,o)=>(e[o.id]||999999)-(e[n.id]||999999)},p={addOperationOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)n.modules[o].id==e.input.moduleId&&n.modules[o].operations.push({id:e.input.id,name:e.input.name,description:e.input.description||"",schema:e.input.schema||"",template:e.input.template||e.input.description||"",reducer:e.input.reducer||"",errors:[],examples:[],scope:e.input.scope||"global"})},setOperationNameOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.id&&(n.modules[o].operations[i].name=e.input.name||"")},setOperationScopeOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.id&&(n.modules[o].operations[i].scope=e.input.scope||"global")},setOperationSchemaOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.id&&(n.modules[o].operations[i].schema=e.input.schema||"")},setOperationDescriptionOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.id&&(n.modules[o].operations[i].description=e.input.description||"")},setOperationTemplateOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.id&&(n.modules[o].operations[i].template=e.input.template||"")},setOperationReducerOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.id&&(n.modules[o].operations[i].reducer=e.input.reducer||"")},moveOperationOperation(t,e){const n=[],o=t.specifications[t.specifications.length-1];for(let i=0;i<o.modules.length;i++)o.modules[i].operations=o.modules[i].operations.filter(a=>a.id==e.input.operationId?(n.push(a),!1):!0);for(let i=0;i<o.modules.length;i++)o.modules[i].id==e.input.newModuleId&&o.modules[i].operations.push(...n)},deleteOperationOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)n.modules[o].operations=n.modules[o].operations.filter(i=>i.id!=e.input.id)},reorderModuleOperationsOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)n.modules[o].id==e.input.moduleId&&n.modules[o].operations.sort(_t(e.input.order))}},At=t=>{const e={};return t.forEach((n,o)=>e[n]=o),(n,o)=>(e[o.id]||999999)-(e[n.id]||999999)},d={setStateSchemaOperation(t,e){const n=t.specifications[t.specifications.length-1];n.state.schema=e.input.schema},setInitialStateOperation(t,e){const n=t.specifications[t.specifications.length-1];n.state.initialValue=e.input.initialValue},addStateExampleOperation(t,e){t.specifications[t.specifications.length-1].state.examples.push({id:e.input.id,value:e.input.example})},updateStateExampleOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.state.examples.length;o++)n.state.examples[o].id==e.input.id&&(n.state.examples[o].value=e.input.newExample)},deleteStateExampleOperation(t,e){const n=t.specifications[t.specifications.length-1];n.state.examples=n.state.examples.filter(o=>o.id!=e.input.id)},reorderStateExamplesOperation(t,e){t.specifications[t.specifications.length-1].state.examples.sort(At(e.input.order))}},zt=(t,e)=>{if(s.isBaseAction(e))return t;switch(e.type){case"SET_MODEL_NAME":W().parse(e.input),c.setModelNameOperation(t,e);break;case"SET_MODEL_ID":B().parse(e.input),c.setModelIdOperation(t,e);break;case"SET_MODEL_EXTENSION":G().parse(e.input),c.setModelExtensionOperation(t,e);break;case"SET_MODEL_DESCRIPTION":X().parse(e.input),c.setModelDescriptionOperation(t,e);break;case"SET_AUTHOR_NAME":F().parse(e.input),c.setAuthorNameOperation(t,e);break;case"SET_AUTHOR_WEBSITE":H().parse(e.input),c.setAuthorWebsiteOperation(t,e);break;case"ADD_CHANGE_LOG_ITEM":_().parse(e.input),E.addChangeLogItemOperation(t,e);break;case"UPDATE_CHANGE_LOG_ITEM":ie().parse(e.input),E.updateChangeLogItemOperation(t,e);break;case"DELETE_CHANGE_LOG_ITEM":D().parse(e.input),E.deleteChangeLogItemOperation(t,e);break;case"REORDER_CHANGE_LOG_ITEMS":C().parse(e.input),E.reorderChangeLogItemsOperation(t,e);break;case"RELEASE_NEW_VERSION":if(Object.keys(e.input).length>0)throw new Error("Expected empty input for action RELEASE_NEW_VERSION");E.releaseNewVersionOperation(t,e);break;case"ADD_MODULE":A().parse(e.input),h.addModuleOperation(t,e);break;case"SET_MODULE_NAME":q().parse(e.input),h.setModuleNameOperation(t,e);break;case"SET_MODULE_DESCRIPTION":$().parse(e.input),h.setModuleDescriptionOperation(t,e);break;case"DELETE_MODULE":M().parse(e.input),h.deleteModuleOperation(t,e);break;case"REORDER_MODULES":y().parse(e.input),h.reorderModulesOperation(t,e);break;case"ADD_OPERATION_ERROR":z().parse(e.input),l.addOperationErrorOperation(t,e);break;case"SET_OPERATION_ERROR_CODE":K().parse(e.input),l.setOperationErrorCodeOperation(t,e);break;case"SET_OPERATION_ERROR_NAME":Y().parse(e.input),l.setOperationErrorNameOperation(t,e);break;case"SET_OPERATION_ERROR_DESCRIPTION":Q().parse(e.input),l.setOperationErrorDescriptionOperation(t,e);break;case"SET_OPERATION_ERROR_TEMPLATE":Z().parse(e.input),l.setOperationErrorTemplateOperation(t,e);break;case"DELETE_OPERATION_ERROR":x().parse(e.input),l.deleteOperationErrorOperation(t,e);break;case"REORDER_OPERATION_ERRORS":w().parse(e.input),l.reorderOperationErrorsOperation(t,e);break;case"ADD_OPERATION_EXAMPLE":I().parse(e.input),g.addOperationExampleOperation(t,e);break;case"UPDATE_OPERATION_EXAMPLE":se().parse(e.input),g.updateOperationExampleOperation(t,e);break;case"DELETE_OPERATION_EXAMPLE":N().parse(e.input),g.deleteOperationExampleOperation(t,e);break;case"REORDER_OPERATION_EXAMPLES":U().parse(e.input),g.reorderOperationExamplesOperation(t,e);break;case"ADD_OPERATION":T().parse(e.input),p.addOperationOperation(t,e);break;case"SET_OPERATION_NAME":ee().parse(e.input),p.setOperationNameOperation(t,e);break;case"SET_OPERATION_SCOPE":Se().parse(e.input),p.setOperationScopeOperation(t,e);break;case"SET_OPERATION_SCHEMA":re().parse(e.input),p.setOperationSchemaOperation(t,e);break;case"SET_OPERATION_DESCRIPTION":J().parse(e.input),p.setOperationDescriptionOperation(t,e);break;case"SET_OPERATION_TEMPLATE":oe().parse(e.input),p.setOperationTemplateOperation(t,e);break;case"SET_OPERATION_REDUCER":te().parse(e.input),p.setOperationReducerOperation(t,e);break;case"MOVE_OPERATION":j().parse(e.input),p.moveOperationOperation(t,e);break;case"DELETE_OPERATION":L().parse(e.input),p.deleteOperationOperation(t,e);break;case"REORDER_MODULE_OPERATIONS":k().parse(e.input),p.reorderModuleOperationsOperation(t,e);break;case"SET_STATE_SCHEMA":ne().parse(e.input),d.setStateSchemaOperation(t,e);break;case"SET_INITIAL_STATE":V().parse(e.input),d.setInitialStateOperation(t,e);break;case"ADD_STATE_EXAMPLE":b().parse(e.input),d.addStateExampleOperation(t,e);break;case"UPDATE_STATE_EXAMPLE":ae().parse(e.input),d.updateStateExampleOperation(t,e);break;case"DELETE_STATE_EXAMPLE":P().parse(e.input),d.deleteStateExampleOperation(t,e);break;case"REORDER_STATE_EXAMPLES":v().parse(e.input),d.reorderStateExamplesOperation(t,e);break;default:return t}},m=s.createReducer(zt),It={id:"",name:"",extension:"",description:"",author:{name:"",website:""},specifications:[{version:1,changeLog:[],state:{schema:"",initialValue:"",examples:[]},modules:[]}]},O={fileExtension:"phdm",createState(t){return{...It,...t}},createExtendedState(t){return s.createExtendedState({...t,documentType:"powerhouse/document-model"},O.createState)},createDocument(t){return s.createDocument(O.createExtendedState(t),O.createState)},saveToFile(t,e,n){return s.saveToFile(t,e,"phdm",n)},saveToFileHandle(t,e){return s.saveToFileHandle(t,e)},loadFromFile(t){return s.loadFromFile(t,m)},loadFromInput(t){return s.loadFromInput(t,m)}},Ae=t=>s.createAction("SET_MODEL_NAME",{...t}),ze=t=>s.createAction("SET_MODEL_ID",{...t}),Ie=t=>s.createAction("SET_MODEL_EXTENSION",{...t}),Te=t=>s.createAction("SET_MODEL_DESCRIPTION",{...t}),be=t=>s.createAction("SET_AUTHOR_NAME",{...t}),Re=t=>s.createAction("SET_AUTHOR_WEBSITE",{...t});class Tt extends s.BaseDocument{setModelName(e){return this.dispatch(Ae(e))}setModelId(e){return this.dispatch(ze(e))}setModelExtension(e){return this.dispatch(Ie(e))}setModelDescription(e){return this.dispatch(Te(e))}setAuthorName(e){return this.dispatch(be(e))}setAuthorWebsite(e){return this.dispatch(Re(e))}}const De=t=>s.createAction("ADD_CHANGE_LOG_ITEM",{...t}),Me=t=>s.createAction("UPDATE_CHANGE_LOG_ITEM",{...t}),xe=t=>s.createAction("DELETE_CHANGE_LOG_ITEM",{...t}),Ne=t=>s.createAction("REORDER_CHANGE_LOG_ITEMS",{...t}),Le=()=>s.createAction("RELEASE_NEW_VERSION");class bt extends s.BaseDocument{addChangeLogItem(e){return this.dispatch(De(e))}updateChangeLogItem(e){return this.dispatch(Me(e))}deleteChangeLogItem(e){return this.dispatch(xe(e))}reorderChangeLogItems(e){return this.dispatch(Ne(e))}releaseNewVersion(){return this.dispatch(Le())}}const Pe=t=>s.createAction("ADD_MODULE",{...t}),je=t=>s.createAction("SET_MODULE_NAME",{...t}),Ce=t=>s.createAction("SET_MODULE_DESCRIPTION",{...t}),ke=t=>s.createAction("DELETE_MODULE",{...t}),ye=t=>s.createAction("REORDER_MODULES",{...t});class Rt extends s.BaseDocument{addModule(e){return this.dispatch(Pe(e))}setModuleName(e){return this.dispatch(je(e))}setModuleDescription(e){return this.dispatch(Ce(e))}deleteModule(e){return this.dispatch(ke(e))}reorderModules(e){return this.dispatch(ye(e))}}const we=t=>s.createAction("ADD_OPERATION_ERROR",{...t}),Ue=t=>s.createAction("SET_OPERATION_ERROR_CODE",{...t}),ve=t=>s.createAction("SET_OPERATION_ERROR_NAME",{...t}),Fe=t=>s.createAction("SET_OPERATION_ERROR_DESCRIPTION",{...t}),He=t=>s.createAction("SET_OPERATION_ERROR_TEMPLATE",{...t}),Ve=t=>s.createAction("DELETE_OPERATION_ERROR",{...t}),Xe=t=>s.createAction("REORDER_OPERATION_ERRORS",{...t});class Dt extends s.BaseDocument{addOperationError(e){return this.dispatch(we(e))}setOperationErrorCode(e){return this.dispatch(Ue(e))}setOperationErrorName(e){return this.dispatch(ve(e))}setOperationErrorDescription(e){return this.dispatch(Fe(e))}setOperationErrorTemplate(e){return this.dispatch(He(e))}deleteOperationError(e){return this.dispatch(Ve(e))}reorderOperationErrors(e){return this.dispatch(Xe(e))}}const Ge=t=>s.createAction("ADD_OPERATION_EXAMPLE",{...t}),Be=t=>s.createAction("UPDATE_OPERATION_EXAMPLE",{...t}),We=t=>s.createAction("DELETE_OPERATION_EXAMPLE",{...t}),$e=t=>s.createAction("REORDER_OPERATION_EXAMPLES",{...t});class Mt extends s.BaseDocument{addOperationExample(e){return this.dispatch(Ge(e))}updateOperationExample(e){return this.dispatch(Be(e))}deleteOperationExample(e){return this.dispatch(We(e))}reorderOperationExamples(e){return this.dispatch($e(e))}}const qe=t=>s.createAction("ADD_OPERATION",{...t}),Je=t=>s.createAction("SET_OPERATION_NAME",{...t}),Ke=t=>s.createAction("SET_OPERATION_SCOPE",{...t}),Qe=t=>s.createAction("SET_OPERATION_SCHEMA",{...t}),Ye=t=>s.createAction("SET_OPERATION_DESCRIPTION",{...t}),Ze=t=>s.createAction("SET_OPERATION_TEMPLATE",{...t}),et=t=>s.createAction("SET_OPERATION_REDUCER",{...t}),tt=t=>s.createAction("MOVE_OPERATION",{...t}),rt=t=>s.createAction("DELETE_OPERATION",{...t}),ot=t=>s.createAction("REORDER_MODULE_OPERATIONS",{...t});class xt extends s.BaseDocument{addOperation(e){return this.dispatch(qe(e))}setOperationName(e){return this.dispatch(Je(e))}setOperationScope(e){return this.dispatch(Ke(e))}setOperationSchema(e){return this.dispatch(Qe(e))}setOperationDescription(e){return this.dispatch(Ye(e))}setOperationTemplate(e){return this.dispatch(Ze(e))}setOperationReducer(e){return this.dispatch(et(e))}moveOperation(e){return this.dispatch(tt(e))}deleteOperation(e){return this.dispatch(rt(e))}reorderModuleOperations(e){return this.dispatch(ot(e))}}const nt=t=>s.createAction("SET_STATE_SCHEMA",{...t}),it=t=>s.createAction("SET_INITIAL_STATE",{...t}),st=t=>s.createAction("ADD_STATE_EXAMPLE",{...t}),at=t=>s.createAction("UPDATE_STATE_EXAMPLE",{...t}),pt=t=>s.createAction("DELETE_STATE_EXAMPLE",{...t}),lt=t=>s.createAction("REORDER_STATE_EXAMPLES",{...t});class Nt extends s.BaseDocument{setStateSchema(e){return this.dispatch(nt(e))}setInitialState(e){return this.dispatch(it(e))}addStateExample(e){return this.dispatch(st(e))}updateStateExample(e){return this.dispatch(at(e))}deleteStateExample(e){return this.dispatch(pt(e))}reorderStateExamples(e){return this.dispatch(lt(e))}}var u;let S=(u=class extends s.BaseDocument{constructor(e,n){super(m,O.createDocument(e),n)}saveToFile(e,n){return super.saveToFile(e,u.fileExtension,n)}loadFromFile(e){return super.loadFromFile(e)}static async fromFile(e){const n=new this;return await n.loadFromFile(e),n}},de(u,"fileExtension","phdm"),u);s.applyMixins(S,[Tt,bt,Rt,Dt,Mt,xt,Nt]);const Lt=Object.freeze(Object.defineProperty({__proto__:null,addChangeLogItem:De,addModule:Pe,addOperation:qe,addOperationError:we,addOperationExample:Ge,addStateExample:st,deleteChangeLogItem:xe,deleteModule:ke,deleteOperation:rt,deleteOperationError:Ve,deleteOperationExample:We,deleteStateExample:pt,moveOperation:tt,releaseNewVersion:Le,reorderChangeLogItems:Ne,reorderModuleOperations:ot,reorderModules:ye,reorderOperationErrors:Xe,reorderOperationExamples:$e,reorderStateExamples:lt,setAuthorName:be,setAuthorWebsite:Re,setInitialState:it,setModelDescription:Te,setModelExtension:Ie,setModelId:ze,setModelName:Ae,setModuleDescription:Ce,setModuleName:je,setOperationDescription:Ye,setOperationErrorCode:Ue,setOperationErrorDescription:Fe,setOperationErrorName:ve,setOperationErrorTemplate:He,setOperationName:Je,setOperationReducer:et,setOperationSchema:Qe,setOperationScope:Ke,setOperationTemplate:Ze,setStateSchema:nt,updateChangeLogItem:Me,updateOperationExample:Be,updateStateExample:at},Symbol.toStringTag,{value:"Module"})),pe=S,le={...O,...mt},ce={...s.BaseActions,...Lt},ct={Document:pe,reducer:m,actions:ce,utils:le,documentModel:f},Pt=Object.freeze(Object.defineProperty({__proto__:null,Document:pe,DocumentModel:S,actions:ce,documentModel:f,module:ct,reducer:m,utils:le,z:_e},Symbol.toStringTag,{value:"Module"}));exports.Document=pe;exports.DocumentModel=Pt;exports.DocumentModel$1=S;exports.actions=ce;exports.documentModel=f;exports.module=ct;exports.reducer=m;exports.utils=le;exports.zod=_e;
@@ -1,6 +0,0 @@
1
- "use strict";var Er=Object.defineProperty;var Fr=(i,a,s)=>a in i?Er(i,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[a]=s;var J=(i,a,s)=>(Fr(i,typeof a!="symbol"?a+"":a,s),s);const _r=require("json-stringify-deterministic"),R=require("immer"),Bt=require("jszip"),g=require("zod"),St=i=>i!=null,Ar=g.z.any().refine(i=>St(i)),jt=g.z.enum(["LOAD_STATE"]),Ut=g.z.enum(["PRUNE"]),It=g.z.enum(["REDO"]),zt=g.z.enum(["SET_NAME"]),Tt=g.z.enum(["UNDO"]);function Br(){return g.z.object({__typename:g.z.literal("Action").optional(),type:g.z.string()})}function kt(){return g.z.union([ot(),pt(),st(),lt(),ct()])}function Sr(){return g.z.object({__typename:g.z.literal("DocumentFile").optional(),data:g.z.string(),extension:g.z.string().nullable(),fileName:g.z.string().nullable(),mimeType:g.z.string()})}function ot(){return g.z.object({input:g.z.lazy(()=>Dt()),type:jt,scope:g.z.literal("global")})}function Dt(){return g.z.object({operations:g.z.number(),state:g.z.lazy(()=>Ot())})}function Ot(){return g.z.object({data:g.z.unknown().nullish(),name:g.z.string()})}function jr(){return g.z.object({__typename:g.z.literal("Operation").optional(),hash:g.z.string(),index:g.z.number(),timestamp:g.z.string().datetime(),type:g.z.string()})}function pt(){return g.z.object({input:g.z.lazy(()=>Nt()),type:Ut,scope:g.z.literal("global")})}function Nt(){return g.z.object({end:g.z.number().nullish(),start:g.z.number().nullish()})}function st(){return g.z.object({input:g.z.number(),type:It,scope:g.z.literal("global")})}function lt(){return g.z.object({input:g.z.string(),type:zt,scope:g.z.literal("global")})}function Ur(){return g.z.object({__typename:g.z.literal("SetNameOperation").optional(),hash:g.z.string(),index:g.z.number(),input:g.z.string(),timestamp:g.z.string().datetime(),type:g.z.string()})}function ct(){return g.z.object({input:g.z.number(),type:Tt,scope:g.z.literal("global")})}const Ir=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:Br,BaseActionSchema:kt,DocumentFileSchema:Sr,LoadStateActionInputSchema:Dt,LoadStateActionSchema:ot,LoadStateActionStateInputSchema:Ot,Load_StateSchema:jt,OperationSchema:jr,PruneActionInputSchema:Nt,PruneActionSchema:pt,PruneSchema:Ut,RedoActionSchema:st,RedoSchema:It,SetNameActionSchema:lt,SetNameOperationSchema:Ur,Set_NameSchema:zt,UndoActionSchema:ct,UndoSchema:Tt,definedNonNullAnySchema:Ar,isDefinedNonNullAny:St},Symbol.toStringTag,{value:"Module"}));function Mt(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}function W(){this._types=Object.create(null),this._extensions=Object.create(null);for(let i=0;i<arguments.length;i++)this.define(arguments[i]);this.define=this.define.bind(this),this.getType=this.getType.bind(this),this.getExtension=this.getExtension.bind(this)}W.prototype.define=function(i,a){for(let s in i){let l=i[s].map(function(f){return f.toLowerCase()});s=s.toLowerCase();for(let f=0;f<l.length;f++){const h=l[f];if(h[0]!=="*"){if(!a&&h in this._types)throw new Error('Attempt to change mapping for "'+h+'" extension from "'+this._types[h]+'" to "'+s+'". Pass `force=true` to allow this, otherwise remove "'+h+'" from the list of extensions for "'+s+'".');this._types[h]=s}}if(a||!this._extensions[s]){const f=l[0];this._extensions[s]=f[0]!=="*"?f:f.substr(1)}}};W.prototype.getType=function(i){i=String(i);let a=i.replace(/^.*[/\\]/,"").toLowerCase(),s=a.replace(/^.*\./,"").toLowerCase(),l=a.length<i.length;return(s.length<a.length-1||!l)&&this._types[s]||null};W.prototype.getExtension=function(i){return i=/^\s*([^;\s]*)/.test(i)&&RegExp.$1,i&&this._extensions[i.toLowerCase()]||null};var zr=W,Tr={"application/andrew-inset":["ez"],"application/applixware":["aw"],"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/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/cu-seeme":["cu"],"application/dash+xml":["mpd"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["es","ecma"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/express":["exp"],"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","mjs"],"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/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":["mp4s","m4p"],"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-signature":["asc","sig"],"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/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/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/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/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/avif":["avif"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"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"],"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/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/step+xml":["stpx"],"model/step+zip":["stpz"],"model/step-xml+zip":["stpxz"],"model/stl":["stl"],"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/jsx":["jsx"],"text/less":["less"],"text/markdown":["markdown","md"],"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/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"]};let kr=zr;var Dr=new kr(Tr);const Or=Mt(Dr);var rt={exports:{}};typeof Object.create=="function"?rt.exports=function(a,s){s&&(a.super_=s,a.prototype=Object.create(s.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}))}:rt.exports=function(a,s){if(s){a.super_=s;var l=function(){};l.prototype=s.prototype,a.prototype=new l,a.prototype.constructor=a}};var Nr=rt.exports,et={exports:{}},Rt={},H={};H.byteLength=Cr;H.toByteArray=qr;H.fromByteArray=Pr;var z=[],j=[],Mr=typeof Uint8Array<"u"?Uint8Array:Array,tt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var k=0,Rr=tt.length;k<Rr;++k)z[k]=tt[k],j[tt.charCodeAt(k)]=k;j["-".charCodeAt(0)]=62;j["_".charCodeAt(0)]=63;function Ct(i){var a=i.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var s=i.indexOf("=");s===-1&&(s=a);var l=s===a?0:4-s%4;return[s,l]}function Cr(i){var a=Ct(i),s=a[0],l=a[1];return(s+l)*3/4-l}function Lr(i,a,s){return(a+s)*3/4-s}function qr(i){var a,s=Ct(i),l=s[0],f=s[1],h=new Mr(Lr(i,l,f)),u=0,o=f>0?l-4:l,x;for(x=0;x<o;x+=4)a=j[i.charCodeAt(x)]<<18|j[i.charCodeAt(x+1)]<<12|j[i.charCodeAt(x+2)]<<6|j[i.charCodeAt(x+3)],h[u++]=a>>16&255,h[u++]=a>>8&255,h[u++]=a&255;return f===2&&(a=j[i.charCodeAt(x)]<<2|j[i.charCodeAt(x+1)]>>4,h[u++]=a&255),f===1&&(a=j[i.charCodeAt(x)]<<10|j[i.charCodeAt(x+1)]<<4|j[i.charCodeAt(x+2)]>>2,h[u++]=a>>8&255,h[u++]=a&255),h}function $r(i){return z[i>>18&63]+z[i>>12&63]+z[i>>6&63]+z[i&63]}function Jr(i,a,s){for(var l,f=[],h=a;h<s;h+=3)l=(i[h]<<16&16711680)+(i[h+1]<<8&65280)+(i[h+2]&255),f.push($r(l));return f.join("")}function Pr(i){for(var a,s=i.length,l=s%3,f=[],h=16383,u=0,o=s-l;u<o;u+=h)f.push(Jr(i,u,u+h>o?o:u+h));return l===1?(a=i[s-1],f.push(z[a>>2]+z[a<<4&63]+"==")):l===2&&(a=(i[s-2]<<8)+i[s-1],f.push(z[a>>10]+z[a>>4&63]+z[a<<2&63]+"=")),f.join("")}var ut={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */ut.read=function(i,a,s,l,f){var h,u,o=f*8-l-1,x=(1<<o)-1,y=x>>1,w=-7,F=s?f-1:0,U=s?-1:1,B=i[a+F];for(F+=U,h=B&(1<<-w)-1,B>>=-w,w+=o;w>0;h=h*256+i[a+F],F+=U,w-=8);for(u=h&(1<<-w)-1,h>>=-w,w+=l;w>0;u=u*256+i[a+F],F+=U,w-=8);if(h===0)h=1-y;else{if(h===x)return u?NaN:(B?-1:1)*(1/0);u=u+Math.pow(2,l),h=h-y}return(B?-1:1)*u*Math.pow(2,h-l)};ut.write=function(i,a,s,l,f,h){var u,o,x,y=h*8-f-1,w=(1<<y)-1,F=w>>1,U=f===23?Math.pow(2,-24)-Math.pow(2,-77):0,B=l?0:h-1,O=l?1:-1,N=a<0||a===0&&1/a<0?1:0;for(a=Math.abs(a),isNaN(a)||a===1/0?(o=isNaN(a)?1:0,u=w):(u=Math.floor(Math.log(a)/Math.LN2),a*(x=Math.pow(2,-u))<1&&(u--,x*=2),u+F>=1?a+=U/x:a+=U*Math.pow(2,1-F),a*x>=2&&(u++,x/=2),u+F>=w?(o=0,u=w):u+F>=1?(o=(a*x-1)*Math.pow(2,f),u=u+F):(o=a*Math.pow(2,F-1)*Math.pow(2,f),u=0));f>=8;i[s+B]=o&255,B+=O,o/=256,f-=8);for(u=u<<f|o,y+=f;y>0;i[s+B]=u&255,B+=O,u/=256,y-=8);i[s+B-O]|=N*128};/*!
2
- * The buffer module from node.js, for the browser.
3
- *
4
- * @author Feross Aboukhadijeh <https://feross.org>
5
- * @license MIT
6
- */(function(i){var a=H,s=ut,l=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;i.Buffer=o,i.SlowBuffer=nr,i.INSPECT_MAX_BYTES=50;var f=2147483647;i.kMaxLength=f,o.TYPED_ARRAY_SUPPORT=h(),!o.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 h(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}});function u(e){if(e>f)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,o.prototype),t}function o(e,t,r){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return F(e)}return x(e,t,r)}o.poolSize=8192;function x(e,t,r){if(typeof e=="string")return U(e,t);if(ArrayBuffer.isView(e))return O(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(I(e,ArrayBuffer)||e&&I(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(I(e,SharedArrayBuffer)||e&&I(e.buffer,SharedArrayBuffer)))return N(e,t,r);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var n=e.valueOf&&e.valueOf();if(n!=null&&n!==e)return o.from(n,t,r);var p=ir(e);if(p)return p;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return o.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}o.from=function(e,t,r){return x(e,t,r)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array);function y(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function w(e,t,r){return y(e),e<=0?u(e):t!==void 0?typeof r=="string"?u(e).fill(t,r):u(e).fill(t):u(e)}o.alloc=function(e,t,r){return w(e,t,r)};function F(e){return y(e),u(e<0?0:G(e)|0)}o.allocUnsafe=function(e){return F(e)},o.allocUnsafeSlow=function(e){return F(e)};function U(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!o.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=xt(e,t)|0,n=u(r),p=n.write(e,t);return p!==r&&(n=n.slice(0,p)),n}function B(e){for(var t=e.length<0?0:G(e.length)|0,r=u(t),n=0;n<t;n+=1)r[n]=e[n]&255;return r}function O(e){if(I(e,Uint8Array)){var t=new Uint8Array(e);return N(t.buffer,t.byteOffset,t.byteLength)}return B(e)}function N(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');var n;return t===void 0&&r===void 0?n=new Uint8Array(e):r===void 0?n=new Uint8Array(e,t):n=new Uint8Array(e,t,r),Object.setPrototypeOf(n,o.prototype),n}function ir(e){if(o.isBuffer(e)){var t=G(e.length)|0,r=u(t);return r.length===0||e.copy(r,0,0,t),r}if(e.length!==void 0)return typeof e.length!="number"||Q(e.length)?u(0):B(e);if(e.type==="Buffer"&&Array.isArray(e.data))return B(e.data)}function G(e){if(e>=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+" bytes");return e|0}function nr(e){return+e!=e&&(e=0),o.alloc(+e)}o.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==o.prototype},o.compare=function(t,r){if(I(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),I(r,Uint8Array)&&(r=o.from(r,r.offset,r.byteLength)),!o.isBuffer(t)||!o.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;for(var n=t.length,p=r.length,c=0,m=Math.min(n,p);c<m;++c)if(t[c]!==r[c]){n=t[c],p=r[c];break}return n<p?-1:p<n?1:0},o.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}},o.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return o.alloc(0);var n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;var p=o.allocUnsafe(r),c=0;for(n=0;n<t.length;++n){var m=t[n];if(I(m,Uint8Array))c+m.length>p.length?o.from(m).copy(p,c):Uint8Array.prototype.set.call(p,m,c);else if(o.isBuffer(m))m.copy(p,c);else throw new TypeError('"list" argument must be an Array of Buffers');c+=m.length}return p};function xt(e,t){if(o.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||I(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;for(var p=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Ft(e).length;default:if(p)return n?-1:V(e).length;t=(""+t).toLowerCase(),p=!0}}o.byteLength=xt;function ar(e,t,r){var n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return xr(this,t,r);case"utf8":case"utf-8":return yt(this,t,r);case"ascii":return hr(this,t,r);case"latin1":case"binary":return mr(this,t,r);case"base64":return ur(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return gr(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}o.prototype._isBuffer=!0;function T(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}o.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 r=0;r<t;r+=2)T(this,r,r+1);return this},o.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 r=0;r<t;r+=4)T(this,r,r+3),T(this,r+1,r+2);return this},o.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 r=0;r<t;r+=8)T(this,r,r+7),T(this,r+1,r+6),T(this,r+2,r+5),T(this,r+3,r+4);return this},o.prototype.toString=function(){var t=this.length;return t===0?"":arguments.length===0?yt(this,0,t):ar.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(t){if(!o.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:o.compare(this,t)===0},o.prototype.inspect=function(){var t="",r=i.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},l&&(o.prototype[l]=o.prototype.inspect),o.prototype.compare=function(t,r,n,p,c){if(I(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),p===void 0&&(p=0),c===void 0&&(c=this.length),r<0||n>t.length||p<0||c>this.length)throw new RangeError("out of range index");if(p>=c&&r>=n)return 0;if(p>=c)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,p>>>=0,c>>>=0,this===t)return 0;for(var m=c-p,d=n-r,v=Math.min(m,d),b=this.slice(p,c),A=t.slice(r,n),E=0;E<v;++E)if(b[E]!==A[E]){m=b[E],d=A[E];break}return m<d?-1:d<m?1:0};function gt(e,t,r,n,p){if(e.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Q(r)&&(r=p?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(p)return-1;r=e.length-1}else if(r<0)if(p)r=0;else return-1;if(typeof t=="string"&&(t=o.from(t,n)),o.isBuffer(t))return t.length===0?-1:dt(e,t,r,n,p);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?p?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):dt(e,[t],r,n,p);throw new TypeError("val must be string, number or Buffer")}function dt(e,t,r,n,p){var c=1,m=e.length,d=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;c=2,m/=2,d/=2,r/=2}function v(_t,At){return c===1?_t[At]:_t.readUInt16BE(At*c)}var b;if(p){var A=-1;for(b=r;b<m;b++)if(v(e,b)===v(t,A===-1?0:b-A)){if(A===-1&&(A=b),b-A+1===d)return A*c}else A!==-1&&(b-=b-A),A=-1}else for(r+d>m&&(r=m-d),b=r;b>=0;b--){for(var E=!0,$=0;$<d;$++)if(v(e,b+$)!==v(t,$)){E=!1;break}if(E)return b}return-1}o.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1},o.prototype.indexOf=function(t,r,n){return gt(this,t,r,n,!0)},o.prototype.lastIndexOf=function(t,r,n){return gt(this,t,r,n,!1)};function or(e,t,r,n){r=Number(r)||0;var p=e.length-r;n?(n=Number(n),n>p&&(n=p)):n=p;var c=t.length;n>c/2&&(n=c/2);for(var m=0;m<n;++m){var d=parseInt(t.substr(m*2,2),16);if(Q(d))return m;e[r+m]=d}return m}function pr(e,t,r,n){return q(V(t,e.length-r),e,r,n)}function sr(e,t,r,n){return q(wr(t),e,r,n)}function lr(e,t,r,n){return q(Ft(t),e,r,n)}function cr(e,t,r,n){return q(vr(t,e.length-r),e,r,n)}o.prototype.write=function(t,r,n,p){if(r===void 0)p="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")p=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,p===void 0&&(p="utf8")):(p=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var c=this.length-r;if((n===void 0||n>c)&&(n=c),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");p||(p="utf8");for(var m=!1;;)switch(p){case"hex":return or(this,t,r,n);case"utf8":case"utf-8":return pr(this,t,r,n);case"ascii":case"latin1":case"binary":return sr(this,t,r,n);case"base64":return lr(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return cr(this,t,r,n);default:if(m)throw new TypeError("Unknown encoding: "+p);p=(""+p).toLowerCase(),m=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ur(e,t,r){return t===0&&r===e.length?a.fromByteArray(e):a.fromByteArray(e.slice(t,r))}function yt(e,t,r){r=Math.min(e.length,r);for(var n=[],p=t;p<r;){var c=e[p],m=null,d=c>239?4:c>223?3:c>191?2:1;if(p+d<=r){var v,b,A,E;switch(d){case 1:c<128&&(m=c);break;case 2:v=e[p+1],(v&192)===128&&(E=(c&31)<<6|v&63,E>127&&(m=E));break;case 3:v=e[p+1],b=e[p+2],(v&192)===128&&(b&192)===128&&(E=(c&15)<<12|(v&63)<<6|b&63,E>2047&&(E<55296||E>57343)&&(m=E));break;case 4:v=e[p+1],b=e[p+2],A=e[p+3],(v&192)===128&&(b&192)===128&&(A&192)===128&&(E=(c&15)<<18|(v&63)<<12|(b&63)<<6|A&63,E>65535&&E<1114112&&(m=E))}}m===null?(m=65533,d=1):m>65535&&(m-=65536,n.push(m>>>10&1023|55296),m=56320|m&1023),n.push(m),p+=d}return fr(n)}var wt=4096;function fr(e){var t=e.length;if(t<=wt)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=wt));return r}function hr(e,t,r){var n="";r=Math.min(e.length,r);for(var p=t;p<r;++p)n+=String.fromCharCode(e[p]&127);return n}function mr(e,t,r){var n="";r=Math.min(e.length,r);for(var p=t;p<r;++p)n+=String.fromCharCode(e[p]);return n}function xr(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var p="",c=t;c<r;++c)p+=br[e[c]];return p}function gr(e,t,r){for(var n=e.slice(t,r),p="",c=0;c<n.length-1;c+=2)p+=String.fromCharCode(n[c]+n[c+1]*256);return p}o.prototype.slice=function(t,r){var n=this.length;t=~~t,r=r===void 0?n:~~r,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<t&&(r=t);var p=this.subarray(t,r);return Object.setPrototypeOf(p,o.prototype),p};function _(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUintLE=o.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||_(t,r,this.length);for(var p=this[t],c=1,m=0;++m<r&&(c*=256);)p+=this[t+m]*c;return p},o.prototype.readUintBE=o.prototype.readUIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||_(t,r,this.length);for(var p=this[t+--r],c=1;r>0&&(c*=256);)p+=this[t+--r]*c;return p},o.prototype.readUint8=o.prototype.readUInt8=function(t,r){return t=t>>>0,r||_(t,1,this.length),this[t]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||_(t,2,this.length),this[t]|this[t+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||_(t,2,this.length),this[t]<<8|this[t+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||_(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||_(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},o.prototype.readIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||_(t,r,this.length);for(var p=this[t],c=1,m=0;++m<r&&(c*=256);)p+=this[t+m]*c;return c*=128,p>=c&&(p-=Math.pow(2,8*r)),p},o.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||_(t,r,this.length);for(var p=r,c=1,m=this[t+--p];p>0&&(c*=256);)m+=this[t+--p]*c;return c*=128,m>=c&&(m-=Math.pow(2,8*r)),m},o.prototype.readInt8=function(t,r){return t=t>>>0,r||_(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},o.prototype.readInt16LE=function(t,r){t=t>>>0,r||_(t,2,this.length);var n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n},o.prototype.readInt16BE=function(t,r){t=t>>>0,r||_(t,2,this.length);var n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n},o.prototype.readInt32LE=function(t,r){return t=t>>>0,r||_(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},o.prototype.readInt32BE=function(t,r){return t=t>>>0,r||_(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},o.prototype.readFloatLE=function(t,r){return t=t>>>0,r||_(t,4,this.length),s.read(this,t,!0,23,4)},o.prototype.readFloatBE=function(t,r){return t=t>>>0,r||_(t,4,this.length),s.read(this,t,!1,23,4)},o.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||_(t,8,this.length),s.read(this,t,!0,52,8)},o.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||_(t,8,this.length),s.read(this,t,!1,52,8)};function S(e,t,r,n,p,c){if(!o.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>p||t<c)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}o.prototype.writeUintLE=o.prototype.writeUIntLE=function(t,r,n,p){if(t=+t,r=r>>>0,n=n>>>0,!p){var c=Math.pow(2,8*n)-1;S(this,t,r,n,c,0)}var m=1,d=0;for(this[r]=t&255;++d<n&&(m*=256);)this[r+d]=t/m&255;return r+n},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(t,r,n,p){if(t=+t,r=r>>>0,n=n>>>0,!p){var c=Math.pow(2,8*n)-1;S(this,t,r,n,c,0)}var m=n-1,d=1;for(this[r+m]=t&255;--m>=0&&(d*=256);)this[r+m]=t/d&255;return r+n},o.prototype.writeUint8=o.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||S(this,t,r,1,255,0),this[r]=t&255,r+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||S(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||S(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||S(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255,r+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||S(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4},o.prototype.writeIntLE=function(t,r,n,p){if(t=+t,r=r>>>0,!p){var c=Math.pow(2,8*n-1);S(this,t,r,n,c-1,-c)}var m=0,d=1,v=0;for(this[r]=t&255;++m<n&&(d*=256);)t<0&&v===0&&this[r+m-1]!==0&&(v=1),this[r+m]=(t/d>>0)-v&255;return r+n},o.prototype.writeIntBE=function(t,r,n,p){if(t=+t,r=r>>>0,!p){var c=Math.pow(2,8*n-1);S(this,t,r,n,c-1,-c)}var m=n-1,d=1,v=0;for(this[r+m]=t&255;--m>=0&&(d*=256);)t<0&&v===0&&this[r+m+1]!==0&&(v=1),this[r+m]=(t/d>>0)-v&255;return r+n},o.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||S(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1},o.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||S(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2},o.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||S(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2},o.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||S(this,t,r,4,2147483647,-2147483648),this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},o.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||S(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};function vt(e,t,r,n,p,c){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function bt(e,t,r,n,p){return t=+t,r=r>>>0,p||vt(e,t,r,4),s.write(e,t,r,n,23,4),r+4}o.prototype.writeFloatLE=function(t,r,n){return bt(this,t,r,!0,n)},o.prototype.writeFloatBE=function(t,r,n){return bt(this,t,r,!1,n)};function Et(e,t,r,n,p){return t=+t,r=r>>>0,p||vt(e,t,r,8),s.write(e,t,r,n,52,8),r+8}o.prototype.writeDoubleLE=function(t,r,n){return Et(this,t,r,!0,n)},o.prototype.writeDoubleBE=function(t,r,n){return Et(this,t,r,!1,n)},o.prototype.copy=function(t,r,n,p){if(!o.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!p&&p!==0&&(p=this.length),r>=t.length&&(r=t.length),r||(r=0),p>0&&p<n&&(p=n),p===n||t.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(p<0)throw new RangeError("sourceEnd out of bounds");p>this.length&&(p=this.length),t.length-r<p-n&&(p=t.length-r+n);var c=p-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,p):Uint8Array.prototype.set.call(t,this.subarray(n,p),r),c},o.prototype.fill=function(t,r,n,p){if(typeof t=="string"){if(typeof r=="string"?(p=r,r=0,n=this.length):typeof n=="string"&&(p=n,n=this.length),p!==void 0&&typeof p!="string")throw new TypeError("encoding must be a string");if(typeof p=="string"&&!o.isEncoding(p))throw new TypeError("Unknown encoding: "+p);if(t.length===1){var c=t.charCodeAt(0);(p==="utf8"&&c<128||p==="latin1")&&(t=c)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);var m;if(typeof t=="number")for(m=r;m<n;++m)this[m]=t;else{var d=o.isBuffer(t)?t:o.from(t,p),v=d.length;if(v===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(m=0;m<n-r;++m)this[m+r]=d[m%v]}return this};var dr=/[^+/0-9A-Za-z-_]/g;function yr(e){if(e=e.split("=")[0],e=e.trim().replace(dr,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function V(e,t){t=t||1/0;for(var r,n=e.length,p=null,c=[],m=0;m<n;++m){if(r=e.charCodeAt(m),r>55295&&r<57344){if(!p){if(r>56319){(t-=3)>-1&&c.push(239,191,189);continue}else if(m+1===n){(t-=3)>-1&&c.push(239,191,189);continue}p=r;continue}if(r<56320){(t-=3)>-1&&c.push(239,191,189),p=r;continue}r=(p-55296<<10|r-56320)+65536}else p&&(t-=3)>-1&&c.push(239,191,189);if(p=null,r<128){if((t-=1)<0)break;c.push(r)}else if(r<2048){if((t-=2)<0)break;c.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;c.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;c.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return c}function wr(e){for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function vr(e,t){for(var r,n,p,c=[],m=0;m<e.length&&!((t-=2)<0);++m)r=e.charCodeAt(m),n=r>>8,p=r%256,c.push(p),c.push(n);return c}function Ft(e){return a.toByteArray(yr(e))}function q(e,t,r,n){for(var p=0;p<n&&!(p+r>=t.length||p>=e.length);++p)t[p+r]=e[p];return p}function I(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function Q(e){return e!==e}var br=function(){for(var e="0123456789abcdef",t=new Array(256),r=0;r<16;++r)for(var n=r*16,p=0;p<16;++p)t[n+p]=e[r]+e[p];return t}()})(Rt);/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(i,a){var s=Rt,l=s.Buffer;function f(u,o){for(var x in u)o[x]=u[x]}l.from&&l.alloc&&l.allocUnsafe&&l.allocUnsafeSlow?i.exports=s:(f(s,a),a.Buffer=h);function h(u,o,x){return l(u,o,x)}h.prototype=Object.create(l.prototype),f(l,h),h.from=function(u,o,x){if(typeof u=="number")throw new TypeError("Argument must not be a number");return l(u,o,x)},h.alloc=function(u,o,x){if(typeof u!="number")throw new TypeError("Argument must be a number");var y=l(u);return o!==void 0?typeof x=="string"?y.fill(o,x):y.fill(o):y.fill(0),y},h.allocUnsafe=function(u){if(typeof u!="number")throw new TypeError("Argument must be a number");return l(u)},h.allocUnsafeSlow=function(u){if(typeof u!="number")throw new TypeError("Argument must be a number");return s.SlowBuffer(u)}})(et,et.exports);var Lt=et.exports,qt=Lt.Buffer;function Z(i,a){this._block=qt.alloc(i),this._finalSize=a,this._blockSize=i,this._len=0}Z.prototype.update=function(i,a){typeof i=="string"&&(a=a||"utf8",i=qt.from(i,a));for(var s=this._block,l=this._blockSize,f=i.length,h=this._len,u=0;u<f;){for(var o=h%l,x=Math.min(f-u,l-o),y=0;y<x;y++)s[o+y]=i[u+y];h+=x,u+=x,h%l===0&&this._update(s)}return this._len+=f,this};Z.prototype.digest=function(i){var a=this._len%this._blockSize;this._block[a]=128,this._block.fill(0,a+1),a>=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 l=(s&4294967295)>>>0,f=(s-l)/4294967296;this._block.writeUInt32BE(f,this._blockSize-8),this._block.writeUInt32BE(l,this._blockSize-4)}this._update(this._block);var h=this._hash();return i?h.toString(i):h};Z.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var Wr=Z,Hr=Nr,$t=Wr,Zr=Lt.Buffer,Kr=[1518500249,1859775393,-1894007588,-899497514],Yr=new Array(80);function L(){this.init(),this._w=Yr,$t.call(this,64,56)}Hr(L,$t);L.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Xr(i){return i<<1|i>>>31}function Gr(i){return i<<5|i>>>27}function Vr(i){return i<<30|i>>>2}function Qr(i,a,s,l){return i===0?a&s|~a&l:i===2?a&s|a&l|s&l:a^s^l}L.prototype._update=function(i){for(var a=this._w,s=this._a|0,l=this._b|0,f=this._c|0,h=this._d|0,u=this._e|0,o=0;o<16;++o)a[o]=i.readInt32BE(o*4);for(;o<80;++o)a[o]=Xr(a[o-3]^a[o-8]^a[o-14]^a[o-16]);for(var x=0;x<80;++x){var y=~~(x/20),w=Gr(s)+Qr(y,l,f,h)+u+a[x]+Kr[y]|0;u=h,h=f,f=Vr(l),l=s,s=w}this._a=s+this._a|0,this._b=l+this._b|0,this._c=f+this._c|0,this._d=h+this._d|0,this._e=u+this._e|0};L.prototype._hash=function(){var i=Zr.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 te=L;const re=Mt(te),ft=new Error("File system not available.");function ee(i,a,s){throw ft}function Jt(i){throw ft}function ie(i){throw ft}const ne=async i=>Jt();function ae(i){let a="";for(let s=0;s<i.length;s+=2)a+=String.fromCharCode(parseInt(i.substr(s,2),16));return btoa(a)}const K=(i,a="sha1")=>{if(a!=="sha1")throw new Error("Only sha1 algorithm is available.");const s=new re;return ae(s.update(i).digest("hex"))},ht=async i=>{const a=new Bt,{name:s,revision:l,documentType:f,created:h,lastModified:u}=i,o={name:s,revision:l,documentType:f,created:h,lastModified:u};return a.file("header.json",JSON.stringify(o,null,2)),a.file("state.json",JSON.stringify(i.initialState||{},null,2)),a.file("operations.json",JSON.stringify(i.operations,null,2)),Object.keys(i.attachments).forEach(y=>{const{data:w,...F}=i.attachments[y];a.file(y,w,{base64:!0,createFolders:!0,comment:JSON.stringify(F)})}),a},Pt=async(i,a,s,l)=>{await(await ht(i)).generateAsync({type:"uint8array",streamFiles:!0});const h=l??i.name,u=`.${s}.zip`;return ee(a,h.endsWith(u)?h:`${h}${u}`)},oe=async(i,a)=>{const l=await(await ht(i)).generateAsync({type:"blob"}),f=await a.createWritable();await f.write(l),await f.close()},it=async(i,a)=>{const s=Jt();return Wt(s,a)},Wt=async(i,a)=>{const s=new Bt;return await s.loadAsync(i),pe(s,a)};async function pe(i,a){const s=i.file("state.json");if(!s)throw new Error("Initial state not found");const l=await s.async("string"),f=JSON.parse(l),h=i.file("header.json");let u=null;h&&(u=JSON.parse(await h.async("string")));const o=i.file("operations.json");if(!o)throw new Error("Operations history not found");const x=JSON.parse(await o.async("string")),y={...f,...u,initialState:f,operations:{global:[],local:[]},attachments:{...f.attachments}};let w=x.global.concat(x.local).slice(0,u==null?void 0:u.revision).reduce((F,U)=>a(F,U),y);return u&&(w={...w,...u,operations:{global:[...w.operations.global,...x.global.slice(u.revision)],local:w.operations.local}}),w}function Ht(i){const a=i.replace(/^.*\./,"")||void 0,s=i.replace(/^.*[/\\]/,"")||void 0;return{extension:a,fileName:s}}async function se(i){const{buffer:a,mimeType:s="application/octet-stream"}=await ie(),l=Ht(i),f=a.toString("base64");return{data:f,hash:K(f),mimeType:s,...l}}async function le(i){const a=await ne(),s=Or.getType(i)||"application/octet-stream",l=Ht(i),f=a.toString("base64");return{data:f,hash:K(f),mimeType:s,...l}}function P(i,a,s,l){const f=Vt(i),h=Xt(s);return a.global.concat(a.local).reduce((u,o)=>h(u,o,l),f)}function ce(i,a){return{...i,name:a}}function ue(i,a,s){const l=Math.min(a,i.revision),f=i.operations.global.slice(0,i.revision-l);return{...P(i.initialState,{global:f,local:i.operations.local},s),operations:i.operations,revision:i.revision-l}}function fe(i,a,s){const l=i.operations.global.length-i.revision;if(!l)throw new Error("There is no UNDO operation to REDO");const f=a<l?a:l,h=i.operations.global.slice(0,i.revision+f);return{...P(i.initialState,{global:h,local:i.operations.local},s),operations:i.operations,revision:i.revision+f}}function he(i,a,s,l){a=a||0,s=s||i.operations.global.length;const f=i.operations.global.slice(a,s),h=i.operations.global.slice(0,a),u=i.operations.global.slice(s),o=P(i.initialState,{global:h.concat(f),local:i.operations.local},l),{name:x,state:y}=o;return P(i.initialState,{global:[...h,mt({name:x,state:y},f.length),...u],local:i.operations.local},l)}function me(i,a){return{...i,name:a.name,state:a.state??{global:{},local:{}}}}const Zt="SET_NAME",Y="UNDO",X="REDO",C="PRUNE",Kt="LOAD_STATE";function xe(i,a){return[Y,X,C].includes(a.type)?i.revision:i.revision+1}function ge(i,a){return{...i,revision:xe(i,a),lastModified:new Date().toISOString()}}function de(i,a){if([Y,X,C,C].includes(a.type))return i;const s=i.operations.global.slice(0,i.revision),l=i.operations.local.slice();return!a.scope||a.scope==="global"?s.push({...a,index:s.length,timestamp:new Date().toISOString(),hash:"",scope:"global"}):a.scope==="local"&&l.push({...a,index:l.length,timestamp:new Date().toISOString(),hash:"",scope:"local"}),{...i,operations:{global:s,local:l}}}function ye(i,a){let s=de(i,a);return(!a.scope||a.scope==="global")&&(s=ge(s,a)),s}function we(i,a,s){switch(kt().parse(a),a.type){case Zt:return ce(i,a.input);case Y:return ue(i,a.input,s);case X:return fe(i,a.input,s);case C:return he(i,a.input.start,a.input.end,s);case Kt:return me(i,a.input.state);default:return i}}function Yt(i,a,s,l){let f=i;return nt(a)&&(f=we(f,a,s)),f=ye(f,a),f=R.produce(f,h=>{const u=s(h.state,a,l);if(u)return R.castDraft({...f,state:u})}),R.produce(f,h=>{!a.scope||a.scope==="global"?h.operations.global[h.operations.global.length-1].hash=at(h,"global"):a.scope==="local"&&(h.operations.local[h.operations.local.length-1].hash=at(h,"local")),!nt(a)&&a.attachments&&a.attachments.forEach(u=>{const{hash:o,...x}=u;h.attachments[o]={...x}})})}function nt(i){return[Zt,Y,X,C,Kt].includes(i.type)}function D(i,a,s,l,f="global"){if(!i)throw new Error("Empty action type");if(typeof i!="string")throw new Error(`Invalid action type: ${i}`);const h={type:i,input:a,scope:f};return s&&(h.attachments=s),l==null||l().parse(h),h}function Xt(i,a=Yt){return(s,l,f)=>a(s,l,i,f)}const Gt=(i,a)=>({name:"",documentType:"",revision:0,created:new Date().toISOString(),lastModified:new Date().toISOString(),attachments:{},...i,state:(a==null?void 0:a(i==null?void 0:i.state))??(i==null?void 0:i.state)??{global:{},local:{}}}),Vt=(i,a)=>{const s=Gt(i,a);return{...s,initialState:s,operations:{global:[],local:[]}}},at=(i,a="global")=>K(_r(a==="local"?i.state.local:i.state.global)),ve=(i,a=1e3)=>{const s=Math.random()*a;return K(`${(i??new Date).toISOString()}${s}`)};function M(i){return R.castImmutable(R.freeze(i,!0))}const Qt=i=>D("SET_NAME",i,void 0,lt),tr=(i=1)=>D("UNDO",i,void 0,ct),rr=(i=1)=>D("REDO",i,void 0,st),er=(i,a)=>D("PRUNE",{start:i,end:a},void 0,pt),mt=(i,a)=>D("LOAD_STATE",{state:i,operations:a},void 0,ot),be=Object.freeze(Object.defineProperty({__proto__:null,loadState:mt,prune:er,redo:rr,setName:Qt,undo:tr},Symbol.toStringTag,{value:"Module"}));class Ee{constructor(a,s,l){J(this,"_document");J(this,"_reducer");J(this,"_signalDispatch");this._reducer=a,this._document=s,this._signalDispatch=l}dispatch(a){return this._document=this._reducer(this._document,a,this._signalDispatch),this}saveToFile(a,s,l){return Pt(this._document,a,s,l)}async loadFromFile(a){this._document=await it(a,this._reducer)}static async stateFromFile(a,s){return await it(a,s)}get state(){return M(this._document.state)}get operations(){return M(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}get initialState(){return M(this._document.initialState)}toDocument(){return M(this._document)}getAttachment(a){return this._document.attachments[a]}setName(a){return this.dispatch(Qt(a)),this}undo(a){return this.dispatch(tr(a)),this}redo(a){return this.dispatch(rr(a)),this}prune(a,s){return this.dispatch(er(a,s)),this}loadState(a,s){return this.dispatch(mt(a,s)),this}}function Fe(i,a){a.forEach(s=>{Object.getOwnPropertyNames(s.prototype).forEach(l=>{Object.defineProperty(i.prototype,l,Object.getOwnPropertyDescriptor(s.prototype,l)||Object.create(null))})})}exports.BaseActions=be;exports.BaseDocument=Ee;exports.applyMixins=Fe;exports.baseReducer=Yt;exports.createAction=D;exports.createDocument=Vt;exports.createExtendedState=Gt;exports.createReducer=Xt;exports.createZip=ht;exports.getLocalFile=le;exports.getRemoteFile=se;exports.hashDocument=at;exports.hashKey=ve;exports.isBaseAction=nt;exports.loadFromFile=it;exports.loadFromInput=Wt;exports.readOnly=M;exports.saveToFile=Pt;exports.saveToFileHandle=oe;exports.zod=Ir;
@@ -1,22 +0,0 @@
1
- "use strict";var dt=Object.defineProperty;var ut=(t,e,n)=>e in t?dt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var de=(t,e,n)=>(ut(t,typeof e!="symbol"?e+"":e,n),n);const s=require("./object-f3dd289e.js");require("json-stringify-deterministic");require("immer");require("crypto");require("fs");require("https");require("path");require("jszip");const r=require("zod"),mt=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),f={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:{schema:"",initialValue:`{
2
- "id": "",
3
- "name": "",
4
- "extension": "",
5
- "description": "",
6
- "author": {
7
- "name": "",
8
- "website": ""
9
- },
10
- "specifications": [
11
- {
12
- "version": 1,
13
- "changeLog": [],
14
- "state": {
15
- "schema": "",
16
- "initialValue": "",
17
- "examples": []
18
- },
19
- "modules": []
20
- }
21
- ]
22
- }`,examples:[]}}]},ue=t=>t!=null,Et=r.z.any().refine(t=>ue(t));function _(){return r.z.object({__typename:r.z.literal("AddChangeLogItemInput").optional(),content:r.z.string(),id:r.z.string(),insertBefore:r.z.string().nullable()})}function A(){return r.z.object({description:r.z.string().nullish(),id:r.z.string(),name:r.z.string()})}function z(){return r.z.object({errorCode:r.z.string().nullish(),errorDescription:r.z.string().nullish(),errorName:r.z.string().nullish(),errorTemplate:r.z.string().nullish(),id:r.z.string(),operationId:r.z.string()})}function I(){return r.z.object({example:r.z.string(),id:r.z.string(),operationId:r.z.string()})}function T(){return r.z.object({description:r.z.string().nullish(),id:r.z.string(),moduleId:r.z.string(),name:r.z.string(),reducer:r.z.string().nullish(),schema:r.z.string().nullish(),template:r.z.string().nullish(),scope:r.z.literal("local").or(r.z.literal("global")).nullish()})}function b(){return r.z.object({example:r.z.string(),id:r.z.string(),insertBefore:r.z.string().nullish()})}function me(){return r.z.object({__typename:r.z.literal("Author").optional(),name:r.z.string(),website:r.z.string().nullable()})}function R(){return r.z.object({__typename:r.z.literal("CodeExample").optional(),id:r.z.string(),value:r.z.string()})}function D(){return r.z.object({__typename:r.z.literal("DeleteChangeLogItemInput").optional(),id:r.z.string()})}function M(){return r.z.object({id:r.z.string()})}function x(){return r.z.object({id:r.z.string()})}function N(){return r.z.object({id:r.z.string()})}function L(){return r.z.object({id:r.z.string()})}function P(){return r.z.object({id:r.z.string()})}function ht(){return r.z.union([_(),A(),z(),I(),T(),b(),D(),M(),x(),N(),L(),P(),j(),C(),k(),y(),w(),U(),v(),F(),H(),V(),X(),G(),B(),W(),$(),q(),J(),K(),Q(),Y(),Z(),ee(),te(),re(),oe(),ne(),ie(),se(),ae()])}function Ot(){return r.z.object({__typename:r.z.literal("DocumentModelState").optional(),author:me(),description:r.z.string(),extension:r.z.string(),id:r.z.string(),name:r.z.string(),specifications:r.z.array(Ee())})}function Ee(){return r.z.object({__typename:r.z.literal("DocumentSpecification").optional(),changeLog:r.z.array(r.z.string()),modules:r.z.array(he()),state:fe(),version:r.z.number()})}function he(){return r.z.object({__typename:r.z.literal("Module").optional(),description:r.z.string().nullable(),id:r.z.string(),name:r.z.string(),operations:r.z.array(Oe())})}function j(){return r.z.object({newModuleId:r.z.string(),operationId:r.z.string()})}function Oe(){return r.z.object({__typename:r.z.literal("Operation").optional(),description:r.z.string().nullable(),errors:r.z.array(ge()),examples:r.z.array(R()),id:r.z.string(),name:r.z.string().nullable(),reducer:r.z.string().nullable(),schema:r.z.string().nullable(),template:r.z.string().nullable(),scope:r.z.literal("local").or(r.z.literal("global"))})}function ge(){return r.z.object({__typename:r.z.literal("OperationError").optional(),code:r.z.string().nullable(),description:r.z.string().nullable(),id:r.z.string(),name:r.z.string().nullable(),template:r.z.string().nullable()})}function C(){return r.z.object({__typename:r.z.literal("ReorderChangeLogItemsInput").optional(),order:r.z.array(r.z.string())})}function k(){return r.z.object({moduleId:r.z.string(),order:r.z.array(r.z.string())})}function y(){return r.z.object({order:r.z.array(r.z.string())})}function w(){return r.z.object({operationId:r.z.string(),order:r.z.array(r.z.string())})}function U(){return r.z.object({operationId:r.z.string(),order:r.z.array(r.z.string())})}function v(){return r.z.object({order:r.z.array(r.z.string())})}function F(){return r.z.object({authorName:r.z.string()})}function H(){return r.z.object({authorWebsite:r.z.string()})}function V(){return r.z.object({initialValue:r.z.string()})}function X(){return r.z.object({description:r.z.string()})}function G(){return r.z.object({extension:r.z.string()})}function B(){return r.z.object({id:r.z.string()})}function W(){return r.z.object({name:r.z.string()})}function $(){return r.z.object({description:r.z.string().nullish(),id:r.z.string()})}function q(){return r.z.object({id:r.z.string(),name:r.z.string().nullish()})}function J(){return r.z.object({description:r.z.string().nullish(),id:r.z.string()})}function K(){return r.z.object({errorCode:r.z.string().nullish(),id:r.z.string()})}function Q(){return r.z.object({errorDescription:r.z.string().nullish(),id:r.z.string()})}function Y(){return r.z.object({errorName:r.z.string().nullish(),id:r.z.string()})}function Z(){return r.z.object({errorTemplate:r.z.string().nullish(),id:r.z.string()})}function ee(){return r.z.object({id:r.z.string(),name:r.z.string().nullish()})}function Se(){return r.z.object({id:r.z.string(),scope:r.z.literal("global").or(r.z.literal("local"))})}function te(){return r.z.object({id:r.z.string(),reducer:r.z.string().nullish()})}function re(){return r.z.object({id:r.z.string(),schema:r.z.string().nullish()})}function oe(){return r.z.object({id:r.z.string(),template:r.z.string().nullish()})}function ne(){return r.z.object({schema:r.z.string()})}function fe(){return r.z.object({__typename:r.z.literal("State").optional(),examples:r.z.array(R()),initialValue:r.z.string(),schema:r.z.string()})}function ie(){return r.z.object({__typename:r.z.literal("UpdateChangeLogItemInput").optional(),id:r.z.string(),newContent:r.z.string()})}function se(){return r.z.object({example:r.z.string(),id:r.z.string()})}function ae(){return r.z.object({id:r.z.string(),newExample:r.z.string()})}const _e=Object.freeze(Object.defineProperty({__proto__:null,AddChangeLogItemInputSchema:_,AddModuleInputSchema:A,AddOperationErrorInputSchema:z,AddOperationExampleInputSchema:I,AddOperationInputSchema:T,AddStateExampleInputSchema:b,AuthorSchema:me,CodeExampleSchema:R,DeleteChangeLogItemInputSchema:D,DeleteModuleInputSchema:M,DeleteOperationErrorInputSchema:x,DeleteOperationExampleInputSchema:N,DeleteOperationInputSchema:L,DeleteStateExampleInputSchema:P,DocumentModelInputSchema:ht,DocumentModelStateSchema:Ot,DocumentSpecificationSchema:Ee,ModuleSchema:he,MoveOperationInputSchema:j,OperationErrorSchema:ge,OperationSchema:Oe,ReorderChangeLogItemsInputSchema:C,ReorderModuleOperationsInputSchema:k,ReorderModulesInputSchema:y,ReorderOperationErrorsInputSchema:w,ReorderOperationExamplesInputSchema:U,ReorderStateExamplesInputSchema:v,SetAuthorNameInputSchema:F,SetAuthorWebsiteInputSchema:H,SetInitialStateInputSchema:V,SetModelDescriptionInputSchema:X,SetModelExtensionInputSchema:G,SetModelIdInputSchema:B,SetModelNameInputSchema:W,SetModuleDescriptionInputSchema:$,SetModuleNameInputSchema:q,SetOperationDescriptionInputSchema:J,SetOperationErrorCodeInputSchema:K,SetOperationErrorDescriptionInputSchema:Q,SetOperationErrorNameInputSchema:Y,SetOperationErrorTemplateInputSchema:Z,SetOperationNameInputSchema:ee,SetOperationReducerInputSchema:te,SetOperationSchemaInputSchema:re,SetOperationScopeInputSchema:Se,SetOperationTemplateInputSchema:oe,SetStateSchemaInputSchema:ne,StateSchema:fe,UpdateChangeLogItemInputSchema:ie,UpdateOperationExampleInputSchema:se,UpdateStateExampleInputSchema:ae,definedNonNullAnySchema:Et,isDefinedNonNullAny:ue},Symbol.toStringTag,{value:"Module"})),c={setModelNameOperation(t,e){t.name=e.input.name},setModelIdOperation(t,e){t.id=e.input.id},setModelExtensionOperation(t,e){t.extension=e.input.extension},setModelDescriptionOperation(t,e){t.description=e.input.description},setAuthorNameOperation(t,e){t.author=t.author||{name:"",website:null},t.author.name=e.input.authorName},setAuthorWebsiteOperation(t,e){t.author=t.author||{name:"",website:null},t.author.website=e.input.authorWebsite}},E={addChangeLogItemOperation(t,e){throw new Error('Reducer "addChangeLogItemOperation" not yet implemented')},updateChangeLogItemOperation(t,e){throw new Error('Reducer "updateChangeLogItemOperation" not yet implemented')},deleteChangeLogItemOperation(t,e){throw new Error('Reducer "deleteChangeLogItemOperation" not yet implemented')},reorderChangeLogItemsOperation(t,e){throw new Error('Reducer "reorderChangeLogItemsOperation" not yet implemented')},releaseNewVersionOperation(t,e){throw new Error('Reducer "releaseNewVersionOperation" not yet implemented')}},gt=t=>{const e={};return t.forEach((n,o)=>e[n]=o),(n,o)=>(e[o.id]||999999)-(e[n.id]||999999)},h={addModuleOperation(t,e){t.specifications[t.specifications.length-1].modules.push({id:e.input.id,name:e.input.name,description:e.input.description||"",operations:[]})},setModuleNameOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)n.modules[o].id===e.input.id&&(n.modules[o].name=e.input.name||"")},setModuleDescriptionOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)n.modules[o].id===e.input.id&&(n.modules[o].description=e.input.description||"")},deleteModuleOperation(t,e){const n=t.specifications[t.specifications.length-1];n.modules=n.modules.filter(o=>o.id!=e.input.id)},reorderModulesOperation(t,e){t.specifications[t.specifications.length-1].modules.sort(gt(e.input.order))}},St=t=>{const e={};return t.forEach((n,o)=>e[n]=o),(n,o)=>(e[o.id]||999999)-(e[n.id]||999999)},l={addOperationErrorOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.operationId&&n.modules[o].operations[i].errors.push({id:e.input.id,name:e.input.errorName||"",code:e.input.errorCode||"",description:e.input.errorDescription||"",template:e.input.errorTemplate||""})},setOperationErrorCodeOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)for(let a=0;a<n.modules[o].operations[i].errors.length;a++)n.modules[o].operations[i].errors[a].id==e.input.id&&(n.modules[o].operations[i].errors[a].code=e.input.errorCode||"")},setOperationErrorNameOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)for(let a=0;a<n.modules[o].operations[i].errors.length;a++)n.modules[o].operations[i].errors[a].id==e.input.id&&(n.modules[o].operations[i].errors[a].name=e.input.errorName||"")},setOperationErrorDescriptionOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)for(let a=0;a<n.modules[o].operations[i].errors.length;a++)n.modules[o].operations[i].errors[a].id==e.input.id&&(n.modules[o].operations[i].errors[a].description=e.input.errorDescription||"")},setOperationErrorTemplateOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)for(let a=0;a<n.modules[o].operations[i].errors.length;a++)n.modules[o].operations[i].errors[a].id==e.input.id&&(n.modules[o].operations[i].errors[a].template=e.input.errorTemplate||"")},deleteOperationErrorOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].errors=n.modules[o].operations[i].errors.filter(a=>a.id!=e.input.id)},reorderOperationErrorsOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.operationId&&n.modules[o].operations[i].errors.sort(St(e.input.order))}},ft=t=>{const e={};return t.forEach((n,o)=>e[n]=o),(n,o)=>(e[o.id]||999999)-(e[n.id]||999999)},g={addOperationExampleOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.operationId&&n.modules[o].operations[i].examples.push({id:e.input.id,value:e.input.example})},updateOperationExampleOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)for(let a=0;a<n.modules[o].operations[i].examples.length;a++)n.modules[o].operations[i].examples[a].id==e.input.id&&(n.modules[o].operations[i].examples[a].value=e.input.example)},deleteOperationExampleOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].examples=n.modules[o].operations[i].examples.filter(a=>a.id!=e.input.id)},reorderOperationExamplesOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.operationId&&n.modules[o].operations[i].examples.sort(ft(e.input.order))}},_t=t=>{const e={};return t.forEach((n,o)=>e[n]=o),(n,o)=>(e[o.id]||999999)-(e[n.id]||999999)},p={addOperationOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)n.modules[o].id==e.input.moduleId&&n.modules[o].operations.push({id:e.input.id,name:e.input.name,description:e.input.description||"",schema:e.input.schema||"",template:e.input.template||e.input.description||"",reducer:e.input.reducer||"",errors:[],examples:[],scope:e.input.scope||"global"})},setOperationNameOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.id&&(n.modules[o].operations[i].name=e.input.name||"")},setOperationScopeOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.id&&(n.modules[o].operations[i].scope=e.input.scope||"global")},setOperationSchemaOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.id&&(n.modules[o].operations[i].schema=e.input.schema||"")},setOperationDescriptionOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.id&&(n.modules[o].operations[i].description=e.input.description||"")},setOperationTemplateOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.id&&(n.modules[o].operations[i].template=e.input.template||"")},setOperationReducerOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.id&&(n.modules[o].operations[i].reducer=e.input.reducer||"")},moveOperationOperation(t,e){const n=[],o=t.specifications[t.specifications.length-1];for(let i=0;i<o.modules.length;i++)o.modules[i].operations=o.modules[i].operations.filter(a=>a.id==e.input.operationId?(n.push(a),!1):!0);for(let i=0;i<o.modules.length;i++)o.modules[i].id==e.input.newModuleId&&o.modules[i].operations.push(...n)},deleteOperationOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)n.modules[o].operations=n.modules[o].operations.filter(i=>i.id!=e.input.id)},reorderModuleOperationsOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)n.modules[o].id==e.input.moduleId&&n.modules[o].operations.sort(_t(e.input.order))}},At=t=>{const e={};return t.forEach((n,o)=>e[n]=o),(n,o)=>(e[o.id]||999999)-(e[n.id]||999999)},d={setStateSchemaOperation(t,e){const n=t.specifications[t.specifications.length-1];n.state.schema=e.input.schema},setInitialStateOperation(t,e){const n=t.specifications[t.specifications.length-1];n.state.initialValue=e.input.initialValue},addStateExampleOperation(t,e){t.specifications[t.specifications.length-1].state.examples.push({id:e.input.id,value:e.input.example})},updateStateExampleOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.state.examples.length;o++)n.state.examples[o].id==e.input.id&&(n.state.examples[o].value=e.input.newExample)},deleteStateExampleOperation(t,e){const n=t.specifications[t.specifications.length-1];n.state.examples=n.state.examples.filter(o=>o.id!=e.input.id)},reorderStateExamplesOperation(t,e){t.specifications[t.specifications.length-1].state.examples.sort(At(e.input.order))}},zt=(t,e)=>{if(s.isBaseAction(e))return t;switch(e.type){case"SET_MODEL_NAME":W().parse(e.input),c.setModelNameOperation(t,e);break;case"SET_MODEL_ID":B().parse(e.input),c.setModelIdOperation(t,e);break;case"SET_MODEL_EXTENSION":G().parse(e.input),c.setModelExtensionOperation(t,e);break;case"SET_MODEL_DESCRIPTION":X().parse(e.input),c.setModelDescriptionOperation(t,e);break;case"SET_AUTHOR_NAME":F().parse(e.input),c.setAuthorNameOperation(t,e);break;case"SET_AUTHOR_WEBSITE":H().parse(e.input),c.setAuthorWebsiteOperation(t,e);break;case"ADD_CHANGE_LOG_ITEM":_().parse(e.input),E.addChangeLogItemOperation(t,e);break;case"UPDATE_CHANGE_LOG_ITEM":ie().parse(e.input),E.updateChangeLogItemOperation(t,e);break;case"DELETE_CHANGE_LOG_ITEM":D().parse(e.input),E.deleteChangeLogItemOperation(t,e);break;case"REORDER_CHANGE_LOG_ITEMS":C().parse(e.input),E.reorderChangeLogItemsOperation(t,e);break;case"RELEASE_NEW_VERSION":if(Object.keys(e.input).length>0)throw new Error("Expected empty input for action RELEASE_NEW_VERSION");E.releaseNewVersionOperation(t,e);break;case"ADD_MODULE":A().parse(e.input),h.addModuleOperation(t,e);break;case"SET_MODULE_NAME":q().parse(e.input),h.setModuleNameOperation(t,e);break;case"SET_MODULE_DESCRIPTION":$().parse(e.input),h.setModuleDescriptionOperation(t,e);break;case"DELETE_MODULE":M().parse(e.input),h.deleteModuleOperation(t,e);break;case"REORDER_MODULES":y().parse(e.input),h.reorderModulesOperation(t,e);break;case"ADD_OPERATION_ERROR":z().parse(e.input),l.addOperationErrorOperation(t,e);break;case"SET_OPERATION_ERROR_CODE":K().parse(e.input),l.setOperationErrorCodeOperation(t,e);break;case"SET_OPERATION_ERROR_NAME":Y().parse(e.input),l.setOperationErrorNameOperation(t,e);break;case"SET_OPERATION_ERROR_DESCRIPTION":Q().parse(e.input),l.setOperationErrorDescriptionOperation(t,e);break;case"SET_OPERATION_ERROR_TEMPLATE":Z().parse(e.input),l.setOperationErrorTemplateOperation(t,e);break;case"DELETE_OPERATION_ERROR":x().parse(e.input),l.deleteOperationErrorOperation(t,e);break;case"REORDER_OPERATION_ERRORS":w().parse(e.input),l.reorderOperationErrorsOperation(t,e);break;case"ADD_OPERATION_EXAMPLE":I().parse(e.input),g.addOperationExampleOperation(t,e);break;case"UPDATE_OPERATION_EXAMPLE":se().parse(e.input),g.updateOperationExampleOperation(t,e);break;case"DELETE_OPERATION_EXAMPLE":N().parse(e.input),g.deleteOperationExampleOperation(t,e);break;case"REORDER_OPERATION_EXAMPLES":U().parse(e.input),g.reorderOperationExamplesOperation(t,e);break;case"ADD_OPERATION":T().parse(e.input),p.addOperationOperation(t,e);break;case"SET_OPERATION_NAME":ee().parse(e.input),p.setOperationNameOperation(t,e);break;case"SET_OPERATION_SCOPE":Se().parse(e.input),p.setOperationScopeOperation(t,e);break;case"SET_OPERATION_SCHEMA":re().parse(e.input),p.setOperationSchemaOperation(t,e);break;case"SET_OPERATION_DESCRIPTION":J().parse(e.input),p.setOperationDescriptionOperation(t,e);break;case"SET_OPERATION_TEMPLATE":oe().parse(e.input),p.setOperationTemplateOperation(t,e);break;case"SET_OPERATION_REDUCER":te().parse(e.input),p.setOperationReducerOperation(t,e);break;case"MOVE_OPERATION":j().parse(e.input),p.moveOperationOperation(t,e);break;case"DELETE_OPERATION":L().parse(e.input),p.deleteOperationOperation(t,e);break;case"REORDER_MODULE_OPERATIONS":k().parse(e.input),p.reorderModuleOperationsOperation(t,e);break;case"SET_STATE_SCHEMA":ne().parse(e.input),d.setStateSchemaOperation(t,e);break;case"SET_INITIAL_STATE":V().parse(e.input),d.setInitialStateOperation(t,e);break;case"ADD_STATE_EXAMPLE":b().parse(e.input),d.addStateExampleOperation(t,e);break;case"UPDATE_STATE_EXAMPLE":ae().parse(e.input),d.updateStateExampleOperation(t,e);break;case"DELETE_STATE_EXAMPLE":P().parse(e.input),d.deleteStateExampleOperation(t,e);break;case"REORDER_STATE_EXAMPLES":v().parse(e.input),d.reorderStateExamplesOperation(t,e);break;default:return t}},m=s.createReducer(zt),It={id:"",name:"",extension:"",description:"",author:{name:"",website:""},specifications:[{version:1,changeLog:[],state:{schema:"",initialValue:"",examples:[]},modules:[]}]},O={fileExtension:"phdm",createState(t){return{...It,...t}},createExtendedState(t){return s.createExtendedState({...t,documentType:"powerhouse/document-model"},O.createState)},createDocument(t){return s.createDocument(O.createExtendedState(t),O.createState)},saveToFile(t,e,n){return s.saveToFile(t,e,"phdm",n)},saveToFileHandle(t,e){return s.saveToFileHandle(t,e)},loadFromFile(t){return s.loadFromFile(t,m)},loadFromInput(t){return s.loadFromInput(t,m)}},Ae=t=>s.createAction("SET_MODEL_NAME",{...t}),ze=t=>s.createAction("SET_MODEL_ID",{...t}),Ie=t=>s.createAction("SET_MODEL_EXTENSION",{...t}),Te=t=>s.createAction("SET_MODEL_DESCRIPTION",{...t}),be=t=>s.createAction("SET_AUTHOR_NAME",{...t}),Re=t=>s.createAction("SET_AUTHOR_WEBSITE",{...t});class Tt extends s.BaseDocument{setModelName(e){return this.dispatch(Ae(e))}setModelId(e){return this.dispatch(ze(e))}setModelExtension(e){return this.dispatch(Ie(e))}setModelDescription(e){return this.dispatch(Te(e))}setAuthorName(e){return this.dispatch(be(e))}setAuthorWebsite(e){return this.dispatch(Re(e))}}const De=t=>s.createAction("ADD_CHANGE_LOG_ITEM",{...t}),Me=t=>s.createAction("UPDATE_CHANGE_LOG_ITEM",{...t}),xe=t=>s.createAction("DELETE_CHANGE_LOG_ITEM",{...t}),Ne=t=>s.createAction("REORDER_CHANGE_LOG_ITEMS",{...t}),Le=()=>s.createAction("RELEASE_NEW_VERSION");class bt extends s.BaseDocument{addChangeLogItem(e){return this.dispatch(De(e))}updateChangeLogItem(e){return this.dispatch(Me(e))}deleteChangeLogItem(e){return this.dispatch(xe(e))}reorderChangeLogItems(e){return this.dispatch(Ne(e))}releaseNewVersion(){return this.dispatch(Le())}}const Pe=t=>s.createAction("ADD_MODULE",{...t}),je=t=>s.createAction("SET_MODULE_NAME",{...t}),Ce=t=>s.createAction("SET_MODULE_DESCRIPTION",{...t}),ke=t=>s.createAction("DELETE_MODULE",{...t}),ye=t=>s.createAction("REORDER_MODULES",{...t});class Rt extends s.BaseDocument{addModule(e){return this.dispatch(Pe(e))}setModuleName(e){return this.dispatch(je(e))}setModuleDescription(e){return this.dispatch(Ce(e))}deleteModule(e){return this.dispatch(ke(e))}reorderModules(e){return this.dispatch(ye(e))}}const we=t=>s.createAction("ADD_OPERATION_ERROR",{...t}),Ue=t=>s.createAction("SET_OPERATION_ERROR_CODE",{...t}),ve=t=>s.createAction("SET_OPERATION_ERROR_NAME",{...t}),Fe=t=>s.createAction("SET_OPERATION_ERROR_DESCRIPTION",{...t}),He=t=>s.createAction("SET_OPERATION_ERROR_TEMPLATE",{...t}),Ve=t=>s.createAction("DELETE_OPERATION_ERROR",{...t}),Xe=t=>s.createAction("REORDER_OPERATION_ERRORS",{...t});class Dt extends s.BaseDocument{addOperationError(e){return this.dispatch(we(e))}setOperationErrorCode(e){return this.dispatch(Ue(e))}setOperationErrorName(e){return this.dispatch(ve(e))}setOperationErrorDescription(e){return this.dispatch(Fe(e))}setOperationErrorTemplate(e){return this.dispatch(He(e))}deleteOperationError(e){return this.dispatch(Ve(e))}reorderOperationErrors(e){return this.dispatch(Xe(e))}}const Ge=t=>s.createAction("ADD_OPERATION_EXAMPLE",{...t}),Be=t=>s.createAction("UPDATE_OPERATION_EXAMPLE",{...t}),We=t=>s.createAction("DELETE_OPERATION_EXAMPLE",{...t}),$e=t=>s.createAction("REORDER_OPERATION_EXAMPLES",{...t});class Mt extends s.BaseDocument{addOperationExample(e){return this.dispatch(Ge(e))}updateOperationExample(e){return this.dispatch(Be(e))}deleteOperationExample(e){return this.dispatch(We(e))}reorderOperationExamples(e){return this.dispatch($e(e))}}const qe=t=>s.createAction("ADD_OPERATION",{...t}),Je=t=>s.createAction("SET_OPERATION_NAME",{...t}),Ke=t=>s.createAction("SET_OPERATION_SCOPE",{...t}),Qe=t=>s.createAction("SET_OPERATION_SCHEMA",{...t}),Ye=t=>s.createAction("SET_OPERATION_DESCRIPTION",{...t}),Ze=t=>s.createAction("SET_OPERATION_TEMPLATE",{...t}),et=t=>s.createAction("SET_OPERATION_REDUCER",{...t}),tt=t=>s.createAction("MOVE_OPERATION",{...t}),rt=t=>s.createAction("DELETE_OPERATION",{...t}),ot=t=>s.createAction("REORDER_MODULE_OPERATIONS",{...t});class xt extends s.BaseDocument{addOperation(e){return this.dispatch(qe(e))}setOperationName(e){return this.dispatch(Je(e))}setOperationScope(e){return this.dispatch(Ke(e))}setOperationSchema(e){return this.dispatch(Qe(e))}setOperationDescription(e){return this.dispatch(Ye(e))}setOperationTemplate(e){return this.dispatch(Ze(e))}setOperationReducer(e){return this.dispatch(et(e))}moveOperation(e){return this.dispatch(tt(e))}deleteOperation(e){return this.dispatch(rt(e))}reorderModuleOperations(e){return this.dispatch(ot(e))}}const nt=t=>s.createAction("SET_STATE_SCHEMA",{...t}),it=t=>s.createAction("SET_INITIAL_STATE",{...t}),st=t=>s.createAction("ADD_STATE_EXAMPLE",{...t}),at=t=>s.createAction("UPDATE_STATE_EXAMPLE",{...t}),pt=t=>s.createAction("DELETE_STATE_EXAMPLE",{...t}),lt=t=>s.createAction("REORDER_STATE_EXAMPLES",{...t});class Nt extends s.BaseDocument{setStateSchema(e){return this.dispatch(nt(e))}setInitialState(e){return this.dispatch(it(e))}addStateExample(e){return this.dispatch(st(e))}updateStateExample(e){return this.dispatch(at(e))}deleteStateExample(e){return this.dispatch(pt(e))}reorderStateExamples(e){return this.dispatch(lt(e))}}var u;let S=(u=class extends s.BaseDocument{constructor(e,n){super(m,O.createDocument(e),n)}saveToFile(e,n){return super.saveToFile(e,u.fileExtension,n)}loadFromFile(e){return super.loadFromFile(e)}static async fromFile(e){const n=new this;return await n.loadFromFile(e),n}},de(u,"fileExtension","phdm"),u);s.applyMixins(S,[Tt,bt,Rt,Dt,Mt,xt,Nt]);const Lt=Object.freeze(Object.defineProperty({__proto__:null,addChangeLogItem:De,addModule:Pe,addOperation:qe,addOperationError:we,addOperationExample:Ge,addStateExample:st,deleteChangeLogItem:xe,deleteModule:ke,deleteOperation:rt,deleteOperationError:Ve,deleteOperationExample:We,deleteStateExample:pt,moveOperation:tt,releaseNewVersion:Le,reorderChangeLogItems:Ne,reorderModuleOperations:ot,reorderModules:ye,reorderOperationErrors:Xe,reorderOperationExamples:$e,reorderStateExamples:lt,setAuthorName:be,setAuthorWebsite:Re,setInitialState:it,setModelDescription:Te,setModelExtension:Ie,setModelId:ze,setModelName:Ae,setModuleDescription:Ce,setModuleName:je,setOperationDescription:Ye,setOperationErrorCode:Ue,setOperationErrorDescription:Fe,setOperationErrorName:ve,setOperationErrorTemplate:He,setOperationName:Je,setOperationReducer:et,setOperationSchema:Qe,setOperationScope:Ke,setOperationTemplate:Ze,setStateSchema:nt,updateChangeLogItem:Me,updateOperationExample:Be,updateStateExample:at},Symbol.toStringTag,{value:"Module"})),pe=S,le={...O,...mt},ce={...s.BaseActions,...Lt},ct={Document:pe,reducer:m,actions:ce,utils:le,documentModel:f},Pt=Object.freeze(Object.defineProperty({__proto__:null,Document:pe,DocumentModel:S,actions:ce,documentModel:f,module:ct,reducer:m,utils:le,z:_e},Symbol.toStringTag,{value:"Module"}));exports.Document=pe;exports.DocumentModel=Pt;exports.DocumentModel$1=S;exports.actions=ce;exports.documentModel=f;exports.module=ct;exports.reducer=m;exports.utils=le;exports.zod=_e;
@@ -1 +0,0 @@
1
- "use strict";var st=Object.defineProperty;var lt=(t,e,i)=>e in t?st(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var f=(t,e,i)=>(lt(t,typeof e!="symbol"?e+"":e,i),i);const pt=require("json-stringify-deterministic"),x=require("immer"),q=require("jszip"),ct=require("crypto"),z=require("fs"),rt=require("https"),mt=require("path"),n=require("zod"),P=t=>t!=null,ut=n.z.any().refine(t=>P(t)),M=n.z.enum(["LOAD_STATE"]),R=n.z.enum(["PRUNE"]),L=n.z.enum(["REDO"]),I=n.z.enum(["SET_NAME"]),U=n.z.enum(["UNDO"]);function dt(){return n.z.object({__typename:n.z.literal("Action").optional(),type:n.z.string()})}function J(){return n.z.union([D(),k(),E(),A(),N()])}function xt(){return n.z.object({__typename:n.z.literal("DocumentFile").optional(),data:n.z.string(),extension:n.z.string().nullable(),fileName:n.z.string().nullable(),mimeType:n.z.string()})}function D(){return n.z.object({input:n.z.lazy(()=>B()),type:M,scope:n.z.literal("global")})}function B(){return n.z.object({operations:n.z.number(),state:n.z.lazy(()=>C())})}function C(){return n.z.object({data:n.z.unknown().nullish(),name:n.z.string()})}function gt(){return n.z.object({__typename:n.z.literal("Operation").optional(),hash:n.z.string(),index:n.z.number(),timestamp:n.z.string().datetime(),type:n.z.string()})}function k(){return n.z.object({input:n.z.lazy(()=>$()),type:R,scope:n.z.literal("global")})}function $(){return n.z.object({end:n.z.number().nullish(),start:n.z.number().nullish()})}function E(){return n.z.object({input:n.z.number(),type:L,scope:n.z.literal("global")})}function A(){return n.z.object({input:n.z.string(),type:I,scope:n.z.literal("global")})}function ft(){return n.z.object({__typename:n.z.literal("SetNameOperation").optional(),hash:n.z.string(),index:n.z.number(),input:n.z.string(),timestamp:n.z.string().datetime(),type:n.z.string()})}function N(){return n.z.object({input:n.z.number(),type:U,scope:n.z.literal("global")})}const ht=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:dt,BaseActionSchema:J,DocumentFileSchema:xt,LoadStateActionInputSchema:B,LoadStateActionSchema:D,LoadStateActionStateInputSchema:C,Load_StateSchema:M,OperationSchema:gt,PruneActionInputSchema:$,PruneActionSchema:k,PruneSchema:R,RedoActionSchema:E,RedoSchema:L,SetNameActionSchema:A,SetNameOperationSchema:ft,Set_NameSchema:I,UndoActionSchema:N,UndoSchema:U,definedNonNullAnySchema:ut,isDefinedNonNullAny:P},Symbol.toStringTag,{value:"Module"}));function bt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function b(){this._types=Object.create(null),this._extensions=Object.create(null);for(let t=0;t<arguments.length;t++)this.define(arguments[t]);this.define=this.define.bind(this),this.getType=this.getType.bind(this),this.getExtension=this.getExtension.bind(this)}b.prototype.define=function(t,e){for(let i in t){let a=t[i].map(function(o){return o.toLowerCase()});i=i.toLowerCase();for(let o=0;o<a.length;o++){const s=a[o];if(s[0]!=="*"){if(!e&&s in this._types)throw new Error('Attempt to change mapping for "'+s+'" extension from "'+this._types[s]+'" to "'+i+'". Pass `force=true` to allow this, otherwise remove "'+s+'" from the list of extensions for "'+i+'".');this._types[s]=i}}if(e||!this._extensions[i]){const o=a[0];this._extensions[i]=o[0]!=="*"?o:o.substr(1)}}};b.prototype.getType=function(t){t=String(t);let e=t.replace(/^.*[/\\]/,"").toLowerCase(),i=e.replace(/^.*\./,"").toLowerCase(),a=e.length<t.length;return(i.length<e.length-1||!a)&&this._types[i]||null};b.prototype.getExtension=function(t){return t=/^\s*([^;\s]*)/.test(t)&&RegExp.$1,t&&this._extensions[t.toLowerCase()]||null};var vt=b,yt={"application/andrew-inset":["ez"],"application/applixware":["aw"],"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/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/cu-seeme":["cu"],"application/dash+xml":["mpd"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["es","ecma"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/express":["exp"],"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","mjs"],"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/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":["mp4s","m4p"],"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-signature":["asc","sig"],"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/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/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/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/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/avif":["avif"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"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"],"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/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/step+xml":["stpx"],"model/step+zip":["stpz"],"model/step-xml+zip":["stpxz"],"model/stl":["stl"],"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/jsx":["jsx"],"text/less":["less"],"text/markdown":["markdown","md"],"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/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"]};let jt=vt;var wt=new jt(yt);const zt=bt(wt);function St(t,e,i){const a=mt.join(t,e);return z.mkdirSync(t,{recursive:!0}),new Promise((o,s)=>{try{z.writeFile(a,i,{},l=>{l?s(l):o(a)})}catch(l){s(l)}})}function Z(t){return z.readFileSync(t)}function _t(t){return new Promise((e,i)=>{rt.get(t,a=>{const o=[],s=a.headers["content-type"];a.on("data",l=>{o.push(l)}),a.on("end",()=>{e({buffer:Buffer.concat(o),mimeType:s})})}).on("error",a=>{i(a)})})}const Ot=async t=>Z(t),v=(t,e="sha1")=>ct.createHash(e).update(t).digest("base64"),T=async t=>{const e=new q,{name:i,revision:a,documentType:o,created:s,lastModified:l}=t,p={name:i,revision:a,documentType:o,created:s,lastModified:l};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(m=>{const{data:r,...w}=t.attachments[m];e.file(m,r,{base64:!0,createFolders:!0,comment:JSON.stringify(w)})}),e},H=async(t,e,i,a)=>{const s=await(await T(t)).generateAsync({type:"uint8array",streamFiles:!0}),l=a??t.name,p=`.${i}.zip`;return St(e,l.endsWith(p)?l:`${l}${p}`,s)},Dt=async(t,e)=>{const a=await(await T(t)).generateAsync({type:"blob"}),o=await e.createWritable();await o.write(a),await o.close()},S=async(t,e)=>{const i=Z(t);return K(i,e)},K=async(t,e)=>{const i=new q;return await i.loadAsync(t),kt(i,e)};async function kt(t,e){const i=t.file("state.json");if(!i)throw new Error("Initial state not found");const a=await i.async("string"),o=JSON.parse(a),s=t.file("header.json");let l=null;s&&(l=JSON.parse(await s.async("string")));const p=t.file("operations.json");if(!p)throw new Error("Operations history not found");const c=JSON.parse(await p.async("string")),m={...o,...l,initialState:o,operations:{global:[],local:[]},attachments:{...o.attachments}};let r=c.global.concat(c.local).slice(0,l==null?void 0:l.revision).reduce((w,nt)=>e(w,nt),m);return l&&(r={...r,...l,operations:{global:[...r.operations.global,...c.global.slice(l.revision)],local:r.operations.local}}),r}function W(t){const e=t.replace(/^.*\./,"")||void 0,i=t.replace(/^.*[/\\]/,"")||void 0;return{extension:e,fileName:i}}async function Et(t){const{buffer:e,mimeType:i="application/octet-stream"}=await _t(t),a=W(t),o=e.toString("base64");return{data:o,hash:v(o),mimeType:i,...a}}async function At(t){const e=await Ot(t),i=zt.getType(t)||"application/octet-stream",a=W(t),o=e.toString("base64");return{data:o,hash:v(o),mimeType:i,...a}}function h(t,e,i,a){const o=tt(t),s=X(i);return e.global.concat(e.local).reduce((l,p)=>s(l,p,a),o)}function Nt(t,e){return{...t,name:e}}function Tt(t,e,i){const a=Math.min(e,t.revision),o=t.operations.global.slice(0,t.revision-a);return{...h(t.initialState,{global:o,local:t.operations.local},i),operations:t.operations,revision:t.revision-a}}function Ft(t,e,i){const a=t.operations.global.length-t.revision;if(!a)throw new Error("There is no UNDO operation to REDO");const o=e<a?e:a,s=t.operations.global.slice(0,t.revision+o);return{...h(t.initialState,{global:s,local:t.operations.local},i),operations:t.operations,revision:t.revision+o}}function qt(t,e,i,a){e=e||0,i=i||t.operations.global.length;const o=t.operations.global.slice(e,i),s=t.operations.global.slice(0,e),l=t.operations.global.slice(i),p=h(t.initialState,{global:s.concat(o),local:t.operations.local},a),{name:c,state:m}=p;return h(t.initialState,{global:[...s,F({name:c,state:m},o.length),...l],local:t.operations.local},a)}function Pt(t,e){return{...t,name:e.name,state:e.state??{global:{},local:{}}}}const G="SET_NAME",y="UNDO",j="REDO",g="PRUNE",Q="LOAD_STATE";function Mt(t,e){return[y,j,g].includes(e.type)?t.revision:t.revision+1}function Rt(t,e){return{...t,revision:Mt(t,e),lastModified:new Date().toISOString()}}function Lt(t,e){if([y,j,g,g].includes(e.type))return t;const i=t.operations.global.slice(0,t.revision),a=t.operations.local.slice();return!e.scope||e.scope==="global"?i.push({...e,index:i.length,timestamp:new Date().toISOString(),hash:"",scope:"global"}):e.scope==="local"&&a.push({...e,index:a.length,timestamp:new Date().toISOString(),hash:"",scope:"local"}),{...t,operations:{global:i,local:a}}}function It(t,e){let i=Lt(t,e);return(!e.scope||e.scope==="global")&&(i=Rt(i,e)),i}function Ut(t,e,i){switch(J().parse(e),e.type){case G:return Nt(t,e.input);case y:return Tt(t,e.input,i);case j:return Ft(t,e.input,i);case g:return qt(t,e.input.start,e.input.end,i);case Q:return Pt(t,e.input.state);default:return t}}function V(t,e,i,a){let o=t;return _(e)&&(o=Ut(o,e,i)),o=It(o,e),o=x.produce(o,s=>{const l=i(s.state,e,a);if(l)return x.castDraft({...o,state:l})}),x.produce(o,s=>{!e.scope||e.scope==="global"?s.operations.global[s.operations.global.length-1].hash=O(s,"global"):e.scope==="local"&&(s.operations.local[s.operations.local.length-1].hash=O(s,"local")),!_(e)&&e.attachments&&e.attachments.forEach(l=>{const{hash:p,...c}=l;s.attachments[p]={...c}})})}function _(t){return[G,y,j,g,Q].includes(t.type)}function u(t,e,i,a,o="global"){if(!t)throw new Error("Empty action type");if(typeof t!="string")throw new Error(`Invalid action type: ${t}`);const s={type:t,input:e,scope:o};return i&&(s.attachments=i),a==null||a().parse(s),s}function X(t,e=V){return(i,a,o)=>e(i,a,t,o)}const Y=(t,e)=>({name:"",documentType:"",revision: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:{}}}),tt=(t,e)=>{const i=Y(t,e);return{...i,initialState:i,operations:{global:[],local:[]}}},O=(t,e="global")=>v(pt(e==="local"?t.state.local:t.state.global)),Jt=(t,e=1e3)=>{const i=Math.random()*e;return v(`${(t??new Date).toISOString()}${i}`)};function d(t){return x.castImmutable(x.freeze(t,!0))}const et=t=>u("SET_NAME",t,void 0,A),it=(t=1)=>u("UNDO",t,void 0,N),at=(t=1)=>u("REDO",t,void 0,E),ot=(t,e)=>u("PRUNE",{start:t,end:e},void 0,k),F=(t,e)=>u("LOAD_STATE",{state:t,operations:e},void 0,D),Bt=Object.freeze(Object.defineProperty({__proto__:null,loadState:F,prune:ot,redo:at,setName:et,undo:it},Symbol.toStringTag,{value:"Module"}));class Ct{constructor(e,i,a){f(this,"_document");f(this,"_reducer");f(this,"_signalDispatch");this._reducer=e,this._document=i,this._signalDispatch=a}dispatch(e){return this._document=this._reducer(this._document,e,this._signalDispatch),this}saveToFile(e,i,a){return H(this._document,e,i,a)}async loadFromFile(e){this._document=await S(e,this._reducer)}static async stateFromFile(e,i){return await S(e,i)}get state(){return d(this._document.state)}get operations(){return d(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}get initialState(){return d(this._document.initialState)}toDocument(){return d(this._document)}getAttachment(e){return this._document.attachments[e]}setName(e){return this.dispatch(et(e)),this}undo(e){return this.dispatch(it(e)),this}redo(e){return this.dispatch(at(e)),this}prune(e,i){return this.dispatch(ot(e,i)),this}loadState(e,i){return this.dispatch(F(e,i)),this}}function $t(t,e){e.forEach(i=>{Object.getOwnPropertyNames(i.prototype).forEach(a=>{Object.defineProperty(t.prototype,a,Object.getOwnPropertyDescriptor(i.prototype,a)||Object.create(null))})})}exports.BaseActions=Bt;exports.BaseDocument=Ct;exports.applyMixins=$t;exports.baseReducer=V;exports.createAction=u;exports.createDocument=tt;exports.createExtendedState=Y;exports.createReducer=X;exports.createZip=T;exports.getLocalFile=At;exports.getRemoteFile=Et;exports.hashDocument=O;exports.hashKey=Jt;exports.isBaseAction=_;exports.loadFromFile=S;exports.loadFromInput=K;exports.readOnly=d;exports.saveToFile=H;exports.saveToFileHandle=Dt;exports.zod=ht;