document-model 1.0.10 → 1.0.12

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 (37) hide show
  1. package/dist/browser/document/index.d.ts +1 -0
  2. package/dist/browser/document/object.d.ts +4 -2
  3. package/dist/browser/document/reducer.d.ts +2 -1
  4. package/dist/browser/document/signal.d.ts +16 -0
  5. package/dist/browser/document/types.d.ts +4 -3
  6. package/dist/browser/document-model/gen/object.d.ts +2 -2
  7. package/dist/browser/document-model.cjs +1 -1
  8. package/dist/browser/document-model.js +2 -2
  9. package/dist/browser/document.cjs +1 -1
  10. package/dist/browser/document.js +2 -2
  11. package/dist/browser/index.cjs +1 -1
  12. package/dist/browser/index.js +3 -3
  13. package/dist/browser/internal/{index-05592a17.js → index-ac329925.js} +2 -2
  14. package/dist/{node/internal/index-7056a501.js → browser/internal/index-c9e4dc9e.js} +1 -1
  15. package/dist/{node/internal/index-14934709.js → browser/internal/index-cf51e575.js} +1 -1
  16. package/dist/browser/internal/{index-ea1557d4.js → index-df1f6a1b.js} +3 -3
  17. package/dist/browser/internal/{object-70e4dae8.js → object-113c73e2.js} +2 -2
  18. package/dist/browser/internal/{object-35506f2f.js → object-13eaec2b.js} +218 -217
  19. package/dist/node/document/index.d.ts +1 -0
  20. package/dist/node/document/object.d.ts +4 -2
  21. package/dist/node/document/reducer.d.ts +2 -1
  22. package/dist/node/document/signal.d.ts +16 -0
  23. package/dist/node/document/types.d.ts +4 -3
  24. package/dist/node/document-model/gen/object.d.ts +2 -2
  25. package/dist/node/document-model.cjs +1 -1
  26. package/dist/node/document-model.js +2 -2
  27. package/dist/node/document.cjs +1 -1
  28. package/dist/node/document.js +2 -2
  29. package/dist/node/index.cjs +1 -1
  30. package/dist/node/index.js +3 -3
  31. package/dist/node/internal/{index-0b946b7d.js → index-0abc9251.js} +3 -3
  32. package/dist/{browser/internal/index-5dee4170.js → node/internal/index-150bbba4.js} +1 -1
  33. package/dist/node/internal/{index-fbe65e32.js → index-2cd26a65.js} +2 -2
  34. package/dist/{browser/internal/index-a61bcd7c.js → node/internal/index-a74d15aa.js} +1 -1
  35. package/dist/node/internal/{object-8ed23327.js → object-073dccc4.js} +1 -1
  36. package/dist/node/internal/{object-e24dafec.js → object-baf4e3d5.js} +86 -85
  37. package/package.json +1 -1
@@ -1,5 +1,6 @@
1
1
  export * as actions from './actions/creators';
2
2
  export * from './object';
3
3
  export * from './reducer';
4
+ export * from './signal';
4
5
  export * from './types';
5
6
  export * as utils from './utils';
@@ -1,4 +1,5 @@
1
- import { BaseAction } from './actions/types';
1
+ import type { BaseAction } from './actions/types';
2
+ import type { SignalDispatch } from './signal';
2
3
  import type { Action, AttachmentRef, Document, ExtendedState, Reducer } from './types';
3
4
  /**
4
5
  * This is an abstract class representing a document and provides methods
@@ -9,12 +10,13 @@ import type { Action, AttachmentRef, Document, ExtendedState, Reducer } from './
9
10
  export declare abstract class BaseDocument<T, A extends Action> {
10
11
  protected _document: Document<T, A>;
11
12
  private _reducer;
13
+ private _dispatch?;
12
14
  /**
13
15
  * Constructs a BaseDocument instance with an initial state.
14
16
  * @param reducer - The reducer function that updates the state.
15
17
  * @param document - The initial state of the document.
16
18
  */
17
- constructor(reducer: Reducer<T, A>, document: Document<T, A>);
19
+ constructor(reducer: Reducer<T, A>, document: Document<T, A>, dispatch?: SignalDispatch);
18
20
  /**
19
21
  * Dispatches an action to update the state of the document.
20
22
  * @param action - The action to dispatch.
@@ -1,5 +1,6 @@
1
1
  import { BaseAction } from './actions/types';
2
2
  import { Action, Document, ImmutableStateReducer } from './types';
3
+ import { SignalDispatch } from './signal';
3
4
  /**
4
5
  * Base document reducer that wraps a custom document reducer and handles
5
6
  * document-level actions such as undo, redo, prune, and set name.
@@ -12,4 +13,4 @@ import { Action, Document, ImmutableStateReducer } from './types';
12
13
  * specific to the document's state.
13
14
  * @returns The new state of the document.
14
15
  */
