{"version":3,"file":"RedirectTo.DDzC7BKB.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/U5Zmbyf4BWoq5QttpiPL/ZAN0D3BjZ1x5hyprjqL8/RedirectTo.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useState,useEffect}from\"react\";const STAGING_ORIGIN_MAP=[{match:\"staging.sports.aparentmedia.com\",origin:\"https://streaming.staging.sports.aparentmedia.com\"},{match:\"dev01.apmc.io\",origin:\"https://web-streaming-origin.dev01.apmc.io\"},{match:\"stg-be.victoryplus.com\",origin:\"https://stg-be.victoryplus.com\"}];function getMatchingOrigin(){if(typeof window===\"undefined\")return null;const host=window.location.hostname;const match=STAGING_ORIGIN_MAP.find(({match})=>host.includes(match));return match?.origin??null;}export function withCustomLink(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[url,setUrl]=useState(null);useEffect(()=>{if(!props.link){setUrl(null);return;}try{const originalUrl=new URL(props.link);// clone original url\nconst finalUrl=new URL(originalUrl.toString());// replace origin only for staging environments\nconst matchingOrigin=getMatchingOrigin();if(matchingOrigin){const stagingUrl=new URL(matchingOrigin);finalUrl.protocol=stagingUrl.protocol;finalUrl.host=stagingUrl.host;}// forward current page params (utm etc.)\nconst currentParams=new URLSearchParams(window.location.search);currentParams.forEach((value,key)=>{// do not overwrite existing params\nif(!finalUrl.searchParams.has(key)){finalUrl.searchParams.set(key,value);}});setUrl(finalUrl.toString());}catch{console.error(\"Invalid URL:\",props.link);setUrl(props.link);}},[props.link]);if(!url)return null;return /*#__PURE__*/_jsx(Component,{...props,ref:ref,href:url,link:url,target:\"_blank\"});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withCustomLink\":{\"type\":\"reactHoc\",\"name\":\"withCustomLink\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./RedirectTo.map"],"mappings":"8IAAiX,SAAS,GAAmB,CAAC,GAAU,IAAS,OA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