import React, { Component } from 'react';
import {SerialMonitor, BrowserAdressBar, SourceIntensityController} from 'components'
import {
	getObjectById,
	compareStepOptions,
	verifyWiFiAuth
} from 'utils/ioty'
export default class IoTyVLabOutputView extends Component {
	constructor (props) {
		super(props)

		this.infiniteInterval = ''
		this.sensorMin = ''
		this.sensorMax = ''
		this.sensorThreshold = ''
		this.serialMonitorOutputMessage = ''
		this._isMounted = false

		this.defaultMessagesLogEnable = true
		this.initialMessagesLogEnable = true

		this.state = {
			showSourceIntensityChanger : false,
			showPushButton : false,
			showSerialMonitor : false,
			showSerialMonitorWithStdin: true,
			showBrowserAdressBar : false,
			isSimulating : false,
			errorMessage : '',
			successMessage : '',
			serialMonitorInput : '',
			browserAdressBarInput : '',
			stopInterval : false,
			showLoadingBeforeOutput : false
		}

		this.checkCircuit = this.checkCircuit.bind(this)
		this.startCircuitSimulation = this.startCircuitSimulation.bind(this)
		this.showCircuitOutput = this.showCircuitOutput.bind(this)

		this.getComponentOutputPattern = this.getComponentOutputPattern.bind(this)
		this.displayComponentOutputPattern = this.displayComponentOutputPattern.bind(this)

		this.showSerialMonitor = this.showSerialMonitor.bind(this)
		this.showBrowserAdressBar = this.showBrowserAdressBar.bind(this)
		this.serialMonitorInputHandler = this.serialMonitorInputHandler.bind(this)
		this.browserAdressBarHandler = this.browserAdressBarHandler.bind(this)
		this.pushButtonStateChangeHandler = this.pushButtonStateChangeHandler.bind(this)

		/* output patterns utils*/
		this.displayOutputDetail = this.displayOutputDetail.bind(this)
		this.displayOutputDetails = this.displayOutputDetails.bind(this)

		/*output patterns */
		this.showFixedStateOutputPattern = this.showFixedStateOutputPattern.bind(this)
		this.showContinuousStateChangeOutputPattern = this.showContinuousStateChangeOutputPattern.bind(this)
		this.showSensorBasedOutputPattern = this.showSensorBasedOutputPattern.bind(this)
		this.showOutputPatternByUserInput = this.showOutputPatternByUserInput.bind(this)
	}

	componentWillReceiveProps (nextProps) {
		if (this.props.IoTyvLab.thresholdValue !== nextProps.IoTyvLab.thresholdValue || 
			this.props.IoTyvLab.pushButtonState !== nextProps.IoTyvLab.pushButtonState) {
			// console.log('componentWillReceiveProps', nextProps.IoTyvLab.thresholdValue, this.props.IoTyvLab.thresholdValue);
			this.startCircuitSimulation(nextProps)
		}
	}

	componentDidMount() {
		this._isMounted = true
	}

	componentWillUnmount() {
		this._isMounted = false
		clearInterval(this.infiniteInterval)
	}



	checkCircuit () {
		// console.log('Wait, checking circuit', this.state.isSimulating);
		/*$('.circuitError').hide()
		$('.circuitSuccess').hide()*/
		if (this.state.isSimulating) {
			// console.log('showSourceIntensityChanger false');
			/*clearInterval(this.infiniteInterval)
			this.defaultState.stopInterval = true
			this.setState(this.defaultState)*/
			this.setState({
				showSourceIntensityChanger : false
			})
		} else {
			this.setState({
				isSimulating : !this.state.isSimulating,
				showLoadingBeforeOutput : true
			}, function () {
				if (this.state.isSimulating) {
					this.startCircuitSimulation(this.props)
				}
			}.bind(this))
		}
	}

