

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _jsx = function () { var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7; return function createRawReactElement(type, props, key, children) { var defaultProps = type && type.defaultProps; var childrenLength = arguments.length - 3; if (!props && childrenLength !== 0) { props = {}; } if (props && defaultProps) { for (var propName in defaultProps) { if (props[propName] === void 0) { props[propName] = defaultProps[propName]; } } } else if (!props) { props = defaultProps || {}; } if (childrenLength === 1) { props.children = children; } else if (childrenLength > 1) { var childArray = Array(childrenLength); for (var i = 0; i < childrenLength; i++) { childArray[i] = arguments[i + 3]; } props.children = childArray; } return { $$typeof: REACT_ELEMENT_TYPE, type: type, key: key === undefined ? null : '' + key, ref: null, props: props, _owner: null }; }; }();

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _react = __webpack_require__(1);

var _react2 = _interopRequireDefault(_react);

var _reactRedux = __webpack_require__(43);

var _TextField = __webpack_require__(77);

var _TextField2 = _interopRequireDefault(_TextField);

var _IconButton = __webpack_require__(70);

var _IconButton2 = _interopRequireDefault(_IconButton);

var _FloatingActionButton = __webpack_require__(158);

var _FloatingActionButton2 = _interopRequireDefault(_FloatingActionButton);

var _save = __webpack_require__(480);

var _save2 = _interopRequireDefault(_save);

var _visibility = __webpack_require__(479);

var _visibility2 = _interopRequireDefault(_visibility);

var _dialpad = __webpack_require__(478);

var _dialpad2 = _interopRequireDefault(_dialpad);

var _Calculator = __webpack_require__(469);

var _Calculator2 = _interopRequireDefault(_Calculator);

var _logBook = __webpack_require__(456);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

// Own modules


/**
 * This component will render a list of input fields to create or edit
 * a logbook
 */
var _ref = _jsx(_dialpad2.default, {});

var _ref2 = _jsx(_dialpad2.default, {});

var LogBookItems = function (_React$Component) {
  _inherits(LogBookItems, _React$Component);

  function LogBookItems() {
    _classCallCheck(this, LogBookItems);

    return _possibleConstructorReturn(this, (LogBookItems.__proto__ || Object.getPrototypeOf(LogBookItems)).apply(this, arguments));
  }

  _createClass(LogBookItems, [{
    key: 'shouldComponentUpdate',
    value: function shouldComponentUpdate(nextProps) {
      if (nextProps.productsLines) {
        if (this.props.productsLines) {
          return JSON.stringify(this.props.productsLines) !== JSON.stringify(nextProps.productsLines);
        }
        return true;
      }
      return false;
    }
  }, {
    key: 'render',
    value: function render() {
      var _props = this.props,
          productsLines = _props.productsLines,
          changeProduct = _props.changeProduct,
          openCalculator = _props.openCalculator,
          logbook = _props.logbook,
          name = _props.name,
          unit = _props.unit,
          id = _props.id;


      var isDisabled = logbook.confirmAt || false;

      return _jsx('div', {
        className: 'row',
        style: { marginTop: '15px' }
      }, void 0, _jsx('div', {
        className: 'col-lg-12',
        style: { paddingLeft: 0, paddingRight: 0 }
      }, void 0, _jsx('div', {
        className: 'col-lg-12'
      }, void 0, _jsx('label', {}, void 0, name + ' (' + unit + ')')), _jsx('div', {
        style: { width: '100%', float: 'left' }
      }, void 0, _jsx('div', {
        className: 'col-lg-12 col-xs-6'
      }, void 0, _jsx(_TextField2.default, {
        floatingLabelText: 'Inventario',
        fullWidth: true,
        'data-id': id,
        type: 'number',
        pattern: '\\d*',
        onChange: function onChange(event) {
          return changeProduct({
            id: id,
            initialStock: parseFloat(event.target.value),
            stockStrOperation: productsLines && productsLines.stockStrOperation || ''
          });
        },
        value: productsLines && (productsLines.initialStock ? productsLines.initialStock : ''),
        errorText: productsLines ? productsLines.stockStrOperation : '',
        errorStyle: { color: '#8a8a8a' }
      }), _jsx(_IconButton2.default, {
        onClick: function onClick() {
          return openCalculator({ id: id, textFieldType: 'initialStock', strOperation: 'stockStrOperation' }, true);
        },
        style: { position: 'absolute', right: '10px', top: '20px' }
      }, void 0, _ref)), _jsx('div', {
        className: 'col-lg-12 col-xs-6'
      }, void 0, _jsx(_TextField2.default, {
        floatingLabelText: 'Mermas',
        fullWidth: true,
        style: { padding: 0 },
        'data-id': id,
        type: 'number',
        pattern: '\\d*',
        onChange: function onChange(event) {
          return changeProduct({
            id: id,
            loss: parseFloat(event.target.value),
            lossStrOperation: productsLines && productsLines.lossStrOperation || ''
          });
        },
        value: productsLines && (productsLines.loss ? productsLines.loss : ''),
        errorText: productsLines ? productsLines.lossStrOperation : '',
        errorStyle: { color: '#8a8a8a' }
      }), _jsx(_IconButton2.default, {
        onClick: function onClick() {
          return openCalculator({ id: id, textFieldType: 'loss', strOperation: 'lossStrOperation' }, true);
        },
        style: { position: 'absolute', right: '10px', top: '20px' }
      }, void 0, _ref2))), _jsx('small', {
        className: 'col-lg-12',
        style: { color: isDisabled ? '#b2b2b2' : '' }
      }, void 0, 'Total:', productsLines && (productsLines.initialStock ? productsLines.initialStock : 0) - (productsLines.loss ? productsLines.loss : 0))));
    }
  }]);

  return LogBookItems;
}(_react2.default.Component);

/**
 * This is general component
 */


var _ref3 = _jsx(_save2.default, {});

var _ref4 = _jsx(_visibility2.default, {});

var LogBookForm = function LogBookForm(props) {
  var productsLines = props.productsLines,
      changeRoute = props.changeRoute,
      isEditing = props.isEditing,
      logbookId = props.logbookId,
      textField = props.textField,
      objects = props.objects,
      actions = props.actions,
      open = props.open;


  var logbook = Object.values(objects.logbooks).find(function (lb) {
    return Number(logbookId) === lb.id;
  });

  var productList = Object.values(objects.products).filter(function (p) {
    return p.logbookKindId === logbook.logbookKindId;
  }).map(function (product) {
    return _jsx(LogBookItems, {
      changeProduct: actions.changeProduct,
      openCalculator: actions.openCalculator,
      productsLines: productsLines[product.id - 1],
      logbook: logbook,
      name: product.name,
      unit: product.unit().name,
      id: product.id
    }, 'product-' + product.id);
  });

  return _jsx('div', {}, void 0, _jsx('div', {}, void 0, _jsx(_Calculator2.default, {
    openCalculator: actions.openCalculator,
    setStrResult: actions.setStrResult,
    textField: textField,
    open: open
  }), productList), _jsx('div', {
    style: {
      position: 'fixed',
      bottom: 0,
      right: 0,
      marginBottom: '15px',
      marginRight: '15px',
      zIndex: 2
    }
  }, void 0, isEditing ? _jsx(_FloatingActionButton2.default, {
    style: { float: 'right' },
    onClick: function onClick() {
      return actions.createLogBook(logbookId, productsLines, true);
    }
  }, void 0, _ref3) : _jsx(_FloatingActionButton2.default, {
    style: { float: 'right' },
    onClick: function onClick() {
      return changeRoute('logbook_review/' + logbookId);
    }
  }, void 0, _ref4)));
};

exports.default = (0, _reactRedux.connect)(_logBook.selectForm)(LogBookForm);

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _jsx = function () { var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7; return function createRawReactElement(type, props, key, children) { var defaultProps = type && type.defaultProps; var childrenLength = arguments.length - 3; if (!props && childrenLength !== 0) { props = {}; } if (props && defaultProps) { for (var propName in defaultProps) { if (props[propName] === void 0) { props[propName] = defaultProps[propName]; } } } else if (!props) { props = defaultProps || {}; } if (childrenLength === 1) { props.children = children; } else if (childrenLength > 1) { var childArray = Array(childrenLength); for (var i = 0; i < childrenLength; i++) { childArray[i] = arguments[i + 3]; } props.children = childArray; } return { $$typeof: REACT_ELEMENT_TYPE, type: type, key: key === undefined ? null : '' + key, ref: null, props: props, _owner: null }; }; }();

var _react = __webpack_require__(1);

var _react2 = _interopRequireDefault(_react);

var _reactRedux = __webpack_require__(43);

var _reactRouterRedux = __webpack_require__(37);

var _materialUiTheme = __webpack_require__(307);

var _Card = __webpack_require__(137);

var _Card2 = _interopRequireDefault(_Card);

var _CardText = __webpack_require__(87);

var _CardText2 = _interopRequireDefault(_CardText);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var Home = function Home(props) {
  var changeRoute = props.changeRoute;


  return _jsx(_Card2.default, {}, void 0, _jsx(_CardText2.default, {}, void 0, _jsx(_materialUiTheme.EmailSignInForm, {
    next: function next() {
      return changeRoute('/');
    },
    inputProps: {
      password: { floatingLabelText: 'Contraseña' }
    }
  })));
};

function mapDispatchToProps(dispatch) {
  return {
    changeRoute: function changeRoute(url) {
      return dispatch((0, _reactRouterRedux.push)(url));
    },
    dispatch: dispatch
  };
}

exports.default = (0, _reactRedux.connect)(null, mapDispatchToProps)(Home);

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.xsrfHeaderName = undefined;
exports.default = get;
exports.absGet = absGet;
exports.post = post;
exports.postFormData = postFormData;
exports.normalPut = normalPut;
exports.del = del;
exports.objectToQueryString = objectToQueryString;

var _reduxAuth = __webpack_require__(157);

__webpack_require__(305);

var xsrfHeaderName = exports.xsrfHeaderName = 'xsrf-token';
// const sessionIdHeaderName = 'session-id';

function getOptions() {
  return {
    headers: {
      Accept: 'application/json',
      'Content-Type': 'application/json',
      'XSRF-TOKEN': localStorage.getItem(xsrfHeaderName)
    },
    credentials: 'same-origin'
  };
}

function get(path) {
  return (0, _reduxAuth.fetch)(getApiPath(path), getOptions())
  // .then(handleErrors)
  .then(function (response) {
    return processResponse(response);
  });
}

function absGet(path) {
  return (0, _reduxAuth.fetch)(path, getOptions())
  // .then(handleErrors)
  .then(function (response) {
    return processResponse(response);
  });
}

function post(path, body) {
  return (0, _reduxAuth.fetch)(getApiPath(path), Object.assign({}, getOptions(), {
    method: 'POST',
    body: JSON.stringify(body)
  })).then(function (response) {
    return processResponse(response);
  }).catch(function (response) {
    return processResponse(response);
  });
}

