"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.DownloadSpecification=void 0;const jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),jotai_1=require("jotai"),styled_components_1=__importDefault(require("styled-components")),theme_1=require("@redocly/theme"),useDownloadInfo_1=require("./useDownloadInfo"),store_1=require("../../jotai/store"),hooks_1=require("../../hooks");function DownloadSpecificationComponent(){const e=(0,hooks_1.useOtelTelemetry)(),{options:t}=(0,jotai_1.useAtomValue)(store_1.globalStoreAtom),o=(0,theme_1.getPathPrefix)(),r=(0,useDownloadInfo_1.useDownloadInfo)({downloadUrls:t.downloadUrls}),n=(0,react_1.useCallback)((e=>{switch(e){case"yaml":return(0,jsx_runtime_1.jsx)(theme_1.DocumentIcon,{});case"json":return(0,jsx_runtime_1.jsx)(theme_1.JsonIcon,{});default:return(0,jsx_runtime_1.jsx)(theme_1.FileIcon,{})}}),[]);return r?(0,jsx_runtime_1.jsx)(Wrapper,{children:(r||[]).map((({title:t,url:r,iconType:s})=>{const i=o?(0,theme_1.combineUrls)(o,r):r;return(0,jsx_runtime_1.jsxs)(Card,{onClick:()=>e.send({type:"openapi_docs.download_definition.clicked"}),children:[(0,jsx_runtime_1.jsxs)(FileName,{children:[n(s),(0,jsx_runtime_1.jsx)("a",{href:i,target:"_blank",download:!0,rel:"noreferrer",children:t})]}),(0,jsx_runtime_1.jsx)("a",{href:i,target:"_blank",download:!0,rel:"noreferrer",children:(0,jsx_runtime_1.jsx)(theme_1.Button,{variant:"text",size:"small",icon:(0,jsx_runtime_1.jsx)(theme_1.DownloadIcon,{})})})]},t)}))}):(0,jsx_runtime_1.jsx)(jsx_runtime_1.Fragment,{})}exports.DownloadSpecification=(0,react_1.memo)(DownloadSpecificationComponent);const Card=styled_components_1.default.div`
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  width: 100%;

  border-bottom: 1px solid var(--border-color-secondary);
  padding-bottom: var(--spacing-sm);
  :last-of-type {
    padding-bottom: 0px;
    border-bottom: none;
  }
`,FileName=styled_components_1.default.span`
  display: flex;
  width: calc(100% - 25px);
  gap: var(--spacing-xs);
  align-items: center;

  svg {
    flex-shrink: 0;
  }
  a {
    width: 100%;
    color: var(--text-color-primary);
    word-break: break-word;
    text-decoration: none;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
  }
`,Wrapper=styled_components_1.default.div`
  display: flex;
  align-items: center;
  align-self: flex-start;
  justify-content: space-between;
  flex-direction: column;
  gap: var(--spacing-sm);
  font-size: var(--font-size-base);
`;
//# sourceMappingURL=DownloadSpecification.js.map