	startCircuitSimulation (props) {
		let {output, userSelectedStepOptions, outputPatterns, thresholdValue, pushButtonState} = props.IoTyvLab
		let utilParam = {
			thresholdValue,
			pushButtonState
		}
		let componentOutputPatternDetails = this.getComponentOutputPattern(output.possibleOutputs, userSelectedStepOptions)
		console.log('componentOutputPatternDetails', componentOutputPatternDetails);
		if (componentOutputPatternDetails !== -1) {
			this.showCircuitOutput(componentOutputPatternDetails, utilParam)
			let outputRequestObject = {},
				userSubmission = {}
			userSubmission.text = 	{
				steps : userSelectedStepOptions,
				vlqStatus : componentOutputPatternDetails.outputStatus
			}
			userSubmission.optionId = -1
			outputRequestObject.metaData = ""
			outputRequestObject.userSubmission = JSON.stringify([userSubmission])
			outputRequestObject.vlqId = 282				//	REMOVE IT WHILE INTEGRATION
			// console.log('final outputRequestObject ', outputRequestObject);
			// props.IoTyActions.evaluateCircuitOutput(outputRequestObject)
		} else {
			// alert ('Error : No such output combination!')
			this.setState({
				errorMessage : output.defaultErrorMessage,
				showLoadingBeforeOutput : false
			}, function () {
				$('.circuitError').show()
			})
		}
	}

	showCircuitOutput (componentOutputPatternDetails, utilParam) {
		let componentOutputPattern = -1
		if (componentOutputPatternDetails !== undefined && componentOutputPatternDetails !== null) {
			if (componentOutputPatternDetails.outputStatus === 'STATUS_SUCCESS') {
				componentOutputPattern = JSON.parse(componentOutputPatternDetails.componentOutputPattern)
				if (componentOutputPattern !== undefined && componentOutputPattern !== null) {
					console.log('componentOutputPattern', componentOutputPattern);
					this.displayComponentOutputPattern(componentOutputPatternDetails.componentOutputPatternType, componentOutputPattern, utilParam)
				}
				this.setState({
					successMessage : componentOutputPatternDetails.outputMessage
				}, function () {
					$('.circuitSuccess').show()
				})
			} else {
				this.setState({
					errorMessage : componentOutputPatternDetails.outputMessage,
					showLoadingBeforeOutput : false
				}, function () {
					$('.circuitError').show()
					// console.log('no such output pattern found!');
				})
			}
		}
	}

	getComponentOutputPattern (possibleOutputs, userSelectedStepOptions) {
		let componentOutputPattern = -1
		if (possibleOutputs !== undefined && possibleOutputs !== null && userSelectedStepOptions !== undefined && userSelectedStepOptions !== null) {
			for (let i=0;i<possibleOutputs.length;i++) {
				let isEqual = true
				for (let j=0;j<possibleOutputs[i].stepOptions.length;j++) {
					if (!compareStepOptions(possibleOutputs[i].stepOptions[j], userSelectedStepOptions[j])) {
						isEqual = false
						break
					}
					// console.log('compareObjects', );
				}
				if (isEqual) {
					return possibleOutputs[i]
				}
				/*if (JSON.stringify(possibleOutputs[i].stepOptions) === JSON.stringify(userSelectedStepOptions)) {
					return possibleOutputs[i]
				}*/
			}
		}
		return componentOutputPattern
	}

	displayComponentOutputPattern (componentOutputPatternType, componentOutputPattern, utilParam) {
		switch (componentOutputPatternType) {
			case 1:
				// this.onOrOffLED(componentOutputPattern)
				this.showFixedStateOutputPattern(componentOutputPattern)
				break
			case 2:
				// this.onAndOffLEDWithGivenTime(componentOutputPattern)
				this.showContinuousStateChangeOutputPattern(componentOutputPattern)
				break
			case 3:
				this.showSensorBasedOutputPattern(componentOutputPattern, utilParam)
				break
			case 4:
				this.showOutputPatternByUserInput(componentOutputPattern)
				break
			default:
				/*this.setState({
					showLoadingBeforeOutput : false,
					isSimulating : false,
					errorMessage : 'Please try again!'
				}, function () {
					$('.circuitSuccess').hide();
					$('.circuitError').show()
				})*/
				break
		}
	}

	displayOutputDetail (outputDetail) {
		// console.log('outputDetail', outputDetail);
		if (outputDetail.hasOwnProperty('messageString') && this._isMounted) {
			this.setState({
				showSerialMonitor : true,
				showSerialMonitorWithStdin : false,
				showLoadingBeforeOutput : false
			}, function () {
				let stdout = document.getElementById('SerialMonitor__STDOUT')
				stdout.innerHTML = stdout.innerHTML + outputDetail.messageString + '\n'
				stdout.scrollTop = stdout.scrollHeight
			})
		}
		if (outputDetail.hasOwnProperty('componentState'))  {
			// console.log('inside componentState');
			let {componentId, componentMultimediaURL} = outputDetail.componentState
			let img = $('#IoTyVLabComponent_'+componentId)
			img.attr('src', outputDetail.componentState.componentMultimediaURL)
		}
	}

