-
Notifications
You must be signed in to change notification settings - Fork 0
/
bundle.min.d9847dec188cb3ba71e262769d7f64069d223c3a9713999a5da5f7aca5638686e15a900ac07cc755d19861961f24145ef2d608296933e4150cae87f4911a7dbb.js
1 lines (1 loc) · 5.2 KB
/
bundle.min.d9847dec188cb3ba71e262769d7f64069d223c3a9713999a5da5f7aca5638686e15a900ac07cc755d19861961f24145ef2d608296933e4150cae87f4911a7dbb.js
1
const themeToggle=document.querySelector(".theme-toggle"),chosenTheme=window.localStorage&&window.localStorage.getItem("theme"),chosenThemeIsDark=chosenTheme=="dark",chosenThemeIsLight=chosenTheme=="light";function detectOSColorTheme(){chosenThemeIsDark?document.documentElement.setAttribute("data-theme","dark"):chosenThemeIsLight?document.documentElement.setAttribute("data-theme","light"):window.matchMedia("(prefers-color-scheme: dark)").matches?document.documentElement.setAttribute("data-theme","dark"):document.documentElement.setAttribute("data-theme","light"),jQuery("img.color-scheme").get().map(function(e){file=e.src;var t=file.lastIndexOf(".");t<0&&(t=file.length),dataTheme=document.documentElement.getAttribute("data-theme"),dataTheme=="dark"&&!e.src.endsWith("-dark",t)?(newFile=file.substr(0,t)+"-dark"+file.substr(t,file.length),e.src=newFile):dataTheme=="light"&&e.src.endsWith("-dark")&&(newFile=file.substr(0,t-"-dark".length)+file.substr(t,file.length),e.src=newFile),e.style.width="100%"})}function showColorSchemeImages(){jQuery("img.color-scheme").get().map(function(e){e.style.display="block"}),jQuery("img.banner").get().map(function(e){e.style.display="block"})}function switchTheme(){chosenThemeIsDark?localStorage.setItem("theme","light"):chosenThemeIsLight?localStorage.setItem("theme","dark"):document.documentElement.getAttribute("data-theme")=="dark"?localStorage.setItem("theme","light"):localStorage.setItem("theme","dark"),detectOSColorTheme(),window.location.reload()}themeToggle?(themeToggle.addEventListener("click",switchTheme,!1),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",e=>e.matches&&detectOSColorTheme()),window.matchMedia("(prefers-color-scheme: light)").addEventListener("change",e=>e.matches&&detectOSColorTheme()),detectOSColorTheme()):localStorage.removeItem("theme");function menuUnderline(e,t){t?e.style.textDecoration="underline":e.style.textDecoration="none"}function menuDisplay(e,t){t?e.style.display="block":e.style.display="none"}function createCopyButton(e){const t=document.createElement("button");t.className="copy-code-button",t.type="button",t.innerText="⧉",t.addEventListener("click",()=>copyCodeToClipboard(t,e)),e.insertBefore(t,e.firstChild);const n=document.createElement("div");n.className="highlight-wrapper",e.parentNode.insertBefore(n,e),n.appendChild(e)}async function copyCodeToClipboard(e,t){const n=t.querySelector(":last-child > .chroma > code").innerText;try{var s=await navigator.permissions.query({name:"clipboard-write"});s.state=="granted"||s.state=="prompt"?await navigator.clipboard.writeText(n):copyCodeBlockExecCommand(n,t)}catch{copyCodeBlockExecCommand(n,t)}finally{e.blur(),e.innerText="📋",setTimeout(function(){e.innerText="⧉"},500)}}function copyCodeBlockExecCommand(e,t){const n=document.createElement("textArea");n.contentEditable="true",n.readOnly="false",n.className="copyable-text-area",n.value=e,t.insertBefore(n,t.firstChild);const s=document.createRange();s.selectNodeContents(n);const o=window.getSelection();o.removeAllRanges(),o.addRange(s),n.setSelectionRange(0,999999),document.execCommand("copy"),t.removeChild(n)}function searchFocus(){document.querySelector("#search > div > form > input").focus()}function switchTab(e,t,n){if(allTabItems=jQuery("[data-tab-group='"+t+"']"),targetTabItems=jQuery("[data-tab-group='"+t+"'][data-tab-item='"+n+"']"),e)var s,o,i,a=event.target.getBoundingClientRect().top;allTabItems.removeClass("active"),targetTabItems.addClass("active"),e&&(i=event.target.getBoundingClientRect().top-a,window.scrollTo(window.scrollX,window.scrollY+i),window.localStorage&&(o=window.localStorage.getItem("tabSelections"),o?(s=JSON.parse(o)):(s={}),s[t]=n,window.localStorage.setItem("tabSelections",JSON.stringify(s))))}function detectOs(){return navigator.appVersion.indexOf("Win")!=-1?"Windows":navigator.appVersion.indexOf("Mac")!=-1?"macOS":navigator.appVersion.indexOf("Linux")!=-1?"Linux":"Unknown"}function armString(){return navigator.platform.indexOf("aarch64")!=-1?" (aarch64":navigator.platform.indexOf("arm")!=-1||navigator.platform.indexOf("aarch")!=-1?" (aarch":""}function tryClickTab(e,t){var n=!1;for(button of e.children)n||(item=button.getAttribute("data-tab-item"),item.indexOf(t)!=-1&&(n=!0,button.click()));return n}function restoreTabSelections(){if(window.localStorage&&(selectionsJSON=window.localStorage.getItem("tabSelections"),selectionsJSON)){let e=JSON.parse(selectionsJSON);Object.keys(e).forEach(function(t){var n=e[t];switchTab(!1,t,n)});return}os=detectOs(),arm=armString(),jQuery(".tab-nav").get().forEach(e=>{tryClickTab(e,os+arm)||tryClickTab(e,os)})}document.querySelectorAll(".highlight").forEach(e=>createCopyButton(e)),window.addEventListener("load",function(){showColorSchemeImages(),restoreTabSelections()});const menuTrigger=document.querySelector(".menu-trigger"),menu=document.querySelector(".menu"),mobileQuery=getComputedStyle(document.body).getPropertyValue("--phoneWidth"),isMobile=()=>window.matchMedia(mobileQuery).matches,isMobileMenu=()=>{menuTrigger&&menuTrigger.classList.toggle("hidden",!isMobile()),menu&&menu.classList.toggle("hidden",isMobile())};isMobileMenu(),menuTrigger&&menuTrigger.addEventListener("click",()=>menu&&menu.classList.toggle("hidden")),window.addEventListener("resize",isMobileMenu)