"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.agentStatusCheckInstruction = agentStatusCheckInstruction;
var _i18n = require("@kbn/i18n");
var _eui = require("@elastic/eui");
var _react = _interopRequireDefault(require("react"));
/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License
 * 2.0; you may not use this file except in compliance with the Elastic License
 * 2.0.
 */

function AgentStatusWarningCallout() {
  return /*#__PURE__*/_react.default.createElement(_eui.EuiCallOut, {
    color: "warning",
    "data-test-subj": "agentStatusWarningCallout"
  }, _i18n.i18n.translate('xpack.apm.onboarding.agentStatus.warning.calloutMessage', {
    defaultMessage: 'No data has been received from agents yet'
  }));
}
function AgentStatusSuccessCallout() {
  return /*#__PURE__*/_react.default.createElement(_eui.EuiCallOut, {
    color: "success",
    "data-test-subj": "agentStatusSuccessCallout"
  }, _i18n.i18n.translate('xpack.apm.onboarding.agentStatus.success.calloutMessage', {
    defaultMessage: 'Data successfully received from one or more agents'
  }));
}
function agentStatusCheckInstruction({
  checkAgentStatus,
  agentStatus,
  agentStatusLoading
}) {
  let status = 'incomplete';
  let statusCallout = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
  // Explicit false check required as this value can be null initially. API returns true/false based on data present
  if (agentStatus === false) {
    status = 'warning';
    statusCallout = /*#__PURE__*/_react.default.createElement(AgentStatusWarningCallout, null);
  }
  if (agentStatus) {
    status = 'complete';
    statusCallout = /*#__PURE__*/_react.default.createElement(AgentStatusSuccessCallout, null);
  }
  return {
    title: _i18n.i18n.translate('xpack.apm.onboarding.agentStatusCheck.title', {
      defaultMessage: 'Agent status'
    }),
    children: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_eui.EuiMarkdownFormat, null, _i18n.i18n.translate('xpack.apm.onboarding.agentStatusCheck.textPre', {
      defaultMessage: 'Make sure your application is running and the agents are sending data.'
    })), /*#__PURE__*/_react.default.createElement(_eui.EuiSpacer, null), /*#__PURE__*/_react.default.createElement(_eui.EuiButton, {
      "data-test-subj": "checkAgentStatus",
      onClick: checkAgentStatus,
      isLoading: agentStatusLoading
    }, _i18n.i18n.translate('xpack.apm.onboarding.agentStatus.check', {
      defaultMessage: 'Check Agent Status'
    })), /*#__PURE__*/_react.default.createElement(_eui.EuiSpacer, null), statusCallout),
    status
  };
}