(function () {
"use strict";
var touchDevice = (window.matchMedia && window.matchMedia("(pointer: coarse)").matches) || /Android|iPhone|iPad|iPod|Mobile/i.test(window.navigator.userAgent || "");
if (touchDevice) document.documentElement.classList.add("ak-touch-device");
function initializeNavigation() {
var navigation = document.getElementById("akLinks");
var menuButton = document.querySelector("[data-ak-menu-toggle]");
var languageMenu = document.querySelector(".ak-lang-global");
if (!navigation || !menuButton) return;
function closeMenu(returnFocus) {
navigation.classList.remove("open");
menuButton.setAttribute("aria-expanded", "false");
if (returnFocus) menuButton.focus();
}
menuButton.addEventListener("click", function () {
var open = navigation.classList.toggle("open");
menuButton.setAttribute("aria-expanded", String(open));
if (open && languageMenu) languageMenu.removeAttribute("open");
});
navigation.addEventListener("click", function (event) {
if (event.target.closest("a")) closeMenu(false);
});
document.addEventListener("click", function (event) {
if (!navigation.classList.contains("open")) return;
if (!navigation.contains(event.target) && !menuButton.contains(event.target)) closeMenu(false);
});
document.addEventListener("keydown", function (event) {
if (event.key === "Escape") closeMenu(true);
});
window.addEventListener("resize", function () {
if (window.innerWidth > 1180) closeMenu(false);
}, { passive: true });
}
function initializeMotion() {
var videos = Array.prototype.slice.call(document.querySelectorAll("video.ak-motion"));
if (!videos.length) return;
var reducedMotion = window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)");
var canAnimate = !reducedMotion || !reducedMotion.matches;
function prepare(video) {
video.muted = true;
video.defaultMuted = true;
video.loop = true;
video.playsInline = true;
video.controls = false;
video.setAttribute("muted", "");
video.setAttribute("playsinline", "");
video.setAttribute("webkit-playsinline", "");
video.removeAttribute("controls");
}
function play(video) {
if (!canAnimate || document.hidden || video.dataset.akVisible === "false") return;
var attempt = video.play();
if (attempt && typeof attempt.catch === "function") attempt.catch(function () { video.classList.add("ak-motion-fallback"); });
}
videos.forEach(function (video) {
prepare(video);
if (!canAnimate) { video.pause(); video.removeAttribute("autoplay"); return; }
["loadedmetadata", "loadeddata", "canplay"].forEach(function (eventName) {
video.addEventListener(eventName, function () { play(video); }, { once: true });
});
play(video);
});
if ("IntersectionObserver" in window) {
var observer = new IntersectionObserver(function (entries) {
entries.forEach(function (entry) {
entry.target.dataset.akVisible = String(entry.isIntersecting);
if (entry.isIntersecting) play(entry.target); else entry.target.pause();
});
}, { rootMargin: "100px 0px", threshold: 0.02 });
videos.forEach(function (video) { observer.observe(video); });
}
document.addEventListener("visibilitychange", function () {
videos.forEach(function (video) { if (document.hidden) video.pause(); else play(video); });
});
}
function initializeBorderMotion() {
var selectors = [".ak-panel", ".ak-card", ".ak-icon", ".ak-step", ".ak-context-grid > p", ".ak-workflow-card", ".ak-workflow-detail .ak-workflow-steps li", ".ak-partner-card", ".ak-strip > div", ".ak-btn:not(.primary)", ".ak-motion-frame"].join(",");
var frames = Array.prototype.slice.call(document.querySelectorAll(selectors));
if (!frames.length) return;
var reduced = window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
frames.forEach(function (frame) { frame.classList.add("ak-border-flow"); });
if (reduced) return;
if ("IntersectionObserver" in window) {
var observer = new IntersectionObserver(function (entries) {
entries.forEach(function (entry) {
entry.target.dataset.akFrameVisible = String(entry.isIntersecting);
entry.target.classList.toggle("ak-border-active", entry.isIntersecting && !document.hidden);
});
}, { rootMargin: "120px 0px", threshold: 0.01 });
frames.forEach(function (frame) { observer.observe(frame); });
} else {
frames.forEach(function (frame) { frame.classList.add("ak-border-active"); });
}
}
function initialize() {
initializeNavigation();
initializeMotion();
initializeBorderMotion();
}
if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", initialize); else initialize();
})();