import React, { forwardRef } from "react";
import { IconClose } from "../../../_Icon";
import cls from "classnames";
import { base as viewCSS } from "./variations/_view/base";
import { base as sizeCSS } from "./variations/_size/base";
import { CardText, CloseButton, Description, Dot, DotsContainer, Title, TourCard, Img, Controls, ActionButtonsContainer, SkipButtonContainer, CardBody } from "./Card.styles";
import { classes } from "./Card.tokens";
export const tourCardRoot = (Root)=>/*#__PURE__*/ forwardRef(({ view, size, image, title, description, orientation = 'horizontal', showPagination = true, stepCurrent = 0, stepLength = 0, actionButtons, skipButton, showClose = true, goToStep, onClose, style, className, ...rest }, outerRef)=>{
        // Если показан только текст, то к нему добавляется отступ снизу для компенсации.
        const onlyText = !showPagination && !actionButtons && !skipButton;
        const dotOnClick = (index)=>{
            if (goToStep) {
                goToStep(index);
            }
        };
        return /*#__PURE__*/ React.createElement(Root, {
            ref: outerRef,
            view: view,
            size: size,
            ...rest
        }, /*#__PURE__*/ React.createElement(TourCard, {
            className: cls(className, classes.card),
            style: style,
            orientation: orientation
        }, showClose && /*#__PURE__*/ React.createElement(CloseButton, {
            onClick: onClose
        }, /*#__PURE__*/ React.createElement(IconClose, {
            size: "xs",
            color: "inherit"
        })), image && /*#__PURE__*/ React.createElement(Img, {
            ...image,
            orientation: orientation
        }), /*#__PURE__*/ React.createElement(CardBody, {
            orientation: orientation
        }, /*#__PURE__*/ React.createElement(CardText, {
            onlyText: onlyText
        }, /*#__PURE__*/ React.createElement(Title, {
            className: classes.title
        }, title), /*#__PURE__*/ React.createElement(Description, {
            className: classes.description
        }, description)), /*#__PURE__*/ React.createElement(Controls, {
            orientation: orientation
        }, showPagination && /*#__PURE__*/ React.createElement(DotsContainer, {
            orientation: orientation,
            className: classes.pagination
        }, Array(stepLength).fill(null).map((_, index)=>/*#__PURE__*/ React.createElement(Dot, {
                key: index,
                isActive: stepCurrent === index,
                onClick: ()=>dotOnClick(index)
            }))), actionButtons && /*#__PURE__*/ React.createElement(ActionButtonsContainer, {
            orientation: orientation,
            className: classes.actionButtons
        }, actionButtons), skipButton && /*#__PURE__*/ React.createElement(SkipButtonContainer, {
            orientation: orientation,
            className: classes.skipButton
        }, skipButton)))));
    });
export const tourCardConfig = {
    name: 'Tour',
    tag: 'div',
    layout: tourCardRoot,
    base: '',
    variations: {
        view: {
            css: viewCSS
        },
        size: {
            css: sizeCSS
        }
    },
    defaults: {
        view: 'default',
        size: 's'
    }
};
