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,CAAC,OAAO,CAAG,QAC/B,EAAe,KAAK,CAAC,eAAe,CAAG,sBACvC,EAAe,WAAW,CAAG,CAAC,2BAA2B,EAAE,EAAM,OAAO,EAAI,oBAAA,CAAqB,CAEjG,WAAW,KACP,EAAe,KAAK,CAAC,OAAO,CAAG,MACnC,EAAG,IAEP,QAAU,CAEN,EAAgB,WAAW,CAAG,kBAC9B,EAAmB,KAAK,CAAC,OAAO,CAAG,MACvC,CACJ,GAIA,AADkB,SAAS,cAAc,CAAC,cAChC,gBAAgB,CAAC,QAAS,MAAO,IACvC,EAAE,cAAc,GAChB,GAAI,CACA,IAAM,EAAS,MAAM,AAAA,CAAA,EAAA,EAAA,cAAa,AAAb,EAAe,OAAO,EACvC,CAAA,EAAO,OAAO,EAGd,QAAQ,KAAK,CAAC,iBAAkB,EAAO,OAAO,EAF9C,OAAO,QAAQ,CAAC,IAAI,CAAG,YAK/B,CAAE,MAAO,EAAO,CACZ,QAAQ,KAAK,CAAC,uBAAwB,GACtC,OAAO,QAAQ,CAAC,IAAI,CAAG,YAC3B,CACJ,EAvQA,CAAE,MAAO,EAAO,CACZ,QAAQ,KAAK,CAAC,qBAAsB,GACpC,OAAO,QAAQ,CAAC,IAAI,CAAG,WAC3B,CACJ","sources":["","profile.js"],"sourcesContent":["import \"./auth.856e296b.js\";\n\n\n var $parcel$global = globalThis;\n \nvar $parcel$modules = {};\nvar $parcel$inits = {};\n\nvar parcelRequire = $parcel$global[\"parcelRequireeac0\"];\n\nif (parcelRequire == null) {\n parcelRequire = function(id) {\n if (id in $parcel$modules) {\n return $parcel$modules[id].exports;\n }\n if (id in $parcel$inits) {\n var init = $parcel$inits[id];\n delete $parcel$inits[id];\n var module = {id: id, exports: {}};\n $parcel$modules[id] = module;\n init.call(module.exports, module, module.exports);\n return module.exports;\n }\n var err = new Error(\"Cannot find module '\" + id + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n };\n\n parcelRequire.register = function register(id, init) {\n $parcel$inits[id] = init;\n };\n\n $parcel$global[\"parcelRequireeac0\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\n\nvar $jUUxy = parcelRequire(\"jUUxy\");\n\nvar $2Izdj = parcelRequire(\"2Izdj\");\nvar $2yfk2 = parcelRequire(\"2yfk2\");\nvar $bykg2 = parcelRequire(\"bykg2\");\ndocument.addEventListener('DOMContentLoaded', async ()=>{\n try {\n const isAuthenticated = await (0, $jUUxy.Authentication).checkStatus();\n if (!isAuthenticated) {\n window.location.href = 'auth.html';\n return;\n }\n document.body.style.visibility = 'visible';\n // Load user attributes from Cognito\n await $1eecad6b029344eb$var$loadUserProfile();\n // Load server stats\n $1eecad6b029344eb$var$loadServerStats();\n // Set up event listeners\n $1eecad6b029344eb$var$setupEventListeners();\n } catch (error) {\n console.error('Auth check failed:', error);\n window.location.href = 'auth.html';\n }\n});\nasync function $1eecad6b029344eb$var$loadUserProfile() {\n try {\n const saveBtnText = document.getElementById('save-btn-text');\n const saveBtnLoading = document.getElementById('save-btn-loading');\n // Show loading state\n saveBtnText.textContent = \"Loading...\";\n saveBtnLoading.style.display = \"inline-block\";\n // Get user attributes from Cognito\n const userResult = await (0, $2Izdj.fetchUserAttributes)();\n if (userResult.success && userResult.attributes) {\n // Update display name field\n const displayNameInput = document.getElementById('display-name');\n displayNameInput.value = userResult.attributes.name || '';\n }\n // Hide loading state\n saveBtnText.textContent = \"Save Changes\";\n saveBtnLoading.style.display = \"none\";\n } catch (error) {\n console.error(\"Error loading user profile:\", error);\n // Handle error - show error message to user\n const successMessage = document.getElementById('success-message');\n successMessage.style.display = 'block';\n successMessage.style.backgroundColor = 'var(--redstone-red)';\n successMessage.textContent = \"Error loading profile. Please try again.\" + error;\n setTimeout(()=>{\n successMessage.style.display = 'none';\n }, 3000);\n }\n}\nfunction $1eecad6b029344eb$var$loadServerStats() {\n // In a real application, this would fetch from an API\n // For now, we'll just use sample data or localStorage\n try {\n // Get uptime from localStorage or set default\n const uptimeHours = parseInt(localStorage.getItem('server_uptime_hours') || '0');\n document.getElementById('uptime-value').textContent = uptimeHours;\n // Get player count from localStorage or set default\n const playerCount = parseInt(localStorage.getItem('server_player_count') || '0');\n document.getElementById('player-count-value').textContent = playerCount;\n // In a real app, you'd fetch this data from your server API\n // fetch('/api/server-stats')\n // .then(response => response.json())\n // .then(data => {\n // document.getElementById('uptime-value').textContent = data.uptimeHours;\n // document.getElementById('player-count-value').textContent = data.playerCount;\n // });\n } catch (error) {\n console.error(\"Error loading server stats:\", error);\n }\n}\nfunction $1eecad6b029344eb$var$setupEventListeners() {\n // Handle profile form submission\n const profileForm = document.getElementById('profile-form');\n profileForm.addEventListener('submit', async (e)=>{\n e.preventDefault();\n const displayName = document.getElementById('display-name').value.trim();\n const saveBtnText = document.getElementById('save-btn-text');\n const saveBtnLoading = document.getElementById('save-btn-loading');\n const successMessage = document.getElementById('success-message');\n if (!displayName) {\n successMessage.style.display = 'block';\n successMessage.style.backgroundColor = 'var(--gold-yellow)';\n successMessage.style.color = 'black';\n successMessage.textContent = \"Please enter a display name.\";\n setTimeout(()=>{\n successMessage.style.display = 'none';\n }, 3000);\n return;\n }\n try {\n // Show loading state\n saveBtnText.textContent = \"Saving...\";\n saveBtnLoading.style.display = \"inline-block\";\n const user = await (0, $2yfk2.getCurrentUser)();\n // Update user attributes in Cognito\n console.log(\"Updating user attributes...\");\n console.log(user);\n const result = await (0, $bykg2.updateUserAttributes)({\n user: user,\n attributes: {\n \"custom:displayName\": displayName\n }\n });\n if (result.success) {\n // Show success message\n successMessage.style.display = 'block';\n successMessage.style.backgroundColor = 'var(--grass-green)';\n successMessage.style.color = 'white';\n successMessage.textContent = \"Your changes have been saved successfully!\";\n // Play success sound\n const sound = new Audio('data:audio/wav;base64,UklGRiQAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQAAAAA=');\n sound.volume = 0.2;\n sound.play().catch((err)=>console.log(\"Sound playback error:\", err));\n // Hide message after 3 seconds\n setTimeout(()=>{\n successMessage.style.display = 'none';\n }, 3000);\n } else {\n // Show error message\n successMessage.style.display = 'block';\n successMessage.style.backgroundColor = 'var(--redstone-red)';\n successMessage.textContent = result.message || \"Failed to update profile. Please try again.\";\n setTimeout(()=>{\n successMessage.style.display = 'none';\n }, 3000);\n }\n } catch (error) {\n console.error(\"Error updating profile:\", error);\n // Show error message\n successMessage.style.display = 'block';\n successMessage.style.backgroundColor = 'var(--redstone-red)';\n successMessage.textContent = \"Failed to update profile. Please try again.\";\n setTimeout(()=>{\n successMessage.style.display = 'none';\n }, 3000);\n } finally{\n // Reset button state\n saveBtnText.textContent = \"Save Changes\";\n saveBtnLoading.style.display = \"none\";\n }\n });\n // Handle password change\n const changePasswordButton = document.getElementById('change-password-button');\n changePasswordButton.addEventListener('click', async ()=>{\n const currentPassword = document.getElementById('current-password').value;\n const newPassword = document.getElementById('new-password').value;\n const confirmPassword = document.getElementById('confirm-password').value;\n const changePwBtnText = document.getElementById('change-pw-btn-text');\n const changePwBtnLoading = document.getElementById('change-pw-btn-loading');\n const successMessage = document.getElementById('success-message');\n if (!currentPassword || !newPassword || !confirmPassword) {\n successMessage.style.display = 'block';\n successMessage.style.backgroundColor = 'var(--gold-yellow)';\n successMessage.style.color = 'black';\n successMessage.textContent = \"Please fill all password fields.\";\n setTimeout(()=>{\n successMessage.style.display = 'none';\n }, 3000);\n return;\n }\n if (newPassword !== confirmPassword) {\n successMessage.style.display = 'block';\n successMessage.style.backgroundColor = 'var(--gold-yellow)';\n successMessage.style.color = 'black';\n successMessage.textContent = \"New passwords don't match.\";\n setTimeout(()=>{\n successMessage.style.display = 'none';\n }, 3000);\n return;\n }\n try {\n // Show loading state\n changePwBtnText.textContent = \"Changing...\";\n changePwBtnLoading.style.display = \"inline-block\";\n // Update password in Cognito\n const result = await (0, $jUUxy.Authentication).changePassword(currentPassword, newPassword);\n if (result.success) {\n // Clear password fields\n document.getElementById('current-password').value = '';\n document.getElementById('new-password').value = '';\n document.getElementById('confirm-password').value = '';\n // Show success message\n successMessage.style.display = 'block';\n successMessage.style.backgroundColor = 'var(--grass-green)';\n successMessage.style.color = 'white';\n successMessage.textContent = \"Password changed successfully!\";\n // Play success sound\n const sound = new Audio('data:audio/wav;base64,UklGRiQAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQAAAAA=');\n sound.volume = 0.2;\n sound.play().catch((err)=>console.log(\"Sound playback error:\", err));\n // Hide message after 3 seconds\n setTimeout(()=>{\n successMessage.style.display = 'none';\n }, 3000);\n } else {\n // Show error message\n successMessage.style.display = 'block';\n successMessage.style.backgroundColor = 'var(--redstone-red)';\n successMessage.textContent = result.message || \"Failed to change password. Please try again.\";\n setTimeout(()=>{\n successMessage.style.display = 'none';\n }, 3000);\n }\n } catch (error) {\n console.error(\"Error changing password:\", error);\n // Show error message\n successMessage.style.display = 'block';\n successMessage.style.backgroundColor = 'var(--redstone-red)';\n successMessage.textContent = `Failed to change password: ${error.message || \"Please try again.\"}`;\n setTimeout(()=>{\n successMessage.style.display = 'none';\n }, 3000);\n } finally{\n // Reset button state\n changePwBtnText.textContent = \"Change Password\";\n changePwBtnLoading.style.display = \"none\";\n }\n });\n // Handle logout\n const navLogout = document.getElementById('nav-logout');\n navLogout.addEventListener('click', async (e)=>{\n e.preventDefault();\n try {\n const result = await (0, $jUUxy.Authentication).signOut();\n if (result.success) window.location.href = \"index.html\";\n else {\n console.error(\"Logout failed:\", result.message);\n window.location.href = \"index.html\";\n }\n } catch (error) {\n console.error(\"Error during logout:\", error);\n window.location.href = \"index.html\";\n }\n });\n}\n\n\n//# sourceMappingURL=profile.89c7fcc0.js.map\n","import { Authentication } from './auth.js';\r\nimport { fetchUserAttributes, updateUserAttributes, getCurrentUser, } from 'aws-amplify/auth';\r\n\r\n document.addEventListener('DOMContentLoaded', async () => {\r\n try {\r\n const isAuthenticated = await Authentication.checkStatus();\r\n if (!isAuthenticated) {\r\n window.location.href = 'auth.html';\r\n return;\r\n }\r\n document.body.style.visibility = 'visible';\r\n \r\n // Load user attributes from Cognito\r\n await loadUserProfile();\r\n \r\n // Load server stats\r\n loadServerStats();\r\n \r\n // Set up event listeners\r\n setupEventListeners();\r\n \r\n } catch (error) {\r\n console.error('Auth check failed:', error);\r\n window.location.href = 'auth.html';\r\n }\r\n });\r\n \r\n async function loadUserProfile() {\r\n try {\r\n const saveBtnText = document.getElementById('save-btn-text');\r\n const saveBtnLoading = document.getElementById('save-btn-loading');\r\n \r\n // Show loading state\r\n saveBtnText.textContent = \"Loading...\";\r\n saveBtnLoading.style.display = \"inline-block\";\r\n \r\n // Get user attributes from Cognito\r\n const userResult = await fetchUserAttributes();\r\n \r\n if (userResult.success && userResult.attributes) {\r\n // Update display name field\r\n const displayNameInput = document.getElementById('display-name');\r\n displayNameInput.value = userResult.attributes.name || '';\r\n }\r\n \r\n // Hide loading state\r\n saveBtnText.textContent = \"Save Changes\";\r\n saveBtnLoading.style.display = \"none\";\r\n \r\n } catch (error) {\r\n console.error(\"Error loading user profile:\", error);\r\n // Handle error - show error message to user\r\n const successMessage = document.getElementById('success-message');\r\n successMessage.style.display = 'block';\r\n successMessage.style.backgroundColor = 'var(--redstone-red)';\r\n successMessage.textContent = \"Error loading profile. Please try again.\"+error;\r\n \r\n setTimeout(() => {\r\n successMessage.style.display = 'none';\r\n }, 3000);\r\n }\r\n }\r\n \r\n function loadServerStats() {\r\n // In a real application, this would fetch from an API\r\n // For now, we'll just use sample data or localStorage\r\n \r\n try {\r\n // Get uptime from localStorage or set default\r\n const uptimeHours = parseInt(localStorage.getItem('server_uptime_hours') || '0');\r\n document.getElementById('uptime-value').textContent = uptimeHours;\r\n \r\n // Get player count from localStorage or set default\r\n const playerCount = parseInt(localStorage.getItem('server_player_count') || '0');\r\n document.getElementById('player-count-value').textContent = playerCount;\r\n \r\n // In a real app, you'd fetch this data from your server API\r\n // fetch('/api/server-stats')\r\n // .then(response => response.json())\r\n // .then(data => {\r\n // document.getElementById('uptime-value').textContent = data.uptimeHours;\r\n // document.getElementById('player-count-value').textContent = data.playerCount;\r\n // });\r\n \r\n } catch (error) {\r\n console.error(\"Error loading server stats:\", error);\r\n }\r\n }\r\n \r\n function setupEventListeners() {\r\n // Handle profile form submission\r\n const profileForm = document.getElementById('profile-form');\r\n profileForm.addEventListener('submit', async (e) => {\r\n e.preventDefault();\r\n \r\n const displayName = document.getElementById('display-name').value.trim();\r\n const saveBtnText = document.getElementById('save-btn-text');\r\n const saveBtnLoading = document.getElementById('save-btn-loading');\r\n const successMessage = document.getElementById('success-message');\r\n \r\n if (!displayName) {\r\n successMessage.style.display = 'block';\r\n successMessage.style.backgroundColor = 'var(--gold-yellow)';\r\n successMessage.style.color = 'black';\r\n successMessage.textContent = \"Please enter a display name.\";\r\n \r\n setTimeout(() => {\r\n successMessage.style.display = 'none';\r\n }, 3000);\r\n return;\r\n }\r\n \r\n try {\r\n // Show loading state\r\n\r\n saveBtnText.textContent = \"Saving...\";\r\n saveBtnLoading.style.display = \"inline-block\";\r\n \r\n const user = await getCurrentUser();\r\n // Update user attributes in Cognito\r\n console.log(\"Updating user attributes...\");\r\n console.log(user);\r\n const result = await updateUserAttributes({\r\n user,\r\n attributes: {\r\n \"custom:displayName\": displayName\r\n }\r\n });\r\n \r\n if (result.success) {\r\n // Show success message\r\n successMessage.style.display = 'block';\r\n successMessage.style.backgroundColor = 'var(--grass-green)';\r\n successMessage.style.color = 'white';\r\n successMessage.textContent = \"Your changes have been saved successfully!\";\r\n \r\n // Play success sound\r\n const sound = new Audio('data:audio/wav;base64,UklGRiQAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQAAAAA=');\r\n sound.volume = 0.2;\r\n sound.play().catch(err => console.log(\"Sound playback error:\", err));\r\n \r\n // Hide message after 3 seconds\r\n setTimeout(() => {\r\n successMessage.style.display = 'none';\r\n }, 3000);\r\n } else {\r\n // Show error message\r\n successMessage.style.display = 'block';\r\n successMessage.style.backgroundColor = 'var(--redstone-red)';\r\n successMessage.textContent = result.message || \"Failed to update profile. Please try again.\";\r\n \r\n setTimeout(() => {\r\n successMessage.style.display = 'none';\r\n }, 3000);\r\n }\r\n \r\n } catch (error) {\r\n console.error(\"Error updating profile:\", error);\r\n \r\n // Show error message\r\n successMessage.style.display = 'block';\r\n successMessage.style.backgroundColor = 'var(--redstone-red)';\r\n successMessage.textContent = \"Failed to update profile. Please try again.\";\r\n \r\n setTimeout(() => {\r\n successMessage.style.display = 'none';\r\n }, 3000);\r\n \r\n } finally {\r\n // Reset button state\r\n saveBtnText.textContent = \"Save Changes\";\r\n saveBtnLoading.style.display = \"none\";\r\n }\r\n });\r\n \r\n // Handle password change\r\n const changePasswordButton = document.getElementById('change-password-button');\r\n changePasswordButton.addEventListener('click', async () => {\r\n const currentPassword = document.getElementById('current-password').value;\r\n const newPassword = document.getElementById('new-password').value;\r\n const confirmPassword = document.getElementById('confirm-password').value;\r\n const changePwBtnText = document.getElementById('change-pw-btn-text');\r\n const changePwBtnLoading = document.getElementById('change-pw-btn-loading');\r\n const successMessage = document.getElementById('success-message');\r\n \r\n if (!currentPassword || !newPassword || !confirmPassword) {\r\n successMessage.style.display = 'block';\r\n successMessage.style.backgroundColor = 'var(--gold-yellow)';\r\n successMessage.style.color = 'black';\r\n successMessage.textContent = \"Please fill all password fields.\";\r\n \r\n setTimeout(() => {\r\n successMessage.style.display = 'none';\r\n }, 3000);\r\n return;\r\n }\r\n \r\n if (newPassword !== confirmPassword) {\r\n successMessage.style.display = 'block';\r\n successMessage.style.backgroundColor = 'var(--gold-yellow)';\r\n successMessage.style.color = 'black';\r\n successMessage.textContent = \"New passwords don't match.\";\r\n \r\n setTimeout(() => {\r\n successMessage.style.display = 'none';\r\n }, 3000);\r\n return;\r\n }\r\n \r\n try {\r\n // Show loading state\r\n changePwBtnText.textContent = \"Changing...\";\r\n changePwBtnLoading.style.display = \"inline-block\";\r\n \r\n // Update password in Cognito\r\n const result = await Authentication.changePassword(currentPassword, newPassword);\r\n \r\n if (result.success) {\r\n // Clear password fields\r\n document.getElementById('current-password').value = '';\r\n document.getElementById('new-password').value = '';\r\n document.getElementById('confirm-password').value = '';\r\n \r\n // Show success message\r\n successMessage.style.display = 'block';\r\n successMessage.style.backgroundColor = 'var(--grass-green)';\r\n successMessage.style.color = 'white';\r\n successMessage.textContent = \"Password changed successfully!\";\r\n \r\n // Play success sound\r\n const sound = new Audio('data:audio/wav;base64,UklGRiQAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQAAAAA=');\r\n sound.volume = 0.2;\r\n sound.play().catch(err => console.log(\"Sound playback error:\", err));\r\n \r\n // Hide message after 3 seconds\r\n setTimeout(() => {\r\n successMessage.style.display = 'none';\r\n }, 3000);\r\n } else {\r\n // Show error message\r\n successMessage.style.display = 'block';\r\n successMessage.style.backgroundColor = 'var(--redstone-red)';\r\n successMessage.textContent = result.message || \"Failed to change password. Please try again.\";\r\n \r\n setTimeout(() => {\r\n successMessage.style.display = 'none';\r\n }, 3000);\r\n }\r\n \r\n } catch (error) {\r\n console.error(\"Error changing password:\", error);\r\n \r\n // Show error message\r\n successMessage.style.display = 'block';\r\n successMessage.style.backgroundColor = 'var(--redstone-red)';\r\n successMessage.textContent = `Failed to change password: ${error.message || \"Please try again.\"}`;\r\n \r\n setTimeout(() => {\r\n successMessage.style.display = 'none';\r\n }, 3000);\r\n \r\n } finally {\r\n // Reset button state\r\n changePwBtnText.textContent = \"Change Password\";\r\n changePwBtnLoading.style.display = \"none\";\r\n }\r\n });\r\n \r\n // Handle logout\r\n const navLogout = document.getElementById('nav-logout');\r\n navLogout.addEventListener('click', async (e) => {\r\n e.preventDefault();\r\n try {\r\n const result = await Authentication.signOut();\r\n if (result.success) {\r\n window.location.href = \"index.html\";\r\n } else {\r\n console.error(\"Logout failed:\", result.message);\r\n window.location.href = \"index.html\";\r\n }\r\n } catch (error) {\r\n console.error(\"Error during logout:\", error);\r\n window.location.href = \"index.html\";\r\n }\r\n });\r\n };"],"names":["$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","$jUUxy","$2Izdj","$2yfk2","$bykg2","$1eecad6b029344eb$var$loadUserProfile","saveBtnText","document","getElementById","saveBtnLoading","textContent","style","display","userResult","fetchUserAttributes","success","attributes","displayNameInput","value","name","error","console","successMessage","backgroundColor","setTimeout","addEventListener","Authentication","checkStatus","window","location","href","body","visibility","$1eecad6b029344eb$var$loadServerStats","uptimeHours","parseInt","localStorage","getItem","playerCount","profileForm","e","preventDefault","displayName","trim","color","user","getCurrentUser","log","result","updateUserAttributes","sound","Audio","volume","play","catch","message","changePasswordButton","currentPassword","newPassword","confirmPassword","changePwBtnText","changePwBtnLoading","changePassword","navLogout","signOut"],"version":3,"file":"profile.89c7fcc0.js.map"}