{"version":3,"file":"App-BZ7S0MmB.js","sources":["../../../app/javascript/entrypoints/App/App.jsx"],"sourcesContent":["import React, { useEffect, useState } from \"react\";\nimport { BrowserRouter, Routes, Route } from \"react-router-dom\";\nimport { ThemeProvider } from '@mui/material/styles';\nimport { Box, CircularProgress } from \"@mui/material\";\nimport { theme, colors } from \"../lib/theme\";\nimport Header from \"./Header\";\nimport { useAuth } from \"../../shared/useAuth\";\nimport Home from \"../Home/Home\";\nimport Checkout from \"../Checkout/Checkout\";\nimport Dashboard from \"../Dashboard/Dashboard\";\nimport Questionnaire from \"../Questionnaire/Questionnaire\";\nimport Welcome from \"../Welcome/Welcome\";\nimport User from \"../User/User\";\nimport Login from \"../Login/Login\";\nimport GetStarted from \"../GetStarted/GetStarted\";\nimport Album from \"../Album/Album\";\nimport Track from \"../Track/Track\";\nimport Register from \"../Register/Register\";\nimport { createAndRenderApp } from \"../AppWrapper/AppWrapper\";\nimport { getUserData } from \"../../shared/firebase\";\nimport Profile from \"../Profile/Profile\";\nimport CreateAlbum from \"../CreateAlbum/CreateAlbum\";\nimport VerifyEmail from \"../VerifyEmail/VerifyEmail\";\nimport EmailCallback from \"../EmailCallback/EmailCallback\";\n\nconst detectCountry = async () => {\n // Check if country is already stored in localStorage\n const storedCountry = localStorage.getItem('userCountry');\n if (storedCountry) return;\n\n // Check browser language\n const language = navigator.language || navigator.userLanguage;\n if (language.toLowerCase().includes('en-gb')) {\n localStorage.setItem('userCountry', 'UK');\n return;\n }\n\n // If not clearly UK, use geolocation API\n try {\n const response = await fetch('https://ipapi.co/json/');\n const data = await response.json();\n const country = data.country_code === 'GB' ? 'UK' : 'US';\n localStorage.setItem('userCountry', country);\n } catch (error) {\n console.error('Error detecting country:', error);\n localStorage.setItem('userCountry', 'US'); // Default to US if detection fails\n }\n};\n\nconst App = ({ config }) => {\n const { user } = useAuth();\n const [userData, setUserData] = useState(null);\n const [loadingUserData, setLoadingUserData] = useState(false);\n const [loadingCountry, setLoadingCountry] = useState(false);\n\n useEffect(() => {\n const fetchUserData = async () => {\n if (user) {\n setLoadingUserData(true);\n const data = await getUserData(user.uid);\n setUserData(data);\n setLoadingUserData(false);\n }\n };\n\n fetchUserData();\n }, [user]);\n\n useEffect(() => {\n const detectCountryWithLoading = async () => {\n setLoadingCountry(true);\n await detectCountry();\n setLoadingCountry(false);\n };\n\n detectCountryWithLoading();\n }, []);\n\n if (loadingUserData || loadingCountry) {\n return (\n \n \n \n );\n }\n\n return (\n \n \n
\n
\n
\n
\n \n \n } />\n } />\n } />\n } />\n } />\n } />\n } />\n } />\n } />\n } />\n } />\n } />\n } />\n } />\n } />\n \n \n
\n
\n
\n
\n
\n );\n};\n\nexport default createAndRenderApp(App);\n"],"names":["detectCountry","country","error","App","config","user","useAuth","userData","setUserData","useState","loadingUserData","setLoadingUserData","loadingCountry","setLoadingCountry","useEffect","data","getUserData","React","Box","CircularProgress","colors","ThemeProvider","theme","BrowserRouter","Header","Routes","Route","Home","Checkout","CreateAlbum","Questionnaire","Welcome","GetStarted","Album","Track","User","Login","Register","Dashboard","Profile","VerifyEmail","EmailCallback","createAndRenderApp"],"mappings":"w8GAyBA,MAAMA,EAAgB,SAAY,CAGhC,GADsB,aAAa,QAAQ,aAAa,EACrC,OAInB,IADiB,UAAU,UAAY,UAAU,cACpC,YAAA,EAAc,SAAS,OAAO,EAAG,CAC/B,aAAA,QAAQ,cAAe,IAAI,EACxC,MACF,CAGI,GAAA,CAGF,MAAMC,GADO,MADI,MAAM,MAAM,wBAAwB,GACzB,QACP,eAAiB,KAAO,KAAO,KACvC,aAAA,QAAQ,cAAeA,CAAO,QACpCC,EAAO,CACN,QAAA,MAAM,2BAA4BA,CAAK,EAClC,aAAA,QAAQ,cAAe,IAAI,CAC1C,CACF,EAEMC,EAAM,CAAC,CAAE,OAAAC,KAAa,CACpB,KAAA,CAAE,KAAAC,GAASC,IACX,CAACC,EAAUC,CAAW,EAAIC,WAAS,IAAI,EACvC,CAACC,EAAiBC,CAAkB,EAAIF,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