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