import { h as hashKey, z as z$1, c as createReducer, i as isBaseAction, a as createAction, B as BaseDocument, b as applyMixins, d as BaseActions } from './object-9b920497.js';

const createEmptyDocumentModelState = () => ({
  id: hashKey(),
  name: "",
  extension: "",
  description: "",
  author: {
    name: "",
    website: ""
  },
  state: {
    schema: "",
    examples: []
  },
  modules: []
});
const dateTimeNow = (/* @__PURE__ */ new Date()).toISOString();
const createEmptyExtendedDocumentModelState = () => ({
  // Component 1: document header
  name: "",
  created: dateTimeNow,
  lastModified: dateTimeNow,
  documentType: "powerhouse/document-model",
  revision: 0,
  // Component 2: (strict) state object
  // TODO: rename data to state
  data: createEmptyDocumentModelState(),
  // Component 3: file registry
  fileRegistry: {},
  // TODO: remove operations, lift to the document level structure: operations = { fileRegistry:File[], history:Operation[] }
  operations: [],
  // TODO: remove initialState, lift to the document level (with type: ExtendedDocumentModelState)
  initialState: {
    name: "",
    created: dateTimeNow,
    lastModified: dateTimeNow,
    documentType: "powerhouse/document-model",
    revision: 0,
    data: createEmptyDocumentModelState(),
    fileRegistry: {},
    operations: []
  }
});