	displayOutputDetails (outputDetails) {
		let i=0
		// let stdout = document.getElementById('SerialMonitor__STDOUT')
		let limitedInterval = setInterval(function () {
			if (this.state.stopInterval) {
				clearInterval(limitedInterval)
				// console.log('cleared limitedInterval');
				return
			}
			if (outputDetails[i].hasOwnProperty('messageString') && this._isMounted) {
				this.setState({
					showSerialMonitor : true,
					showSerialMonitorWithStdin : false,
					showLoadingBeforeOutput : false
				}, function () {
					let stdout = document.getElementById('SerialMonitor__STDOUT')
					stdout.innerHTML = stdout.innerHTML + outputDetails[i].messageString + '\n'
					stdout.scrollTop = stdout.scrollHeight
				})
			}
			if (outputDetails[i].hasOwnProperty('componentState')) {
				let {componentId, componentMultimediaURL} = outputDetails[i].componentState
				let img = $('#IoTyVLabComponent_'+componentId)
				img.attr('src', componentMultimediaURL)
			}
			i++
			if (i == outputDetails.length) {
				clearInterval(limitedInterval)
			}
		}.bind(this), outputDetails[i].time)
	}

	//componentOutputPatternType 1
	showFixedStateOutputPattern (componentOutputPattern) {
		if (componentOutputPattern !== undefined && componentOutputPattern !== null) {
			this.displayOutputDetail(componentOutputPattern.outputDetail)
		}
	}

	//componentOutputPatternType 2
	showContinuousStateChangeOutputPattern (componentOutputPattern) {
		if (componentOutputPattern !== undefined && componentOutputPattern !== null) {
			let {outputDetails, repeatCount} = componentOutputPattern
			let switchTime = 0, i = 0, arrayIterationCount = 1
			let limitedInterval, infiniteInterval, totalTime = 0
			for (let i=0;i<outputDetails.length;i++) {
				totalTime += Number(outputDetails[i].time)
			}
			if (repeatCount === -1 ) {
				this.infiniteInterval = setInterval(function () {
					this.showLoadingBeforeOutput = false
					if (this.state.stopInterval) {
						clearInterval(this.infiniteInterval)
						return
					}
					this.displayOutputDetails(outputDetails)
				}.bind(this), totalTime)
			} else {
				limitedInterval = setInterval(function (){  
					this.displayOutputDetails(outputDetails)
					if (repeatCount === 0 ||  arrayIterationCount === repeatCount) {
						clearInterval(limitedInterval)
					}
					arrayIterationCount++
				}.bind(this), totalTime)
			}
		}
	}