function postFormData(path, formData) {
  return (0, _reduxAuth.fetch)(getApiPath(path), Object.assign({}, {
    headers: {
      Accept: 'application/json',
      'XSRF-TOKEN': localStorage.getItem(xsrfHeaderName)
    },
    credentials: 'same-origin',
    method: 'POST',
    body: formData
  })).then(function (response) {
    return processResponse(response);
  }).catch(function (response) {
    return processResponse(response);
  });
}

function normalPut(path, body) {
  return (0, _reduxAuth.fetch)(getApiPath(path), Object.assign({}, getOptions(), {
    method: 'PUT',
    body: JSON.stringify(body)
  })).then(function (response) {
    return processResponse(response);
  });
}
function del(path) {
  return (0, _reduxAuth.fetch)(getApiPath(path), Object.assign({}, getOptions(), {
    method: 'DELETE'
  })).then(function (response) {
    return processResponse(response);
  });
}

function objectToQueryString(obj) {
  return Object.keys(obj).map(function (k) {
    return encodeURIComponent(k) + '=' + encodeURIComponent(obj[k]);
  }).join('&');
}

function getApiPath(path) {
  return '/api/v1/' + path;
}

function processResponse(response) {
  if (response.message && response.message === 'Failed to fetch') {
    return {
      status: 503,
      ok: false
    };
  }
  return response.json().then(function (data) {
    return {
      data: data,
      status: response.status,
      ok: response.ok
    };
  });
}

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _jsx = function () { var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7; return function createRawReactElement(type, props, key, children) { var defaultProps = type && type.defaultProps; var childrenLength = arguments.length - 3; if (!props && childrenLength !== 0) { props = {}; } if (props && defaultProps) { for (var propName in defaultProps) { if (props[propName] === void 0) { props[propName] = defaultProps[propName]; } } } else if (!props) { props = defaultProps || {}; } if (childrenLength === 1) { props.children = children; } else if (childrenLength > 1) { var childArray = Array(childrenLength); for (var i = 0; i < childrenLength; i++) { childArray[i] = arguments[i + 3]; } props.children = childArray; } return { $$typeof: REACT_ELEMENT_TYPE, type: type, key: key === undefined ? null : '' + key, ref: null, props: props, _owner: null }; }; }();

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _react = __webpack_require__(1);

var _react2 = _interopRequireDefault(_react);

var _Card = __webpack_require__(137);

var _Card2 = _interopRequireDefault(_Card);

var _CardTitle = __webpack_require__(112);

var _CardTitle2 = _interopRequireDefault(_CardTitle);

var _CardText = __webpack_require__(87);

var _CardText2 = _interopRequireDefault(_CardText);

var _reactRedux = __webpack_require__(43);

var _reactRouterRedux = __webpack_require__(37);

var _redux = __webpack_require__(88);

var _objects = __webpack_require__(199);

var _logBooks = __webpack_require__(159);

var logBookActions = _interopRequireWildcard(_logBooks);

var _LogBookFilter = __webpack_require__(473);

var _LogBookFilter2 = _interopRequireDefault(_LogBookFilter);

var _LogBookList = __webpack_require__(472);

var _LogBookList2 = _interopRequireDefault(_LogBookList);

var _LogBookButton = __webpack_require__(471);

var _LogBookButton2 = _interopRequireDefault(_LogBookButton);

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

// Own modules


var correctDateString = function correctDateString(dateString) {
  var date = new Date(dateString);
  return new Date(date.getTime() + date.getTimezoneOffset() * 60 * 1000);
};

var date = new Date();
date.setHours(0, 0, 0, 0);

var _ref = _jsx(_CardTitle2.default, {
  title: 'Inventarios'
});

var LogBooksManager = function (_React$Component) {
  _inherits(LogBooksManager, _React$Component);

  function LogBooksManager(props) {
    _classCallCheck(this, LogBooksManager);

    var _this = _possibleConstructorReturn(this, (LogBooksManager.__proto__ || Object.getPrototypeOf(LogBooksManager)).call(this, props));

    _this.isEableToAdd = _this.isEableToAdd.bind(_this);
    return _this;
  }

  _createClass(LogBooksManager, [{
    key: 'isEableToAdd',
    value: function isEableToAdd() {
      var objects = this.props.objects;

      // find if a logbooks has been added in an specific date with an specific branch
      // It can only be created just one logbook per day and by local

      var branchesIds = Object.values(objects.branches).map(function (br) {
        return br.id;
      });
      var logbookKinds = Object.values(objects.logbookKinds).map(function (lk) {
        return lk.id;
      });

      // Filter only by the date of today
      var filteredLogBooks = [].concat(_toConsumableArray(new Set(Object.values(objects.logbooks).filter(function (logbook) {
        return correctDateString(logbook.date) >= date;
      }).filter(function (logbook) {
        return branchesIds.find(function (id) {
          return id === logbook.branchId;
        });
      }))));

      // The gotten dates must be filter by the branchId (uniques) agains the branches array
      return !logbookKinds.every(function (lk) {
        return filteredLogBooks.find(function (lb) {
          return lb.logbookKindId === lk;
        });
      });
    }
  }, {
    key: 'render',
    value: function render() {
      var _props = this.props,
          changeRoute = _props.changeRoute,
          actions = _props.actions,
          objects = _props.objects,
          _props$objects = _props.objects,
          logbookKinds = _props$objects.logbookKinds,
          branches = _props$objects.branches,
          logbooks = _props$objects.logbooks,
          user = _props.user;


      var logbookArray = Object.values(logbooks).filter(function (logbook) {
        return correctDateString(logbook.date) >= date;
      });

      return _jsx('div', {}, void 0, _jsx(_Card2.default, {
        style: { marginBottom: '10px' }
      }, void 0, _ref, _jsx(_CardText2.default, {}, void 0, _jsx(_LogBookFilter2.default, {
        actions: actions,
        objects: objects,
        user: user
      }))), this.isEableToAdd() && _jsx(_Card2.default, {}, void 0, _jsx(_CardText2.default, {}, void 0, _jsx(_LogBookButton2.default, {
        actions: actions,
        branches: branches,
        logbookKinds: logbookKinds,
        logbooks: logbookArray,
        user: user
      }))), _jsx(_Card2.default, {}, void 0, _jsx(_CardText2.default, {}, void 0, _jsx(_LogBookList2.default, {
        actions: actions,
        objects: objects,
        changeRoute: changeRoute
      }))));
    }
  }]);

  return LogBooksManager;
}(_react2.default.Component);

function select(state) {
  return {
    objects: (0, _objects.reselectObjects)(state),
    user: (0, _objects.userSelector)(state)
  };
}

function mapDispatchToProps(dispatch) {
  return {
    actions: (0, _redux.bindActionCreators)(logBookActions, dispatch),
    changeRoute: function changeRoute(url) {
      return dispatch((0, _reactRouterRedux.push)(url));
    },
    dispatch: dispatch
  };
}

exports.default = (0, _reactRedux.connect)(select, mapDispatchToProps)(LogBooksManager);

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.userSelector = exports.reselectObjects = undefined;

var _index = __webpack_require__(451);

var Models = _interopRequireWildcard(_index);

var _reselect = __webpack_require__(136);

var _modelEnvironment = __webpack_require__(452);

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

var getUserState = function getUserState(state) {
  return state.get('auth').get('user');
};
var userSelector = (0, _reselect.createSelector)([getUserState], function (userState) {
  return userState.toJS();
});

var selectObjects = function selectObjects(state) {
  return state.get('objects').get('objects');
};
var reselectObjects = (0, _reselect.createSelector)([selectObjects], function (objectsState) {
  return new _modelEnvironment.Environment({ objects: objectsState.toJS() }, Models).parseDB().objects;
});
exports.reselectObjects = reselectObjects;
exports.userSelector = userSelector;

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _jsx = function () { var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7; return function createRawReactElement(type, props, key, children) { var defaultProps = type && type.defaultProps; var childrenLength = arguments.length - 3; if (!props && childrenLength !== 0) { props = {}; } if (props && defaultProps) { for (var propName in defaultProps) { if (props[propName] === void 0) { props[propName] = defaultProps[propName]; } } } else if (!props) { props = defaultProps || {}; } if (childrenLength === 1) { props.children = children; } else if (childrenLength > 1) { var childArray = Array(childrenLength); for (var i = 0; i < childrenLength; i++) { childArray[i] = arguments[i + 3]; } props.children = childArray; } return { $$typeof: REACT_ELEMENT_TYPE, type: type, key: key === undefined ? null : '' + key, ref: null, props: props, _owner: null }; }; }();

// own modules


var _react = __webpack_require__(1);

var _react2 = _interopRequireDefault(_react);

var _reactRedux = __webpack_require__(43);

var _DatePicker = __webpack_require__(204);

var _DatePicker2 = _interopRequireDefault(_DatePicker);

var _SelectField = __webpack_require__(203);

var _SelectField2 = _interopRequireDefault(_SelectField);

var _MenuItem = __webpack_require__(113);

var _MenuItem2 = _interopRequireDefault(_MenuItem);

var _logBooks = __webpack_require__(201);

var _UserHelper = __webpack_require__(304);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/**
 * This component will render the fields to filter the list of data
 * 
 * @param {object} props some props needed
 */
var _ref = _jsx(_MenuItem2.default, {
  value: null,
  primaryText: ''
}, 'itembranch-0');

var LogBookFilter = function LogBookFilter(props) {
  var actions = props.actions,
      filters = props.filters,
      objects = props.objects,
      user = props.user;


  var menuBranchItems = [_ref].concat(Object.values(objects.branches).map(function (branch) {
    return _jsx(_MenuItem2.default, {
      value: branch.id,
      primaryText: branch.name
    }, 'itempbranch-' + branch.id);
  }));

  return _jsx('div', {
    className: 'row'
  }, void 0, _jsx('div', {
    className: 'col-lg-4 col-md-6 col-sm-6'
  }, void 0, _jsx(_DatePicker2.default, {
    hintText: 'Desde',
    fullWidth: true,
    onChange: function onChange(event, date) {
      return actions.changeFilters({ filterByDateFrom: date });
    },
    value: filters.filterByDateFrom
  })), _jsx('div', {
    className: 'col-lg-4 col-md-6 col-sm-6'
  }, void 0, _jsx(_DatePicker2.default, {
    hintText: 'Hasta',
    fullWidth: true,
    onChange: function onChange(event, date) {
      return actions.changeFilters({ filterByDateTo: date });
    },
    value: filters.filterByDateTo
  })), _jsx('div', {
    className: 'col-lg-4 col-md-6 col-sm-6'
  }, void 0, (0, _UserHelper.isAdmin)(user) && _jsx(_SelectField2.default, {
    floatingLabelText: 'Filtrar por local',
    fullWidth: true,
    value: filters.filterByBranch,
    onChange: function onChange(event, index, value) {
      return actions.changeFilters({ filterByBranch: value });
    }
  }, void 0, menuBranchItems)));
};