const r = (e) => e != null, J = z$1.any().refine((e) => r(e));
function i() {
  return z$1.object({
    description: z$1.string().nullish(),
    name: z$1.string()
  });
}
function o() {
  return z$1.object({
    errorCode: z$1.string().nullish(),
    errorDescription: z$1.string().nullish(),
    errorName: z$1.string().nullish(),
    errorTemplate: z$1.string().nullish(),
    operationId: z$1.string()
  });
}
function u() {
  return z$1.object({
    example: z$1.string(),
    operationId: z$1.string()
  });
}
function a() {
  return z$1.object({
    description: z$1.string().nullish(),
    moduleId: z$1.string(),
    name: z$1.string(),
    reducer: z$1.string().nullish(),
    schema: z$1.string().nullish(),
    template: z$1.string().nullish()
  });
}
function c() {
  return z$1.object({
    example: z$1.string(),
    insertBefore: z$1.string().nullish()
  });
}
function s() {
  return z$1.object({
    __typename: z$1.literal("Author").optional(),
    name: z$1.string(),
    website: z$1.string().nullish()
  });
}
function n() {
  return z$1.object({
    __typename: z$1.literal("CodeExample").optional(),
    id: z$1.string(),
    value: z$1.string()
  });
}
function l() {
  return z$1.object({
    id: z$1.string()
  });
}
function p() {
  return z$1.object({
    id: z$1.string()
  });
}
function m() {
  return z$1.object({
    id: z$1.string()
  });
}
function d() {
  return z$1.object({
    id: z$1.string()
  });
}
function h() {
  return z$1.object({
    id: z$1.string()
  });
}
function K() {
  return z$1.union([i(), o(), u(), a(), c(), l(), p(), m(), d(), h(), S(), I(), j(), O(), y(), E(), x(), M(), _(), D(), N(), A(), R(), C(), T(), z(), v(), w(), U(), W(), B(), P(), k(), q(), G(), H()]);
}
function L() {
  return z$1.object({
    __typename: z$1.literal("DocumentModelState").optional(),
    author: s(),
    description: z$1.string(),
    extension: z$1.string(),
    id: z$1.string(),
    modules: z$1.array(g()),
    name: z$1.string(),
    state: F()
  });
}
function g() {
  return z$1.object({
    __typename: z$1.literal("Module").optional(),
    description: z$1.string().nullish(),
    id: z$1.string(),
    name: z$1.string(),
    operations: z$1.array(f())
  });
}
function S() {
  return z$1.object({
    newModuleId: z$1.string(),
    operationId: z$1.string()
  });
}
function f() {
  return z$1.object({
    __typename: z$1.literal("Operation").optional(),
    description: z$1.string().nullish(),
    errors: z$1.array(b()),
    examples: z$1.array(n()),
    id: z$1.string(),
    name: z$1.string().nullish(),
    reducer: z$1.string().nullish(),
    schema: z$1.string().nullish(),
    template: z$1.string().nullish()
  });
}
function b() {
  return z$1.object({
    __typename: z$1.literal("OperationError").optional(),
    code: z$1.string().nullish(),
    description: z$1.string().nullish(),
    id: z$1.string(),
    name: z$1.string().nullish(),
    template: z$1.string().nullish()
  });
}
function I() {
  return z$1.object({
    moduleId: z$1.string(),
    order: z$1.array(z$1.string())
  });
}
function j() {
  return z$1.object({
    order: z$1.array(z$1.string())
  });
}
function O() {
  return z$1.object({
    operationId: z$1.string(),
    order: z$1.array(z$1.string())
  });
}
function y() {
  return z$1.object({
    operationId: z$1.string(),
    order: z$1.array(z$1.string())
  });
}
function E() {
  return z$1.object({
    order: z$1.array(z$1.string())
  });
}
function x() {
  return z$1.object({
    authorName: z$1.string()
  });
}
function M() {
  return z$1.object({
    authorWebsite: z$1.string()
  });
}
function _() {
  return z$1.object({
    description: z$1.string()
  });
}
function D() {
  return z$1.object({
    extension: z$1.string()
  });
}
function N() {
  return z$1.object({
    id: z$1.string()
  });
}
function A() {
  return z$1.object({
    name: z$1.string()
  });
}
function R() {
  return z$1.object({
    description: z$1.string().nullish(),
    id: z$1.string()
  });
}
function C() {
  return z$1.object({
    id: z$1.string(),
    name: z$1.string().nullish()
  });
}
function T() {
  return z$1.object({
    description: z$1.string().nullish(),
    id: z$1.string()
  });
}
function z() {
  return z$1.object({
    errorCode: z$1.string().nullish(),
    id: z$1.string()
  });
}
function v() {
  return z$1.object({
    errorDescription: z$1.string().nullish(),
    id: z$1.string()
  });
}
function w() {
  return z$1.object({
    errorName: z$1.string().nullish(),
    id: z$1.string()
  });
}
function U() {
  return z$1.object({
    errorTemplate: z$1.string().nullish(),
    id: z$1.string()
  });
}
function W() {
  return z$1.object({
    id: z$1.string(),
    name: z$1.string().nullish()
  });
}
function B() {
  return z$1.object({
    id: z$1.string(),
    reducer: z$1.string().nullish()
  });
}
function P() {
  return z$1.object({
    id: z$1.string(),
    schema: z$1.string().nullish()
  });
}
function k() {
  return z$1.object({
    id: z$1.string(),
    template: z$1.string().nullish()
  });
}
function q() {
  return z$1.object({
    schema: z$1.string()
  });
}
function F() {
  return z$1.object({
    __typename: z$1.literal("State").optional(),
    examples: z$1.array(n()),
    schema: z$1.string()
  });
}
function G() {
  return z$1.object({
    example: z$1.string(),
    id: z$1.string()
  });
}
function H() {
  return z$1.object({
    id: z$1.string(),
    newExample: z$1.string()
  });
}
const V = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  AddModuleInputSchema: i,
  AddOperationErrorInputSchema: o,
  AddOperationExampleInputSchema: u,
  AddOperationInputSchema: a,
  AddStateExampleInputSchema: c,
  AuthorSchema: s,
  CodeExampleSchema: n,
  DeleteModuleInputSchema: l,
  DeleteOperationErrorInputSchema: p,
  DeleteOperationExampleInputSchema: m,
  DeleteOperationInputSchema: d,
  DeleteStateExampleInputSchema: h,
  DocumentModelInputSchema: K,
  DocumentModelStateSchema: L,
  ModuleSchema: g,
  MoveOperationInputSchema: S,
  OperationErrorSchema: b,
  OperationSchema: f,
  ReorderModuleOperationsInputSchema: I,
  ReorderModulesInputSchema: j,
  ReorderOperationErrorsInputSchema: O,
  ReorderOperationExamplesInputSchema: y,
  ReorderStateExamplesInputSchema: E,
  SetAuthorNameInputSchema: x,
  SetAuthorWebsiteInputSchema: M,
  SetModelDescriptionInputSchema: _,
  SetModelExtensionInputSchema: D,
  SetModelIdInputSchema: N,
  SetModelNameInputSchema: A,
  SetModuleDescriptionInputSchema: R,
  SetModuleNameInputSchema: C,
  SetOperationDescriptionInputSchema: T,
  SetOperationErrorCodeInputSchema: z,
  SetOperationErrorDescriptionInputSchema: v,
  SetOperationErrorNameInputSchema: w,
  SetOperationErrorTemplateInputSchema: U,
  SetOperationNameInputSchema: W,
  SetOperationReducerInputSchema: B,
  SetOperationSchemaInputSchema: P,
  SetOperationTemplateInputSchema: k,
  SetStateSchemaInputSchema: q,
  StateSchema: F,
  UpdateOperationExampleInputSchema: G,
  UpdateStateExampleInputSchema: H,
  definedNonNullAnySchema: J,
  isDefinedNonNullAny: r
}, Symbol.toStringTag, { value: "Module" }));

