'use strict';

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }

var react = require('react');
var reactNative = require('react-native');
var mapValues = _interopDefault(require('lodash/mapValues'));

function create(styles) {
  return function useStyles() {
    var _useState = react.useState({
      window: reactNative.Dimensions.get('window'),
      screen: reactNative.Dimensions.get('screen')
    }),
        dimensions = _useState[0],
        setDimensions = _useState[1];

    var onChange = react.useCallback(function onChange(_ref) {
      var window = _ref.window,
          screen = _ref.screen;
      setDimensions({
        window: window,
        screen: screen
      });
    }, []);
    react.useEffect(function manageDimensionsEventListeners() {
      reactNative.Dimensions.addEventListener('change', onChange);
      return function () {
        return reactNative.Dimensions.removeEventListener('change', onChange);
      };
    }, []);
    var compiledStyles = react.useMemo(function () {
      return reactNative.StyleSheet.create(mapValues(styles, function (s) {
        return s(dimensions);
      }));
    }, [dimensions]);
    return compiledStyles;
  };
}
var StyleSheet = {
  create: create
};

exports.StyleSheet = StyleSheet;
exports.create = create;
//# sourceMappingURL=react-native-stylehooks.cjs.development.js.map
