/******/ (() => { // webpackBootstrap
/******/ 	"use strict";
/******/ 	var __webpack_modules__ = ({

/***/ "./src/faq/view.js":
/*!*************************!*\
  !*** ./src/faq/view.js ***!
  \*************************/
/***/ ((module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var https_cdn_jsdelivr_net_npm_motion_11_18_2_esm__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! https://cdn.jsdelivr.net/npm/motion@11.18.2/+esm */ "https://cdn.jsdelivr.net/npm/motion@11.18.2/+esm");
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([https_cdn_jsdelivr_net_npm_motion_11_18_2_esm__WEBPACK_IMPORTED_MODULE_0__]);
https_cdn_jsdelivr_net_npm_motion_11_18_2_esm__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
/**
 * Use this file for JavaScript code that you want to run in the front-end
 * on posts/pages that contain this block.
 *
 * When this file is defined as the value of the `viewScript` property
 * in `block.json` it will be enqueued on the front end of the site.
 *
 * Example:
 *
 * ```js
 * {
 *   "viewScript": "file:./view.js"
 * }
 * ```
 *
 * If you're not making any changes to this file because your project doesn't need any
 * JavaScript running in the front-end, then you should delete this file and remove
 * the `viewScript` property from `block.json`.
 *
 * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#view-script
 */

// Import Motion au début du fichier

const faqModule = {
  initFollower() {
    const faqContainers = document.querySelectorAll('.orphic-wp-block-faq__container');
    faqContainers.forEach(container => {
      const follower = container.querySelector('.orphic-wp-block-faq__filter-follower');
      const filterItems = container.querySelector('.orphic-wp-block-faq__filter-items');
      const filterItemsArray = container.querySelectorAll('.orphic-wp-block-faq__filter-item');
      if (follower && filterItemsArray.length > 0) {
        // Position initiale
        follower.style.transform = `translateX(${filterItemsArray[0].offsetLeft}px)`;
        follower.style.width = `${filterItemsArray[0].offsetWidth}px`;
        follower.style.bottom = '-1px';
        filterItemsArray.forEach(item => {
          item.addEventListener('click', () => {
            const position = item.offsetLeft - filterItems.scrollLeft;
            (0,https_cdn_jsdelivr_net_npm_motion_11_18_2_esm__WEBPACK_IMPORTED_MODULE_0__.animate)(follower, {
              transform: `translateX(${position}px)`,
              width: `${item.offsetWidth}px`
            }, {
              duration: 0.3,
              easing: [.4, 0, .2, 1] // power2.inOut equivalent
            });
          });
        });
      }
    });
  },
  initPanel() {
    const faqContainers = document.querySelectorAll('.orphic-wp-block-faq__container');
    faqContainers.forEach(container => {
      const panels = container.querySelectorAll('.orphic-wp-block-faq__questions-panel');
      const filterItems = container.querySelectorAll('.orphic-wp-block-faq__filter-item');
      filterItems.forEach(item => {
        item.addEventListener('click', () => {
          filterItems.forEach(filterItem => {
            filterItem.classList.remove('active');
          });
          item.classList.add('active');
          panels.forEach(panel => {
            if (panel.dataset.id === item.dataset.id) {
              panel.classList.add('active');
            } else {
              panel.classList.remove('active');
            }
          });
        });
      });
    });
  },
  initContent() {
    const faqItems = document.querySelectorAll('.orphic-wp-block-faq__questions-faq-item');
    faqItems.forEach(item => {
      const header = item.querySelector('.orphic-wp-block-faq__questions-faq-item-header');
      const content = item.querySelector('.orphic-wp-block-faq__questions-faq-item-content');

      // Initialiser la hauteur à 0
      content.style.height = '0px';
      header.addEventListener('click', () => {
        const isActive = item.classList.contains('active');

        // Toggle la classe active sur l'item
        item.classList.toggle('active');

        // Animer la hauteur
        (0,https_cdn_jsdelivr_net_npm_motion_11_18_2_esm__WEBPACK_IMPORTED_MODULE_0__.animate)(content, {
          height: isActive ? '0px' : `${content.scrollHeight}px`
        }, {
          duration: 0.3,
          easing: [.25, .1, .25, 1] // power4.out equivalent
        });
      });
    });
  },
  initScrollFilter() {
    const filter = document.querySelector('.orphic-wp-block-faq__filter');
    const filterItems = filter.querySelector('.orphic-wp-block-faq__filter-items');
    const follower = filter.querySelector('.orphic-wp-block-faq__filter-follower');
    filter.addEventListener('wheel', event => {
      event.preventDefault();
      const newScrollLeft = filterItems.scrollLeft + event.deltaY;
      filterItems.scrollLeft = newScrollLeft;
      const activeFilterItem = filterItems.querySelector('.orphic-wp-block-faq__filter-item.active');
      if (activeFilterItem) {
        const position = activeFilterItem.offsetLeft - filterItems.scrollLeft;
        (0,https_cdn_jsdelivr_net_npm_motion_11_18_2_esm__WEBPACK_IMPORTED_MODULE_0__.animate)(follower, {
          transform: `translateX(${position}px)`
        }, {
          duration: 0.1
        });
      }
    });
    filterItems.addEventListener('scroll', () => {
      const activeFilterItem = filterItems.querySelector('.orphic-wp-block-faq__filter-item.active');
      if (activeFilterItem) {
        const position = activeFilterItem.offsetLeft - filterItems.scrollLeft;
        (0,https_cdn_jsdelivr_net_npm_motion_11_18_2_esm__WEBPACK_IMPORTED_MODULE_0__.animate)(follower, {
          transform: `translateX(${position}px)`
        }, {
          duration: 0.1
        });
      }
    });
  },
  init: function () {
    if (document.readyState === 'loading') {
      document.addEventListener('DOMContentLoaded', () => this.initializeFaq());
    } else {
      this.initializeFaq();
    }
  },
  initializeFaq: function () {
    this.initFollower();
    this.initPanel();
    this.initContent();
    this.initScrollFilter();
  }
};
faqModule.init();
__webpack_async_result__();
} catch(e) { __webpack_async_result__(e); } });

/***/ }),

/***/ "https://cdn.jsdelivr.net/npm/motion@11.18.2/+esm":
/*!*******************************************************************!*\
  !*** external "https://cdn.jsdelivr.net/npm/motion@11.18.2/+esm" ***!
  \*******************************************************************/
/***/ ((module) => {

module.exports = import("https://cdn.jsdelivr.net/npm/motion@11.18.2/+esm");;

/***/ })

/******/ 	});
/************************************************************************/
/******/ 	// 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/async module */
/******/ 	(() => {
/******/ 		var webpackQueues = typeof Symbol === "function" ? Symbol("webpack queues") : "__webpack_queues__";
/******/ 		var webpackExports = typeof Symbol === "function" ? Symbol("webpack exports") : "__webpack_exports__";
/******/ 		var webpackError = typeof Symbol === "function" ? Symbol("webpack error") : "__webpack_error__";
/******/ 		var resolveQueue = (queue) => {
/******/ 			if(queue && queue.d < 1) {
/******/ 				queue.d = 1;
/******/ 				queue.forEach((fn) => (fn.r--));
/******/ 				queue.forEach((fn) => (fn.r-- ? fn.r++ : fn()));
/******/ 			}
/******/ 		}
/******/ 		var wrapDeps = (deps) => (deps.map((dep) => {
/******/ 			if(dep !== null && typeof dep === "object") {
/******/ 				if(dep[webpackQueues]) return dep;
/******/ 				if(dep.then) {
/******/ 					var queue = [];
/******/ 					queue.d = 0;
/******/ 					dep.then((r) => {
/******/ 						obj[webpackExports] = r;
/******/ 						resolveQueue(queue);
/******/ 					}, (e) => {
/******/ 						obj[webpackError] = e;
/******/ 						resolveQueue(queue);
/******/ 					});
/******/ 					var obj = {};
/******/ 					obj[webpackQueues] = (fn) => (fn(queue));
/******/ 					return obj;
/******/ 				}
/******/ 			}
/******/ 			var ret = {};
/******/ 			ret[webpackQueues] = x => {};
/******/ 			ret[webpackExports] = dep;
/******/ 			return ret;
/******/ 		}));
/******/ 		__webpack_require__.a = (module, body, hasAwait) => {
/******/ 			var queue;
/******/ 			hasAwait && ((queue = []).d = -1);
/******/ 			var depQueues = new Set();
/******/ 			var exports = module.exports;
/******/ 			var currentDeps;
/******/ 			var outerResolve;
/******/ 			var reject;
/******/ 			var promise = new Promise((resolve, rej) => {
/******/ 				reject = rej;
/******/ 				outerResolve = resolve;
/******/ 			});
/******/ 			promise[webpackExports] = exports;
/******/ 			promise[webpackQueues] = (fn) => (queue && fn(queue), depQueues.forEach(fn), promise["catch"](x => {}));
/******/ 			module.exports = promise;
/******/ 			body((deps) => {
/******/ 				currentDeps = wrapDeps(deps);
/******/ 				var fn;
/******/ 				var getResult = () => (currentDeps.map((d) => {
/******/ 					if(d[webpackError]) throw d[webpackError];
/******/ 					return d[webpackExports];
/******/ 				}))
/******/ 				var promise = new Promise((resolve) => {
/******/ 					fn = () => (resolve(getResult));
/******/ 					fn.r = 0;
/******/ 					var fnQueue = (q) => (q !== queue && !depQueues.has(q) && (depQueues.add(q), q && !q.d && (fn.r++, q.push(fn))));
/******/ 					currentDeps.map((dep) => (dep[webpackQueues](fnQueue)));
/******/ 				});
/******/ 				return fn.r ? promise : getResult();
/******/ 			}, (err) => ((err ? reject(promise[webpackError] = err) : outerResolve(exports)), resolveQueue(queue)));
/******/ 			queue && queue.d < 0 && (queue.d = 0);
/******/ 		};
/******/ 	})();
/******/ 	
/******/ 	/* 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 used 'module' so it can't be inlined
/******/ 	var __webpack_exports__ = __webpack_require__("./src/faq/view.js");
/******/ 	
/******/ })()
;
//# sourceMappingURL=view.js.map