const reducer$6 = {
  setModelNameOperation(state, action) {
    state.data.name = action.input.name;
  },
  setModelIdOperation(state, action) {
    state.data.id = action.input.id;
  },
  setModelExtensionOperation(state, action) {
    state.data.extension = action.input.extension;
  },
  setModelDescriptionOperation(state, action) {
    state.data.description = action.input.description;
  },
  setAuthorNameOperation(state, action) {
    state.data.author = state.data.author || { name: "", website: null };
    state.data.author.name = action.input.authorName;
  },
  setAuthorWebsiteOperation(state, action) {
    state.data.author = state.data.author || { name: "", website: null };
    state.data.author.website = action.input.authorWebsite;
  }
};

const moduleSorter = (order) => {
  const mapping = {};
  order.forEach((key, index) => mapping[key] = index);
  return (a, b) => (mapping[b.id] || 999999) - (mapping[a.id] || 999999);
};
const reducer$5 = {
  addModuleOperation(state, action) {
    state.data.modules.push({
      id: hashKey(),
      name: action.input.name,
      description: action.input.description || "",
      operations: []
    });
  },
  setModuleNameOperation(state, action) {
    for (let i = 0; i < state.data.modules.length; i++) {
      if (state.data.modules[i].id === action.input.id) {
        state.data.modules[i].name = action.input.name || "";
      }
    }
  },
  setModuleDescriptionOperation(state, action) {
    for (let i = 0; i < state.data.modules.length; i++) {
      if (state.data.modules[i].id === action.input.id) {
        state.data.modules[i].description = action.input.description || "";
      }
    }
  },
  deleteModuleOperation(state, action) {
    state.data.modules = state.data.modules.filter((m) => m.id != action.input.id);
  },
  reorderModulesOperation(state, action) {
    state.data.modules.sort(moduleSorter(action.input.order));
  }
};

const errorSorter = (order) => {
  const mapping = {};
  order.forEach((key, index) => mapping[key] = index);
  return (a, b) => (mapping[b.id] || 999999) - (mapping[a.id] || 999999);
};
const reducer$4 = {
  addOperationErrorOperation(state, action) {
    for (let i = 0; i < state.data.modules.length; i++) {
      for (let j = 0; j < state.data.modules[i].operations.length; j++) {
        if (state.data.modules[i].operations[j].id == action.input.operationId) {
          state.data.modules[i].operations[j].errors.push({
            id: hashKey(),
            name: action.input.errorName || "",
            code: action.input.errorCode || "",
            description: action.input.errorDescription || "",
            template: action.input.errorTemplate || ""
          });
        }
      }
    }
  },
  setOperationErrorCodeOperation(state, action) {
    for (let i = 0; i < state.data.modules.length; i++) {
      for (let j = 0; j < state.data.modules[i].operations.length; j++) {
        for (let k = 0; k < state.data.modules[i].operations[j].errors.length; k++) {
          if (state.data.modules[i].operations[j].errors[k].id == action.input.id) {
            state.data.modules[i].operations[j].errors[k].code = action.input.errorCode || "";
          }
        }
      }
    }
  },
  setOperationErrorNameOperation(state, action) {
    for (let i = 0; i < state.data.modules.length; i++) {
      for (let j = 0; j < state.data.modules[i].operations.length; j++) {
        for (let k = 0; k < state.data.modules[i].operations[j].errors.length; k++) {
          if (state.data.modules[i].operations[j].errors[k].id == action.input.id) {
            state.data.modules[i].operations[j].errors[k].name = action.input.errorName || "";
          }
        }
      }
    }
  },
  setOperationErrorDescriptionOperation(state, action) {
    for (let i = 0; i < state.data.modules.length; i++) {
      for (let j = 0; j < state.data.modules[i].operations.length; j++) {
        for (let k = 0; k < state.data.modules[i].operations[j].errors.length; k++) {
          if (state.data.modules[i].operations[j].errors[k].id == action.input.id) {
            state.data.modules[i].operations[j].errors[k].description = action.input.errorDescription || "";
          }
        }
      }
    }
  },
  setOperationErrorTemplateOperation(state, action) {
    for (let i = 0; i < state.data.modules.length; i++) {
      for (let j = 0; j < state.data.modules[i].operations.length; j++) {
        for (let k = 0; k < state.data.modules[i].operations[j].errors.length; k++) {
          if (state.data.modules[i].operations[j].errors[k].id == action.input.id) {
            state.data.modules[i].operations[j].errors[k].template = action.input.errorTemplate || "";
          }
        }
      }
    }
  },
  deleteOperationErrorOperation(state, action) {
    for (let i = 0; i < state.data.modules.length; i++) {
      for (let j = 0; j < state.data.modules[i].operations.length; j++) {
        state.data.modules[i].operations[j].errors = state.data.modules[i].operations[j].errors.filter((e) => e.id != action.input.id);
      }
    }
  },
  reorderOperationErrorsOperation(state, action) {
    for (let i = 0; i < state.data.modules.length; i++) {
      for (let j = 0; j < state.data.modules[i].operations.length; j++) {
        if (state.data.modules[i].operations[j].id == action.input.operationId) {
          state.data.modules[i].operations[j].errors.sort(errorSorter(action.input.order));
        }
      }
    }
  }
};

