-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathoutline.min.js
2 lines (2 loc) · 65.8 KB
/
outline.min.js
1
2
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Outline=e()}(this,(function(){"use strict";function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var s=0,i=Array(e);s<e;s++)i[s]=t[s];return i}function e(t,e,s){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var i=s.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function s(e,s,i){if(s&&!Array.isArray(s)&&"number"==typeof s.length){var r=s.length;return t(s,void 0!==i&&i<r?i:r)}return e(s,i)}function i(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),s.push.apply(s,i)}return s}function r(t){for(var s=1;s<arguments.length;s++){var r=null!=arguments[s]?arguments[s]:{};s%2?i(Object(r),!0).forEach((function(s){e(t,s,r[s])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function n(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||function(e,s){if(e){if("string"==typeof e)return t(e,s);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?t(e,s):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}const o=t=>Object.prototype.toString.apply(t),l=t=>"function"==typeof t||"[object Function]"===o(t),h=(t,e=300)=>!!l(t)&&setTimeout((()=>{t()}),e),a=t=>("[object Object]"===o(t)||"object"==typeof t||l(t))&&null!==t,c=t=>Array.isArray?Array.isArray(t):"[object Array]"===o(t),u=t=>{let e={};return null===t?null:(c(t)?e=Array.from(t):(e=Object.assign({},t),Object.keys(e).forEach((s=>e[s]=a(t[s])?u(t[s]):t[s]))),e)},d=(t,e)=>{const s=Object.prototype.hasOwnProperty;return t&&s.call(t,e)},m=t=>"string"==typeof t,p=t=>!!(a(t)&&t.nodeName&&t.tagName&&1===t.nodeType),g=(t,e)=>{const s=new RegExp("(\\s|^)"+e+"(\\s|$)");let i,r;return!!p(t)&&(i=t.className,!!i&&(r=t.classList,r&&r.contains?t.classList.contains(e):!!s.exec(i)))},f=(t,e)=>{var s;let i,r;if(g(t,e))return!1;i=t.classList,null!==(s=i)&&void 0!==s&&s.add?e.indexOf(" ")>-1?e.split(" ").forEach((t=>{i.add(t)})):i.add(e):(r=t.className,r+=r.length>0?" "+e:e,t.className=r)},b=t=>t*t,y=(t,e,s)=>{const i=((t=null)=>{let e,s;return t?m(t)?s=document.querySelector(t):p(t)&&(s=t):(e=document.querySelectorAll("html,body"),s=e[0].scrollTop-e[1].scrollTop>=0?e[0]:e[1]),s})(t);let r=i.scrollTop,n=0;const o=e-r,h=i.scrollHeight,a=e-h<=0?e:h,c=t=>(l(s)&&s(t),!1),u=()=>{if(n+=1,o<0){if(r-=b(n),i.scrollTop=r,r<=e)return i.scrollTop=e,c(e)}else if(r+=b(n),i.scrollTop=r,r>=a)return i.scrollTop=a,c(a);requestAnimationFrame(u)};requestAnimationFrame(u)},v=(t=null)=>{let e,s;return t?m(t)?s=document.querySelector(t):p(t)&&(s=t):(e=document.querySelectorAll("html,body"),s=e[0].scrollTop-e[1].scrollTop>=0?e[0]:e[1]),s},$=t=>!!m(t)&&t.replace(/(^\s+)|(\s+$)/g,""),_=(t,e=!1,s=null)=>{const i=/^\d(\.|(\.\d+)*)\s?/gi,r=[];let n=1,o=0,h="";return t.forEach(((t,a)=>{const c=t.tagName,u=c.replace(/h/i,"");let d=parseInt(u,10),p=-1;var g;d>n?(o+=1,p=1===o?-1:a-1):d===n||d<n&&d>o?1===d?(o=1,p=-1):p=r[a-1].pid:d<=o&&(1===d?o=1:(o-=n-d,o<=1&&(o=1)),p=1===o?-1:((t,e,s)=>{let i,r,n=t[s-1];for(r=0;r<e;r+=1)i=n.pid,n=t[i];return i=n.pid,i})(r,n-d,a)),n=d,h=$((g=t.innerHTML,m(g)?g.replace(/<\/?[^>]+(>|$)/g,""):"")),e&&(h=$(h.replace(i,""))),l(s)&&(h=s(h)),r.push({id:a,pid:p,level:o,rel:`heading-${a}`,text:h,tagName:c})})),e?(t=>{const e={};return t.forEach((t=>{const s=JSON.stringify((t=>[t.pid])(t));e[s]=e[s]||[],e[s].push(t),t.index=e[s].length,-1===t.pid&&(t.code=String(t.index))})),Object.keys(e).forEach((t=>{e[t].forEach((t=>{const s=e[`[${t.id}]`];if(!s||!c(s))return!1;s.forEach((e=>{e.code=t.code+"."+e.index}))}))})),t})(r):r},x=t=>{const{articleElement:e,selector:i,showCode:r,chapterTextFilter:o,isTreeStructured:h}=t;let a=document.querySelector("#article"),c=[],u=[],d=null;return m(e)?a=document.querySelector(e):p(e)&&(a=e),a?(l(o)?d=o:!0===o&&(d=t=>t.replace(/\(.*?\)/,"()")),c=s(n,a.querySelectorAll(i||"h1,h2,h3,h4,h5,h6")),u=_(c,r,d),!0===h?((t,e,s)=>{const i={},r=[];return t.forEach(((t,s)=>{i[t[e]]=s,t.children=[]})),t.forEach((e=>{const n=t[i[e[s]]];-1!==e[s]?n.children.push(e):r.push(e)})),r})(u,"id","pid"):u):u};class w{constructor(t,e,s){return this.name=t,this.module=e,this.options=s,this.instance=null,this}execute(t){return t&&(this.options=t),this.instance=new this.module(this.options),this}destroy(){return this.instances=null,this}}class T{constructor(t,e,s){this.name=t,this.options=s,l(e)&&(this.action=e)}execute(t){return t&&(this.options=t),this.action(t),this}destroy(){this.name="",this.options=null,this.action=null}}const E=(t,e)=>{Object.keys(e).forEach((s=>{d(e,s)&&(t[s]=e[s])}))},S={},C=t=>d(S,t)&&S[t].length>0,L=(t,e=!0)=>e?C(t):(t=>{let e=C(t),s=t.lastIndexOf(".");for(;!e&&-1!==s;)s=(t=t.substring(0,s)).lastIndexOf("."),e=C(t);return e})(t),z=(t,e,s=!0)=>{const i=t=>{if(!C(t))return!1;S[t].forEach((t=>{const s=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]","[object BigInt64Array]","[object BigUint64Array]"].indexOf(o(e))>-1?e.toString():e;t.callback.call(t.context||t,s)}))},r=()=>{let e=t,s=t.lastIndexOf(".");for(;-1!==s;)e=e.substring(0,s),s=e.lastIndexOf("."),i(e);i(t),i("*")};if(!L(t))return!1;s?setTimeout(r,10):r()},k=(()=>{let t=0;return e=>(t+=1,e?e+"-"+t:"guid-"+t)})(),M=t=>{if(!d(S,t))return!1;delete S[t]},A=(t,e)=>{if(!L(t))return!1;e?(t=>{const e=Object.keys(S);if(!t||e.length<1)return!1;e.forEach((e=>{const s=S[e];let i;s.forEach(((e,r)=>{e.callback!==t&&e.token!==t||(i=e.topic,s.splice(-1,r))})),s.length<1&&M(i)}))})(e):M(t)};class O{constructor(t){this.name="component",this.attrs={},t&&this.initialize(t)}initialize(t){return this.attr(t).render().addListeners(),this}attr(t,e){const s=this.attrs;return m(t)?e&&d(s,t)?(s[t]=e,this):s[t]:a(t)?(E(s,t),this):0===arguments.length?s:this}render(){return this}refresh(){return this}destroy(){return this.removeListeners(),this}reload(t){let e=this.attr();return t&&(e=this.attr(t)),this.destroy().initialize(e),this}$emit(t,e){return z(t,e),this}$on(t,e){return((t,e,s=null)=>{const i=k();let r="symbol"==typeof t?t.toString():t;l(e)&&(S[r]||(S[r]=[]),S[r].push({topic:r,callback:e,context:s,token:i}))})(t,e,this),this}$off(t,e){return A(t,e),this}addListeners(){return this}removeListeners(){return this}}const N=[];let H,D;function F(t){for(;t.timeRemaining()>0&&N.length;){const t=N.shift();if(!l(t))return!1;t()}N.length?H=requestIdleCallback(F):(H=0,l(D)&&(D(),D=null))}void 0===window.requestIdleCallback&&(window.requestIdleCallback=function(t){const e=Date.now();return h((function(){t({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-e))}})}),10)},window.cancelIdleCallback=function(t){clearTimeout(t)});const j=(t,e=null)=>{N.push(t),l(e)&&(D=e),H||requestIdleCallback(F)},q=t=>{let e=t.offsetTop;return null!==t.offsetParent&&(e+=q(t.offsetParent)),e},R=(t,e="")=>{const s=e.replace(/^>/i,"");return!!(e&&s&&t)&&(t.matches?t.matches(s):!!t.msMatchesSelector&&t.msMatchesSelector(s))},U=t=>t.host&&t!==document&&t.host.nodeType?t.host:t.parentNode,I=["focusout","blur","focusin","focus","load","unload","mouseenter","mouseleave"],B=(t,e,s)=>{const i=I.indexOf(e)>-1;s._delegateListener&&delete(s=s._delegateListener)._delegateListener,function(t,e,s){const i=t._listeners;let r=-1;if(i.length<1)return!1;i.forEach(((t,i)=>{const n=t.fn;e===t.type&&(r=i,n===s&&(r=i))})),r>-1&&i.splice(r,1)}(t,e,s),t.removeEventListener(e,s,i)},P=function(t,e,s=!1){const i=m(t)?document.querySelector(t):t,r=i.childNodes,n=((t,e)=>{let s=t._listeners||[];return m(e)&&e&&(s=s.filter((t=>t.type===e))),s})(i,e);n.forEach((t=>{B(i,t.type,t.fn)})),(s||!0===e||1===arguments.length)&&i&&r&&r.forEach((t=>{p(t)&&P(t,e,s)}))},V=(t,e,s)=>{if(!l(s))return P(t,e),!1;B(t,e,s)},W=(t,e,s,i,r,n,o=!1)=>{const l=I.indexOf(s)>-1,h=function(l){const a=function(t){const e=t.target;return(s=e)&&3===s.nodeType?s.parentNode:s;var s}(l),c=((t,e,s,i)=>{const r=s||document;if(!t)return null;do{if(null!=e&&(e.startsWith(">")?t.parentNode===r&&R(t,e):R(t,e))||i&&t===r)return t;if(t===r)break}while(t=U(t))})(a,e,t);let u=n||t;l.delegateTarget=c,!0===n&&(u=r),c&&(!0===o&&V(t,s,h),i.call(u,l,r))};if(!t)return!1;t._listeners||(t._listeners=[]),t._listeners.push({el:t,selector:e,type:s,fn:h,data:r,context:n,capture:l}),i._delegateListener=h,t.addEventListener(s,h,l)},Q=function(t){t.stopPropagation(),t.preventDefault()},J=[],Y=(t,e="icon")=>m(t)?((t,e="icon")=>{const s=/id="(.*?)"/,i=/^(\w+)-/;return J.find((r=>{const n=s.exec(r)[1];return i.exec(n)[1]===e&&n===("icon"===e?`${e}-${t}`:`${e}-icon-${t}`)}))})(t,e):s(n,J),G=(t="")=>{const e=document.body;let s=document.querySelector("#outline-icons"),i=[];(t=>{if(!t)return!1;c(t)&&t.length>0?t.forEach((t=>{-1===J.indexOf(t)&&m(t)&&J.push(t)})):m(t)&&J.push(t)})(t),i=Y(),s?s.innerHTML=i.join(""):(s=document.createElement("div"),s.innerHTML=`<svg id="outline-icons" aria-hidden="true" style="position:absolute;display:none;width:0;height:0;overflow:hidden;">${i.join("")}</svg>`,e.insertBefore(s.firstChild,e.firstChild))},K=t=>{return!(!a(t)||!(p(t)||(t=>!(!a(t)||"[object NodeList]"!==o(t)))(t)||(e=t,a(e)&&"[object DocumentFragment]"===o(e))||(t=>!(!a(t)||!("[object Text]"===o(t)||t.tagName&&3===t.nodeType)))(t)));var e},X=(t,e,s)=>{let i=t.tagName.toLowerCase();switch(e){case"style":t.style.cssText=s;break;case"value":"input"===i||"textarea"===i?t.value=s:t.setAttribute(e,s);break;case"htmlFor":t.setAttribute("for",s);break;case"className":f(t,s);break;case"innerHTML":t.innerHTML=s;break;case"innerText":t.innerText=s;break;default:t.setAttribute(e,s)}},Z=(t,e)=>{if(!t||!a(e))return!1;Object.keys(e).forEach((s=>{const i=e[s];d(e,s)&&X(t,s,i)}))},tt=(t,e,s)=>{const i=document.createDocumentFragment(),r=document.createElement(t),n=t=>K(t)||m(t),o=t=>{let e;if(!n(t))return!1;K(t)?e=t:m(t)&&(e=document.createTextNode(t)),i.appendChild(e)};return a(e)?Z(r,e):c(e)&&e.every((t=>n(t)))?e.forEach((t=>{o(t)})):K(e)?o(e):m(e)&&o(document.createTextNode(e)),c(s)?s.forEach((t=>{o(t)})):o(s),r.appendChild(i),r},et=(t,e={})=>{const s="outline-icon",i=e.size||0,r=e.color||"",n=e.iconSet||"",o=c(i)?i[0]:i,l=c(i)?i[1]:i,h=i?`width:${o}px;height:${l}px;`:"",a=r?h+`color:${r}`:h,u=e.attrs||{},d=document.createElement("i");let p,g="",f="";return m(t)?((t=>{const e=new RegExp("^\\s*(?:<\\?xml[^>]*>\\s*)?(?:<\\!doctype svg[^>]*\\s*(?:\\[?(?:\\s*<![^>]*>\\s*)*\\]?)*[^>]*>\\s*)?<svg[^>]*>[^]*<\\/svg>\\s*$\\s*$","i");return m(t)&&e.test(t)})(t)?f=t:(g=n&&"icon"!==n?`xlink:href="#${n}-icon-${t}"`:`xlink:href="#icon-${t}"`,f=`<svg><use ${g}></use></svg>`),d.innerHTML=f,u.className?u.className=`${s} ${u.className}`:u.className=s,Z(d,u),p=d.querySelector("svg"),Z(p,{"aria-hidden":!0,xmlns:"http://www.w3.org/2000/svg",class:"outline-icon__svg",width:200,height:200,style:a}),d):null},st=(t,e={})=>et(t,e),it=(t,e)=>{var s;let i,r=t.className;if(!r||!g(t,e))return!1;i=t.classList,null!==(s=i)&&void 0!==s&&s.remove?i.remove(e):(r=$(r.replace(e,"")),t.className=r)},rt=(t,e=!0,s=!0)=>{const i="outline-heading",r=t.innerHTML;let n;if(t.innerHTML=r.replace(/^\d+(\.?\d+)*\s?/gi,""),t.removeAttribute("id"),t.removeAttribute("data-id"),it(t,i),!e)return!1;var o;n=t.querySelector(`.${i}__anchor`),s&&it(t,`${i}_start`),o=$(t.className),m(o)&&""===o&&t.removeAttribute("class"),n&&t.removeChild(n)},nt=['<symbol id="outline-icon-hash" viewBox="0 0 24 24"><path d="M14.216 10l-0.444 4h-3.988l0.444-4zM15.006 2.89l-0.568 5.11h-3.988l0.543-4.89c0.061-0.549-0.335-1.043-0.883-1.104s-1.043 0.335-1.104 0.884l-0.568 5.11h-4.438c-0.552 0-1 0.448-1 1s0.448 1 1 1h4.216l-0.444 4h-3.772c-0.552 0-1 0.448-1 1s0.448 1 1 1h3.549l-0.543 4.89c-0.061 0.549 0.335 1.043 0.883 1.104s1.043-0.335 1.104-0.883l0.569-5.111h3.988l-0.543 4.89c-0.061 0.549 0.335 1.043 0.883 1.104s1.043-0.335 1.104-0.883l0.568-5.111h4.438c0.552 0 1-0.448 1-1s-0.448-1-1-1h-4.216l0.444-4h3.772c0.552 0 1-0.448 1-1s-0.448-1-1-1h-3.549l0.543-4.89c0.061-0.549-0.335-1.043-0.883-1.104s-1.043 0.335-1.104 0.883z"></path></symbol>'];class ot extends O{constructor(t){super(),this.name="anchors",this._default(),t&&this.initialize(t)}_default(){return this.attrs=u(ot.DEFAULTS),this.$articleElement=null,this.$scrollElement=null,this.$headings=[],this}initialize(t){let e,s,i,r;return this.attr(t),r=this.attr("articleElement"),s=this.attr("scrollElement"),e=this.attr("created"),m(r)?i=document.querySelector(r):p(r)&&(i=r),i?(this.$articleElement=i,this.$scrollElement=v(s),this.$headings=this.getHeadings(),this.$headings.length<1||(l(e)&&e.call(this),this.render().addListeners()),this):this}getHeadings(){const t=this.$articleElement,e=this.attr("selector");return s(n,t.querySelectorAll(e))}count(){return this.getHeadings().length}render(){const t=this.attr("articleElement"),e=this.attr("selector"),s=this.attr("showCode"),i=this.attr("chapterTextFilter"),r=this.attr("mounted"),n=x({articleElement:t,selector:e,showCode:s,chapterTextFilter:i});return G(nt),this._paint(n),l(r)&&r.call(this),this}erase(){return this._remove(),this}_paint(t){const e=400,i=this.attr("hasAnchor"),r=this.attr("isAtStart"),o=this.attr("showCode"),h=this.attr("anchorURL"),a=this.attr("anchorLinkFilter"),c=this.count(),u=s(n,this.$headings),d=(s,n)=>{s.forEach(((s,c)=>{const u=c+n*e,d=t[u].code;((t,e,s)=>{const i="outline-heading",r=s.hasAnchor||!0,n=s.isAtStart||!0,o=s.showCode||!1,h=s.chapterCode||"",a=s.anchorURL||"",c=s.anchorLinkFilter||null,u=`heading-${e}`,d={id:u,className:n?`${i} ${i}_start`:i,"data-id":e},m=$(t.innerHTML);let p,g,f;if(o&&(d.innerHTML=h+" "+m,d["data-code"]=h),Z(t,d),!r)return!1;p=a||(l(c)?c(t.tagName.toLowerCase(),m,e):`#${u}`),f=st("hash",{iconSet:"outline"}),g=tt("a",{id:`anchor-${e}`,className:`${i}__anchor anchor-${e}`,href:p,target:a?"_blank":"self","data-id":e},f),t.appendChild(g)})(s,u,{hasAnchor:i,isAtStart:r,showCode:o,chapterCode:d,anchorURL:h,anchorLinkFilter:a})}))};let m=-1;if(c>e)for(m+=1,d(u.splice(0,e),0);u.length>0;){const t=u.splice(0,e);j((()=>{d(t,m+=1)}),(()=>{this.$emit("anchors:all:paint")}))}else d(u,0);return this}_remove(){const t=this.attr("hasAnchor"),e=this.attr("isAtStart");return this.$headings.forEach((s=>{rt(s,t,e)})),this}refresh(t){const e=this.attr("articleElement"),s=this.attr("selector"),i=this.attr("showCode"),r=this.attr("chapterTextFilter");return this.$headings=this.getHeadings(),this.erase()._paint(t||x({articleElement:e,selector:s,showCode:i,chapterTextFilter:r})),this}scrollTo(t,e){const s=this.$scrollElement;return y(s,t,e),this}destroy(){const t=this.attr("beforeDestroy"),e=this.attr("afterDestroy");return l(t)&&t.call(this),this.removeListeners()._remove()._default(),l(e)&&e.call(this),this}onAnchorTrigger(t){const e=this.attr("anchorURL"),s=this.attr("afterScroll"),i=this.attr("stickyHeight"),r=t.delegateTarget.parentNode,n=q(r)-(i+10),o=this.$scrollElement,a=o.scrollHeight-o.clientHeight;return this.scrollTo(n,(()=>{l(s)&&s.call(this,"anchor"),h((()=>{this.$emit("toolbar:update",{top:n,min:0,max:a})}))})),e||Q(t),this}onRefresh(t){return this.refresh(t),this}addListeners(){const t=this.$articleElement;return this.count()<1||(W(t,".outline-heading__anchor","click",this.onAnchorTrigger,this,!0),this.$on("anchors:refresh",this.onRefresh)),this}removeListeners(){const t=this.$articleElement;return this.count()<1||(V(t,"click",this.onAnchorTrigger),this.$off("anchors:refresh",this.onRefresh)),this}}ot.DEFAULTS=u({scrollElement:"html,body",articleElement:"#article",selector:"h1,h2,h3,h4,h5,h6",stickyHeight:0,anchorURL:"",hasAnchor:!0,isAtStart:!0,showCode:!1,created:null,mounted:null,afterScroll:null,beforeDestroy:null,afterDestroy:null,chapterTextFilter:null,anchorLinkFilter:null});const lt=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","math","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rb","rp","rt","rtc","ruby","s","samp","script","search","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"],ht=t=>{let e,s,i;return!!m(t)&&(e=$(t).slice(0,1e3),s=/\s*<!doctype html>|<html\b[^>]*>|<body\b[^>]*>|<x-[^>]+>/i,i=new RegExp(lt.map((t=>`<${t}\\b[^>]*>`)).join("|"),"i"),s.test(e)||i.test(e))},at=t=>t.replace(/<script[^>]*>.*?<\/script>/gi,""),ct=(t,e)=>{document.documentElement.style.setProperty(t,e)};let ut=2e3;const dt=t=>(t?ut=t:ut+=1,ct("--outline-zIndex",`${ut}`),ut),mt=['<symbol id="outline-icon-close" viewBox="0 0 1024 1024"><path d="M536.96 491.648L310.592 265.344a32 32 0 1 0-45.248 45.248L491.584 536.96l-226.304 226.304a32 32 0 0 0 45.312 45.248l226.24-226.304 226.304 226.304a32 32 0 0 0 45.248-45.248L582.144 536.896l226.304-226.24a32 32 0 0 0-45.248-45.248L536.896 491.584z"></path></symbol>'];class pt extends O{constructor(t){super(),this.name="drawer",this._default(),this.zIndex=0,t&&this.initialize(t)}_default(){return this.attrs=u(pt.DEFAULTS),this.title="",this.closed=!1,this.$el=null,this.$modal=null,this.$header=null,this.$title=null,this.$close=null,this.$main=null,this.$footer=null,this.$overlay=null,this}initialize(t){let e;return this.attr(t),this.title=this.attr("title"),e=this.attr("created"),l(e)&&e.call(this),this.render().addListeners(),this}setTitle(t){return this.attr("title",t),this.title=t,this.$title.innerHTML=t,this}isClosed(){return this.closed}render(){const t=this.attr("mounted"),e=this.attr("size"),s=this.attr("placement"),i=this.attr("hasClose"),r=this.attr("hasOverlay"),n=this.attr("hasOffset"),o=this.attr("hasPadding"),h=this.attr("autoHeight"),a=this.attr("overflow"),c=this.attr("customClass");let u,d,m,p,g,b,y,v,$="outline-drawer__main";return G(mt),this.zIndex=dt(),p=tt("h2",{className:"outline-drawer__title"},this.title),this.$title=p,i&&(g=tt("div",{className:"outline-drawer__close"},st("close",{iconSet:"outline",size:20})),this.$close=g),m=tt("header",{className:"outline-drawer__header"},[p,g]),this.$header=m,"hidden"===a&&($+=" overflow-hidden"),b=tt("div",{className:$}),this.$main=b,o||f(b,"outline-drawer_full"),y=tt("footer",{className:"outline-drawer__footer"}),this.$footer=y,d=tt("div",{className:`outline-drawer__modal outline-drawer_${s} outline-drawer_${e} outline-drawer_closed`},[m,b,y]),this.$modal=d,n&&f(d,"outline-drawer_offset"),h&&f(d,"outline-drawer_auto"),c&&f(d,c),r&&(v=tt("div",{className:"outline-drawer__overlay"}),this.$overlay=v),u=tt("div",{className:"outline-drawer"},[d,v]),this.$el=u,document.body.appendChild(u),l(t)&&t.call(this),this}erase(){return this.$main.innerHTML="",this}_paint(t){let e=null;return l(t)?e=t():K(t)?e=t:ht(t)&&(e=((t,e)=>{const i=document.createDocumentFragment();if(!t||!ht(t)&&!m(t)&&!p(t))return null;if(ht(t)){const e=tt("div");let r=[];return e.innerHTML=at(t),r=s(n,e.childNodes),r.forEach((t=>{i.appendChild(t)})),i}if(!m(e))return t.innerHTML;t.innerHTML=at(e)})(t)),e&&this.$main.appendChild(e),this}_remove(){return document.body.removeChild(this.$el),this}refresh(t){return this.erase()._paint(t),this}open(){const t=this.attr("afterOpened"),e=this.$modal;return f(this.$el,"outline-drawer_opened"),it(e,"outline-drawer_closed"),f(e,"outline-drawer_opened"),h((()=>{this.closed=!1,l(t)&&t.call(this)})),this}close(){const t=this.attr("afterClosed"),e=this.$modal;return it(e,"outline-drawer_opened"),f(e,"outline-drawer_closed"),h((()=>{it(this.$el,"outline-drawer_opened"),this.closed=!0,l(t)&&t.call(this)})),this}toggle(){const t=this.attr("afterToggle"),e=this.isClosed();return e?this.open():this.close(),l(t)&&h((()=>{t.call(this,e)})),this}destroy(){const t=this.attr("afterDestroy"),e=this.attr("beforeDestroy");let s=this.zIndex;return l(e)&&e.call(this),this.removeListeners()._remove()._default(),s-=1,dt(s),this.zIndex=0,l(t)&&t.call(this),this}onClose(){return this.close(),this}addListeners(){const t=this.attr("hasClose"),e=this.attr("hasOverlay"),s=this.attr("closeOnClickModal"),i=this.$el;return t&&W(i,".outline-drawer__close","click",this.onClose,this,!0),e&&s&&W(i,".outline-drawer__overlay","click",this.onClose,this,!0),this}removeListeners(){const t=this.attr("hasClose"),e=this.attr("hasOverlay"),s=this.$el;return t||e?(V(s,"click",this.onClose),this):this}}pt.DEFAULTS=u({placement:"rtl",title:"标题",size:"regular",hasClose:!0,hasOverlay:!0,hasOffset:!1,hasPadding:!0,autoHeight:!0,closeOnClickModal:!0,overflow:"auto",created:null,mounted:null,afterClosed:null,afterOpened:null,afterScroll:null,beforeDestroy:null,afterDestroy:null,afterToggle:null});const gt=(t,e,s,i,r,n=!1)=>{const o=I.indexOf(e)>-1,h=function(o){let l=r||t;!0===r&&(l=i),!0===n&&V(t,e,h),s.call(l,o,i)};if(!l(s))return!1;t._listeners||(t._listeners=[]),t._listeners.push({el:t,type:e,fn:h,data:i,context:r,capture:o}),s._delegateListener=h,t.addEventListener(e,h,o)},ft=(t,e)=>getComputedStyle(t)[e],bt="outline-navigator_hidden",yt="outline-navigator_expanded",vt="outline-navigator_folded";class $t extends O{constructor(t){super(),this.name="navigator",this._default(),this.scrollTimer=null,this.resizeTimer=null,this.observerTimer=null,this.Observer=null,t&&this.initialize(t)}_default(){return this.attrs=u($t.DEFAULTS),this.$el=null,this.$title=null,this.$main=null,this.$list=null,this.$placeholder=null,this.$parentElement=null,this.$scrollElement=null,this.$active=null,this.chapters=[],this.active=0,this.offsetWidth=0,this.offsetTop=0,this.playing=!1,this.closed=!1,this}initialize(t){let e,s,i,r;return this.attr(t),e=this.attr("created"),s=this.attr("parentElement"),i=this.attr("scrollElement"),m(s)?r=document.querySelector(s):p(s)&&(r=s),this.$parentElement=r,this.$scrollElement=v(i),this.chapters=this.attr("chapters"),this.closed=this.attr("closed"),this.active=this.attr("active"),l(e)&&e.call(this),this.chapters.length<1||(this.render().addListeners(),this.$active=document.querySelector(`#chapter-${this.active}`)),this}isClosed(){return this.closed}isSticky(){return"sticky"===this.attr("position")}isFixed(){return"fixed"===this.attr("position")}isInside(){return this.isFixed()||this.isSticky()}isOutside(){return!this.isInside()}count(){return this.chapters.length}_paintEdge(){const t=document.createDocumentFragment(),e=this.attr("title"),s=this.attr("animationCurrent"),i=this.attr("customClass"),r=this.$parentElement,n=[],o=[];let l,h,a,c,u=null;return r?(this.isInside()&&e&&(u=tt("h2",{className:"outline-navigator__title"},e),this.$title=u,o.push(u)),a=tt("ul",{className:"outline-navigator__list"}),this.$list=a,n.push(a),s&&(c=tt("div",{className:"outline-navigator__placeholder"}),this.$placeholder=c,n.push(c)),h=tt("div",{className:"outline-navigator__main"},n),this.$main=h,o.push(h),l=tt("nav",{id:"outline-navigator",className:`outline-navigator ${bt}`},o),this.$el=l,this.isSticky()&&(this.calculateStickyHeight(),f(l,"outline-navigator_sticky")),i&&f(l,i),t.appendChild(l),r.appendChild(t),this):this}render(){const t=this.attr("mounted"),e=this.$parentElement,s=this.chapters,i=this.count();let r;return!e||s.length<1||(this.isInside()&&f(e,"outline-navigator-parent"),this._paintEdge(),r=this.$el,this._paint(s),h((()=>{this.highlight(this.active)}),60),this.offsetTop=q(r),this.offsetWidth=r.offsetWidth,this.isFixed()&&(this.sticky(),ct("--outline-navigator-width",`${this.offsetWidth}px`)),l(t)&&t.call(this),i<400&&this.onObserver()),this}erase(){return this.$list.innerHTML="",this}_paint(t){const e=this.attr("showCode"),i=this.$el;return((t,e,i=!1)=>{const r=e.length,o=s(n,e),l=e=>{const s=e=>t.querySelector(`#${e}`);e.forEach((e=>{const r=e.pid,n=e.id,o=e.code,l=e.rel,h=[],a=tt("span",{className:"outline-navigator__text"},e.text);let c,u,d,m,p;i&&(u=tt("span",{className:"outline-navigator__code","data-id":n},e.code),h.push(u)),h.push(a),c=tt("a",{id:`chapter__anchor-${n}`,className:"outline-navigator__anchor",href:"#"+l,rel:l,"data-id":n,"data-code":o},h),d=tt("li",{id:`chapter-${n}`,className:"outline-navigator__item","data-id":n,"data-code":o},c),-1===r?t.appendChild(d):(p=s(`chapter-${r}`),m=s(`subject-${r}`),m?m.appendChild(d):(m=tt("ul",{id:"subject-"+r,className:"outline-navigator__subject"},d),p.appendChild(m)))}))};if(r>400)for(l(o.splice(0,400));o.length>0;){const t=o.splice(0,400);j((()=>{l(t)}))}else l(o)})(this.$list,t,e),it(i,bt),f(i,yt),this}_remove(){return this.$parentElement.removeChild(this.$el),this}refresh(t){const e=this.$el;return it(e,bt),this.erase()._paint(t),this}_getPlaceholderOffset(t){const e=this.$main,s=this.$list,i=s.querySelector(".outline-navigator__anchor"),r=parseInt(ft(e,"padding-top"),10),n=parseInt(ft(e,"border-top-width"),10),o=parseInt(ft(s,"padding-top"),10),l=parseInt(ft(s,"margin-top"),10),h=parseInt(ft(s,"border-top-width"),10);let a,c=0;return r&&(c+=r),o&&(c+=o),l&&(c+=l),n&&(c+=n),h&&(c+=h),a=i.offsetHeight*t,c+a}positionPlaceholder(t){const e=this.$list,s=this.$placeholder,i=e.querySelector(".outline-navigator__anchor"),r=this.attr("animationCurrent"),n=i.offsetHeight;let o=0;return r?(o=this._getPlaceholderOffset(t),s.style.cssText=`transform: translateY(${o}px);height:${n}px;`,this):this}highlight(t){const e=this.$el,s=this.attr("animationCurrent"),i="outline-navigator_active",r="outline-navigator_highlight";let n="relative"===this.attr("position")?this.$parentElement:this.$main,o=null,l=0;return e?(o=e.querySelector(`#chapter__anchor-${t}`),o?(this.active=parseInt(o.getAttribute("data-id"),10),this.$active&&(it(this.$active,r),it(this.$active,i)),this.$active=o,f(this.$active,i),s?this.positionPlaceholder(this.active):f(this.$active,r),h((()=>{((t,e)=>{let s,i,r=!1;return p(t)&&p(e)?(s=e.getBoundingClientRect(),i=t.getBoundingClientRect(),r=!!(i.top>=s.top&&i.right<=s.right&&i.bottom<=s.bottom&&i.left>=s.left),r):r})(this.$active,n)||(l=this._getPlaceholderOffset(this.active),y(n,l))})),this):this):this}sticky(){const t=this.attr("afterSticky"),e="outline-navigator_fixed",s=this.$el,i=this.offsetTop,r=this.$scrollElement.scrollTop;let n;return this.isFixed()?(n=r>=i,n?f(s,e):it(s,e),l(t)&&t.call(this,this.isClosed(),n),this):this}calculateStickyHeight(){const t=document.documentElement,e=Math.max(t.clientHeight||0,window.innerHeight||0);return ct("--outline-sticky-height",`${e}px`),this}scrollTo(t,e){const s=this.$scrollElement;return y(s,t,e),this}show(){const t=this.attr("afterOpened"),e=this.count(),s=this.$el,i=this.$parentElement;return this.isInside()?e>800?it(i,bt):(it(i,bt),h((()=>{it(i,vt),f(i,yt)}),30)):it(s,bt),this.closed=!1,l(t)&&t.call(this),this}hide(){const t=this.attr("afterClosed"),e=this.count(),s=this.$el,i=this.$parentElement;return this.isInside()?e>800?f(i,bt):(f(i,vt),it(i,yt),h((()=>{f(i,bt)}))):f(s,bt),this.closed=!0,l(t)&&t.call(this),this}toggle(){const t=this.attr("afterToggle"),e=this.offsetTop,s=this.$scrollElement.scrollTop;let i;return this.isClosed()?this.show():this.hide(),l(t)&&h((()=>{i=s>=e,t.call(this,this.isClosed(),i)})),this}destroy(){const t=this.attr("beforeDestroy"),e=this.attr("afterDestroy");return l(t)&&t.call(this),this.removeListeners()._remove()._default(),this.scrollTimer&&(clearTimeout(this.scrollTimer),this.scrollTimer=null),this.resizeTimer&&(clearTimeout(this.resizeTimer),this.resizeTimer=null),this.observerTimer&&(clearTimeout(this.observerTimer),this.observerTimer=null),this.Observer&&(this.Observer=null),l(e)&&e.call(this),this}onObserver(){const t=this.attr("selector");return this.Observer=((t,e={})=>{const s=e.root||null,i=e.selector||".outline-heading",r=e.context||null,n={rootMargin:e.rootMargin||"0px 0px -90% 0px"},o=new IntersectionObserver((e=>{e.forEach((e=>{e.intersectionRatio>0&&l(t)&&t.call(r||e.target,e.target)}))}),n),h=p(s)?s:document;return s&&(n.root=s),h.querySelectorAll(i).forEach((t=>{o.observe(t)})),o})((t=>{const e=t.getAttribute("data-id");if(this.playing)return!1;this.observerTimer&&clearTimeout(this.observerTimer),this.observerTimer=h((()=>{this.highlight(e)}),100)}),{selector:t,context:this}),this}onSelect(t){const e=this.attr("stickyHeight"),s=t.delegateTarget,i=s.getAttribute("data-id"),r=s.href.split("#")[1],n=document.querySelector(`#${r}`),o=q(n)-(e+10),a=this.$scrollElement.scrollHeight,c=this.attr("afterScroll"),u=()=>{l(c)&&c.call(this,"chapter"),h((()=>{this.playing=!1,this.$emit("toolbar:update",{top:o,min:0,max:a})}))};return this.playing=!0,this.isFixed()?(this.sticky(),h((()=>{this.scrollTo(o,u),this.highlight(i)}),10)):(this.scrollTo(o,u),this.highlight(i)),Q(t),this}onScroll(){const t=this.$scrollElement;return this.scrollTimer&&clearTimeout(this.scrollTimer),this.scrollTimer=h((()=>{const e=t.scrollTop,s=t.scrollHeight-t.clientHeight;this.isFixed()&&this.sticky(),this.$emit("toolbar:update",{top:e,min:0,max:s})}),100),this}onResize(){return this.isSticky()?(this.resizeTimer&&clearTimeout(this.resizeTimer),this.resizeTimer=h((()=>{this.calculateStickyHeight()})),this):this}onRefresh(t){return this.refresh(t),this}addListeners(){const t=this.$el,e=this.$scrollElement,s=e.tagName.toLowerCase();let i=e;return this.count()<1||("html"!==s&&"body"!==s||(i=window),W(t,".outline-navigator__anchor","click",this.onSelect,this,!0),gt(i,"scroll",this.onScroll,this,!0),this.isSticky()&>(window,"resize",this.onResize,this,!0),this.$on("anchors:all:paint",this.onObserver,this),this.$on("navigator:refresh",this.onRefresh,this)),this}removeListeners(){const t=this.attr("selector"),e=this.$el,s=this.$scrollElement,i=s.tagName.toLowerCase();let r=s;return this.count()<1||("html"!==i&&"body"!==i||(r=window),V(e,"click",this.onSelect),V(r,"scroll",this.onScroll),this.isSticky()&&V(window,"resize",this.onResize),this.$off("anchors:all:paint"),this.$off("navigator:refresh"),this.Observer&&document.querySelectorAll(t).forEach((t=>{this.Observer.unobserve(t)}))),this}}$t.DEFAULTS=u({parentElement:"",scrollElement:"",selector:".outline-heading",active:0,closed:!1,showCode:!0,animationCurrent:!0,position:"relative",stickyHeight:0,chapters:[],created:null,mounted:null,afterClosed:null,afterOpened:null,afterScroll:null,beforeDestroy:null,afterDestroy:null,afterSticky:null});const _t=()=>{const t=navigator.userAgent;return/Mobile|mini|Fennec|Android|iP(ad|od|hone)|NokiaN[^/]*/.test(t)},xt=t=>{const e=Object.getPrototypeOf;let s;if(!(t=>a(t)&&null!==t)(t))return!1;if(s=t.prototype,!s)return!0;for(s=t;null!==e(s);)s=e(s);return e(t)===s},wt=t=>{const e={"&":"&","<":"<",">":">","'":"'",'"':"""};return t.replace(/[&<>'"]/g,(t=>e[t]||t))},Tt=[];let Et;G(['<symbol id="outline-icon-warning" viewBox="0 0 1024 1024"><path d="M512 639.704018a95.994 95.994 0 0 1-95.994-95.994V95.994a95.994 95.994 0 0 1 191.988 0v447.716018a95.994 95.994 0 0 1-95.994 95.994z m0 128.375977A127.992 127.992 0 1 1 512 1023.936004a127.992 127.992 0 0 1 0-255.984001z"></path></symbol>','<symbol id="outline-icon-error" viewBox="0 0 1024 1024"><path d="M512.64 376.96L263.744 128 128 263.744l248.96 248.96L128 761.472l135.744 135.808 248.96-248.96 248.832 248.96 135.808-135.808-248.96-248.896 248.96-248.896L761.536 128 512.64 376.96z"></path></symbol>','<symbol id="outline-icon-success" viewBox="0 0 1024 1024"><path d="M426.368 580.864l-226.56-226.56L64 489.984l362.048 362.112 0.32-0.32 0.32 0.32 588.288-588.352L879.36 128 426.304 580.864z"></path></symbol>','<symbol id="outline-icon-circle-info" viewBox="0 0 1024 1024"><path d="M512 810.666667s-42.666667 4.266667-42.666667-42.666667v-341.333333c0-46.933333 42.666667-42.666667 42.666667-42.666667s42.666667-4.266667 42.666667 42.666667v341.333333c0 46.933333-42.666667 42.666667-42.666667 42.666667z m0 213.333333C228.949333 1024 0 795.050667 0 512S228.949333 0 512 0s512 228.949333 512 512-229.674667 512-512 512z m0-938.666667C276.608 85.333333 85.333333 276.608 85.333333 512s191.274667 426.666667 426.666667 426.666667 426.666667-191.274667 426.666667-426.666667S747.392 85.333333 512 85.333333z m0 213.333334c-23.466667 0-42.666667-19.2-42.666667-42.666667s19.2-42.666667 42.666667-42.666667 42.666667 19.2 42.666667 42.666667-19.2 42.666667-42.666667 42.666667z"></path></symbol>','<symbol id="outline-icon-circle-warning" viewBox="0 0 1024 1024"><path d="M512 213.333333s-42.666667-4.266667-42.666667 42.666667v341.333333c0 46.933333 42.666667 42.666667 42.666667 42.666667s42.666667 4.266667 42.666667-42.666667V256c0-46.933333-42.666667-42.666667-42.666667-42.666667z m0-213.333333C228.949333 0 0 228.949333 0 512s228.949333 512 512 512 512-228.949333 512-512S794.325333 0 512 0z m0 938.666667C276.608 938.666667 85.333333 747.392 85.333333 512S276.608 85.333333 512 85.333333s426.666667 191.274667 426.666667 426.666667-191.274667 426.666667-426.666667 426.666667z m0-213.333334c-23.466667 0-42.666667 19.2-42.666667 42.666667s19.2 42.666667 42.666667 42.666667 42.666667-19.2 42.666667-42.666667-19.2-42.666667-42.666667-42.666667z"></path></symbol>','<symbol id="outline-icon-circle-error" viewBox="0 0 1024 1024"><path d="M512 0a512 512 0 1 0 512 512 512 512 0 0 0-512-512z m0 955.776A443.84 443.84 0 0 1 512 68.224a443.904 443.904 0 0 1 0 887.552z"></path><path d="M641.664 326.144a32 32 0 0 1 50.304 39.168l-3.52 4.48-306.112 328.064a32 32 0 0 1-50.304-39.168l3.52-4.48 306.112-328.064z"></path><path d="M324.608 337.088a32 32 0 0 1 40.704-5.12l4.48 3.584 328.064 306.112a32 32 0 0 1-39.168 50.304l-4.48-3.52-328.064-306.112a32 32 0 0 1-1.536-45.248z"></path></symbol>','<symbol id="outline-icon-circle-success" viewBox="0 0 1024 1024"><path d="M512 0C228.949333 0 0 228.949333 0 512s228.949333 512 512 512 512-228.949333 512-512S794.325333 0 512 0z m0 950.869333C269.909333 950.869333 73.130667 754.090667 73.130667 512 73.130667 269.909333 269.909333 73.130667 512 73.130667c242.090667 0 438.869333 196.778667 438.869333 438.869333 0 242.090667-196.778667 438.869333-438.869333 438.869333z"></path><path d="M737.834667 353.834667a42.666667 42.666667 0 0 1 63.872 56.32l-3.541334 4.010666L486.997333 725.333333a85.333333 85.333333 0 0 1-115.242666 4.992L366.336 725.333333l-140.501333-140.501333a42.666667 42.666667 0 0 1 56.32-63.872l4.010666 3.541333L426.666667 665.002667l311.168-311.168z"></path></symbol>']);class St extends O{constructor(t){return super(),this._default().initialize(t),this}_default(){return this.attrs=u(St.DEFAULTS),this.$el=null,this.id="",this.closed=!1,this.visible=!1,this.offset=-50,this.timer=null,this.destroyed=!1,this}initialize(t){return this.attr(t),this.id=this.attr("id"),this.offset=this.attr("offset")||-50,this.$emit("created",r({},this.attr())),this.render().addListeners(),this.attr("visible")&&this.getText()&&this.open(),this}isClosed(){return this.closed}isDestroyed(){return this.destroyed}_getClassName(){const t=this.attr("type"),e=this.attr("effect"),s=this.attr("round"),i=this.attr("closable"),r=this.attr("visible"),n=this.attr("customClass"),o=["outline-message",`outline-message_${t}`,`outline-message_${e}`];return s&&o.push("outline-message_round"),i||o.push("outline-message_full-width"),r&&o.push("outline-message_visible"),n&&o.push(n),o}getText(){const t=this.attr("dangerouslyUseHTMLString");let e=this.attr("message"),s="";return s=t?e:wt(at(e)),s}render(){const t=this.attr("type"),e=this.attr("message"),s=this.attr("effect"),i=this.attr("round"),r=this.attr("closable"),n=this.attr("dangerouslyUseHTMLString"),o=this._getClassName(),l=[];let h,a,c,u,d,m=20;return i&&"default"===s&&(m=12),"plain"!==s&&(h=st("light"===s?`circle-${t}`:t,{iconSet:"outline",size:m}),f(h,"outline-message__icon"),l.push(h)),n?(c=document.createDocumentFragment(),c.innerHTML=e):c=document.createTextNode(wt(at(e))),a=tt("p",{className:"outline-message__content"},[c]),l.push(a),r&&(u=st("close",{iconSet:"outline",size:18}),f(u,"outline-message__close"),l.push(u)),d=tt("div",{className:o.join(" ")},l),d.style.cssText="top:-50px;",this.$el=d,document.body.appendChild(this.$el),this.$emit("mounted"),this}_refreshIcon(){const t=".outline-message_hidden",e=this.$el;let s,i,r,n,o,l,h,a=20;return this.isDestroyed()?this:(o=e.querySelector(".outline-icon"),o?(s=this.attr("type"),i=this.attr("effect"),r=this.attr("round"),"plain"===i?f(o,t):(it(o,t),r&&"default"===i&&(a=12)),l=o.querySelector(".outline-icon__svg"),Z(l,{style:`width:${a}px;height:${a}px;`}),h=l.querySelector("use"),n="light"===i?`circle-${s}`:s,X(h,"xlink:href",`#outline-icon-${n}`),this):this)}_refreshMessage(){const t=this.$el;let e,s,i,r;return this.isDestroyed()||(e=t.querySelector(".outline-message__content"),s=this.attr("dangerouslyUseHTMLString"),i=this.attr("message"),r=s?i:wt(at(i)),e.innerHTML=r),this}_refreshClose(){const t=".outline-message_hidden",e=this.$el;let s,i;return this.isDestroyed()||(s=e.querySelector(".outline-message__close"),i=this.attr("closable"),s&&(i?f(s,t):it(s,t))),this}_refreshEl(){const t=this.$el;let e;return this.isDestroyed()||(e=this._getClassName(),X(t,"className",e.join(" "))),this}refresh(t){return xt(t)?(this.attr(t)._refreshIcon()._refreshMessage()._refreshClose()._refreshEl(),this):this}clearTimer(){return this.isDestroyed()||this.timer&&(clearTimeout(this.timer),this.timer=null),this}startTimer(t){return this.isDestroyed()||(this.timer=h((()=>{this.$emit("opened"),this.close()}),1e3*t)),this}open(t){const e=this.$el;let s,i,r,n;return this.isDestroyed()||(this.isClosed()&&this.refresh(t),s=this.attr("offset"),i=this.attr("duration"),r=s&&s>=this.offset?s:this.offset,n=`top:${r}px;`,this.clearTimer(),this.$emit("beforeOpen"),h((()=>{this.visible=!0,f(e,"outline-message_visible"),e.style.cssText=n,i>0&&this.startTimer(i)}),100)),this}close(){const t=this.$el;let e,s;return this.isDestroyed()||(e=this.attr("destroyAfterClosed"),s=this.attr("beforeClose"),l(s)&&s.call(this),t.style.cssText="top:-50px;",it(t,"outline-message_visible"),this.visible=!1,this.closed=!0,h((()=>{this.$emit("closed"),e&&this.destroy()}),500)),this}destroy(){return this.$emit("beforeDestroy"),this.isDestroyed()||(this.removeListeners(),document.body.removeChild(this.$el),clearTimeout(this.timer),this._default(),this.$emit("afterDestroy")),this}onMouseEnter(){return this.clearTimer(),this}onMouseLeave(){const t=this.attr("duration"),e=this.attr("delay");return t<=0||this.startTimer(e),this}onClose(){return this.clearTimer(),this.close(),this}addListeners(){const t=this.$el;return W(t,".outline-message__content","mouseenter",this.onMouseEnter,this,!0),W(t,".outline-message__content","mouseleave",this.onMouseLeave,this,!0),W(t,".outline-message__close","click",this.onClose,this,!0),this}removeListeners(){const t=this.$el;return V(t,"mouseenter",this.onMouseEnter),V(t,"mouseleave",this.onMouseLeave),V(t,"click",this.onClose),this}}St.DEFAULTS=u({id:"",type:"info",effect:"default",round:!1,offset:30,duration:3,delay:2,message:"",customClass:"",closable:!0,visible:!0,dangerouslyUseHTMLString:!1,destroyAfterClosed:!1,beforeClose:null}),["info","success","warning","error"].forEach((t=>{St[t]=e=>{const s={},i=k("outline-message-"),r=e&&e.beforeClose?e.beforeClose:null;let n=e&&e.offset?e.offset:30;return m(e)?s.message=e:xt(e)&&E(s,e),s.id=i,s.type=t,s.offset=n,s.visible=!1,s.destroyAfterClosed=!0,s.beforeClose=()=>{St.close(i,r)},Et=new St(s),Tt.forEach((t=>{n+=t.$el.offsetHeight+16})),Et.offset=n,s.message&&Et.open(),Tt.push(Et),Et}})),St.close=(t,e)=>{const s=Tt.length;let i,r,n=-1;if(Tt.forEach(((s,i)=>{t===s.id&&(r=s.$el.offsetHeight,n=i,l(e)&&e.call(s),Tt.splice(i,1))})),s<=1||-1===n||n>Tt.length-1)return!1;for(i=n;i<s-1;i+=1){const t=Tt[i].$el;t.style.top=parseInt(t.style.top,10)-r-16+"px"}},St.clear=()=>{let t=Tt.length-1;for(;t>=0;t-=1)Tt[t].close()};class Ct{constructor(){this.commands=[]}find(t){return this.commands.find((e=>e.name===t))}exists(t){return!!this.find(t)}add(t){return this.exists(t)||this.commands.push(t),this}remove(t){const e=this.find(t);if(!e)return this;const s=this.commands;return s.splice(s.indexOf(e),1),this}execute(t){const e=this.find(t);return l(null==e?void 0:e.execute)&&e.execute(),this}clear(){return this.commands=[],this}}const Lt=(t,e=!0)=>{const s=st(t.icon,{iconSet:t.iconSet||"outline",color:t.color||"",size:t.size}),i=tt("a",{className:"outline-toolbar__anchor",href:t.link},s),r=tt("div",{className:`outline-toolbar__button ${t.name}`,"data-cmd":t.name},[t.link?i:s]);return f(s,"outline-toolbar__icon"),e&&f(r,"outline-toolbar_rounded"),t.disabled&&f(r,"outline-toolbar_disabled"),r},zt=['<symbol id="outline-icon-up" viewBox="0 0 1024 1024"><path d="M494.784 261.696c0.832-0.448 1.536-1.216 2.368-1.536a38.72 38.72 0 0 1 46.08 8.256l277.824 302.272a41.92 41.92 0 0 1-1.536 58.048 39.104 39.104 0 0 1-56.448-1.6L513.728 355.904 260.736 626.048a39.104 39.104 0 0 1-56.448 1.088 41.6 41.6 0 0 1-1.088-57.984L483.84 269.696c0.512-0.512 1.344-0.768 1.92-1.408l1.088-1.344c2.368-2.496 5.312-3.648 8-5.248z"></path></symbol>','<symbol id="outline-icon-down" viewBox="0 0 1024 1024"><path d="M494.784 762.304c0.832 0.448 1.536 1.216 2.368 1.536 15.232 7.488 33.92 4.992 46.08-8.256l277.824-302.272a41.92 41.92 0 0 0-1.536-58.048 39.104 39.104 0 0 0-56.448 1.6l-249.344 271.232-252.992-270.144a39.104 39.104 0 0 0-56.448-1.088 41.6 41.6 0 0 0-1.088 57.984l280.576 299.456c0.512 0.512 1.344 0.768 1.92 1.408l1.088 1.344c2.368 2.496 5.312 3.648 8 5.248z"></path></symbol>','<symbol id="outline-icon-menu" viewBox="0 0 1024 1024"><path d="M320 256h640V128H320zM320 576h640V448H320zM320 896h640v-128H320zM64 256h128V128H64zM64 576h128V448H64zM64 896h128v-128H64z"></path></symbol>','<symbol id="outline-icon-file" viewBox="0 0 1024 1024"><path d="M320 640h256v128H320z"></path><path d="M320 448h384v128H320z"></path><path d="M640 0l320 320v557.696C960 958.528 909.824 1024 848 1024H176C114.176 1024 64 958.528 64 877.696V146.304C64 65.472 114.176 0 176 0H640z m0 128H192v768h640V320h-192V128z"></path></symbol>','<symbol id="outline-icon-close" viewBox="0 0 1024 1024"><path d="M536.96 491.648L310.592 265.344a32 32 0 1 0-45.248 45.248L491.584 536.96l-226.304 226.304a32 32 0 0 0 45.312 45.248l226.24-226.304 226.304 226.304a32 32 0 0 0 45.248-45.248L582.144 536.896l226.304-226.24a32 32 0 0 0-45.248-45.248L536.896 491.584z"></path></symbol>','<symbol id="outline-icon-homepage" viewBox="0 0 26 28"><path d="M22 15.5v7.5c0 0.547-0.453 1-1 1h-6v-6h-4v6h-6c-0.547 0-1-0.453-1-1v-7.5c0-0.031 0.016-0.063 0.016-0.094l8.984-7.406 8.984 7.406c0.016 0.031 0.016 0.063 0.016 0.094zM25.484 14.422l-0.969 1.156c-0.078 0.094-0.203 0.156-0.328 0.172h-0.047c-0.125 0-0.234-0.031-0.328-0.109l-10.813-9.016-10.813 9.016c-0.109 0.078-0.234 0.125-0.375 0.109-0.125-0.016-0.25-0.078-0.328-0.172l-0.969-1.156c-0.172-0.203-0.141-0.531 0.063-0.703l11.234-9.359c0.656-0.547 1.719-0.547 2.375 0l3.813 3.187v-3.047c0-0.281 0.219-0.5 0.5-0.5h3c0.281 0 0.5 0.219 0.5 0.5v6.375l3.422 2.844c0.203 0.172 0.234 0.5 0.063 0.703z"></path></symbol>','<symbol id="outline-icon-github" viewBox="0 0 24 28"><path d="M12 2c6.625 0 12 5.375 12 12 0 5.297-3.437 9.797-8.203 11.391-0.609 0.109-0.828-0.266-0.828-0.578 0-0.391 0.016-1.687 0.016-3.297 0-1.125-0.375-1.844-0.812-2.219 2.672-0.297 5.484-1.313 5.484-5.922 0-1.313-0.469-2.375-1.234-3.219 0.125-0.313 0.531-1.531-0.125-3.187-1-0.313-3.297 1.234-3.297 1.234-0.953-0.266-1.984-0.406-3-0.406s-2.047 0.141-3 0.406c0 0-2.297-1.547-3.297-1.234-0.656 1.656-0.25 2.875-0.125 3.187-0.766 0.844-1.234 1.906-1.234 3.219 0 4.594 2.797 5.625 5.469 5.922-0.344 0.313-0.656 0.844-0.766 1.609-0.688 0.313-2.438 0.844-3.484-1-0.656-1.141-1.844-1.234-1.844-1.234-1.172-0.016-0.078 0.734-0.078 0.734 0.781 0.359 1.328 1.75 1.328 1.75 0.703 2.141 4.047 1.422 4.047 1.422 0 1 0.016 1.937 0.016 2.234 0 0.313-0.219 0.688-0.828 0.578-4.766-1.594-8.203-6.094-8.203-11.391 0-6.625 5.375-12 12-12zM4.547 19.234c0.031-0.063-0.016-0.141-0.109-0.187-0.094-0.031-0.172-0.016-0.203 0.031-0.031 0.063 0.016 0.141 0.109 0.187 0.078 0.047 0.172 0.031 0.203-0.031zM5.031 19.766c0.063-0.047 0.047-0.156-0.031-0.25-0.078-0.078-0.187-0.109-0.25-0.047-0.063 0.047-0.047 0.156 0.031 0.25 0.078 0.078 0.187 0.109 0.25 0.047zM5.5 20.469c0.078-0.063 0.078-0.187 0-0.297-0.063-0.109-0.187-0.156-0.266-0.094-0.078 0.047-0.078 0.172 0 0.281s0.203 0.156 0.266 0.109zM6.156 21.125c0.063-0.063 0.031-0.203-0.063-0.297-0.109-0.109-0.25-0.125-0.313-0.047-0.078 0.063-0.047 0.203 0.063 0.297 0.109 0.109 0.25 0.125 0.313 0.047zM7.047 21.516c0.031-0.094-0.063-0.203-0.203-0.25-0.125-0.031-0.266 0.016-0.297 0.109s0.063 0.203 0.203 0.234c0.125 0.047 0.266 0 0.297-0.094zM8.031 21.594c0-0.109-0.125-0.187-0.266-0.172-0.141 0-0.25 0.078-0.25 0.172 0 0.109 0.109 0.187 0.266 0.172 0.141 0 0.25-0.078 0.25-0.172zM8.937 21.438c-0.016-0.094-0.141-0.156-0.281-0.141-0.141 0.031-0.234 0.125-0.219 0.234 0.016 0.094 0.141 0.156 0.281 0.125s0.234-0.125 0.219-0.219z"></path></symbol>','<symbol id="outline-icon-issues" viewBox="0 0 24 28"><path d="M25.5 15c0 0.547-0.453 1-1 1h-3.5c0 1.953-0.422 3.422-1.047 4.531l3.25 3.266c0.391 0.391 0.391 1.016 0 1.406-0.187 0.203-0.453 0.297-0.703 0.297s-0.516-0.094-0.703-0.297l-3.094-3.078s-2.047 1.875-4.703 1.875v-14h-2v14c-2.828 0-4.891-2.063-4.891-2.063l-2.859 3.234c-0.203 0.219-0.469 0.328-0.75 0.328-0.234 0-0.469-0.078-0.672-0.25-0.406-0.375-0.438-1-0.078-1.422l3.156-3.547c-0.547-1.078-0.906-2.469-0.906-4.281h-3.5c-0.547 0-1-0.453-1-1s0.453-1 1-1h3.5v-4.594l-2.703-2.703c-0.391-0.391-0.391-1.016 0-1.406s1.016-0.391 1.406 0l2.703 2.703h13.188l2.703-2.703c0.391-0.391 1.016-0.391 1.406 0s0.391 1.016 0 1.406l-2.703 2.703v4.594h3.5c0.547 0 1 0.453 1 1zM18 6h-10c0-2.766 2.234-5 5-5s5 2.234 5 5z"></path></symbol>','<symbol id="outline-icon-tags" viewBox="0 0 26 28"><path d="M7 7c0-1.109-0.891-2-2-2s-2 0.891-2 2 0.891 2 2 2 2-0.891 2-2zM23.672 16c0 0.531-0.219 1.047-0.578 1.406l-7.672 7.688c-0.375 0.359-0.891 0.578-1.422 0.578s-1.047-0.219-1.406-0.578l-11.172-11.188c-0.797-0.781-1.422-2.297-1.422-3.406v-6.5c0-1.094 0.906-2 2-2h6.5c1.109 0 2.625 0.625 3.422 1.422l11.172 11.156c0.359 0.375 0.578 0.891 0.578 1.422zM29.672 16c0 0.531-0.219 1.047-0.578 1.406l-7.672 7.688c-0.375 0.359-0.891 0.578-1.422 0.578-0.812 0-1.219-0.375-1.75-0.922l7.344-7.344c0.359-0.359 0.578-0.875 0.578-1.406s-0.219-1.047-0.578-1.422l-11.172-11.156c-0.797-0.797-2.312-1.422-3.422-1.422h3.5c1.109 0 2.625 0.625 3.422 1.422l11.172 11.156c0.359 0.375 0.578 0.891 0.578 1.422z"></path></symbol>','<symbol id="outline-icon-print" viewBox="0 0 24 24"><path d="M18 3v3.984h-12v-3.984h12zM18.984 12q0.422 0 0.727-0.281t0.305-0.703-0.305-0.727-0.727-0.305-0.703 0.305-0.281 0.727 0.281 0.703 0.703 0.281zM15.984 18.984v-4.969h-7.969v4.969h7.969zM18.984 8.016q1.219 0 2.109 0.891t0.891 2.109v6h-3.984v3.984h-12v-3.984h-3.984v-6q0-1.219 0.891-2.109t2.109-0.891h13.969z"></path></symbol>','<symbol id="outline-icon-info" viewBox="0 0 1024 1024"><path d="M512 384.295982a95.994 95.994 0 0 1 95.994 95.994V928.006a95.994 95.994 0 0 1-191.988 0V480.289982a95.994 95.994 0 0 1 95.994-95.994z m0-128.375977A127.992 127.992 0 1 1 512 0.063996a127.992 127.992 0 0 1 0 255.984001z"></path></symbol>','<symbol id="outline-icon-sound" viewBox="0 0 16 16"><path d="M12.757 4.708c-0.406 0.405-1.062 0.405-1.468 0s-0.405-1.062 0-1.468l2.935-2.935c0.406-0.405 1.062-0.405 1.468 0 0.405 0.405 0.405 1.062 0 1.468l-2.935 2.935zM7.996 15.991l-3.996-3.996h-2.997c-0.552 0-0.999-0.447-0.999-0.999v-5.994c0-0.552 0.447-0.999 0.999-0.999h2.997l3.996-3.996c0 0 0.999-0.125 0.999 0.999 0 5.976 0 14.966 0 13.985 0 1.124-0.999 0.999-0.999 0.999zM6.997 4.004l-1.998 1.998h-2.997v3.996h2.997l1.998 1.998v-7.992zM11.992 8.999c-0.552 0-0.999-0.447-0.999-0.999s0.447-0.999 0.999-0.999h2.997c0.552 0 0.999 0.447 0.999 0.999s-0.447 0.999-0.999 0.999h-2.997zM12.757 11.292l2.935 2.935c0.405 0.406 0.405 1.063 0 1.468s-1.062 0.405-1.468 0l-2.935-2.935c-0.405-0.406-0.405-1.063 0-1.468s1.062-0.405 1.468 0z"></path></symbol>'],kt="outline-toolbar_disabled",Mt="outline-toolbar_hidden",At="outline-toolbar_active";class Ot extends O{constructor(t){super(),this.name="toolbar",this._default(),t&&this.initialize(t)}_default(){return this.attrs=u(Ot.DEFAULTS),this.disabled=!1,this.closed=!1,this.$el=null,this.buttons=[],this.commands=null,this}initialize(t){let e;return this.attr(t),this.disabled=this.attr("disabled"),this.closed=this.attr("closed"),this.commands=new Ct,e=this.attr("created"),l(e)&&e.call(this),this.render().addListeners(),this}isHighlight(t){const e=this.get(t);return!!e&&g(e.$el,At)}isDisabled(t){let e;return t?(e=this.get(t),e.disabled):this.disabled}isExist(t){return!!this.get(t)}isClosed(){return this.closed}_getCommand(t){const e=this,{action:s,name:i}=t;let r,n,o=null,h=null;return s?(h=s.handler,r=s.context||this,l(h)?n=h:m(h)&&(n=function(){e.$emit(h,i)}),l(n)&&(o=new T(i,n.bind(r))),o):o}get(t){return this.buttons.find((e=>e.name===t))}render(){const t=this.attr("mounted"),e=this.attr("buttons")||[],s=this.attr("placement");return G(zt),this.$el=tt("div",{id:k("outline-toolbar"),className:`outline-toolbar outline-toolbar_${s}`}),this._paint(e),document.body.appendChild(this.$el),this.closed&&this.hide(),this.disabled&&this.disable(),l(t)&&t.call(this),this}erase(){return this.$el.innerHTML="",this}_paint(t){const e=this.attr("rounded"),s=document.createDocumentFragment();return t.forEach((t=>{const i=Lt(t,e),r=this._getCommand(t),{name:n,disabled:o,context:l}=t;s.appendChild(i),this.isExist(n)||(this.buttons.push({$el:i,name:n,disabled:o||!1,context:l||this}),r&&this.commands.add(r))})),this.$el.appendChild(s),this}_remove(){return document.body.removeChild(this.$el),this}refresh(t){return this.attr({buttons:t}),this.erase()._paint(t),this}add(t){const e=this.$el,s=document.createDocumentFragment(),i=this.attr("buttons")||[],{name:r,disabled:n,context:o}=t,l=this._getCommand(t),h=t=>{const e=Lt(t);s.appendChild(e),i.push(t),this.buttons.push({$el:e,name:r,disabled:n||!1,context:o||this,command:l}),l&&this.commands.add(l)};return a(t)?h(t):c(t)&&t.forEach((t=>{a(t)&&h(t)})),e.appendChild(s),this}remove(t){const e=this.$el,s=this.buttons,i=this.get(t);let r=-1;return i?(r=s.indexOf(i),r>-1&&(s.splice(r,1),this.attr("buttons").splice(r,1)),this._disable(t),e.removeChild(i.$el),this):this}_disable(t){const e=this.get(t),s=this.commands.find(t);return!e||e.disabled||(e.disabled=!0,s&&this.commands.remove(s),f(e.$el,kt)),this}_enable(t){const e=this.get(t),s=this.commands.find(t);return e&&e.disabled?(e.disabled=!1,s&&this.commands.add(s),it(e.$el,kt),this):this}disable(t){const e=this.attr("afterDisabled");return t?this._disable(t):(f(this.$el,kt),this.removeListeners(),this.disabled=!0,l(e)&&e.call(this)),this}enable(t){const e=this.attr("afterEnabled");return t?this._enable(t):(this.disabled=!1,it(this.$el,kt),this.addListeners(),l(e)&&e.call(this)),this}show(t){const e=this.attr("afterOpened"),s=this.get(t),i=this.$el;if(t){if(!s)return this;it(s.$el,Mt)}else it(i,Mt),this.closed=!1,l(e)&&h((()=>{e.call(this)}),310);return this}hide(t){const e=this.attr("afterClosed"),s=this.get(t),i=this.$el;if(t){if(!s)return this;f(s.$el,Mt)}else f(i,Mt),this.closed=!0,l(e)&&h((()=>{e.call(this)}),310);return this}toggle(t){return this.isClosed()?this.show(t):this.hide(t),this}highlight(t){const e=this.get(t);let s;return e?(s=e.$el,g(s,At)?it(s,At):f(s,At),this):this}updateUpAndDown({top:t,min:e,max:s}){const i=Math.ceil(t);return i<=e?(this.hide("up"),this.show("down")):i>=s?(this.hide("down"),this.show("up")):i>e&&i<s&&(this.show("up"),this.show("down")),this}destroy(){const t=this.attr("beforeDestroy"),e=this.attr("afterDestroy");return l(t)&&t.call(this),this.commands.clear(),this.removeListeners()._remove()._default(),l(e)&&e.call(this),this}execute(t){return this.isDisabled(t)||this.commands.execute(t),this}onExecute(t){const e=t.delegateTarget;let s="";return e&&(s=e.getAttribute("data-cmd"),s&&this.execute(s)),this}onToolbarUpdate({top:t,min:e,max:s}){return this.updateUpAndDown({top:t,min:e,max:s}),this}onAddButton(t){return this.attr({buttons:t}),this.refresh(t),this}onRemoveButton(t){return this.remove(t),this}addListeners(){const t=this.attr("buttons")||[],e=this.$el;return!t||t.length<1||(W(e,".outline-toolbar__button","click",this.onExecute,this,!0),this.$on("toolbar:update",this.onToolbarUpdate),this.$on("toolbar:add:button",this.onAddButton),this.$on("toolbar:remove:button",this.onRemoveButton),this.$on("toolbar:toggle",this.toggle)),this}removeListeners(){const t=this.attr("buttons")||[],e=this.$el;return!t||t.length<1||(V(e,".outline-toolbar__button",this.onExecute),this.$off("toolbar:update"),this.$off("toolbar:add:button"),this.$off("toolbar:remove:button"),this.$off("toolbar:toggle")),this}}Ot.DEFAULTS=u({placement:"ltr",closed:!1,disabled:!1,rounded:!0,buttons:[],created:null,mounted:null,afterClosed:null,afterOpened:null,afterDisabled:null,afterEnabled:null,beforeDestroy:null,afterDestroy:null});class Nt{constructor(t){this.utterance=new SpeechSynthesisUtterance,t&&this.initialize(t)}_initialize(t){return t.lang&&this.setLang(t.lang),t.pitch&&this.setPitch(t.pitch),t.rate&&this.setRate(t.rate),t.text&&this.setText(t.text),t.voice&&this.setVoice(t.voice),t.volume&&this.setVolume(t.volume),this}initialize(t){return this._initialize(t)._addListeners(),this}isSpeaking(){return speechSynthesis.speaking}isPending(){return speechSynthesis.pending}isPaused(){return speechSynthesis.paused}getVoices(){return speechSynthesis.getVoices()}setLang(t){return this.utterance.lang=t,this}setPitch(t){return this.utterance.pitch=t,this}setRate(t){return this.utterance.rate=t,this}setText(t){return this.utterance.text=t,this}setVoice(t){return this.utterance.voice=t,this}setVolume(t){return this.utterance.volume=t,this}speak(t){return t&&this.setText(t),speechSynthesis.speak(this.utterance),this}pause(){return speechSynthesis.pause(),this}resume(){return speechSynthesis.resume(),this}cancel(){return speechSynthesis.cancel(),this.setText(""),this}_addListeners(){const t=this.utterance,e=this;return["boundary","end","error","start","mark","pause","resume"].forEach((s=>{t[`on${s}`]=t=>{z(s,{event:t,speech:e})}})),speechSynthesis.onvoiceschanged=t=>{z("voiceschanged",{event:t,speech:e})},this}}Nt.isSupport="speechSynthesis"in window;const Ht=(t,e)=>{let s,i=t;for(;i;)s=i.tagName.toLowerCase(),"script"!==s&&"style"!==s&&f(i,"outline-reader_sibling"),i=e?i.previousElementSibling:i.nextElementSibling},Dt="进入阅读模式,按 ESC 键可退出阅读模式";class Ft extends O{constructor(t){super(),this.name="reader",this._default(),t&&this.initialize(t)}_default(){return this.attrs=u(Ft.DEFAULTS),this.reading=!1,this.$target=null,this.$el=null,this.$paper=null,this.$title=null,this.$article=null,this.$progress=null,this.toolbar=null,this.speech=null,this}initialize(t){let e;return this.attr(t),e=this.attr("target"),m(e)?this.$target=document.querySelector(e):p(e)&&(this.$target=e),this.$target?(Nt.isSupport&&(this.speech=new Nt),this.render().addListeners(),this):this}isSpeaking(){var t;return null==this||null===(t=this.speech)||void 0===t?void 0:t.isSpeaking()}render(){return this._renderEdge()._paint(this.$target),this}erase(){return this.$article.innerHTML="",this}_paint(t){const e=document.createDocumentFragment(),i=s(n,t.cloneNode(!0).children);return h((()=>{i.forEach((t=>{e.appendChild(t)})),this.$article.appendChild(e)})),this}_remove(){const t=this.$el,e=this.toolbar;return t&&document.body.removeChild(t),e&&e.destroy(),this}refresh(){return this.erase()._paint(this.$target),this}_animateTimeline(){return window.ScrollTimeline&&_t()?(this.$progress.animate({scale:["0 1","1 1"]},{timeline:new ScrollTimeline({source:this.$article,axis:"block"})}),this):this}_renderEdge(){const t=this.$target,e=_t()?26:20;let s,i,r,n,o,l,a=this.attr("title");o=tt("div",{className:"outline-reader__progress"}),this.$progress=o,r=t.querySelector("h1"),p(a)&&(r=a),p(r)&&(a=r.innerText),r=tt("h1",{className:"outline-reader__title"},a),this.$title=r,n=tt("article",{id:"outline-reader__article",className:"outline-reader__article"},_t()?[]:[o.cloneNode()]),this.$article=n,i=tt("div",{id:"outline-reader__paper",className:"outline-reader__paper"},[r,n]),this.$paper=i;const c=[];return c.push({name:"print",icon:"print",size:e,action:{context:this,handler:this.print}}),Nt.isSupport&&this.attr("allowSpeak")&&c.push({name:"speak",icon:"sound",size:e,action:{context:this,handler:this.speak}}),c.push({name:"exit",icon:"close",size:e,action:{context:this,handler:this.exit}}),this.toolbar=new Ot({placement:"rtl",buttons:c}),s=tt("section",{id:"outline-reader",className:"outline-reader outline-reader_hidden"},[o,i,this.toolbar.$el]),this.$el=s,document.body.appendChild(s),this._animateTimeline(),h((()=>{l=s.previousElementSibling,Ht(l,!0),l=s.nextElementSibling,Ht(l)})),this}enter(){const t="outline-reader",e=`${t}--reading`,s=`${t}_hidden`,i=this.$el,r=document.querySelectorAll(".outline-reader_sibling"),n=this.attr("enterReadingTip")||Dt;return this.reading||!i||(r.forEach((t=>{f(t,s)})),f(i,e),it(i,s),this.toolbar.show(),this.reading=!0,St.info({round:!0,message:n}),this.$emit("reader:enter")),this}exit(){const t="speak",e="outline-reader",s=`${e}--reading`,i=`${e}_hidden`,r=this.$el,n=document.querySelectorAll(".outline-reader_sibling"),o=this.speech,l=this.toolbar;return this.reading&&r?(f(r,i),it(r,s),n.forEach((t=>{it(t,i)})),l.hide(),this.reading=!1,o&&(l.isHighlight(t)&&l.highlight(t),o.cancel()),this.$emit("reader:exit"),this):this}toggle(){return this.reading?this.exit():this.enter(),this}speak(){const t=this.$article.innerText,e=this.speech;return Nt.isSupport&&e?(this.toolbar.highlight("speak"),this.isSpeaking()?e.cancel():e.speak(t),this):this}print(){return l(print)?(print(),this):this}destroy(){return this.$el?(this.removeListeners()._remove()._default(),this):this}onPrint(){return this.print(),this}onEnterReading(){return this.toggle(),this}onExitReading(t){return 27===t.keyCode&&this.reading&&(this.toggle(),Q(t)),this}onRefresh(){return this.refresh(),this}addListeners(){return this.$el?(gt(document,"keyup",this.onExitReading,this,!0),this.$on("toolbar:action:print",this.onPrint),this.$on("toolbar:action:reading",this.onEnterReading),this.$on("reader:print",this.onPrint),this.$on("reader:refresh",this.onRefresh),this.$on("reader:enter",this.enter),this.$on("reader:exit",this.exit),this.$on("reader:toggle",this.toggle),this):this}removeListeners(){return this.$el?(V(document,"keyup",this.onExitReading),this.$off("toolbar:action:print"),this.$off("toolbar:action:reading"),this.$off("reader:refresh"),this.$off("reader:toggle"),this):this}}var jt;Ft.DEFAULTS=u({target:"",title:"",enterReadingTip:Dt,allowSpeak:!1});class qt extends O{constructor(t){super(),this.version="3.39.3",this.name="outline",this._default(),t&&this.initialize(t)}_default(){return this.attrs=qt.DEFAULTS,this.$article=null,this.$scrollElement=null,this}initialize(t){let e="",s="",i=null;return this.attr(t),e=this.attr("articleElement"),s=this.attr("scrollElement"),m(e)?i=document.querySelector(e):p(e)&&(i=e),this.$article=i,this.$scrollElement=v(s),this.$emit("created",r({},this.attr())),this.render(),this}isExpanded(){const t=this.attr("position"),e=this.drawer,s=this.navigator;return!(this.count()<0)&&("relative"===t?!e.isClosed():!s.isClosed())}getChapters(t=!1){const e=this.$article,s=this.attr("selector"),i=this.attr("showCode"),r=this.attr("chapterTextFilter");return x({articleElement:e,selector:s,showCode:i,chapterTextFilter:r,isTreeStructured:t})}count(){return this.getChapters().length}render(){const t=this.attr("hasToolbar"),e=this.$scrollElement;return this._renderReader()._renderAnchors()._renderNavigator()._renderToolbar(),e&&t&&this.toolbar.updateUpAndDown({top:e.scrollTop,min:0,max:e.scrollHeight}),qt.plugins.executeAll(),this.$emit("mounted"),this}_renderReader(){const t=this.attr("reader");return t.target?(f(this.$article,"outline-article"),this.reader=new Ft(t),this):this}_renderAnchors(){const t=this.attr("articleElement"),e=this.attr("selector"),s=this.attr("stickyHeight"),i=this.attr("scrollElement"),r=this.attr("showCode"),n=this.attr("anchorURL"),o=this.attr("afterScroll"),l=this.attr("chapterTextFilter"),h=this.attr("anchorLinkFilter");return this.anchors=new ot({articleElement:t,stickyHeight:s,scrollElement:i,selector:e,showCode:r,anchorURL:n,afterScroll:o,chapterTextFilter:l,anchorLinkFilter:h}),this}_renderNavigator(){const t=this.attr("title"),e=this.attr("stickyHeight"),s=this.attr("scrollElement"),i=this.attr("customClass"),r=this.attr("showCode"),n=this.attr("animationCurrent"),o=this.attr("closeOnClickModal"),l=this.attr("showNavModalFirst"),h=this.attr("position"),a=this.attr("placement"),c=this.attr("afterSticky"),u=this.attr("afterToggle"),d=this.attr("afterScroll"),m=this.count();let p,g=this.attr("parentElement");return m<1||(p={scrollElement:s,showCode:r,animationCurrent:n,position:h,title:t,stickyHeight:e,chapters:this.getChapters(),afterSticky:c,afterToggle:u,afterScroll:d},"relative"===h?(this.drawer=new pt({placement:a,title:t,size:"tiny",hasOffset:!0,hasPadding:!1,closeOnClickModal:o,customClass:i,afterClosed:()=>{this.toolbar.toggle()}}),g=this.drawer.$main,l&&this.drawer.open()):p.customClass=i,p.parentElement=g,this.navigator=new $t(p)),this}_renderToolbar(){const t=this.attr("position"),e=this.attr("hasToolbar"),i=this.attr("showNavModalFirst"),r=this.attr("placement"),o=this.attr("homepage"),h=this.attr("git"),a=this.attr("tags"),c=this.attr("issues"),u=this.attr("tools"),d=this.attr("reader"),m=this.count(),p={name:"up",icon:"up",size:20,action:{context:this,handler:this.toTop}},g={name:"homepage",icon:"homepage",size:20,link:o},f={name:"github",icon:"github",size:20,link:h},b={name:"tags",icon:"tags",size:20,link:a},y={name:"issues",icon:"issues",size:20,link:c},v={name:"toggle",icon:"menu",size:18,action:{context:this,handler:this.toggle}},$={name:"reading",icon:"file",size:18,action:{context:this,handler:"toolbar:action:reading"}},_={name:"print",icon:"print",size:20,action:{handler:"toolbar:action:print"}},x={name:"down",icon:"down",size:20,action:{context:this,handler:this.toBottom}},w=[];return e?(w.push(p),m>0&&w.push(v),o&&w.push(g),h&&w.push(f),a&&w.push(b),c&&w.push(y),d.target&&(w.push($),l(print)&&w.push(_)),(null==u?void 0:u.length)>0&&w.push.apply(w,s(n,u)),w.push(x),this.toolbar=new Ot({placement:r,buttons:w}),"relative"===t&&i&&this.toolbar.hide(),this):this}refresh(){const t=this.getChapters();return this.anchors.refresh(t),this.navigator.refresh(t),this.reader.refresh(),this.$emit("refresh",t),this}addButton(t){return this.toolbar.add(t),this}removeButton(t){return this.toolbar.remove(t),this}toTop(){const t=this.attr("afterScroll"),e=this.toolbar,s=this.navigator,i=this.count();return i>0&&(s.playing=!0),this.scrollTo(0,(()=>{e.hide("up"),e.show("down"),i>0&&(s.highlight(0),s.playing=!1,y(s.$main,0)),l(t)&&t.call(e,"up")})),this}toBottom(){const t=this.attr("afterScroll"),e=this.$scrollElement,s=this.toolbar,i=this.navigator,r=this.count(),n=Math.floor(e.scrollHeight-e.clientHeight);return r>0&&(i.playing=!0),this.scrollTo(n,(()=>{const e=i.$main;s.hide("down"),s.show("up"),r>0&&(i.highlight(r-1),y(e,e.scrollHeight),i.playing=!1),l(t)&&t.call(s,"bottom")})),this}scrollTo(t,e){return y(this.$scrollElement,t,e),this}enterReading(){return this.toolbar.toggle(),this.reader.enter(),this}exitReading(){return this.toolbar.toggle(),this.reader.exit(),this}switchReading(){return this.toolbar.toggle(),this.reader.exit(),this}expand(){const t=this.attr("position"),e=this.toolbar,s=this.drawer,i=this.navigator;return this.count()<1||("relative"!==t?(i.show(),e.highlight("toggle")):(e.hide(),h((()=>{s.open()})))),this}collapses(){const t=this.attr("position"),e=this.toolbar,s=this.drawer,i=this.navigator;return this.count()<1||("relative"!==t?(i.hide(),e.highlight("toggle")):(e.show(),h((()=>{s.close()})))),this}toggle(){return this.isExpanded()?this.collapses():this.expand(),this}print(){return this.reader.print(),this}execute(t,e){return qt.plugins.execute(t,e),this}_destroy(){const t=this.count();let e=this.anchors,s=this.navigator,i=this.drawer,r=this.reader,n=this.toolbar,o=!1;return r&&r.destroy(),t>0&&s&&(o=s.isOutside(),s.destroy(),o&&i&&i.destroy()),e&&e.destroy(),n&&n.destroy(),qt.plugins.destroyAll(),this}destroy(){return this.$emit("beforeDestroy"),this._destroy()._default(),this.$emit("destroyed"),this}}if(qt.plugins=new class{constructor(){return this.plugins=[],this}find(t){return this.plugins.find((e=>e.name===t))}exists(t){return!!this.find(t)}add(t){const{name:e}=t;if(!e)throw new Error("Plugin name required");return this.exists(e)||this.plugins.push(t),this}remove(t){const e=this.find(t);if(!e)return this;const s=this.plugins;return s.splice(s.indexOf(e),1),this}execute(t,e){const s=this.find(t);return s?(s.execute(e),this):this}executeAll(){return this.plugins.forEach((t=>{this.execute(t.name)})),this}destroy(t){const e=this.find(t);return e?(e.destroy(),this.remove(t),this):this}destroyAll(){return this.plugins.map((t=>t.name)).forEach((t=>{this.destroy(t)})),this}},qt.proto=(t,e,s)=>{if(d(qt.prototype,t))return!1;let i;e.DEFAULTS?i=new e(s):l(e)&&(i=e),qt.prototype[t]=i},qt.cmd=(t,e,s)=>{qt.plugins.add(new T(t,e,s))},qt.plug=(t,e,s)=>{qt.plugins.add(new w(t,e,s))},qt.DEFAULTS=u({articleElement:"#article",selector:"h2,h3,h4,h5,h6",parentElement:"#aside",scrollElement:"html,body",title:"目录",position:"relative",placement:"rtl",animationCurrent:!0,showCode:!1,hasToolbar:!0,closeOnClickModal:!0,showNavModalFirst:!1,anchorURL:"",stickyHeight:0,homepage:"",git:"",tags:"",issues:"",tools:[],reader:{target:"",title:"",enterReadingTip:"进入阅读模式,按 ESC 键可退出阅读模式",allowSpeak:!1},customClass:"",afterSticky:null,afterToggle:null,afterScroll:null,chapterTextFilter:null,anchorLinkFilter:null}),null!==(jt=window)&&void 0!==jt&&jt.jQuery){const t=window.jQuery;t.extend(t.fn,{outline:function(e){let s=t(this);return new qt(t.extend({},e,{articleElement:s}))}})}return qt}));
//# sourceMappingURL=outline.min.js.map