/*
 * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
 * This devtool is neither made for production nor for readable output files.
 * It uses "eval()" calls to create a separate source file in the browser devtools.
 * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
 * or disable the default devtool with "devtool: false".
 * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
 */
/******/ (() => { // webpackBootstrap
/******/ 	"use strict";
/******/ 	var __webpack_modules__ = ({

/***/ "./src/templates/site-layout/component/site-mode-switcher/site-mode-switcher.js":
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _site_mode_switcher_scss__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(\"./src/templates/site-layout/component/site-mode-switcher/site-mode-switcher.scss\");\n/* harmony import */ var utils_cookies_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(\"./utils/cookies.js\");\n\n\nDrupal.behaviors.siteModeSwitcher = {\n  attach: function attach(context) {\n    var HTML = document.documentElement;\n    var BUTTON_SITE_MODE_SWITCHER = context.querySelector('button[data-js=\"site-mode-switcher\"]');\n    var USER_SITE_MODE_VALUE = (0,utils_cookies_js__WEBPACK_IMPORTED_MODULE_1__.getCookie)('USER_SITE_MODE');\n    var siteModeTimeCheckInterval;\n    var siteModeTimeCheckTimeout;\n    var setDataSiteMode = function setDataSiteMode(siteMode) {\n      if (!document.startViewTransition) {\n        HTML.setAttribute('data-site-mode', siteMode);\n      } else {\n        document.startViewTransition(function () {\n          HTML.setAttribute('data-site-mode', siteMode);\n        });\n      }\n    };\n    var getSiteMode = function getSiteMode() {\n      if (USER_SITE_MODE_VALUE) {\n        HTML.setAttribute('data-site-mode', USER_SITE_MODE_VALUE);\n        return;\n      }\n\n      // Create fresh date for accurate time calculation\n      var NOW = new Date();\n\n      // Get time in America/New_York time zone (EST/EDT depending on date)\n      var DATE_FORMATTER = new Intl.DateTimeFormat('en-US', {\n        timeZone: 'America/New_York',\n        hour: 'numeric',\n        hour12: false\n      });\n      var DATE_PARTS = DATE_FORMATTER.formatToParts(NOW);\n      var HOURS = Number(DATE_PARTS.find(function (p) {\n        return p.type === 'hour';\n      }).value);\n\n      // Get day of week from the date object directly (0 = Sunday, 1 = Monday, ..., 6 = Saturday)\n      var DAY_OF_WEEK = new Date(NOW.toLocaleString(\"en-US\", {\n        timeZone: \"America/New_York\"\n      })).getDay();\n\n      // Check if it's Monday (1) through Friday (5)\n      var IS_WEEKDAY = DAY_OF_WEEK >= 1 && DAY_OF_WEEK <= 5;\n\n      // Check if it's between 9AM (9) and 6PM (18) - (17:59 is still work)\n      var IS_WORK_HOURS = HOURS >= 9 && HOURS < 18;\n      var siteMode = IS_WEEKDAY && IS_WORK_HOURS ? 'at-work' : 'at-play';\n      if (siteMode !== (0,utils_cookies_js__WEBPACK_IMPORTED_MODULE_1__.getCookie)('SYSTEM_SITE_MODE')) {\n        (0,utils_cookies_js__WEBPACK_IMPORTED_MODULE_1__.setCookie)('SYSTEM_SITE_MODE', siteMode);\n        setDataSiteMode(siteMode);\n      }\n    };\n    if (BUTTON_SITE_MODE_SWITCHER) {\n      BUTTON_SITE_MODE_SWITCHER.addEventListener('click', function () {\n        var currentSiteMode = HTML.getAttribute('data-site-mode');\n        var newSiteMode = currentSiteMode === 'at-work' ? 'at-play' : 'at-work';\n        (0,utils_cookies_js__WEBPACK_IMPORTED_MODULE_1__.setCookie)('USER_SITE_MODE', newSiteMode);\n        setDataSiteMode(newSiteMode);\n\n        // The user set their preference, stop checking for a site mode change.\n        clearInterval(siteModeTimeCheckInterval);\n        clearTimeout(siteModeTimeCheckTimeout);\n      });\n    }\n\n    // Prevent setting the site-mode when in storybook.\n    if (window.location.hostname === 'localhost') {\n      return;\n    }\n\n    // If the user has not selected their preference.\n    if (!USER_SITE_MODE_VALUE) {\n      /**\n       * Check every minute if the site-mode should change.\n       */\n      var siteModeTimeCheck = function siteModeTimeCheck() {\n        var NOW = new Date();\n        var msUntilNextMinute = (60 - NOW.getSeconds()) * 1000 - NOW.getMilliseconds();\n        siteModeTimeCheckTimeout = setTimeout(function () {\n          getSiteMode();\n          siteModeTimeCheckInterval = setInterval(getSiteMode, 60000);\n        }, msUntilNextMinute);\n      };\n      siteModeTimeCheck();\n    }\n    getSiteMode();\n  }\n};\n\n//# sourceURL=webpack://@naomi-2025/ui/./src/templates/site-layout/component/site-mode-switcher/site-mode-switcher.js?\n}");

/***/ }),

/***/ "./src/templates/site-layout/component/site-mode-switcher/site-mode-switcher.scss":
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

eval("{__webpack_require__.r(__webpack_exports__);\n// extracted by mini-css-extract-plugin\n\n\n//# sourceURL=webpack://@naomi-2025/ui/./src/templates/site-layout/component/site-mode-switcher/site-mode-switcher.scss?\n}");

/***/ }),