const exampleSorter$1 = (order) => {
  const mapping = {};
  order.forEach((key, index) => mapping[key] = index);
  return (a, b) => (mapping[b.id] || 999999) - (mapping[a.id] || 999999);
};
const reducer$3 = {
  addOperationExampleOperation(state, action) {
    for (let i = 0; i < state.data.modules.length; i++) {
      for (let j = 0; j < state.data.modules[i].operations.length; j++) {
        if (state.data.modules[i].operations[j].id == action.input.operationId) {
          state.data.modules[i].operations[j].examples.push({
            id: hashKey(),
            value: action.input.example
          });
        }
      }
    }
  },
  updateOperationExampleOperation(state, action) {
    for (let i = 0; i < state.data.modules.length; i++) {
      for (let j = 0; j < state.data.modules[i].operations.length; j++) {
        for (let k = 0; k < state.data.modules[i].operations[j].examples.length; k++) {
          if (state.data.modules[i].operations[j].examples[k].id == action.input.id) {
            state.data.modules[i].operations[j].examples[k].value = action.input.example;
          }
        }
      }
    }
  },
  deleteOperationExampleOperation(state, action) {
    for (let i = 0; i < state.data.modules.length; i++) {
      for (let j = 0; j < state.data.modules[i].operations.length; j++) {
        state.data.modules[i].operations[j].examples = state.data.modules[i].operations[j].examples.filter((e) => e.id != action.input.id);
      }
    }
  },
  reorderOperationExamplesOperation(state, action) {
    for (let i = 0; i < state.data.modules.length; i++) {
      for (let j = 0; j < state.data.modules[i].operations.length; j++) {
        if (state.data.modules[i].operations[j].id == action.input.operationId) {
          state.data.modules[i].operations[j].examples.sort(exampleSorter$1(action.input.order));
        }
      }
    }
  }
};

const operationSorter = (order) => {
  const mapping = {};
  order.forEach((key, index) => mapping[key] = index);
  return (a, b) => (mapping[b.id] || 999999) - (mapping[a.id] || 999999);
};
const reducer$2 = {
  addOperationOperation(state, action) {
    for (let i = 0; i < state.data.modules.length; i++) {
      if (state.data.modules[i].id == action.input.moduleId) {
        state.data.modules[i].operations.push({
          id: hashKey(),
          name: action.input.name,
          description: action.input.description || "",
          schema: action.input.schema || "",
          template: action.input.template || action.input.description || "",
          reducer: action.input.reducer || "",
          errors: [],
          examples: []
        });
      }
    }
  },
  setOperationNameOperation(state, action) {
    for (let i = 0; i < state.data.modules.length; i++) {
      for (let j = 0; j < state.data.modules[i].operations.length; j++) {
        if (state.data.modules[i].operations[j].id == action.input.id) {
          state.data.modules[i].operations[j].name = action.input.name || "";
        }
      }
    }
  },
  setOperationSchemaOperation(state, action) {
    for (let i = 0; i < state.data.modules.length; i++) {
      for (let j = 0; j < state.data.modules[i].operations.length; j++) {
        if (state.data.modules[i].operations[j].id == action.input.id) {
          state.data.modules[i].operations[j].schema = action.input.schema || "";
        }
      }
    }
  },
  setOperationDescriptionOperation(state, action) {
    for (let i = 0; i < state.data.modules.length; i++) {
      for (let j = 0; j < state.data.modules[i].operations.length; j++) {
        if (state.data.modules[i].operations[j].id == action.input.id) {
          state.data.modules[i].operations[j].description = action.input.description || "";
        }
      }
    }
  },
  setOperationTemplateOperation(state, action) {
    for (let i = 0; i < state.data.modules.length; i++) {
      for (let j = 0; j < state.data.modules[i].operations.length; j++) {
        if (state.data.modules[i].operations[j].id == action.input.id) {
          state.data.modules[i].operations[j].template = action.input.template || "";
        }
      }
    }
  },
  setOperationReducerOperation(state, action) {
    for (let i = 0; i < state.data.modules.length; i++) {
      for (let j = 0; j < state.data.modules[i].operations.length; j++) {
        if (state.data.modules[i].operations[j].id == action.input.id) {
          state.data.modules[i].operations[j].reducer = action.input.reducer || "";
        }
      }
    }
  },
  moveOperationOperation(state, action) {
    const moveOperations = [];
    for (let i = 0; i < state.data.modules.length; i++) {
      state.data.modules[i].operations = state.data.modules[i].operations.filter((operation) => {
        if (operation.id == action.input.operationId) {
          moveOperations.push(operation);
          return false;
        }
        return true;
      });
    }
    for (let i = 0; i < state.data.modules.length; i++) {
      if (state.data.modules[i].id == action.input.newModuleId) {
        state.data.modules[i].operations.push(...moveOperations);
      }
    }
  },
  deleteOperationOperation(state, action) {
    for (let i = 0; i < state.data.modules.length; i++) {
      state.data.modules[i].operations = state.data.modules[i].operations.filter((operation) => operation.id != action.input.id);
    }
  },
  reorderModuleOperationsOperation(state, action) {
    for (let i = 0; i < state.data.modules.length; i++) {
      if (state.data.modules[i].id == action.input.moduleId) {
        state.data.modules[i].operations.sort(operationSorter(action.input.order));
      }
    }
  }
};

