import{Ja as e,Qa as t,Ut as n,Ya as r,_n as i,an as a,cr as o,fr as s,io as c,mn as l,vr as u}from"./index.dkY5s53S.js";import{t as d}from"./iconPosition.CY47f4C7.js";var f=c(t(),1),p=u(`div`,{target:`evng2kd0`})({display:`flex`,flexDirection:`column`,width:`100%`}),m=u(`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=u(`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 _(t){let{onPageChange:c,currentPageScriptHash:u}=(0,f.useContext)(n),{colors:_}=o(),{disabled:v,element:y}=t,b=u===y.pageScriptHash,x=e=>{y.external?v&&e.preventDefault():(e.preventDefault(),v||c(y.pageScriptHash,y.queryString))},S=d(y.iconPosition),C=g(y);return e(`div`,{className:`stPageLink`,"data-testid":`stPageLink`,children:e(a,{help:y.help,placement:i.TOP_RIGHT,containerWidth:!0,children:e(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`&&e(s,{size:`base`,color:v?_.fadedText40:_.bodyText,iconValue:y.icon}),e(h,{disabled:v,children:e(l,{source:y.label,allowHTML:!1,isLabel:!0,boldLabel:b,disableLinks:!0})}),y.icon&&S===`right`&&e(s,{size:`base`,color:v?_.fadedText40:_.bodyText,iconValue:y.icon})]})})})})}var v=(0,f.memo)(_);export{g as buildHref,v as default};