15
- export declare function baseReducer<T, A extends Action>(document: Document<T, A>, action: A | BaseAction, customReducer: ImmutableStateReducer<T, A>): Document<T, A>;
16
+ export declare function baseReducer<T, A extends Action>(document: Document<T, A>, action: A | BaseAction, customReducer: ImmutableStateReducer<T, A>, dispatch?: SignalDispatch): Document<T, A>;
@@ -0,0 +1,16 @@
1
+ export interface ISignal<T extends string = string, I = unknown> {
2
+ type: T;
3
+ input: I;
4
+ }
5
+ export type CreateChildDocumentInput = {
6
+ id: string;
7
+ documentType: string;
8
+ initialState?: unknown;
9
+ };
10
+ export type CreateChildDocumentSignal = ISignal<'CREATE_CHILD_DOCUMENT', CreateChildDocumentInput>;
11
+ export type DeleteChildDocumentInput = {
12
+ id: string;
13
+ };
14
+ export type DeleteChildDocumentSignal = ISignal<'DELETE_CHILD_DOCUMENT', DeleteChildDocumentInput>;
15
+ export type Signal = CreateChildDocumentSignal | DeleteChildDocumentSignal;
16
+ export type SignalDispatch = (signal: Signal) => void;
@@ -4,6 +4,7 @@ import type { DocumentModelState } from '../document-model/';
4
4
  import type { BaseAction } from './actions/types';
5
5
  import { BaseDocument } from './object';
6
6
  import { FileInput } from './utils';
7
+ import { SignalDispatch } from './signal';
7
8
  export { z } from './schema';
8
9
  export type * from './schema/types';
9
10
  export type { FileInput } from './utils';
@@ -33,7 +34,7 @@ export type ActionWithAttachment<T extends string = string, I = unknown> = Actio
33
34
  * @typeParam State - The type of the document data.
34
35
  * @typeParam A - The type of the actions supported by the reducer.
35
36
  */
36
- export type Reducer<State, A extends Action> = (state: Document<State, A>, action: A | BaseAction) => Document<State, A>;
37
+ export type Reducer<State, A extends Action> = (state: Document<State, A>, action: A | BaseAction, dispatch?: SignalDispatch) => Document<State, A>;
37
38
  /**
38
39
  * A {@link Reducer} that prevents mutable code from changing the previous state.
39
40
  *
@@ -46,8 +47,8 @@ export type Reducer<State, A extends Action> = (state: Document<State, A>, actio
46
47
  * @typeParam State - The type of the document data.
47
48
  * @typeParam A - The type of the actions supported by the reducer.
48
49
  */
