17 lines
44 KiB
JavaScript

/*
This is the Obsidian example vault is amazing, there are a lot of dazzling features and showcase, I believe you will wonder a bit, is this Obsidian?
[Blue-topaz-examples](https://github.com/cumany/Blue-topaz-examples)
*/
var ke=Object.create;var q=Object.defineProperty,Ae=Object.defineProperties,Ie=Object.getOwnPropertyDescriptor,Me=Object.getOwnPropertyDescriptors,Oe=Object.getOwnPropertyNames,X=Object.getOwnPropertySymbols,De=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty,Fe=Object.prototype.propertyIsEnumerable;var Q=(i,e,t)=>e in i?q(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,z=(i,e)=>{for(var t in e||(e={}))J.call(e,t)&&Q(i,t,e[t]);if(X)for(var t of X(e))Fe.call(e,t)&&Q(i,t,e[t]);return i},V=(i,e)=>Ae(i,Me(e)),Z=i=>q(i,"__esModule",{value:!0});var qe=(i,e)=>{Z(i);for(var t in e)q(i,t,{get:e[t],enumerable:!0})},ze=(i,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Oe(e))!J.call(i,n)&&n!=="default"&&q(i,n,{get:()=>e[n],enumerable:!(t=Ie(e,n))||t.enumerable});return i},N=i=>ze(Z(q(i!=null?ke(De(i)):{},"default",i&&i.__esModule&&"default"in i?{get:()=>i.default,enumerable:!0}:{value:i,enumerable:!0})),i);var L=(i,e,t)=>new Promise((n,s)=>{var a=c=>{try{o(t.next(c))}catch(r){s(r)}},l=c=>{try{o(t.throw(c))}catch(r){s(r)}},o=c=>c.done?n(c.value):Promise.resolve(c.value).then(a,l);o((t=t.apply(i,e)).next())});qe(exports,{default:()=>K,refresh_node:()=>He,selfDestruct:()=>F});var C=N(require("obsidian"));var T=N(require("obsidian"));function P(i,e){return i+1<e.length?e[i+1].level>e[i].level:!1}function R(i,e,t){let n,s;i instanceof MouseEvent?(i.stopPropagation(),n=e,s=t||!1):(n=i,s=e);let a=n.getAttribute("isCollapsed");a!==null&&(a==="true"?Pe(n,s):a==="false"&&Be(n))}function Pe(i,e){i.setAttribute("isCollapsed","false");let t=parseInt(i.getAttribute("data-level")),n=i.nextElementSibling;if(e)for(;n&&parseInt(n.getAttribute("data-level"))>t;)n.style.display="block",n.getAttribute("isCollapsed")!==null&&n.setAttribute("isCollapsed","false"),n=n.nextElementSibling;else{let s=!1,a=Number.MAX_VALUE;for(;n&&parseInt(n.getAttribute("data-level"))>t;){let l=n.getAttribute("isCollapsed")!==null,o=parseInt(n.getAttribute("data-level"));s?o<=a&&(n.style.display="block",s=l,a=l?o:Number.MAX_VALUE):(l&&(s=!0,a=o),n.style.display="block"),n=n.nextElementSibling}}}function Be(i){i.setAttribute("isCollapsed","true");let e=parseInt(i.getAttribute("data-level")),t=i.nextElementSibling;for(;t&&parseInt(t.getAttribute("data-level"))>e;)t.style.display="none",t.getAttribute("isCollapsed")!==null&&t.setAttribute("isCollapsed","true"),t=t.nextElementSibling}function ee(i,e){i.querySelectorAll("li.heading-list-item[iscollapsed]").forEach(n=>{let s=n,a=s.getAttribute("isCollapsed")==="true";e!==!a&&R(s,e)})}var Ee=N(require("obsidian"));var te={};var ne={};var ie={};var ae={};var $={"ctrl + click on the floating toc to collapse/expand the header.":"ctrl + click on the floating toc to collapse/expand the header.","Floating TOC position":"Floating TOC position","Floating TOC position, default on the left side of the notes":"Floating TOC position, default on the left side of the notes","Hide heading level":"Hide heading level","Whichever option is selected, the corresponding heading level will be hidden":"Whichever option is selected, the corresponding heading level will be hidden","Plugin Settings":"Plugin Settings","Default Pin":"Default Pin","Enable Tooltip":"Enable Tooltip","Enable Search":"Enable Search","Enable quick search functionality in floating TOC. Press any key when TOC is active to start searching.":"Enable quick search functionality in floating TOC. Press any key when TOC is active to start searching.","Plugin Style Settings":"Plugin Style Settings","Mobile enabled or not":"Mobile enabled or not","Whether to enable the plugin for the mobile client, the default is enabled.":"Whether to enable the plugin for the mobile client, the default is enabled.","If the floating Toc option is not found in the style setting, please reload the style setting plugin (turn it off and on again)":"If the floating Toc option is not found in the style setting, please reload the style setting plugin (turn it off and on again)","Left alignment of TOC text":"Left alignment of TOC text","Aligned on both sides":"Aligned on both sides","Floating TOC position, on the right side of the notes":"Floating TOC position, on the right side of the notes","whether the text in TOC is left aligned":"whether the text in TOC is left aligned","When the panel is split left and right, the right side of the layout is aligned right and the left side of the panel is aligned left.":"When the panel is split left and right, the right side of the layout is aligned right and the left side of the panel is aligned left.","Set the default collapsed level of headings when initialised":"Set the default collapsed level of headings when initialised","Default Collapsed Level":"Default Collapsed Levels","Expand All Subheadings Recursively":"Expand All Subheadings Recursively","When disabled, only direct subheadings will be expanded":"When disabled, only direct subheadings will be expanded","Basic Settings":"Basic Settings","TOC Display Settings":"TOC Display Settings","Interaction Settings":"Interaction Settings","Style Settings":"Style Settings","Default Hide TOC":"Default Hide TOC","When enabled, TOC will be hidden by default when plugin starts":"When enabled, TOC will be hidden by default when plugin starts","Header single line display":"Header single line display","When enabled, heading text will be displayed in a single line":"When enabled, heading text will be displayed in a single line","Indicator bar style":"Indicator bar style","Choose the style of the indicator bar":"Choose the style of the indicator bar",Default:"Default",Icon:"Icon",Bold:"Bold","Show heading text next to indicator bar":"Show heading text next to indicator bar","When enabled, heading text will be shown next to the indicator bar":"When enabled, heading text will be shown next to the indicator bar","More Style Settings":"More Style Settings","Notice: Please click the button again,If the floating-toc option is not found in the style settings":"Notice: Please click the button again,If the floating-toc option is not found in the style settings","Search in TOC ":"Search in TOC ","Search in Floating TOC":"Search in Floating TOC",Search:"Search","Search title... ":"Search TOC title... ","Search results":"Search results","No results found":"No results found","Press Enter to jump to selected title":"Press Enter to jump to selected title","Press Escape to cancel search":"Press Escape to cancel search","Use arrow keys to navigate results":"Use arrow keys to navigate results","Close search":"Close search"};var se={};var le={};var oe={};var re={};var ce={};var de={};var he={};var ge={};var ue={};var pe={};var fe={};var me={};var be={};var ye={};var ve={};var Ce={};var Te={"ctrl + click on the floating toc to collapse/expand the header.":"\u6309\u4F4Fctrl \u70B9\u51FB\u76EE\u5F55\u4E2D\u7684\u6807\u9898\uFF0C\u53EF\u4EE5\u4F7F\u5BF9\u5E94\u7684\u6B63\u6587\u5185\u5BB9\u6298\u53E0/\u5C55\u5F00\u3002","Floating TOC position":"\u6D6E\u52A8\u76EE\u5F55\u663E\u793A\u4F4D\u7F6E","Floating TOC position, default on the left side of the notes":"\u6D6E\u52A8\u76EE\u5F55\u663E\u793A\u4F4D\u7F6E\uFF0C\u9ED8\u8BA4\u663E\u793A\u5728\u7B14\u8BB0\u5DE6\u4FA7","Hide heading level":"\u9690\u85CF\u6307\u5B9A\u7684\u6807\u9898\u5C42\u7EA7","Whichever option is selected, the corresponding heading level will be hidden":"\u9690\u85CF\u9009\u4E2D\u7684\u6807\u9898\u5C42\u7EA7\uFF0C\u9009\u4E2D\u7684\u6807\u9898\u4E0D\u4F1A\u5728\u6D6E\u52A8\u76EE\u5F55\u4E2D\u663E\u793A\u3002","Plugin Settings":"\u63D2\u4EF6\u8BBE\u7F6E","Default Pin":"\u662F\u5426\u9ED8\u8BA4\u9489\u5728\u7B14\u8BB0\u4E0A","Enable Tooltip":"\u662F\u5426\u5F00\u542F\u6807\u9898\u63D0\u793A","Enable Search":"\u542F\u7528\u641C\u7D22\u529F\u80FD","Enable quick search functionality in floating TOC. Press any key when TOC is active to start searching.":"\u542F\u7528\u6D6E\u52A8\u76EE\u5F55\u7684\u5FEB\u901F\u641C\u7D22\u529F\u80FD\u3002\u5F53\u76EE\u5F55\u6FC0\u6D3B\u65F6\u6309\u4EFB\u610F\u952E\u5F00\u59CB\u641C\u7D22\u3002","Plugin Style Settings":"\u63D2\u4EF6\u6837\u5F0F\u8BBE\u7F6E","Mobile enabled or not":"\u662F\u5426\u5728\u79FB\u52A8\u7AEF\u542F\u7528","Whether to enable the plugin for the mobile client, the default is enabled.":"\u79FB\u52A8\u5BA2\u6237\u7AEF\u662F\u5426\u542F\u7528\u63D2\u4EF6\uFF0C\u9ED8\u8BA4\u542F\u7528\u3002","If the floating Toc option is not found in the style setting, please reload the style setting plugin (turn it off and on again)":"\u5982\u679Cstyle setting \u4E2D\u65E0\u6CD5\u770B\u5230 floating Toc\u9009\u9879\uFF0C\u8BF7\u91CD\u8F7Dstyle setting\u63D2\u4EF6\uFF08\u5173\u95ED\u518D\u5F00\u542F\u5373\u53EF\uFF09","Left alignment of TOC text":"\u76EE\u5F55\u6587\u5B57\u5DE6\u5BF9\u9F50","Floating TOC position, on the right side of the notes":"\u6D6E\u52A8\u76EE\u5F55\u663E\u793A\u4F4D\u7F6E\uFF0C\u663E\u793A\u5728\u7B14\u8BB0\u53F3\u4FA7","whether the text in TOC is left aligned":"\u5F53\u5DE5\u5177\u680F\u5728\u53F3\u4FA7\u65F6\uFF0C\u76EE\u5F55\u4E2D\u7684\u6807\u9898\u662F\u5426\u5DE6\u5BF9\u9F50","Aligned on both sides":"\u4E24\u7AEF\u5BF9\u9F50","When the panel is split left and right, the right side of the layout is aligned right and the left side of the panel is aligned left.":"\u5F53\u9762\u677F\u5DE6\u53F3\u5206\u5272\u7684\u65F6\u5019\uFF0C\u53F3\u4FA7\u7248\u9762\u53F3\u5BF9\u9F50\uFF0C\u5DE6\u4FA7\u9762\u677F\u5DE6\u5BF9\u9F50\u3002","Set the default collapsed level of headings when initialised":"\u8BBE\u7F6E\u521D\u59CB\u5316\u65F6TOC\u4E2D\u9ED8\u8BA4\u6298\u53E0\u7684\u6807\u9898\u7EA7\u522B","Default Collapsed Level":"\u9ED8\u8BA4\u6298\u53E0\u7EA7\u522B","Expand All Subheadings Recursively":"\u9012\u5F52\u5C55\u5F00\u6240\u6709\u5B50\u6807\u9898","When disabled, only direct subheadings will be expanded":"\u5173\u95ED\u6B64\u9009\u9879\u65F6, \u53EA\u5C55\u5F00\u76F4\u63A5\u5B50\u6807\u9898","Basic Settings":"\u57FA\u672C\u8BBE\u7F6E","TOC Display Settings":"\u76EE\u5F55\u663E\u793A\u8BBE\u7F6E","Interaction Settings":"\u4EA4\u4E92\u8BBE\u7F6E","Style Settings":"\u6837\u5F0F\u8BBE\u7F6E","Default Hide TOC":"\u9ED8\u8BA4\u9690\u85CF\u76EE\u5F55","When enabled, TOC will be hidden by default when plugin starts":"\u542F\u7528\u540E\uFF0C\u63D2\u4EF6\u542F\u52A8\u65F6\u76EE\u5F55\u5C06\u9ED8\u8BA4\u9690\u85CF","Header single line display":"\u76EE\u5F55\u6807\u9898\u5355\u884C\u663E\u793A","When enabled, heading text will be displayed in a single line":"\u542F\u7528\u540E\uFF0C\u76EE\u5F55\u6807\u9898\u5C06\u5728\u4E00\u884C\u5185\u663E\u793A","Indicator bar style":"\u6307\u793A\u6761\u6837\u5F0F","Choose the style of the indicator bar":"\u9009\u62E9\u6307\u793A\u6761\u7684\u6837\u5F0F",Default:"\u9ED8\u8BA4",Icon:"\u56FE\u6807",Bold:"\u7C97\u4F53","Show heading text next to indicator bar":"\u5728\u6307\u793A\u6761\u65C1\u8FB9\u663E\u793A\u6807\u9898\u4E0A\u4E0B\u7EA7","When enabled, heading text will be shown next to the indicator bar":"\u542F\u7528\u540E\uFF0C\u6807\u9898\u6587\u672C\u5C06\u663E\u793A\u5728\u6307\u793A\u6761\u65C1\u8FB9","More Style Settings":"\u66F4\u591A\u6837\u5F0F\u8BBE\u7F6E","Search in TOC ":"\u5728\u76EE\u5F55\u4E2D\u641C\u7D22 ","Search in Floating TOC":"\u5728\u6D6E\u52A8\u76EE\u5F55\u4E2D\u641C\u7D22",Search:"\u641C\u7D22","Search title... ":"\u641C\u7D22\u5927\u7EB2\u6807\u9898... ","Search results":"\u641C\u7D22\u7ED3\u679C","No results found":"\u672A\u627E\u5230\u7ED3\u679C","Press Enter to jump to selected title":"\u6309\u56DE\u8F66\u952E\u8DF3\u8F6C\u5230\u9009\u4E2D\u7684\u6807\u9898","Press Escape to cancel search":"\u6309ESC\u952E\u53D6\u6D88\u641C\u7D22","Use arrow keys to navigate results":"\u4F7F\u7528\u7BAD\u5934\u952E\u5BFC\u822A\u7ED3\u679C","Close search":"\u5173\u95ED\u641C\u7D22"};var Se={"Floating TOC position":"\u6D6E\u52D5\u76EE\u9304\u986F\u793A\u4F4D\u7F6E","Floating TOC position, default on the left side of the notes":"\u6D6E\u52D5\u76EE\u9304\u986F\u793A\u4F4D\u7F6E\uFF0C\u9ED8\u8A8D\u986F\u793A\u5728\u7B46\u8A18\u5DE6\u5074","Ignore top-level headers":"\u662F\u5426\u5FFD\u7565\u9802\u7D1A\u76EE\u9304","Select whether to ignore the top-level headings. When turned on, the top-level headings in the current note are not displayed in the floating TOC.":"\u9078\u64C7\u662F\u5426\u5FFD\u7565\u9802\u7D1A\u6A19\u984C\uFF0C\u958B\u555F\u5F8C\u7576\u524D\u6587\u6A94\u4E2D\u6700\u9802\u7D1A\u7684\u6A19\u984C\u4E0D\u986F\u793A\u5728\u6D6E\u52D5\u76EE\u9304\u4E2D\u3002","Plugin Settings":"\u63D2\u4EF6\u8A2D\u7F6E","Default Pin":"\u662F\u5426\u9ED8\u8A8D\u91D8\u5728\u7B46\u8A18\u4E0A","Plugin Style Settings":"\u63D2\u4EF6\u6A23\u5F0F\u8A2D\u7F6E","Mobile enabled or not":"\u662F\u5426\u5728\u79FB\u52D5\u7AEF\u555F\u7528","Whether to enable the plugin for the mobile client, the default is enabled.":"\u79FB\u52D5\u5BA2\u6236\u7AEF\u662F\u5426\u555F\u7528\u63D2\u4EF6\uFF0C\u9ED8\u8A8D\u555F\u7528\u3002","If the floating Toc option is not found in the style setting, please reload the style setting plugin (turn it off and on again)":"\u5982\u679Cstyle setting \u4E2D\u7121\u6CD5\u770B\u5230 floating Toc\u9078\u9805\uFF0C\u8ACB\u91CD\u8F09style setting\u63D2\u4EF6\uFF08\u95DC\u9589\u518D\u958B\u555F\u5373\u53EF\uFF09","Left alignment of TOC text":"\u76EE\u9304\u6587\u5B57\u5DE6\u5C0D\u9F4A","Floating TOC position, on the right side of the notes":"\u6D6E\u52D5\u76EE\u9304\u986F\u793A\u4F4D\u7F6E\uFF0C\u986F\u793A\u5728\u7B46\u8A18\u53F3\u5074","whether the text in TOC is left or right aligned When the floating toc is on the right":"\u7576\u5DE5\u5177\u6B04\u5728\u53F3\u5074\u6642\uFF0C\u76EE\u9304\u4E2D\u7684\u6A19\u984C\u662F\u5426\u5DE6\u5C0D\u9F4A","Aligned on both sides":"\u5169\u7AEF\u5C0D\u9F4A","When the panel is split left and right, the right side of the layout is aligned right and the left side of the panel is aligned left.":"\u7576\u9762\u677F\u5DE6\u53F3\u5206\u5272\u7684\u6642\u5019\uFF0C\u53F3\u5074\u7248\u9762\u53F3\u5C0D\u9F4A\uFF0C\u5DE6\u5074\u9762\u677F\u5DE6\u5C0D\u9F4A\u3002"};var Ne={ar:te,cs:ne,da:ie,de:ae,en:$,"en-gb":se,es:le,fr:oe,hi:re,id:ce,it:de,ja:he,ko:ge,nl:ue,nn:pe,pl:fe,pt:me,"pt-br":be,ro:ye,ru:ve,tr:Ce,"zh-cn":Te,"zh-tw":Se},we=Ne[Ee.moment.locale()];function f(i){return we&&we[i]||$[i]}function _e(i,e,t,n,s,a){return L(this,null,function*(){let l=/^(?:\s*)[0-9]+\.\s/,o=/^(?:\s*)[\-\+]\s/,c,r="";(c=l.exec(t))!==null?(r=c[0],t=t.replace(l,"")):(c=o.exec(t))!==null&&(r=c[0],t=t.replace(o,""));let h=Number(n.parentElement.getAttribute("data-id")),b=Number(n.parentElement.getAttribute("data-level")),u=m=>{m.stopImmediatePropagation(),R(m,n.parentElement,i.settings.expandAllSubheadings)};n.parentElement.addEventListener("click",u),n.parentElement.hasAttribute("isCollapsed")?P(h,i.headingdata)||(n.parentElement.removeAttribute("isCollapsed"),n.parentElement.removeEventListener("click",u)):P(h,i.headingdata)&&n.parentElement.setAttribute("isCollapsed","false");let p=n;a=new T.Component,yield T.MarkdownRenderer.renderMarkdown(t,p,s,a),p&&p.classList.add("heading-rendered");let E=p.createEl("a");E.addClass("text"),E.onclick=function(m){var I;m.stopPropagation();let w=(I=parseInt(p.parentElement.getAttribute("data-line")))!=null?I:0;if(m.ctrlKey||m.metaKey)Re(e,w);else{Ve(e,w);let x=p.parentElement.parentElement.querySelector(".text-wrap.located");x&&x.removeClass("located"),p.addClass("located")}};let v=p.querySelector("p");if(v){let m=/<a[^>]*>|<\/[^>]*a>/gm;r?E.innerHTML=r+v.innerHTML.replace(m,""):E.innerHTML=v.innerHTML.replace(m,""),p.removeChild(v),i.settings.isTooltip&&(p.setAttribute("aria-label",t),i.settings.positionStyle=="right"&&p.setAttribute("aria-label-position","left"),i.settings.positionStyle=="left"&&p.setAttribute("aria-label-position","right"),i.settings.positionStyle=="both"&&p.setAttribute("aria-label-position","top"))}})}function B(i,e,t,n,s){return L(this,null,function*(){var c,r,h,b,u,p;if(!n)return;let a=t.createEl("li");a.addClass("heading-list-item"),a.setAttribute("data-level",(r=(c=n==null?void 0:n.level)==null?void 0:c.toString())!=null?r:""),a.setAttribute("data-id",s.toString()),a.setAttribute("data-line",(p=(u=(b=(h=n==null?void 0:n.position)==null?void 0:h.start)==null?void 0:b.line)==null?void 0:u.toString())!=null?p:"");let l=a.createEl("div");l.addClass("text-wrap"),yield _e(i,e,n.heading,l,e.file.path,null);let o=a.createEl("div");o.addClass("line-wrap"),o.createDiv().addClass("line")})}var Ve=(i,e)=>{i.leaf.openFile(i.file,{eState:{line:e}})},Re=(i,e)=>{var a,l;let t=(l=(a=i==null?void 0:i.currentMode.getFoldInfo())==null?void 0:a.folds)!=null?l:[],n=e,s=0;if(t.some((o,c)=>(s=c,o.from==n)))t.splice(s,1);else{let o={from:e,to:e+1};t.push(o)}i==null||i.currentMode.applyFoldInfo({folds:t,lines:i.editor.lineCount()}),i==null||i.onMarkdownFold()};function _(i,e){var s;let t=(a,l)=>{var p,E,v;let o=i.workspace.getActiveFile(),c=i.metadataCache.getFileCache(o).headings,r=[];if(c==null||c.map(m=>{m.heading=m.heading.replace(/<\/?[\s\S]*?(?:".*")*>/g,""),r.push(m)}),e.headingdata=r,e.headingdata.length==0)return;e.settings.positionStyle=="right"?(l.addClass("floating-right"),l.removeClass("floating-left"),l.removeClass("floating-both")):e.settings.positionStyle=="left"?(l.addClass("floating-left"),l.removeClass("floating-rigth"),l.removeClass("floating-both")):e.settings.positionStyle=="both"&&(l.addClass("floating-both"),l.removeClass("floating-left"),l.removeClass("floating-rigth")),e.settings.isLeft?(l.removeClass("alignLeft"),l.addClass("alignLeft")):l.removeClass("alignLeft");let h=l.createEl("ul");h.addClass("floating-toc");let b=l.createEl("div");if(W(e,b,l),e.settings.ignoreHeaders){let m=e.settings.ignoreHeaders.split(`
`);e.headingdata=(p=i.metadataCache.getFileCache(o).headings)==null?void 0:p.filter(w=>!m.includes(w.level.toString()))}(()=>{let m=e.headingdata.length,w=i.workspace.getActiveViewOfType(T.MarkdownView);if(m>50){let I=20,x=e.headingdata.slice(0,I),S=activeDocument.createElement("div");S.className="toc-loading-indicator",S.textContent=`Loading... (${I}/${m})`,S.style.textAlign="center",S.style.padding="8px",S.style.color="var(--text-muted)",S.style.fontSize="0.8em",S.style.position="fixed",S.style.top="45px",x.forEach((g,d)=>{B(e,w,h,g,d)}),h.appendChild(S);let M=I,D=20,O=()=>{let g=Math.min(M+D,m);S.textContent=`\u52A0\u8F7D\u4E2D... (${g}/${m})`;for(let d=M;d<g;d++)B(e,w,h,e.headingdata[d],d);M=g,M<m?requestAnimationFrame(()=>{setTimeout(O,10)}):S.remove()};setTimeout(O,50)}else e.headingdata.forEach((I,x)=>{B(e,w,h,I,x)})})(),((E=a==null?void 0:a.querySelector(".markdown-source-view"))==null?void 0:E.insertAdjacentElement("beforebegin",l))||((v=a==null?void 0:a.querySelector(".markdown-reading-view"))==null||v.insertAdjacentElement("beforebegin",l))};if(this.app.workspace.getActiveViewOfType(T.MarkdownView)){(0,T.requireApiVersion)("0.15.0")?activeDocument=activeWindow.document:activeDocument=window.document;let a=e.app.workspace.getActiveViewOfType(T.MarkdownView);if(a){if((s=a.contentEl)==null?void 0:s.querySelector(".floating-toc-div"))return;{let o=createEl("div");o.addClass("floating-toc-div"),e.BAR_STYLE_CLASSES.forEach(c=>{activeDocument.body.removeClass(c)}),e.settings.isDefaultPin&&o.addClass("pin"),e.settings.isDefaultHide&&o.addClass("hide"),e.settings.enableHeadingNowrap&&activeDocument.body.addClass("enable-heading-nowrap"),e.settings.enableBarHeadingText&&activeDocument.body.addClass("enable-bar-heading-text"),activeDocument.body.addClass(e.settings.barStyle||"enable-edge-style"),t(a.contentEl,o),e.updateTocWidth(o,e.headingdata),e.search&&e.search.initSearch(o)}}}}function W(i,e,t){e.addClass("toolbar"),e.addClass("hide"),new T.ButtonComponent(e).setIcon("pin").setTooltip("pin").onClick(()=>{t.classList.contains("pin")?t.removeClass("pin"):t.addClass("pin")}),new T.ButtonComponent(e).setIcon("search").setTooltip(f("Search in TOC ")).setClass("search").onClick(()=>{i.search&&i.search.startSearchFromButton()}),new T.ButtonComponent(e).setIcon("double-up-arrow-glyph").setTooltip("Scroll to Top").setClass("top").onClick(()=>{let r=this.app.workspace.getActiveViewOfType(T.MarkdownView);r&&r.setEphemeralState({scroll:0})}),new T.ButtonComponent(e).setIcon("double-down-arrow-glyph").setTooltip("Scroll to Bottom").setClass("bottom").onClick(()=>L(this,null,function*(){let r=this.app.workspace.getActiveViewOfType(T.MarkdownView);if(r){let h=this.app.workspace.getActiveFile(),u=(yield this.app.vault.cachedRead(h)).split(`
`),p=u.length;if(r.getMode()==="preview")for(;p>0&&u[p-1].trim()==="";)p--;r.currentMode.applyScroll(p-1)}})),new T.ButtonComponent(e).setIcon("copy").setTooltip("copy TOC to clipboard").setClass("copy").onClick(()=>L(this,null,function*(){let r=i.headingdata.map(h=>`${" ".repeat(h.level-1)}- [[#${h.heading}]]`);yield navigator.clipboard.writeText(r.join(`
`)),new T.Notice("TOC Copied")}));let c=new T.ButtonComponent(e).setIcon("chevron-down").setTooltip("Collapse/Expand all headings").setClass("toggle-all").onClick(()=>{let r=t.getAttribute("data-all-expanded")==="true";c.setIcon(r?"chevron-right":"chevron-down"),ee(t,!r),t.setAttribute("data-all-expanded",(!r).toString())})}var H=N(require("obsidian"));var xe=["left","right","both"],Le={ignoreHeaders:"",ignoreTopHeader:!1,positionStyle:"left",isLoadOnMobile:!0,isLeft:!1,isDefaultPin:!1,isTooltip:!0,defaultCollapsedLevel:6,expandAllSubheadings:!1,isDefaultHide:!1,enableHeadingNowrap:!0,barStyle:"enable-edge-style",enableBarHeadingText:!1};var j=class{constructor(e){this.checkedList=[];this.containerEl=e,this.flowListEl=this.containerEl.createDiv({cls:"check-list"})}addItem(e,t,n,s){let a=this.flowListEl.createDiv({cls:"check-item"}),l=a.createEl("input",{type:"checkbox"});return l.checked=n,l.checked&&this.checkedList.push(t),l.addEventListener("change",c=>{l.checked?this.checkedList.includes(t)||this.checkedList.push(t):this.checkedList.includes(t)&&this.checkedList.remove(t)}),l.addEventListener("change",c=>s(l.checked)),a.createDiv({cls:"flow-label"}).setText(e),a}};var U=class extends H.PluginSettingTab{constructor(e,t){super(e,t);this.plugin=t,addEventListener("refresh-toc",()=>{F(),_(e,this.plugin)})}display(){var D,O;let{containerEl:e}=this;e.empty(),e.createEl("h1",{text:"Obsidian Floating TOC "}),e.createEl("span",{text:""}).createEl("a",{text:"Author: Cuman \u2728",href:"https://github.com/cumany"}),e.createEl("span",{text:""}).createEl("a",{text:"Readme:\u4E2D\u6587",href:"https://pkmer.cn/Pkmer-Docs/10-obsidian/obsidian%E7%A4%BE%E5%8C%BA%E6%8F%92%E4%BB%B6/floating-toc/"}),e.createEl("span",{text:""}).createEl("a",{text:"|English ",href:"https://github.com/cumany/obsidian-floating-toc-plugin/blob/master/README.md"});let t=e.createEl("div");t.addClass("callout"),t.setAttribute("data-callout","info");let n=t.createEl("div",{text:"\u{1F511}TIPS:"});n.addClass("callout-title"),n.createEl("br"),t.createEl("div",{text:f("ctrl + click on the floating toc to collapse/expand the header.")}).addClass("callout-content");let a=e.createEl("div",{cls:"floating-toc-tabs"}),l=a.createEl("div",{cls:"floating-toc-tab-header"}),o=a.createEl("div",{cls:"floating-toc-tab-content"}),c=["\u{1F3A2}TOC Display","\u{1F3AE}Interaction","\u{1F3A8}Style Settings"],r={};c.forEach(g=>{let d=l.createEl("div",{cls:"floating-toc-tab"});d.setText(g),d.addEventListener("click",()=>{l.querySelectorAll(".floating-toc-tab").forEach(k=>k.removeClass("active")),o.querySelectorAll(".floating-toc-tab-pane").forEach(k=>k.removeClass("active")),d.addClass("active"),r[g].addClass("active")});let y=o.createEl("div",{cls:"floating-toc-tab-pane"});r[g]=y}),(D=l.querySelector(".floating-toc-tab"))==null||D.addClass("active"),(O=o.querySelector(".floating-toc-tab-pane"))==null||O.addClass("active");let h=r["\u{1F3A2}TOC Display"];h.createEl("h2",{text:f("TOC Display Settings")}),new H.Setting(h).setName(f("Floating TOC position")).setDesc(this.plugin.settings.positionStyle=="both"?f("When the panel is split left and right, the right side of the layout is aligned right and the left side of the panel is aligned left."):this.plugin.settings.positionStyle=="right"?f("Floating TOC position, on the right side of the notes"):f("Floating TOC position, default on the left side of the notes")).addDropdown(g=>{let d={};xe.map(y=>d[y]=y),g.addOptions(d),g.setValue(this.plugin.settings.positionStyle).onChange(y=>{this.plugin.settings.positionStyle=y,this.plugin.saveSettings(),setTimeout(()=>{this.display(),dispatchEvent(new Event("refresh-toc"))},100)})}),this.plugin.settings.positionStyle!="left"&&new H.Setting(h).setName(f("Left alignment of TOC text")).setDesc(f("whether the text in TOC is left aligned")).addToggle(g=>{var d;return g.setValue((d=this.plugin.settings)==null?void 0:d.isLeft).onChange(y=>{this.plugin.settings.isLeft=y,this.plugin.saveSettings(),setTimeout(()=>{this.display(),dispatchEvent(new Event("refresh-toc"))},100)})}),new H.Setting(h).setName(f("Default Hide TOC")).setDesc(f("When enabled, TOC will be hidden by default when plugin starts")).addToggle(g=>{var d;return g.setValue((d=this.plugin.settings)==null?void 0:d.isDefaultHide).onChange(y=>{this.plugin.settings.isDefaultHide=y,this.plugin.saveSettings(),setTimeout(()=>{dispatchEvent(new Event("refresh-toc"))},100)})}),new H.Setting(h).setName(f("Expand All Subheadings Recursively")).setDesc(f("When disabled, only direct subheadings will be expanded")).addToggle(g=>g.setValue(this.plugin.settings.expandAllSubheadings).onChange(d=>{this.plugin.settings.expandAllSubheadings=d,this.plugin.saveSettings(),setTimeout(()=>{dispatchEvent(new Event("refresh-toc"))},100)})),new H.Setting(h).setName(f("Hide heading level")).setDesc(f("Whichever option is selected, the corresponding heading level will be hidden"));let u=new j(h);[1,2,3,4,5,6].forEach(g=>L(this,null,function*(){let y=this.plugin.settings.ignoreHeaders.split(`
`).includes(g.toString());u.addItem(g.toString(),g.toString(),y,k=>{this.plugin.settings.ignoreHeaders=u.checkedList.join(`
`),this.plugin.saveSettings(),setTimeout(()=>{dispatchEvent(new Event("refresh-toc"))},100)})}));let E=r["\u{1F3AE}Interaction"];E.createEl("h2",{text:f("Interaction Settings")}),new H.Setting(E).setName(f("Default Pin")).addToggle(g=>{var d;return g.setValue((d=this.plugin.settings)==null?void 0:d.isDefaultPin).onChange(y=>{this.plugin.settings.isDefaultPin=y,this.plugin.saveSettings(),setTimeout(()=>{dispatchEvent(new Event("refresh-toc"))},100)})}),new H.Setting(E).setName(f("Enable Tooltip")).addToggle(g=>{var d;return g.setValue((d=this.plugin.settings)==null?void 0:d.isTooltip).onChange(y=>{this.plugin.settings.isTooltip=y,this.plugin.saveSettings(),setTimeout(()=>{dispatchEvent(new Event("refresh-toc"))},100)})});let v=r["\u{1F3A8}Style Settings"];v.createEl("h2",{text:f("Style Settings")}),new H.Setting(v).setName(f("Header single line display")).setDesc(f("When enabled, heading text will be displayed in a single line")).addToggle(g=>{var d;return g.setValue((d=this.plugin.settings)==null?void 0:d.enableHeadingNowrap).onChange(y=>{this.plugin.settings.enableHeadingNowrap=y,this.plugin.saveSettings(),setTimeout(()=>{dispatchEvent(new Event("refresh-toc"))},100)})}),new H.Setting(v).setName(f("Indicator bar style")).setDesc(f("Choose the style of the indicator bar")).addDropdown(g=>{g.addOption("default-bar-style","Default").addOption("enable-edge-style","Edge").addOption("enable-bar-icon","Icon").addOption("enable-bold-bar","Bold").addOption("enable-dot-style","Dot").addOption("enable-square-style","Square").addOption("enable-vertical-line-style","Vertical Line").addOption("enable-hollow-line-style","Hollow Line").setValue(this.plugin.settings.barStyle).onChange(d=>{this.plugin.settings.barStyle=d,this.plugin.saveSettings(),setTimeout(()=>{dispatchEvent(new Event("refresh-toc"))},100)})}),new H.Setting(v).setName(f("Show heading text next to indicator bar")).setDesc(f("When enabled, heading text will be shown next to the indicator bar")).addToggle(g=>{var d;return g.setValue((d=this.plugin.settings)==null?void 0:d.enableBarHeadingText).onChange(y=>{this.plugin.settings.enableBarHeadingText=y,this.plugin.saveSettings(),setTimeout(()=>{dispatchEvent(new Event("refresh-toc"))},100)})}),v.createEl("h2",{text:f("More Style Settings")});let m=v.createEl("div");m.addClass("callout"),m.setAttribute("data-callout","warning");let w=m.createEl("div");w.addClass("callout-content"),this.app.plugins.enabledPlugins.has("obsidian-style-settings")?(w.createEl("br"),new H.ButtonComponent(w).setIcon("palette").setClass("mod-cta").setButtonText("\u{1F3A8} Open style settings").onClick(()=>{this.app.setting.open(),this.app.setting.openTabById("obsidian-style-settings"),this.app.workspace.trigger("parse-style-settings"),setTimeout(()=>{var y,k,G;let d=this.app.setting.activeTab.containerEl.querySelector(".setting-item-heading[data-id='floating-toc-styles']");d?(y=d.addClass)==null||y.call(d,"float-cta"):(this.app.workspace.trigger("parse-style-settings"),(G=(k=this.app.setting.activeTab.containerEl.querySelector(".setting-item-heading[data-id='floating-toc-styles']"))==null?void 0:k.addClass)==null||G.call(k,"float-cta"))},250)})):(w.createEl("br"),w.createEl("span",{text:""}).createEl("a",{text:"Please install or enable the style-settings plugin",href:"obsidian://show-plugin?id=obsidian-style-settings"}));let x=e.createEl("div",{cls:"cDonationSection"}),S=createEl("p"),M=createEl("p");M.appendText("If you like this Plugin and are considering donating to support continued development, use the button below!"),S.setAttribute("style","color: var(--text-muted)"),x.appendChild(M),x.appendChild(S),x.appendChild($e("https://github.com/cumany#thank-you-very-much-for-your-support"))}},$e=i=>{let e=createEl("a");return e.setAttribute("href",i),e.addClass("buymeacoffee-img"),e.innerHTML='<img src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee &emoji=&slug=Cuman&button_colour=BD5FFF&font_colour=ffffff&font_family=Poppins&outline_colour=000000&coffee_colour=FFDD00" />',e};function We(i){return i.toLowerCase()}function je(i,e){let t=i.toLowerCase(),n=e.toLowerCase();if(n.includes(t)||We(e).includes(t))return!0;let a=t.split(""),l=n.split(""),o=0;for(let c=0;c<l.length&&o<a.length;c++)l[c]===a[o]&&o++;return o===a.length}var Y=class{constructor(e){this.searchInput=null;this.searchContainer=null;this.plugin=e,this.state={isActive:!1,query:"",results:[],currentIndex:-1,searchTimeout:null}}initSearch(e){this.createSearchInput(e),this.setupKeyboardListeners(e)}createSearchInput(e){this.searchContainer=e.createEl("div",{cls:"floating-toc-search-container"}),this.searchInput=this.searchContainer.createEl("input",{type:"text",placeholder:f("Search title... "),cls:"floating-toc-search-input"});let t=this.searchContainer.createEl("button",{cls:"floating-toc-search-close"});t.innerHTML="\xD7",t.setAttribute("aria-label",f("Close search")),t.addEventListener("click",()=>{this.hideSearch()}),this.searchContainer.style.display="none",this.searchInput.addEventListener("input",n=>{let s=n.target;this.handleSearchInput(s.value)}),this.searchInput.addEventListener("keydown",n=>{n.key==="Enter"?(n.preventDefault(),this.selectCurrentResult()):n.key==="Escape"&&(n.preventDefault(),this.hideSearch())})}setupKeyboardListeners(e){document.addEventListener("keydown",t=>{if(!!this.state.isActive)switch(t.key){case"Tab":t.preventDefault(),this.navigateResults(1);break;case"ArrowUp":t.preventDefault(),this.navigateResults(-1);break;case"ArrowDown":t.preventDefault(),this.navigateResults(1);break;case"Enter":t.preventDefault(),this.selectCurrentResult();break;case"Escape":t.preventDefault(),this.hideSearch();break}})}startSearch(e){this.state.isActive=!0,this.state.query=e,this.state.currentIndex=-1,this.searchInput&&(this.searchInput.value=e,this.searchInput.style.display="block",this.searchInput.focus(),this.searchInput.select()),this.searchContainer&&(this.searchContainer.style.display="flex"),this.performSearch()}startSearchFromButton(){this.state.isActive=!0,this.state.query="",this.state.currentIndex=-1,this.searchContainer&&(this.searchContainer.style.display="flex"),this.searchInput&&(this.searchInput.value="",this.searchInput.style.display="block",setTimeout(()=>{this.searchInput.focus(),this.searchInput.select()},10));let e=document.querySelector(".floating-toc-div");e&&(e.classList.contains("pin")?e.addClass("searchonly"):(e.addClass("pin"),e.addClass("search"))),this.performSearch()}handleSearchInput(e){this.state.query=e,this.state.searchTimeout&&clearTimeout(this.state.searchTimeout),this.state.searchTimeout=window.setTimeout(()=>{this.performSearch()},100)}performSearch(){let e=document.querySelector(".floating-toc-div");if(!e)return;let t=e.querySelectorAll(".heading-list-item");if(this.state.results=[],t.forEach(n=>{n.classList.remove("search-highlight","search-current")}),!this.state.query.trim()){this.state.currentIndex=-1,this.updateResultCount(0);return}if(t.forEach(n=>{let s=n.querySelector(".text");if(s){let a=s.textContent||"";je(this.state.query,a)&&(this.state.results.push(n),n.classList.add("search-highlight"))}}),this.updateResultCount(this.state.results.length),this.state.results.length>0){this.state.currentIndex=0;let n=this.state.results[0];n.classList.add("search-current"),this.scrollToResult(n)}}updateResultCount(e){this.searchContainer&&this.searchContainer.setAttribute("data-result-count",`${e} results`)}navigateResults(e){if(this.state.results.length!==0&&(this.state.currentIndex>=0&&this.state.currentIndex<this.state.results.length&&this.state.results[this.state.currentIndex].classList.remove("search-current"),this.state.currentIndex+=e,this.state.currentIndex<0?this.state.currentIndex=this.state.results.length-1:this.state.currentIndex>=this.state.results.length&&(this.state.currentIndex=0),this.state.currentIndex>=0&&this.state.currentIndex<this.state.results.length)){let t=this.state.results[this.state.currentIndex];t.classList.add("search-current"),this.scrollToResult(t)}}scrollToResult(e){let t=document.querySelector(".floating-toc-div");if(!t)return;let n=t.querySelector(".floating-toc");if(!n)return;let s=e.offsetTop,a=e.offsetHeight,l=n.clientHeight,o=s-(l/2-a/2);n.scrollTo({top:Math.max(0,o),behavior:"smooth"})}selectCurrentResult(){if(this.state.currentIndex>=0&&this.state.currentIndex<this.state.results.length){let t=this.state.results[this.state.currentIndex].querySelector(".text");t&&t.click()}this.hideSearch()}hideSearch(){this.state.isActive=!1,this.state.query="",this.state.currentIndex=-1;let e=document.querySelector(".floating-toc-div");e&&(e.querySelectorAll(".heading-list-item").forEach(n=>{n.classList.remove("search-highlight","search-current")}),e.classList.contains("searchonly")?e.removeClass("searchonly"):(e.classList.contains("pin")&&e.classList.contains("search")&&e.removeClass("pin"),e.removeClass("search"))),this.searchContainer&&(this.searchContainer.style.display="none"),this.state.searchTimeout&&(clearTimeout(this.state.searchTimeout),this.state.searchTimeout=null)}isSearchActive(){return this.state.isActive}getSearchState(){return z({},this.state)}};var A;function F(){(0,C.requireApiVersion)("0.15.0")?A=activeWindow.document:A=window.document,A.querySelectorAll(".floating-toc-div").forEach(e=>{e&&e.remove()})}function He(i,e){var h,b;(0,C.requireApiVersion)("0.15.0")?A=activeWindow.document:A=window.document;let t=(h=e.contentEl)==null?void 0:h.querySelector(".floating-toc-div");if(!t)return!1;let n=t.querySelector(".toolbar");n||(n=t.createEl("div"),W(i,n,t));let s=t.querySelector("ul.floating-toc");s||(s=t.createEl("ul"),s.addClass("floating-toc"));let a=i.headingdata;if(i.settings.ignoreHeaders){let u=new Set(i.settings.ignoreHeaders.split(`
`));a=(b=i.headingdata)==null?void 0:b.filter(p=>!u.has(p.level.toString()))}if(!a)return s.remove(),!1;a&&a.length>0&&i.updateTocWidth(t,a);let l=new Map;(t==null?void 0:t.querySelectorAll("li.heading-list-item")).forEach(u=>{let p=`${u.getAttribute("data-level")}-${u.getAttribute("data-line")}-${u.children[0].innerText}`;l.set(p,u)});let c=A.createDocumentFragment(),r=new Set(l.values());return a.forEach((u,p)=>{let E=`${u.level}-${u.position.start.line}-${u.heading}`,v=l.get(E);v?(r.delete(v),P(p,i.headingdata)?v.hasAttribute("iscollapsed")||v.setAttribute("isCollapsed","false"):v.hasAttribute("iscollapsed")&&v.removeAttribute("isCollapsed"),c.appendChild(v)):B(i,e,c,u,p)}),r.forEach(u=>u.remove()),s.replaceChildren(c),!0}function Ue(i){let e=[];if(i==null?void 0:i.previousElementSibling)for(;i=i.previousElementSibling;)i.nodeType==1&&e.push(i);return e}function Ye(i,e,t){var s,a,l;let n=t.target;if(((s=n.parentElement)==null?void 0:s.classList.contains("cm-editor"))||((a=n.parentElement)==null?void 0:a.classList.contains("markdown-reading-view"))){let o=i.workspace.getActiveViewOfType(C.MarkdownView);if(!o)return;let c=(l=o.currentMode.getScroll())!=null?l:0,r=e.headingdata;if(!r||r.length===0)return;let h=o.contentEl.querySelector(".floating-toc");if(!h)return;let b=h.querySelectorAll("li.heading-list-item");if(!b.length)return;let u=b[0],p=b[b.length-1],E=parseInt(u.getAttribute("data-line")||"0"),v=parseInt(p.getAttribute("data-line")||"0"),m=0,w=null;if(c<=0)m=E;else{let g=0,d=r.length-1,y=-1;for(;g<=d;){let k=Math.floor((g+d)/2);r[k].position.start.line<=c?(y=k,g=k+1):d=k-1}y!==-1?(m=r[y].position.start.line,w=r[y]):m=E}let I=h.querySelector(".heading-list-item.located");I&&I.removeClass("located");let x=h.querySelector(`li[data-line='${m}']`);if(!x)return;x.addClass("located");let S=parseInt(x.getAttribute("data-level")||"1"),M=S>1?S-1:1,D=h.querySelector("li.focus");D&&D.removeClass("focus");let O=Ue(x);for(let g=0;g<O.length;g++){let d=O[g];if(d.dataset.level<=M.toString()){d.addClass("focus");break}}requestAnimationFrame(()=>{x.scrollIntoView({block:"nearest",behavior:"smooth"})})}}var K=class extends C.Plugin{constructor(){super(...arguments);this.isUpdating=!1;this.lastRefreshTime=0;this.REFRESH_COOLDOWN=200;this.currentFile=null;this.BAR_STYLE_CLASSES=["enable-bar-heading-text","enable-heading-nowrap","pin","hide","default-bar-style","enable-edge-style","enable-bar-icon","enable-bold-bar","enable-dot-style","enable-square-style","enable-vertical-line-style","enable-hollow-line-style"];this.updateTocWidth=(0,C.debounce)((e,t)=>{let n=t.reduce((a,l)=>{let c=l.heading.split("").reduce((r,h)=>r+(/[\u4e00-\u9fa5]/.test(h)?1:.6),0);return Math.max(a,c)},0),s=Math.ceil(n)+"rem";A.body.style.setProperty("--actual-toc-width",`${s}`)},100);this.handleScroll=(e,t,n)=>(0,C.debounce)(Ye(e,t,n),100)}onload(){return L(this,null,function*(){(0,C.requireApiVersion)("0.15.0")?A=activeWindow.document:A=window.document,yield this.loadSettings(),this.search=new Y(this);let e=n=>{n&&(He(this,n)||_(this.app,this))};this.addCommand({id:"pin-toc-panel",name:"Pinning the Floating TOC panel",icon:"pin",callback:()=>L(this,null,function*(){let n=this.app.workspace.getActiveViewOfType(C.MarkdownView);if(n){let s=n.contentEl.querySelector(".floating-toc-div");s&&(s.classList.contains("pin")?s.removeClass("pin"):s.addClass("pin"))}})}),this.addCommand({id:"hide-toc-panel",name:"Hide/Show the Floating TOC panel",icon:"list",callback:()=>L(this,null,function*(){let n=this.app.workspace.getActiveViewOfType(C.MarkdownView);if(n){let s=n.contentEl.querySelector(".floating-toc-div");s&&(s.classList.contains("hide")?s.removeClass("hide"):s.addClass("hide"))}})}),this.addCommand({id:"scroll-to-bottom",name:"Scroll to Bottom",icon:"double-down-arrow-glyph",callback:()=>L(this,null,function*(){let n=this.app.workspace.getActiveViewOfType(C.MarkdownView);if(n){let s=this.app.workspace.getActiveFile(),l=(yield this.app.vault.cachedRead(s)).split(`
`),o=l.length;if(n.getMode()==="preview")for(;o>0&&l[o-1].trim()==="";)o--;n.currentMode.applyScroll(o-1)}})}),this.addCommand({id:"scroll-to-top",name:"Scroll to Top",icon:"double-up-arrow-glyph",callback:()=>L(this,null,function*(){let n=this.app.workspace.getActiveViewOfType(C.MarkdownView);n&&n.setEphemeralState({scroll:0})})}),this.addCommand({id:"toggle-position-style",name:"Toggle Floating TOC Position (left/right)",icon:"switch",callback:()=>{this.settings.positionStyle==="left"?this.settings.positionStyle="right":this.settings.positionStyle==="right"?this.settings.positionStyle="left":this.settings.positionStyle==="both"&&new C.Notice("Position style set to both. Toogle position only works when fixed position (left or right) is selected."),this.saveSettings(),dispatchEvent(new Event("refresh-toc"))}}),this.addCommand({id:"search-in-toc",name:"Search in Floating TOC",icon:"search",hotkeys:[{modifiers:["Alt"],key:"F"}],callback:()=>{this.search&&this.search.startSearchFromButton()}}),this.registerEvent(this.app.workspace.on("active-leaf-change",()=>{var o,c,r,h;let n=this.app.workspace.getActiveViewOfType(C.MarkdownView);if(!n)return;let s=(o=n.file)==null?void 0:o.path;if(s===this.currentFile)return;this.currentFile=s;let a=this.app.workspace.getActiveFile();if(!a||!((r=(c=this.app.metadataCache.getFileCache(a))==null?void 0:c.headings)==null?void 0:r.length)){this.headingdata=null,F();return}let l=(h=this.app.metadataCache.getFileCache(a))==null?void 0:h.headings;if(!!l){if(this.headingdata=l,this.settings.ignoreHeaders){let b=this.settings.ignoreHeaders.split(`
`);this.headingdata=l.filter(u=>!b.includes(u.level.toString()))}t(n,!0)}})),this.registerEvent(this.app.metadataCache.on("changed",()=>{var r,h;let n=this.app.workspace.getActiveViewOfType(C.MarkdownView);if(!n||((r=n.file)==null?void 0:r.path)!==this.currentFile)return;let s=n.file,a=(h=this.app.metadataCache.getFileCache(s))==null?void 0:h.headings;if(!(a==null?void 0:a.length)){this.headingdata=null,F();return}let l=a.map(b=>V(z({},b),{heading:this.removeMarkdownSyntax(b.heading)})),o=this.headingdata?this.headingdata.map(b=>V(z({},b),{heading:this.removeMarkdownSyntax(b.heading)})):null;if(this.hasStructuralHeadingChanges(l,o)){if(this.headingdata=a,this.settings.ignoreHeaders){let b=this.settings.ignoreHeaders.split(`
`);this.headingdata=a.filter(u=>!b.includes(u.level.toString()))}t(n,!0)}else this.updateOutlineLineNumbers(n,a)}));let t=(n,s=!1)=>{let a=Date.now();!s&&a-this.lastRefreshTime<this.REFRESH_COOLDOWN||(this.lastRefreshTime=a,e(n))};A.addEventListener("scroll",n=>{this.handleScroll(this.app,this,n)},!0),this.addSettingTab(new U(this.app,this)),e(this.app.workspace.getActiveViewOfType(C.MarkdownView)),this.app.workspace.on("window-open",n=>{console.log("window-open"),n.doc.addEventListener("scroll",s=>{this.handleScroll(this.app,this,s)},!0)}),this.app.workspace.onLayoutReady(()=>{this.app.workspace.trigger("parse-style-settings")})})}removeMarkdownSyntax(e){if(!e)return"";let t=e;return t=t.replace(/\*\*(.*?)\*\*/g,"$1").replace(/__(.*?)__/g,"$1").replace(/\*(.*?)\*/g,"$1").replace(/_(.*?)_/g,"$1"),t=t.replace(/`([^`]+)`/g,"$1").replace(/~~(.*?)~~/g,"$1"),t=t.replace(/==(.*?)==/g,"$1"),t=t.replace(/\[(.*?)\]\([^\)]+\)/g,"$1").replace(/\[\[(.*?)(\|.*?)?\]\]/g,"$1"),t=t.replace(/<[^>]+>/g,""),t=t.replace(/^#+\s+/,""),t.trim()}hasHeadingsChanged(e,t){if(!t||e.length!==t.length)return!0;let n=a=>`${a.heading}|${a.level}|${a.position.start.line}`;return!e.every((a,l)=>{let o=t[l],c=n(a),r=n(o);return c===r})}updateOutlineLineNumbers(e,t){var l;let n=(l=e.contentEl)==null?void 0:l.querySelector(".floating-toc-div");if(!n)return;let s=n.querySelectorAll("li.heading-list-item");if(!s.length)return;let a=new Map;t.forEach(o=>{let c=`${this.removeMarkdownSyntax(o.heading)}|${o.level}`;a.set(c,o.position.start.line)}),s.forEach(o=>{let c=o.getAttribute("data-level"),r=o.querySelector(".text-wrap a.text");if(!r)return;let b=`${r.innerText}|${c}`;if(a.has(b)){let u=a.get(b);o.getAttribute("data-line")!==u.toString()&&o.setAttribute("data-line",u.toString())}})}hasStructuralHeadingChanges(e,t){if(!t||e.length!==t.length)return!0;let n=s=>`${this.removeMarkdownSyntax(s.heading)}|${s.level}`;return e.some((s,a)=>{let l=t[a];return n(s)!==n(l)})}onunload(){var e;(0,C.requireApiVersion)("0.15.0")?A=activeWindow.document:A=window.document;try{A.removeEventListener("scroll",t=>{this.handleScroll(this.app,this,t)},!0)}catch(t){console.error("Error removing scroll event listener:",t)}try{let t=this.app.workspace.getActiveViewOfType(C.MarkdownView);if(t){let n=(e=t.contentEl)==null?void 0:e.querySelector(".floating-toc-div");n&&(n.querySelectorAll("li.heading-list-item").forEach(a=>{let l=a.cloneNode(!0);a.parentNode&&a.parentNode.replaceChild(l,a)}),n._tocCleanup&&n._tocCleanup())}}catch(t){console.error("Error cleaning up resources:",t)}F()}setHeadingdata(e){this.headingdata=e}loadSettings(){return L(this,null,function*(){this.settings=Object.assign({},Le,yield this.loadData())})}saveSettings(){return L(this,null,function*(){yield this.saveData(this.settings)})}};
/* nosourcemap */