text: import * as CommonUtils from './lambda-common-utils-ES5.js';
  import React from 'react';
  import ReactDOMServer from 'react-dom/server';
  
  var LOGGER = null;
  var CONFIG = null;
  
  exports.renderer = function(event, context) {
    try {
      handle(event, context);
    }
    catch (err) {
      var stackTrace = err.stack.replace(/\n/g, '');
      LOGGER.error(`exception | lambda_progress=error | exception_type="${err.code}" | exception_value="${err.message}" | stacktrace="${stackTrace}"`);
    }
  };
  
  function handle(event, context) {
  
    var metaData = CommonUtils.getMetaData(event, context);
    LOGGER = CommonUtils.configureLogger(metaData);
  
    if (CommonUtils.maintenanceModeActive()) {
      LOGGER.info('maintenance_mode_active | lambda_progress=aborting');
      var response = CommonUtils.generateServiceUnavailableResponse();
      context.succeed(response);
      return;
    }
  
    LOGGER.info('starting_lambda | lambda_progress=started');
    CommonUtils.retrieveSessionIdFromCookie(event, metaData);
  
    var alias = metaData.functionAlias;
    if (CONFIG === null || CONFIG.ENVIRONMENT != alias) {
      CommonUtils.getConfig(alias, function (retrievedConfig, err) {
        if (err) {
          context.succeed(CommonUtils.generateResponse(
            CommonUtils.RESPONSE_BODY_INTERNAL_SERVER_ERROR,
            CommonUtils.HTTP_RESPONSE_SERVER_ERROR,
            CommonUtils.CONTENT_TYPE_APPLICATION_JSON_HEADER));
          return;
        }
        CONFIG = retrievedConfig;
        renderHtml(context);
      });
    }
    else {
      LOGGER.info('loaded_config_cached_in_warm_lambda | lambda_progress=in-progress');
      renderHtml(context);
    }
  }
  
  function renderHtml(context) {
    LOGGER.info('rendering_html | lambda_progress=in-progress');
    var incorrectOtpComponent = getIncorrectOtpComponent();
    var ComponentFactory = React.createFactory(incorrectOtpComponent);
    var html = CommonUtils.DOCTYPE_TAG + ReactDOMServer.renderToStaticMarkup(ComponentFactory());
    LOGGER.info('rendered_html | lambda_progress=in-progress');
    var response = CommonUtils.generateResponse(html, CommonUtils.HTTP_RESPONSE_OK, CommonUtils.CONTENT_TYPE_TEXT_HTML_HEADER);
    LOGGER.info('finished_lambda | lambda_progress=finished');
    context.succeed(response);
  }
  
  function getIncorrectOtpComponent() {
    return IncorrectOtp;
  }
  
  class IncorrectOtp extends React.Component {
    render() {
      return (
        <html lang="en-GB">
          <head>
            <meta charSet="utf-8"/>
            <meta httpEquiv="content-type" content="text/html; charset=UTF-8"/>
            <meta name="viewport" content="width=device-width, initial-scale=1"/>
            <meta httpEquiv="x-ua-compatible" content="ie=edge"/>
            <meta httpEquiv="X-Frame-Options" content="deny"/>
            <noscript>
              <style dangerouslySetInnerHTML={{__html: `
                html{display:none;}
              `}} />
              <meta httpEquiv="refresh" content="0.0;url=/nojs/"/>
            </noscript>
            <title>Sorry, we could not accept your security code - {CONFIG.SERVICE_NAME}</title>
  
            <link rel="shortcut icon" type="image/x-icon" href={CONFIG.STATIC_RESOURCES_CDN_URL + '/images/favicon.ico'}/>
            <link rel="apple-touch-icon" href={CONFIG.STATIC_RESOURCES_CDN_URL + '/images/apple-touch-icon.png'}/>
            <link rel="icon" href={CONFIG.STATIC_RESOURCES_CDN_URL + '/images/favicon.png'}/>
            <link rel="image" href={CONFIG.STATIC_RESOURCES_CDN_URL + '/images/logotype-nhs-colour__reverse.png'}/>
            <link rel="stylesheet" type="text/css" href={CONFIG.STATIC_RESOURCES_CDN_URL + '/css/nhsuk.css'} media="screen"/>
          </head>
          <body id="mainBody">
            <div className="skiplinks">
              <div className="skiplinks__inner">
                <a id="skipToContentLink" href="#mainContent" className="skiplinks__link">Skip to main content</a>
              </div>
            </div>
            <header id="header" role="banner">
              <div className="global-header">
                <div className="global-header__inner">
                  <a id="headerImgLink" href={CONFIG.NHSUK_ROOT_DOMAIN} className="global-header__link">
                    <img src={CONFIG.STATIC_RESOURCES_CDN_URL + '/images/logotype-nhs-mono.png'} alt="NHS"/>
                  </a>
                </div>
              </div>
              <div className="page-band">
                <div className="page-section">
                  {CONFIG.SERVICE_NAME}
                </div>
              </div>
            </header>
            <main id="mainContent" role="main">
              <div className="page-section">
                <div className="reading-width">
                  <div className="grid-row">
                    <div className="column--two-thirds">
                      <h1 className="h2">Sorry, we could not accept your security code</h1>
                      <p>Contact us for help making your choice:</p>
                      <p>Telephone: 0300 303 5678
                        <br/>Monday to Friday, 9am to 5pm excluding bank holidays</p>
                    </div>
                  </div>
                </div>
              </div>
            </main>
            <footer role="contentinfo">
              <div className="global-footer">
                <div className="global-footer__inner">
                  <div>
                    <h2 className="util-visuallyhidden">Getting help using the website</h2>
                    <p>
                      <a id="accessibilityStatementFooterLink" target="_blank" rel="noopener noreferrer" href={CONFIG.ACCESSIBILITY_STATEMENT_ENDPOINT}>Accessibility <span className="util-visuallyhidden"> - Page opens in new window</span></a>
                    </p>
                    <h2 className="util-visuallyhidden">Terms and conditions</h2>
                    <ul className="link-list">
                      <li><a id="privacyNoticeFooterLink" target="_blank" rel="noopener noreferrer" href={CONFIG.PRIVACY_NOTICE_ENDPOINT}>Privacy notice <span className="util-visuallyhidden"> - Page opens in new window</span></a></li>
                      <li><a id="termsAndConditionsFooterLink" target="_blank" rel="noopener noreferrer" href={CONFIG.TERMS_AND_CONDITIONS_ENDPOINT}>Terms and conditions <span className="util-visuallyhidden"> - Page opens in new window</span></a></li>
                      <li><a id="cookiePolicyFooterLink" target="_blank" rel="noopener noreferrer" href={CONFIG.COOKIES_POLICY_ENDPOINT}>Cookie policy <span className="util-visuallyhidden"> - Page opens in new window</span></a></li>
                    </ul>
                  </div>
                </div>
              </div>
            </footer>
          </body>
        </html>
      );
    }
  }
  