"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HttpService = void 0;
const tslib_1 = require("tslib");
const core_1 = require("@blueprintjs/core");
const react_error_boundary_1 = require("@stoplight/react-error-boundary");
const ui_kit_1 = require("@stoplight/ui-kit");
const classnames_1 = tslib_1.__importDefault(require("classnames"));
const React = tslib_1.__importStar(require("react"));
const MarkdownViewer_1 = require("../../MarkdownViewer");
const SectionTitle_1 = require("../HttpOperation/SectionTitle");
const HttpSecuritySchemes_1 = require("../HttpSecuritySchemes");
const HttpServiceComponent = React.memo(({ className, data }) => {
    var _a, _b;
    return (React.createElement("div", { className: classnames_1.default('HttpService MarkdownViewer', className) },
        data.name !== void 0 && React.createElement("h1", { className: ui_kit_1.Classes.HEADING }, data.name),
        React.createElement("div", { className: "MarkdownViewer flex mb-10" },
            ((_a = data === null || data === void 0 ? void 0 : data.contact) === null || _a === void 0 ? void 0 : _a.email) && (React.createElement("a", { className: "flex items-center mr-4", href: `mailto:${data.contact.email}`, target: "_blank", rel: "noopener noreferrer" },
                React.createElement(core_1.Icon, { icon: "envelope", className: "mr-2", iconSize: 12 }),
                data.contact.email ? data.contact.email : 'Email')),
            ((_b = data === null || data === void 0 ? void 0 : data.contact) === null || _b === void 0 ? void 0 : _b.url) && (React.createElement("a", { className: "flex items-center mr-4", href: data.contact.url, target: "_blank", rel: "noopener noreferrer" },
                React.createElement(core_1.Icon, { icon: "link", className: "mr-2", iconSize: 12 }),
                " URL")),
            data.license && (data.license.url || data.license.name) && (React.createElement("div", { className: "mr-4" }, data.license.url ? (React.createElement("a", { href: data.license.url, target: "_blank", rel: "noopener noreferrer" }, data.license.name || 'Licence')) : (React.createElement("span", null, data.license.name)))),
            data.termsOfService && (React.createElement("a", { href: data.termsOfService, target: "_blank", rel: "noopener noreferrer" }, "Terms of Service"))),
        data.description && React.createElement(MarkdownViewer_1.MarkdownViewer, { className: "mb-10", markdown: data.description }),
        data.servers && data.servers.length > 0 ? (React.createElement("div", { className: "mb-10" },
            React.createElement(SectionTitle_1.SectionTitle, { title: "Servers" }),
            data.servers.map((server, index) => (React.createElement("div", { key: index, className: "MarkdownViewer flex items-center flex-1 mt-4" },
                server.name && React.createElement("div", { className: "mr-2" }, server.name),
                server.description && React.createElement("div", { className: "mr-2" }, server.description),
                React.createElement("a", { href: server.url, target: "_blank", rel: "noopener noreferrer" }, server.url)))))) : null,
        data.security && React.createElement(HttpSecuritySchemes_1.HttpSecuritySchemes, { className: "mb-10", title: "Global Securities", securities: data.security })));
});
HttpServiceComponent.displayName = 'HttpService.Component';
exports.HttpService = react_error_boundary_1.withErrorBoundary(HttpServiceComponent, { recoverableProps: ['data'] });
//# sourceMappingURL=index.js.map