"use strict";

exports.__esModule = true;
exports.selectionLayerUpdate = exports.selectionLayerClear = exports["default"] = void 0;
var _reduxAct = require("redux-act");
var _createMetaAction = _interopRequireDefault(require("./utils/createMetaAction"));
var _createReducer;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// ------------------------------------
// Actions
// ------------------------------------
var selectionLayerClear = (0, _createMetaAction["default"])("SELECTION_LAYER_CLEAR");
exports.selectionLayerClear = selectionLayerClear;
var selectionLayerUpdate = (0, _createMetaAction["default"])("SELECTION_LAYER_UPDATE");

// ------------------------------------
// Reducer
// ------------------------------------
exports.selectionLayerUpdate = selectionLayerUpdate;
var _default = (0, _reduxAct.createReducer)((_createReducer = {
  CARET_POSITION_UPDATE: function CARET_POSITION_UPDATE() {
    //clear the selection layer if the caret is updated!
    return {
      start: -1,
      end: -1
    };
  }
}, _createReducer[selectionLayerClear] = function () {
  return {
    start: -1,
    end: -1
  };
}, _createReducer[selectionLayerUpdate] = function (state, newSelectionLayer) {
  if (!newSelectionLayer || !(newSelectionLayer.start >= 0 && newSelectionLayer.end >= 0)) {
    console.error("we should never be here! selectionLayerUpdate must always be called with a valid selection layer");
    return state;
  }
  return newSelectionLayer;
}, _createReducer), {
  start: -1,
  end: -1
});
exports["default"] = _default;