/* THIS IS A GENERATED/BUNDLED FILE BY ESBUILD */ var ie=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var be=Object.getOwnPropertyNames;var De=Object.prototype.hasOwnProperty;var Fe=(c,d)=>{for(var e in d)ie(c,e,{get:d[e],enumerable:!0})},Se=(c,d,e,n)=>{if(d&&typeof d=="object"||typeof d=="function")for(let i of be(d))!De.call(c,i)&&i!==e&&ie(c,i,{get:()=>d[i],enumerable:!(n=ke(d,i))||n.enumerable});return c};var xe=c=>Se(ie({},"__esModule",{value:!0}),c);var Ae={};Fe(Ae,{default:()=>ne});module.exports=xe(Ae);var f=require("obsidian");var _={name:"",folder:"",nameFormat:"YYYY-MM-DD - {title}",templateFile:"",typeProperty:"",icon:"file",indicatorColor:"#64748b"},P={calendar:{firstDayOfWeek:1,showNoteIndicators:!0,indicatorMode:"systems",dailyIndicatorColor:"#3b82f6"},daily:{folder:"periodic/daily",templateFile:"Templates/Daily note",nameFormat:"YYYY-MM-DD",typeProperty:"daily-note"},reusePeriodicNoteTabs:!1,weekly:{folder:"periodic/weekly",templateFile:"Templates/Weekly note",nameFormat:"GGGG-[W]WW",typeProperty:"weekly-note"},monthly:{folder:"periodic/monthly",templateFile:"Templates/Monthly note",nameFormat:"YYYY-MM",typeProperty:"monthly-note"},quarterly:{folder:"periodic/quarterly",templateFile:"Templates/Quarterly note",nameFormat:"YYYY-[Q]Q",typeProperty:"quarterly-note"},yearly:{folder:"periodic/yearly",templateFile:"Templates/Yearly note",nameFormat:"YYYY",typeProperty:"yearly-note"},dateSystems:[{id:"journal",name:"Journal",folder:"periodic/journal",nameFormat:"YYYY-MM-DD - [Journal]",templateFile:"",typeProperty:"journal",icon:"book-open",indicatorColor:"#22c55e"},{id:"meetings",name:"Meeting",folder:"periodic/meetings",nameFormat:"YYYY-MM-DD - {title}",templateFile:"",typeProperty:"meeting",icon:"users",indicatorColor:"#a855f7"}],recentFiles:{maxItems:50,show:"all",omittedPaths:[],omittedTags:[],showTypeFilter:!0,types:[]},display:{rowSize:26,rowSpacing:2,indentSize:16,fontSize:13,iconSize:16,calendarCellSize:32}};var y=require("obsidian");var me="{title}";function q(c){let d=c.indexOf(me);return d<0?{before:c,after:"",hasTitle:!1}:{before:c.slice(0,d),after:c.slice(d+me.length),hasTitle:!0}}function ae(c,d){if(!d)return!0;let e=d.endsWith("/")?d:`${d}/`;return c.startsWith(e)}function se(c,d,e,n){return n?!d||c.length|#^[\]]/g;function ge(c){return c.replace(Te,"-").replace(/\s+/g," ").trim()}function $(c){let{before:d}=q(c),e=d.replace(/\[[^\]]*\]/g,"");return/[YMDQGWEwdgeo]/.test(e)}var m=require("obsidian");var Y=require("obsidian");function ye(c,d,e){let n=(0,Y.moment)({year:c,month:d,day:1}),i=(0,Y.moment)(n).endOf("month"),t=(0,Y.moment)(n).subtract((n.day()-e+7)%7,"days"),a=(0,Y.moment)().startOf("day"),r=[],s=(0,Y.moment)(t);for(;s.isBefore(i)||s.month()===d;){let o=[];for(let l=0;l<7;l++)o.push({date:(0,Y.moment)(s),dayOfMonth:s.date(),isToday:s.isSame(a,"day"),isCurrentMonth:s.month()===d,isoWeekNumber:s.isoWeek()}),s.add(1,"day");if(r.push({weekNumber:o[0].isoWeekNumber,days:o}),r.length>=6)break}return r}function Ee(c,d){return d==="opened"?c.openedAt:d==="changed"||c.openedAt===void 0?c.changedAt:c.changedAt===void 0?c.openedAt:Math.max(c.openedAt,c.changedAt)}function W(c,d){let e=[];for(let n of c){let i=Ee(n,d);i!==void 0&&e.push({entry:n,key:i})}return e.sort((n,i)=>i.key-n.key),e.map(n=>n.entry)}function K(c,d){let e=new Set([...W(c,"opened").slice(0,d),...W(c,"changed").slice(0,d)]);return W(c,"all").filter(n=>e.has(n))}var E="waypoint-view";function Me(c){return c.dragManager}var z=class extends m.ItemView{constructor(e,n){super(e);this.redraw=()=>{this.contentEl.empty(),this.contentEl.addClass("waypoint-view");let e=this.plugin.settings.display;this.contentEl.style.setProperty("--wp-row-size",e.rowSize+"px"),this.contentEl.style.setProperty("--wp-row-spacing",e.rowSpacing+"px"),this.contentEl.style.setProperty("--wp-indent-size",e.indentSize+"px"),this.contentEl.style.setProperty("--wp-font-size",e.fontSize+"px"),this.contentEl.style.setProperty("--wp-icon-size",e.iconSize+"px"),this.contentEl.style.setProperty("--wp-cal-cell-size",e.calendarCellSize+"px");let n=this.contentEl.createDiv({cls:"waypoint-lists"});this.renderFavorites(n),this.renderRecentFiles(n),this.renderCalendar()};this.currentDisplayMonth=(0,m.moment)().month();this.currentDisplayYear=(0,m.moment)().year();this.dragId=null;this.dropZones=new WeakMap;this.recentFilesFilter=null;this.selectedDate=null;this.plugin=n}getViewType(){return E}getDisplayText(){return"Waypoint"}getIcon(){return"compass"}async onOpen(){this.redraw()}async onClose(){}showDate(e){this.currentDisplayMonth=e.month(),this.currentDisplayYear=e.year(),this.selectedDate=e.clone(),this.redraw()}renderCalendar(){var le;let n=this.contentEl.createDiv({cls:"waypoint-section waypoint-calendar-section"}).createDiv({cls:"waypoint-calendar"}),i=(0,m.moment)(),t=(0,m.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth,day:1}),a=n.createDiv({cls:"waypoint-calendar-top"}),r=a.createDiv({cls:"waypoint-calendar-breadcrumb"}),s=t.format("[Q]Q"),o=r.createSpan({cls:"waypoint-clickable",text:s});o.addEventListener("click",()=>{this.plugin.openPeriodNote("quarter",t)}),o.addEventListener("mousedown",k=>{k.button===1&&(k.preventDefault(),this.plugin.openPeriodNote("quarter",t,this.app.workspace.getLeaf("tab")))});let l=t.format("MMMM"),p=r.createSpan({cls:"waypoint-clickable",text:l});p.addEventListener("click",()=>{this.plugin.openPeriodNote("month",t)}),p.addEventListener("mousedown",k=>{k.button===1&&(k.preventDefault(),this.plugin.openPeriodNote("month",t,this.app.workspace.getLeaf("tab")))});let u=t.format("YYYY"),D=r.createSpan({cls:"waypoint-clickable",text:u});D.addEventListener("click",()=>{this.plugin.openPeriodNote("year",t)}),D.addEventListener("mousedown",k=>{k.button===1&&(k.preventDefault(),this.plugin.openPeriodNote("year",t,this.app.workspace.getLeaf("tab")))});let S=a.createDiv({cls:"waypoint-calendar-today-group"}),M=S.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,m.setIcon)(M,"chevron-left"),M.addEventListener("click",()=>this.navigateMonth(-1)),S.createEl("button",{cls:"waypoint-calendar-today-btn",text:"Today"}).addEventListener("click",()=>{this.currentDisplayMonth=(0,m.moment)().month(),this.currentDisplayYear=(0,m.moment)().year(),this.selectedDate=null,this.redraw()});let C=S.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,m.setIcon)(C,"chevron-right"),C.addEventListener("click",()=>this.navigateMonth(1));let I=S.createEl("button",{cls:"waypoint-calendar-nav-btn waypoint-calendar-pick-btn"});(0,m.setIcon)(I,"calendar-search"),(0,m.setTooltip)(I,"Go to date");let h=S.createEl("input",{type:"date",cls:"waypoint-calendar-pick-input"});h.tabIndex=-1,h.value=((le=this.selectedDate)!=null?le:i).format("YYYY-MM-DD"),h.addEventListener("change",()=>{let k=(0,m.moment)(h.value,"YYYY-MM-DD",!0);k.isValid()&&this.showDate(k)}),I.addEventListener("click",()=>{try{h.showPicker()}catch(k){h.click()}});let g=n.createEl("table"),x=g.createEl("thead").createEl("tr");x.createEl("th",{text:""});let b=["sun","mon","tue","wed","thu","fri","sat"],w=this.plugin.settings.calendar.firstDayOfWeek;for(let k=0;k<7;k++){let O=(w+k)%7;x.createEl("th",{text:b[O]})}let F=g.createEl("tbody"),R=ye(this.currentDisplayYear,this.currentDisplayMonth,this.plugin.settings.calendar.firstDayOfWeek),L=this.plugin.settings.calendar.showNoteIndicators&&this.plugin.settings.calendar.indicatorMode==="systems"?this.plugin.getDateSystemIndicators(R.reduce((k,O)=>k.concat(O.days.map(H=>H.date)),[])):null;for(let k of R){let O=F.createEl("tr"),H=O.createEl("td",{cls:"waypoint-weeknum"});H.setText(String(k.weekNumber));let ce=k.days[0].date;H.addEventListener("click",()=>{this.plugin.openPeriodNote("week",ce)}),H.addEventListener("mousedown",T=>{T.button===1&&(T.preventDefault(),this.plugin.openPeriodNote("week",ce,this.app.workspace.getLeaf("tab")))});for(let T of k.days){let A=O.createEl("td",{cls:"waypoint-day"});if(A.setText(String(T.dayOfMonth)),T.isCurrentMonth||A.addClass("other-month"),T.isToday&&A.addClass("today"),this.selectedDate&&T.date.isSame(this.selectedDate,"day")&&A.addClass("is-selected"),this.plugin.settings.calendar.showNoteIndicators){let N=T.date.format("YYYY-MM-DD");if(this.plugin.settings.calendar.indicatorMode==="any")this.plugin.hasNoteForDate(N)&&A.addClass("has-note");else{let de=(L==null?void 0:L.get(N))||[];if(de.length>0){let we=A.createDiv({cls:"waypoint-day-indicators"});for(let pe of de){let he=we.createSpan({cls:"waypoint-day-indicator"});he.style.setProperty("--waypoint-indicator-color",pe.color),(0,m.setTooltip)(he,pe.name)}}}}A.addEventListener("click",()=>{this.plugin.openPeriodNote("day",T.date)}),A.addEventListener("mousedown",N=>{N.button===1&&(N.preventDefault(),this.plugin.openPeriodNote("day",T.date,this.app.workspace.getLeaf("tab")))}),A.addEventListener("contextmenu",N=>{N.preventDefault(),N.stopPropagation(),this.showDayContextMenu(N,T.date)})}}}navigateMonth(e){let n=(0,m.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth}).add(e,"month");this.currentDisplayMonth=n.month(),this.currentDisplayYear=n.year(),this.selectedDate=null,this.redraw()}showDayContextMenu(e,n){let i=new m.Menu;i.addItem(t=>t.setTitle(n.format("dddd, MMMM D, YYYY")).setIsLabel(!0));for(let t of this.plugin.findDateSystemNotes(n)){let a=t.multiple||t.notes.length===0;if(t.notes.length+(a?1:0)===0)continue;i.addSeparator();for(let s of t.notes)i.addItem(o=>o.setTitle(s.label).setIcon(t.system.icon).onClick(l=>this.focusFile(s.file,m.Keymap.isModEvent(l))));if(!a)continue;let r=t.system.name.toLowerCase();i.addItem(s=>s.setTitle(t.multiple?`New ${r} note\u2026`:`New ${r} note`).setIcon("plus").onClick(o=>this.createDateSystemNote(t,n,m.Keymap.isModEvent(o))))}i.showAtPosition({x:e.clientX,y:e.clientY})}createDateSystemNote(e,n,i){if(!e.multiple){this.plugin.openDateSystemNote(e.system,n,{leaf:i?this.app.workspace.getLeaf(i):void 0});return}let t=e.system.name;new U(this.app,{title:`New ${t.toLowerCase()} note`,placeholder:`${t} with\u2026`,cta:"Create"},a=>{this.plugin.openDateSystemNote(e.system,n,{title:a,leaf:i?this.app.workspace.getLeaf(i):void 0})}).open()}renderRecentFiles(e){var C,I;let n=this.plugin.settings.recentFiles,i=e.createDiv({cls:"waypoint-section waypoint-recent-files"}),t=i.createDiv({cls:"waypoint-section-header"});t.createSpan({text:"Recent Files"});let a=t.createDiv({cls:"waypoint-recent-show"}),r=[{value:"all",label:"all",tooltip:"Opened or changed"},{value:"opened",label:"opened",tooltip:"Files you opened"},{value:"changed",label:"changed",tooltip:"Files that changed, by you or in the background"}];for(let h of r){let g=a.createSpan({cls:`waypoint-recent-show-option${n.show===h.value?" is-active":""}`,text:h.label});(0,m.setTooltip)(g,h.tooltip),g.addEventListener("click",()=>{n.show!==h.value&&(n.show=h.value,this.plugin.saveSettings(),this.redraw())})}let s=W(this.plugin.recentFiles,n.show);if(s.length===0){i.createDiv({cls:"nav-file",text:"No recent files"});return}let o=h=>{var x,b;let g=this.app.vault.getFileByPath(h),v=g?(b=(x=this.app.metadataCache.getFileCache(g))==null?void 0:x.frontmatter)==null?void 0:b.type:null;return typeof v=="string"?v:null},l=n.types.filter(h=>h.type);if(!n.showTypeFilter)this.recentFilesFilter=null;else{let h=new Map;for(let g of l)h.set(g.type,0);for(let g of s){let v=o(g.path);v!==null&&(l.length>0&&!h.has(v)||h.set(v,((C=h.get(v))!=null?C:0)+1))}if(h.size>0){let g=i.createDiv({cls:"waypoint-recent-filter"});g.createSpan({cls:`waypoint-recent-pill${this.recentFilesFilter?"":" is-active"}`,text:"all"}).addEventListener("click",()=>{this.recentFilesFilter=null,this.redraw()});let x=[...h.entries()];l.length===0&&x.sort((b,w)=>w[1]-b[1]);for(let[b,w]of x){let F=g.createSpan({cls:`waypoint-recent-pill${this.recentFilesFilter===b?" is-active":""}`});F.setText(`${b} ${w}`),F.addEventListener("click",()=>{this.recentFilesFilter=this.recentFilesFilter===b?null:b,this.redraw()})}}}let p=this.recentFilesFilter?s.filter(h=>o(h.path)===this.recentFilesFilter):s,u=new Map(l.filter(h=>h.icon).map(h=>[h.type,h.icon])),D=u.size>0,S=this.app.workspace.getActiveFile(),M=i.createDiv({cls:"nav-folder mod-root"}),B=M.createDiv({cls:"nav-folder-children"});for(let h of p){let g=B.createDiv({cls:"tree-item nav-file"}),v=g.createDiv({cls:"tree-item-self is-clickable nav-file-title"});if(D){let w=v.createDiv({cls:"waypoint-recent-icon"}),F=u.get((I=o(h.path))!=null?I:"");F&&(0,m.setIcon)(w,F)}if(v.createDiv({cls:"tree-item-inner nav-file-title-content"}).setText(h.basename),v.createDiv({cls:"tree-item-spacer"}),h.changedInBackground){let w=v.createDiv({cls:"waypoint-recent-changed"});(0,m.setTooltip)(w,"Changed in the background")}let b=v.createDiv({cls:"waypoint-recent-remove"});(0,m.setIcon)(b,"x"),b.addEventListener("click",w=>{w.stopPropagation(),this.plugin.recentFiles=this.plugin.recentFiles.filter(F=>F.path!==h.path),this.plugin.persistRecentFiles(),this.redraw()}),(0,m.setTooltip)(g,h.path),S&&h.path===S.path&&v.addClass("is-active"),v.setAttr("draggable","true"),v.addEventListener("dragstart",w=>{let F=this.app.metadataCache.getFirstLinkpathDest(h.path,"");if(F){let R=Me(this.app),L=R.dragFile(w,F);R.onDragStart(w,L)}}),v.addEventListener("mouseover",w=>{this.app.workspace.trigger("hover-link",{event:w,source:E,hoverParent:M,targetEl:g,linktext:h.path})}),v.addEventListener("contextmenu",w=>{let F=new m.Menu;F.addItem(L=>L.setSection("action").setTitle("Open in new tab").setIcon("file-plus").onClick(()=>this.focusFile(h,"tab"))),F.addItem(L=>L.setSection("action").setTitle("Add to bookmarks").setIcon("bookmark").onClick(()=>{this.plugin.addBookmark(h.path,h.basename,"file"),new m.Notice(`Bookmarked: ${h.basename}`)}));let R=this.app.vault.getAbstractFileByPath(h.path);R&&this.app.workspace.trigger("file-menu",F,R,"link-context-menu"),F.showAtPosition({x:w.clientX,y:w.clientY})}),v.addEventListener("click",w=>{let F=m.Keymap.isModEvent(w);this.focusFile(h,F)}),v.addEventListener("mousedown",w=>{w.button===1&&(w.preventDefault(),this.focusFile(h,"tab"))})}}focusFile(e,n){let i=this.app.vault.getFiles().find(t=>t.path===e.path);i?this.app.workspace.getLeaf(n).openFile(i):(new m.Notice("Cannot find file"),this.plugin.recentFiles=this.plugin.recentFiles.filter(t=>t.path!==e.path),this.plugin.persistRecentFiles(),this.redraw())}renderFavorites(e){let n=e.createDiv({cls:"waypoint-section waypoint-favorites"}),i=n.createDiv({cls:"waypoint-section-header"});i.setText("Waypoint Bookmarks");let t=i.createEl("button",{cls:"waypoint-header-more"});if((0,m.setIcon)(t,"more-horizontal"),(0,m.setTooltip)(t,"Add bookmark"),t.addEventListener("click",a=>{let r=new m.Menu;r.addItem(s=>{s.setTitle("Add current file").setIcon("file-plus").onClick(()=>{let o=this.app.workspace.getActiveFile();o&&this.plugin.addBookmark(o.path,o.basename,"file")})}),r.addItem(s=>{s.setTitle("Add as parent note").setIcon("folder-plus").onClick(()=>{let o=this.app.workspace.getActiveFile();if(!o)return;let l=this.plugin.addBookmark(o.path,o.basename,"group","");l.filePath=o.path,this.plugin.saveWaypointData(),this.redraw()})}),r.addItem(s=>{s.setTitle("New group").setIcon("folder-plus").onClick(()=>{this.plugin.addBookmark("","New Group","group","")})}),r.addSeparator(),r.addItem(s=>{s.setTitle("Add separator").setIcon("minus").onClick(()=>{this.plugin.addBookmark("","","separator")})}),r.addItem(s=>{s.setTitle("Add spacer").setIcon("space").onClick(()=>{this.plugin.addBookmark("","","spacer")})}),r.showAtPosition({x:a.clientX,y:a.clientY})}),this.plugin.waypointData.bookmarks.length===0){n.createDiv({cls:"waypoint-bookmark-item",text:"No bookmarks"});return}this.renderBookmarkList(n,this.plugin.waypointData.bookmarks,0)}renderBookmarkList(e,n,i){for(let t=0;t{l.stopPropagation(),l.preventDefault(),this.showBookmarkContextMenu(l,a)});continue}if(a.type==="spacer"){let o=e.createDiv({cls:"waypoint-bookmark-item waypoint-bookmark-spacer"});o.setAttr("draggable","true"),o.setAttr("data-bm-id",a.id),o.style.paddingLeft=`${8+i*16}px`,o.style.cursor="grab",this.attachBookmarkDragHandlers(o,e,a,!1),o.addEventListener("contextmenu",l=>{l.stopPropagation(),l.preventDefault(),this.showBookmarkContextMenu(l,a)});continue}let r=a.type==="group",s=e.createDiv({cls:`waypoint-bookmark-item${r?" waypoint-bookmark-group":""}${a.collapsed?" collapsed":""}`});if(s.setAttr("draggable","true"),s.setAttr("data-bm-id",a.id),r||(s.style.paddingLeft=`${8+i*16}px`),this.attachBookmarkDragHandlers(s,e,a,!0),r){let o=s.createDiv({cls:"waypoint-bm-icon"});a.icon&&(0,m.setIcon)(o,a.icon);let l=s.createDiv({cls:"waypoint-bm-label",text:a.label}),p=s.createDiv({cls:"waypoint-bm-chevron"});(0,m.setIcon)(p,"chevron-down"),p.addEventListener("click",D=>{D.stopPropagation(),this.plugin.updateBookmark(a.id,{collapsed:!a.collapsed})}),s.addEventListener("click",D=>{if(a.filePath){let S=this.app.vault.getFileByPath(a.filePath);if(S){let M=m.Keymap.isModEvent(D);this.app.workspace.getLeaf(M).openFile(S);return}}this.plugin.updateBookmark(a.id,{collapsed:!a.collapsed})}),s.addEventListener("mousedown",D=>{if(D.button===1&&a.filePath){D.preventDefault();let S=this.app.vault.getFileByPath(a.filePath);S&&this.app.workspace.getLeaf("tab").openFile(S)}});let u=e.createDiv({cls:`waypoint-bookmark-children${a.collapsed?" collapsed":""}`});a.children&&a.children.length>0&&this.renderBookmarkList(u,a.children,i+1)}else{let o=s.createDiv({cls:"waypoint-bm-icon"});a.icon&&(0,m.setIcon)(o,a.icon);let l=s.createDiv({cls:"waypoint-bm-label",text:a.label});if(a.children&&a.children.length>0){let p=s.createDiv({cls:"waypoint-bm-chevron"});(0,m.setIcon)(p,"chevron-down"),p.addEventListener("click",u=>{u.stopPropagation(),this.plugin.updateBookmark(a.id,{collapsed:!a.collapsed})}),a.collapsed&&(s.addClass("collapsed"),p.style.transform="rotate(-90deg)")}if((0,m.setTooltip)(s,a.filePath),s.addEventListener("click",p=>{if(a.filePath){let u=this.app.vault.getFileByPath(a.filePath);if(u){let D=m.Keymap.isModEvent(p);this.app.workspace.getLeaf(D).openFile(u)}else new m.Notice("File not found"),this.plugin.removeBookmark(a.id)}}),s.addEventListener("mousedown",p=>{if(p.button===1&&a.filePath){p.preventDefault();let u=this.app.vault.getFileByPath(a.filePath);u&&this.app.workspace.getLeaf("tab").openFile(u)}}),a.children&&a.children.length>0){let p=e.createDiv({cls:`waypoint-bookmark-children${a.collapsed?" collapsed":""}`});this.renderBookmarkList(p,a.children,i+1)}}s.addEventListener("contextmenu",o=>{o.stopPropagation(),o.preventDefault(),this.showBookmarkContextMenu(o,a)})}}showBookmarkContextMenu(e,n){let i=new m.Menu;if(n.type==="separator"||n.type==="spacer"){i.addItem(t=>t.setTitle("Remove").setIcon("trash").onClick(()=>this.plugin.removeBookmark(n.id))),i.showAtPosition({x:e.clientX,y:e.clientY});return}n.type==="file"?(i.addItem(t=>t.setTitle("Open in new tab").setIcon("file-plus").onClick(()=>{let a=this.app.vault.getFileByPath(n.filePath);a&&this.app.workspace.getLeaf("tab").openFile(a)})),i.addSeparator(),i.addItem(t=>t.setTitle("Rename").setIcon("pencil").onClick(()=>this.promptRename(n))),i.addItem(t=>t.setTitle("Change icon").setIcon("image").onClick(()=>this.promptIcon(n))),i.addSeparator(),i.addItem(t=>t.setTitle("Remove").setIcon("trash").onClick(()=>this.plugin.removeBookmark(n.id)))):n.type==="group"&&(n.filePath&&(i.addItem(t=>t.setTitle("Open in new tab").setIcon("file-plus").onClick(()=>{let a=this.app.vault.getFileByPath(n.filePath);a&&this.app.workspace.getLeaf("tab").openFile(a)})),i.addSeparator()),i.addItem(t=>t.setTitle("Rename").setIcon("pencil").onClick(()=>this.promptRename(n))),i.addItem(t=>t.setTitle("Change icon").setIcon("image").onClick(()=>this.promptIcon(n))),i.addSeparator(),i.addItem(t=>t.setTitle("Add child bookmark").setIcon("file-plus").onClick(()=>{let a=this.app.workspace.getActiveFile();if(!a){new m.Notice("No active file");return}let r={id:`bm-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,type:"file",label:a.basename,filePath:a.path,icon:"",children:[],collapsed:!1,indent:n.indent+1};n.children.push(r),this.plugin.saveWaypointData(),this.redraw()})),i.addItem(t=>t.setTitle("Add child note").setIcon("folder-plus").onClick(()=>{let a=this.app.workspace.getActiveFile();if(!a){new m.Notice("No active file");return}let r={id:`bm-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,type:"group",label:a.basename,filePath:a.path,icon:"",children:[],collapsed:!1,indent:n.indent+1};n.children.push(r),this.plugin.saveWaypointData(),this.redraw()})),i.addItem(t=>t.setTitle("New sub-group").setIcon("folder-plus").onClick(()=>{let a={id:`bm-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,type:"group",label:"New Group",filePath:"",icon:"",children:[],collapsed:!1,indent:n.indent+1};n.children.push(a),this.plugin.saveWaypointData(),this.redraw()})),i.addSeparator(),i.addItem(t=>t.setTitle("Remove").setIcon("trash").onClick(()=>this.plugin.removeBookmark(n.id)))),i.showAtPosition({x:e.clientX,y:e.clientY})}attachBookmarkDragHandlers(e,n,i,t){let a=()=>{e.removeClass("waypoint-bm-drop-line"),e.removeClass("waypoint-bm-drop-below"),e.removeClass("waypoint-bm-drop-into")};e.addEventListener("dragstart",r=>{this.dragId=i.id,r.dataTransfer.effectAllowed="move",r.dataTransfer.setData("text/plain",i.id),e.addClass("waypoint-bm-dragging")}),e.addEventListener("dragend",()=>{this.dragId=null,n.querySelectorAll(".waypoint-bm-dragging, .waypoint-bm-drop-line, .waypoint-bm-drop-below, .waypoint-bm-drop-into").forEach(r=>{r.removeClass("waypoint-bm-dragging"),r.removeClass("waypoint-bm-drop-line"),r.removeClass("waypoint-bm-drop-below"),r.removeClass("waypoint-bm-drop-into")})}),e.addEventListener("dragenter",r=>{r.preventDefault(),!(!this.dragId||this.dragId===i.id)&&this.showDropIndicator(e,r,t)}),e.addEventListener("dragover",r=>{r.preventDefault(),!(!this.dragId||this.dragId===i.id)&&this.showDropIndicator(e,r,t)}),e.addEventListener("dragleave",a),e.addEventListener("drop",r=>{var l,p;r.preventDefault(),this.dragId=null,a();let s=(l=r.dataTransfer)==null?void 0:l.getData("text/plain");if(!s||s===i.id)return;let o=this.dropZones.get(e);t&&(o!=null&&o.into)?i.type==="group"?this.moveBookmarkToGroup(s,i.id):this.createParentNoteAndMove(s,i.id):this.moveBookmarkToPosition(s,i.id,(p=o==null?void 0:o.above)!=null?p:!1)})}showDropIndicator(e,n,i){let t=e.parentElement;t&&t.querySelectorAll(".waypoint-bm-drop-line, .waypoint-bm-drop-below, .waypoint-bm-drop-into").forEach(s=>{s.removeClass("waypoint-bm-drop-line"),s.removeClass("waypoint-bm-drop-below"),s.removeClass("waypoint-bm-drop-into")});let a=e.getBoundingClientRect(),r=n.clientY;if(i){let s=a.top+a.height*.25,o=a.top+a.height*.75;ro?(e.addClass("waypoint-bm-drop-line"),e.addClass("waypoint-bm-drop-below"),this.dropZones.set(e,{above:!1,into:!1})):(e.addClass("waypoint-bm-drop-into"),this.dropZones.set(e,{above:!1,into:!0}))}else{let s=r{let r=a.findIndex(s=>s.id===e);if(r>=0){let[s]=a.splice(r,1);return s}for(let s of a){let o=i(s.children);if(o)return o}return null},t=i(this.plugin.waypointData.bookmarks);if(t){if(n){let a=(r,s)=>r.id===s?!0:r.children.some(o=>a(o,s));if(t.id===n||a(t,n))return}if(n){let a=s=>{for(let o of s){if(o.id===n)return o;let l=a(o.children);if(l)return l}return null},r=a(this.plugin.waypointData.bookmarks);r&&(t.indent=r.indent+1,r.children.push(t))}else t.indent=0,this.plugin.waypointData.bookmarks.push(t);this.plugin.saveWaypointData(),this.redraw()}}createParentNoteAndMove(e,n){let i=s=>{let o=s.findIndex(l=>l.id===e);if(o>=0){let[l]=s.splice(o,1);return l}for(let l of s)if(l.children){let p=i(l.children);if(p)return p}return null},t=i(this.plugin.waypointData.bookmarks);if(!t)return;let a=s=>{for(let o of s){if(o.id===n)return o;if(o.children){let l=a(o.children);if(l)return l}}return null},r=a(this.plugin.waypointData.bookmarks);r&&(t.indent=r.indent+1,r.children.push(t),this.plugin.saveWaypointData(),this.redraw())}moveBookmarkToPosition(e,n,i){let t=o=>{let l=o.findIndex(p=>p.id===e);if(l>=0){let[p]=o.splice(l,1);return{item:p,parent:o}}for(let p of o)if(p.children){let u=t(p.children);if(u.item)return u}return{item:null,parent:[]}},{item:a}=t(this.plugin.waypointData.bookmarks);if(!a)return;let r=o=>{let l=o.findIndex(p=>p.id===n);if(l>=0)return{parent:o,idx:l};for(let p of o)if(p.children){let u=r(p.children);if(u)return u}return null},s=r(this.plugin.waypointData.bookmarks);if(!s)a.indent=0,this.plugin.waypointData.bookmarks.push(a);else{let o=i?s.idx:s.idx+1;s.parent.splice(o,0,a)}this.plugin.saveWaypointData(),this.redraw()}promptRename(e){new U(this.app,{title:"Rename bookmark",initialValue:e.label},n=>{n&&n.trim()&&this.plugin.updateBookmark(e.id,{label:n.trim()})}).open()}promptIcon(e){new G(this.app,e.icon,n=>{this.plugin.updateBookmark(e.id,{icon:n})}).open()}},U=class extends m.Modal{constructor(d,e,n){super(d),this.options=e,this.onSubmit=n}onOpen(){var t,a,r;this.titleEl.setText(this.options.title);let d=this.contentEl.createEl("input",{type:"text",value:(t=this.options.initialValue)!=null?t:"",placeholder:(a=this.options.placeholder)!=null?a:""});d.style.width="100%",d.style.marginBottom="12px",d.focus(),d.select();let e=this.contentEl.createDiv({cls:"modal-button-container"}),n=e.createEl("button",{text:"Cancel",cls:"mod-cta"});n.style.marginRight="8px",n.addEventListener("click",()=>this.close()),e.createEl("button",{text:(r=this.options.cta)!=null?r:"Save",cls:"mod-cta"}).addEventListener("click",()=>{this.onSubmit(d.value),this.close()}),d.addEventListener("keydown",s=>{s.key==="Enter"&&(this.onSubmit(d.value),this.close())})}onClose(){this.contentEl.empty()}},Q=null;function Ie(){return Q||(Q=(async()=>{try{return await(await fetch("https://cdn.jsdelivr.net/npm/lucide-static@0.517.0/tags.json")).json()}catch(c){try{return await(await fetch("https://lucide.dev/api/tags")).json()}catch(d){return Q=null,Pe}}})()),Q}var G=class extends m.Modal{constructor(e,n,i){super(e);this.allIcons=[];this.tagsMap={};this.loaded=!1;this.selected=n,this.onSubmit=i}async onOpen(){let e=this.contentEl;e.style.display="flex",e.style.flexDirection="column",e.style.gap="10px",this.titleEl.setText("Change icon");let n=e.createDiv({cls:"waypoint-icon-preview"});n.style.display="flex",n.style.alignItems="center",n.style.gap="10px",n.style.padding="12px 16px",n.style.borderRadius="8px",n.style.background="var(--background-secondary)",n.style.minHeight="48px";let i=n.createSpan();i.style.display="flex",this.selected&&(0,m.setIcon)(i,this.selected);let t=n.createSpan();t.style.fontWeight="var(--font-medium)",t.style.fontSize="var(--font-ui-medium)",t.setText(this.selected||"No icon");let a=e.createEl("input",{type:"text",placeholder:"Type to search (e.g. arrow, chart, home)..."});Object.assign(a.style,{width:"100%",boxSizing:"border-box",padding:"8px 10px",borderRadius:"6px",border:"1px solid var(--background-modifier-border)",background:"var(--background-primary)",color:"var(--text-normal)",fontSize:"var(--font-ui-medium)"}),a.focus();let r=e.createDiv({cls:"waypoint-icon-grid"});r.style.display="grid",r.style.gridTemplateColumns="repeat(auto-fill, minmax(52px, 1fr))",r.style.gap="4px",r.style.maxHeight="320px",r.style.overflowY="auto",r.style.padding="2px 0";let s=e.createDiv();s.style.display="flex",s.style.justifyContent="space-between",s.style.alignItems="center",s.style.fontSize="var(--font-ui-smaller)",s.style.color="var(--text-muted)",s.style.padding="0 4px";let o=s.createSpan();o.setText("Loading\u2026"),this.loadIcons().then(()=>{this.loaded=!0,o.setText(this.allIcons.length+" icons"),p(a.value)});let l,p=B=>{if(r.empty(),!this.loaded){r.createDiv({text:"Loading\u2026"});return}let C=B.toLowerCase().trim(),I=C?this.allIcons.filter(h=>{if(h.includes(C))return!0;let g=this.tagsMap[h];return g?g.some(v=>v.includes(C)):!1}).slice(0,80):this.allIcons.slice(0,80);if(I.length===0){let h=r.createDiv();h.style.gridColumn="1 / -1",h.style.textAlign="center",h.style.color="var(--text-muted)",h.style.padding="20px",h.setText('No icons match "'+B+'"');return}for(let h of I){let g=r.createDiv();g.setAttr("data-icon",h),g.style.display="flex",g.style.alignItems="center",g.style.justifyContent="center",g.style.aspectRatio="1",g.style.borderRadius="6px",g.style.cursor="var(--cursor-link, pointer)",g.style.transition="background 80ms",g.setAttr("title",h),h===this.selected?(g.style.background="var(--interactive-accent)",g.style.color="var(--text-on-accent)"):g.style.color="var(--text-muted)";let v=g.createSpan();v.style.display="flex",(0,m.setIcon)(v,h),g.addEventListener("mouseenter",()=>{h!==this.selected&&(g.style.background="var(--background-modifier-hover)")}),g.addEventListener("mouseleave",()=>{h!==this.selected&&(g.style.background="")}),g.addEventListener("click",()=>{this.selected=h,p(B),i.empty(),(0,m.setIcon)(i,h),t.setText(h),r.querySelectorAll("div[data-icon]").forEach(x=>{let b=x;b.getAttr("data-icon")===h?(b.style.background="var(--interactive-accent)",b.style.color="var(--text-on-accent)"):(b.style.background="",b.style.color="var(--text-muted)")})})}o.setText(I.length+" of "+this.allIcons.length+" icons")};a.addEventListener("input",()=>{window.clearTimeout(l),l=window.setTimeout(()=>p(a.value),60)}),a.addEventListener("keydown",B=>{B.key==="Escape"&&this.close()});let u=e.createDiv({cls:"modal-button-container"});u.createEl("button",{text:"No icon",cls:"waypoint-icon-clear"}).addEventListener("click",()=>{this.onSubmit(""),this.close()}),u.createEl("button",{text:"Cancel"}).addEventListener("click",()=>this.close());let M=u.createEl("button",{text:"Save",cls:"mod-cta"});M.style.marginLeft="8px",M.addEventListener("click",()=>{this.onSubmit(this.selected),this.close()})}onClose(){this.contentEl.empty()}async loadIcons(){let e=await Ie();this.tagsMap=e,this.allIcons=Object.keys(e).sort()}},Pe={file:[],folder:[],star:[],heart:[],bookmark:[],flag:[],pin:[],tag:[],book:[],"book-open":[],library:[],calendar:[],"calendar-days":[],clock:[],home:[],inbox:[],mail:[],search:[],settings:[],cog:[],user:[],users:[],zap:[],sparkles:[],target:[],link:[],globe:[],edit:[],pencil:[],anchor:[],award:[],bell:[],"bell-ring":[],brain:[],briefcase:[],camera:[],"chart-bar":[],"chart-line":[],"chart-pie":[],check:[],"check-circle":[],"chevron-down":[],"chevron-left":[],"chevron-right":[],"chevron-up":[],circle:[],clipboard:[],code:[],command:[],compass:[],copy:[],"credit-card":[],crown:[],database:[],download:[],"external-link":[],eye:[],"eye-off":[],"file-text":[],filter:[],fingerprint:[],flashlight:[],"folder-open":[],"folder-plus":[],gift:[],"git-branch":[],"git-commit":[],"git-merge":[],"git-pull-request":[],github:[],grid:[],hash:[],headphones:[],image:[],info:[],key:[],layers:[],layout:[],"life-buoy":[],"link-2":[],list:[],loader:[],lock:[],"log-in":[],"log-out":[],map:[],"map-pin":[],maximize:[],megaphone:[],menu:[],"message-circle":[],"message-square":[],mic:[],minimize:[],moon:[],"more-horizontal":[],"more-vertical":[],"mouse-pointer":[],move:[],music:[],navigation:[],"navigation-2":[],package:[],palette:[],paperclip:[],pause:[],phone:[],play:[],plus:[],"plus-circle":[],power:[],printer:[],radio:[],"refresh-cw":[],repeat:[],"rotate-ccw":[],"rotate-cw":[],rss:[],save:[],scissors:[],screen:[],send:[],server:[],share:[],"share-2":[],shield:[],"shield-off":[],"shopping-bag":[],"shopping-cart":[],shuffle:[],sidebar:[],slack:[],slash:[],sliders:[],smartphone:[],smile:[],speaker:[],square:[],"stop-circle":[],sun:[],sunrise:[],sunset:[],swords:[],table:[],tablet:[],terminal:[],thermometer:[],"thumbs-down":[],"thumbs-up":[],"toggle-left":[],"toggle-right":[],tool:[],trash:[],"trash-2":[],trello:[],"trending-down":[],"trending-up":[],triangle:[],truck:[],tv:[],twitter:[],type:[],umbrella:[],unlock:[],upload:[],"user-check":[],"user-minus":[],"user-plus":[],"user-x":[],video:[],"video-off":[],voicemail:[],volume:[],"volume-1":[],"volume-2":[],"volume-x":[],watch:[],wifi:[],"wifi-off":[],wind:[],x:[],"x-circle":[],"x-square":[],youtube:[],"zap-off":[],"zoom-in":[],"zoom-out":[],"arrow-down":[],"arrow-left":[],"arrow-right":[],"arrow-up":[],airplay:[],"alarm-clock":[],archive:[],armchair:[],atom:[],baby:[],backpack:[],badge:[],"badge-check":[],ban:[],banknote:[],barcode:[],bath:[],battery:[],"battery-charging":[],beer:[],bike:[],bird:[],bluetooth:[],bolt:[],bone:[],"bookmark-plus":[],bot:[],box:[],bug:[],building:[],bus:[],cake:[],calculator:[],car:[],"clipboard-check":[],cloud:[],"cloud-download":[],"cloud-lightning":[],"cloud-rain":[],"cloud-sun":[],"cloud-upload":[],clover:[],coffee:[],coins:[],contact:[],cookie:[],"corner-down-left":[],"corner-down-right":[],"corner-up-left":[],"corner-up-right":[],crosshair:[],"dice-1":[],"dice-6":[],"dollar-sign":[],"door-open":[],drama:[],droplet:[],drum:[],egg:[],equal:[],euro:[],factory:[],fan:[],feather:[],film:[],fish:[],flame:[],flask:[],flower:[],frown:[],fuel:[],gamepad:[],gauge:[],gem:[],ghost:[],glasses:[],"graduation-cap":[],hammer:[],"hard-drive":[],haze:[],"help-circle":[],"ice-cream":[],infinity:[],italic:[],"japanese-yen":[],keyboard:[],knife:[],lamp:[],landmark:[],languages:[],laptop:[],laugh:[],leaf:[],lightbulb:[],"list-plus":[],magnet:[],"mail-plus":[],meh:[],microscope:[],milestone:[],"minimize-2":[],monitor:[],mountain:[],mouse:[],network:[],newspaper:[],"package-check":[],"package-search":[],"paint-bucket":[],parking:[],"party-popper":[],"pen-tool":[],percent:[],"person-standing":[],"picture-in-picture-2":[],plane:[],plug:[],podcast:[],pointer:[],"pound-sterling":[],puzzle:[],"qr-code":[],rabbit:[],radar:[],rainbow:[],rocket:[],"roller-coaster":[],route:[],ruler:[],sailboat:[],scale:[],scan:[],school:[],ship:[],shirt:[],"shopping-basket":[],shovel:[],sigma:[],siren:[],skull:[],snowflake:[],soup:[],space:[],sparkle:[],stamp:[],store:[],subscript:[],superscript:[],syringe:[],tent:[],"tent-tree":[],"test-tube":[],theater:[],timer:[],train:[],"tree-deciduous":[],"tree-pine":[],trophy:[],typing:[],utensils:[],vibrate:[],wallet:[],wand:[],warehouse:[],waves:[],webcam:[],wheat:[],wine:[],wrench:[]};var Z=class extends y.AbstractInputSuggest{constructor(e,n){super(e,n);this.inputEl=n}getSuggestions(e){let n=e.toLowerCase();return this.app.vault.getMarkdownFiles().filter(i=>i.path.toLowerCase().includes(n)).slice(0,200)}renderSuggestion(e,n){n.setText(e.path.replace(/\.md$/,""))}selectSuggestion(e){this.setValue(e.path.replace(/\.md$/,"")),this.inputEl.trigger("input"),this.close()}},J=class extends y.PluginSettingTab{constructor(e,n,i,t){super(e,n);this.activeTab="calendar";this.plugin=n,this.settings=i,this.onSettingsChange=t}display(){let{containerEl:e}=this;e.empty();let n=e.createDiv({cls:"waypoint-settings-tabs"}),i=[{key:"calendar",label:"Calendar"},{key:"periodic",label:"Periodic Notes"},{key:"systems",label:"Date systems"},{key:"recent",label:"Recent Files"},{key:"display",label:"Display"},{key:"about",label:"About"}];for(let a of i)n.createEl("button",{cls:`waypoint-settings-tab${this.activeTab===a.key?" is-active":""}`,text:a.label}).addEventListener("click",()=>{this.activeTab=a.key,this.display()});let t=e.createDiv({cls:"waypoint-settings-content"});switch(this.activeTab){case"calendar":this.renderCalendarTab(t);break;case"periodic":this.renderPeriodicTab(t);break;case"systems":this.renderSystemsTab(t);break;case"recent":this.renderRecentTab(t);break;case"display":this.renderDisplayTab(t);break;case"about":this.renderAboutTab(t);break}}renderCalendarTab(e){new y.Setting(e).setName("First day of week").setDesc("Which day the calendar week starts on.").addDropdown(n=>{n.addOption("0","Sunday").addOption("1","Monday").setValue(String(this.settings.calendar.firstDayOfWeek)).onChange(i=>{this.settings.calendar.firstDayOfWeek=parseInt(i,10),this.saveAndRefresh()})}),new y.Setting(e).setName("Show note indicators").setDesc("Show a dot on days that have existing notes.").addToggle(n=>{n.setValue(this.settings.calendar.showNoteIndicators).onChange(i=>{this.settings.calendar.showNoteIndicators=i,this.saveAndRefresh()})}),new y.Setting(e).setName("Indicator style").setDesc("Show one neutral dot for any dated note, or one coloured dot for each configured date system.").addDropdown(n=>{n.addOption("any","Single dot").addOption("systems","Colour by note system").setValue(this.settings.calendar.indicatorMode).onChange(i=>{this.settings.calendar.indicatorMode=i,this.saveAndRefresh()})}),new y.Setting(e).setName("Daily indicator colour").setDesc("Colour for daily-note dots when using \u201CColour by note system\u201D.").addColorPicker(n=>{n.setValue(this.settings.calendar.dailyIndicatorColor).onChange(i=>{this.settings.calendar.dailyIndicatorColor=i,this.saveAndRefresh()})})}renderPeriodicTab(e){new y.Setting(e).setName("Use existing tabs").setDesc("If a periodic note is already open, switch to its tab instead of opening it again.").addToggle(n=>{n.setValue(this.settings.reusePeriodicNoteTabs).onChange(i=>{this.settings.reusePeriodicNoteTabs=i,this.saveAndRefresh()})}),this.addPeriodNoteSettings(e,"Daily",this.settings.daily),this.addPeriodNoteSettings(e,"Weekly",this.settings.weekly),this.addPeriodNoteSettings(e,"Monthly",this.settings.monthly),this.addPeriodNoteSettings(e,"Quarterly",this.settings.quarterly),this.addPeriodNoteSettings(e,"Yearly",this.settings.yearly)}addPeriodNoteSettings(e,n,i){new y.Setting(e).setHeading().setName(n),new y.Setting(e).setName("Folder").setDesc(`Folder path for ${n.toLowerCase()} notes.`).addText(t=>{t.setPlaceholder("periodic/daily"),t.setValue(i.folder),t.onChange(a=>{i.folder=a,this.saveAndRefresh()})}),new y.Setting(e).setName("Name format").setDesc(`Date format for ${n.toLowerCase()} note filenames (moment.js format).`).addText(t=>{t.setPlaceholder("yyyy-MM-dd"),t.setValue(i.nameFormat),t.onChange(a=>{i.nameFormat=a,this.saveAndRefresh()})}),new y.Setting(e).setName("Template file").setDesc("Path to the template file. The .md extension is optional.").addText(t=>{t.setPlaceholder("Templates/Daily note"),t.setValue(i.templateFile),new Z(this.app,t.inputEl),t.onChange(a=>{i.templateFile=a,this.saveAndRefresh()})}),new y.Setting(e).setName("Type property").setDesc("Value for the 'type' frontmatter property.").addText(t=>{t.setPlaceholder("daily-note"),t.setValue(i.typeProperty),t.onChange(a=>{i.typeProperty=a,this.saveAndRefresh()})})}renderSystemsTab(e){let n=new DocumentFragment;n.createDiv({text:"A date system is a folder of notes whose filenames start with a date. Each one appears in the calendar's right-click menu for that day."}),n.createDiv({text:"The daily note is configured under Periodic Notes and always comes first in that menu."}),n.createDiv({text:"Name format is a moment.js format. Literal words need bracket escaping, e.g. YYYY-MM-DD - [Journal]."}),n.createDiv({text:"Include {title} for systems that hold many notes per date, such as meetings: the text before the token finds the existing notes, and the token marks where a typed title goes. Without it, a date has exactly one note."}),new y.Setting(e).setHeading().setName("Date systems").setDesc(n),this.settings.dateSystems.forEach((i,t,a)=>{new y.Setting(e).setHeading().setName(i.name||"Untitled system").addExtraButton(s=>{s.setIcon("arrow-up").setTooltip("Move up").setDisabled(t===0).onClick(async()=>{if(t===0)return;let o=a[t-1];a[t-1]=a[t],a[t]=o,await this.saveAndRefresh(),this.display()})}).addExtraButton(s=>{s.setIcon("arrow-down").setTooltip("Move down").setDisabled(t===a.length-1).onClick(async()=>{if(t===a.length-1)return;let o=a[t+1];a[t+1]=a[t],a[t]=o,await this.saveAndRefresh(),this.display()})}).addExtraButton(s=>{s.setIcon("trash").setTooltip("Delete this date system").onClick(async()=>{a.splice(t,1),await this.saveAndRefresh(),this.display()})}),this.addSystemTextSetting(e,"Name","Label shown in the calendar right-click menu.",i,"name","Journal"),this.addSystemTextSetting(e,"Folder","Folder these notes live in.",i,"folder","periodic/journal");let r=this.addSystemTextSetting(e,"Name format","Filename format (moment.js format). Include {title} for many notes per date.",i,"nameFormat","YYYY-MM-DD - {title}");i.nameFormat&&!$(i.nameFormat)&&r.descEl.createDiv({cls:"waypoint-settings-warning",text:"This name format has no date placeholder, so it will never match or create dated notes."}),this.addSystemTextSetting(e,"Template file","Path to the template file. The .md extension is optional.",i,"templateFile","resources/template/journal",!0),this.addSystemTextSetting(e,"Type property","Fallback value for the 'type' frontmatter property, used when no template is found.",i,"typeProperty","journal-note"),this.addSystemTextSetting(e,"Icon","Lucide icon name for the menu item. Browse names at lucide.dev.",i,"icon","book-open"),new y.Setting(e).setName("Indicator colour").setDesc("Colour for this system\u2019s dot when using \u201CColour by note system\u201D.").addColorPicker(s=>{s.setValue(i.indicatorColor).onChange(o=>{i.indicatorColor=o,this.saveAndRefresh()})})}),new y.Setting(e).addButton(i=>i.setButtonText("Add date system").setCta().onClick(async()=>{this.settings.dateSystems.push(Object.assign({id:`ds-${Date.now()}-${Math.random().toString(36).slice(2,6)}`},_)),await this.saveAndRefresh(),this.display()}))}addSystemTextSetting(e,n,i,t,a,r,s){return new y.Setting(e).setName(n).setDesc(i).addText(o=>{o.setPlaceholder(r),o.setValue(t[a]),s&&new Z(this.app,o.inputEl),o.onChange(l=>{t[a]=l,this.saveAndRefresh()})})}renderRecentTab(e){new y.Setting(e).setName("Max items").setDesc("How many recently opened files, and separately how many recently changed files, to keep. A burst of synced changes cannot push out the files you opened.").addText(t=>{t.inputEl.setAttr("type","number"),t.inputEl.setAttr("placeholder","50"),t.setValue(String(this.settings.recentFiles.maxItems)),t.inputEl.onblur=()=>{let a=parseInt(t.getValue(),10);!isNaN(a)&&a>0&&(this.settings.recentFiles.maxItems=a,this.saveAndRefresh())}});let n=new DocumentFragment;n.appendText("Regex patterns for paths to exclude. One per line."),new y.Setting(e).setName("Omitted paths").setDesc(n).addTextArea(t=>{t.inputEl.setAttr("rows",4),t.setPlaceholder(`^archives/ \\.png$`),t.setValue(this.settings.recentFiles.omittedPaths.join(` `)),t.inputEl.onblur=()=>{this.settings.recentFiles.omittedPaths=t.getValue().split(` `).filter(a=>a.trim()),this.saveAndRefresh()}});let i=new DocumentFragment;i.appendText("Regex patterns for frontmatter tags to exclude. One per line."),new y.Setting(e).setName("Omitted tags").setDesc(i).addTextArea(t=>{t.inputEl.setAttr("rows",4),t.setPlaceholder(`ignore archive`),t.setValue(this.settings.recentFiles.omittedTags.join(` `)),t.inputEl.onblur=()=>{this.settings.recentFiles.omittedTags=t.getValue().split(` `).filter(a=>a.trim()),this.saveAndRefresh()}}),new y.Setting(e).setName("Type filter").setDesc("Show pills above the list to filter recent files by their frontmatter `type`.").addToggle(t=>{t.setValue(this.settings.recentFiles.showTypeFilter).onChange(a=>{this.settings.recentFiles.showTypeFilter=a,this.saveAndRefresh()})}),this.renderRecentTypes(e)}renderRecentTypes(e){let n=this.settings.recentFiles.types;new y.Setting(e).setHeading().setName("File types").setDesc("Frontmatter `type` values. A type's icon shows beside matching recent files. With the type filter on, these types are the pills, in this order; with no types listed, pills are detected automatically."),n.forEach((i,t)=>{new y.Setting(e).addText(a=>{a.setPlaceholder("meeting"),a.setValue(i.type),a.inputEl.onblur=()=>{let r=a.getValue().trim();r!==i.type&&(i.type=r,this.saveAndRefresh())}}).addExtraButton(a=>{a.setIcon(i.icon||"image-off").setTooltip(i.icon?`Icon: ${i.icon}`:"Choose icon").onClick(()=>{new G(this.app,i.icon,r=>{i.icon=r,this.saveAndRefresh(),this.display()}).open()})}).addExtraButton(a=>{a.setIcon("trash").setTooltip("Remove this type").onClick(()=>{n.splice(t,1),this.saveAndRefresh(),this.display()})})}),new y.Setting(e).addButton(i=>{i.setButtonText("Add type").onClick(()=>{n.push({type:"",icon:""}),this.display()})})}renderDisplayTab(e){new y.Setting(e).setHeading().setName("Bookmarks"),this.addSliderSetting(e,"Row size","Height of bookmark items.",this.settings.display,"rowSize",18,40,1,"px"),this.addSliderSetting(e,"Row spacing","Gap between bookmark items.",this.settings.display,"rowSpacing",0,12,1,"px"),this.addSliderSetting(e,"Indent size","Indent per nesting depth.",this.settings.display,"indentSize",8,32,2,"px"),this.addSliderSetting(e,"Font size","Label font size.",this.settings.display,"fontSize",10,18,1,"px"),this.addSliderSetting(e,"Icon size","Bookmark icon size.",this.settings.display,"iconSize",12,24,1,"px"),new y.Setting(e).setHeading().setName("Calendar"),this.addSliderSetting(e,"Cell size","Height of calendar day cells.",this.settings.display,"calendarCellSize",20,48,2,"px"),new y.Setting(e).addButton(n=>n.setButtonText("Reset to defaults").onClick(()=>{this.settings.display={...P.display},this.saveAndRefresh(),this.display()}))}addSliderSetting(e,n,i,t,a,r,s,o,l){let p=new y.Setting(e).setName(n).setDesc(`${i} (${t[a]}${l})`);p.addSlider(u=>{u.setLimits(r,s,o).setValue(t[a]).setDynamicTooltip().onChange(D=>{t[a]=D,p.setDesc(`${i} (${D}${l})`),this.saveAndRefresh()})})}async saveAndRefresh(){await this.plugin.saveSettings(),this.onSettingsChange()}renderAboutTab(e){let n=this.plugin.manifest.version,i=e.createDiv();i.style.display="flex",i.style.alignItems="center",i.style.gap="12px",i.style.marginBottom="16px";let t=i.createDiv();t.style.display="flex",t.style.alignItems="center",t.style.justifyContent="center",t.style.width="48px",t.style.height="48px",t.style.borderRadius="12px",t.style.background="var(--interactive-accent)",t.style.color="var(--text-on-accent)",t.style.fontSize="24px",(0,y.setIcon)(t,"compass");let a=i.createDiv(),r=a.createEl("h2",{text:"Waypoint Sidebar"});r.style.margin="0",r.style.lineHeight="1.2";let s=a.createDiv({text:`v${n}`});s.style.color="var(--text-muted)",s.style.fontSize="var(--font-ui-small)";let o=e.createDiv();o.style.marginBottom="20px",o.style.lineHeight="1.6",o.style.color="var(--text-normal)",o.innerHTML=["

Waypoint is a sidebar plugin that brings three essential panels into one view:

",'
    ',"
  • Calendar \u2014 a monthly grid for your periodic notes (daily, weekly, monthly, quarterly, yearly). Click any day, week, or month to open or create the corresponding note.
  • ","
  • Recent Files \u2014 a list of recently opened files with type filtering, drag-and-drop, and right-click actions.
  • ","
  • Bookmarks \u2014 custom bookmarks with icons, groups, nesting, and drag-and-drop reordering. Separate from Obsidian's native bookmarks.
  • ","
",'

Made by Olivier. Licensed under MIT.

'].join(` `)}};var ee=require("obsidian"),X=class extends ee.Modal{constructor(e,n,i){super(e);this.initialDate=n;this.onSubmit=i}onOpen(){this.titleEl.setText("Open date");let e=this.contentEl.createEl("input",{type:"date",value:this.initialDate.format("YYYY-MM-DD")});e.style.width="100%",e.style.marginBottom="12px",e.focus();let n=()=>{let t=(0,ee.moment)(e.value,"YYYY-MM-DD",!0);t.isValid()&&(this.close(),this.onSubmit(t))};e.addEventListener("keydown",t=>{t.key==="Enter"&&n()});let i=this.contentEl.createDiv({cls:"modal-button-container"});i.createEl("button",{text:"Cancel"}).addEventListener("click",()=>this.close()),i.createEl("button",{text:"Open",cls:"mod-cta"}).addEventListener("click",n)}onClose(){this.contentEl.empty()}};function oe(c,d,e){return!c||!d?null:c===d?e:c.startsWith(d+"/")?e+c.slice(d.length):null}var ne=class extends f.Plugin{constructor(){super(...arguments);this.recentFiles=[];this.savePromise=Promise.resolve();this.markdownBasenames=new Set;this.dateSystemIndicators=null;this.dateSystemIndicatorKey="";this.indicatorModeMigrated=!1;this.previouslyActive=null;this.activePath=null}async onload(){console.debug("Waypoint: loading plugin v"+this.manifest.version);let e=await this.loadData(),n=this.applySettings(e);this.applyWaypointData(e),n&&this.persistAll(),this.registerView(E,s=>new z(s,this)),this.addSettingTab(new J(this.app,this,this.settings,()=>{this.enforceRecentFilesLimit(),this.invalidateDateSystemIndicators(),this.redrawAll()})),this.addCommand({id:"waypoint-open-view",name:"Open Waypoint sidebar",callback:async()=>{let s=this.app.workspace.getLeavesOfType(E);if(s.length>0)await this.app.workspace.revealLeaf(s[0]);else{let o=this.app.workspace.getLeftLeaf(!1);o&&(await o.setViewState({type:E}),await this.app.workspace.revealLeaf(o))}}}),this.addCommand({id:"waypoint-add-bookmark",name:"Add current file as Waypoint bookmark",callback:async()=>{let s=this.app.workspace.getActiveFile();if(!s){new f.Notice("No active file");return}this.addBookmark(s.path,s.basename,"file"),new f.Notice(`Bookmarked: ${s.basename}`)}}),this.addCommand({id:"waypoint-go-to-daily",name:"Go to daily note",hotkeys:[{modifiers:["Mod","Shift","Alt"],key:"d"}],callback:async()=>{await this.openPeriodNote("day",(0,f.moment)())}}),this.addCommand({id:"waypoint-go-to-weekly",name:"Go to weekly note",hotkeys:[{modifiers:["Mod","Shift","Alt"],key:"w"}],callback:async()=>{await this.openPeriodNote("week",(0,f.moment)())}}),this.addCommand({id:"waypoint-go-to-monthly",name:"Go to monthly note",hotkeys:[{modifiers:["Mod","Shift","Alt"],key:"m"}],callback:async()=>{await this.openPeriodNote("month",(0,f.moment)())}}),this.addCommand({id:"waypoint-go-to-quarterly",name:"Go to quarterly note",hotkeys:[{modifiers:["Mod","Shift","Alt"],key:"q"}],callback:async()=>{await this.openPeriodNote("quarter",(0,f.moment)())}}),this.addCommand({id:"waypoint-go-to-yearly",name:"Go to yearly note",hotkeys:[{modifiers:["Mod","Shift","Alt"],key:"y"}],callback:async()=>{await this.openPeriodNote("year",(0,f.moment)())}}),this.addCommand({id:"waypoint-open-date",name:"Open daily note for a date\u2026",callback:()=>{new X(this.app,(0,f.moment)(),s=>{this.showDateInViews(s),this.openPeriodNote("day",s)}).open()}});let i=["next","prev"],t=["daily","weekly","monthly","quarterly","yearly"],a={next:"Next",prev:"Previous"};for(let s of t)for(let o of i){let l=`waypoint-go-to-${o}-${s}`,p=`${a[o]} ${s} note`;this.addCommand({id:l,name:p,callback:async()=>{await this.navigatePeriodNote(o)}})}this.registerEvent(this.app.workspace.on("file-open",s=>{s&&this.onFileOpen(s)})),this.registerEvent(this.app.vault.on("create",s=>this.onVaultCreate(s))),this.registerEvent(this.app.vault.on("delete",s=>this.onVaultDelete(s))),this.registerEvent(this.app.vault.on("rename",(s,o)=>this.onRename(s,o))),this.registerEvent(this.app.vault.on("modify",s=>this.onFileChange(s))),this.app.workspace.onLayoutReady(()=>{if(this.buildMarkdownIndex(),this.app.workspace.getLeavesOfType(E).length===0){let o=this.app.workspace.getLeftLeaf(!1);o&&o.setViewState({type:E})}else this.broadcastRedraw()});let r=new Date().toDateString();this.registerInterval(window.setInterval(()=>{let s=new Date().toDateString();s!==r&&(r=s,this.redrawAll())},6e5))}async onunload(){this.app.workspace.detachLeavesOfType(E)}applySettings(e){var r,s,o;let n=(e==null?void 0:e.settings)||{};this.settings=Object.assign({},P,n),this.settings.recentFiles=Object.assign({},P.recentFiles,n.recentFiles||{});let i=this.settings.recentFiles;this.settings.recentFiles.types=Array.isArray((r=n.recentFiles)==null?void 0:r.types)?n.recentFiles.types.map(l=>({...l})):((s=i.filterTags)!=null?s:[]).map(l=>({type:l,icon:""})),delete i.filterTags,delete i.updateOn,this.settings.calendar=Object.assign({},P.calendar,n.calendar||{}),this.settings.display=Object.assign({},P.display,n.display||{});for(let l of Ce)this.settings[l]=Object.assign({},P[l],n[l]||{});this.settings.dateSystems=Array.isArray(n.dateSystems)?n.dateSystems.map(l=>{let p=P.dateSystems.find(u=>u.id===l.id);return Object.assign({},p||_,l)}):P.dateSystems.map(l=>Object.assign({},l));let t=(e==null?void 0:e.indicatorModeMigrated)===!0,a=!1;return!t&&((o=n.calendar)==null?void 0:o.indicatorMode)==="any"&&(this.settings.calendar.indicatorMode="systems",a=!0),this.indicatorModeMigrated=!0,a}applyWaypointData(e){var r,s;let n=(e==null?void 0:e.waypointData)||{};this.waypointData={bookmarks:Array.isArray(n.bookmarks)?n.bookmarks:[],recentFiles:Array.isArray(n.recentFiles)?n.recentFiles:[]};let t=((s=(r=e==null?void 0:e.settings)==null?void 0:r.recentFiles)==null?void 0:s.updateOn)==="file-edit"?"changedAt":"openedAt",a=this.waypointData.recentFiles.length;this.recentFiles=K(this.waypointData.recentFiles.map((o,l)=>o.openedAt===void 0&&o.changedAt===void 0?{...o,[t]:a-l}:o),this.settings.recentFiles.maxItems),this.waypointData.recentFiles=this.recentFiles}persistAll(){let e=this.savePromise.then(()=>(this.waypointData.recentFiles=this.recentFiles,this.saveData({settings:this.settings,waypointData:this.waypointData,indicatorModeMigrated:this.indicatorModeMigrated})));return this.savePromise=e.catch(()=>{}),e}async saveSettings(){await this.persistAll()}async saveWaypointData(){await this.persistAll()}enforceRecentFilesLimit(){let e=K(this.recentFiles,this.settings.recentFiles.maxItems);e.length!==this.recentFiles.length&&(this.recentFiles=e,this.persistRecentFiles())}persistRecentFiles(){this.waypointData.recentFiles=this.recentFiles,window.clearTimeout(this.recentFilesSaveTimer),this.recentFilesSaveTimer=window.setTimeout(()=>{this.saveWaypointData()},300)}onFileOpen(e){this.activePath&&this.activePath!==e.path&&(this.previouslyActive={path:this.activePath,until:Date.now()+Le}),this.activePath=e.path,this.recordRecentFile(e,"opened")}onFileChange(e){e instanceof f.TFile&&this.recordRecentFile(e,"changed",this.isBackgroundChange(e))}isBackgroundChange(e){var i;if(((i=this.app.workspace.getActiveFile())==null?void 0:i.path)===e.path)return!1;let n=this.previouslyActive;return!(n&&n.path===e.path&&Date.now()r.path===e.path),a=n==="changed"&&t!==void 0&&this.recentFiles[0]===t&&W(this.recentFiles,"changed")[0]===t&&!(i&&!t.changedInBackground);t||(t={path:e.path,basename:e.basename},this.recentFiles.push(t)),n==="opened"?(t.openedAt=Date.now(),delete t.changedInBackground):(t.changedAt=Date.now(),i&&(t.changedInBackground=!0)),this.recentFiles=K(this.recentFiles,this.settings.recentFiles.maxItems),this.persistRecentFiles(),a||this.broadcastRedraw()}isOmittedFromRecentFiles(e){for(let r of this.settings.recentFiles.omittedPaths)try{if(new RegExp(r).test(e.path))return!0}catch(s){}let n=this.settings.recentFiles.omittedTags;if(n.length===0)return!1;let i=this.app.metadataCache.getFileCache(e),t=(i?(0,f.getAllTags)(i):null)||[];if(t.length===0)return!1;let a=t.map(r=>r.replace(/^#/,""));for(let r of n)try{let s=new RegExp(r);if(a.some(o=>s.test(o)))return!0}catch(s){}return!1}onRename(e,n){this.invalidateDateSystemIndicators();let i=this.syncIndexForRename(e,n),t=!1;for(let r of this.recentFiles){let s=oe(r.path,n,e.path);s!==null&&(r.path=s,r.basename=ve(s),t=!0)}let a=r=>{for(let s of r){if(s.filePath){let o=oe(s.filePath,n,e.path);o!==null&&(s.filePath=o,t=!0)}s.children&&a(s.children)}};a(this.waypointData.bookmarks),t&&(this.waypointData.recentFiles=this.recentFiles,this.persistAll()),(t||i)&&this.broadcastRedraw()}onVaultCreate(e){e instanceof f.TFile&&e.extension==="md"&&(this.markdownBasenames.add(e.basename),this.invalidateDateSystemIndicators()),this.app.workspace.layoutReady&&this.onFileChange(e),this.broadcastRedraw()}onVaultDelete(e){e instanceof f.TFile&&e.extension==="md"&&(this.removeFromMarkdownIndex(e.basename,e.path),this.invalidateDateSystemIndicators()),this.broadcastRedraw()}buildMarkdownIndex(){this.markdownBasenames.clear();for(let e of this.app.vault.getMarkdownFiles())this.markdownBasenames.add(e.basename)}invalidateDateSystemIndicators(){this.dateSystemIndicators=null,this.dateSystemIndicatorKey=""}removeFromMarkdownIndex(e,n){return!this.markdownBasenames.has(e)||this.app.vault.getMarkdownFiles().some(t=>t.basename===e&&t.path!==n)?!1:(this.markdownBasenames.delete(e),!0)}syncIndexForRename(e,n){if(!(e instanceof f.TFile))return!1;let i=!1,t=ve(n);return n.toLowerCase().endsWith(".md")&&(t!==e.basename||e.extension!=="md")&&(i=this.removeFromMarkdownIndex(t,n)),e.extension==="md"&&!this.markdownBasenames.has(e.basename)&&(this.markdownBasenames.add(e.basename),i=!0),i}hasNoteForDate(e){return this.markdownBasenames.has(e)}addBookmark(e,n,i="file",t=""){let r={id:`bm-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,type:i,label:n,filePath:i==="file"?e:"",icon:t,children:[],collapsed:!1,indent:0};return this.waypointData.bookmarks.push(r),this.saveWaypointData(),this.broadcastRedraw(),r}removeBookmark(e){let n=i=>{let t=i.findIndex(a=>a.id===e);if(t>=0)return i.splice(t,1),!0;for(let a of i)if(a.children&&n(a.children))return!0;return!1};n(this.waypointData.bookmarks),this.saveWaypointData(),this.broadcastRedraw()}updateBookmark(e,n){let i=a=>{for(let r of a){if(r.id===e)return r;if(r.children){let s=i(r.children);if(s)return s}}return null},t=i(this.waypointData.bookmarks);t&&(Object.assign(t,n),this.saveWaypointData(),this.broadcastRedraw())}periodAsDateSystem(e){let n=te[e],i=this.settings[n.key];return{id:n.key,name:n.label,folder:i.folder,nameFormat:i.nameFormat,templateFile:i.templateFile,typeProperty:i.typeProperty,icon:"calendar",indicatorColor:this.settings.calendar.dailyIndicatorColor}}dateSystems(){return[this.periodAsDateSystem("day"),...this.settings.dateSystems]}findDateSystemNotes(e){let n=this.dateSystems().map(i=>{let t=q(i.nameFormat);return{result:{system:i,notes:[],multiple:t.hasTitle},before:V(e,t.before),after:V(e,t.after),hasTitle:t.hasTitle,skip:!$(i.nameFormat)}});for(let i of this.app.vault.getMarkdownFiles())for(let t of n){if(t.skip)continue;let a=t.result.system;ae(i.path,a.folder)&&se(i.basename,t.before,t.after,t.hasTitle)&&t.result.notes.push({file:i,label:t.hasTitle?ue(i.basename,t.before,t.after):a.name})}for(let i of n)i.result.notes.sort((t,a)=>t.file.basename.localeCompare(a.file.basename));return n.filter(i=>!i.skip).map(i=>i.result)}getDateSystemIndicators(e){var s;let n=e.map(o=>o.format("YYYY-MM-DD")),i=this.dateSystems().filter(o=>$(o.nameFormat)).map(o=>{let l=q(o.nameFormat);return{system:o,hasTitle:l.hasTitle,dates:e.map((p,u)=>({dateStr:n[u],before:V(p,l.before),after:V(p,l.after)}))}}),t=JSON.stringify({dates:n,systems:i.map(({system:o})=>[o.id,o.name,o.folder,o.nameFormat,o.indicatorColor])});if(this.dateSystemIndicators&&this.dateSystemIndicatorKey===t)return this.dateSystemIndicators;let a=new Map;for(let o of n)a.set(o,new Set);for(let o of this.app.vault.getMarkdownFiles())for(let l of i)if(ae(o.path,l.system.folder))for(let p of l.dates)se(o.basename,p.before,p.after,l.hasTitle)&&((s=a.get(p.dateStr))==null||s.add(l.system.id));let r=new Map;for(let o of n){let l=a.get(o);r.set(o,i.filter(({system:p})=>l==null?void 0:l.has(p.id)).map(({system:p})=>({id:p.id,name:p.name,color:p.indicatorColor})))}return this.dateSystemIndicatorKey=t,this.dateSystemIndicators=r,r}async openDateSystemNote(e,n,i){if(!$(e.nameFormat)){new f.Notice(`Waypoint: ${e.name||"This"} name format needs a date placeholder.`);return}let t=q(e.nameFormat),a=V(n,t.before),r=V(n,t.after),s;if(t.hasTitle){let u=ge((i==null?void 0:i.title)||"");if(!u){new f.Notice(`Waypoint: a ${e.name.toLowerCase()} note needs a title.`);return}s=a+u+r}else s=a+r;let o=e.folder?`${e.folder}/${s}.md`:`${s}.md`,l=this.app.vault.getFileByPath(o);if(!l&&(l=await this.createDatedNote(o,e,n),!l))return;if(i!=null&&i.reuseExistingLeaf&&!i.leaf){let u=this.app.workspace.getLeavesOfType("markdown").find(D=>{var S;return((S=D.getViewState().state)==null?void 0:S.file)===l.path});if(u){await this.app.workspace.revealLeaf(u),this.app.workspace.setActiveLeaf(u,{focus:!0});return}}await((i==null?void 0:i.leaf)||this.app.workspace.getLeaf(!1)).openFile(l)}async openPeriodNote(e,n,i){await this.openDateSystemNote(this.periodAsDateSystem(e),n,{leaf:i,reuseExistingLeaf:this.settings.reusePeriodicNoteTabs})}async createDatedNote(e,n,i){let t=n.name.toLowerCase(),a=e.lastIndexOf("/"),r=a<0?"":e.slice(0,a);try{await this.ensureFolderExists(r)}catch(u){return new f.Notice(`Waypoint: could not create the folder "${r}" for the ${t} note. ${re(u)} Check Settings \u2192 Waypoint Sidebar \u2192 Periodic Notes.`,j),null}let s=n.templateFile,o=this.resolveTemplateFile(s),l;if(o)try{l=await this.app.vault.read(o)}catch(u){return new f.Notice(`Waypoint: could not read the template "${o.path}" for the ${t} note. `+re(u),j),null}else l=`--- type: ${n.typeProperty} date: ${i.format("YYYY-MM-DD")} --- `;let p;try{p=await this.app.vault.create(e,l)}catch(u){return new f.Notice(`Waypoint: could not create the ${t} note at "${e}". ${re(u)}`,j),null}return s&&!o?new f.Notice(`Created ${t} note: ${p.basename} Template "${s}" was not found, so a basic note was created instead.`,j):new f.Notice(`Created ${t} note: ${p.basename}`),p}async ensureFolderExists(e){if(!e||this.app.vault.getAbstractFileByPath(e)instanceof f.TFolder)return;let n="";for(let i of e.split("/"))if(i&&(n=n?`${n}/${i}`:i,!(this.app.vault.getAbstractFileByPath(n)instanceof f.TFolder)))try{await this.app.vault.createFolder(n)}catch(t){if(!(this.app.vault.getAbstractFileByPath(n)instanceof f.TFolder))throw t}}resolveTemplateFile(e){if(!e)return null;let n=e.toLowerCase().endsWith(".md")?e:`${e}.md`;return this.app.vault.getFileByPath(n)}detectPeriodType(e){for(let n of fe){let i=this.settings[te[n].key].nameFormat;if(!i)continue;let t=(0,f.moment)(e,i,!0);if(t.isValid())return{period:n,date:t}}return null}async navigatePeriodNote(e){let n=this.app.workspace.getActiveFile();if(!n){new f.Notice("No active file");return}let i=this.detectPeriodType(n.basename);if(!i){let o=fe.map(l=>`${te[l].label.toLowerCase()} "${this.settings[te[l].key].nameFormat}"`).join(", ");new f.Notice(`Waypoint: "${n.basename}" does not match any configured periodic note format. Expected one of: ${o}.`,j);return}let{period:t,date:a}=i,r=e==="next"?1:-1,s=t==="quarter"?a.clone().add(r*3,"months"):a.clone().add(r,`${t}s`);await this.openPeriodNote(t,s)}redrawAll(){this.broadcastRedraw()}broadcastRedraw(){let e=this.app.workspace.getLeavesOfType(E);for(let n of e)n.view instanceof z&&n.view.redraw()}showDateInViews(e){for(let n of this.app.workspace.getLeavesOfType(E))n.view instanceof z&&n.view.showDate(e)}},Ce=["daily","weekly","monthly","quarterly","yearly"],te={day:{key:"daily",label:"Daily"},week:{key:"weekly",label:"Weekly"},month:{key:"monthly",label:"Monthly"},quarter:{key:"quarterly",label:"Quarterly"},year:{key:"yearly",label:"Yearly"}},fe=["day","week","month","quarter","year"];function ve(c){return c.slice(c.lastIndexOf("/")+1).replace(/\.[^/.]+$/,"")}var j=1e4,Le=5e3;function re(c){return c instanceof Error?c.message:String(c)}function V(c,d){return d?c.format(d):""}