import{o as e}from"./rolldown-runtime.C0FnF6B9.js";import{r as t}from"./emotion-is-prop-valid.esm.CuYlOKOk.js";import{i as n,t as r}from"./emotion-styled.browser.esm.BYv_Qzcq.js";import{g as i}from"./getColors.DtAxY2Hd.js";import{n as a}from"./UriUtil.FYzIdBsL.js";import{i as o}from"./Tooltip.CcubhKj6.js";import{n as s,t as c}from"./styled-components.BjKbfR5p.js";import{t as l}from"./BaseButtonTooltip.B83DZSNb.js";import{i as u,t as d}from"./DynamicButtonLabel.BTjDBnmI.js";import{t as f}from"./useResolvedWrap.DnjqnyWR.js";import{t as p}from"./iconPosition.DwITqWdC.js";var m=e(t(),1);function h(e,t){switch(e){case s.XSMALL:return{padding:`${t.spacing.twoXS} ${t.spacing.sm}`,fontSize:t.fontSizes.sm};case s.SMALL:return{padding:`${t.spacing.twoXS} ${t.spacing.md}`};case s.LARGE:return{padding:`${t.spacing.md} ${t.spacing.md}`};default:return{padding:`${t.spacing.xs} ${t.spacing.md}`}}}var g=r(`a`,{target:`evo6qzw0`})(({containerWidth:e,size:t,theme:n})=>({display:`inline-flex`,alignItems:`center`,justifyContent:`center`,fontWeight:n.fontWeights.normal,padding:`${n.spacing.xs} ${n.spacing.md}`,borderRadius:n.radii.button,minHeight:n.sizes.minElementHeight,margin:0,lineHeight:n.lineHeights.base,color:n.colors.primary,textDecoration:`none`,width:e?`100%`:`auto`,userSelect:`none`,"&:visited":{color:n.colors.primary},"&:focus":{outline:`none`},"&:focus-visible":{boxShadow:n.shadows.focusRing},"&:hover":{textDecoration:`none`},"&:active":{textDecoration:`none`},...h(t,n)})),_=r(g,{target:`evo6qzw1`})(({theme:e})=>({backgroundColor:e.colors.primary,color:e.colors.white,border:`${e.sizes.borderWidth} solid ${e.colors.primary}`,"&:hover, &:focus-visible":{backgroundColor:i(e.colors.primary,.15),borderColor:i(e.colors.primary,.15)},"&:active":{backgroundColor:e.colors.primary,borderColor:i(e.colors.primary,.15)},"&:visited:not(:active)":{color:e.colors.white},"&[disabled], &[disabled]:hover, &[disabled]:active, &[disabled]:visited":{borderColor:e.colors.borderColor,backgroundColor:e.colors.transparent,color:e.colors.fadedText40,cursor:`not-allowed`}})),v=r(g,{target:`evo6qzw2`})(({theme:e})=>({backgroundColor:e.colors.lightenedBg05,color:e.colors.bodyText,border:`${e.sizes.borderWidth} solid ${e.colors.borderColor}`,"&:visited":{color:e.colors.bodyText},"&:hover, &:focus-visible":{backgroundColor:e.colors.darkenedBgMix15},"&:active":{backgroundColor:e.colors.darkenedBgMix25},"&[disabled], &[disabled]:hover, &[disabled]:active":{borderColor:e.colors.borderColor,backgroundColor:e.colors.transparent,color:e.colors.fadedText40,cursor:`not-allowed`}})),y=r(g,{target:`evo6qzw3`})(({theme:e})=>({padding:e.spacing.none,backgroundColor:e.colors.transparent,color:e.colors.bodyText,border:`none`,"&:visited":{color:e.colors.bodyText},"&:hover, &:focus-visible":{color:e.colors.primary},"&:hover:not([disabled]), &:focus-visible:not([disabled])":{"span.stMarkdownColoredText":{color:`inherit !important`}},"&:active":{color:i(e.colors.primary,.25)},"&[disabled], &[disabled]:hover, &[disabled]:active":{backgroundColor:e.colors.transparent,color:e.colors.fadedText40,cursor:`not-allowed`}})),b=(0,m.forwardRef)(function({kind:e,size:t,disabled:r,children:i,autoFocus:a,href:o,rel:l,target:u,onClick:d},f){let p=_;return e===c.SECONDARY?p=v:e===c.TERTIARY&&(p=y),n(p,{ref:f,kind:e,size:t||s.MEDIUM,containerWidth:!0,disabled:r||!1,autoFocus:a||!1,href:o,target:u,rel:l,onClick:d,tabIndex:r?-1:0,"data-testid":`stBaseLinkButton-${e}`,children:i})});b.displayName=`BaseLinkButton`;var x=(0,m.memo)(b);function S(e){let{element:t,widgetMgr:r,fragmentId:i}=e,h=t.shortcut||void 0,g=a(t.url),_=g?`#`:t.url,v=f(t.wrap),y=!v&&!t.help,b=c.SECONDARY;t.type===`primary`?b=c.PRIMARY:t.type===`tertiary`&&(b=c.TERTIARY);let S=(0,m.useRef)(null),C=(0,m.useCallback)(()=>{t.disabled||g||S.current?.click()},[t.disabled,g]),w=(0,m.useCallback)(e=>{if(t.disabled||g){e.preventDefault();return}!t.ignoreRerun&&t.id&&r.setTriggerValue(t,{fromUi:!0},i)},[t,i,g,r]);return u({shortcut:h,disabled:t.disabled,onActivate:C}),n(o,{className:`stLinkButton`,"data-testid":`stLinkButton`,children:n(l,{help:t.help,containerWidth:!0,children:n(x,{ref:S,kind:b,size:s.SMALL,disabled:t.disabled,onClick:w,href:_,target:g?`_self`:`_blank`,rel:`noreferrer`,"aria-disabled":t.disabled,children:n(d,{icon:t.icon,iconPosition:p(t.iconPosition),label:t.label,shortcut:h,wrap:v,addTitleTooltip:y})})})})}var C=(0,m.memo)(S);export{C as default};