exports.default = (0, _reactRedux.connect)(_logBooks.filterSelector)(LogBookFilter);

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _jsx = function () { var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7; return function createRawReactElement(type, props, key, children) { var defaultProps = type && type.defaultProps; var childrenLength = arguments.length - 3; if (!props && childrenLength !== 0) { props = {}; } if (props && defaultProps) { for (var propName in defaultProps) { if (props[propName] === void 0) { props[propName] = defaultProps[propName]; } } } else if (!props) { props = defaultProps || {}; } if (childrenLength === 1) { props.children = children; } else if (childrenLength > 1) { var childArray = Array(childrenLength); for (var i = 0; i < childrenLength; i++) { childArray[i] = arguments[i + 3]; } props.children = childArray; } return { $$typeof: REACT_ELEMENT_TYPE, type: type, key: key === undefined ? null : '' + key, ref: null, props: props, _owner: null }; }; }();

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _react = __webpack_require__(1);

var _react2 = _interopRequireDefault(_react);

var _reactRedux = __webpack_require__(43);

var _List = __webpack_require__(162);

var _List2 = _interopRequireDefault(_List);

var _ListItem = __webpack_require__(139);

var _ListItem2 = _interopRequireDefault(_ListItem);

var _RaisedButton = __webpack_require__(163);

var _RaisedButton2 = _interopRequireDefault(_RaisedButton);

var _logBooks = __webpack_require__(201);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

// own modules


var correctDateString = function correctDateString(dateString) {
  var date = new Date(dateString);
  return new Date(date.getTime() + date.getTimezoneOffset() * 60 * 1000);
};

var LogBookListItem = function (_React$PureComponent) {
  _inherits(LogBookListItem, _React$PureComponent);

  function LogBookListItem() {
    _classCallCheck(this, LogBookListItem);

    return _possibleConstructorReturn(this, (LogBookListItem.__proto__ || Object.getPrototypeOf(LogBookListItem)).apply(this, arguments));
  }

  _createClass(LogBookListItem, [{
    key: 'render',
    value: function render() {
      var _props = this.props,
          changeRoute = _props.changeRoute,
          confirmAt = _props.confirmAt,
          branch = _props.branch,
          date = _props.date,
          kind = _props.kind,
          id = _props.id;


      return _jsx('div', {}, void 0, _jsx(_ListItem2.default, {
        primaryText: kind + ' (' + branch + ')',
        secondaryText: 'Inicio: ' + date + ' - Editado: ' + (confirmAt || 'sin edición')
      }), _jsx('div', {
        className: 'row'
      }, void 0, _jsx('div', {
        className: 'col-xs-6'
      }, void 0, _jsx(_RaisedButton2.default, {
        label: 'Ver',
        fullWidth: true,
        backgroundColor: '#f5f5f5',
        onClick: function onClick() {
          return changeRoute('/logbook_review/' + id);
        }
      })), _jsx('div', {
        className: 'col-xs-6'
      }, void 0, _jsx(_RaisedButton2.default, {
        label: 'Editar',
        fullWidth: true,
        primary: true,
        onClick: function onClick() {
          return changeRoute('/logbooks/' + id);
        }
      }))));
    }
  }]);

  return LogBookListItem;
}(_react2.default.PureComponent);

var LogBookList = function (_React$Component) {
  _inherits(LogBookList, _React$Component);

  function LogBookList() {
    _classCallCheck(this, LogBookList);

    return _possibleConstructorReturn(this, (LogBookList.__proto__ || Object.getPrototypeOf(LogBookList)).apply(this, arguments));
  }

  _createClass(LogBookList, [{
    key: 'componentDidMount',
    value: function componentDidMount() {
      this.props.actions.getStateFromApi();
    }
  }, {
    key: 'render',
    value: function render() {
      var _props2 = this.props,
          changeRoute = _props2.changeRoute,
          objects = _props2.objects,
          filters = _props2.filters;


      var listItems = Object.values(objects.logbooks);

      if (filters.filterByDateFrom !== null) {
        listItems = listItems.filter(function (logbook) {
          return correctDateString(logbook.date) >= filters.filterByDateFrom;
        });
      }

      if (filters.filterByDateTo !== null) {
        listItems = listItems.filter(function (logbook) {
          return correctDateString(logbook.date) <= filters.filterByDateTo;
        });
      }

      if (filters.filterByBranch !== null) {
        listItems = listItems.filter(function (logbook) {
          return logbook.branch().id === filters.filterByBranch;
        });
      }

      listItems = listItems.map(function (logbook) {
        return _jsx(LogBookListItem, {
          changeRoute: changeRoute,
          confirmAt: logbook.confirmAt,
          date: logbook.date,
          branch: logbook.branch().name,
          kind: logbook.logbookKind().name,
          id: logbook.id
        }, 'logbook-' + logbook.id);
      });

      return _jsx(_List2.default, {}, void 0, listItems);
    }
  }]);

  return LogBookList;
}(_react2.default.Component);

exports.default = (0, _reactRedux.connect)(_logBooks.filterSelector)(LogBookList);

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _jsx = function () { var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7; return function createRawReactElement(type, props, key, children) { var defaultProps = type && type.defaultProps; var childrenLength = arguments.length - 3; if (!props && childrenLength !== 0) { props = {}; } if (props && defaultProps) { for (var propName in defaultProps) { if (props[propName] === void 0) { props[propName] = defaultProps[propName]; } } } else if (!props) { props = defaultProps || {}; } if (childrenLength === 1) { props.children = children; } else if (childrenLength > 1) { var childArray = Array(childrenLength); for (var i = 0; i < childrenLength; i++) { childArray[i] = arguments[i + 3]; } props.children = childArray; } return { $$typeof: REACT_ELEMENT_TYPE, type: type, key: key === undefined ? null : '' + key, ref: null, props: props, _owner: null }; }; }();

// own modules


var _react = __webpack_require__(1);

var _react2 = _interopRequireDefault(_react);

var _reactRedux = __webpack_require__(43);

var _materialUi = __webpack_require__(483);

var _UserHelper = __webpack_require__(304);

var _logBooks = __webpack_require__(201);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }

var getMenuItems = function getMenuItems(items) {
  return items.map(function (item) {
    return _jsx(_materialUi.MenuItem, {
      value: item.id,
      primaryText: item.name
    }, 'itempbranch-' + item.id);
  });
};

/**
 * This component will render the needed buttons
 * @param {object} props some props needed
 */

var _ref = _jsx(_materialUi.MenuItem, {
  value: null,
  primaryText: ''
}, 'itembranch-0');

var _ref2 = _jsx(_materialUi.MenuItem, {
  value: null,
  primaryText: ''
}, 'itembranch-0');

var LogBookButton = function LogBookButton(props) {
  var logbookKinds = props.logbookKinds,
      createLogBook = props.createLogBook,
      logbooks = props.logbooks,
      branches = props.branches,
      actions = props.actions,
      user = props.user;


  var currrentUserId = user.attributes.id;

  var menuBranchItems = [_ref].concat(_toConsumableArray(getMenuItems(Object.values(branches))));

  var menuLogBookKindItems = [_ref2].concat(_toConsumableArray(getMenuItems(Object.values(logbookKinds).filter(function (lk) {
    return !logbooks.find(function (lb) {
      return lb.logbookKindId === lk.id;
    });
  }))));

  return _jsx('div', {
    className: 'row'
  }, void 0, _jsx('div', {
    className: 'col-lg-4 col-md-4 col-sm-4'
  }, void 0, _jsx(_materialUi.SelectField, {
    floatingLabelText: 'Seleccionar tipo de inventario',
    fullWidth: true,
    value: createLogBook.logBookKindId,
    onChange: function onChange(e, i, logBookKindId) {
      return actions.changeCreateLoogBook({ logBookKindId: logBookKindId });
    }
  }, void 0, menuLogBookKindItems)), (0, _UserHelper.isAdmin)(user) && _jsx('div', {
    className: 'col-lg-4 col-md-4 col-sm-4'
  }, void 0, _jsx(_materialUi.SelectField, {
    floatingLabelText: 'Seleccionar local',
    value: createLogBook.branchId,
    fullWidth: true,
    onChange: function onChange(e, i, branchId) {
      return actions.changeCreateLoogBook({ branchId: branchId });
    }
  }, void 0, menuBranchItems)), _jsx('div', {
    className: 'col-lg-4 col-md-4 col-sm-4'
  }, void 0, _jsx(_materialUi.RaisedButton, {
    fullWidth: true,
    label: 'Nuevo ingreso',
    style: { marginBottom: '15px', marginTop: '15px' },
    onClick: function onClick() {
      return actions.generateLogBook(createLogBook.logBookKindId, (0, _UserHelper.isAdmin)(user) ? createLogBook.branchId : Object.values(branches).find(function (br) {
        return br.userId === currrentUserId;
      }).id, new Date());
    }
  })));
};

exports.default = (0, _reactRedux.connect)(_logBooks.createLogBookSelector)(LogBookButton);

Object.defineProperty(exports, "__esModule", {
  value: true
});
var isAdmin = function isAdmin(user) {
  var response = false;
  if (user && user.attributes && user.attributes.role === 'admin') {
    response = true;
  }

  return response;
};
var isInspector = function isInspector(user) {
  var response = false;
  if (user && user.attributes && user.attributes.role === 'inspector') {
    response = true;
  }

  return response;
};
var canCreateMovement = function canCreateMovement(user, place) {
  return isAdmin(user) || place.companyId === user.attributes.company_id;
};
var canViewPlace = function canViewPlace(user, place) {
  return isAdmin(user) || isInspector(user) || place.companyId === user.attributes.company_id;
};
var canDestroyMovement = function canDestroyMovement(user, movement) {
  return isAdmin(user);
};

exports.isAdmin = isAdmin;
exports.isInspector = isInspector;
exports.canCreateMovement = canCreateMovement;
exports.canViewPlace = canViewPlace;
exports.canDestroyMovement = canDestroyMovement;

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.createLogBookSelector = exports.filterSelector = undefined;

var _reselect = __webpack_require__(136);

var getFiltersState = function getFiltersState(state) {
  return state.get('logBooks').get('filters');
};
var getCreateLogBookState = function getCreateLogBookState(state) {
  return state.get('logBooks').get('createLogBook');
};

var toJSSelector = function toJSSelector(stateSelector) {
  return (0, _reselect.createSelector)(stateSelector, function (state) {
    return state.toJS();
  });
};

/**
 * It will get the state of the `logBooks`
 *
 *  filters: {
 *    filterByDateFrom: date,
 *    filterByDateTo: null,
 *    filterByBranch: null
 *  }
 */
var filterSelector = exports.filterSelector = (0, _reselect.createStructuredSelector)({
  filters: toJSSelector(getFiltersState)
});

var createLogBookSelector = exports.createLogBookSelector = (0, _reselect.createStructuredSelector)({
  createLogBook: toJSSelector(getCreateLogBookState)
});

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Branch = exports.LogbookLine = exports.Logbook = exports.LogbookKind = exports.Unit = exports.Product = undefined;