	//componentOutputPatternType 3
	showSensorBasedOutputPattern (componentOutputPattern, utilParam) {
		if (componentOutputPattern !== undefined && componentOutputPattern !== null) {
			let thresholdValue, pushButtonState
			if (componentOutputPattern.hasOwnProperty('sensorDetail') && this._isMounted) {
				this.setState({
					showSourceIntensityChanger : componentOutputPattern.hasOwnProperty('sensorDetail'),
					showLoadingBeforeOutput : false
				})
				// this.props.IoTyActions.changeThresholdValue(componentOutputPattern.sensorDetail.defaultSensorValue)
				this.sensorMin = componentOutputPattern.sensorDetail.sensorMin
				this.sensorMax = componentOutputPattern.sensorDetail.sensorMax
				this.sensorThreshold = componentOutputPattern.sensorDetail.sensorThreshold
			}
			let {
				sensorComponentId,
				sensorMin,
				sensorMax,
				sensorThreshold,
				defaultSensorValue
			} = componentOutputPattern.sensorDetail
			let {
				belowThresholdConnectedOutputDetail, aboveThresholdConnectedOutputDetail,
				belowThresholdDisconnectedOutputDetail, aboveThresholdDisconnectedOutputDetail
			} = componentOutputPattern

			

			thresholdValue = utilParam.hasOwnProperty('thresholdValue') ? utilParam.thresholdValue === -1 ? sensorMin : utilParam.thresholdValue  :  sensorMin
			pushButtonState = utilParam.hasOwnProperty('pushButtonState') ? utilParam.pushButtonState : ''

			if (this.initialMessagesLogEnable && componentOutputPattern.hasOwnProperty('initialMessages')) {
				// console.log('initialMessages if');
				let limitedInterval, totalTime = 0,
					arrayIterationCount = 1,
					initialMessages = JSON.parse(componentOutputPattern.initialMessages)
				let {outputDetails, repeatCount} = initialMessages
				// console.log('initialMessages outputDetails', outputDetails);
				for (let i=0;i<outputDetails.length;i++) {
					totalTime += Number(outputDetails[i].time)
				}
				if (repeatCount === -1) {
					// console.log('initialMessages infiniteInterval');
					this.infiniteInterval = setInterval(function () {
						if (this.state.stopInterval) {
							clearInterval(this.infiniteInterval)
							return
						}
						this.displayOutputDetails(outputDetails)
					}.bind(this), totalTime)
				} else if (repeatCount >= 0) {
					limitedInterval = setInterval(function (){  
						this.displayOutputDetails(outputDetails)
						if (repeatCount === 0 ||  arrayIterationCount === repeatCount) {
							clearInterval(limitedInterval)
						}
						arrayIterationCount++
					}.bind(this), totalTime)
				}
				this.initialMessagesLogEnable = false
			}

			if (this.defaultMessagesLogEnable && componentOutputPattern.hasOwnProperty('defaultMessages')) {
				// console.log('defaultMessages if');
				let limitedInterval, totalTime = 0,
					arrayIterationCount = 1,
					defaultMessages = JSON.parse(componentOutputPattern.defaultMessages)
				let {outputDetails, repeatCount} = defaultMessages
				// console.log('defaultMessages outputDetails', outputDetails);
				for (let i=0;i<outputDetails.length;i++) {
					totalTime += Number(outputDetails[i].time)
				}
				if (repeatCount === -1) {
					// console.log('defaultMessages infiniteInterval');
					this.infiniteInterval = setInterval(function () {
						if (this.state.stopInterval) {
							clearInterval(this.infiniteInterval)
							return
						}
						this.displayOutputDetails(outputDetails)
					}.bind(this), totalTime)
				} else if (repeatCount >= 0) {
					limitedInterval = setInterval(function (){  
						this.displayOutputDetails(outputDetails)
						if (repeatCount === 0 ||  arrayIterationCount === repeatCount) {
							clearInterval(limitedInterval)
						}
						arrayIterationCount++
					}.bind(this), totalTime)
				}
				this.defaultMessagesLogEnable = false
			}
			/*if (this.state.showPushButton) {
				pushButtonState = this.props.IoTyvLab.pushButtonState
			}*/
			// console.log('pushButtonState = ', pushButtonState);
			let outputDetail = null
			if (componentOutputPattern.hasOwnProperty('belowThresholdDisconnectedOutputDetail') && componentOutputPattern.hasOwnProperty('aboveThresholdDisconnectedOutputDetail')) {
				//sensor with push button combination
				if (pushButtonState === 'ON') {
					if (thresholdValue > sensorThreshold) {
						outputDetail = aboveThresholdConnectedOutputDetail
						if (outputDetail.hasOwnProperty('replaceCharacter')) {
							outputDetail.messageString = outputDetail.messageString.replace(outputDetail.replaceCharacter, thresholdValue)
							this.displayOutputDetail(outputDetail)
						}
					} else {
						outputDetail = belowThresholdConnectedOutputDetail
						if (outputDetail.hasOwnProperty('replaceCharacter')) {
							outputDetail.messageString = outputDetail.messageString.replace(outputDetail.replaceCharacter, thresholdValue)
							this.displayOutputDetail(outputDetail)
						}
					}
				} else if (pushButtonState === 'OFF') {
					if (thresholdValue > sensorThreshold) {
						outputDetail = aboveThresholdDisconnectedOutputDetail
						if (outputDetail.hasOwnProperty('replaceCharacter')) {
							outputDetail.messageString = outputDetail.messageString.replace(outputDetail.replaceCharacter, thresholdValue)
							this.displayOutputDetail(outputDetail)
						}
					} else {
						outputDetail = belowThresholdDisconnectedOutputDetail
						if (outputDetail.hasOwnProperty('replaceCharacter')) {
							outputDetail.messageString = outputDetail.messageString.replace(outputDetail.replaceCharacter, thresholdValue)
							this.displayOutputDetail(outputDetail)
						}
					}
				}
			} else {
				//only sensor
				if (thresholdValue > sensorThreshold) {
					outputDetail = aboveThresholdConnectedOutputDetail
					if (outputDetail.hasOwnProperty('replaceCharacter')) {
						outputDetail.messageString = outputDetail.messageString.replace(outputDetail.replaceCharacter, thresholdValue)
						this.displayOutputDetail(outputDetail)
					}
				} else {
					outputDetail = belowThresholdConnectedOutputDetail
					if (outputDetail.hasOwnProperty('replaceCharacter')) {
						outputDetail.messageString = outputDetail.messageString.replace(outputDetail.replaceCharacter, thresholdValue)
						this.displayOutputDetail(outputDetail)
					}
				}
			}
		}
	}
	
