Oscar Plaisant f91c506a9e update
2025-03-16 18:05:45 +01:00

6 lines
38 KiB
JavaScript

var se=Object.defineProperty;var He=Object.getOwnPropertyDescriptor;var Re=Object.getOwnPropertyNames;var Ie=Object.prototype.hasOwnProperty;var Ae=(i,r)=>{for(var e in r)se(i,e,{get:r[e],enumerable:!0})},Fe=(i,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of Re(r))!Ie.call(i,o)&&o!==e&&se(i,o,{get:()=>r[o],enumerable:!(t=He(r,o))||t.enumerable});return i};var Ve=i=>Fe(se({},"__esModule",{value:!0}),i);var Ke={};Ae(Ke,{default:()=>ne,leafName:()=>v,splitName:()=>ie});module.exports=Ve(Ke);var E=require("obsidian");var S=typeof queueMicrotask=="function"?queueMicrotask:(i=>r=>i.then(r))(Promise.resolve());function ce(i){return i&&typeof i=="object"?JSON.parse(JSON.stringify(i)):i}function M(i,r,e){let t=i.classList.contains(r);return e=e!=null?e:!t,e!==t&&(e?i.classList.add(r):i.classList.remove(r)),e}var f;(i=>Object.assign(i,require("obsidian")))(f||(f={}));var le="use.me",pe="use.factory",O,U,de=function(){return Object.defineProperties(i(),{this:{get(){if(O)return O;throw new TypeError("No current context")}},me:{value:le},factory:{value:pe}});function i(o){let a=new Map;a.prev=o;let n=Object.assign(o?c=>{let l=a.get(c);if(!l){for(let y=a.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},a.set(c,l)}let u,h,m;for(;;)switch(l.s){case 0:return O===n&&U&&U.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(a,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(a,c,2,l),n},set(c,l){return r(a,c,1,l),n},fork(c){let l=i(a);return c!=null?l(c):l}});return o?n.use=n:n;function s(c,l,u){let h=O,m=U;try{return O=n,U=u,c(l)}finally{O=h,U=m}}}function r(o,a,n,s){if(o.has(a)){let c=o.get(a);if(!c.s)throw new Error(`Already read: ${String(a)}`);c.s=n,c.v=s,c.d=null}else o.set(a,{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 De,V=(i=>(i.service=function(r){return i(Y).addChild(r),i.this},i.plugin=function(r){if(!F)De=r.app,F=i.fork(),F.set(f.Plugin,r),F.set(r.constructor,r),r.addChild(F.use(Y));else if(r!==F.use(f.Plugin))throw new TypeError("use.plugin() called on multiple plugins");return F},i.def(f.Plugin,()=>{throw new Error("Plugin not created yet")}),i.def(f.App,()=>i(f.Plugin).app),i))(de),F;var k=class extends f.Component{constructor(){super(...arguments);this.use=V.service(this)}},Y=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?S(()=>super.addChild(e)):super.addChild(e)),e}};function G(i,r){S(()=>i.removeChild(r))}function ye(i,r){let e=new f.Component;e.onload=()=>{G(i,e),i=null,r()},i.addChild(e)}function d(i,r){let e=Object.keys(r).map(t=>Ne(i,t,r[t]));return e.length===1?e[0]:function(){e.forEach(t=>t())}}function Ne(i,r,e){let t=i[r],o=i.hasOwnProperty(r),a=e(t);return t&&Object.setPrototypeOf(a,t),Object.setPrototypeOf(n,a),i[r]=n,s;function n(...c){return a===t&&i[r]===n&&s(),a.apply(this,c)}function s(){i[r]===n&&(o?i[r]=t:delete i[r]),a!==t&&(a=t,Object.setPrototypeOf(n,t||Function))}}function Q(i,r,e){return t[i]=i,t;function t(...o){return(r[i]===i?r:e).apply(this,o)}}function X(i){let r=app.workspace;switch(i==null?void 0:i.getRoot()){case r.rootSplit:case r.floatingSplit:case r.leftSplit:case r.rightSplit:return!0;default:return!1}}function D(i,r){if(!i)return!1;if(typeof i=="function"&&(r=i,i=app.workspace),r(i))return!0;if(i instanceof f.Workspace)return D(i.rootSplit,r)||D(i.floatingSplit,r)||D(i.leftSplit,r)||D(i.rightSplit,r);if(i instanceof f.WorkspaceParent){for(let e of i.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,a)=>{t===this.owner&&r.call(e,o,a)}):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 a,n;return(n=(a=e==null?void 0:e[C])==null?void 0:a[t])!=null?n:o}set(e,t,o){let a=e[C]||(e[C]={}),n=a[t];a[t]=o,!this.loading&&n!==o&&(app.workspace.trigger(ke+t,e,o,n),app.workspace.requestSaveLayout())}unset(e,t){let o=e[C];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&&S(()=>{D(o=>{try{e.call(t,o)}catch(a){console.error(a)}})}),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&&S(()=>{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 Q(ue,t,async function(a,...n){e.trigger(N+":start");try{return be(this,a),await t.call(this,a,...n)}finally{e.trigger(N+":workspace")}})},deserializeLayout(t){return Q(ue,t,async function(a,...n){let s=await t.call(this,a,...n);return be(s,a),s})}}))}},fe=2,ue=Symbol.for(`v${fe}.layout-storage-events.ophidian.peak-dev.org`),C="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(i){return Q(ue,i,function(){let e=i.call(this);return app.workspace.trigger(Le,this,e),this[C]&&(e[C]=ce(this[C])),e})}function be(i,r){if(!i)return;let e=r==null?void 0:r[C];e&&(i[C]=ce(e)),app.workspace.trigger(N,i,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 J(this.constructor)}static onload(e){}static onunload(e){}},J=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(S),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?S(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 a=ze(e);if(a)return this.forContainer(a,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(()=>{G(this,o),G(e.component,o),this.instances.delete(e)}))),o}forDom(e,t=!0){return this.forWindow(Oe(e),t)}forLeaf(e=app.workspace.activeLeaf,t=!0){if(X(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(i=>i.win)}function b(){var i,r;return 1+((r=(i=app.workspace.floatingSplit)==null?void 0:i.children.length)!=null?r:0)}function Oe(i){return i.win||(i.ownerDocument||i).defaultView||window}function ze(i){if(i===window)return app.workspace.rootSplit;let{floatingSplit:r}=app.workspace;if(r){for(let e of r.children)if(i===e.win)return e}}var _=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(i,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:i,name:r,hotkeys:o});let a=Symbol("cmd:"+i);return Ce[a]=t,a}function Te(i,r=i.constructor.prototype){Object.getOwnPropertySymbols(r).forEach(e=>{let t=Ce[e],o=r[e];t&&i.addCommand(Object.assign({},t,{checkCallback(a){let n=o.call(i);return a||typeof n!="function"?!!n:(n(),!0)}}))})}var Pe={};function p(i,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:i,name:r,hotkeys:o});let a=Symbol("cmd:"+i);return Pe[a]=t,a}function Z(i,r=i.constructor.prototype){Object.getOwnPropertySymbols(r).forEach(e=>{let t=Pe[e],o=r[e];t&&i.addCommand(Object.assign({},t,{checkCallback(a){let n=o.call(i);return a||typeof n!="function"?!!n:(n(),!0)}}))})}var I=require("obsidian");var g=require("obsidian");var x=require("obsidian");var ee="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,a=t&&(app==null?void 0:app.vault.getAbstractFileByPath(t));t&&!a&&(new x.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),a=JSON.stringify(t.state.info);if(o!==a)return!1}}return this.setState(r),!0}},w=class{constructor(r,{pos:e,stack:t}={pos:0,stack:[]}){this.leaf=r;r&&(r[ee]=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[ee];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 x.Notice(`Pinned ${v}: unpin before going forward or back`),void 0;if(this.leaf.working)return new x.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 x.Notice(`No more ${r<0?"back":"forward"} history for ${v}`)}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()}},te=class extends k{onload(){let r=this.use(j);this.registerEvent(r.onSaveItem((e,t)=>{e instanceof x.WorkspaceLeaf&&e[ee]&&(t[he]=e[ee].serialize())})),this.registerEvent(r.onLoadItem((e,t)=>{e instanceof x.WorkspaceLeaf&&t&&t[he]&&new w(e,t[he]).saveToNative()})),this.register(d(x.WorkspaceLeaf.prototype,{trigger(e){return function(o,...a){if(o==="history-change"){let n=w.forLeaf(this);n.loadFromNative(),app.workspace.trigger("pane-relief:update-history",this,n)}return e.call(this,o,...a)}}})),app.workspace.onLayoutReady(()=>app.workspace.iterateAllLeaves(e=>{e.trigger("history-change")}))}};var Be=(0,g.debounce)(()=>{var i;app.vault.getConfig("theme")==="system"&&((i=app.adaptToSystemTheme)==null||i.call(app))},200,!0),qe={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"]},q=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 a;let e=new Set,t=n=>{e.add(n)};app.workspace.iterateLeaves(t,this.container);let o=(a=app.plugins.plugins["obsidian-hover-editor"])==null?void 0:a.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(q).forLeaf(e)===this?e:this.leaves().reduce((t,o)=>!t||t.activeTime<o.activeTime?o:t,null)}onload(){let{document:e}=this.win;(0,g.requireApiVersion)("0.16.0")&&e.body.addClass("obsidian-themepocalypse"),this.win.addEventListener("pointerup",o,!0),this.win.addEventListener("pointerdown",o,!0),this.register(()=>{this.win.removeEventListener("pointerup",o,!0),this.win.removeEventListener("pointerdown",o,!0)});let t=this;function o(a){if(a.button!==3&&a.button!==4)return;a.preventDefault(),a.stopImmediatePropagation();let n=a.target.matchParent(".workspace-leaf, .workspace-tab-header");if(n&&a.type==="pointerup"){let s=me.get(n);if(s||app.workspace.iterateLeaves(c=>s=c.containerEl===n||c.tabHeaderEl===n?c:s,t.container),!s)return!1;a.button==3&&w.forLeaf(s).back(),a.button==4&&w.forLeaf(s).forward()}return!1}(0,g.requireApiVersion)("1.6.0")||this.registerDomEvent(this.win.matchMedia("(prefers-color-scheme: dark)"),"change",Be),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"]'),a=t==null?void 0:t.find('.view-action[class*=" app:go-back"]');o&&$(o,this.forward.oldLabel),a&&$(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"),a=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"]');a&&this.forward.updateDisplay(t,a),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(a=>{a.containerEl.style.setProperty("--pane-relief-label",++t<9?""+t:""),a.containerEl.toggleClass("has-pane-relief-label",t<9),o=a,this.updateLeaf(a),a.parentSplit instanceof g.WorkspaceTabs&&e.set(a.parentSplit,1+(e.get(a.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[a,n]of e.entries())a.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=t=>{var o;t.preventDefault(),t.stopImmediatePropagation(),(o=this.history)==null||o[this.kind]()};this.register(()=>this.containerEl.removeEventListener("click",e,!0)),this.containerEl.addEventListener("click",e,!0),this.register($e(this.owner.win.document.body,"contextmenu",`.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`,(t,o)=>{let a=o.matchParent(".workspace-leaf"),n=this.owner.leaves().filter(s=>s.containerEl===a).pop();n&&(t.preventDefault(),t.stopImmediatePropagation(),this.openMenu(t,w.forLeaf(n)))},{capture:!0}))}onunload(){$(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),$(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 a=new g.Menu;(n=a.setUseNativeMenu)==null||n.call(a,!1),a.dom.addClass("pane-relief-history-menu"),a.dom.on("mousedown",".menu-item",s=>{s.stopPropagation()},!0),o.map(oe).forEach((s,c)=>this.menuItem(s,c,a,t)),a.showAtPosition({x:e.clientX,y:e.clientY+20}),a.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,a.onHide(()=>{this.owner.historyIsOpen=!1,this.owner.display()})}menuItem(e,t,o,a){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(a.leaf){app.workspace.duplicateLeaf(a.leaf,g.Keymap.isModEvent(m)).then(y=>{w.forLeaf(y).go((t+1)*n,!0)});return}else a=a.cloneTo(app.workspace.getLeaf(g.Keymap.isModEvent(m)));a.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(i){var c,l,u,h,m;let{viewState:{type:r,state:e},eState:t,path:o,raw:a}=i,n=o&&app.vault.getAbstractFileByPath(o),s={icon:(c=a==null?void 0:a.icon)!=null?c:"",title:(l=a==null?void 0:a.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=qe[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 $e(i,r,e,t,o){return i.on(r,e,t,o),()=>i.off(r,e,t,o)}function $(i,r){r?i.setAttribute("aria-label",r||void 0):i.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()),Z(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,...a){var n,s;if(!e.isLocked||R(o))return t.call(this,o,...a);if(app.workspace.revealLeaf(o),!this.activeLeaf||!X(this.activeLeaf))return t.call(this,this.getLeaf(),...a);(((n=o.view)==null?void 0:n.getViewType())==="search"&&a[0]===!0||(s=a[0])!=null&&s.focus)&&o.setEphemeralState({focus:!0})}},revealLeaf(t){return function(o){let a=o.getContainer();if(!e.isLocked||R(o)||!a)return t.call(this,o);let n=d(a,{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(...a){try{return t.apply(this,a)}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(...a){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&&S(d(c,{focus(l){return function(){}}}))}}return o==null?void 0:o.apply(this,a)}}}))}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"),$(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(i){let r=i==null?void 0:i.getRoot();return!!(r&&r!==app.workspace.leftSplit&&r!==app.workspace.rightSplit)}var L=require("obsidian");var ae=class extends k{constructor(){super(...arguments);this.changing=!1;this.fixSlidingPanes=(0,L.debounce)(()=>{activeWindow.requestAnimationFrame(()=>{let{activeLeaf:e}=app.workspace;if(!e)return;let t=e.parentSplit;if((0,L.requireApiVersion)("0.16.2")&&t instanceof L.WorkspaceTabs&&t.isStacked){let o=d(t.tabsContainerEl,{scrollTo(a){return function(n,s){return typeof n=="object"?(delete n.behavior,a.call(this,n)):a.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(a,...n){let s=e.parentForLeaf(a),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(a)&&s&&e.refresh(s,s.hasClass("should-maximize")?a.containerEl:null),t.call(this,a,...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(L.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",a=>{this.app.workspace.onDragLeaf(a,this.leaf)}),(0,L.setIcon)(o,this.getIcon()),(0,L.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 a=!M(t,"should-maximize");t&&this.refresh(t,a?null:e.containerEl,a)}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(a=>{(a===e||this.parentFor(a)===e)&&M(a,"has-maximized",t?a.contains(t):!1)}),e.findAll(".workspace-leaf").forEach(a=>{this.parentFor(a)===e&&M(a,"is-maximized",a===t)}),(!t||!e.contains(t))&&(M(e,"should-maximize",!1),o))return this.fixSlidingPanes();this.changing=!1}parents(){var o,a,n;let e=[app.workspace.rootSplit.containerEl];e.concat(((a=(o=app.workspace.floatingSplit)==null?void 0:o.children)!=null?a:[]).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"),K=class extends z{constructor(){super(...arguments);this.manager=this.use(K)}[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(a=>a.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 J{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;Te(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 v=(0,E.requireApiVersion)("0.16")?"tab":"pane",ie=(0,E.requireApiVersion)("0.16")?"group":"split";function T(i){return`Jump to ${i} ${v} in window`}function P(i){return`Place as ${i} ${v} in ${ie}`}var ne=class extends E.Plugin{constructor(){super(...arguments);this.use=V.plugin(this);this.nav=this.use(q).watch();this.max=this.use(ae);this.sliding=this.use(K).watch()}onload(){this.use(te).load(),this.register(d(E.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 E.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)}))}),Z(this),(0,E.requireApiVersion)("0.15.6")&&this.use(re),this.use(_)}[p("swap-prev",`Swap ${v} with previous in ${ie}`,"Mod+Shift+PageUp")](){return this.leafPlacer(-1)}[p("swap-next",`Swap ${v} with next in ${ie}`,"Mod+Shift+PageDown")](){return this.leafPlacer(1)}[p("go-prev",`Cycle to previous ${v} in this window`,"Mod+PageUp")](){return()=>this.gotoNthLeaf(-1,!0)}[p("go-next",`Cycle to next ${v} in this window`,"Mod+PageDown")](){return()=>this.gotoNthLeaf(1,!0)}[p("win-prev","Cycle to previous window",[])](){if(b()>1)return()=>this.gotoNthWindow(-1,!0)}[p("win-next","Cycle to next window",[])](){if(b()>1)return()=>this.gotoNthWindow(1,!0)}[p("go-1st",T("1st"),"Alt+1")](){return()=>this.gotoNthLeaf(0)}[p("go-2nd",T("2nd"),"Alt+2")](){return()=>this.gotoNthLeaf(1)}[p("go-3rd",T("3rd"),"Alt+3")](){return()=>this.gotoNthLeaf(2)}[p("go-4th",T("4th"),"Alt+4")](){return()=>this.gotoNthLeaf(3)}[p("go-5th",T("5th"),"Alt+5")](){return()=>this.gotoNthLeaf(4)}[p("go-6th",T("6th"),"Alt+6")](){return()=>this.gotoNthLeaf(5)}[p("go-7th",T("7th"),"Alt+7")](){return()=>this.gotoNthLeaf(6)}[p("go-8th",T("8th"),"Alt+8")](){return()=>this.gotoNthLeaf(7)}[p("go-last",T("last"),"Alt+9")](){return()=>this.gotoNthLeaf(99999999)}[p("win-1st","Switch to 1st window",[])](){if(b()>1)return()=>this.gotoNthWindow(0)}[p("win-2nd","Switch to 2nd window",[])](){if(b()>1)return()=>this.gotoNthWindow(1)}[p("win-3rd","Switch to 3rd window",[])](){if(b()>2)return()=>this.gotoNthWindow(2)}[p("win-4th","Switch to 4th window",[])](){if(b()>3)return()=>this.gotoNthWindow(3)}[p("win-5th","Switch to 5th window",[])](){if(b()>4)return()=>this.gotoNthWindow(4)}[p("win-6th","Switch to 6th window",[])](){if(b()>5)return()=>this.gotoNthWindow(5)}[p("win-7th","Switch to 7th window",[])](){if(b()>6)return()=>this.gotoNthWindow(6)}[p("win-8th","Switch to 8th window",[])](){if(b()>7)return()=>this.gotoNthWindow(7)}[p("win-last","Switch to last window",[])](){if(b()>1)return()=>this.gotoNthWindow(99999999)}[p("put-1st",P("1st"),"Mod+Alt+1")](){return()=>this.placeLeaf(0,!1)}[p("put-2nd",P("2nd"),"Mod+Alt+2")](){return()=>this.placeLeaf(1,!1)}[p("put-3rd",P("3rd"),"Mod+Alt+3")](){return()=>this.placeLeaf(2,!1)}[p("put-4th",P("4th"),"Mod+Alt+4")](){return()=>this.placeLeaf(3,!1)}[p("put-5th",P("5th"),"Mod+Alt+5")](){return()=>this.placeLeaf(4,!1)}[p("put-6th",P("6th"),"Mod+Alt+6")](){return()=>this.placeLeaf(5,!1)}[p("put-7th",P("7th"),"Mod+Alt+7")](){return()=>this.placeLeaf(6,!1)}[p("put-8th",P("8th"),"Mod+Alt+8")](){return()=>this.placeLeaf(7,!1)}[p("put-last",P("last"),"Mod+Alt+9")](){return()=>this.placeLeaf(99999999,!1)}[p("maximize",`Maximize active ${v} (Toggle)`,[])](){if(this.max.parentForLeaf(app.workspace.activeLeaf))return()=>this.max.toggleMaximize()}[p("ordered-close",`Close ${v} and go to adjacent ${v}`)](){return()=>{let e=app.workspace.activeLeaf,t=this.nav.forLeaf(e).leaves(),o=t.indexOf(e),a;o>-1&&(t.length>o+1?a=t[o+1]:o>0&&(a=t[o-1])),a&&app.workspace.setActiveLeaf(a,!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,a=o.getRoot();(a===app.workspace.leftSplit||a===app.workspace.rightSplit)&&(o=app.workspace.getMostRecentLeaf(app.workspace.rootSplit));let n=this.nav.forLeaf(o);o=We(n.leaves(),o,e,t),!o||this.app.workspace.setActiveLeaf(o,!0,!0)}gotoNthWindow(e,t){var n,s,c,l,u;let o=We(this.nav.forAll(),this.nav.forLeaf(app.workspace.activeLeaf),e,t),a=o==null?void 0:o.latestLeaf();a&&app.workspace.setActiveLeaf(a,!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 a=o.parentSplit,n=a.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),a.selectTab?a.selectTab(o):(c.containerEl.insertAdjacentElement(s>e?"beforebegin":"afterend",o.containerEl),a.recomputeChildrenDimensions(),o.onResize(),this.app.workspace.onLayoutChange(),this.app.workspace.activeLeaf=null,this.app.workspace.setActiveLeaf(o,!1,!0))}}};function We(i,r,e,t){return t&&(e+=i.indexOf(r),e=(e+i.length)%i.length),i[e>=i.length?i.length-1:e]}
/* nosourcemap */