"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const keyChain = require("./keyChain.cjs");
const touchedStateForKeyChain = (state, keyChain$1) => {
  return state.filter((s) => keyChain.isMyKeyChainItem(s, keyChain.keyStringFromKeyChain(keyChain$1, "dots")));
};
const touchedStateReducer = (state, action) => {
  switch (action.type) {
    case "set-touched":
      if (action.touched) {
        const key = keyChain.keyStringFromKeyChain(action.keyChain, "dots");
        if (state.includes(key)) {
          return state;
        }
        return [...state.filter((k) => k !== key), key];
      }
      {
        const toRemove = touchedStateForKeyChain(state, action.keyChain);
        if (!state.some((k) => toRemove.includes(k))) {
          return state;
        }
        return state.filter((k) => !toRemove.includes(k));
      }
    case "reset-touched":
      return [];
    default:
      return state;
  }
};
exports.touchedStateForKeyChain = touchedStateForKeyChain;
exports.touchedStateReducer = touchedStateReducer;
//# sourceMappingURL=touchedState.cjs.map
