d18ec638284763a5d5b6c52296f25554.json 52.3 KB
{"ast":null,"code":"var _interopRequireWildcard=require(\"@babel/runtime/helpers/interopRequireWildcard\");var _interopRequireDefault=require(\"@babel/runtime/helpers/interopRequireDefault\");Object.defineProperty(exports,\"__esModule\",{value:true});exports.default=void 0;var _toConsumableArray2=_interopRequireDefault(require(\"@babel/runtime/helpers/toConsumableArray\"));var _objectSpread2=_interopRequireDefault(require(\"@babel/runtime/helpers/objectSpread\"));var NavigationActions=_interopRequireWildcard(require(\"../NavigationActions\"));var StackActions=_interopRequireWildcard(require(\"./StackActions\"));var _createConfigGetter=_interopRequireDefault(require(\"./createConfigGetter\"));var _getScreenForRouteName=_interopRequireDefault(require(\"./getScreenForRouteName\"));var _StateUtils=_interopRequireDefault(require(\"../StateUtils\"));var _validateRouteConfigMap=_interopRequireDefault(require(\"./validateRouteConfigMap\"));var _invariant=_interopRequireDefault(require(\"../utils/invariant\"));var _KeyGenerator=require(\"./KeyGenerator\");var _pathUtils=require(\"./pathUtils\");function behavesLikePushAction(action){return action.type===NavigationActions.NAVIGATE||action.type===StackActions.PUSH;}var defaultActionCreators=function defaultActionCreators(){return{};};function isResetToRootStack(action){return action.type===StackActions.RESET&&action.key===null;}var _default=function _default(routeConfigs){var stackConfig=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};(0,_validateRouteConfigMap.default)(routeConfigs);var childRouters={};var routeNames=Object.keys(routeConfigs);routeNames.forEach(function(routeName){var routeConfig=routeConfigs[routeName];var screen=routeConfig&&routeConfig.screen?routeConfig.screen:routeConfig;if(screen&&screen.router){childRouters[routeName]=screen.router;}else{childRouters[routeName]=null;}});var initialRouteParams=stackConfig.initialRouteParams;var getCustomActionCreators=stackConfig.getCustomActionCreators||defaultActionCreators;var initialRouteName=stackConfig.initialRouteName||routeNames[0];var initialChildRouter=childRouters[initialRouteName];function getInitialState(action){var route={};var childRouter=childRouters[action.routeName];if(behavesLikePushAction(action)&&childRouter!==undefined){var childState={};if(childRouter!==null){var childAction=action.action||NavigationActions.init({params:action.params});childState=childRouter.getStateForAction(childAction);}return{key:'StackRouterRoot',isTransitioning:false,index:0,routes:[(0,_objectSpread2.default)({params:action.params},childState,{key:action.key||(0,_KeyGenerator.generateKey)(),routeName:action.routeName})]};}if(initialChildRouter){route=initialChildRouter.getStateForAction(NavigationActions.navigate({routeName:initialRouteName,params:initialRouteParams}));}var params=(routeConfigs[initialRouteName].params||route.params||action.params||initialRouteParams)&&(0,_objectSpread2.default)({},routeConfigs[initialRouteName].params||{},route.params||{},action.params||{},initialRouteParams||{});var initialRouteKey=stackConfig.initialRouteKey;route=(0,_objectSpread2.default)({},route,params?{params:params}:{},{routeName:initialRouteName,key:action.key||initialRouteKey||(0,_KeyGenerator.generateKey)()});return{key:'StackRouterRoot',isTransitioning:false,index:0,routes:[route]};}function getParamsForRouteAndAction(routeName,action){var routeConfig=routeConfigs[routeName];if(routeConfig&&routeConfig.params){return(0,_objectSpread2.default)({},routeConfig.params,action.params);}else{return action.params;}}var _createPathParser=(0,_pathUtils.createPathParser)(childRouters,routeConfigs,stackConfig),getPathAndParamsForRoute=_createPathParser.getPathAndParamsForRoute,_getActionForPathAndParams=_createPathParser.getActionForPathAndParams;return{childRouters:childRouters,getComponentForState:function getComponentForState(state){var activeChildRoute=state.routes[state.index];var routeName=activeChildRoute.routeName;if(childRouters[routeName]){return childRouters[routeName].getComponentForState(activeChildRoute);}return(0,_getScreenForRouteName.default)(routeConfigs,routeName);},getComponentForRouteName:function getComponentForRouteName(routeName){return(0,_getScreenForRouteName.default)(routeConfigs,routeName);},getActionCreators:function getActionCreators(route,navStateKey){return(0,_objectSpread2.default)({},getCustomActionCreators(route,navStateKey),{pop:function pop(n,params){return StackActions.pop((0,_objectSpread2.default)({n:n},params));},popToTop:function popToTop(params){return StackActions.popToTop(params);},push:function push(routeName,params,action){return StackActions.push({routeName:routeName,params:params,action:action});},replace:function replace(replaceWith,params,action,newKey){if(typeof replaceWith==='string'){return StackActions.replace({routeName:replaceWith,params:params,action:action,key:route.key,newKey:newKey});}(0,_invariant.default)(typeof replaceWith==='object','Must replaceWith an object or a string');(0,_invariant.default)(params==null,'Params must not be provided to .replace() when specifying an object');(0,_invariant.default)(action==null,'Child action must not be provided to .replace() when specifying an object');(0,_invariant.default)(newKey==null,'Child action must not be provided to .replace() when specifying an object');return StackActions.replace(replaceWith);},reset:function reset(actions,index){return StackActions.reset({actions:actions,index:index==null?actions.length-1:index,key:navStateKey});},dismiss:function dismiss(){return NavigationActions.back({key:navStateKey});}});},getStateForAction:function getStateForAction(action,state){if(!state){return getInitialState(action);}var activeChildRoute=state.routes[state.index];if(!isResetToRootStack(action)&&action.type!==NavigationActions.NAVIGATE){var activeChildRouter=childRouters[activeChildRoute.routeName];if(activeChildRouter){var route=activeChildRouter.getStateForAction(action,activeChildRoute);if(route!==null&&route!==activeChildRoute){return _StateUtils.default.replaceAt(state,activeChildRoute.key,route,action.type===NavigationActions.SET_PARAMS);}}}else if(action.type===NavigationActions.NAVIGATE){for(var _iterator=state.routes.slice().reverse(),_isArray=Array.isArray(_iterator),_i=0,_iterator=_isArray?_iterator:_iterator[typeof Symbol===\"function\"?typeof Symbol===\"function\"?Symbol.iterator:\"@@iterator\":\"@@iterator\"]();;){var _ref;if(_isArray){if(_i>=_iterator.length)break;_ref=_iterator[_i++];}else{_i=_iterator.next();if(_i.done)break;_ref=_i.value;}var _childRoute=_ref;var childRouter=childRouters[_childRoute.routeName];var childAction=action.routeName===_childRoute.routeName&&action.action?action.action:action;if(childRouter){var nextRouteState=childRouter.getStateForAction(childAction,_childRoute);if(nextRouteState===null||nextRouteState!==_childRoute){var newState=_StateUtils.default.replaceAndPrune(state,nextRouteState?nextRouteState.key:_childRoute.key,nextRouteState?nextRouteState:_childRoute);return(0,_objectSpread2.default)({},newState,{isTransitioning:state.index!==newState.index?action.immediate!==true:state.isTransitioning});}}}}if(behavesLikePushAction(action)&&childRouters[action.routeName]!==undefined){var _childRouter=childRouters[action.routeName];var _route;(0,_invariant.default)(action.type!==StackActions.PUSH||action.key==null,'StackRouter does not support key on the push action');var lastRouteIndex=state.routes.findIndex(function(r){if(action.key){return r.key===action.key;}else{return r.routeName===action.routeName;}});if(action.type!==StackActions.PUSH&&lastRouteIndex!==-1){if(state.index===lastRouteIndex&&!action.params){return null;}var routes=state.routes.slice(0,lastRouteIndex+1);if(action.params){var _route2=state.routes[lastRouteIndex];routes[lastRouteIndex]=(0,_objectSpread2.default)({},_route2,{params:(0,_objectSpread2.default)({},_route2.params,action.params)});}return(0,_objectSpread2.default)({},state,{isTransitioning:state.index!==lastRouteIndex?action.immediate!==true:state.isTransitioning,index:lastRouteIndex,routes:routes});}if(_childRouter){var _childAction=action.action||NavigationActions.init({params:getParamsForRouteAndAction(action.routeName,action)});_route=(0,_objectSpread2.default)({params:getParamsForRouteAndAction(action.routeName,action)},_childRouter.getStateForAction(_childAction),{routeName:action.routeName,key:action.key||(0,_KeyGenerator.generateKey)()});}else{_route={params:getParamsForRouteAndAction(action.routeName,action),routeName:action.routeName,key:action.key||(0,_KeyGenerator.generateKey)()};}return(0,_objectSpread2.default)({},_StateUtils.default.push(state,_route),{isTransitioning:action.immediate!==true});}else if(action.type===StackActions.PUSH&&childRouters[action.routeName]===undefined){return state;}if(behavesLikePushAction(action)){var childRouterNames=Object.keys(childRouters);for(var i=0;i<childRouterNames.length;i++){var childRouterName=childRouterNames[i];var _childRouter2=childRouters[childRouterName];if(_childRouter2){var initChildRoute=_childRouter2.getStateForAction(NavigationActions.init());var navigatedChildRoute=_childRouter2.getStateForAction(action,initChildRoute);var routeToPush=null;if(navigatedChildRoute===null){routeToPush=initChildRoute;}else if(navigatedChildRoute!==initChildRoute){routeToPush=navigatedChildRoute;}if(routeToPush){var _route3=(0,_objectSpread2.default)({},routeToPush,{routeName:childRouterName,key:action.key||(0,_KeyGenerator.generateKey)()});return(0,_objectSpread2.default)({},_StateUtils.default.push(state,_route3),{isTransitioning:action.immediate!==true});}}}}if(action.type===StackActions.POP_TO_TOP){if(action.key&&state.key!==action.key){return state;}if(state.index>0){return(0,_objectSpread2.default)({},state,{isTransitioning:action.immediate!==true,index:0,routes:[state.routes[0]]});}return state;}if(action.type===StackActions.REPLACE){var routeIndex;if(action.key===undefined&&state.routes.length){routeIndex=state.routes.length-1;}else{routeIndex=state.routes.findIndex(function(r){return r.key===action.key;});}if(routeIndex!==-1){var _childRouter3=childRouters[action.routeName];var childState={};if(_childRouter3){var _childAction2=action.action||NavigationActions.init({params:getParamsForRouteAndAction(action.routeName,action)});childState=_childRouter3.getStateForAction(_childAction2);}var _routes=(0,_toConsumableArray2.default)(state.routes);_routes[routeIndex]=(0,_objectSpread2.default)({params:getParamsForRouteAndAction(action.routeName,action)},childState,{routeName:action.routeName,key:action.newKey||(0,_KeyGenerator.generateKey)()});return(0,_objectSpread2.default)({},state,{routes:_routes});}}if(action.type===StackActions.COMPLETE_TRANSITION&&(action.key==null||action.key===state.key)&&action.toChildKey===state.routes[state.index].key&&state.isTransitioning){return(0,_objectSpread2.default)({},state,{isTransitioning:false});}if(action.type===NavigationActions.SET_PARAMS){var key=action.key;var lastRoute=state.routes.find(function(route){return route.key===key;});if(lastRoute){var params=(0,_objectSpread2.default)({},lastRoute.params,action.params);var _routes2=(0,_toConsumableArray2.default)(state.routes);_routes2[state.routes.indexOf(lastRoute)]=(0,_objectSpread2.default)({},lastRoute,{params:params});return(0,_objectSpread2.default)({},state,{routes:_routes2});}}if(action.type===StackActions.RESET){if(action.key!=null&&action.key!=state.key){return state;}var newStackActions=action.actions;return(0,_objectSpread2.default)({},state,{routes:newStackActions.map(function(newStackAction){var router=childRouters[newStackAction.routeName];var childState={};if(router){var _childAction3=newStackAction.action||NavigationActions.init({params:getParamsForRouteAndAction(newStackAction.routeName,newStackAction)});childState=router.getStateForAction(_childAction3);}return(0,_objectSpread2.default)({params:getParamsForRouteAndAction(newStackAction.routeName,newStackAction)},childState,{routeName:newStackAction.routeName,key:newStackAction.key||(0,_KeyGenerator.generateKey)()});}),index:action.index});}if(action.type===NavigationActions.BACK||action.type===StackActions.POP){var _key=action.key,n=action.n,immediate=action.immediate;var backRouteIndex=state.index;if(action.type===StackActions.POP&&n!=null){backRouteIndex=Math.max(1,state.index-n+1);}else if(_key){var backRoute=state.routes.find(function(route){return route.key===_key;});backRouteIndex=state.routes.indexOf(backRoute);}if(backRouteIndex>0){return(0,_objectSpread2.default)({},state,{routes:state.routes.slice(0,backRouteIndex),index:backRouteIndex-1,isTransitioning:immediate!==true});}}var keyIndex=action.key?_StateUtils.default.indexOf(state,action.key):-1;for(var _iterator2=state.routes.slice().reverse(),_isArray2=Array.isArray(_iterator2),_i2=0,_iterator2=_isArray2?_iterator2:_iterator2[typeof Symbol===\"function\"?typeof Symbol===\"function\"?Symbol.iterator:\"@@iterator\":\"@@iterator\"]();;){var _ref2;if(_isArray2){if(_i2>=_iterator2.length)break;_ref2=_iterator2[_i2++];}else{_i2=_iterator2.next();if(_i2.done)break;_ref2=_i2.value;}var _childRoute3=_ref2;if(_childRoute3.key===activeChildRoute.key){continue;}if(keyIndex>=0&&_childRoute3.key!==action.key){continue;}var _childRouter5=childRouters[_childRoute3.routeName];if(_childRouter5){var _route4=_childRouter5.getStateForAction(action,_childRoute3);if(_route4===null){return state;}else if(_route4&&_route4!==_childRoute3){return _StateUtils.default.replaceAt(state,_childRoute3.key,_route4,action.preserveFocus||action.type.includes('DRAWER'));}}}return state;},getPathAndParamsForState:function getPathAndParamsForState(state){var route=state.routes[state.index];return getPathAndParamsForRoute(route);},getActionForPathAndParams:function getActionForPathAndParams(path,params){return _getActionForPathAndParams(path,params);},getScreenOptions:(0,_createConfigGetter.default)(routeConfigs,stackConfig.defaultNavigationOptions)};};exports.default=_default;","map":{"version":3,"sources":["StackRouter.js"],"names":["action","NavigationActions","StackActions","defaultActionCreators","stackConfig","validateRouteConfigMap","childRouters","routeNames","Object","routeConfig","routeConfigs","screen","initialRouteParams","getCustomActionCreators","initialRouteName","initialChildRouter","route","childRouter","behavesLikePushAction","childState","childAction","params","key","isTransitioning","index","routes","routeName","initialRouteKey","getPathAndParamsForRoute","getActionForPathAndParams","createPathParser","getComponentForState","activeChildRoute","state","getScreenForRouteName","getComponentForRouteName","getActionCreators","pop","n","popToTop","push","replace","newKey","invariant","reset","actions","dismiss","getStateForAction","getInitialState","isResetToRootStack","activeChildRouter","StateUtils","childRoute","nextRouteState","newState","lastRouteIndex","r","getParamsForRouteAndAction","childRouterNames","i","childRouterName","initChildRoute","navigatedChildRoute","routeToPush","routeIndex","lastRoute","newStackActions","router","newStackAction","immediate","backRouteIndex","Math","backRoute","keyIndex","getPathAndParamsForState","getScreenOptions","createConfigGetter"],"mappings":"sbAAA,+EACA,oEACA,gFACA,sFACA,iEACA,wFACA,qEACA,4CACA,sCAEA,QAAA,CAAA,qBAAA,CAAA,MAAA,CAAuC,CACrC,MACEA,CAAAA,MAAM,CAANA,IAAAA,GAAgBC,iBAAiB,CAAjCD,QAAAA,EACAA,MAAM,CAANA,IAAAA,GAAgBE,YAAY,CAF9B,IAAA,CAMF,IAAMC,CAAAA,qBAAqB,CAArBA,QAAAA,CAAAA,qBAAAA,EAAwB,CAAA,MAAA,EAAA,CAA9B,CAAA,CAEA,QAAA,CAAA,kBAAA,CAAA,MAAA,CAAoC,CAClC,MAAOH,CAAAA,MAAM,CAANA,IAAAA,GAAgBE,YAAY,CAA5BF,KAAAA,EAAsCA,MAAM,CAANA,GAAAA,GAA7C,IAAA,CAGF,C,aAAe,kBAAA,YAAA,CAAoC,CAArBI,GAAAA,CAAAA,WAAqB,CAAA,SAAA,CAAA,MAAA,CAAA,CAAA,EAAA,SAAA,CAAA,CAAA,CAAA,GAAA,SAAA,CAAA,SAAA,CAAA,CAAA,CAAA,CAAP,EAAdA,CAE5BC,oCAAAA,YAAAA,EAEA,GAAMC,CAAAA,YAAY,CAAlB,EAAA,CACA,GAAMC,CAAAA,UAAU,CAAGC,MAAM,CAANA,IAAAA,CAAnB,YAAmBA,CAAnB,CAGAD,UAAU,CAAVA,OAAA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CAE3C,SAKF,IAAIyC,QAAQ,EAARA,CAAAA,EAAiBrB,YAAU,CAAVA,GAAAA,GAAmBpD,MAAM,CAA9C,GAAA,CAAoD,CAClD,SAEF,IAAIiB,CAAAA,aAAW,CAAGX,YAAY,CAAC8C,YAAU,CAAzC,SAA8B,CAA9B,CACA,GAAA,aAAA,CAAiB,CACf,GAAMpC,CAAAA,OAAK,CAAGC,aAAW,CAAXA,iBAAAA,CAAAA,MAAAA,CAAd,YAAcA,CAAd,CAEA,GAAID,OAAK,GAAT,IAAA,CAAoB,CAClB,MAAA,CAAA,KAAA,CADF,CAAA,IAEO,IAAIA,OAAK,EAAIA,OAAK,GAAlB,YAAA,CAAmC,CACxC,MAAOmC,qBAAAA,SAAAA,CAAAA,KAAAA,CAELC,YAAU,CAFLD,GAAAA,CAAAA,OAAAA,CAMLnD,MAAM,CAANA,aAAAA,EAAwBA,MAAM,CAANA,IAAAA,CAAAA,QAAAA,CAN1B,QAM0BA,CANnBmD,CAAP,CASH,CACF,CAED,OAAA,CAAA,KAAA,CA9cG,CAAA,CAidLuB,wBAjdK,CAAA,QAAA,CAAA,wBAAA,CAAA,KAAA,CAid2B,CAC9B,GAAM1D,CAAAA,KAAK,CAAGiB,KAAK,CAALA,MAAAA,CAAaA,KAAK,CAAhC,KAAcA,CAAd,CACA,MAAOL,CAAAA,wBAAwB,CAA/B,KAA+B,CAA/B,CAndG,CAAA,CAsdLC,yBAtdK,CAAA,QAAA,CAAA,yBAAA,CAAA,IAAA,CAAA,MAAA,CAsdmC,CACtC,MAAOA,CAAAA,0BAAyB,CAAA,IAAA,CAAhC,MAAgC,CAAhC,CAvdG,CAAA,CA0dL8C,gBAAgB,CAAEC,gCAAkB,YAAlBA,CAEhBxE,WAAW,CA5df,wBA0doBwE,CA1db,CAAP,CA3GF,C","sourcesContent":["import * as NavigationActions from '../NavigationActions';\nimport * as StackActions from './StackActions';\nimport createConfigGetter from './createConfigGetter';\nimport getScreenForRouteName from './getScreenForRouteName';\nimport StateUtils from '../StateUtils';\nimport validateRouteConfigMap from './validateRouteConfigMap';\nimport invariant from '../utils/invariant';\nimport { generateKey } from './KeyGenerator';\nimport { createPathParser } from './pathUtils';\n\nfunction behavesLikePushAction(action) {\n  return (\n    action.type === NavigationActions.NAVIGATE ||\n    action.type === StackActions.PUSH\n  );\n}\n\nconst defaultActionCreators = () => ({});\n\nfunction isResetToRootStack(action) {\n  return action.type === StackActions.RESET && action.key === null;\n}\n\nexport default (routeConfigs, stackConfig = {}) => {\n  // Fail fast on invalid route definitions\n  validateRouteConfigMap(routeConfigs);\n\n  const childRouters = {};\n  const routeNames = Object.keys(routeConfigs);\n\n  // Loop through routes and find child routers\n  routeNames.forEach(routeName => {\n    // We're not using `getScreenForRouteName` here to preserve the lazy loading\n    // behaviour of routes. This means that routes with child routers must be\n    // defined using a component directly or with an object with a screen prop.\n    const routeConfig = routeConfigs[routeName];\n    const screen =\n      routeConfig && routeConfig.screen ? routeConfig.screen : routeConfig;\n    if (screen && screen.router) {\n      // If it has a router it's a navigator.\n      childRouters[routeName] = screen.router;\n    } else {\n      // If it doesn't have router it's an ordinary React component.\n      childRouters[routeName] = null;\n    }\n  });\n\n  const { initialRouteParams } = stackConfig;\n  const getCustomActionCreators =\n    stackConfig.getCustomActionCreators || defaultActionCreators;\n\n  const initialRouteName = stackConfig.initialRouteName || routeNames[0];\n\n  const initialChildRouter = childRouters[initialRouteName];\n\n  function getInitialState(action) {\n    let route = {};\n    const childRouter = childRouters[action.routeName];\n\n    // This is a push-like action, and childRouter will be a router or null if we are responsible for this routeName\n    if (behavesLikePushAction(action) && childRouter !== undefined) {\n      let childState = {};\n      // The router is null for normal leaf routes\n      if (childRouter !== null) {\n        const childAction =\n          action.action || NavigationActions.init({ params: action.params });\n        childState = childRouter.getStateForAction(childAction);\n      }\n\n      return {\n        key: 'StackRouterRoot',\n        isTransitioning: false,\n        index: 0,\n        routes: [\n          {\n            params: action.params,\n            ...childState,\n            key: action.key || generateKey(),\n            routeName: action.routeName,\n          },\n        ],\n      };\n    }\n\n    if (initialChildRouter) {\n      route = initialChildRouter.getStateForAction(\n        NavigationActions.navigate({\n          routeName: initialRouteName,\n          params: initialRouteParams,\n        })\n      );\n    }\n    const params = (routeConfigs[initialRouteName].params ||\n      route.params ||\n      action.params ||\n      initialRouteParams) && {\n      ...(routeConfigs[initialRouteName].params || {}),\n      ...(route.params || {}),\n      ...(action.params || {}),\n      ...(initialRouteParams || {}),\n    };\n    const { initialRouteKey } = stackConfig;\n    route = {\n      ...route,\n      ...(params ? { params } : {}),\n      routeName: initialRouteName,\n      key: action.key || (initialRouteKey || generateKey()),\n    };\n    return {\n      key: 'StackRouterRoot',\n      isTransitioning: false,\n      index: 0,\n      routes: [route],\n    };\n  }\n\n  function getParamsForRouteAndAction(routeName, action) {\n    let routeConfig = routeConfigs[routeName];\n    if (routeConfig && routeConfig.params) {\n      return { ...routeConfig.params, ...action.params };\n    } else {\n      return action.params;\n    }\n  }\n\n  const {\n    getPathAndParamsForRoute,\n    getActionForPathAndParams,\n  } = createPathParser(childRouters, routeConfigs, stackConfig);\n\n  return {\n    childRouters,\n\n    getComponentForState(state) {\n      const activeChildRoute = state.routes[state.index];\n      const { routeName } = activeChildRoute;\n      if (childRouters[routeName]) {\n        return childRouters[routeName].getComponentForState(activeChildRoute);\n      }\n      return getScreenForRouteName(routeConfigs, routeName);\n    },\n\n    getComponentForRouteName(routeName) {\n      return getScreenForRouteName(routeConfigs, routeName);\n    },\n\n    getActionCreators(route, navStateKey) {\n      return {\n        ...getCustomActionCreators(route, navStateKey),\n        pop: (n, params) =>\n          StackActions.pop({\n            n,\n            ...params,\n          }),\n        popToTop: params => StackActions.popToTop(params),\n        push: (routeName, params, action) =>\n          StackActions.push({\n            routeName,\n            params,\n            action,\n          }),\n        replace: (replaceWith, params, action, newKey) => {\n          if (typeof replaceWith === 'string') {\n            return StackActions.replace({\n              routeName: replaceWith,\n              params,\n              action,\n              key: route.key,\n              newKey,\n            });\n          }\n          invariant(\n            typeof replaceWith === 'object',\n            'Must replaceWith an object or a string'\n          );\n          invariant(\n            params == null,\n            'Params must not be provided to .replace() when specifying an object'\n          );\n          invariant(\n            action == null,\n            'Child action must not be provided to .replace() when specifying an object'\n          );\n          invariant(\n            newKey == null,\n            'Child action must not be provided to .replace() when specifying an object'\n          );\n          return StackActions.replace(replaceWith);\n        },\n        reset: (actions, index) =>\n          StackActions.reset({\n            actions,\n            index: index == null ? actions.length - 1 : index,\n            key: navStateKey,\n          }),\n        dismiss: () =>\n          NavigationActions.back({\n            key: navStateKey,\n          }),\n      };\n    },\n\n    getStateForAction(action, state) {\n      // Set up the initial state if needed\n      if (!state) {\n        return getInitialState(action);\n      }\n\n      const activeChildRoute = state.routes[state.index];\n\n      if (\n        !isResetToRootStack(action) &&\n        action.type !== NavigationActions.NAVIGATE\n      ) {\n        // Let the active child router handle the action\n        const activeChildRouter = childRouters[activeChildRoute.routeName];\n        if (activeChildRouter) {\n          const route = activeChildRouter.getStateForAction(\n            action,\n            activeChildRoute\n          );\n          if (route !== null && route !== activeChildRoute) {\n            return StateUtils.replaceAt(\n              state,\n              activeChildRoute.key,\n              route,\n              // the following tells replaceAt to NOT change the index to this route for the setParam action, because people don't expect param-setting actions to switch the active route\n              action.type === NavigationActions.SET_PARAMS\n            );\n          }\n        }\n      } else if (action.type === NavigationActions.NAVIGATE) {\n        // Traverse routes from the top of the stack to the bottom, so the\n        // active route has the first opportunity, then the one before it, etc.\n\n        for (let childRoute of state.routes.slice().reverse()) {\n          let childRouter = childRouters[childRoute.routeName];\n          let childAction =\n            action.routeName === childRoute.routeName && action.action\n              ? action.action\n              : action;\n\n          if (childRouter) {\n            const nextRouteState = childRouter.getStateForAction(\n              childAction,\n              childRoute\n            );\n\n            if (nextRouteState === null || nextRouteState !== childRoute) {\n              const newState = StateUtils.replaceAndPrune(\n                state,\n                nextRouteState ? nextRouteState.key : childRoute.key,\n                nextRouteState ? nextRouteState : childRoute\n              );\n              return {\n                ...newState,\n                isTransitioning:\n                  state.index !== newState.index\n                    ? action.immediate !== true\n                    : state.isTransitioning,\n              };\n            }\n          }\n        }\n      }\n\n      // Handle push and navigate actions. This must happen after the focused\n      // child router has had a chance to handle the action.\n      if (\n        behavesLikePushAction(action) &&\n        childRouters[action.routeName] !== undefined // undefined means it's not a childRouter or a screen\n      ) {\n        const childRouter = childRouters[action.routeName];\n        let route;\n\n        invariant(\n          action.type !== StackActions.PUSH || action.key == null,\n          'StackRouter does not support key on the push action'\n        );\n\n        // Before pushing a new route we first try to find one in the existing route stack\n        // More information on this: https://github.com/react-navigation/rfcs/blob/master/text/0004-less-pushy-navigate.md\n        const lastRouteIndex = state.routes.findIndex(r => {\n          if (action.key) {\n            return r.key === action.key;\n          } else {\n            return r.routeName === action.routeName;\n          }\n        });\n\n        // An instance of this route exists already and we're dealing with a navigate action\n        if (action.type !== StackActions.PUSH && lastRouteIndex !== -1) {\n          // If index is unchanged and params are not being set, leave state identity intact\n          if (state.index === lastRouteIndex && !action.params) {\n            return null;\n          }\n\n          // Remove the now unused routes at the tail of the routes array\n          const routes = state.routes.slice(0, lastRouteIndex + 1);\n\n          // Apply params if provided, otherwise leave route identity intact\n          if (action.params) {\n            const route = state.routes[lastRouteIndex];\n            routes[lastRouteIndex] = {\n              ...route,\n              params: {\n                ...route.params,\n                ...action.params,\n              },\n            };\n          }\n          // Return state with new index. Change isTransitioning only if index has changed\n          return {\n            ...state,\n            isTransitioning:\n              state.index !== lastRouteIndex\n                ? action.immediate !== true\n                : state.isTransitioning,\n            index: lastRouteIndex,\n            routes,\n          };\n        }\n\n        if (childRouter) {\n          // Delegate to the child router with the given action, or init it\n          const childAction =\n            action.action ||\n            NavigationActions.init({\n              params: getParamsForRouteAndAction(action.routeName, action),\n            });\n          route = {\n            params: getParamsForRouteAndAction(action.routeName, action),\n            // note(brentvatne): does it make sense to wipe out the params\n            // here? or even to add params at all? need more info about what\n            // this solves\n            ...childRouter.getStateForAction(childAction),\n            routeName: action.routeName,\n            key: action.key || generateKey(),\n          };\n        } else {\n          // Create the route from scratch\n          route = {\n            params: getParamsForRouteAndAction(action.routeName, action),\n            routeName: action.routeName,\n            key: action.key || generateKey(),\n          };\n        }\n        return {\n          ...StateUtils.push(state, route),\n          isTransitioning: action.immediate !== true,\n        };\n      } else if (\n        action.type === StackActions.PUSH &&\n        childRouters[action.routeName] === undefined\n      ) {\n        // Return the state identity to bubble the action up\n        return state;\n      }\n\n      // Handle navigation to other child routers that are not yet pushed\n      if (behavesLikePushAction(action)) {\n        const childRouterNames = Object.keys(childRouters);\n        for (let i = 0; i < childRouterNames.length; i++) {\n          const childRouterName = childRouterNames[i];\n          const childRouter = childRouters[childRouterName];\n          if (childRouter) {\n            // For each child router, start with a blank state\n            const initChildRoute = childRouter.getStateForAction(\n              NavigationActions.init()\n            );\n            // Then check to see if the router handles our navigate action\n            const navigatedChildRoute = childRouter.getStateForAction(\n              action,\n              initChildRoute\n            );\n            let routeToPush = null;\n            if (navigatedChildRoute === null) {\n              // Push the route if the router has 'handled' the action and returned null\n              routeToPush = initChildRoute;\n            } else if (navigatedChildRoute !== initChildRoute) {\n              // Push the route if the state has changed in response to this navigation\n              routeToPush = navigatedChildRoute;\n            }\n            if (routeToPush) {\n              const route = {\n                ...routeToPush,\n                routeName: childRouterName,\n                key: action.key || generateKey(),\n              };\n              return {\n                ...StateUtils.push(state, route),\n                isTransitioning: action.immediate !== true,\n              };\n            }\n          }\n        }\n      }\n\n      // Handle pop-to-top behavior. Make sure this happens after children have had a chance to handle the action, so that the inner stack pops to top first.\n      if (action.type === StackActions.POP_TO_TOP) {\n        // Refuse to handle pop to top if a key is given that doesn't correspond\n        // to this router\n        if (action.key && state.key !== action.key) {\n          return state;\n        }\n\n        // If we're already at the top, then we return the state with a new\n        // identity so that the action is handled by this router.\n        if (state.index > 0) {\n          return {\n            ...state,\n            isTransitioning: action.immediate !== true,\n            index: 0,\n            routes: [state.routes[0]],\n          };\n        }\n        return state;\n      }\n\n      // Handle replace action\n      if (action.type === StackActions.REPLACE) {\n        let routeIndex;\n\n        // If the key param is undefined, set the index to the last route in the stack\n        if (action.key === undefined && state.routes.length) {\n          routeIndex = state.routes.length - 1;\n        } else {\n          routeIndex = state.routes.findIndex(r => r.key === action.key);\n        }\n\n        // Only replace if the key matches one of our routes\n        if (routeIndex !== -1) {\n          const childRouter = childRouters[action.routeName];\n          let childState = {};\n          if (childRouter) {\n            const childAction =\n              action.action ||\n              NavigationActions.init({\n                params: getParamsForRouteAndAction(action.routeName, action),\n              });\n            childState = childRouter.getStateForAction(childAction);\n          }\n          const routes = [...state.routes];\n          routes[routeIndex] = {\n            params: getParamsForRouteAndAction(action.routeName, action),\n            // merge the child state in this order to allow params override\n            ...childState,\n            routeName: action.routeName,\n            key: action.newKey || generateKey(),\n          };\n          return { ...state, routes };\n        }\n      }\n\n      // Update transitioning state\n      if (\n        action.type === StackActions.COMPLETE_TRANSITION &&\n        (action.key == null || action.key === state.key) &&\n        action.toChildKey === state.routes[state.index].key &&\n        state.isTransitioning\n      ) {\n        return {\n          ...state,\n          isTransitioning: false,\n        };\n      }\n\n      if (action.type === NavigationActions.SET_PARAMS) {\n        const key = action.key;\n        const lastRoute = state.routes.find(route => route.key === key);\n        if (lastRoute) {\n          const params = {\n            ...lastRoute.params,\n            ...action.params,\n          };\n          const routes = [...state.routes];\n          routes[state.routes.indexOf(lastRoute)] = {\n            ...lastRoute,\n            params,\n          };\n          return {\n            ...state,\n            routes,\n          };\n        }\n      }\n\n      if (action.type === StackActions.RESET) {\n        // Only handle reset actions that are unspecified or match this state key\n        if (action.key != null && action.key != state.key) {\n          // Deliberately use != instead of !== so we can match null with\n          // undefined on either the state or the action\n          return state;\n        }\n        const newStackActions = action.actions;\n\n        return {\n          ...state,\n          routes: newStackActions.map(newStackAction => {\n            const router = childRouters[newStackAction.routeName];\n\n            let childState = {};\n\n            if (router) {\n              const childAction =\n                newStackAction.action ||\n                NavigationActions.init({\n                  params: getParamsForRouteAndAction(\n                    newStackAction.routeName,\n                    newStackAction\n                  ),\n                });\n\n              childState = router.getStateForAction(childAction);\n            }\n\n            return {\n              params: getParamsForRouteAndAction(\n                newStackAction.routeName,\n                newStackAction\n              ),\n              ...childState,\n              routeName: newStackAction.routeName,\n              key: newStackAction.key || generateKey(),\n            };\n          }),\n          index: action.index,\n        };\n      }\n\n      if (\n        action.type === NavigationActions.BACK ||\n        action.type === StackActions.POP\n      ) {\n        const { key, n, immediate } = action;\n        let backRouteIndex = state.index;\n        if (action.type === StackActions.POP && n != null) {\n          // determine the index to go back *from*. In this case, n=1 means to go\n          // back from state.index, as if it were a normal \"BACK\" action\n          backRouteIndex = Math.max(1, state.index - n + 1);\n        } else if (key) {\n          const backRoute = state.routes.find(route => route.key === key);\n          backRouteIndex = state.routes.indexOf(backRoute);\n        }\n\n        if (backRouteIndex > 0) {\n          return {\n            ...state,\n            routes: state.routes.slice(0, backRouteIndex),\n            index: backRouteIndex - 1,\n            isTransitioning: immediate !== true,\n          };\n        }\n      }\n\n      // By this point in the router's state handling logic, we have handled the behavior of the active route, and handled any stack actions.\n      // If we haven't returned by now, we should allow non-active child routers to handle this action, and switch to that index if the child state (route) does change..\n\n      const keyIndex = action.key ? StateUtils.indexOf(state, action.key) : -1;\n\n      // Traverse routes from the top of the stack to the bottom, so the\n      // active route has the first opportunity, then the one before it, etc.\n      for (let childRoute of state.routes.slice().reverse()) {\n        if (childRoute.key === activeChildRoute.key) {\n          // skip over the active child because we let it attempt to handle the action earlier\n          continue;\n        }\n        // If a key is provided and in routes state then let's use that\n        // knowledge to skip extra getStateForAction calls on other child\n        // routers\n        if (keyIndex >= 0 && childRoute.key !== action.key) {\n          continue;\n        }\n        let childRouter = childRouters[childRoute.routeName];\n        if (childRouter) {\n          const route = childRouter.getStateForAction(action, childRoute);\n\n          if (route === null) {\n            return state;\n          } else if (route && route !== childRoute) {\n            return StateUtils.replaceAt(\n              state,\n              childRoute.key,\n              route,\n              // People don't expect these actions to switch the active route\n              // TODO: We should switch to action.preserveFocus: true for drawer in future\n              action.preserveFocus || action.type.includes('DRAWER')\n            );\n          }\n        }\n      }\n\n      return state;\n    },\n\n    getPathAndParamsForState(state) {\n      const route = state.routes[state.index];\n      return getPathAndParamsForRoute(route);\n    },\n\n    getActionForPathAndParams(path, params) {\n      return getActionForPathAndParams(path, params);\n    },\n\n    getScreenOptions: createConfigGetter(\n      routeConfigs,\n      stackConfig.defaultNavigationOptions\n    ),\n  };\n};\n"]},"metadata":{},"sourceType":"script"}