"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.WidgetNode = void 0;
var _react = _interopRequireDefault(require("react"));
var _react2 = require("@xyflow/react");
var _icons = require("../../shared/utils/icons.utils");
var _common = require("../../shared/constants/common.constants");
var _health_donut = require("../health_donut");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
/*
 * Copyright OpenSearch Contributors
 * SPDX-License-Identifier: Apache-2.0
 */

const ICON_SIZE = 60;
const WidgetNode = props => {
  const {
    data: {
      title,
      subtitle,
      type,
      status,
      isSource,
      isTarget
    }
  } = props;
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
    className: "osd:flex osd:flex-col osd:items-center",
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_health_donut.HealthDonut, {
        metrics: {
          ..._common.DEFAULT_METRICS
        },
        size: ICON_SIZE,
        icon: (0, _icons.getIcon)(type),
        status: status,
        children: [isSource && /*#__PURE__*/(0, _jsxRuntime.jsx)(_react2.Handle, {
          type: "source",
          position: _react2.Position.Right,
          id: "source-right",
          style: {
            opacity: 0
          }
        }), isTarget && /*#__PURE__*/(0, _jsxRuntime.jsx)(_react2.Handle, {
          type: "target",
          position: _react2.Position.Left,
          id: "target-left",
          style: {
            opacity: 0
          }
        })]
      })
    }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
      className: "osd:mt-1 osd:text-center",
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
        className: "osd:font-medium osd:text-xs",
        children: title
      }), subtitle && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
        className: "osd:text-xs osd:text-gray-500",
        children: subtitle || type
      })]
    })]
  });
};

// eslint-disable-next-line import/no-default-export
exports.WidgetNode = WidgetNode;
var _default = exports.default = WidgetNode;