/*! Fiesta 1.1.0 | MPL-2.0 | https://fiesta.rastrillo.org */ (function () { "use strict"; var ROOT = "[rst-shell-sidebar],[rst-shell-console],.rst-shell-sidebar,.rst-shell-console"; var INDEX = '[rst-shell-sidebar~="index"],[rst-shell-console~="index"],.rst-shell-sidebar--index,.rst-shell-console--index'; var PAGE = '[rst-shell-sidebar~="page"],[rst-shell-console~="page"],.rst-shell-sidebar--page,.rst-shell-console--page'; var BACK = "[rst-shell-back] > a[href],.rst-shell__back > a[href]"; var NAV = "[rst-shell-nav] a[href],.rst-shell__nav a[href]"; var NARROW = "(max-width: 799.98px)"; var RETURN = "rst-shell-return", WENT_BACK = "rst-shell-back"; function store(fn) { try { return fn(window.sessionStorage); } catch (e) { return null; } } function take(key) { return store(function (s) { var v = s.getItem(key); s.removeItem(key); return v; }); } function place(href) { var u = new URL(href, location.href); return u.origin === location.origin ? u.pathname + u.search : null; } function view(sel) { var r = document.querySelector(ROOT); return !!r && r.matches(sel); } function returnFocus() { if (document.prerendering || !view(INDEX)) return; var rec = take(RETURN), links, hit = null, i, id; if (!matchMedia(NARROW).matches) return; links = document.querySelectorAll(NAV); for (i = 0; rec && !hit && i < links.length; i++) { if (place(links[i].href) === rec) hit = links[i]; } if (!hit && location.hash) { try { id = decodeURIComponent(location.hash.slice(1)); } catch (e) { id = location.hash.slice(1); } hit = document.getElementById(id); if (hit && !hit.matches(NAV)) hit = null; } if (hit) hit.focus(); } function reveal(e) { var back = take(WENT_BACK) === location.pathname + location.search, a = window.navigation && navigation.activation; if (!back && a && a.navigationType === "traverse" && a.from && a.entry) back = a.entry.index < a.from.index; returnFocus(); if (e.viewTransition && e.viewTransition.types) e.viewTransition.types.add(back ? "back" : "forward"); } if ("onpagereveal" in window) window.addEventListener("pagereveal", reveal); else window.addEventListener("pageshow", returnFocus); function leave() { if (view(PAGE)) store(function (s) { s.setItem(RETURN, location.pathname + location.search); }); } window.addEventListener("onpageswap" in window ? "pageswap" : "pagehide", leave); document.addEventListener("click", function (e) { var a = e.target.closest && e.target.closest(BACK), nav = window.navigation, cur, prev, want; if (!a || e.defaultPrevented || e.button !== 0 || e.ctrlKey || e.metaKey || e.shiftKey || e.altKey) return; want = place(a.href); if (want !== null) store(function (s) { s.setItem(WENT_BACK, want); }); cur = nav && nav.currentEntry; if (!cur || cur.index < 1) return; prev = nav.entries()[cur.index - 1]; if (want !== null && prev && !prev.sameDocument && prev.url && place(prev.url) === want) { e.preventDefault(); history.back(); } }); })();