const exampleSorter = (order) => {
  const mapping = {};
  order.forEach((key, index) => mapping[key] = index);
  return (a, b) => (mapping[b.id] || 999999) - (mapping[a.id] || 999999);
};
const reducer$1 = {
  setStateSchemaOperation(state, action) {
    state.data.state.schema = action.input.schema;
  },
  addStateExampleOperation(state, action) {
    state.data.state.examples.push({
      id: hashKey(),
      value: action.input.example
    });
  },
  updateStateExampleOperation(state, action) {
    for (let i = 0; i < state.data.state.examples.length; i++) {
      if (state.data.state.examples[i].id == action.input.id) {
        state.data.state.examples[i].value = action.input.newExample;
      }
    }
  },
  deleteStateExampleOperation(state, action) {
    state.data.state.examples = state.data.state.examples.filter((e) => e.id != action.input.id);
  },
  reorderStateExamplesOperation(state, action) {
    state.data.state.examples.sort(exampleSorter(action.input.order));
  }
};

const stateReducer = (state, action) => {
  if (isBaseAction(action)) {
    return state;
  }
  switch (action.type) {
    case "SET_MODEL_NAME":
      V.SetModelNameInputSchema().parse(action.input);
      reducer$6.setModelNameOperation(state, action);
      break;
    case "SET_MODEL_ID":
      V.SetModelIdInputSchema().parse(action.input);
      reducer$6.setModelIdOperation(state, action);
      break;
    case "SET_MODEL_EXTENSION":
      V.SetModelExtensionInputSchema().parse(action.input);
      reducer$6.setModelExtensionOperation(state, action);
      break;
    case "SET_MODEL_DESCRIPTION":
      V.SetModelDescriptionInputSchema().parse(action.input);
      reducer$6.setModelDescriptionOperation(state, action);
      break;
    case "SET_AUTHOR_NAME":
      V.SetAuthorNameInputSchema().parse(action.input);
      reducer$6.setAuthorNameOperation(state, action);
      break;
    case "SET_AUTHOR_WEBSITE":
      V.SetAuthorWebsiteInputSchema().parse(action.input);
      reducer$6.setAuthorWebsiteOperation(state, action);
      break;
    case "ADD_MODULE":
      V.AddModuleInputSchema().parse(action.input);
      reducer$5.addModuleOperation(state, action);
      break;
    case "SET_MODULE_NAME":
      V.SetModuleNameInputSchema().parse(action.input);
      reducer$5.setModuleNameOperation(state, action);
      break;
    case "SET_MODULE_DESCRIPTION":
      V.SetModuleDescriptionInputSchema().parse(action.input);
      reducer$5.setModuleDescriptionOperation(state, action);
      break;
    case "DELETE_MODULE":
      V.DeleteModuleInputSchema().parse(action.input);
      reducer$5.deleteModuleOperation(state, action);
      break;
    case "REORDER_MODULES":
      V.ReorderModulesInputSchema().parse(action.input);
      reducer$5.reorderModulesOperation(state, action);
      break;
    case "ADD_OPERATION_ERROR":
      V.AddOperationErrorInputSchema().parse(action.input);
      reducer$4.addOperationErrorOperation(state, action);
      break;
    case "SET_OPERATION_ERROR_CODE":
      V.SetOperationErrorCodeInputSchema().parse(action.input);
      reducer$4.setOperationErrorCodeOperation(state, action);
      break;
    case "SET_OPERATION_ERROR_NAME":
      V.SetOperationErrorNameInputSchema().parse(action.input);
      reducer$4.setOperationErrorNameOperation(state, action);
      break;
    case "SET_OPERATION_ERROR_DESCRIPTION":
      V.SetOperationErrorDescriptionInputSchema().parse(action.input);
      reducer$4.setOperationErrorDescriptionOperation(state, action);
      break;
    case "SET_OPERATION_ERROR_TEMPLATE":
      V.SetOperationErrorTemplateInputSchema().parse(action.input);
      reducer$4.setOperationErrorTemplateOperation(state, action);
      break;
    case "DELETE_OPERATION_ERROR":
      V.DeleteOperationErrorInputSchema().parse(action.input);
      reducer$4.deleteOperationErrorOperation(state, action);
      break;
    case "REORDER_OPERATION_ERRORS":
      V.ReorderOperationErrorsInputSchema().parse(action.input);
      reducer$4.reorderOperationErrorsOperation(state, action);
      break;
    case "ADD_OPERATION_EXAMPLE":
      V.AddOperationExampleInputSchema().parse(action.input);
      reducer$3.addOperationExampleOperation(state, action);
      break;
    case "UPDATE_OPERATION_EXAMPLE":
      V.UpdateOperationExampleInputSchema().parse(action.input);
      reducer$3.updateOperationExampleOperation(state, action);
      break;
    case "DELETE_OPERATION_EXAMPLE":
      V.DeleteOperationExampleInputSchema().parse(action.input);
      reducer$3.deleteOperationExampleOperation(state, action);
      break;
    case "REORDER_OPERATION_EXAMPLES":
      V.ReorderOperationExamplesInputSchema().parse(action.input);
      reducer$3.reorderOperationExamplesOperation(state, action);
      break;
    case "ADD_OPERATION":
      V.AddOperationInputSchema().parse(action.input);
      reducer$2.addOperationOperation(state, action);
      break;
    case "SET_OPERATION_NAME":
      V.SetOperationNameInputSchema().parse(action.input);
      reducer$2.setOperationNameOperation(state, action);
      break;
    case "SET_OPERATION_SCHEMA":
      V.SetOperationSchemaInputSchema().parse(action.input);
      reducer$2.setOperationSchemaOperation(state, action);
      break;
    case "SET_OPERATION_DESCRIPTION":
      V.SetOperationDescriptionInputSchema().parse(action.input);
      reducer$2.setOperationDescriptionOperation(state, action);
      break;
    case "SET_OPERATION_TEMPLATE":
      V.SetOperationTemplateInputSchema().parse(action.input);
      reducer$2.setOperationTemplateOperation(state, action);
      break;
    case "SET_OPERATION_REDUCER":
      V.SetOperationReducerInputSchema().parse(action.input);
      reducer$2.setOperationReducerOperation(state, action);
      break;
    case "MOVE_OPERATION":
      V.MoveOperationInputSchema().parse(action.input);
      reducer$2.moveOperationOperation(state, action);
      break;
    case "DELETE_OPERATION":
      V.DeleteOperationInputSchema().parse(action.input);
      reducer$2.deleteOperationOperation(state, action);
      break;
    case "REORDER_MODULE_OPERATIONS":
      V.ReorderModuleOperationsInputSchema().parse(action.input);
      reducer$2.reorderModuleOperationsOperation(state, action);
      break;
    case "SET_STATE_SCHEMA":
      V.SetStateSchemaInputSchema().parse(action.input);
      reducer$1.setStateSchemaOperation(state, action);
      break;
    case "ADD_STATE_EXAMPLE":
      V.AddStateExampleInputSchema().parse(action.input);
      reducer$1.addStateExampleOperation(state, action);
      break;
    case "UPDATE_STATE_EXAMPLE":
      V.UpdateStateExampleInputSchema().parse(action.input);
      reducer$1.updateStateExampleOperation(state, action);
      break;
    case "DELETE_STATE_EXAMPLE":
      V.DeleteStateExampleInputSchema().parse(action.input);
      reducer$1.deleteStateExampleOperation(state, action);
      break;
    case "REORDER_STATE_EXAMPLES":
      V.ReorderStateExamplesInputSchema().parse(action.input);
      reducer$1.reorderStateExamplesOperation(state, action);
      break;
    default:
      return state;
  }
};
const reducer = createReducer(stateReducer);

