{"version":3,"sources":["webpack:///./src/pages/404.tsx"],"names":["NotFoundPage","useState","isCheckingRedirect","setIsCheckingRedirect","shouldShow404","setShouldShow404","useEffect","a","currentPath","window","location","pathname","fetch","response","ok","Error","json","redirectsData","console","log","redirectArray","matchingRedirect","find","redirect","originPath","isExternal","href","redirectPath","navigate","replace","error","checkRedirect","style","display","name","content","className"],"mappings":"6UA8GeA,UAhGM,WAAM,MAC2BC,oBAAS,GAAtDC,EADkB,KACEC,EADF,OAMiBF,oBAAS,GAA5CG,EANkB,KAMHC,EANG,KAoEzB,OA3DAC,qBAAU,WAqDR,OApDmB,e,EAAA,G,EAAA,UAAG,kCAAAC,EAAA,sEAEZC,EAAcC,OAAOC,SAASC,SAFlB,SAGKC,MAAM,mBAHX,WAGZC,EAHY,QAKJC,GALI,sBAMV,IAAIC,MAAM,6BANA,uBASyBF,EAASG,OATlC,UASZC,EATY,OAWlBC,QAAQC,IAAI,2BACZD,QAAQC,IAAI,2BACZD,QAAQC,IAAI,2BACZD,QAAQC,IAAI,2BACZD,QAAQC,IAAI,2BACZD,QAAQC,IAAI,2BACZD,QAAQC,IAAIF,GACZC,QAAQC,IAAIX,GAEPS,aApBa,EAoBbA,EAAeG,cApBF,wBAqBhBjB,GAAsB,GACtBE,GAAiB,GAtBD,8BA0BZgB,EAAmBJ,EAAcG,cAAcE,MACnD,SAAAC,GAAQ,OAAIA,EAASC,aAAehB,KAGtCU,QAAQC,IAAIE,IAERA,EAhCc,wBAiCZA,EAAiBI,WACnBhB,OAAOC,SAASgB,KAAOL,EAAiBM,aAExCC,mBAASP,EAAiBM,aAAc,CAAEE,SAAS,IApCrC,2BAyClB1B,GAAsB,GACtBE,GAAiB,GA1CC,kDA4ClBa,QAAQY,MAAM,4BAAd,MACA3B,GAAsB,GACtBE,GAAiB,GA9CC,yD,+KAAH,oDAkDnB0B,GAEO,WACL5B,GAAsB,GACtBE,GAAiB,MAElB,IAECH,EAEA,yBAAK8B,MAAO,CAAEC,QAAS,SACrB,kBAAC,IAAD,KACE,mDAMJ7B,EAEA,oCACE,kBAAC,IAAD,KACE,iDACA,0BAAM8B,KAAK,SAASC,QAAQ,aAE9B,yBAAKC,UAAU,0CACb,qCACA,oFAMD","file":"component---src-pages-404-tsx-4e9b97b203961295fe3f.js","sourcesContent":["import { navigate } from 'gatsby'\r\nimport React, { useEffect, useState } from 'react'\r\nimport { Helmet } from 'react-helmet'\r\n\r\ninterface RedirectObj {\r\n isExternal: boolean\r\n originPath: string\r\n redirectPath: string\r\n}\r\n\r\ninterface RedirectsData {\r\n redirectArray: RedirectObj[]\r\n}\r\n\r\nconst NotFoundPage = () => {\r\n const [isCheckingRedirect, setIsCheckingRedirect] = useState(true)\r\n /* \r\n this state is used to prevent the 404 page content shows up \r\n before the redirect happens (in case a redirect exists for the page)\r\n */\r\n const [shouldShow404, setShouldShow404] = useState(false)\r\n\r\n // this logic is required to force redirects even if the pageFrom does not exist in sanity\r\n useEffect(() => {\r\n const checkRedirect = async () => {\r\n try {\r\n const currentPath = window.location.pathname\r\n const response = await fetch('/redirects.json')\r\n\r\n if (!response.ok) {\r\n throw new Error('Failed to fetch redirects')\r\n }\r\n\r\n const redirectsData: RedirectsData = await response.json()\r\n\r\n console.log('=======================')\r\n console.log('=======================')\r\n console.log('=======================')\r\n console.log('=======================')\r\n console.log('=======================')\r\n console.log('=======================')\r\n console.log(redirectsData)\r\n console.log(currentPath)\r\n\r\n if (!redirectsData?.redirectArray) {\r\n setIsCheckingRedirect(false)\r\n setShouldShow404(true)\r\n return\r\n }\r\n\r\n const matchingRedirect = redirectsData.redirectArray.find(\r\n redirect => redirect.originPath === currentPath\r\n )\r\n\r\n console.log(matchingRedirect)\r\n\r\n if (matchingRedirect) {\r\n if (matchingRedirect.isExternal) {\r\n window.location.href = matchingRedirect.redirectPath\r\n } else {\r\n navigate(matchingRedirect.redirectPath, { replace: true })\r\n }\r\n return\r\n }\r\n\r\n setIsCheckingRedirect(false)\r\n setShouldShow404(true)\r\n } catch (error) {\r\n console.error('Error checking redirects:', error)\r\n setIsCheckingRedirect(false)\r\n setShouldShow404(true)\r\n }\r\n }\r\n\r\n checkRedirect()\r\n\r\n return () => {\r\n setIsCheckingRedirect(false)\r\n setShouldShow404(false)\r\n }\r\n }, [])\r\n\r\n if (isCheckingRedirect) {\r\n return (\r\n
\r\n \r\n Redirecting...\r\n \r\n
\r\n )\r\n }\r\n\r\n if (shouldShow404) {\r\n return (\r\n <>\r\n \r\n Page Not Found\r\n \r\n \r\n
\r\n

Oops!

\r\n

Sorry, the page you're looking for does not exist!

\r\n
\r\n \r\n )\r\n }\r\n\r\n return null\r\n}\r\n\r\nexport default NotFoundPage\r\n"],"sourceRoot":""}