/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ 		}
/******/ 	};
/******/
/******/ 	// define __esModule on exports
/******/ 	__webpack_require__.r = function(exports) {
/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 		}
/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
/******/ 	};
/******/
/******/ 	// create a fake namespace object
/******/ 	// mode & 1: value is a module id, require it
/******/ 	// mode & 2: merge all properties of value into the ns
/******/ 	// mode & 4: return value when already ns object
/******/ 	// mode & 8|1: behave like require
/******/ 	__webpack_require__.t = function(value, mode) {
/******/ 		if(mode & 1) value = __webpack_require__(value);
/******/ 		if(mode & 8) return value;
/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ 		var ns = Object.create(null);
/******/ 		__webpack_require__.r(ns);
/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ 		return ns;
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = "./blocks/rdg-handicappers-hub/assets/js/rdg-handicappers-hub-script.js");
/******/ })
/************************************************************************/
/******/ ({

/***/ "./blocks/rdg-handicappers-hub/assets/js/rdg-handicappers-hub-script.js":
/*!******************************************************************************!*\
  !*** ./blocks/rdg-handicappers-hub/assets/js/rdg-handicappers-hub-script.js ***!
  \******************************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {

eval("var handicappers_blocks = document.querySelectorAll(\".rdg-handicappers-hub\");\nif (handicappers_blocks.length > 0) {\n  handicappers_blocks.forEach(function (block) {\n    var block_id = block.querySelector(\".filters\").getAttribute(\"data-block-id\");\n    var dropdownSports = block.querySelectorAll(\".section-dropdown a\");\n    var selected = block.querySelector(\".dropdown-container .for-dropdown\");\n    var dropdownSportList = block.querySelector(\".dropdown\");\n    var sportData = block.querySelector(\".filter-sport\");\n    var defaultSports = block.querySelectorAll(\".default-sports a\");\n    var packageData = block.querySelector(\".filter-packages\");\n    dropdownSports.forEach(function (sportDropdown) {\n      sportDropdown.addEventListener(\"click\", function (event) {\n        event.preventDefault();\n\n        // Cerrar dropdown al seleccionar un deporte\n        dropdownSportList.checked = false;\n\n        // Si el sportDropdown no es el activo\n        if (!sportDropdown.classList.contains(\"active\")) {\n          // Mostrar capa de carga\n          block.querySelector(\"#wait\").style.display = \"block\";\n\n          // Setear el valor del deporte seleccionado en input para su posterior uso\n          sportData.setAttribute(\"data-sport-id\", sportDropdown.getAttribute(\"data-sport-id\"));\n\n          // Tomar el nombre del deporte seleccionado y mostrarlo en el dropdown\n          var sportName = sportDropdown.innerHTML.replace(/<i[^>]*>.*?<\\/i>/g, \"\").trim();\n\n          // Mostrar el deporte seleccionado en el dropdown\n          selected.innerHTML = sportName + ' <i class=\"uil fal fa-chevron-down\"></i>';\n\n          // Desactivar los deportes por defecto\n          deactivateDefaultSports(defaultSports);\n\n          // Desactivar los deportes del dropdown\n          deactivateDropdownSports(dropdownSports);\n          dropdownSports.forEach(function (sportD) {\n            // Eliminar la clase activate de los deportes del dropdown\n            sportD.classList.remove(\"active\");\n\n            // Eliminar el icono de check de los deportes del dropdown\n            sportD.innerHTML = sportD.innerHTML.replace(/<i[^>]*>.*?<\\/i>/g, \"\").trim();\n          });\n\n          // Agregar la clase active al deporte seleccionado\n          sportDropdown.classList.add(\"active\");\n\n          // Agregar el icono de check al deporte seleccionado\n          sportDropdown.innerHTML += ' <i class=\"fal fa-check\"></i>';\n\n          // Si el deporte seleccionado es el primero del dropdown, agregar la clase active al primer default sport\n          if (!sportDropdown.getAttribute(\"data-sport-id\")) {\n            defaultSports[0].classList.add(\"active\");\n          }\n\n          // Crear el llamado a la función getHandicappers con los parámetros necesarios\n          getHandicappers(block, sportDropdown, sportData, packageData);\n        }\n      });\n    });\n    defaultSports.forEach(function (sportDefault) {\n      sportDefault.addEventListener(\"click\", function (event) {\n        event.preventDefault();\n\n        // Si el sportDefault no es el activo\n        if (!sportDefault.classList.contains(\"active\")) {\n          // Setear el valor del deporte seleccionado en input para su posterior uso\n          sportData.setAttribute(\"data-sport-id\", sportDefault.getAttribute(\"data-sport-id\"));\n\n          // Mostrar capa de carga\n          block.querySelector(\"#wait\").style.display = \"block\";\n\n          // Si el default sport seleccionado no esta activo, se activa y se desactivan los demas\n          if (!sportDefault.classList.contains(\"active\")) {\n            // Desactivar los deportes por defecto\n            deactivateDefaultSports(defaultSports);\n\n            // Activar el default sport seleccionado\n            sportDefault.classList.add(\"active\");\n          }\n          var top_link = 1;\n          var top_link_selected = \"\";\n\n          // Si el default sport seleccionado es el primero, se activa solo el primer deporte del dropdown\n          if (!dropdownSports[0].classList.contains(\"active\")) {\n            dropdownSports.forEach(function (sportD) {\n              if (top_link == 1) {\n                top_link_selected = sportD.innerHTML;\n                sportD.classList.add(\"active\");\n                sportD.innerHTML += ' <i class=\"fal fa-check\"></i>';\n              } else {\n                sportD.classList.remove(\"active\");\n                sportD.innerHTML = sportD.innerHTML.replace(/<i[^>]*>.*?<\\/i>/g, \"\").trim();\n              }\n              top_link++;\n            });\n            selected.innerHTML = top_link_selected + '<i class=\"uil fal fa-chevron-down\"></i>';\n          }\n\n          // Crear el llamado a la función getHandicappers con los parámetros necesarios\n          getHandicappers(block, sportDefault, sportData, packageData);\n        }\n      });\n    });\n    var packages = block.querySelectorAll(\".filter-packages .package\");\n    packages.forEach(function (packageItem) {\n      packageItem.addEventListener(\"click\", function (event) {\n        event.preventDefault();\n\n        // Si el packageItem no es el activo\n        if (!packageItem.classList.contains(\"active\")) {\n          // Mostrar capa de carga\n          block.querySelector(\"#wait\").style.display = \"block\";\n\n          // Desactivar todos los packages\n          deactivatePackages(packages);\n\n          // Activar el package seleccionado\n          packageItem.classList.add(\"active\");\n\n          // Setear el valor del package seleccionado en packageData para su posterior uso\n          packageData.setAttribute(\"data-package-id\", packageItem.getAttribute(\"data-package-id\"));\n\n          // Crear el llamado a la función getHandicappers con los parámetros necesarios\n          // El segundo parametro también debe ser sportData, ya que es el deporte seleccionado\n          getHandicappers(block, sportData, sportData, packageData);\n        }\n      });\n    });\n  });\n}\nfunction deactivateDefaultSports(defaultSports) {\n  defaultSports.forEach(function (defaultSport) {\n    defaultSport.classList.remove(\"active\");\n  });\n}\nfunction deactivateDropdownSports(dropdownSports) {\n  dropdownSports.forEach(function (dropdownSport) {\n    dropdownSport.classList.remove(\"active\");\n    dropdownSport.innerHTML = dropdownSport.innerHTML.replace(/<i[^>]*>.*?<\\/i>/g, \"\").trim();\n  });\n}\nfunction deactivatePackages(packages) {\n  packages.forEach(function (packageItem) {\n    packageItem.classList.remove(\"active\");\n  });\n}\nfunction getHandicappers(block, sport, sportData, packageData) {\n  var ajax_url = rdg_handicappers_hub_var.ajaxurl;\n  var sport_id = sport.getAttribute(\"data-sport-id\");\n  var items = sportData.getAttribute(\"data-items\");\n  var duration = sportData.getAttribute(\"data-duration\");\n  var exclude = sportData.getAttribute(\"data-cappers-exclude\");\n  var packageId = packageData.getAttribute(\"data-package-id\");\n  fetch(ajax_url, {\n    method: \"POST\",\n    headers: {\n      \"Content-Type\": \"application/x-www-form-urlencoded\"\n    },\n    body: \"action=load_handicappers_hub&exclude=\".concat(exclude, \"&duration=\").concat(duration, \"&packageId=\").concat(packageId, \"&items=\").concat(items, \"&sport=\").concat(sport_id)\n  }).then(function (response) {\n    return response.text();\n  }).then(function (resultado) {\n    block.querySelector(\".handicappers\").innerHTML = resultado.trim();\n    block.querySelector(\"#wait\").style.display = \"none\";\n  })[\"catch\"](function (err) {\n    return console.error(err);\n  });\n}\n\n//# sourceURL=webpack:///./blocks/rdg-handicappers-hub/assets/js/rdg-handicappers-hub-script.js?");

/***/ })

/******/ });