import{jsx as i,jsxs as r}from"react/jsx-runtime";import{CopyButton as x}from"@redocly/theme/components/Buttons/CopyButton";import{Tooltip as v}from"@redocly/theme/components/Tooltip/Tooltip";import{getServerDisplayName as y}from"../../utils/helpers.js";import{PanelItemDescription as u,Title as w}from"../PanelItem/index.js";import{ViewNested as T}from"../ViewNested/index.js";import{Tag as S}from"../common/index.js";import{Markdown as j}from"../Markdown/index.js";import{styled as o}from"../../styled-components.js";import{ServerDescriptionTooltip as D}from"./ServerDescriptionTooltip.js";const F=({servers:h,path:b="",translate:t})=>i($,{children:h.map(e=>{const a=e.url+b,p=Object.keys(e.variables||{}).length,d=p===1?"variable":"variables",l=`${p||""} ${t(`openapi.${d}`,d)}`,f=!!e.name&&!!e.description;return r("div",{children:[r(O,{children:[i(u,{"data-testid":"server-panel-item-name",children:y(e)}),f&&i(D,{description:e.description})]}),r(B,{children:[i(w,{suppressHydrationWarning:!0,children:a}),i(v,{tip:t("button.copy.tooltipText","Copy to clipboard"),placement:"top",arrowPosition:"right",children:i(x,{data:a},a)})]}),e.variables&&i(T,{expandText:`${t("openapi.actions.show","Show")} ${l}`,hideText:`${t("openapi.actions.hide","Hide")} ${l}`,expandByDefault:!1,expandable:!0,hideDivider:!0,children:i(z,{children:Object.entries(e.variables||{}).map(([c,n])=>r(C,{children:[i(k,{children:c}),r(s,{children:[t("openapi.default","Default")," ",i(g,{children:n.default})]}),i(W,{source:n.description}),n.enum&&r(s,{children:[t("openapi.enum","Enum")," ",i(L,{children:n.enum.map(m=>i(g,{children:m},m))})]})]},c))})})]},e.url)})}),$=o.div`
  & > div {
    border-bottom: 1px solid var(--border-color-secondary);
    margin-bottom: var(--spacing-xs);
    padding-bottom: var(--spacing-sm);
  }

  & > div:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
  }
`,z=o.div`
  padding-left: var(--spacing-xxs);
  & > div {
    border-bottom: 1px solid var(--border-color-secondary);
    margin-bottom: var(--spacing-xs);
    padding-bottom: var(--spacing-sm);
  }

  & > div:first-child {
    margin-top: var(--spacing-sm);
    padding-top: 0;
  }

  & > div:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
  }
`,C=o.div`
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
`,W=o(j)`
  font-size: var(--font-size-sm);
  line-height: var(--line-height-sm);
  color: var(--text-color-primary);
`,s=o.span`
  display: flex;
  gap: var(--spacing-xxs);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-sm);
  color: var(--text-color-primary);
`,k=o(s)`
  padding-bottom: var(--spacing-xxs);
  font-weight: var(--font-weight-semibold);
`,L=o.span`
  display: flex;
  gap: var(--spacing-xxs);
  flex-wrap: wrap;
`,g=o(S)`
  font-size: var(--font-size-sm);
  line-height: var(--line-height-sm);
`,O=o.div`
  display: flex;
  justify-content: start;
  align-items: center;
  gap: var(--spacing-xxs);
`,B=o.div`
  display: flex;
  justify-content: space-between;
  align-items: center;
`;export{F as ServerList};
