const throttle=(b,c)=>{let d,e,a;return function(){const f=this,g=arguments;d?(clearTimeout(e),e=setTimeout(function(){Date.now()-a>=c&&(b.apply(f,g),a=Date.now())},Math.max(c-(Date.now()-a),0))):(b.apply(f,g),a=Date.now(),d=!0)}},delayTime=420;window.addEventListener('DOMContentLoaded',b=>{const a=document.querySelector('.header');if(a){const b=window.getComputedStyle(a,null).getPropertyValue('height');document.documentElement.style.setProperty('--header-height',b)}},{once:!0}),window.addEventListener("DOMContentLoaded",j=>{const b=document.querySelector('.nav-toggle'),d=document.createElement('div');d.className='nav-toggle-inner',b.appendChild(d);for(let a=0;a<3;a++){const b=document.createElement('span');d.appendChild(b)}const c=document.getElementById('nav-toggle'),a=document.querySelector('.header'),e=document.querySelector('.nav-curtain');c.addEventListener('change',c=>{c.target.checked?(a.classList.add('open'),b.classList.add('open'),a.classList.remove('fade'),e.style='display: block'):(a.classList.remove('open'),b.classList.remove('open'),a.classList.add('fade'))}),e.addEventListener('animationend',a=>{c.checked||a.target.removeAttribute('style')}),window.addEventListener('scroll',throttle(function(){i()},delayTime));const g=window.getComputedStyle(document.documentElement,null).getPropertyValue('--max-width');let h=window.matchMedia(`(max-width: ${g})`);h.addListener(a=>{a.matches||f(!0)});function i(){const a=document.getElementById('search-input');if(a&&a===document.activeElement)return;f()}function f(d){c.checked&&(c.checked=!1,a.classList.remove('open'),b.classList.remove('open'),d?e.removeAttribute("style"):a.classList.add('fade'))}},{once:!0}),window.addEventListener("DOMContentLoaded",b=>{const a=document.getElementById('back-to-top');a!==null&&window.addEventListener('scroll',throttle(function(){window.scrollY>100?a.classList.add('show'):a.classList.remove('show')},delayTime))},{once:!0});const userPrefers=localStorage.getItem('theme');userPrefers==='dark'?changeModeMeta('dark'):userPrefers==='light'&&changeModeMeta('light'),window.matchMedia('(prefers-color-scheme: dark)').addListener(a=>{changeMode()}),window.addEventListener("DOMContentLoaded",b=>{changeMode();const a=document.getElementById('theme-switcher');a&&a.addEventListener('click',a=>{a.preventDefault(),getCurrentTheme()=="dark"?changeModeMeta('light'):changeModeMeta('dark'),changeMode(),storePrefers()})},{once:!0}),window.addEventListener('storage',function(a){if(a.key!=='theme')return;a.newValue==='dark'?changeModeMeta('dark'):changeModeMeta('light'),changeMode()});function getCurrentTheme(){return JSON.parse(window.getComputedStyle(document.documentElement,null).getPropertyValue("--theme-name"))}function changeModeMeta(a){document.documentElement.setAttribute('data-theme',a)}function changeMode(){const a=getCurrentTheme()==='dark',b=a?'#16171d':'#fff';if(document.querySelector('meta[name="theme-color"]').setAttribute('content',b),typeof mermaidConfig!='undefined'){const b=document.querySelectorAll('.mermaid');b.forEach(a=>{a.getAttribute('data-processed')?(a.removeAttribute('data-processed'),a.innerHTML=a.getAttribute('data-graph')):a.setAttribute('data-graph',a.textContent)}),a?(mermaidConfig.theme='dark',mermaid.initialize(mermaidConfig),mermaid.init()):(mermaidConfig.theme='default',mermaid.initialize(mermaidConfig),mermaid.init())}}function storePrefers(){window.localStorage.setItem('theme',getCurrentTheme())}window.addEventListener("DOMContentLoaded",d=>{const a='Copy',c='Copied!';document.querySelectorAll('.post-body > pre').forEach(a=>{let b=document.createElement('div');a.parentNode.replaceChild(b,a),b.appendChild(a)});function b(b){const d=document.querySelectorAll('table.lntable, .highlight > pre, .post-body > div > pre');d.forEach(e=>{var f;e.parentNode.style.position='relative';const d=document.createElement('button');d.className='copy-button',d.type='button',d.innerText=a,e.classList.contains('lntable')?(f=e.querySelectorAll('.lntd')[1]):(f=e.querySelector('code')),d.addEventListener('click',()=>{b.writeText(f.innerText).then(()=>{d.blur(),d.innerText=c,setTimeout(()=>{d.innerText=a},1e3)}).catch(a=>{d.innerText='Error',console.error(a)})}),e.appendChild(d),e.parentNode.addEventListener('mouseover',()=>{d.style='visibility: visible; opacity: 1'}),e.parentNode.addEventListener('mouseout',()=>{d.style='visibility: hidden; opacity: 0'})})}if(navigator&&navigator.clipboard)b(navigator.clipboard);else{const a=document.createElement('script');a.src='https://cdn.jsdelivr.net/npm/clipboard-polyfill@2.8.6/dist/clipboard-polyfill.min.js',a.defer=!0,a.onload=function(){b(clipboard)},document.head.appendChild(a)}},{once:!0}),window.addEventListener("DOMContentLoaded",m=>{let e=null,f=null,a=null,c=!1,b=null;const d=document.getElementById("search"),g=document.getElementById("search-input");d.addEventListener("submit",function(b){b.preventDefault();let a=g.value.trim();if(!a)return;h(a,!1)},!1),history.state&&history.state.type=="search"&&h(history.state.term,!0),window.addEventListener("popstate",function(a){if(a.state&&a.state.type=="search")h(a.state.term,!0);else if(!a.state&&b){let a=document.querySelector(".main-inner");while(a.firstChild)a.removeChild(a.firstChild);for(let c of b)a.appendChild(c);b=null}},!1);function h(b,f){g.value=b,d.setAttribute("data-running","true"),e?j(b,f):a?(a=b,c=f):(a=b,c=f,l())}function i(){d.removeAttribute("data-running");const b=document.querySelector('.header');b&&b.classList.contains('fade')&&g.blur(),a=null,c=!1}function l(){let b=new XMLHttpRequest;b.open("GET","../search.json"),b.responseType="json",b.addEventListener("load",function(g){let d=b.response;if(!d){console.error("Search index could not be downloaded, was it generated?"),i();return}f={},e=lunr(function(){const a="en";a!="en"&&lunr.hasOwnProperty(a)&&this.use(lunr[a]),this.ref("uri"),this.field("title"),this.field("subtitle"),this.field("content"),this.field("description"),this.field("categories"),this.field("tags");for(let a of d)this.add(a),f[a.uri]=a}),j(a,c)},!1),b.addEventListener("error",i,!1),b.send(null)}function j(a,c){try{let h=e.search(a),g=document.querySelector(".main-inner")||document.querySelector("main.home"),j=[];while(g.firstChild)j.push(g.firstChild),g.removeChild(g.firstChild);b||(b=j);let d=document.createElement("h1");d.id="search-results",d.className="list-title",h.length==0?d.textContent="No results found for “{}”".replace("{}",a):h.length==1?d.textContent="Found one result for “{}”".replace("{}",a):d.textContent="Found 13579 results for “{}”".replace("{}",a).replace("13579",h.length),g.appendChild(d),document.title=d.textContent;let l=document.getElementById("search-result");for(let c of h){let b=f[c.ref],a=l.content.cloneNode(!0);a.querySelector(".summary-title-link").href=a.querySelector(".read-more-link").href=b.uri,a.querySelector(".summary-title-link").textContent=b.title,a.querySelector(".summary").textContent=k(b.content,70),g.appendChild(a)}d.scrollIntoView(!0),c||history.pushState({type:"search",term:a},d.textContent,"#search="+encodeURIComponent(a));let i=document.querySelector('.nav-toggle');i&&i.classList.contains("open")&&document.getElementById(i.getAttribute("for")).click()}finally{i()}}function k(d,e){let a,b="",c=0,f=/(\S+)(\s*)/g;while(a=f.exec(d))if(c++,c<=e)b+=a[0];else{let c=a[1][a[1].length-1],d=a[2][0];if(/[.?!"]/.test(c)||d=="\n"){b+=a[1];break}b+=a[0]}return b}},{once:!0})