var _Product = __webpack_require__(450);

var _Product2 = _interopRequireDefault(_Product);

var _Unit = __webpack_require__(449);

var _Unit2 = _interopRequireDefault(_Unit);

var _LogbookKind = __webpack_require__(448);

var _LogbookKind2 = _interopRequireDefault(_LogbookKind);

var _Logbook = __webpack_require__(447);

var _Logbook2 = _interopRequireDefault(_Logbook);

var _LogbookLine = __webpack_require__(446);

var _LogbookLine2 = _interopRequireDefault(_LogbookLine);

var _Branch = __webpack_require__(445);

var _Branch2 = _interopRequireDefault(_Branch);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

exports.Product = _Product2.default;
exports.Unit = _Unit2.default;
exports.LogbookKind = _LogbookKind2.default;
exports.Logbook = _Logbook2.default;
exports.LogbookLine = _LogbookLine2.default;
exports.Branch = _Branch2.default;

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _Filters = __webpack_require__(111);

var _Filters2 = _interopRequireDefault(_Filters);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var Product = function () {
  function Product(data) {
    _classCallCheck(this, Product);

    var props = _Filters2.default.camelizeKeys(data);
    Object.assign(this, props);
  }

  _createClass(Product, [{
    key: 'unit',
    value: function unit() {
      return this.env().Unit.getById(this.unitId);
    }
  }]);

  return Product;
}();

exports.default = Product;

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _Filters = __webpack_require__(111);

var _Filters2 = _interopRequireDefault(_Filters);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var Unit = function Unit(data) {
  _classCallCheck(this, Unit);

  var props = _Filters2.default.camelizeKeys(data);
  this.id = props.id;
  this.name = props.name;
};

exports.default = Unit;

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _Filters = __webpack_require__(111);

var _Filters2 = _interopRequireDefault(_Filters);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var LogbookKind = function LogbookKind(data) {
  _classCallCheck(this, LogbookKind);

  var props = _Filters2.default.camelizeKeys(data);
  this.id = props.id;
  this.name = props.name;
};

exports.default = LogbookKind;

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _Filters = __webpack_require__(111);

var _Filters2 = _interopRequireDefault(_Filters);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var Logbook = function () {
  function Logbook(data) {
    _classCallCheck(this, Logbook);

    var props = _Filters2.default.camelizeKeys(data);
    this.id = props.id;
    this.date = props.date;
    this.confirmAt = props.confirmAt;
    this.logbookKindId = props.logbookKindId;
    this.branchId = props.branchId;
  }

  _createClass(Logbook, [{
    key: 'logbookKind',
    value: function logbookKind() {
      return this.env().LogbookKind.getById(this.logbookKindId);
    }
  }, {
    key: 'branch',
    value: function branch() {
      return this.env().Branch.getById(this.branchId);
    }
  }]);

  return Logbook;
}();

exports.default = Logbook;

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _Filters = __webpack_require__(111);

var _Filters2 = _interopRequireDefault(_Filters);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var LogbookLine = function () {
  function LogbookLine(data) {
    _classCallCheck(this, LogbookLine);

    var props = _Filters2.default.camelizeKeys(data);
    this.id = props.id;
    this.loss = props.loss;
    this.productId = props.productId;
    this.logbookId = props.logbookId;
  }

  _createClass(LogbookLine, [{
    key: 'product',
    value: function product() {
      return this.env().Product.getById(this.productId);
    }
  }]);

  return LogbookLine;
}();

exports.default = LogbookLine;

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _Filters = __webpack_require__(111);

var _Filters2 = _interopRequireDefault(_Filters);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var Branch = function Branch(data) {
  _classCallCheck(this, Branch);

  var props = _Filters2.default.camelizeKeys(data);
  this.id = props.id;
  this.name = props.name;
  this.userId = props.userId;
};

exports.default = Branch;

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _chileanRut = __webpack_require__(453);

var _chileanRut2 = _interopRequireDefault(_chileanRut);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var Filters = function () {
  function Filters() {
    _classCallCheck(this, Filters);
  }

  _createClass(Filters, null, [{
    key: 'camelize',
    value: function camelize(string) {
      var newString = string.replace(/(?:^|[-_])(\w)/g, function (_, c) {
        return c ? c.toUpperCase() : '';
      });
      var firstLetter = newString[0];
      var newFirstLetter = firstLetter.toLowerCase();
      var cutString = newString.substring(1);
      var finalString = newFirstLetter + cutString;

      return finalString;
    }
  }, {
    key: 'camelizeKeys',
    value: function camelizeKeys(hash) {
      var thisReference = this;
      var newHash = {};
      Object.keys(hash).forEach(function (key) {
        var newKey = thisReference.camelize(key);
        newHash[newKey] = hash[key];
      });
      return newHash;
    }
  }, {
    key: 'correctDateString',
    value: function correctDateString(dateString) {
      var date = new Date(dateString);
      return new Date(date.getTime() + date.getTimezoneOffset() * 60 * 1000);
    }
  }, {
    key: 'workingDayBefore',
    value: function workingDayBefore(dateObject) {
      var holidays = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];

      dateObject.setHours(0);
      dateObject.setMinutes(0);
      dateObject.setSeconds(0);
      dateObject.setMilliseconds(0);
      var dayBackwards = 1;
      var isHoliday = true;
      while (isHoliday) {
        var day = dateObject.getDay();
        if (day === 0) {
          dayBackwards = 2;
        } else if (day === 1) {
          dayBackwards = 3;
        }
        dateObject.setDate(dateObject.getDate() - dayBackwards);
        isHoliday = holidays.some(function (holiday) {
          return holiday.getTime() === dateObject.getTime();
        });
      }
      return dateObject;
    }
  }, {
    key: 'fDate',
    value: function fDate(dateString) {
      var date = '';

      if (dateString) {
        date = new Date(dateString).toISOString().slice(0, 10).replace(/-/g, '-');
      }
      return date;
    }
  }, {
    key: 'hashToArray',
    value: function hashToArray(hash) {
      var array = [];

      for (var key in hash) {
        array.push(hash[key]);
      }

      return array;
    }
  }, {
    key: 'spanishDate',
    value: function spanishDate(dateString) {
      // return new Intl.DateTimeFormat('es-CL').format(new Date(dateString), {year: 'long', month: 'numeric', day: 'numeric'});
      if (dateString) {
        var date = this.fDate(dateString);
        var year = date.split('-')[0];
        var month = this.month(parseInt(date.split('-')[1], 10) - 1);
        var day = date.split('-')[2];

        return day + ' ' + month + ' ' + year;
      }
      return '';
    }
  }, {
    key: 'unformatTaxNumber',
    value: function unformatTaxNumber(taxNumber) {
      return _chileanRut2.default.unformat(taxNumber);
    }
  }, {
    key: 'daysFromDate',
    value: function daysFromDate(date) {
      var today = new Date();

      return Math.trunc((today - date) / (1000 * 60 * 60 * 24));
    }
  }, {
    key: 'legalDaysFromDate',
    value: function legalDaysFromDate(date, holidays) {
      var count = this.daysFromDate(date) - this.sundaysFromDate(date);
      var today = new Date();

      holidays.forEach(function (holiday) {
        var holidayDate = new Date(holiday.holidayDate);

        if (holidayDate > date && holidayDate < today) {
          count -= 1;
        }
      });

      return count;
    }
  }, {
    key: 'month',
    value: function month(code) {
      var hash = {
        '0': 'enero',
        '1': 'febrero',
        '2': 'marzo',
        '3': 'abril',
        '4': 'mayo',
        '5': 'junio',
        '6': 'julio',
        '7': 'agosto',
        '8': 'septiembre',
        '9': 'octubre',
        '10': 'noviembre',
        '11': 'diciembre'
      };

      return hash[code];
    }
  }, {
    key: 'sundaysFromDate',
    value: function sundaysFromDate(date) {
      var today = new Date();
      var days = this.daysFromDate(date, today);

      if (days < 7) {
        if (date.getDay() + days > 6) {
          return 1;
        }
        return 0;
      }
      return Math.floor(days / 7);
    }
  }]);

  return Filters;
}();

exports.default = Filters;

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _apiFetch = __webpack_require__(200);

var _apiFetch2 = _interopRequireDefault(_apiFetch);

var _effects = __webpack_require__(138);

var _reactRouterRedux = __webpack_require__(37);

var _logBook = __webpack_require__(161);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var _marked = /*#__PURE__*/regeneratorRuntime.mark(getStateFromApi),
    _marked2 = /*#__PURE__*/regeneratorRuntime.mark(createLogBook),
    _marked3 = /*#__PURE__*/regeneratorRuntime.mark(saga);

exports.default = [saga];

/**
 * It will get all the needed data from the server
 */

function getStateFromApi() {
  return regeneratorRuntime.wrap(function getStateFromApi$(_context2) {
    while (1) {
      switch (_context2.prev = _context2.next) {
        case 0:
          _context2.next = 2;
          return (0, _effects.takeEvery)(_logBook.GET_STATE_FROM_API, /*#__PURE__*/regeneratorRuntime.mark(function _callee(action) {
            var result;
            return regeneratorRuntime.wrap(function _callee$(_context) {
              while (1) {
                switch (_context.prev = _context.next) {
                  case 0:
                    _context.next = 2;
                    return (0, _effects.call)(_apiFetch2.default, 'logbook_lines?id=' + action.logbookId);

                  case 2:
                    result = _context.sent;

                    if (!result.ok) {
                      _context.next = 8;
                      break;
                    }

                    _context.next = 6;
                    return (0, _effects.put)((0, _logBook.getStateFromApiSuccess)(result.data));

                  case 6:
                    _context.next = 10;
                    break;

                  case 8:
                    _context.next = 10;
                    return (0, _effects.put)((0, _logBook.getStateFromApiFail)(result.err));

                  case 10:
                  case 'end':
                    return _context.stop();
                }
              }
            }, _callee, this);
          }));

        case 2:
        case 'end':
          return _context2.stop();
      }
    }
  }, _marked, this);
}

/**
 * It will create a new logbook line.
 */