	//componentOutputPatternType 4
	showOutputPatternByUserInput (componentOutputPattern) {
		if (componentOutputPattern === undefined || componentOutputPattern === null) {
			return
		}
		let {wifiConfig, inputOptions} = componentOutputPattern,
			userInput = '',
			outputPatternByUserInput = null,
			wifiSettings = null
		if (componentOutputPattern.hasOwnProperty('wifiConfig') && this._isMounted) {
			userInput = this.state.browserAdressBarInput.toLowerCase()
			wifiSettings = this.props.IoTyvLab.wifiSettings
			let userSelectedStepOptions = this.props.IoTyvLab.userSelectedStepOptions
			let ssid = getObjectById(userSelectedStepOptions, 'blankId', componentOutputPattern.wifiConfig.wifiSSIDBlankId).blankValue
			let password = getObjectById(userSelectedStepOptions, 'blankId', componentOutputPattern.wifiConfig.wifiPasswordBlankId).blankValue
			let showBrowserAdressBar = false
			if (verifyWiFiAuth(wifiSettings, {ssid, password})) {
				// console.log('wifi auth true');
				this.serialMonitorOutputMessage = componentOutputPattern.wifiConfig['wifiConnectedMessage']
				showBrowserAdressBar = true
			} else {
				// console.log('wifi auth fasle');
				this.serialMonitorOutputMessage = componentOutputPattern.wifiConfig['wifiAuthErrorMessage']
				showBrowserAdressBar = false
			}
			this.setState({
				showBrowserAdressBar : showBrowserAdressBar,
				showSerialMonitor : componentOutputPattern.hasOwnProperty('wifiConfig'),
				showSerialMonitorWithStdin : false
			})
		} else {
			userInput = this.state.serialMonitorInput.toLowerCase()
		}
		// console.log('userInput', userInput, inputOptions);
		if (userInput !== '') {
			let browserContentView = document.getElementById('BrowserContentView__messages')
			outputPatternByUserInput = getObjectById(inputOptions, 'inputValue', userInput)
			// console.log('showOutputPatternByUserInput', outputPatternByUserInput);
			if (outputPatternByUserInput !== -1) {
				browserContentView.innerHTML = outputPatternByUserInput.hasOwnProperty('outputValue') ? outputPatternByUserInput.outputValue : '200 OK'
				let stdout = document.getElementById('SerialMonitor__STDOUT')
				if (wifiSettings !== null && wifiSettings.wifiStatus === 'ON') {
					let {outputPattern, outputPatternType} = outputPatternByUserInput
					this.displayComponentOutputPattern(outputPatternType, JSON.parse(outputPattern), {})
				} else if (wifiSettings !== null && wifiSettings.wifiStatus === 'OFF') {
					stdout.innerHTML = stdout.innerHTML + wifiConfig.wifiDisconnectedMessage + '\n'
					stdout.scrollTop = stdout.scrollHeight
				}
			} else {
				browserContentView.innerHTML = 'Bad request\n'
			}
		}
	}

	serialMonitorInputHandler (serialMonitorInput) {
		if (serialMonitorInput.indexOf('party')!== -1 && this.state.serialMonitorInput.indexOf('party') !== -1) {
			return
		}
		let stopInterval = this.state.serialMonitorInput.indexOf('party') !== -1
		// console.log('stopInterval', stopInterval);
		this.setState({
			serialMonitorInput: serialMonitorInput,
			stopInterval : this.state.serialMonitorInput.indexOf('party') !== -1
		}, function () {
			clearInterval(this.infiniteInterval)
			this.startCircuitSimulation(this.props)
		}.bind(this));
	}

