"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = require("react");
var _jsxRuntime = require("react/jsx-runtime");
// Copyright 1999-2023. Plesk International GmbH. All rights reserved.

/**
 * `Tour` component is used for introducing a new functionality in the product.
 * The component consists of several [Spots](#!/Spot), each of them highlighting a specific feature
 * or element you want to focus user attention on.
 * @since 2.7.0
 */
const Tour = _ref => {
  let {
    current,
    children,
    onClose
  } = _ref;
  const spots = _react.Children.toArray(children);
  if (current !== undefined && current in spots) {
    const spot = spots[current];
    if ( /*#__PURE__*/(0, _react.isValidElement)(spot)) {
      let popup;
      if (onClose && spot.props.popup) {
        popup = {
          ...spot.props.popup,
          onClose
        };
      }
      const props = {
        key: current,
        meta: {
          current,
          total: spots.length
        },
        popup
      };
      return /*#__PURE__*/(0, _react.cloneElement)(spot, props);
    }
  }

  // a workaround for Props & Methods in Styleguidist
  // eslint-disable-next-line no-constant-condition
  if (false) {
    return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {});
  }
  return null;
};
var _default = exports.default = Tour;