function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import deepEqual from "deep-equal";
import { tidyUpSequenceData } from "@teselagen/sequence-utils";
import uuid from "shortid";
import createAction from "../utils/createMetaAction";
import features from "./features";
import parts from "./parts";
import name from "./name";
import description from "./description";
import primers from "./primers";
import sequence from "./sequence";
import circular from "./circular";
import materiallyAvailable from "./materiallyAvailable";
import translations from "./translations";
import combineReducersDontIgnoreKeys from "../../utils/combineReducersDontIgnoreKeys";
// import cleanSequenceData from "../../utils/cleanSequenceData";

import { createReducer } from "redux-act";
// export * from './sharedActionCreators';
export * from "./primers";
export * from "./features";
export * from "./parts";
export * from "./name";
export * from "./description";
// export * from './sequence';
export * from "./circular";
export * from "./materiallyAvailable";
export * from "./translations";

// ------------------------------------
// Actions
// ------------------------------------

var _updateSequenceData = createAction("SEQUENCE_DATA_UPDATE");
export var updateSequenceData = function updateSequenceData(seqData) {
  for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
    rest[_key - 1] = arguments[_key];
  }
  //tnrtodo: currently we're not using that type variable for anything
  return _updateSequenceData.apply(void 0, [tidyUpSequenceData(seqData, {
    annotationsAsObjects: true
  })].concat(rest));
};

// ------------------------------------
// Reducer
// ------------------------------------

var coreReducer = combineReducersDontIgnoreKeys({
  primers: primers,
  features: features,
  parts: parts,
  sequence: sequence,
  translations: translations,
  size: function size(state) {
    if (state === void 0) {
      state = {};
    }
    return state;
  },
  circular: circular,
  materiallyAvailable: materiallyAvailable,
  name: name,
  description: description,
  fromFileUpload: createReducer({}, false)
});
export default function (state, action) {
  var stateToPass = state;
  if (action.type === "SEQUENCE_DATA_UPDATE") {
    stateToPass = action.payload;
  }
  //tnr: do a clone deep here in order to make sure we are using a totally new object for undo/redo tracking
  // stateToPass = cloneDeep(stateToPass);

  var newState = coreReducer(stateToPass, action);
  if (deepEqual(newState, state)) {
    return state;
  } else {
    //tnr: do a clone deep here in order to make sure we are using a totally new object for undo/redo tracking
    // mm: we don't need this if we are not mutating the newState, which we shouldn't be doing.
    return _extends({}, newState, {
      stateTrackingId: newState.stateTrackingId ? uuid() : "initialLoadId"
    });
  }
}