"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.HealthPage = HealthPage;

var _react = _interopRequireDefault(require("react"));

var _lodash = require("lodash");

var _Layout = require("../components/Layout");

var _TimeRange = require("../components/Dropdown/TimeRange");

var _StandaloneWrapper = require("../components/Dropdown/StandaloneWrapper");

var _CanarySearchBar = require("../components/Canary/CanarySearchBar");

var _Canary = require("../components/Canary");

var _url = require("../components/Canary/url");

var _utils = require("../components/Canary/utils");

var _jsxRuntime = require("react/jsx-runtime");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var getSearchParams = function getSearchParams() {
  return (0, _utils.getParamsFromURL)(window.location.search);
};

function HealthPage(_ref) {
  var _getSearchParams;

  var url = _ref.url;
  var handleSearch = (0, _lodash.debounce)(function (value) {
    (0, _url.updateParams)({
      query: value
    });
  }, 400);
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Layout.SearchLayout, {
    title: /*#__PURE__*/(0, _jsxRuntime.jsx)("h1", {
      className: "text-xl font-semibold",
      children: "Health"
    }),
    extra: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_StandaloneWrapper.DropdownStandaloneWrapper, {
        dropdownElem: /*#__PURE__*/(0, _jsxRuntime.jsx)(_TimeRange.TimeRange, {}),
        defaultValue: _TimeRange.timeRanges[0].value,
        paramKey: "timeRange",
        className: "w-56 mr-2",
        prefix: /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
          children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
            className: "text-xs text-gray-500 mr-2 whitespace-nowrap",
            children: "Time Range:"
          })
        })
      }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_CanarySearchBar.CanarySearchBar, {
        onChange: function onChange(e) {
          return handleSearch(e.target.value);
        },
        onSubmit: function onSubmit(value) {
          return handleSearch(value);
        },
        onClear: function onClear() {
          return handleSearch("");
        },
        className: "",
        inputClassName: "w-full py-2 mb-px",
        inputOuterClassName: "w-80",
        placeholder: "Search by name, description, or endpoint",
        defaultValue: (_getSearchParams = getSearchParams()) === null || _getSearchParams === void 0 ? void 0 : _getSearchParams.query
      })]
    }),
    contentClass: "p-0",
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Canary.Canary, {
      url: url,
      topLayoutOffset: 64,
      hideSearch: true,
      hideTimeRange: true
    })
  });
}