import{o as e}from"./chunk.DuxOD-Sk.js";import{r as t}from"./emotion-is-prop-valid.esm.DV_OErv-.js";import{c as n,l as r,t as i}from"./emotion-styled.browser.esm.BPUx6WuE.js";import{$ as a,St as o,_t as s,wt as c}from"./src.sR_9Xh2m.js";import{t as l}from"./useEmotionTheme.61kSPILX.js";import{t as u}from"./DynamicIcon.BDXbm0Of.js";import{t as d}from"./iconPosition.CAyE8Pjc.js";var f=e(t()),p=i(`div`,{target:`evng2kd0`})({display:`flex`,flexDirection:`column`,width:`100%`}),m=i(`a`,{target:`evng2kd1`})(({disabled:e,isCurrentPage:t,theme:n})=>({textDecoration:`none`,width:`100%`,display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`flex-start`,gap:n.spacing.sm,borderRadius:n.radii.default,paddingLeft:n.spacing.sm,paddingRight:n.spacing.sm,marginTop:n.spacing.threeXS,marginBottom:n.spacing.threeXS,lineHeight:n.lineHeights.menuItem,backgroundColor:t?n.colors.darkenedBgMix15:`transparent`,"&:hover":{backgroundColor:t?n.colors.darkenedBgMix25:n.colors.darkenedBgMix15},"&:active,&:visited,&:hover":{textDecoration:`none`},"&:focus":{outline:`none`},"&:focus-visible":{backgroundColor:n.colors.darkenedBgMix15},"@media print":{paddingLeft:n.spacing.none},...e?{borderColor:n.colors.borderColor,backgroundColor:n.colors.transparent,color:n.colors.fadedText40,cursor:`not-allowed`,"&:hover":{color:n.colors.fadedText40,backgroundColor:n.colors.transparent}}:{}})),h=i(`span`,{target:`evng2kd2`})(({disabled:e,theme:t})=>({color:t.colors.bodyText,overflow:`hidden`,whiteSpace:`nowrap`,textOverflow:`ellipsis`,display:`table-cell`,...e?{borderColor:t.colors.borderColor,backgroundColor:t.colors.transparent,color:t.colors.fadedText40,cursor:`not-allowed`}:{}}));function g(e){let t=e.page;if(e.queryString)if(e.external)try{let n=new URL(e.page);new URLSearchParams(e.queryString).forEach((e,t)=>n.searchParams.append(t,e)),t=n.toString()}catch{let[n,r]=t.split(`#`);t=n+(n.includes(`?`)?`&`:`?`)+e.queryString+(r?`#`+r:``)}else t+=(t.includes(`?`)?`&`:`?`)+e.queryString;return t}function _(e){let{onPageChange:t,currentPageScriptHash:i}=(0,f.useContext)(a),{colors:_}=l(),{disabled:v,element:y}=e,b=i===y.pageScriptHash,x=e=>{y.external?v&&e.preventDefault():(e.preventDefault(),v||t(y.pageScriptHash,y.queryString))},S=d(y.iconPosition),C=g(y);return n(`div`,{className:`stPageLink`,"data-testid":`stPageLink`,children:n(s,{help:y.help,placement:c.TOP_RIGHT,containerWidth:!0,children:n(p,{children:r(m,{"data-testid":`stPageLink-NavLink`,disabled:v,isCurrentPage:b,href:C,target:y.external?`_blank`:``,rel:`noreferrer`,onClick:x,children:[y.icon&&S===`left`&&n(u,{size:`lg`,color:v?_.fadedText40:_.bodyText,iconValue:y.icon}),n(h,{disabled:v,children:n(o,{source:y.label,allowHTML:!1,isLabel:!0,boldLabel:b,largerLabel:!0,disableLinks:!0})}),y.icon&&S===`right`&&n(u,{size:`lg`,color:v?_.fadedText40:_.bodyText,iconValue:y.icon})]})})})})}var v=(0,f.memo)(_);export{g as buildHref,v as default};