function createLogBook() {
  return regeneratorRuntime.wrap(function createLogBook$(_context4) {
    while (1) {
      switch (_context4.prev = _context4.next) {
        case 0:
          _context4.next = 2;
          return (0, _effects.takeEvery)(_logBook.CREATE_LOOBBOOK, /*#__PURE__*/regeneratorRuntime.mark(function _callee2(action) {
            var logbook_lineslist, result;
            return regeneratorRuntime.wrap(function _callee2$(_context3) {
              while (1) {
                switch (_context3.prev = _context3.next) {
                  case 0:
                    logbook_lineslist = Object.values(action.productsLines).map(function (productsLine) {
                      return {
                        logbook_id: parseInt(action.logbookId),
                        product_id: parseInt(productsLine.id),
                        initial_stock: parseFloat(productsLine.initialStock ? productsLine.initialStock : 0),
                        loss: parseFloat(productsLine.loss ? productsLine.loss : 0),
                        loss_str_operation: productsLine.lossStrOperation,
                        stock_str_operation: productsLine.stockStrOperation
                      };
                    });
                    _context3.next = 3;
                    return (0, _effects.call)(_apiFetch.post, 'logbook_lines', {
                      logbook_lineslist: logbook_lineslist,
                      temp_save: action.tempSave
                    });

                  case 3:
                    result = _context3.sent;

                    if (!result.ok) {
                      _context3.next = 11;
                      break;
                    }

                    _context3.next = 7;
                    return (0, _effects.put)((0, _logBook.createLogBookSuccess)());

                  case 7:
                    _context3.next = 9;
                    return (0, _effects.put)((0, _reactRouterRedux.push)('/logbook_review/' + result.data.logbook_id));

                  case 9:
                    _context3.next = 13;
                    break;

                  case 11:
                    _context3.next = 13;
                    return (0, _effects.put)((0, _logBook.createLogBookFails)(result.err));

                  case 13:
                  case 'end':
                    return _context3.stop();
                }
              }
            }, _callee2, this);
          }));

        case 2:
        case 'end':
          return _context4.stop();
      }
    }
  }, _marked2, this);
}

function saga() {
  var forks;
  return regeneratorRuntime.wrap(function saga$(_context5) {
    while (1) {
      switch (_context5.prev = _context5.next) {
        case 0:
          _context5.next = 2;
          return [(0, _effects.fork)(getStateFromApi), (0, _effects.fork)(createLogBook)];

        case 2:
          forks = _context5.sent;
          _context5.next = 5;
          return (0, _effects.take)(_reactRouterRedux.LOCATION_CHANGE);

        case 5:
          _context5.next = 7;
          return forks.map(function (f) {
            return (0, _effects.cancel)(f);
          });

        case 7:
        case 'end':
          return _context5.stop();
      }
    }
  }, _marked3, this);
}

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _jsx = function () { var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7; return function createRawReactElement(type, props, key, children) { var defaultProps = type && type.defaultProps; var childrenLength = arguments.length - 3; if (!props && childrenLength !== 0) { props = {}; } if (props && defaultProps) { for (var propName in defaultProps) { if (props[propName] === void 0) { props[propName] = defaultProps[propName]; } } } else if (!props) { props = defaultProps || {}; } if (childrenLength === 1) { props.children = children; } else if (childrenLength > 1) { var childArray = Array(childrenLength); for (var i = 0; i < childrenLength; i++) { childArray[i] = arguments[i + 3]; } props.children = childArray; } return { $$typeof: REACT_ELEMENT_TYPE, type: type, key: key === undefined ? null : '' + key, ref: null, props: props, _owner: null }; }; }();

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _react = __webpack_require__(1);

var _react2 = _interopRequireDefault(_react);

var _Card = __webpack_require__(137);

var _Card2 = _interopRequireDefault(_Card);

var _CardTitle = __webpack_require__(112);

var _CardTitle2 = _interopRequireDefault(_CardTitle);

var _CardText = __webpack_require__(87);

var _CardText2 = _interopRequireDefault(_CardText);

var _reactRedux = __webpack_require__(43);

var _reactRouterRedux = __webpack_require__(37);

var _redux = __webpack_require__(88);

var _LogBookForm = __webpack_require__(470);

var _LogBookForm2 = _interopRequireDefault(_LogBookForm);

var _objects = __webpack_require__(199);

var _logBook = __webpack_require__(161);

var logBookActions = _interopRequireWildcard(_logBook);

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

// Own modules


var LogBook = function (_React$Component) {
  _inherits(LogBook, _React$Component);

  function LogBook() {
    _classCallCheck(this, LogBook);

    return _possibleConstructorReturn(this, (LogBook.__proto__ || Object.getPrototypeOf(LogBook)).apply(this, arguments));
  }

  _createClass(LogBook, [{
    key: 'componentWillMount',
    value: function componentWillMount() {
      this.props.actions.getStateFromApi(this.props.routeParams.id);
    }
  }, {
    key: 'render',
    value: function render() {
      var _props = this.props,
          routeParams = _props.routeParams,
          changeRoute = _props.changeRoute,
          objects = _props.objects,
          logbooks = _props.objects.logbooks,
          actions = _props.actions;


      var logbookName = '';
      if (Object.values(logbooks).length) {
        var _Object$values$0$logb = Object.values(logbooks)[0].logbookKind();

        logbookName = _Object$values$0$logb.name;
      }

      return _jsx(_Card2.default, {
        style: { marginBottom: '10px' }
      }, void 0, _jsx(_CardTitle2.default, {
        title: 'Ingreso de ' + logbookName
      }), _jsx(_CardText2.default, {}, void 0, _jsx(_LogBookForm2.default, {
        actions: actions,
        objects: objects,
        logbookId: routeParams.id,
        changeRoute: changeRoute
      })));
    }
  }]);

  return LogBook;
}(_react2.default.Component);

function select(state) {
  return {
    objects: (0, _objects.reselectObjects)(state)
  };
}

function mapDispatchToProps(dispatch) {
  return {
    actions: (0, _redux.bindActionCreators)(logBookActions, dispatch),
    changeRoute: function changeRoute(url) {
      return dispatch((0, _reactRouterRedux.push)(url));
    },
    dispatch: dispatch
  };
}

exports.default = (0, _reactRedux.connect)(select, mapDispatchToProps)(LogBook);

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _apiFetch = __webpack_require__(200);

var _apiFetch2 = _interopRequireDefault(_apiFetch);

var _effects = __webpack_require__(138);

var _reactRouterRedux = __webpack_require__(37);

var _logBooks = __webpack_require__(159);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var _marked = /*#__PURE__*/regeneratorRuntime.mark(getStateFromApi),
    _marked2 = /*#__PURE__*/regeneratorRuntime.mark(generateLogBook),
    _marked3 = /*#__PURE__*/regeneratorRuntime.mark(saga);

exports.default = [saga];

/**
 * It will get all the needed data from the server
 */

function getStateFromApi() {
  return regeneratorRuntime.wrap(function getStateFromApi$(_context2) {
    while (1) {
      switch (_context2.prev = _context2.next) {
        case 0:
          _context2.next = 2;
          return (0, _effects.takeEvery)(_logBooks.GET_STATE_FROM_API, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
            var result;
            return regeneratorRuntime.wrap(function _callee$(_context) {
              while (1) {
                switch (_context.prev = _context.next) {
                  case 0:
                    _context.next = 2;
                    return (0, _effects.call)(_apiFetch2.default, 'logbooks');

                  case 2:
                    result = _context.sent;

                    if (!result.ok) {
                      _context.next = 8;
                      break;
                    }

                    _context.next = 6;
                    return (0, _effects.put)((0, _logBooks.getStateFromApiSuccess)(result.data));

                  case 6:
                    _context.next = 10;
                    break;

                  case 8:
                    _context.next = 10;
                    return (0, _effects.put)((0, _logBooks.getStateFromApiFail)(result.err));

                  case 10:
                  case 'end':
                    return _context.stop();
                }
              }
            }, _callee, this);
          }));

        case 2:
        case 'end':
          return _context2.stop();
      }
    }
  }, _marked, this);
}

/**
 * It will create a new logbook
 */
function generateLogBook() {
  return regeneratorRuntime.wrap(function generateLogBook$(_context4) {
    while (1) {
      switch (_context4.prev = _context4.next) {
        case 0:
          _context4.next = 2;
          return (0, _effects.takeEvery)(_logBooks.CREATE_LOGBOOK, /*#__PURE__*/regeneratorRuntime.mark(function _callee2(action) {
            var result;
            return regeneratorRuntime.wrap(function _callee2$(_context3) {
              while (1) {
                switch (_context3.prev = _context3.next) {
                  case 0:
                    _context3.next = 2;
                    return (0, _effects.call)(_apiFetch.post, 'logbooks', {
                      logbook_kind_id: action.logBookKindId,
                      branch_id: action.branchId,
                      date: action.date
                    });

                  case 2:
                    result = _context3.sent;

                    if (!result.ok) {
                      _context3.next = 8;
                      break;
                    }

                    _context3.next = 6;
                    return (0, _effects.put)((0, _reactRouterRedux.push)('/logbooks/' + result.data.logbook_id));

                  case 6:
                    _context3.next = 10;
                    break;

                  case 8:
                    _context3.next = 10;
                    return (0, _effects.put)((0, _logBooks.generateLogBookFail)(result.err));

                  case 10:
                  case 'end':
                    return _context3.stop();
                }
              }
            }, _callee2, this);
          }));

        case 2:
        case 'end':
          return _context4.stop();
      }
    }
  }, _marked2, this);
}

function saga() {
  var forks;
  return regeneratorRuntime.wrap(function saga$(_context5) {
    while (1) {
      switch (_context5.prev = _context5.next) {
        case 0:
          _context5.next = 2;
          return [(0, _effects.fork)(getStateFromApi), (0, _effects.fork)(generateLogBook)];

        case 2:
          forks = _context5.sent;
          _context5.next = 5;
          return (0, _effects.take)(_reactRouterRedux.LOCATION_CHANGE);

        case 5:
          _context5.next = 7;
          return forks.map(function (f) {
            return (0, _effects.cancel)(f);
          });

        case 7:
        case 'end':
          return _context5.stop();
      }
    }
  }, _marked3, this);
}

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _jsx = function () { var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7; return function createRawReactElement(type, props, key, children) { var defaultProps = type && type.defaultProps; var childrenLength = arguments.length - 3; if (!props && childrenLength !== 0) { props = {}; } if (props && defaultProps) { for (var propName in defaultProps) { if (props[propName] === void 0) { props[propName] = defaultProps[propName]; } } } else if (!props) { props = defaultProps || {}; } if (childrenLength === 1) { props.children = children; } else if (childrenLength > 1) { var childArray = Array(childrenLength); for (var i = 0; i < childrenLength; i++) { childArray[i] = arguments[i + 3]; } props.children = childArray; } return { $$typeof: REACT_ELEMENT_TYPE, type: type, key: key === undefined ? null : '' + key, ref: null, props: props, _owner: null }; }; }();

var _extends = Object.assign || 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; };

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _react = __webpack_require__(1);

var _react2 = _interopRequireDefault(_react);

var _Dialog = __webpack_require__(89);

var _Dialog2 = _interopRequireDefault(_Dialog);

var _Display = __webpack_require__(468);

var _Display2 = _interopRequireDefault(_Display);

var _ButtonPanel = __webpack_require__(465);

var _ButtonPanel2 = _interopRequireDefault(_ButtonPanel);

var _calculate = __webpack_require__(459);

var _calculate2 = _interopRequireDefault(_calculate);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var concatedOperator = [];

