import{jsx as e,Fragment as d,jsxs as s}from"react/jsx-runtime";import{memo as p,useCallback as f}from"react";import{DownloadIcon as x}from"@redocly/theme/icons/DownloadIcon/DownloadIcon";import{getPathPrefix as g,combineUrls as w}from"@redocly/theme/core/openapi";import{Button as b}from"@redocly/theme/components/Button/Button";import{DocumentIcon as h}from"@redocly/theme/icons/DocumentIcon/DocumentIcon";import{JsonIcon as u}from"@redocly/theme/icons/JsonIcon/JsonIcon";import{FileIcon as v}from"@redocly/theme/icons/FileIcon/FileIcon";import{useTelemetry as y}from"../../hooks/index.js";import{styled as r}from"../../styled-components.js";function k({downloadObjects:t}){const l=y(),n=g(),c=f(o=>{switch(o){case"yaml":return e(h,{});case"json":return e(u,{});default:return e(v,{})}},[]);return t?e(C,{children:(t||[]).map(({title:o,url:a,iconType:m})=>{const i=n?w(n,a):a;return s(j,{onClick:()=>{l.sendDownloadDefinitionClickedMessage()},children:[s(D,{children:[c(m),e("a",{href:i,target:"_blank",download:!0,rel:"noreferrer",children:o})]}),e("a",{href:i,target:"_blank",download:!0,rel:"noreferrer",children:e(b,{variant:"text",size:"small",icon:e(x,{})})})]},o)})}):e(d,{})}const N=p(k),j=r.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;
  }
`,D=r.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;
  }
`,C=r.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);
`;export{N as DownloadSpecification};
