var se=Object.defineProperty;var Re=Object.getOwnPropertyDescriptor;var Ie=Object.getOwnPropertyNames;var Ae=Object.prototype.hasOwnProperty;var Fe=(a,r)=>{for(var e in r)se(a,e,{get:r[e],enumerable:!0})},Ve=(a,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of Ie(r))!Ae.call(a,o)&&o!==e&&se(a,o,{get:()=>r[o],enumerable:!(t=Re(r,o))||t.enumerable});return a};var De=a=>Ve(se({},"__esModule",{value:!0}),a);var Ke={};Fe(Ke,{default:()=>ne,leafName:()=>b,splitName:()=>ae});module.exports=De(Ke);var C=require("obsidian");var E=typeof queueMicrotask=="function"?queueMicrotask:(a=>r=>a.then(r))(Promise.resolve());function ce(a){return a&&typeof a=="object"?JSON.parse(JSON.stringify(a)):a}function M(a,r,e){let t=a.classList.contains(r);return e=e!=null?e:!t,e!==t&&(e?a.classList.add(r):a.classList.remove(r)),e}var f;(a=>Object.assign(a,require("obsidian")))(f||(f={}));var le="use.me",pe="use.factory",O,j,de=function(){return Object.defineProperties(a(),{this:{get(){if(O)return O;throw new TypeError("No current context")}},me:{value:le},factory:{value:pe}});function a(o){let i=new Map;i.prev=o;let n=Object.assign(o?c=>{let l=i.get(c);if(!l){for(let y=i.prev;y;y=y.prev)if(l=y.get(c)){l=Object.assign(Object.assign({},l),{s:l.s||1});break}l=l||{s:2,v:e},i.set(c,l)}let u,h,m;for(;;)switch(l.s){case 0:return O===n&&j&&j.push(c),l.v;case 1:if(u=l.d,!u||s(()=>u.k.every(y=>n(y)===u.c(y)))){l.s=0;break}l.v=u.f;case 2:l.s=4;try{r(i,c,0,s(h=l.v,c,m=[])),m.length&&(l.d={c:n,f:h,k:m});break}catch(y){l.s=3,l.v=y,l.d=null}case 3:throw l.v;case 4:throw new Error(`Factory ${String(l.v)} didn't resolve ${String(c)}`)}}:c=>de.this(c),{def(c,l){return r(i,c,2,l),n},set(c,l){return r(i,c,1,l),n},fork(c){let l=a(i);return c!=null?l(c):l}});return o?n.use=n:n;function s(c,l,u){let h=O,m=j;try{return O=n,j=u,c(l)}finally{O=h,j=m}}}function r(o,i,n,s){if(o.has(i)){let c=o.get(i);if(!c.s)throw new Error(`Already read: ${String(i)}`);c.s=n,c.v=s,c.d=null}else o.set(i,{s:n,v:s})}function e(o){if(typeof o[le]=="function")return o[le](o);if(t(o))return typeof o.prototype[pe]=="function"?o.prototype[pe]():new o;throw new ReferenceError(`No config for ${String(o)}`)}function t(o){return typeof o=="function"&&o.prototype!==void 0&&(Object.getPrototypeOf(o.prototype)!==Object.prototype||Object.getOwnPropertyNames(o.prototype).length>1||o.toString().startsWith("class"))}}();var Ne,V=(a=>(a.service=function(r){return a(G).addChild(r),a.this},a.plugin=function(r){if(!F)Ne=r.app,F=a.fork(),F.set(f.Plugin,r),F.set(r.constructor,r),r.addChild(F.use(G));else if(r!==F.use(f.Plugin))throw new TypeError("use.plugin() called on multiple plugins");return F},a.def(f.Plugin,()=>{throw new Error("Plugin not created yet")}),a.def(f.App,()=>a(f.Plugin).app),a))(de),F;var k=class extends f.Component{constructor(){super(...arguments);this.use=V.service(this)}},G=class extends f.Component{constructor(){super(...arguments);this.children=new Set([this])}onload(){this.loaded=!0}onunload(){this.loaded=!1,this.children.clear()}addChild(e){return this.children.has(e)||(this.children.add(e),this.loaded?E(()=>super.addChild(e)):super.addChild(e)),e}};function Q(a,r){E(()=>a.removeChild(r))}function ye(a,r){let e=new f.Component;e.onload=()=>{Q(a,e),a=null,r()},a.addChild(e)}function d(a,r){let e=Object.keys(r).map(t=>Oe(a,t,r[t]));return e.length===1?e[0]:function(){e.forEach(t=>t())}}function Oe(a,r,e){let t=a[r],o=a.hasOwnProperty(r),i=e(t);return t&&Object.setPrototypeOf(i,t),Object.setPrototypeOf(n,i),a[r]=n,s;function n(...c){return i===t&&a[r]===n&&s(),i.apply(this,c)}function s(){a[r]===n&&(o?a[r]=t:delete a[r]),i!==t&&(i=t,Object.setPrototypeOf(n,t||Function))}}function X(a,r,e){return t[a]=a,t;function t(...o){return(r[a]===a?r:e).apply(this,o)}}function _(a){let r=app.workspace;switch(a==null?void 0:a.getRoot()){case r.rootSplit:case r.floatingSplit:case r.leftSplit:case r.rightSplit:return!0;default:return!1}}function D(a,r){if(!a)return!1;if(typeof a=="function"&&(r=a,a=app.workspace),r(a))return!0;if(a instanceof f.Workspace)return D(a.rootSplit,r)||D(a.floatingSplit,r)||D(a.leftSplit,r)||D(a.rightSplit,r);if(a instanceof f.WorkspaceParent){for(let e of a.children)if(D(e,r))return!0}return!1}var W=class{constructor(r,e,t,o){this.key=e;this.defaultValue=t;this.owner=o;this.store=r.use(J)}of(r){return new W(this.store,this.key,this.defaultValue,r)}get(r=this.owner){return this.store.get(this.requires(r),this.key,this.defaultValue)}set(r,e=this.owner){this.store.set(this.requires(e),this.key,r)}unset(r=this.owner){this.store.unset(this.requires(r),this.key)}requires(r){if(r&&(r instanceof f.Workspace||r instanceof f.WorkspaceItem))return r;throw new TypeError("Setting method requires a workspace or workspace item")}onSet(r,e){return this.owner?this.store.onSet(this.key,(t,o,i)=>{t===this.owner&&r.call(e,o,i)}):this.store.onSet(this.key,r,e)}onLoadWorkspace(r,e){return this.store.onLoadWorkspace(r,e)}offref(r){this.store.offref(r)}},J=class extends k{constructor(){super(...arguments);this.loading=!1}get(e,t,o){var i,n;return(n=(i=e==null?void 0:e[x])==null?void 0:i[t])!=null?n:o}set(e,t,o){let i=e[x]||(e[x]={}),n=i[t];i[t]=o,!this.loading&&n!==o&&(app.workspace.trigger(ke+t,e,o,n),app.workspace.requestSaveLayout())}unset(e,t){let o=e[x];o!=null&&o.hasOwnProperty(t)&&(delete o[t],this.loading||app.workspace.requestSaveLayout())}onSet(e,t,o){return app.workspace.on(ke+e,t,o)}onLoadItem(e,t){return!this.loading&&app.workspace.layoutReady&&E(()=>{D(o=>{try{e.call(t,o)}catch(i){console.error(i)}})}),app.workspace.on(N,e,t)}onSaveItem(e,t){return app.workspace.on(Le,e,t)}onLoadWorkspace(e,t){return!this.loading&&app.workspace.layoutReady&&E(()=>{try{e.call(t)}catch(o){console.error(o)}}),app.workspace.on(N+":workspace",e,t)}offref(e){app.workspace.offref(e)}onload(){let e=app.workspace;this.registerEvent(e.on(N+":start",()=>this.loading=!0)),this.registerEvent(e.on(N+":workspace",()=>this.loading=!1)),this.register(d(f.WorkspaceItem.prototype,{serialize:ve})),this.register(d(app.workspace,{getLayout:ve,setLayout(t){return X(ue,t,async function(i,...n){e.trigger(N+":start");try{return be(this,i),await t.call(this,i,...n)}finally{e.trigger(N+":workspace")}})},deserializeLayout(t){return X(ue,t,async function(i,...n){let s=await t.call(this,i,...n);return be(s,i),s})}}))}},fe=2,ue=Symbol.for(`v${fe}.layout-storage-events.ophidian.peak-dev.org`),x="ophidian:layout-settings",N=`ophidian-layout-storage:v${fe}:item-load`,Le=`ophidian-layout-storage:v${fe}:item-save`,ke="ophidian-layout-storage:set:";function ve(a){return X(ue,a,function(){let e=a.call(this);return app.workspace.trigger(Le,this,e),this[x]&&(e[x]=ce(this[x])),e})}function be(a,r){if(!a)return;let e=r==null?void 0:r[x];e&&(a[x]=ce(e)),app.workspace.trigger(N,a,r)}var z=class extends f.Component{constructor(e,t){super();this.use=e;this.container=t;this.win=this.container.win}[V.factory](){return new Y(this.constructor)}static onload(e){}static onunload(e){}},Y=class extends k{constructor(e){super();this.factory=e;this.instances=new Map;this.watching=!1;this.layoutReadyCallbacks=[]}onload(){var e,t;this.registerEvent(app.workspace.on("layout-change",()=>{app.workspace.layoutReady&&this.layoutReadyCallbacks.length&&(this.layoutReadyCallbacks.forEach(E),this.layoutReadyCallbacks=[])})),(t=(e=this.factory).onload)==null||t.call(e,this.use)}onLeafChange(e,t){return this.onLayoutReady(()=>e.call(t,app.workspace.activeLeaf)),app.workspace.on("active-leaf-change",o=>{app.workspace.layoutReady&&e.call(t,o)})}onLayoutReady(e){app.workspace.layoutReady?E(e):this.layoutReadyCallbacks.push(e)}onunload(){var e,t;(t=(e=this.factory).onunload)==null||t.call(e,this.use)}watch(){if(!this._loaded)ye(this,()=>this.watch());else if(!this.watching){let{workspace:e}=app,t=this;this.watching=!0,this.registerEvent(e.on("window-open",o=>{this.onLayoutReady(()=>this.forContainer(o))})),this.register(d(e,{clearLayout(o){return async function(){try{return await o.call(this)}finally{t.onLayoutReady(()=>t.forAll())}}}})),this.onLayoutReady(()=>this.forAll())}return this}forWindow(e=(o=>(o=window.activeWindow)!=null?o:window)(),t=!0){let i=Be(e);if(i)return this.forContainer(i,t)}forContainer(e,t=!0){e=e.getContainer();let o=this.instances.get(e);return!o&&t&&(o=new this.factory(this.use,e),o&&(this.instances.set(e,o),this.addChild(o),e.component.addChild(o),o.register(()=>{Q(this,o),Q(e.component,o),this.instances.delete(e)}))),o}forDom(e,t=!0){return this.forWindow(ze(e),t)}forLeaf(e=app.workspace.activeLeaf,t=!0){if(_(e))return this.forContainer(e.getContainer(),t)}forView(e,t=!0){return this.forLeaf(e.leaf,t)}forAll(e=!0){return Se().map(t=>this.forContainer(t,e)).filter(t=>t)}};function Se(){return[app.workspace.rootSplit].concat(app.workspace.floatingSplit.children)}function Ee(){return Se().map(a=>a.win)}function L(){var a,r;return 1+((r=(a=app.workspace.floatingSplit)==null?void 0:a.children.length)!=null?r:0)}function ze(a){return a.win||(a.ownerDocument||a).defaultView||window}function Be(a){if(a===window)return app.workspace.rootSplit;let{floatingSplit:r}=app.workspace;if(r){for(let e of r.children)if(a===e.win)return e}}var Z=class extends k{onload(){let r=this,e=this.use(f.Plugin);this.register(d(e,{loadCSS(t){return async function(){await t.call(this),r.triggerReparse(),this.register(()=>r.triggerReparse())}}}))}triggerReparse(){app.workspace.layoutReady&&app.workspace.trigger("parse-style-settings")}};var Ce={};function xe(a,r,e=[],t={}){typeof e=="string"&&(e=[e]),typeof e=="object"&&e.key&&(e=[e]);let o=e.map(function(n){if(typeof n=="object")return n;let s=n.split("+");return{modifiers:s,key:s.pop()||"+"}});Object.assign(t,{id:a,name:r,hotkeys:o});let i=Symbol("cmd:"+a);return Ce[i]=t,i}function Pe(a,r=a.constructor.prototype){Object.getOwnPropertySymbols(r).forEach(e=>{let t=Ce[e],o=r[e];t&&a.addCommand(Object.assign({},t,{checkCallback(i){let n=o.call(a);return i||typeof n!="function"?!!n:(n(),!0)}}))})}var Te={};function p(a,r,e=[],t={}){typeof e=="string"&&(e=[e]),typeof e=="object"&&e.key&&(e=[e]);let o=e.map(function(n){if(typeof n=="object")return n;let s=n.split("+");return{modifiers:s,key:s.pop()||"+"}});Object.assign(t,{id:a,name:r,hotkeys:o});let i=Symbol("cmd:"+a);return Te[i]=t,i}function ee(a,r=a.constructor.prototype){Object.getOwnPropertySymbols(r).forEach(e=>{let t=Te[e],o=r[e];t&&a.addCommand(Object.assign({},t,{checkCallback(i){let n=o.call(a);return i||typeof n!="function"?!!n:(n(),!0)}}))})}var I=require("obsidian");var g=require("obsidian");var v=require("obsidian");var te="pane-relief:history-v1",he="pane-relief:history-v1",me=new WeakMap,B=class{constructor(r){this.setState(r)}static fromNative(r){return new this({...r,state:JSON.stringify(r.state),eState:JSON.stringify(r.eState)})}get asNative(){let r={...this.raw,state:this.viewState,eState:this.eState};if(!r.title||!r.icon){let e=oe(this);r.title||(r.title=e.title||""),r.icon||(r.icon=e.icon||"")}return r}get viewState(){return JSON.parse(this.raw.state||"{}")}setState(r){var e;this.raw=r,this.eState=JSON.parse(r.eState||"null"),this.path=(e=this.viewState.state)==null?void 0:e.file}onRename(r,e){if(this.path===e){let t=this.viewState;this.path=t.state.file=r.path,this.raw.state=JSON.stringify(t)}}go(r){let{viewState:e,path:t,eState:o}=this,i=t&&(app==null?void 0:app.vault.getAbstractFileByPath(t));t&&!i&&(new v.Notice("Missing file: "+t),e={type:"empty",state:{}},o=void 0),r.setViewState({...e,active:!0,popstate:!0},o)}isEmpty(){return JSON.parse(this.raw.state||"{}").type==="empty"}replaceState(r){var e;if(r.state!==this.raw.state){let t=JSON.parse(r.state||"{}");if(t.type==="empty")return!0;if(this.path&&this.path!==((e=t==null?void 0:t.state)==null?void 0:e.file))return!1;if(t.type==="media-view"){let o=JSON.stringify(this.viewState.state.info),i=JSON.stringify(t.state.info);if(o!==i)return!1}}return this.setState(r),!0}},w=class{constructor(r,{pos:e,stack:t}={pos:0,stack:[]}){this.leaf=r;r&&(r[te]=this),this.leaf=r,this.pos=e,this.stack=t.map(o=>new B(o))}static current(){return this.forLeaf(app.workspace.activeLeaf)||new this}static forLeaf(r){if(r&&me.set(r.containerEl,r),r){let e=r[te];if(e instanceof this)return e;if(e&&!e.hadTabs){let t=(e==null?void 0:e.serialize())||void 0;return new this(r,t).saveToNative()}return new this(r).loadFromNative()}}saveToNative(){var t;let r=(t=this.leaf)==null?void 0:t.history;if(!r)return this;let e=this.stack.map(o=>o.asNative);return r.deserialize({backHistory:e.slice(this.pos+1).reverse(),forwardHistory:e.slice(0,this.pos)}),this}loadFromNative(){var t;let r=(t=this.leaf)==null?void 0:t.history;if(!r)return this;let e=[].concat(r.forwardHistory.slice().filter(o=>o),{state:{},eState:{}},r.backHistory.slice().filter(o=>o).reverse());return this.stack=e.map(o=>B.fromNative(o)),this.pos=r.forwardHistory.length,this}cloneTo(r){return new w(r,this.serialize()).saveToNative()}onRename(r,e){for(let t of this.stack)t.onRename(r,e)}serialize(){return{pos:this.pos,stack:this.stack.map(r=>r.raw)}}get state(){var r;return((r=this.stack[this.pos])==null?void 0:r.raw)||null}get length(){return this.stack.length}back(){this.go(-1)}forward(){this.go(1)}lookAhead(){return this.stack.slice(0,this.pos).reverse()}lookBehind(){return this.stack.slice(this.pos+1)}announce(){var r;(r=app==null?void 0:app.workspace)==null||r.trigger("pane-relief:update-history",this.leaf,this)}goto(r){var e;if(this.leaf){if(this.leaf.pinned)return new v.Notice(`Pinned ${b}: unpin before going forward or back`),void 0;if(this.leaf.working)return new v.Notice("Pane is busy: please wait before navigating further"),void 0;r=this.pos=Math.max(0,Math.min(r,this.stack.length-1)),(e=this.stack[r])==null||e.go(this.leaf),this.announce()}}go(r,e){if(!this.leaf||!r)return;let t=Math.max(0,Math.min(this.pos-r,this.stack.length-1));e||t!==this.pos?this.leaf.history?(this.pos=t,this.leaf.history.go(r)):this.goto(t):new v.Notice(`No more ${r<0?"back":"forward"} history for ${b}`)}replaceState(r,e,t){let o=this.stack[this.pos];o?o.replaceState(r)||this.pushState(r,e,t):this.stack[this.pos]=new B(r)}pushState(r,e,t){let o=this.stack[this.pos];if(o&&o.isEmpty())return this.replaceState(r,e,t);for(this.stack.splice(0,this.pos,new B(r)),this.pos=0;this.stack.length>20;)this.stack.pop();this.announce()}},q=class extends k{constructor(){super(...arguments);this.lastButtonActivity=0}onload(){let e=this.use(J);this.registerEvent(e.onSaveItem((o,i)=>{o instanceof v.WorkspaceLeaf&&o[te]&&(i[he]=o[te].serialize())})),this.registerEvent(e.onLoadItem((o,i)=>{o instanceof v.WorkspaceLeaf&&i&&i[he]&&new w(o,i[he]).saveToNative()}));let t=this;if(v.Platform.isLinux&&v.Platform.isDesktopApp){let o=function(i){return(0,v.debounce)(function(){Date.now()-t.lastButtonActivity<50||i.call(this)},10)};this.register(d(window.history,{forward:o,back:o}))}this.register(d(v.WorkspaceLeaf.prototype,{trigger(o){return function(n,...s){if(n==="history-change"){let c=w.forLeaf(this);c.loadFromNative(),app.workspace.trigger("pane-relief:update-history",this,c)}return o.call(this,n,...s)}}})),app.workspace.onLayoutReady(()=>app.workspace.iterateAllLeaves(o=>{o.trigger("history-change")}))}onHistoryButtonActivity(){this.lastButtonActivity=Date.now()}};var qe=(0,g.debounce)(()=>{var a;app.vault.getConfig("theme")==="system"&&((a=app.adaptToSystemTheme)==null||a.call(app))},200,!0),$e={markdown:"document",image:"image-file",audio:"audio-file",video:"audio-file",pdf:"pdf-file",localgraph:"dot-network",outline:"bullet-list",backlink:"link",kanban:"blocks",excalidraw:"excalidraw-icon","media-view":"audio-file"},Me={graph:["dot-network","Graph View"],"file-explorer":["folder","File Explorer"],starred:["star","Starred Files"],tag:["tag","Tags View"],"recent-files":["clock","Recent Files"],calendar:["calendar-with-checkmark","Calendar"],empty:["cross","No file"]},$=class extends z{constructor(){super(...arguments);this.historyIsOpen=!1}display(e=this.latestLeaf()){if(!this.historyIsOpen){if(!this._loaded){this.load();return}this.win.requestAnimationFrame(()=>{let t=e?w.forLeaf(e):new w;this.back.setHistory(t),this.forward.setHistory(t),e&&this.updateLeaf(e,t)})}}leaves(){var i;let e=new Set,t=n=>{e.add(n)};app.workspace.iterateLeaves(t,this.container);let o=(i=app.plugins.plugins["obsidian-hover-editor"])==null?void 0:i.activePopovers;if(o)for(let n of o)n.hoverEl.ownerDocument.defaultView===this.win&&(n.rootSplit?app.workspace.iterateLeaves(t,n.rootSplit):n.leaf&&t(n.leaf));return[...e.values()]}latestLeaf(){let e=app.workspace.activeLeaf;return e&&this.use($).forLeaf(e)===this?e:this.leaves().reduce((t,o)=>!t||t.activeTime{this.win.removeEventListener("pointerup",i,!0),this.win.removeEventListener("pointerdown",i,!0)});let t=this,o=this.use(q);function i(n){if(n.button!==3&&n.button!==4)return;o.onHistoryButtonActivity(),n.preventDefault(),n.stopImmediatePropagation();let s=n.target.matchParent(".workspace-leaf, .workspace-tab-header");if(s&&n.type==="pointerup"){let c=me.get(s);if(c||app.workspace.iterateLeaves(l=>c=l.containerEl===s||l.tabHeaderEl===s?l:c,t.container),!c)return!1;n.button==3&&w.forLeaf(c).back(),n.button==4&&w.forLeaf(c).forward()}return!1}(0,g.requireApiVersion)("1.6.0")||this.registerDomEvent(this.win.matchMedia("(prefers-color-scheme: dark)"),"change",qe),app.workspace.onLayoutReady(()=>{this.addChild(this.back=new H(this,"back",-1)),this.addChild(this.forward=new H(this,"forward",1)),this.display(),this.numberPanes(),this.registerEvent(app.workspace.on("layout-change",this.numberPanes,this))})}onunload(){this.unNumberPanes(),this.win.document.body.findAll(".workspace-leaf").forEach(e=>{let t=e.find(".view-header > .view-actions"),o=t==null?void 0:t.find('.view-action[class*=" app:go-forward"]'),i=t==null?void 0:t.find('.view-action[class*=" app:go-back"]');o&&K(o,this.forward.oldLabel),i&&K(o,this.back.oldLabel)})}unNumberPanes(e=".workspace-leaf"){this.win.document.body.findAll(e).forEach(t=>{t.style.removeProperty("--pane-relief-label"),t.toggleClass("has-pane-relief-label",!1),t.style.removeProperty("--pane-relief-forward-count"),t.style.removeProperty("--pane-relief-backward-count")})}updateLeaf(e,t=w.forLeaf(e)){e.containerEl.style.setProperty("--pane-relief-forward-count",'"'+(t.lookAhead().length||"")+'"'),e.containerEl.style.setProperty("--pane-relief-backward-count",'"'+(t.lookBehind().length||"")+'"');let o=e.containerEl.find(".view-header > .view-actions"),i=o==null?void 0:o.find('.view-action[class*=" app:go-forward"]'),n=o==null?void 0:o.find('.view-action[class*=" app:go-back"]');i&&this.forward.updateDisplay(t,i),n&&this.back.updateDisplay(t,n);{let s=e.containerEl.find(".view-header > .view-header-nav-buttons"),c=s==null?void 0:s.find("button:last-child"),l=s==null?void 0:s.find("button:first-child");c&&this.forward.updateDisplay(t,c),l&&this.back.updateDisplay(t,l)}}numberPanes(){this.win.requestAnimationFrame(()=>{let e=new Map;this.win===window&&this.unNumberPanes(".workspace > .workspace-split:not(.mod-root) .workspace-tabs > .workspace-leaf");let t=0,o=null;this.leaves().forEach(i=>{i.containerEl.style.setProperty("--pane-relief-label",++t<9?""+t:""),i.containerEl.toggleClass("has-pane-relief-label",t<9),o=i,this.updateLeaf(i),i.parentSplit instanceof g.WorkspaceTabs&&e.set(i.parentSplit,1+(e.get(i.parentSplit)||0))}),t>8&&(o==null||o.containerEl.style.setProperty("--pane-relief-label","9"),o==null||o.containerEl.toggleClass("has-pane-relief-label",!0));for(let[i,n]of e.entries())i.containerEl.style.setProperty("--pane-relief-tab-count",""+n)})}onUpdateHistory(e,t){this.win.requestAnimationFrame(()=>{this.updateLeaf(e),t===this.forward.history&&this.forward.setHistory(t),t===this.back.history&&this.back.setHistory(t)})}},ge=class extends g.Component{constructor(e,t,o){super();this.owner=e;this.kind=t;this.dir=o;this.history=null}onload(){this.containerEl=this.owner.win.document.body.find(`.titlebar .titlebar-button-container.mod-left .titlebar-button.mod-${this.kind}`)||this.owner.win.createDiv(),this.count=this.containerEl.createSpan({prepend:this.kind==="back",cls:"history-counter"}),this.history=null,this.oldLabel=this.containerEl.getAttribute("aria-label")||i18next.t(this.dir<0?"commands.navigate-back":"commands.navigate-forward"),this.registerDomEvent(this.containerEl,"contextmenu",this.openMenu.bind(this));let e=o=>{var i;o.preventDefault(),o.stopImmediatePropagation(),(i=this.history)==null||i[this.kind]()};this.register(()=>this.containerEl.removeEventListener("click",e,!0)),this.containerEl.addEventListener("click",e,!0);let t=`.view-header > .view-actions > .view-action[class*="app:go-${this.kind}"], .view-header-left > .view-header-nav-buttons > button:${this.dir<0?"first":"last"}-child, .view-header > .view-header-nav-buttons > button:${this.dir<0?"first":"last"}-child`;this.register(We(this.owner.win.document.body,"contextmenu",t,(o,i)=>{let n=i.matchParent(".workspace-leaf"),s=this.owner.leaves().filter(c=>c.containerEl===n).pop();s&&(o.preventDefault(),o.stopImmediatePropagation(),this.openMenu(o,w.forLeaf(s)))},{capture:!0})),(0,g.requireApiVersion)("1.8")&&this.register(We(this.owner.win.document.body,"auxclick",t,o=>{o.button===2&&o.stopImmediatePropagation()},{capture:!0}))}onunload(){K(this.containerEl,this.oldLabel),this.count.detach(),this.containerEl.toggleClass("mod-active",!1)}setCount(e){this.count.textContent=""+(e||"")}setHistory(e=w.current()){this.updateDisplay(this.history=e)}updateDisplay(e,t=this.containerEl){let o=e[this.dir<0?"lookBehind":"lookAhead"]();t===this.containerEl&&this.setCount(o.length),K(t,o.length?this.oldLabel+` `+oe(o[0]).title:`No ${this.kind} history`),t.toggleClass("mod-active",o.length>0)}openMenu(e,t=this.history){var n;let o=t[this.dir<0?"lookBehind":"lookAhead"]();if(!o.length)return;let i=new g.Menu;(n=i.setUseNativeMenu)==null||n.call(i,!1),i.dom.addClass("pane-relief-history-menu"),i.dom.on("mousedown",".menu-item",s=>{s.stopPropagation()},!0),o.map(oe).forEach((s,c)=>this.menuItem(s,c,i,t)),i.showAtPosition({x:e.clientX,y:e.clientY+20}),i.register(d(app.workspace,{setActiveLeaf(s){return function(c,...l){if(!c.containerEl.matchParent(".hover-editor"))return s.call(this,c,...l)}}})),this.owner.historyIsOpen=!0,i.onHide(()=>{this.owner.historyIsOpen=!1,this.owner.display()})}menuItem(e,t,o,i){let{dir:n,kind:s}=this;o.addItem(u=>{c(u),e.file&&l(u.dom)});return;function c(u,h=""){u.setIcon(e.icon).setTitle(h+e.title).onClick(m=>{if(g.Keymap.isModEvent(m))if(i.leaf){app.workspace.duplicateLeaf(i.leaf,g.Keymap.isModEvent(m)).then(y=>{w.forLeaf(y).go((t+1)*n,!0)});return}else i=i.cloneTo(app.workspace.getLeaf(g.Keymap.isModEvent(m)));i.go((t+1)*n,!0)})}function l(u){u.addEventListener("mouseover",h=>{app.workspace.trigger("hover-link",{event:h,source:ge.hoverSource,hoverParent:o.dom,targetEl:u,linktext:e.file.path})}),u.setAttr("draggable","true"),u.addEventListener("dragstart",h=>{let m=app.dragManager,y=m.dragFile(h,e.file);m.onDragStart(h,y)}),u.addEventListener("dragend",h=>o.hide()),u.addEventListener("contextmenu",h=>{let m=new g.Menu;m.addItem(y=>c(y,`Go ${s} to `)).addSeparator(),app.workspace.trigger("file-menu",m,e.file,"link-context-menu"),m.showAtPosition({x:h.clientX,y:h.clientY}),h.stopPropagation()},!0)}}},H=ge;H.hoverSource="pane-relief:history-menu";function oe(a){var c,l,u,h,m;let{viewState:{type:r,state:e},eState:t,path:o,raw:i}=a,n=o&&app.vault.getAbstractFileByPath(o),s={icon:(c=i==null?void 0:i.icon)!=null?c:"",title:(l=i==null?void 0:i.title)!=null?l:"",file:n,type:r,state:e,eState:t};return Me[r]?[s.icon,s.title]=Me[r]:o&&!n?[s.icon,s.title]=["trash","Missing file "+o]:n instanceof g.TFile&&(s.icon=(u=$e[r])!=null?u:"document",r==="markdown"&&e.mode==="preview"&&(s.icon="lines-of-text"),s.title=n?n.basename+(n.extension!=="md"?"."+n.extension:""):"No file",r==="media-view"&&!n&&(s.title=(m=(h=e.info)==null?void 0:h.filename)!=null?m:s.title)),app.workspace.trigger("pane-relief:format-history-item",s),s}function We(a,r,e,t,o){return a.on(r,e,t,o),()=>a.off(r,e,t,o)}function K(a,r){r?a.setAttribute("aria-label",r||void 0):a.removeAttribute("aria-label")}var re=class extends k{constructor(){super(...arguments);this.setting=new W(this,"pane-relief:focus-lock").of(app.workspace);this.plugin=this.use(I.Plugin);this.statusEl=this.plugin.addStatusBarItem();this.iconEl=this.statusEl.createSpan("pane-relief-focus-lock icon",e=>{e.setAttribute("aria-label-position","top"),e.setAttribute("aria-label-delay","0"),e.setAttribute("data-tooltip-position","top")});this.isLocked=null;this.installed=!1}onload(){this.registerDomEvent(this.iconEl,"click",()=>this.toggle()),ee(this.plugin,{[p("focus-lock","Toggle focus lock (Enable/disable sidebar focusing)")]:()=>()=>this.toggle()}),this.registerEvent(this.setting.onLoadWorkspace(this.onChange,this))}install(){this.installed=!0;let e=this;this.register(d(app.workspace,{setActiveLeaf(t){return function(o,...i){var n,s;if(!e.isLocked||R(o))return t.call(this,o,...i);if(app.workspace.revealLeaf(o),!this.activeLeaf||!_(this.activeLeaf))return t.call(this,this.getLeaf(),...i);(((n=o.view)==null?void 0:n.getViewType())==="search"&&i[0]===!0||(s=i[0])!=null&&s.focus)&&o.setEphemeralState({focus:!0})}},revealLeaf(t){return function(o){let i=o.getContainer();if(!e.isLocked||R(o)||!i)return t.call(this,o);let n=d(i,{focus(){return function(){}}});try{return t.call(this,o)}finally{n()}}}})),this.register(d(I.WorkspaceLeaf.prototype,{canNavigate(t){return function(){return t.call(this)&&(!e.isLocked||R(this))}}})),this.register(d(app.internalPlugins.plugins["file-explorer"].instance,{init(t){return function(...i){try{return t.apply(this,i)}finally{e.blockFileExplorerReveal()}}}})),this.blockFileExplorerReveal()}blockFileExplorerReveal(){let e=this,t=app.commands.commands["file-explorer:reveal-active-file"];t&&this.register(d(t,{checkCallback(o){return function(...i){var n;if(e.isLocked){for(let s of app.workspace.getLeavesOfType("file-explorer"))if(!R(s)){let c=(n=s.view.dom)==null?void 0:n.navFileContainerEl;c&&E(d(c,{focus(l){return function(){}}}))}}return o==null?void 0:o.apply(this,i)}}}))}toggle(){this.setting.set(!this.setting.get()),this.onChange()}onChange(){let e=this.setting.get();e&&!this.installed&&this.install(),this.isLocked!==e&&(this.isLocked!=null&&document.body.appendChild(new I.Notice(e?"Sidebar focusing disabled":"Sidebar focusing enabled").noticeEl.parentElement),this.isLocked=e,(0,I.setIcon)(this.iconEl,e?"lucide-lock":"lucide-unlock"),K(this.iconEl,e?"Sidebar focus disabled: click to enable":"Sidebar focus enabled: click to disable"),e&&!R(app.workspace.activeLeaf)&&app.workspace.layoutReady&&app.workspace.setActiveLeaf(app.workspace.getUnpinnedLeaf(),!1,!0))}};function R(a){let r=a==null?void 0:a.getRoot();return!!(r&&r!==app.workspace.leftSplit&&r!==app.workspace.rightSplit)}var S=require("obsidian");var ie=class extends k{constructor(){super(...arguments);this.changing=!1;this.fixSlidingPanes=(0,S.debounce)(()=>{activeWindow.requestAnimationFrame(()=>{let{activeLeaf:e}=app.workspace;if(!e)return;let t=e.parentSplit;if((0,S.requireApiVersion)("0.16.2")&&t instanceof S.WorkspaceTabs&&t.isStacked){let o=d(t.tabsContainerEl,{scrollTo(i){return function(n,s){return typeof n=="object"?(delete n.behavior,i.call(this,n)):i.call(this,n,s)}}});try{t.scrollIntoView(t.currentTab)}finally{o(),this.changing=!1}}else this.changing=!1;e.containerEl.scrollIntoView()})},1,!0)}onload(){this.registerEvent(app.workspace.on("layout-change",()=>{for(let t of this.parents())this.refresh(t)}));let e=this;this.register(d(app.workspace,{setActiveLeaf(t){return function(i,...n){let s=e.parentForLeaf(i),c=e.parentForLeaf(app.workspace.activeLeaf);return s&&c&&s!==c&&c.matchParent(".hover-popover.is-active.snap-to-viewport")&&s.ownerDocument===c.ownerDocument&&!s.matchParent(".hover-popover")&&app.commands.executeCommandById("obsidian-hover-editor:restore-active-popover"),R(i)&&s&&e.refresh(s,s.hasClass("should-maximize")?i.containerEl:null),t.call(this,i,...n)}}})),app.workspace.onLayoutReady(()=>{let t=app.workspace.rightSidebarToggleButtonEl.cloneNode(!0);t.id="pr-maximize-sb-toggle",t.addEventListener("click",()=>app.workspace.rightSplit.toggle()),t.ariaLabel=i18next.t(app.workspace.rightSplit.collapsed?"interface.sidebar-expand":"interface.sidebar-collapse"),app.workspace.containerEl.parentElement.appendChild(t),this.register(()=>t.detach()),this.register(d(app.workspace.rightSplit.constructor.prototype,{expand(o){return function(){return t.ariaLabel=i18next.t("interface.sidebar-collapse"),o.call(this)}},collapse(o){return function(){return t.ariaLabel=i18next.t("interface.sidebar-expand"),o.call(this)}}}))}),this.register(d(S.ItemView.prototype,{load(t){return function(){if(!this.iconEl){let o=this.iconEl=this.headerEl.createDiv("clickable-icon view-header-icon");this.headerEl.prepend(o),o.draggable=!0,o.addEventListener("dragstart",i=>{this.app.workspace.onDragLeaf(i,this.leaf)}),(0,S.setIcon)(o,this.getIcon()),(0,S.setTooltip)(o,"Drag to rearrange")}return t.call(this)}}}))}onunload(){for(let e of this.parents())this.refresh(e,null)}toggleMaximize(e=app.workspace.activeLeaf){(!e||!R(e))&&(e=app.workspace.getMostRecentLeaf(app.workspace.rootSplit));let t=this.parentForLeaf(e);if(!t)return;let o=t.matchParent(".hover-popover");if(o&&app.plugins.plugins["obsidian-hover-editor"]&&o.findAll(".workspace-leaf").length===1){app.commands.executeCommandById("obsidian-hover-editor:"+(o.hasClass("snap-to-viewport")?"restore-active-popover":"snap-active-popover-to-viewport"));return}let i=!M(t,"should-maximize");t&&this.refresh(t,i?null:e.containerEl,i)}lastMaximized(e){return e.find(".workspace-leaf.is-maximized")||app.workspace.getMostRecentLeaf().containerEl}refresh(e,t=e.hasClass("should-maximize")?this.lastMaximized(e):null,o=e.hasClass("has-maximized")){if(this.changing=!0,e.findAllSelf(".workspace-split, .workspace-tabs").forEach(i=>{(i===e||this.parentFor(i)===e)&&M(i,"has-maximized",t?i.contains(t):!1)}),e.findAll(".workspace-leaf").forEach(i=>{this.parentFor(i)===e&&M(i,"is-maximized",i===t)}),(!t||!e.contains(t))&&(M(e,"should-maximize",!1),o))return this.fixSlidingPanes();this.changing=!1}parents(){var o,i,n;let e=[app.workspace.rootSplit.containerEl];e.concat(((i=(o=app.workspace.floatingSplit)==null?void 0:o.children)!=null?i:[]).map(s=>s.containerEl));let t=(n=app.plugins.plugins["obsidian-hover-editor"])==null?void 0:n.activePopovers;if(t)for(let s of t)s.rootSplit&&e.push(s.rootSplit.containerEl);return e.map(s=>this.parentFor(s))}parentForLeaf(e){return this.parentFor(e==null?void 0:e.containerEl)}parentFor(e){return e==null?void 0:e.matchParent(".workspace, .hover-popover > .popover-content > .workspace-split")}};var A=require("obsidian"),U=class extends z{constructor(){super(...arguments);this.manager=this.use(U)}[V.factory](){return new we(this.constructor)}onload(){this.onSet()}onunload(){this.update(!1)}get options(){return this.manager.options.get(this.container)}set options(e){this.manager.options.set(e,this.container)}onSet(e=this.options){this.update(e.active)}update(e){M(this.container.containerEl,"is-sliding",e);let t=this.container.containerEl.matchParent(".workspace");t?M(t,"is-sliding",e):this.register(this.container.containerEl.onNodeInserted(()=>this.update(this.options.active),!0))}activate(e){var o;let{options:t}=this;!this.win.document.hasFocus()&&Ee().some(i=>i.document.hasFocus())&&this.container.focus(),t.active&&((o=e.containerEl.matchParent(".workspace-tabs"))!=null?o:e.containerEl).scrollIntoView(),this.manager.options.defaultValue=t}toggleSliding(){let{options:e}=this;this.options={...e,active:!e.active}}},we=class extends Y{constructor(){super(...arguments);this.options=new W(this,"pane-relief:sliding-panes",{active:!1});this.overlay=app.workspace.containerEl.parentElement.createDiv("prsp-tb-overlay");this.requestOverlayUpdate=(0,A.debounce)(()=>{var e,t;if(app.workspace.layoutReady&&!((e=app.workspace.leftSplit)!=null&&e.collapsed)){let o=(t=app.workspace.leftSplit.containerEl.find(".workspace-tabs.mod-top-left-space .workspace-tab-header-spacer"))==null?void 0:t.getBoundingClientRect();o&&this.overlay.style.setProperty("--pr-overlay-width",`${o.width}px`),o&&this.overlay.style.setProperty("--pr-overlay-left",`${o.left}px`)}},100,!0)}onunload(){super.onunload(),this.overlay.detach()}onload(){super.onload(),window.CodeMirror.getMode({},"XXX");let e=this;Pe(this.use(A.Plugin),{[xe("toggle-sliding","Toggle sliding panes (for current window)")](){return()=>e.forLeaf(app.workspace.activeLeaf).toggleSliding()}}),this.registerEvent(this.options.onSet(this.onChange,this)),this.registerEvent(this.options.store.onLoadItem(this.onChange,this)),this.registerEvent(this.onLeafChange(t=>this.forLeaf(t).activate(t))),app.workspace.onLayoutReady(()=>{this.registerEvent(app.workspace.on("layout-change",this.requestOverlayUpdate)),this.registerEvent(app.workspace.on("resize",this.requestOverlayUpdate));let t=this;this.register(d(app.workspace.leftSplit.constructor.prototype,{expand(o){return function(){return t.requestOverlayUpdate(),o.call(this)}}})),this.requestOverlayUpdate()})}onChange(e){(e instanceof A.WorkspaceRoot||e instanceof A.WorkspaceWindow)&&this.forContainer(e).onSet(this.options.get(e))}};var b=(0,C.requireApiVersion)("0.16")?"tab":"pane",ae=(0,C.requireApiVersion)("0.16")?"group":"split";function P(a){return`Jump to ${a} ${b} in window`}function T(a){return`Place as ${a} ${b} in ${ae}`}var ne=class extends C.Plugin{constructor(){super(...arguments);this.use=V.plugin(this);this.nav=this.use($).watch();this.max=this.use(ie);this.sliding=this.use(U).watch()}onload(){this.use(q).load(),this.register(d(C.Workspace.prototype,{getFocusedContainer(e){return function(){let o=e.call(this);return o===this.rootSplit&&window!==activeWindow?null:o}}})),this.app.workspace.registerHoverLinkSource(H.hoverSource,{display:"History dropdowns",defaultMod:!0}),this.app.workspace.onLayoutReady(()=>{this.registerEvent(this.app.vault.on("rename",(e,t)=>{e instanceof C.TFile&&this.app.workspace.iterateAllLeaves(o=>w.forLeaf(o).onRename(e,t))})),this.registerEvent(app.workspace.on("active-leaf-change",e=>{var t;return(t=this.nav.forLeaf(e))==null?void 0:t.display(e)})),this.registerEvent(app.workspace.on("pane-relief:update-history",(e,t)=>{var o;return(o=this.nav.forLeaf(e))==null?void 0:o.onUpdateHistory(e,t)}))}),ee(this),(0,C.requireApiVersion)("0.15.6")&&this.use(re),this.use(Z)}[p("swap-prev",`Swap ${b} with previous in ${ae}`,"Mod+Shift+PageUp")](){return this.leafPlacer(-1)}[p("swap-next",`Swap ${b} with next in ${ae}`,"Mod+Shift+PageDown")](){return this.leafPlacer(1)}[p("go-prev",`Cycle to previous ${b} in this window`,"Mod+PageUp")](){return()=>this.gotoNthLeaf(-1,!0)}[p("go-next",`Cycle to next ${b} in this window`,"Mod+PageDown")](){return()=>this.gotoNthLeaf(1,!0)}[p("win-prev","Cycle to previous window",[])](){if(L()>1)return()=>this.gotoNthWindow(-1,!0)}[p("win-next","Cycle to next window",[])](){if(L()>1)return()=>this.gotoNthWindow(1,!0)}[p("go-1st",P("1st"),"Alt+1")](){return()=>this.gotoNthLeaf(0)}[p("go-2nd",P("2nd"),"Alt+2")](){return()=>this.gotoNthLeaf(1)}[p("go-3rd",P("3rd"),"Alt+3")](){return()=>this.gotoNthLeaf(2)}[p("go-4th",P("4th"),"Alt+4")](){return()=>this.gotoNthLeaf(3)}[p("go-5th",P("5th"),"Alt+5")](){return()=>this.gotoNthLeaf(4)}[p("go-6th",P("6th"),"Alt+6")](){return()=>this.gotoNthLeaf(5)}[p("go-7th",P("7th"),"Alt+7")](){return()=>this.gotoNthLeaf(6)}[p("go-8th",P("8th"),"Alt+8")](){return()=>this.gotoNthLeaf(7)}[p("go-last",P("last"),"Alt+9")](){return()=>this.gotoNthLeaf(99999999)}[p("win-1st","Switch to 1st window",[])](){if(L()>1)return()=>this.gotoNthWindow(0)}[p("win-2nd","Switch to 2nd window",[])](){if(L()>1)return()=>this.gotoNthWindow(1)}[p("win-3rd","Switch to 3rd window",[])](){if(L()>2)return()=>this.gotoNthWindow(2)}[p("win-4th","Switch to 4th window",[])](){if(L()>3)return()=>this.gotoNthWindow(3)}[p("win-5th","Switch to 5th window",[])](){if(L()>4)return()=>this.gotoNthWindow(4)}[p("win-6th","Switch to 6th window",[])](){if(L()>5)return()=>this.gotoNthWindow(5)}[p("win-7th","Switch to 7th window",[])](){if(L()>6)return()=>this.gotoNthWindow(6)}[p("win-8th","Switch to 8th window",[])](){if(L()>7)return()=>this.gotoNthWindow(7)}[p("win-last","Switch to last window",[])](){if(L()>1)return()=>this.gotoNthWindow(99999999)}[p("put-1st",T("1st"),"Mod+Alt+1")](){return()=>this.placeLeaf(0,!1)}[p("put-2nd",T("2nd"),"Mod+Alt+2")](){return()=>this.placeLeaf(1,!1)}[p("put-3rd",T("3rd"),"Mod+Alt+3")](){return()=>this.placeLeaf(2,!1)}[p("put-4th",T("4th"),"Mod+Alt+4")](){return()=>this.placeLeaf(3,!1)}[p("put-5th",T("5th"),"Mod+Alt+5")](){return()=>this.placeLeaf(4,!1)}[p("put-6th",T("6th"),"Mod+Alt+6")](){return()=>this.placeLeaf(5,!1)}[p("put-7th",T("7th"),"Mod+Alt+7")](){return()=>this.placeLeaf(6,!1)}[p("put-8th",T("8th"),"Mod+Alt+8")](){return()=>this.placeLeaf(7,!1)}[p("put-last",T("last"),"Mod+Alt+9")](){return()=>this.placeLeaf(99999999,!1)}[p("maximize",`Maximize active ${b} (Toggle)`,[])](){if(this.max.parentForLeaf(app.workspace.activeLeaf))return()=>this.max.toggleMaximize()}[p("ordered-close",`Close ${b} and go to adjacent ${b}`)](){return()=>{let e=app.workspace.activeLeaf,t=this.nav.forLeaf(e).leaves(),o=t.indexOf(e),i;o>-1&&(t.length>o+1?i=t[o+1]:o>0&&(i=t[o-1])),i&&app.workspace.setActiveLeaf(i,!1,!0),e.detach()}}[p("open-new-window","Open new window")](){return()=>app.workspace.openPopoutLeaf()}onunload(){this.app.workspace.unregisterHoverLinkSource(H.hoverSource)}gotoNthLeaf(e,t){let o=app.workspace.activeLeaf,i=o.getRoot();(i===app.workspace.leftSplit||i===app.workspace.rightSplit)&&(o=app.workspace.getMostRecentLeaf(app.workspace.rootSplit));let n=this.nav.forLeaf(o);o=He(n.leaves(),o,e,t),!o||this.app.workspace.setActiveLeaf(o,!0,!0)}gotoNthWindow(e,t){var n,s,c,l,u;let o=He(this.nav.forAll(),this.nav.forLeaf(app.workspace.activeLeaf),e,t),i=o==null?void 0:o.latestLeaf();i&&app.workspace.setActiveLeaf(i,!0,!0),(u=(l=(c=(s=(n=o==null?void 0:o.win).require)==null?void 0:s.call(n,"electron"))==null?void 0:c.remote)==null?void 0:l.getCurrentWindow())==null||u.focus()}placeLeaf(e,t=!0){let o=this.leafPlacer(e,t);o&&o()}leafPlacer(e,t=!0){let o=this.app.workspace.activeLeaf;if(!o)return!1;let i=o.parentSplit,n=i.children,s=n.indexOf(o);if(s==-1)return!1;if(n.length===1){let c=o.containerEl.matchParent(".hover-popover");if(c&&t&&Math.abs(e)===1){let l=c;for(;l&&(l===c||!l.matches(".hover-popover"));)l=e<0?l.previousElementSibling:l.nextElementSibling;if(l)return()=>{e<0?l.parentElement.insertBefore(c,l):l.parentElement.insertBefore(l,c),app.workspace.onLayoutChange()}}}if(t){if(e+=s,e<0||e>=n.length)return!1}else e>=n.length&&(e=n.length-1),e<0&&(e=0);return s==e?!1:()=>{let c=n[e];n.splice(s,1),n.splice(e,0,o),i.selectTab?i.selectTab(o):(c.containerEl.insertAdjacentElement(s>e?"beforebegin":"afterend",o.containerEl),i.recomputeChildrenDimensions(),o.onResize(),this.app.workspace.onLayoutChange(),this.app.workspace.activeLeaf=null,this.app.workspace.setActiveLeaf(o,!1,!0))}}};function He(a,r,e,t){return t&&(e+=a.indexOf(r),e=(e+a.length)%a.length),a[e>=a.length?a.length-1:e]} /* nosourcemap */