	browserAdressBarHandler (browserAdressBarInput) {
		// console.log('clearInterval', this.infiniteInterval);
		if (browserAdressBarInput.indexOf('party')!== -1 && this.state.browserAdressBarInput.indexOf('party') !== -1) {
			return
		}
		let stopInterval = this.state.browserAdressBarInput.indexOf('party') !== -1
		// console.log('stopInterval', stopInterval);
		this.setState({
			browserAdressBarInput : browserAdressBarInput,
			stopInterval : this.state.browserAdressBarInput.indexOf('party') !== -1
		},function () {
			clearInterval(this.infiniteInterval)
			// console.log('startCircuitSimulation again>!!');
			this.startCircuitSimulation(this.props)
		}.bind(this) );
	}

	pushButtonStateChangeHandler () {
		// console.log('pushButtonState changed');
		this.startCircuitSimulation(this.props)		
	}


	showSerialMonitor () {
		// console.log('OK, Submitting circuit');
		this.setState({
			showSerialMonitor: !this.state.showSerialMonitor
		});
	}
	showBrowserAdressBar () {
		this.setState({
			showBrowserAdressBar: !this.state.showBrowserAdressBar
		});
	}

	render() {
		let SourceIntensityControllerProps = {}
 		SourceIntensityControllerProps.min = this.sensorMin
 		SourceIntensityControllerProps.max = this.sensorMax
 		SourceIntensityControllerProps.value = this.props.IoTyvLab.thresholdValue
 		SourceIntensityControllerProps.step = 10
 		// SourceIntensityControllerProps.onChangeSimulateCircuit = this.startCircuitSimulation
 		SourceIntensityControllerProps.IoTyActions = this.props.IoTyActions
 		// let renderPushButton = <ToggleButton label='Push button' id='pushButtonState' defaultState={this.props.IoTyvLab.pushButtonState} onStateChange={this.pushButtonStateChangeHandler} />
 		/*let className, title
 		if (this.state.isSimulating) {
 			className  = <i className="fa fa-pause fa-2x" aria-hidden="true"></i>
 			title = 'Stop simulation'
 		} else {
 			className = <i className="fa fa-play-circle-o fa-2x" aria-hidden="true"></i>
 			title = 'Check output'
		 }*/
		 console.log('this.state.showLoadingBeforeOutput', this.state.showLoadingBeforeOutput);
		return (
			<div>
				<div className="button text-center">
					<span className="fa-stack fa-lg IoTyVLabOutputOptions" onClick={this.checkCircuit} title='Check output'>
						<i className="fa fa-play-circle-o fa-2x" aria-hidden="true"></i>
					</span>&emsp;
					<span className="fa-stack fa-lg IoTyVLabOutputOptions" onClick={this.showSerialMonitor} title='Serial Monitor'>
					  <i className="fa fa-square fa-stack-2x"></i>
					  <i className="fa fa-terminal fa-stack-1x fa-inverse"></i>
					</span>&emsp;
					<span className="fa-stack fa-lg IoTyVLabOutputOptions" onClick={this.showBrowserAdressBar} title='Browser'>
						<i className="fa fa-chrome fa-2x" aria-hidden="true"></i>
					</span>
				</div><br/>
				{
					this.state.showLoadingBeforeOutput ? <div className='text-center'>
														<span id='showLoadingBeforeOutput' className='loading-dots'>Initializing</span>
													</div> :  null
				}
				{this.state.showSerialMonitor ? <SerialMonitor 
													stdin={this.state.showSerialMonitorWithStdin} 
													serialMonitorInputHandler={this.serialMonitorInputHandler}
													serialMonitorOutputMessage={this.serialMonitorOutputMessage} /> : null}
				{this.state.showBrowserAdressBar ? <BrowserAdressBar browserAdressBarHandler={this.browserAdressBarHandler} /> : null}
				{this.state.showSourceIntensityChanger ? <SourceIntensityController {...SourceIntensityControllerProps} /> : null}
				{/*this.state.showPushButton ? renderPushButton : null*/}
				<div className='circuitSuccess' hidden>
					{!this.state.showLoadingBeforeOutput ? <div><i className="fa fa-check fa-1x" aria-hidden="true"></i>&emsp;<span>{this.state.successMessage}</span></div> : null}
				</div>
				<div className='circuitError' hidden>
					{!this.state.showLoadingBeforeOutput ? <div><i className="fa fa-close fa-1x" aria-hidden="true"></i>&emsp;<span>{this.state.errorMessage}</span></div> : null}
				</div>
			</div>
		);
	}
}