const setModelName = (input) => createAction(
  "SET_MODEL_NAME",
  { ...input }
);
const setModelId = (input) => createAction(
  "SET_MODEL_ID",
  { ...input }
);
const setModelExtension = (input) => createAction(
  "SET_MODEL_EXTENSION",
  { ...input }
);
const setModelDescription = (input) => createAction(
  "SET_MODEL_DESCRIPTION",
  { ...input }
);
const setAuthorName = (input) => createAction(
  "SET_AUTHOR_NAME",
  { ...input }
);
const setAuthorWebsite = (input) => createAction(
  "SET_AUTHOR_WEBSITE",
  { ...input }
);

class DocumentModel_Header extends BaseDocument {
  setModelName(input) {
    return this.dispatch(setModelName(input));
  }
  setModelId(input) {
    return this.dispatch(setModelId(input));
  }
  setModelExtension(input) {
    return this.dispatch(setModelExtension(input));
  }
  setModelDescription(input) {
    return this.dispatch(setModelDescription(input));
  }
  setAuthorName(input) {
    return this.dispatch(setAuthorName(input));
  }
  setAuthorWebsite(input) {
    return this.dispatch(setAuthorWebsite(input));
  }
}

const addModule = (input) => createAction(
  "ADD_MODULE",
  { ...input }
);
const setModuleName = (input) => createAction(
  "SET_MODULE_NAME",
  { ...input }
);
const setModuleDescription = (input) => createAction(
  "SET_MODULE_DESCRIPTION",
  { ...input }
);
const deleteModule = (input) => createAction(
  "DELETE_MODULE",
  { ...input }
);
const reorderModules = (input) => createAction(
  "REORDER_MODULES",
  { ...input }
);