var cleanOperationString = function cleanOperationString(operation) {
  var noneOperations = operation.split(/(\s[\-\+x÷%]\s|[\-\+x÷%]$)/);
  var cleanedValues = '';
  var lastResult = '';

  if (noneOperations.length > 1) {
    cleanedValues = noneOperations.map(function (noneOperation) {
      lastResult = noneOperation;

      if (!/[\=\-\+x÷%]/.test(lastResult)) {
        var splitedValues = noneOperation.split(' ').pop();
        if (splitedValues.trim()) {
          lastResult = splitedValues;
        }
      }

      return lastResult;
    }).join('');
  } else {
    cleanedValues = noneOperations[0].split(' ').pop();
  }

  return cleanedValues;
};

var Calculator = function (_React$Component) {
  _inherits(Calculator, _React$Component);

  function Calculator(props) {
    _classCallCheck(this, Calculator);

    var _this = _possibleConstructorReturn(this, (Calculator.__proto__ || Object.getPrototypeOf(Calculator)).call(this, props));

    _this.state = {
      total: null,
      next: null,
      operation: null,
      strOperation: ''
    };

    _this.defaultProps = {
      open: false
    };

    _this.handleClick = _this.handleClick.bind(_this);
    return _this;
  }

  _createClass(Calculator, [{
    key: 'componentWillReceiveProps',
    value: function componentWillReceiveProps(nextProps) {
      if (!nextProps.open) {
        this.setState({
          total: null,
          next: null,
          operation: null,
          strOperation: ''
        });
      }
    }
  }, {
    key: 'handleClick',
    value: function handleClick(buttonName) {
      var _this2 = this;

      var calc = (0, _calculate2.default)(this.state, buttonName);
      var next = calc.next,
          operation = calc.operation,
          total = calc.total;


      var concatedOperation = this.state.strOperation;
      var totalStr = total ? ' = ' + total : '';

      concatedOperation = buttonName === 'AC' ? '' : concatedOperation + ' ' + (next || operation || totalStr);

      concatedOperator = [].concat(_toConsumableArray(concatedOperator), [operation]);

      this.setState(_extends({}, (0, _calculate2.default)(this.state, buttonName), {
        strOperation: cleanOperationString(concatedOperation)
      }), function () {
        _this2.props.setStrResult(_this2.state.strOperation, _this2.state.total, _this2.props.textField, buttonName);
      });
    }
  }, {
    key: 'render',
    value: function render() {
      var _props = this.props,
          openCalculator = _props.openCalculator,
          open = _props.open;


      return _jsx(_Dialog2.default, {
        modal: false,
        open: open,
        bodyStyle: { padding: 0 },
        contentStyle: { width: '95%' },
        onRequestClose: function onRequestClose() {
          return openCalculator({}, false);
        }
      }, void 0, _jsx(_Display2.default, {
        value: this.state.next || this.state.total || '0'
      }), _jsx(_ButtonPanel2.default, {
        clickHandler: this.handleClick
      }));
    }
  }]);

  return Calculator;
}(_react2.default.Component);

exports.default = Calculator;

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.selectForm = undefined;

var _reselect = __webpack_require__(136);

var getLogBookState = function getLogBookState(state) {
  return state.get('logBook').get('productsLines');
};
var getIsEditingState = function getIsEditingState(state) {
  return state.get('logBook').get('isEditing');
};
var getOpen = function getOpen(state) {
  return state.get('logBook').get('open');
};
var getTextField = function getTextField(state) {
  return state.get('logBook').get('textField');
};

var toJSSelector = function toJSSelector(stateSelector) {
  return (0, _reselect.createSelector)(stateSelector, function (state) {
    return state.toJS();
  });
};

/**
 * It will get the state of the `logBook`
 *
 * productsLines: {},
 * isEditing: false
 */
var selectForm = exports.selectForm = (0, _reselect.createStructuredSelector)({
  productsLines: toJSSelector(getLogBookState),
  isEditing: getIsEditingState,
  open: getOpen,
  textField: getTextField
});

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _jsx = function () { var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7; return function createRawReactElement(type, props, key, children) { var defaultProps = type && type.defaultProps; var childrenLength = arguments.length - 3; if (!props && childrenLength !== 0) { props = {}; } if (props && defaultProps) { for (var propName in defaultProps) { if (props[propName] === void 0) { props[propName] = defaultProps[propName]; } } } else if (!props) { props = defaultProps || {}; } if (childrenLength === 1) { props.children = children; } else if (childrenLength > 1) { var childArray = Array(childrenLength); for (var i = 0; i < childrenLength; i++) { childArray[i] = arguments[i + 3]; } props.children = childArray; } return { $$typeof: REACT_ELEMENT_TYPE, type: type, key: key === undefined ? null : '' + key, ref: null, props: props, _owner: null }; }; }();

var _react = __webpack_require__(1);

var _react2 = _interopRequireDefault(_react);

var _index = __webpack_require__(467);

var _index2 = _interopRequireDefault(_index);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var Display = function Display(props) {
  return _jsx('div', {
    className: _index2.default.ComponentDisplay
  }, void 0, _jsx('div', {}, void 0, props.value));
};

exports.default = Display;

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _jsx = function () { var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7; return function createRawReactElement(type, props, key, children) { var defaultProps = type && type.defaultProps; var childrenLength = arguments.length - 3; if (!props && childrenLength !== 0) { props = {}; } if (props && defaultProps) { for (var propName in defaultProps) { if (props[propName] === void 0) { props[propName] = defaultProps[propName]; } } } else if (!props) { props = defaultProps || {}; } if (childrenLength === 1) { props.children = children; } else if (childrenLength > 1) { var childArray = Array(childrenLength); for (var i = 0; i < childrenLength; i++) { childArray[i] = arguments[i + 3]; } props.children = childArray; } return { $$typeof: REACT_ELEMENT_TYPE, type: type, key: key === undefined ? null : '' + key, ref: null, props: props, _owner: null }; }; }();

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _react = __webpack_require__(1);

var _react2 = _interopRequireDefault(_react);

var _Button = __webpack_require__(464);

var _Button2 = _interopRequireDefault(_Button);

var _index = __webpack_require__(461);

var _index2 = _interopRequireDefault(_index);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var ButtonPanel = function (_React$Component) {
  _inherits(ButtonPanel, _React$Component);

  function ButtonPanel(props) {
    _classCallCheck(this, ButtonPanel);

    var _this = _possibleConstructorReturn(this, (ButtonPanel.__proto__ || Object.getPrototypeOf(ButtonPanel)).call(this, props));

    _this.handleClick = _this.handleClick.bind(_this);
    return _this;
  }

  _createClass(ButtonPanel, [{
    key: 'handleClick',
    value: function handleClick(buttonName) {
      this.props.clickHandler(buttonName);
    }
  }, {
    key: 'render',
    value: function render() {
      return _jsx('div', {
        className: _index2.default.ComponentButtonPanel
      }, void 0, _jsx('div', {}, void 0, _jsx(_Button2.default, {
        name: 'AC',
        clickHandler: this.handleClick
      }), _jsx(_Button2.default, {
        name: '+/-',
        clickHandler: this.handleClick
      }), _jsx(_Button2.default, {
        name: '%',
        clickHandler: this.handleClick
      }), _jsx(_Button2.default, {
        name: '\xF7',
        clickHandler: this.handleClick,
        orange: true
      })), _jsx('div', {}, void 0, _jsx(_Button2.default, {
        name: '7',
        clickHandler: this.handleClick
      }), _jsx(_Button2.default, {
        name: '8',
        clickHandler: this.handleClick
      }), _jsx(_Button2.default, {
        name: '9',
        clickHandler: this.handleClick
      }), _jsx(_Button2.default, {
        name: 'x',
        clickHandler: this.handleClick,
        orange: true
      })), _jsx('div', {}, void 0, _jsx(_Button2.default, {
        name: '4',
        clickHandler: this.handleClick
      }), _jsx(_Button2.default, {
        name: '5',
        clickHandler: this.handleClick
      }), _jsx(_Button2.default, {
        name: '6',
        clickHandler: this.handleClick
      }), _jsx(_Button2.default, {
        name: '-',
        clickHandler: this.handleClick,
        orange: true
      })), _jsx('div', {}, void 0, _jsx(_Button2.default, {
        name: '1',
        clickHandler: this.handleClick
      }), _jsx(_Button2.default, {
        name: '2',
        clickHandler: this.handleClick
      }), _jsx(_Button2.default, {
        name: '3',
        clickHandler: this.handleClick
      }), _jsx(_Button2.default, {
        name: '+',
        clickHandler: this.handleClick,
        orange: true
      })), _jsx('div', {}, void 0, _jsx(_Button2.default, {
        name: '0',
        clickHandler: this.handleClick,
        wide: true
      }), _jsx(_Button2.default, {
        name: '.',
        clickHandler: this.handleClick
      }), _jsx(_Button2.default, {
        name: 'Aceptar',
        clickHandler: this.handleClick,
        orange: true
      })));
    }
  }]);

  return ButtonPanel;
}(_react2.default.Component);

exports.default = ButtonPanel;

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = calculate;

var _big = __webpack_require__(306);

var _big2 = _interopRequireDefault(_big);

var _operate = __webpack_require__(458);

var _operate2 = _interopRequireDefault(_operate);

var _isNumber = __webpack_require__(457);

var _isNumber2 = _interopRequireDefault(_isNumber);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/**
 * Given a button name and a calculator data object, return an updated
 * calculator data object.
 *
 * Calculator data object contains:
 *   total:String      the running total
 *   next:String       the next number to be operated on with the total
 *   operation:String  +, -, etc.
 */
function calculate(obj, buttonName) {
  if (buttonName === "AC") {
    return {
      total: null,
      next: null,
      operation: null
    };
  }

  if ((0, _isNumber2.default)(buttonName)) {
    if (buttonName === "0" && obj.next === "0") {
      return {};
    }
    // If there is an operation, update next
    if (obj.operation) {
      if (obj.next) {
        return { next: obj.next + buttonName };
      }
      return { next: buttonName };
    }
    // If there is no operation, update next and clear the value
    if (obj.next) {
      return {
        next: obj.next + buttonName,
        total: null
      };
    }
    return {
      next: buttonName,
      total: null
    };
  }

  if (buttonName === "%") {
    if (obj.operation && obj.next) {
      var result = (0, _operate2.default)(obj.total, obj.next, obj.operation);
      return {
        total: (0, _big2.default)(result).div((0, _big2.default)("100")).toString(),
        next: null,
        operation: null
      };
    }
    if (obj.next) {
      return {
        next: (0, _big2.default)(obj.next).div((0, _big2.default)("100")).toString()
      };
    }
    return {};
  }

  if (buttonName === ".") {
    if (obj.next) {
      // ignore a . if the next number already has one
      if (obj.next.includes(".")) {
        return {};
      }
      return { next: obj.next + "." };
    }
    return { next: "0." };
  }

  if (buttonName === "Aceptar") {
    if (obj.next && obj.operation) {
      return {
        total: (0, _operate2.default)(obj.total, obj.next, obj.operation),
        next: null,
        operation: null
      };
    } else {
      // '=' with no operation, nothing to do
      return {};
    }
  }

  if (buttonName === "+/-") {
    if (obj.next) {
      return { next: (-1 * parseFloat(obj.next)).toString() };
    }
    if (obj.total) {
      return { total: (-1 * parseFloat(obj.total)).toString() };
    }
    return {};
  }

  // Button must be an operation

  // When the user presses an operation button without having entered
  // a number first, do nothing.
  // if (!obj.next && !obj.total) {
  //   return {};
  // }

  // User pressed an operation button and there is an existing operation
  if (obj.operation) {
    return {
      total: (0, _operate2.default)(obj.total, obj.next, obj.operation),
      next: null,
      operation: buttonName
    };
  }

  // no operation yet, but the user typed one

  // The user hasn't typed a number yet, just save the operation
  if (!obj.next) {
    return { operation: buttonName };
  }

  // save the operation and shift 'next' into 'total'
  return {
    total: obj.next,
    next: null,
    operation: buttonName
  };
}

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = operate;

