/* eslint-disable @typescript-eslint/ban-ts-comment */
// @ts-nocheck

export function createHistoryStateStore() {
  let entries = [];
  let index = 0;
  let selectionIndex = 0;
  let nextId = 1;
  let lastSavedId = 1;

  return {
    get entries() {
      return entries;
    },
    set entries(value) {
      entries = Array.isArray(value) ? value : [];
    },
    get index() {
      return index;
    },
    set index(value) {
      index = Number(value) || 0;
    },
    get selectionIndex() {
      return selectionIndex;
    },
    set selectionIndex(value) {
      selectionIndex = Number(value) || 0;
    },
    get nextId() {
      return nextId;
    },
    set nextId(value) {
      nextId = Math.max(1, Number(value) || 1);
    },
    get lastSavedId() {
      return lastSavedId;
    },
    set lastSavedId(value) {
      lastSavedId = Math.max(1, Number(value) || 1);
    },
  };
}