class DocumentModel_Module extends BaseDocument {
  addModule(input) {
    return this.dispatch(addModule(input));
  }
  setModuleName(input) {
    return this.dispatch(setModuleName(input));
  }
  setModuleDescription(input) {
    return this.dispatch(setModuleDescription(input));
  }
  deleteModule(input) {
    return this.dispatch(deleteModule(input));
  }
  reorderModules(input) {
    return this.dispatch(reorderModules(input));
  }
}

const addOperationError = (input) => createAction(
  "ADD_OPERATION_ERROR",
  { ...input }
);
const setOperationErrorCode = (input) => createAction(
  "SET_OPERATION_ERROR_CODE",
  { ...input }
);
const setOperationErrorName = (input) => createAction(
  "SET_OPERATION_ERROR_NAME",
  { ...input }
);
const setOperationErrorDescription = (input) => createAction(
  "SET_OPERATION_ERROR_DESCRIPTION",
  { ...input }
);
const setOperationErrorTemplate = (input) => createAction(
  "SET_OPERATION_ERROR_TEMPLATE",
  { ...input }
);
const deleteOperationError = (input) => createAction(
  "DELETE_OPERATION_ERROR",
  { ...input }
);
const reorderOperationErrors = (input) => createAction(
  "REORDER_OPERATION_ERRORS",
  { ...input }
);

class DocumentModel_OperationError extends BaseDocument {
  addOperationError(input) {
    return this.dispatch(addOperationError(input));
  }
  setOperationErrorCode(input) {
    return this.dispatch(setOperationErrorCode(input));
  }
  setOperationErrorName(input) {
    return this.dispatch(setOperationErrorName(input));
  }
  setOperationErrorDescription(input) {
    return this.dispatch(setOperationErrorDescription(input));
  }
  setOperationErrorTemplate(input) {
    return this.dispatch(setOperationErrorTemplate(input));
  }
  deleteOperationError(input) {
    return this.dispatch(deleteOperationError(input));
  }
  reorderOperationErrors(input) {
    return this.dispatch(reorderOperationErrors(input));
  }
}

const addOperationExample = (input) => createAction(
  "ADD_OPERATION_EXAMPLE",
  { ...input }
);
const updateOperationExample = (input) => createAction(
  "UPDATE_OPERATION_EXAMPLE",
  { ...input }
);
const deleteOperationExample = (input) => createAction(
  "DELETE_OPERATION_EXAMPLE",
  { ...input }
);
const reorderOperationExamples = (input) => createAction(
  "REORDER_OPERATION_EXAMPLES",
  { ...input }
);

class DocumentModel_OperationExample extends BaseDocument {
  addOperationExample(input) {
    return this.dispatch(addOperationExample(input));
  }
  updateOperationExample(input) {
    return this.dispatch(updateOperationExample(input));
  }
  deleteOperationExample(input) {
    return this.dispatch(deleteOperationExample(input));
  }
  reorderOperationExamples(input) {
    return this.dispatch(reorderOperationExamples(input));
  }
}

const addOperation = (input) => createAction(
  "ADD_OPERATION",
  { ...input }
);
const setOperationName = (input) => createAction(
  "SET_OPERATION_NAME",
  { ...input }
);
const setOperationSchema = (input) => createAction(
  "SET_OPERATION_SCHEMA",
  { ...input }
);
const setOperationDescription = (input) => createAction(
  "SET_OPERATION_DESCRIPTION",
  { ...input }
);
const setOperationTemplate = (input) => createAction(
  "SET_OPERATION_TEMPLATE",
  { ...input }
);
const setOperationReducer = (input) => createAction(
  "SET_OPERATION_REDUCER",
  { ...input }
);
const moveOperation = (input) => createAction(
  "MOVE_OPERATION",
  { ...input }
);
const deleteOperation = (input) => createAction(
  "DELETE_OPERATION",
  { ...input }
);
const reorderModuleOperations = (input) => createAction(
  "REORDER_MODULE_OPERATIONS",
  { ...input }
);

