"use strict";
exports.__esModule = true;
exports.TestimonialBlockCard = exports.cnTestimonialBlockCard = void 0;
var tslib_1 = require("tslib");
// @ts-nocheck
require("./TestimonialBlockCard.css");
var react_1 = (0, tslib_1.__importDefault)(require("react"));
var IconClose_1 = require("../../icons/IconClose/IconClose");
var IconPlay_1 = require("../../icons/IconPlay/IconPlay");
var IconYouTube_1 = require("../../icons/IconYouTube/IconYouTube");
var bem_1 = require("../../utils/bem");
var PropsWithAsAttributes_1 = require("../../utils/types/PropsWithAsAttributes");
var Button_1 = require("../Button/Button");
var usePropsHandler_1 = require("../EventInterceptor/usePropsHandler");
var Modal_1 = require("../Modal/Modal");
var Mq_1 = require("../Mq/Mq");
var Picture_1 = require("../Picture/Picture");
var Typography_1 = require("../Typography/Typography");
exports.cnTestimonialBlockCard = (0, bem_1.cn)('TestimonialBlockCard');
exports.TestimonialBlockCard = (0, PropsWithAsAttributes_1.forwardRefWithAs)(function (props, ref) {
    var _a = (0, tslib_1.__read)(react_1["default"].useState(false), 2), isModalOpen = _a[0], setIsModalOpen = _a[1];
    var _b = (0, usePropsHandler_1.usePropsHandler)((0, exports.cnTestimonialBlockCard)(), props), title = _b.title, _c = _b.buttonIcon, buttonIcon = _c === void 0 ? IconYouTube_1.IconYouTube : _c, text = _b.text, linkText = _b.linkText, video = _b.video;
    return (react_1["default"].createElement(react_1["default"].Fragment, null,
        react_1["default"].createElement("div", { className: (0, exports.cnTestimonialBlockCard)({}) },
            video.picture && Object.keys(video.picture).length > 0 && (react_1["default"].createElement("div", { className: (0, exports.cnTestimonialBlockCard)('Left') },
                react_1["default"].createElement("div", { className: (0, exports.cnTestimonialBlockCard)('Picture') },
                    react_1["default"].createElement(Mq_1.Mq, { query: "--tablet-min" },
                        react_1["default"].createElement(Button_1.Button, { view: "primary", form: "circle", size: '3xxl', iconSize: 'm', iconRight: IconPlay_1.IconPlay, onlyIcon: true, className: (0, exports.cnTestimonialBlockCard)('Picture-Button'), onClick: function () { return setIsModalOpen(true); } })),
                    react_1["default"].createElement(Mq_1.Mq, { query: "--mobile" },
                        react_1["default"].createElement(Button_1.Button, { view: "primary", form: "circle", size: 'xxl', iconSize: 'm', iconRight: IconPlay_1.IconPlay, onlyIcon: true, className: (0, exports.cnTestimonialBlockCard)('Picture-Button'), onClick: function () { return setIsModalOpen(true); } })),
                    react_1["default"].createElement(Picture_1.Picture, (0, tslib_1.__assign)({}, video.picture, { cover: true })),
                    video.videoUrl && (react_1["default"].createElement(Modal_1.Modal, { className: (0, exports.cnTestimonialBlockCard)('Modal'), isOpen: isModalOpen, hasOverlay: true, width: "full", onOverlayClick: function () { return setIsModalOpen(false); }, onEsc: function () { return setIsModalOpen(false); } },
                        react_1["default"].createElement("iframe", { title: "modal-iframe", src: video.videoUrl, frameBorder: '0', width: "100%", height: "100%" }),
                        react_1["default"].createElement(Button_1.Button, { view: "ghost", iconRight: IconClose_1.IconClose, className: "Modal-Close", onClick: function () { return setIsModalOpen(false); } })))))),
            react_1["default"].createElement("div", { className: (0, exports.cnTestimonialBlockCard)('Right') },
                react_1["default"].createElement("div", { className: (0, exports.cnTestimonialBlockCard)('Border') }),
                title && (react_1["default"].createElement(Typography_1.Typography.Title, { className: (0, exports.cnTestimonialBlockCard)('Title'), size: "lg" }, title)),
                text && (react_1["default"].createElement(Typography_1.Typography.Text, { className: (0, exports.cnTestimonialBlockCard)('SubTitle') }, text)),
                video && (react_1["default"].createElement("div", { className: (0, exports.cnTestimonialBlockCard)('Button') },
                    react_1["default"].createElement(Button_1.Button, { view: "link-secondary", iconSize: 'xs', as: "a", href: video.url, label: linkText, iconRight: buttonIcon, target: "_blank" })))))));
});
