text: function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
  
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  
  import getNavigationActionCreators from './routers/getNavigationActionCreators';
  import getChildNavigation from './getChildNavigation';
  import getChildrenNavigationCache from './getChildrenNavigationCache';
  export default function getNavigation(router, state, dispatch, actionSubscribers, getScreenProps, getCurrentNavigation) {
    var actions = router.getActionCreators(state, null);
    var navigation = {
      actions,
      router,
      state,
      dispatch,
      getScreenProps,
      getChildNavigation: childKey => getChildNavigation(navigation, childKey, getCurrentNavigation),
      isFocused: childKey => {
        var {
          routes,
          index
        } = getCurrentNavigation().state;
  
        if (childKey == null || routes[index].key === childKey) {
          return true;
        }
  
        return false;
      },
      addListener: (eventName, handler) => {
        if (eventName !== 'action') {
          return {
            remove: () => {}
          };
        }
  
        actionSubscribers.add(handler);
        return {
          remove: () => {
            actionSubscribers.delete(handler);
          }
        };
      },
      dangerouslyGetParent: () => null,
      _childrenNavigation: getChildrenNavigationCache(getCurrentNavigation())
    };
  
    var actionCreators = _objectSpread({}, getNavigationActionCreators(navigation.state), actions);
  
    Object.keys(actionCreators).forEach(actionName => {
      navigation[actionName] = (...args) => navigation.dispatch(actionCreators[actionName](...args));
    });
    return navigation;
  }
  //# sourceMappingURL=getNavigation.js.map