49
- export type ImmutableReducer<State, A extends Action> = (state: Draft<Document<State, A>>, action: A | BaseAction) => Document<State, A> | void;
50
- export type ImmutableStateReducer<State, A extends Action> = (state: Draft<State>, action: A) => State | void;
50
+ export type ImmutableReducer<State, A extends Action> = (state: Draft<Document<State, A>>, action: A | BaseAction, dispatch?: SignalDispatch) => Document<State, A> | void;
51
+ export type ImmutableStateReducer<State, A extends Action> = (state: Draft<State>, action: A, dispatch?: SignalDispatch) => State | void;
51
52
  /**
52
53
  * Scope of an operation.
53
54
  * Global: The operation is synchronized everywhere in the network. This is the default document operation.
@@ -1,5 +1,5 @@
1
1
  import { DocumentModelState } from './types';
2
- import { ExtendedState } from '../../document';
2
+ import { ExtendedState, SignalDispatch } from '../../document';
3
3
  import { BaseDocument } from '../../document/object';
4
4
  import { DocumentModelAction } from './actions';
5
5
  import DocumentModel_Header from './header/object';
@@ -20,7 +20,7 @@ interface DocumentModel extends DocumentModel_Header, DocumentModel_Versioning,
20
20
  }
21
21
  declare class DocumentModel extends BaseDocument<DocumentModelState, DocumentModelAction> {
22
22
  static fileExtension: string;
23
- constructor(initialState?: Partial<ExtendedState<Partial<DocumentModelState>>>);
23
+ constructor(initialState?: Partial<ExtendedState<Partial<DocumentModelState>>>, dispatch?: SignalDispatch);
24
24
  saveToFile(path: string, name?: string): Promise<string>;
25
25
  loadFromFile(path: string): Promise<void>;
26
26
  static fromFile(path: string): Promise<DocumentModel>;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-70e4dae8.js");require("json-stringify-deterministic");require("immer");require("jszip");const e=require("./internal/index-05592a17.js");require("zod");exports.Document=e.Document;exports.DocumentModel=e.DocumentModel$1;exports.actions=e.actions;exports.documentModel=e.documentModel;exports.module=e.module;exports.reducer=e.reducer;exports.utils=e.utils;exports.z=e.zod;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-113c73e2.js");require("json-stringify-deterministic");require("immer");require("jszip");const e=require("./internal/index-ac329925.js");require("zod");exports.Document=e.Document;exports.DocumentModel=e.DocumentModel$1;exports.actions=e.actions;exports.documentModel=e.documentModel;exports.module=e.module;exports.reducer=e.reducer;exports.utils=e.utils;exports.z=e.zod;
@@ -1,8 +1,8 @@
1
- import "./internal/object-35506f2f.js";
1
+ import "./internal/object-13eaec2b.js";
2
2
  import "json-stringify-deterministic";
3
3
  import "immer";
4
4
  import "jszip";
5
- import { b as i, a as u, c, d, m as p, r as l, u as n, z as D } from "./internal/index-ea1557d4.js";
5
+ import { b as i, a as u, c, d, m as p, r as l, u as n, z as D } from "./internal/index-df1f6a1b.js";
6
6
  import "zod";
7
7
  export {
8
8
  i as Document,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal/object-70e4dae8.js"),r=require("./internal/index-a61bcd7c.js");require("json-stringify-deterministic");require("immer");require("jszip");require("zod");exports.BaseDocument=e.BaseDocument;exports.actions=e.BaseActions;exports.applyMixins=e.applyMixins;exports.baseReducer=e.baseReducer;exports.z=e.zod;exports.utils=r.index;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal/object-113c73e2.js"),r=require("./internal/index-cf51e575.js");require("json-stringify-deterministic");require("immer");require("jszip");require("zod");exports.BaseDocument=e.BaseDocument;exports.actions=e.BaseActions;exports.applyMixins=e.applyMixins;exports.baseReducer=e.baseReducer;exports.z=e.zod;exports.utils=r.index;
@@ -1,5 +1,5 @@
1
- import { B as t, h as e, g as m, p as c, z as n } from "./internal/object-35506f2f.js";
2
- import { i as x } from "./internal/index-5dee4170.js";
1
+ import { B as t, h as e, g as m, p as c, z as n } from "./internal/object-13eaec2b.js";
2
+ import { i as x } from "./internal/index-c9e4dc9e.js";
3
3
  import "json-stringify-deterministic";
4
4
  import "immer";
5
5
  import "jszip";
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./internal/index-a61bcd7c.js"),o=require("./internal/index-05592a17.js");require("./internal/object-70e4dae8.js");require("json-stringify-deterministic");require("immer");require("jszip");require("zod");const u={"powerhouse/document":e.Document,"powerhouse/document-model":o.DocumentModel},t={Document:e.Document,DocumentModel:o.DocumentModel};exports.Document=e.Document;exports.DocumentModel=o.DocumentModel;exports.DocumentModels=u;exports.default=t;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./internal/index-cf51e575.js"),o=require("./internal/index-ac329925.js");require("./internal/object-113c73e2.js");require("json-stringify-deterministic");require("immer");require("jszip");require("zod");const u={"powerhouse/document":e.Document,"powerhouse/document-model":o.DocumentModel},t={Document:e.Document,DocumentModel:o.DocumentModel};exports.Document=e.Document;exports.DocumentModel=o.DocumentModel;exports.DocumentModels=u;exports.default=t;
@@ -1,6 +1,6 @@
1
- import { D as o } from "./internal/index-5dee4170.js";
2
- import { D as t } from "./internal/index-ea1557d4.js";
3
- import "./internal/object-35506f2f.js";
1
+ import { D as o } from "./internal/index-c9e4dc9e.js";
2
+ import { D as t } from "./internal/index-df1f6a1b.js";
3
+ import "./internal/object-13eaec2b.js";
4
4
  import "json-stringify-deterministic";
5
5
  import "immer";
6
6
  import "jszip";
@@ -1,4 +1,4 @@
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-70e4dae8.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:`{
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-113c73e2.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
2
  "id": "",
3
3
  "name": "",
4
4
  "extension": "",
@@ -19,4 +19,4 @@
19
19
  "modules": []
20
20
  }
21
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){super(m,O.createDocument(e))}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;
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,4 +1,4 @@
1
- import { f as e, b as a, a as s, c as t, j as o, k as r, m as c, n as l, o as n, i, l as d, e as u, r as m, s as p, d as b, B as _, h as g, g as y, p as F, z as f } from "./object-e24dafec.js";
1
+ import { f as e, b as a, a as s, c as t, j as o, k as r, m as c, n as l, o as n, i, l as d, e as u, r as m, s as p, d as b, B as _, h as g, g as y, p as F, z as f } from "./object-13eaec2b.js";
2
2
  const h = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3
3
  __proto__: null,
4
4
  createAction: e,
@@ -1 +1 @@
1
- "use strict";const e=require("./object-8ed23327.js"),t=Object.freeze(Object.defineProperty({__proto__:null,createAction:e.createAction,createDocument:e.createDocument,createExtendedState:e.createExtendedState,createReducer:e.createReducer,createZip:e.createZip,getLocalFile:e.getLocalFile,getRemoteFile:e.getRemoteFile,hashDocument:e.hashDocument,hashKey:e.hashKey,isBaseAction:e.isBaseAction,loadFromFile:e.loadFromFile,loadFromInput:e.loadFromInput,readOnly:e.readOnly,saveToFile:e.saveToFile,saveToFileHandle:e.saveToFileHandle},Symbol.toStringTag,{value:"Module"})),o=Object.freeze(Object.defineProperty({__proto__:null,BaseDocument:e.BaseDocument,actions:e.BaseActions,applyMixins:e.applyMixins,baseReducer:e.baseReducer,utils:t,z:e.zod},Symbol.toStringTag,{value:"Module"}));exports.Document=o;exports.index=t;
1
+ "use strict";const e=require("./object-113c73e2.js"),t=Object.freeze(Object.defineProperty({__proto__:null,createAction:e.createAction,createDocument:e.createDocument,createExtendedState:e.createExtendedState,createReducer:e.createReducer,createZip:e.createZip,getLocalFile:e.getLocalFile,getRemoteFile:e.getRemoteFile,hashDocument:e.hashDocument,hashKey:e.hashKey,isBaseAction:e.isBaseAction,loadFromFile:e.loadFromFile,loadFromInput:e.loadFromInput,readOnly:e.readOnly,saveToFile:e.saveToFile,saveToFileHandle:e.saveToFileHandle},Symbol.toStringTag,{value:"Module"})),o=Object.freeze(Object.defineProperty({__proto__:null,BaseDocument:e.BaseDocument,actions:e.BaseActions,applyMixins:e.applyMixins,baseReducer:e.baseReducer,utils:t,z:e.zod},Symbol.toStringTag,{value:"Module"}));exports.Document=o;exports.index=t;
@@ -1,7 +1,7 @@
1
1
  var dt = Object.defineProperty;
2
2
  var ct = (t, e, n) => e in t ? dt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
3
  var pe = (t, e, n) => (ct(t, typeof e != "symbol" ? e + "" : e, n), n);
4
- import { c as ut, i as mt, a as Et, b as ht, s as Ot, d as gt, l as St, e as ft, f as s, B as l, g as _t, h as It } from "./object-35506f2f.js";
4
+ import { c as ut, i as mt, a as Et, b as ht, s as Ot, d as gt, l as St, e as ft, f as s, B as l, g as _t, h as It } from "./object-13eaec2b.js";
5
5
  import "json-stringify-deterministic";
6
6
  import "immer";
7
7
  import "jszip";
@@ -1745,8 +1745,8 @@ class Ht extends l {
1745
1745
  }
1746
1746
  var m;
1747
1747
  let ae = (m = class extends l {
1748
- constructor(e) {
1749
- super(g, O.createDocument(e));
1748
+ constructor(e, n) {
1749
+ super(g, O.createDocument(e), n);
1750
1750
  }
1751
1751
  saveToFile(e, n) {
1752
1752
  return super.saveToFile(e, m.fileExtension, n);