| 
						
						
						
					 | 
					 | 
					@ -1,19 +1,42 @@
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import deindent from '../../../../utils/deindent.js';
 | 
					 | 
					 | 
					 | 
					import deindent from '../../../../utils/deindent.js';
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					export default function addTransitions ( generator, block, state, node, intro, outro ) {
 | 
					 | 
					 | 
					 | 
					export default function addTransitions ( generator, block, state, node, intro, outro ) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						const introName = intro && block.getUniqueName( `${state.name}_intro` );
 | 
					 | 
					 | 
					 | 
						const wrapTransition = generator.helper( 'wrapTransition' );
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						const outroName = outro && block.getUniqueName( `${state.name}_outro` );
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						const introSnippet = intro && intro.expression ? block.contextualise( intro.expression ).snippet : '{}';
 | 
					 | 
					 | 
					 | 
						if ( intro === outro ) {
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							const name = block.getUniqueName( `${state.name}_transition` );
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							const snippet = intro.expression ? block.contextualise( intro.expression ).snippet : '{}';
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						const outroSnippet = outro === intro ?
 | 
					 | 
					 | 
					 | 
							block.addVariable( name );
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							introSnippet :
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							outro && outro.expression ? block.contextualise( outro.expression ).snippet : '{}';
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						const wrapTransition = generator.helper( 'wrapTransition' );
 | 
					 | 
					 | 
					 | 
							const fn = `${generator.alias( 'template' )}.transitions.${intro.name}`;
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							block.builders.intro.addBlock( deindent`
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
								${block.component}._renderHooks.push( function () {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
									if ( !${name} ) ${name} = ${wrapTransition}( ${state.name}, ${fn}, ${snippet}, true, null );
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
									${name}.run( ${name}.t, 1, function () {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
										${block.component}.fire( 'intro.end', { node: ${state.name} });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
									});
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
								});
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							` );
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							block.builders.outro.addBlock( deindent`
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
								${name}.run( ${name}.t, 0, function () {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
									detachNode( ${state.name} );
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
									${block.component}.fire( 'outro.end', { node: ${state.name} });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
									if ( --${block.alias( 'outros' )} === 0 ) ${block.alias( 'outrocallback' )}();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
									${name} = null;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
								});
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							` );
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						else {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							const introName = intro && block.getUniqueName( `${state.name}_intro` );
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							const outroName = outro && block.getUniqueName( `${state.name}_outro` );
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							if ( intro ) {
 | 
					 | 
					 | 
					 | 
							if ( intro ) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								block.addVariable( introName );
 | 
					 | 
					 | 
					 | 
								block.addVariable( introName );
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
								const snippet = intro.expression ? block.contextualise( intro.expression ).snippet : '{}';
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								const fn = `${generator.alias( 'template' )}.transitions.${intro.name}`; // TODO add built-in transitions?
 | 
					 | 
					 | 
					 | 
								const fn = `${generator.alias( 'template' )}.transitions.${intro.name}`; // TODO add built-in transitions?
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -23,16 +46,17 @@ export default function addTransitions ( generator, block, state, node, intro, o
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								block.builders.intro.addBlock( deindent`
 | 
					 | 
					 | 
					 | 
								block.builders.intro.addBlock( deindent`
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									${block.component}._renderHooks.push( function () {
 | 
					 | 
					 | 
					 | 
									${block.component}._renderHooks.push( function () {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									${introName} = ${wrapTransition}( ${state.name}, ${fn}, ${introSnippet}, true, null, function () {
 | 
					 | 
					 | 
					 | 
										${introName} = ${wrapTransition}( ${state.name}, ${fn}, ${snippet}, true, null );
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
										${introName}.run( 0, 1, function () {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
											${block.component}.fire( 'intro.end', { node: ${state.name} });
 | 
					 | 
					 | 
					 | 
											${block.component}.fire( 'intro.end', { node: ${state.name} });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
										});
 | 
					 | 
					 | 
					 | 
										});
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									${generator.helper( 'transitionManager' )}.add( ${introName} );
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									});
 | 
					 | 
					 | 
					 | 
									});
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								` );
 | 
					 | 
					 | 
					 | 
								` );
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							}
 | 
					 | 
					 | 
					 | 
							}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							if ( outro ) {
 | 
					 | 
					 | 
					 | 
							if ( outro ) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								block.addVariable( outroName );
 | 
					 | 
					 | 
					 | 
								block.addVariable( outroName );
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
								const snippet = outro.expression ? block.contextualise( outro.expression ).snippet : '{}';
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								const fn = `${generator.alias( 'template' )}.transitions.${outro.name}`;
 | 
					 | 
					 | 
					 | 
								const fn = `${generator.alias( 'template' )}.transitions.${outro.name}`;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -41,12 +65,13 @@ export default function addTransitions ( generator, block, state, node, intro, o
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								}
 | 
					 | 
					 | 
					 | 
								}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								block.builders.outro.addBlock( deindent`
 | 
					 | 
					 | 
					 | 
								block.builders.outro.addBlock( deindent`
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								${outroName} = ${wrapTransition}( ${state.name}, ${fn}, ${outroSnippet}, false, null, function () {
 | 
					 | 
					 | 
					 | 
									${outroName} = ${wrapTransition}( ${state.name}, ${fn}, ${snippet}, false, null );
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									detachNode( div );
 | 
					 | 
					 | 
					 | 
									${outroName}.run( 1, 0, function () {
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
										detachNode( ${state.name} );
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
										${block.component}.fire( 'outro.end', { node: ${state.name} });
 | 
					 | 
					 | 
					 | 
										${block.component}.fire( 'outro.end', { node: ${state.name} });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
										if ( --${block.alias( 'outros' )} === 0 ) ${block.alias( 'outrocallback' )}();
 | 
					 | 
					 | 
					 | 
										if ( --${block.alias( 'outros' )} === 0 ) ${block.alias( 'outrocallback' )}();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									});
 | 
					 | 
					 | 
					 | 
									});
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								transitionManager.add( ${outroName} );
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								` );
 | 
					 | 
					 | 
					 | 
								` );
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							}
 | 
					 | 
					 | 
					 | 
							}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						}
 | 
					 | 
					 | 
					 | 
						}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					}
 |