(()=>{"use strict";const e="__theme__",t=()=>{const t=localStorage.getItem(e);return null!=t?t:"light"};new class{constructor(){this.listeners={}}on(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)}off(e,t){const n=this.listeners[e];n&&(this.listeners[e]=n.filter((e=>e!==t)))}emit(e,...t){const n=this.listeners[e];n&&n.length&&n.forEach((e=>{e(...t)}))}};const n=e=>Promise.all(e.map((e=>new Promise(((t,n)=>{if("css"===e.type){const o=document.createElement("link");o.href=e.url,o.rel="stylesheet",o.onload=()=>t(),o.onerror=()=>n(new Error(`Failed to load CSS from ${e.url}`)),document.head.appendChild(o)}else if("js"===e.type){const o=document.createElement("script");o.src=e.url,e.id&&(o.id=e.id),o.onload=()=>t(),o.onerror=()=>n(new Error(`Failed to load JS from ${e.url}`)),document.body.appendChild(o)}else n(new Error("Invalid resource type specified."))}))))),o=e=>{const{enable:t,jsCdn:o,cssCdn:l}=e;t&&n([{type:"css",url:l},{type:"js",url:o}]).then((e=>{e&&(e=>{const t=/\$\$(.+?)\$\$/g,n=/\\\[(.+?)\\\]/g;function o(e,t,n){let o;const l=[];for(;null!==(o=t.exec(e.nodeValue));){const t=document.createRange();t.setStart(e,o.index),t.setEnd(e,o.index+o[0].length),l.push(t)}for(const e of l){const t=e.toString().replace(/^\$\$|\$\$$|\\\[|\\\]$/g,""),o=document.createElement("span");o.innerHTML=window.katex.renderToString(t,{throwOnError:!1,displayMode:n}),e.deleteContents(),e.insertNode(o)}}document.querySelectorAll(e).forEach((e=>{const l=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let r;for(;r=l.nextNode();)o(r,t,!1),o(r,n,!0)}))})(".article-container")}))};var l=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var l=0;for(o=Object.getOwnPropertySymbols(e);l{const{enable:t,cdn:o}=e,r=l(e,["enable","cdn"]);t&&n([{type:"js",url:o}]).then((e=>{e&&(((e="vcomments",t=".article-container")=>{const n=document.querySelector(t);if(!n)return;const o=document.createElement("div");o.id=e,n.appendChild(o)})(),new window.Valine(Object.assign({el:"#vcomments"},r)))}))},c=()=>{((e,t)=>{const n=document.querySelector(e);n&&document.addEventListener("selectionchange",(()=>{const e=window.getSelection();if(e&&e.rangeCount>0&&!e.isCollapsed){const o=e.getRangeAt(0);if(n.contains(o.startContainer)&&n.contains(o.endContainer)){const l=e.toString(),r=[],c=document.createNodeIterator(o.commonAncestorContainer,NodeFilter.SHOW_ELEMENT);let s;for(;s=c.nextNode();)o.intersectsNode(s)&&r.push(s);const a=r.filter((e=>n!==e));t({selectedElements:a,selectedText:l,range:o})}}}))})(".article-container article",(e=>{const{range:t,selectedText:n}=e;document.addEventListener("mouseup",(()=>{!function(e){document.querySelectorAll(".text-tab").forEach((e=>e.remove()));const t=document.createElement("div");t.classList.add("text-tab");const n=document.createElement("ul");s.forEach((e=>{const t=document.createElement("li");t.innerHTML=`${e.icon}
${e.value}
`,n.appendChild(t)})),t.append(n),t.style.left=`${window.scrollX+e.left+e.width/2}px`,t.style.top=window.scrollY+e.top-50-10+"px",document.body.appendChild(t)}(t.getBoundingClientRect())}))}))},s=[{icon:'',value:"马克"},{icon:'',value:"颜色"},{icon:'',value:"直线"},{icon:'',value:"波浪线"}];const a='',i=e=>{document.querySelectorAll(".toc a").forEach((e=>e.classList.remove("active")));const t=document.querySelector('.toc a[href="'+e+'"]');t&&t.classList.add("active")};document.addEventListener("click",(function(e){const t=e.target.closest(".toc-link");if(t){const e=t.getAttribute("href");e&&i(e)}})),document.addEventListener("DOMContentLoaded",(function(){(e=>{const t=document.querySelector(e);if(t){const e=localStorage.getItem("scrolledHeight");e&&(t.scrollTop=Number(e))}})("main.scrollbar-obtrusive"),window.location.hash&&i(window.location.hash);const{mermaid:e,katex:l,valine:s}=window;o(Object.assign(Object.assign({},l),{enable:window.page.use.indexOf("katex")>-1})),(e=>{var t;const{enable:o,cdn:l,theme:r}=e;if(o){const e=document.getElementById("src-mermaid");e&&(null===(t=e.parentNode)||void 0===t||t.removeChild(e)),n([{type:"js",url:l,id:"src-mermaid"}]).then((e=>{e&&window.mermaid.initialize({startOnLoad:!0,theme:r||"neutral"})}))}})(Object.assign(Object.assign({},e),{enable:window.page.use.indexOf("mermaid")>-1})),r(Object.assign(Object.assign({},s),{enable:window.page.use.indexOf("valine")>-1})),document.querySelectorAll(".article-container article pre > code").forEach((e=>{const t=e.parentNode;if(!t)return;const n=document.createElement("div");n.classList.add("code-wrapper"),t.parentNode.insertBefore(n,t),n.appendChild(t);const o=document.createElement("div");o.classList.add("btn-wrapper");const l=t.getAttribute("data-language"),r=document.createElement("span");r.classList.add("lang"),r.textContent=l,o.appendChild(r);const c=document.createElement("span");c.className="copy-button",c.innerHTML=a,c.addEventListener("click",(function(){const t=e.textContent;navigator.clipboard.writeText(t).then((()=>{c.innerHTML='',setTimeout((()=>{c.innerHTML=a}),2e3)}))})),o.appendChild(c),n.appendChild(o)})),c(),d();const u=document.getElementById("toggle-theme");null==u||u.addEventListener("click",(()=>{const e=document.querySelector("#prism-theme");e?e.setAttribute("href",`/lib/prism/one-${t()}.css`):d()}))})),document.addEventListener("DOMContentLoaded",(function(){const e=document.querySelector("main.scrollbar-obtrusive");e&&e.addEventListener("scroll",(()=>(e=>{const t=document.querySelector(e);if(t){const e=t.scrollTop;localStorage.setItem("scrolledHeight",String(e))}})("main.scrollbar-obtrusive")))}));const d=()=>{const e=document.createElement("link");e.setAttribute("id","prism-theme"),e.rel="stylesheet",e.type="text/css",e.href=`/lib/prism/one-${t()}.css`,document.head.append(e)}})();