class DocumentModel_Operation extends BaseDocument {
  addOperation(input) {
    return this.dispatch(addOperation(input));
  }
  setOperationName(input) {
    return this.dispatch(setOperationName(input));
  }
  setOperationSchema(input) {
    return this.dispatch(setOperationSchema(input));
  }
  setOperationDescription(input) {
    return this.dispatch(setOperationDescription(input));
  }
  setOperationTemplate(input) {
    return this.dispatch(setOperationTemplate(input));
  }
  setOperationReducer(input) {
    return this.dispatch(setOperationReducer(input));
  }
  moveOperation(input) {
    return this.dispatch(moveOperation(input));
  }
  deleteOperation(input) {
    return this.dispatch(deleteOperation(input));
  }
  reorderModuleOperations(input) {
    return this.dispatch(reorderModuleOperations(input));
  }
}

const setStateSchema = (input) => createAction(
  "SET_STATE_SCHEMA",
  { ...input }
);
const addStateExample = (input) => createAction(
  "ADD_STATE_EXAMPLE",
  { ...input }
);
const updateStateExample = (input) => createAction(
  "UPDATE_STATE_EXAMPLE",
  { ...input }
);
const deleteStateExample = (input) => createAction(
  "DELETE_STATE_EXAMPLE",
  { ...input }
);
const reorderStateExamples = (input) => createAction(
  "REORDER_STATE_EXAMPLES",
  { ...input }
);

class DocumentModel_State extends BaseDocument {
  setStateSchema(input) {
    return this.dispatch(setStateSchema(input));
  }
  addStateExample(input) {
    return this.dispatch(addStateExample(input));
  }
  updateStateExample(input) {
    return this.dispatch(updateStateExample(input));
  }
  deleteStateExample(input) {
    return this.dispatch(deleteStateExample(input));
  }
  reorderStateExamples(input) {
    return this.dispatch(reorderStateExamples(input));
  }
}

let DocumentModel$2 = class DocumentModel extends BaseDocument {
  static fileExtension = "phdm";
  get state() {
    return this._state.data;
  }
  constructor(initialState) {
    super(reducer, initialState || createEmptyExtendedDocumentModelState());
  }
  saveToFile(path, name) {
    return super.saveToFile(path, DocumentModel.fileExtension, name);
  }
  loadFromFile(path) {
    return super.loadFromFile(path);
  }
  static async fromFile(path) {
    const document = new this();
    await document.loadFromFile(path);
    return document;
  }
};
applyMixins(DocumentModel$2, [
  DocumentModel_Header,
  DocumentModel_Module,
  DocumentModel_OperationError,
  DocumentModel_OperationExample,
  DocumentModel_Operation,
  DocumentModel_State
]);

var gen = /*#__PURE__*/Object.freeze({
    __proto__: null,
    DocumentModel: DocumentModel$2,
    addModule: addModule,
    addOperation: addOperation,
    addOperationError: addOperationError,
    addOperationExample: addOperationExample,
    addStateExample: addStateExample,
    deleteModule: deleteModule,
    deleteOperation: deleteOperation,
    deleteOperationError: deleteOperationError,
    deleteOperationExample: deleteOperationExample,
    deleteStateExample: deleteStateExample,
    moveOperation: moveOperation,
    reorderModuleOperations: reorderModuleOperations,
    reorderModules: reorderModules,
    reorderOperationErrors: reorderOperationErrors,
    reorderOperationExamples: reorderOperationExamples,
    reorderStateExamples: reorderStateExamples,
    setAuthorName: setAuthorName,
    setAuthorWebsite: setAuthorWebsite,
    setModelDescription: setModelDescription,
    setModelExtension: setModelExtension,
    setModelId: setModelId,
    setModelName: setModelName,
    setModuleDescription: setModuleDescription,
    setModuleName: setModuleName,
    setOperationDescription: setOperationDescription,
    setOperationErrorCode: setOperationErrorCode,
    setOperationErrorDescription: setOperationErrorDescription,
    setOperationErrorName: setOperationErrorName,
    setOperationErrorTemplate: setOperationErrorTemplate,
    setOperationName: setOperationName,
    setOperationReducer: setOperationReducer,
    setOperationSchema: setOperationSchema,
    setOperationTemplate: setOperationTemplate,
    setStateSchema: setStateSchema,
    updateOperationExample: updateOperationExample,
    updateStateExample: updateStateExample
});

const { DocumentModel, ...DocumentModelActions } = gen;
const actions = { ...BaseActions, ...DocumentModelActions };

var DocumentModel$1 = /*#__PURE__*/Object.freeze({
    __proto__: null,
    DocumentModel: DocumentModel,
    actions: actions,
    createEmptyDocumentModelState: createEmptyDocumentModelState,
    createEmptyExtendedDocumentModelState: createEmptyExtendedDocumentModelState,
    reducer: reducer
});

export { DocumentModel$1 as D, actions as a, DocumentModel as b, createEmptyDocumentModelState as c, createEmptyExtendedDocumentModelState as d, reducer as r };
//# sourceMappingURL=index-e660d475.js.map