var _big = __webpack_require__(306);

var _big2 = _interopRequireDefault(_big);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function operate(numberOne, numberTwo, operation) {
  var one = (0, _big2.default)(numberOne || "0");
  var two = (0, _big2.default)(numberTwo || "0");
  if (operation === "+") {
    return one.plus(two).toString();
  }
  if (operation === "-") {
    return one.minus(two).toString();
  }
  if (operation === "x") {
    return one.times(two).toString();
  }
  if (operation === "÷") {
    return one.div(two).toString();
  }
  throw Error("Unknown operation '" + operation + "'");
}

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = isNumber;
function isNumber(item) {
  return (/[0-9]+/.test(item)
  );
}

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _jsx = function () { var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7; return function createRawReactElement(type, props, key, children) { var defaultProps = type && type.defaultProps; var childrenLength = arguments.length - 3; if (!props && childrenLength !== 0) { props = {}; } if (props && defaultProps) { for (var propName in defaultProps) { if (props[propName] === void 0) { props[propName] = defaultProps[propName]; } } } else if (!props) { props = defaultProps || {}; } if (childrenLength === 1) { props.children = children; } else if (childrenLength > 1) { var childArray = Array(childrenLength); for (var i = 0; i < childrenLength; i++) { childArray[i] = arguments[i + 3]; } props.children = childArray; } return { $$typeof: REACT_ELEMENT_TYPE, type: type, key: key === undefined ? null : '' + key, ref: null, props: props, _owner: null }; }; }();

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _react = __webpack_require__(1);

var _react2 = _interopRequireDefault(_react);

var _index = __webpack_require__(463);

var _index2 = _interopRequireDefault(_index);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var Button = function (_React$Component) {
  _inherits(Button, _React$Component);

  function Button(props) {
    _classCallCheck(this, Button);

    var _this = _possibleConstructorReturn(this, (Button.__proto__ || Object.getPrototypeOf(Button)).call(this, props));

    _this.handleClick = _this.handleClick.bind(_this);
    return _this;
  }

  _createClass(Button, [{
    key: 'handleClick',
    value: function handleClick() {
      this.props.clickHandler(this.props.name);
    }
  }, {
    key: 'render',
    value: function render() {
      var className = [_index2.default.ComponentButton, this.props.orange ? _index2.default.Orange : '', this.props.wide ? _index2.default.Wide : ''];

      return _jsx('div', {
        className: className.join(' ').trim()
      }, void 0, _jsx('button', {
        onClick: this.handleClick
      }, void 0, this.props.name));
    }
  }]);

  return Button;
}(_react2.default.Component);

exports.default = Button;// style-loader: Adds some css to the DOM by adding a <style> tag

// load the styles
var content = __webpack_require__(460);
if(typeof content === 'string') content = [[module.i, content, '']];
// Prepare cssTransformation
var transform;

var options = {}
options.transform = transform
// add the styles to the DOM
var update = __webpack_require__(61)(content, options);
if(content.locals) module.exports = content.locals;
// Hot Module Replacement
if(false) {}exports = module.exports = __webpack_require__(62)(undefined);
// imports


// module
exports.push([module.i, "._1RNZ0i6mGb5tuZtIyVfMtg {\n  background-color: #858694;\n  display: -webkit-box;\n  display: -ms-flexbox;\n  display: flex;\n  -webkit-box-orient: horizontal;\n  -webkit-box-direction: normal;\n      -ms-flex-direction: row;\n          flex-direction: row;\n  -ms-flex-wrap: wrap;\n      flex-wrap: wrap;\n  -webkit-box-flex: 1;\n      -ms-flex: 1 0 auto;\n          flex: 1 0 auto;\n}\n\n._1RNZ0i6mGb5tuZtIyVfMtg > div {\n  width: 100%;\n  margin-bottom: 1px;\n  -webkit-box-flex: 1;\n      -ms-flex: 1 0 auto;\n          flex: 1 0 auto;\n  display: -webkit-box;\n  display: -ms-flexbox;\n  display: flex;\n}\n", ""]);

// exports
exports.locals = {
	"ComponentButtonPanel": "_1RNZ0i6mGb5tuZtIyVfMtg"
};// style-loader: Adds some css to the DOM by adding a <style> tag

// load the styles
var content = __webpack_require__(462);
if(typeof content === 'string') content = [[module.i, content, '']];
// Prepare cssTransformation
var transform;

var options = {}
options.transform = transform
// add the styles to the DOM
var update = __webpack_require__(61)(content, options);
if(content.locals) module.exports = content.locals;
// Hot Module Replacement
if(false) {}exports = module.exports = __webpack_require__(62)(undefined);
// imports


// module
exports.push([module.i, "._3PBeVVMjtP1D_TP365lf0O {\n  display: -webkit-inline-box;\n  display: -ms-inline-flexbox;\n  display: inline-flex;\n  width: 25%;\n  -webkit-box-flex: 1;\n      -ms-flex: 1 0 auto;\n          flex: 1 0 auto;\n}\n\n._3PBeVVMjtP1D_TP365lf0O._3RipbkdhK4fEog-_LXOVAv {\n  width: 50%;\n}\n\n._3PBeVVMjtP1D_TP365lf0O button {\n  background-color: #e0e0e0;\n  border: 0;\n  font-size: 2rem;\n  margin: 0 1px 0 0;\n  -webkit-box-flex: 1;\n      -ms-flex: 1 0 auto;\n          flex: 1 0 auto;\n  padding: 12px 0;\n}\n\n._3PBeVVMjtP1D_TP365lf0O:last-child button {\n  margin-right: 0;\n}\n\n._3PBeVVMjtP1D_TP365lf0O._3Bq9-w_YJIp3DuE8CfIbgk button {\n  background-color: #f5923e;\n  color: white;\n}\n", ""]);

// exports
exports.locals = {
	"ComponentButton": "_3PBeVVMjtP1D_TP365lf0O",
	"Wide": "_3RipbkdhK4fEog-_LXOVAv",
	"Orange": "_3Bq9-w_YJIp3DuE8CfIbgk"
};// style-loader: Adds some css to the DOM by adding a <style> tag

// load the styles
var content = __webpack_require__(466);
if(typeof content === 'string') content = [[module.i, content, '']];
// Prepare cssTransformation
var transform;

var options = {}
options.transform = transform
// add the styles to the DOM
var update = __webpack_require__(61)(content, options);
if(content.locals) module.exports = content.locals;
// Hot Module Replacement
if(false) {}exports = module.exports = __webpack_require__(62)(undefined);
// imports


// module
exports.push([module.i, "._1TOGUd-rx_A6lxFm06zh0o {\n  background-color: #858694;\n  color: white;\n  text-align: right;\n  font-weight: 200;\n  -webkit-box-flex: 0;\n      -ms-flex: 0 0 auto;\n          flex: 0 0 auto;\n  width: 100%;\n}\n\n._1TOGUd-rx_A6lxFm06zh0o > div {\n  font-size: 2.5rem;\n  padding: 0.2rem 0.7rem 0.1rem 0.5rem;\n}\n", ""]);

// exports
exports.locals = {
	"ComponentDisplay": "_1TOGUd-rx_A6lxFm06zh0o"
};

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _apiFetch = __webpack_require__(200);

var _apiFetch2 = _interopRequireDefault(_apiFetch);

var _effects = __webpack_require__(138);

var _reactRouterRedux = __webpack_require__(37);

var _logBookReview = __webpack_require__(160);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var _marked = /*#__PURE__*/regeneratorRuntime.mark(getStateFromApi),
    _marked2 = /*#__PURE__*/regeneratorRuntime.mark(saga);

exports.default = [saga];

/**
 * It will get all the needed data from the server
 */

function getStateFromApi() {
  return regeneratorRuntime.wrap(function getStateFromApi$(_context2) {
    while (1) {
      switch (_context2.prev = _context2.next) {
        case 0:
          _context2.next = 2;
          return (0, _effects.takeEvery)(_logBookReview.GET_STATE_FROM_API, /*#__PURE__*/regeneratorRuntime.mark(function _callee(action) {
            var result;
            return regeneratorRuntime.wrap(function _callee$(_context) {
              while (1) {
                switch (_context.prev = _context.next) {
                  case 0:
                    _context.next = 2;
                    return (0, _effects.call)(_apiFetch2.default, 'logbook_lines?id=' + action.logbookId);

                  case 2:
                    result = _context.sent;

                    if (!result.ok) {
                      _context.next = 8;
                      break;
                    }

                    _context.next = 6;
                    return (0, _effects.put)((0, _logBookReview.getStateFromApiSuccess)(result.data));

                  case 6:
                    _context.next = 10;
                    break;

                  case 8:
                    _context.next = 10;
                    return (0, _effects.put)((0, _logBookReview.getStateFromApiFail)(result.err));

                  case 10:
                  case 'end':
                    return _context.stop();
                }
              }
            }, _callee, this);
          }));

        case 2:
        case 'end':
          return _context2.stop();
      }
    }
  }, _marked, this);
}

function saga() {
  var forks;
  return regeneratorRuntime.wrap(function saga$(_context3) {
    while (1) {
      switch (_context3.prev = _context3.next) {
        case 0:
          _context3.next = 2;
          return [(0, _effects.fork)(getStateFromApi)];

        case 2:
          forks = _context3.sent;
          _context3.next = 5;
          return (0, _effects.take)(_reactRouterRedux.LOCATION_CHANGE);

        case 5:
          _context3.next = 7;
          return forks.map(function (f) {
            return (0, _effects.cancel)(f);
          });

        case 7:
        case 'end':
          return _context3.stop();
      }
    }
  }, _marked2, this);
}

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _jsx = function () { var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7; return function createRawReactElement(type, props, key, children) { var defaultProps = type && type.defaultProps; var childrenLength = arguments.length - 3; if (!props && childrenLength !== 0) { props = {}; } if (props && defaultProps) { for (var propName in defaultProps) { if (props[propName] === void 0) { props[propName] = defaultProps[propName]; } } } else if (!props) { props = defaultProps || {}; } if (childrenLength === 1) { props.children = children; } else if (childrenLength > 1) { var childArray = Array(childrenLength); for (var i = 0; i < childrenLength; i++) { childArray[i] = arguments[i + 3]; } props.children = childArray; } return { $$typeof: REACT_ELEMENT_TYPE, type: type, key: key === undefined ? null : '' + key, ref: null, props: props, _owner: null }; }; }();

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _react = __webpack_require__(1);

