import{b as h,i as d,a as g}from"../chunks/D-K5V_Al.min.js";const m="_lastScrollPos";function v(){if(window.location.hash)return!1;if(window.location.hostname==="localhost")return!0;try{return window.self!==window.top}catch{return!0}}function P(){if(!v())return;const t=S();if(t){const e=document.documentElement;e.style.scrollBehavior="auto",window.scrollTo({top:t}),setTimeout(()=>{e.style.removeProperty("scroll-behavior")})}window.addEventListener("beforeunload",()=>{E()})}function S(){const t=sessionStorage.getItem(m);if(!t)return null;try{const e=JSON.parse(t);if(e&&e.pathname&&e.pathname===window.location.pathname)return e.y||0}catch(e){return console.error("failed to get last scroll pos:",e),null}}function E(){const t={pathname:window.location.pathname,y:window.scrollY};sessionStorage.setItem(m,JSON.stringify(t))}const l={INVIEW:"inview",INVIEW_ACTIVE:"inview:active"};function k(t){const e=Array.from(document.getElementsByClassName(l.INVIEW));if(e.length>0){const r=new IntersectionObserver(s=>{s.forEach(i=>{i.isIntersecting&&(r.unobserve(i.target),window.requestAnimationFrame(()=>{i.target.classList.add(l.INVIEW_ACTIVE)}))})},{threshold:.4});e.forEach(s=>{r.observe(s)})}}const A=new Set(["help","preview","utm_campaign","utm_source","e","v"]);function u(){h()&&document.body.classList.add("is:android"),d()&&document.body.classList.add("is:ios"),window.requestIdleCallback?window.requestIdleCallback(f,{timeout:2e3}):window.setTimeout(f)}function f(){P(),y(),I(),b(),L(),R(),U(),k()}function y(){const t=new URLSearchParams(window.location.search);if(t.get("preview")==="true"){const r=t.get("help")==="true";document.querySelectorAll("a[href]").forEach(a=>{const n=a.getAttribute("href")||"";if(n.startsWith("/")){const o=new URL(n,window.location.href);o.searchParams.set("preview","true"),r&&o.searchParams.set("help","true"),t.get("v")&&o.searchParams.set("v",t.get("v")),a.href=o.toString()}}),document.querySelectorAll("select#language-picker option").forEach(a=>{const n=a.value||"";if(n.startsWith("/")){const o=new URL(n,window.location.href);o.searchParams.set("preview","true"),r&&o.searchParams.set("help","true"),a.value=o.toString()}})}}function I(){const t=new URLSearchParams(window.location.search),e={};let r=!1;if(t.forEach((n,o)=>{A.has(o)&&(e[o]=n,r=!0)}),!r)return;const s=n=>{const o=new URL(n,window.location.href);return Object.entries(e).forEach(([w,p])=>{o.searchParams.set(w,p)}),o.toString()};document.querySelectorAll("a[href]").forEach(n=>{const o=n.getAttribute("href")||"";o&&c(o)&&(n.href=s(o))}),document.querySelectorAll("select#language-picker option").forEach(n=>{const o=n.value||"";o.startsWith("/")&&(n.value=s(o))})}function c(t){if(t.startsWith("/"))return!0;const e=window.location.hostname,r=new RegExp(`^https?://${e}(:\\d+)?/`);return!!t.match(r)}function b(){document.querySelectorAll('mws-accordion-item [data-slot="accordion-item-content"] a').forEach(e=>{const r=e.getAttribute("href");r&&!c(r)&&(e.target="_blank",e.rel="noopener noreferrer")})}function L(){document.querySelectorAll("#footnotes a").forEach(e=>{const r=e.getAttribute("href");r&&!c(r)&&(e.target="_blank",e.rel="noopener noreferrer")})}function R(){const t=new URLSearchParams(window.location.search);document.querySelectorAll('a[href^="https://apps.apple.com/app/apple-store/"]').forEach(r=>{r.href=g(r.href,t)})}function U(){if(h()||d())return;document.querySelectorAll('a[href^="https://photos.google.com/link/create"]').forEach(e=>{e.href="/photos/download/"})}document.readyState!=="loading"?u():document.addEventListener("DOMContentLoaded",u);