'use strict';

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

var _mobileDetect = require('mobile-detect');

var _mobileDetect2 = _interopRequireDefault(_mobileDetect);

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

var DETECT_DEVICE = exports.DETECT_DEVICE = 'DETECT_DEVICE';

function device() {
  var state = arguments.length <= 0 || arguments[0] === undefined ? 'desktop' : arguments[0];
  var action = arguments[1];

  switch (action.type) {
    case 'DETECT_DEVICE':
      var userAgent = action.userAgent;
      if (userAgent) {
        var md = new _mobileDetect2.default(userAgent);
        if (md.tablet()) {
          return 'tablet';
        } else if (md.mobile()) {
          return 'mobile';
        }
      }
      return state;
    default:
      return state;
  }
}

exports.default = device;