var _react2 = _interopRequireDefault(_react);

var _Card = __webpack_require__(137);

var _Card2 = _interopRequireDefault(_Card);

var _CardTitle = __webpack_require__(112);

var _CardTitle2 = _interopRequireDefault(_CardTitle);

var _CardText = __webpack_require__(87);

var _CardText2 = _interopRequireDefault(_CardText);

var _reactRedux = __webpack_require__(43);

var _reactRouterRedux = __webpack_require__(37);

var _redux = __webpack_require__(88);

var _LogBookTable = __webpack_require__(455);

var _LogBookTable2 = _interopRequireDefault(_LogBookTable);

var _objects = __webpack_require__(199);

var _logBookReview = __webpack_require__(160);

var logBookReviewActions = _interopRequireWildcard(_logBookReview);

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

// Own modules


var _ref = _jsx(_CardTitle2.default, {
  title: 'Detalle'
});

var LogBookReview = function (_React$Component) {
  _inherits(LogBookReview, _React$Component);

  function LogBookReview() {
    _classCallCheck(this, LogBookReview);

    return _possibleConstructorReturn(this, (LogBookReview.__proto__ || Object.getPrototypeOf(LogBookReview)).apply(this, arguments));
  }

  _createClass(LogBookReview, [{
    key: 'componentDidMount',
    value: function componentDidMount() {
      this.props.actions.getStateFromApi(this.props.routeParams.id);
    }
  }, {
    key: 'render',
    value: function render() {
      var _props = this.props,
          routeParams = _props.routeParams,
          changeRoute = _props.changeRoute,
          objects = _props.objects,
          actions = _props.actions;


      return _jsx(_Card2.default, {
        style: { marginBottom: '10px' }
      }, void 0, _ref, _jsx(_CardText2.default, {}, void 0, _jsx(_LogBookTable2.default, {
        objects: objects,
        changeRoute: changeRoute,
        logbookId: this.props.routeParams.id,
        actions: actions
      })));
    }
  }]);

  return LogBookReview;
}(_react2.default.Component);

function select(state) {
  return {
    objects: (0, _objects.reselectObjects)(state)
  };
}

function mapDispatchToProps(dispatch) {
  return {
    actions: (0, _redux.bindActionCreators)(logBookReviewActions, dispatch),
    changeRoute: function changeRoute(url) {
      return dispatch((0, _reactRouterRedux.push)(url));
    },
    dispatch: dispatch
  };
}

exports.default = (0, _reactRedux.connect)(select, mapDispatchToProps)(LogBookReview);

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _jsx = function () { var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7; return function createRawReactElement(type, props, key, children) { var defaultProps = type && type.defaultProps; var childrenLength = arguments.length - 3; if (!props && childrenLength !== 0) { props = {}; } if (props && defaultProps) { for (var propName in defaultProps) { if (props[propName] === void 0) { props[propName] = defaultProps[propName]; } } } else if (!props) { props = defaultProps || {}; } if (childrenLength === 1) { props.children = children; } else if (childrenLength > 1) { var childArray = Array(childrenLength); for (var i = 0; i < childrenLength; i++) { childArray[i] = arguments[i + 3]; } props.children = childArray; } return { $$typeof: REACT_ELEMENT_TYPE, type: type, key: key === undefined ? null : '' + key, ref: null, props: props, _owner: null }; }; }();

// Own modules


var _react = __webpack_require__(1);

var _react2 = _interopRequireDefault(_react);

var _reactRedux = __webpack_require__(43);

var _RadioButton = __webpack_require__(202);

var _logBookReview = __webpack_require__(454);

var _FloatingActionButton = __webpack_require__(158);

var _FloatingActionButton2 = _interopRequireDefault(_FloatingActionButton);

var _modeEdit = __webpack_require__(475);

var _modeEdit2 = _interopRequireDefault(_modeEdit);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var toggleColumns = function toggleColumns(toggleColumn) {
  return toggleColumn === 'showLoss' || toggleColumn === 'showInitialStock' ? 'hidden' : '';
};

/**
 * This component will render the rows of a table structure, readonly. usefull to copy
 * and paste the information
 */
var TableItem = function TableItem(props) {
  var productsLines = props.productsLines,
      toggleColumn = props.toggleColumn,
      logbook = props.logbook,
      name = props.name,
      unit = props.unit,
      id = props.id;


  return _jsx('tr', {}, void 0, _jsx('td', {
    className: toggleColumn === 'showLoss' || toggleColumn === 'showInitialStock' ? 'hidden' : ''
  }, void 0, name), _jsx('td', {
    className: toggleColumn === 'showLoss' ? 'hidden' : ''
  }, void 0, productsLines[id - 1] && (productsLines[id - 1].initialStock ? productsLines[id - 1].initialStock : '')), _jsx('td', {
    className: toggleColumn === 'showInitialStock' ? 'hidden' : ''
  }, void 0, productsLines[id - 1] && (productsLines[id - 1].loss ? productsLines[id - 1].loss : '')));
};

/**
 * This will render the table structure. The children are the `TableItem` component
 */
var Table = function Table(props) {
  var toggleColumn = props.toggleColumn;


  return _jsx('div', {
    className: 'table-responsive'
  }, void 0, _jsx('table', {
    className: 'table table-striped table-bordered'
  }, void 0, _jsx('thead', {}, void 0, _jsx('tr', {}, void 0, _jsx('th', {
    className: toggleColumn === 'showLoss' || toggleColumn === 'showInitialStock' ? 'hidden' : ''
  }, void 0, 'Nombre Insumo'), _jsx('th', {
    className: toggleColumn === 'showLoss' ? 'hidden' : ''
  }, void 0, 'Inventario'), _jsx('th', {
    className: toggleColumn === 'showInitialStock' ? 'hidden' : ''
  }, void 0, 'Merma'))), _jsx('tbody', {}, void 0, props.children)));
};

/**
 * Main component
 */

var _ref = _jsx(_RadioButton.RadioButton, {
  value: 'showAll',
  label: 'Todo'
});

var _ref2 = _jsx(_RadioButton.RadioButton, {
  value: 'showInitialStock',
  label: 'Inventario'
});

var _ref3 = _jsx(_RadioButton.RadioButton, {
  value: 'showLoss',
  label: 'Merma'
});

var _ref4 = _jsx(_modeEdit2.default, {});

var LogBookTable = function LogBookTable(props) {
  var productsLines = props.productsLines,
      toggleColumn = props.toggleColumn,
      changeRoute = props.changeRoute,
      logbookId = props.logbookId,
      actions = props.actions,
      objects = props.objects;


  var logbook = Object.values(objects.logbooks).find(function (lb) {
    return lb.id === Number(logbookId);
  });
  var tableItems = Object.values(objects.products).filter(function (p) {
    return p.logbookKindId === logbook.logbookKindId;
  }).map(function (product) {
    return _jsx(TableItem, {
      productsLines: productsLines,
      toggleColumn: toggleColumn,
      logbook: logbook,
      name: product.name,
      unit: product.unit().name,
      id: product.id
    }, 'product-' + product.id);
  });

  return _jsx('div', {
    className: 'row'
  }, void 0, _jsx('div', {
    className: 'col-lg-12'
  }, void 0, _jsx(_RadioButton.RadioButtonGroup, {
    name: 'shipSpeed',
    defaultSelected: 'showAll',
    style: { marginBottom: '15px' },
    onChange: function onChange(event, value) {
      actions.toggleTableColumn(value);
    }
  }, void 0, _ref, _ref2, _ref3)), _jsx('div', {
    className: 'col-lg-12'
  }, void 0, _jsx(Table, {
    toggleColumn: toggleColumn
  }, void 0, tableItems)), _jsx('div', {
    style: {
      position: 'fixed',
      bottom: 0,
      right: 0,
      marginBottom: '15px',
      marginRight: '15px',
      zIndex: 2
    }
  }, void 0, _jsx(_FloatingActionButton2.default, {
    style: { float: 'right' },
    onClick: function onClick() {
      return changeRoute('/logbooks/' + logbookId);
    }
  }, void 0, _ref4)));
};

exports.default = (0, _reactRedux.connect)(_logBookReview.selectForm)(LogBookTable);

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.selectForm = undefined;

var _reselect = __webpack_require__(136);

var getLogBookState = function getLogBookState(state) {
  return state.get('logBookReview').get('productsLines');
};
var getToggleColumnState = function getToggleColumnState(state) {
  return state.get('logBookReview').get('toggleColumn');
};

var toJSSelector = function toJSSelector(stateSelector) {
  return (0, _reselect.createSelector)(stateSelector, function (state) {
    return state.toJS();
  });
};

/**
 * It will get the state of the `logBookReview`
 *
 * productsLines: {},
 * toggleColumn: 'showAll'
 */
var selectForm = exports.selectForm = (0, _reselect.createStructuredSelector)({
  productsLines: toJSSelector(getLogBookState),
  toggleColumn: getToggleColumnState
});

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _jsx = function () { var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7; return function createRawReactElement(type, props, key, children) { var defaultProps = type && type.defaultProps; var childrenLength = arguments.length - 3; if (!props && childrenLength !== 0) { props = {}; } if (props && defaultProps) { for (var propName in defaultProps) { if (props[propName] === void 0) { props[propName] = defaultProps[propName]; } } } else if (!props) { props = defaultProps || {}; } if (childrenLength === 1) { props.children = children; } else if (childrenLength > 1) { var childArray = Array(childrenLength); for (var i = 0; i < childrenLength; i++) { childArray[i] = arguments[i + 3]; } props.children = childArray; } return { $$typeof: REACT_ELEMENT_TYPE, type: type, key: key === undefined ? null : '' + key, ref: null, props: props, _owner: null }; }; }(); /**
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          * NotFoundPage
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          * This is the page we show when the user visits a url that doesn't have a route
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          */

exports.NotFound = NotFound;

var _react = __webpack_require__(1);

var _react2 = _interopRequireDefault(_react);

var _reactRedux = __webpack_require__(43);

var _reactRouterRedux = __webpack_require__(37);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var _ref = _jsx('article', {}, void 0, 'Page not found');

function NotFound(props) {
  return _ref;
}

// react-redux stuff
function mapDispatchToProps(dispatch) {
  return {
    changeRoute: function changeRoute(url) {
      return dispatch((0, _reactRouterRedux.push)(url));
    }
  };
}

// Wrap the component to inject dispatch and state into it
exports.default = (0, _reactRedux.connect)(null, mapDispatchToProps)(NotFound);