import{jsx as a,jsxs as c}from"react/jsx-runtime";import{useAtomValue as m}from"jotai";import{Link as h}from"react-router-dom";import{LinkIcon as o}from"@redocly/theme/icons/LinkIcon/LinkIcon";import{globalOptionsAtom as d}from"../../jotai/store.js";import{tryDecodeURIComponent as f}from"../../utils/index.js";import{styled as k}from"../../styled-components.js";import{joinWithSeparator as e}from"../../services/history/helpers.js";function u(i){const{routingBasePath:n,onDeepLinkClick:r}=m(d),t=i.to,l=r&&{onClick:s=>{s.preventDefault(),r(e(n||"",t))}};return t?a(h,{"aria-label":i["aria-label"]||`link to ${t}`,id:f(i.id||""),className:i.className||"",to:t?.startsWith("#")?t:e(n||"",t),...l,children:i.children}):i.children?c("span",{"aria-label":i["aria-label"]||`link to ${t}`,className:i.className,children:[" ",i.children," "]}):null}const b=k(u)`
  position: absolute;
  top: 50%;
  left: 0;
  transform: translate(-100%, -50%);
  padding-right: var(--heading-anchor-offset-right);
  z-index: 1;

  ${o} {
    opacity: 0;
    transition:
      visibility 0.3s linear,
      opacity 0.3s linear;
  }

  :hover ${o}, :focus ${o} {
    visibility: visible;
    opacity: 1;
  }

  h2 & {
    top: 0;
    transform: translate(-100%);
  }
`;function N(i){return a(b,{...i,children:a(o,{size:"13px",color:"--heading-anchor-color"})})}export{u as Link,N as ShareLink,b as StyledShareLink};
