/******/ (() => { // webpackBootstrap
/******/ 	"use strict";
/******/ 	// The require scope
/******/ 	var __webpack_require__ = {};
/******/ 	
/************************************************************************/
/******/ 	/* webpack/runtime/make namespace object */
/******/ 	(() => {
/******/ 		// define __esModule on exports
/******/ 		__webpack_require__.r = (exports) => {
/******/ 			if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 				Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 			}
/******/ 			Object.defineProperty(exports, '__esModule', { value: true });
/******/ 		};
/******/ 	})();
/******/ 	
/************************************************************************/
var __webpack_exports__ = {};
/*!**********************************!*\
  !*** ./extension/js/register.js ***!
  \**********************************/
__webpack_require__.r(__webpack_exports__);
// js/register.js
// This script handles the user registration form.
document.addEventListener('DOMContentLoaded', function () {
  var registerForm = document.getElementById('register-form');
  var errorMessageDiv = document.getElementById('error-message');
  var successMessageDiv = document.getElementById('success-message');
  var passwordEl = document.getElementById('password');
  var confirmPasswordEl = document.getElementById('confirm-password');
  var showPasswordEl = document.getElementById('show-password');
  var submitButton = registerForm.querySelector('button[type="submit"]');

  // --- Show/Hide Password Logic ---
  showPasswordEl.addEventListener('change', function () {
    // Get the current state of the checkbox (true/false)
    var isChecked = showPasswordEl.checked;
    if (isChecked) {
      // If checked, change the input type to 'text' to show the password
      passwordEl.type = 'text';
      confirmPasswordEl.type = 'text';
    } else {
      // Otherwise, set it back to 'password' to hide it
      passwordEl.type = 'password';
      confirmPasswordEl.type = 'password';
    }
  });

  // --- Form Submission Logic ---
  registerForm.addEventListener('submit', function (e) {
    e.preventDefault(); // Prevent the form from submitting normally
    submitButton.disabled = true;
    var email = registerForm.email.value;
    var password = registerForm.password.value;
    var confirmPassword = registerForm['confirm-password'].value;
    // Get the new username value
    var username = registerForm.username.value.trim();

    // Clear previous messages
    errorMessageDiv.textContent = '';
    successMessageDiv.textContent = '';
    if (password !== confirmPassword) {
      errorMessageDiv.textContent = 'Passwords do not match.';
      submitButton.disabled = false;
      return;
    }

    // Send the registration request to the background script
    chrome.runtime.sendMessage({
      type: 'registerUser',
      target: 'background',
      // Send all three data points
      data: {
        email: email,
        password: password,
        username: username
      }
    }, function (response) {
      if (chrome.runtime.lastError) {
        errorMessageDiv.textContent = "Error: ".concat(chrome.runtime.lastError.message);
        submitButton.disabled = false;
        return;
      }
      if (response && response.success) {
        successMessageDiv.textContent = 'Registration successful! You can now sign in.';
        // Redirect to the sign-in page after a short delay
        setTimeout(function () {
          window.location.href = 'signin.html';
        }, 2000);
      } else {
        // Display the error from Firebase (e.g., "email already in use")
        errorMessageDiv.textContent = "Error: ".concat(response.error);
        submitButton.disabled = false;
      }
    });
  });
});
/******/ })()
;
//# sourceMappingURL=register.js.map