/***/ "./utils/cookies.js":
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   deleteCookie: () => (/* binding */ deleteCookie),\n/* harmony export */   getCookie: () => (/* binding */ getCookie),\n/* harmony export */   setCookie: () => (/* binding */ setCookie)\n/* harmony export */ });\n/**\n * Sets a cookie with the specified name, value, expiry, and path.\n *\n * @param {string} cookieName - The name of the cookie to set\n * @param {string} cookieValue - The value to store in the cookie\n * @param {number} expiryDays - Number of days until the cookie expires\n * @param {string} [cookiePath='/'] - The path where the cookie is accessible (defaults to '/')\n */\nvar setCookie = function setCookie(cookieName, cookieValue, expiryDays) {\n  var cookiePath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '/';\n  var date = new Date();\n  date.setTime(date.getTime() + expiryDays * 24 * 60 * 60 * 1000);\n  var expires = \"expires=\".concat(date.toUTCString());\n  document.cookie = \"\".concat(cookieName, \"=\").concat(cookieValue, \";\").concat(expires, \";path=\").concat(cookiePath, \";\");\n};\n\n/**\n * Retrieves the value of a cookie by its name.\n *\n * @param {string} name - The name of the cookie to retrieve\n * @returns {string} The cookie value if found, empty string if not found\n */\nvar getCookie = function getCookie(name) {\n  var cookieName = \"\".concat(name, \"=\");\n  var cookies = document.cookie.split(';');\n  for (var i = 0; i < cookies.length; i++) {\n    var cookie = cookies[i];\n    while (cookie.charAt(0) == ' ') {\n      cookie = cookie.substring(1);\n    }\n    if (cookie.indexOf(cookieName) == 0) {\n      return cookie.substring(cookieName.length, cookie.length);\n    }\n  }\n  return '';\n};\n\n/**\n * Deletes a cookie by setting its expiry date to the past.\n *\n * @param {string} cookieName - The name of the cookie to delete\n * @param {string} [cookiePath='/'] - The path where the cookie was set (defaults to '/')\n */\nvar deleteCookie = function deleteCookie(cookieName) {\n  var cookiePath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '/';\n  document.cookie = \"\".concat(cookieName, \"=;expires=Thu, 01 Jan 1970 00:00:01 GMT;path=\").concat(cookiePath, \";\");\n};\n\n//# sourceURL=webpack://@naomi-2025/ui/./utils/cookies.js?\n}");

/***/ })

/******/ 	});
/************************************************************************/
/******/ 	// The module cache
/******/ 	var __webpack_module_cache__ = {};
/******/ 	
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/ 		// Check if module is in cache
/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
/******/ 		if (cachedModule !== undefined) {
/******/ 			return cachedModule.exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = __webpack_module_cache__[moduleId] = {
/******/ 			// no module.id needed
/******/ 			// no module.loaded needed
/******/ 			exports: {}
/******/ 		};
/******/ 	
/******/ 		// Execute the module function
/******/ 		__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/ 	
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/ 	
/************************************************************************/
/******/ 	/* webpack/runtime/define property getters */
/******/ 	(() => {
/******/ 		// define getter functions for harmony exports
/******/ 		__webpack_require__.d = (exports, definition) => {
/******/ 			for(var key in definition) {
/******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ 				}
/******/ 			}
/******/ 		};
/******/ 	})();
/******/ 	
/******/ 	/* webpack/runtime/hasOwnProperty shorthand */
/******/ 	(() => {
/******/ 		__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ 	})();
/******/ 	
/******/ 	/* 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 });
/******/ 		};
/******/ 	})();
/******/ 	
/************************************************************************/
/******/ 	
/******/ 	// startup
/******/ 	// Load entry module and return exports
/******/ 	// This entry module can't be inlined because the eval devtool is used.
/******/ 	var __webpack_exports__ = __webpack_require__("./src/templates/site-layout/component/site-mode-switcher/site-mode-switcher.js");
/******/ 	
/******/ })()
;