${i}`,e*1e3);n&&(o.noticeEl.oncontextmenu=()=>a(this,null,function*(){n()}))}function J(){return a(this,null,function*(){try{let s=yield fetch("https://obsidian.md/?"+Math.random());return s.status>=200&&s.status<300}catch(s){return!1}})}var Pe=s=>(0,W.normalizePath)(s.app.vault.configDir+"/themes")+"/",ie=(s,t,e="")=>a(void 0,null,function*(){let n=yield ne(t,s.settings.debuggingMode);if(!n)return m(s,"There is no obsidian.css file in the root path of this repository, so there is no theme to install."),!1;yield ve(s,e,n);let i=`${e}themeinstalledfrom${t}.`;return s.log(i+`[ThemeInfo](https://github.com/${t})`,!1),m(s,`${i}`,10,()=>a(void 0,null,function*(){window.open(`https://github.com/${t}`)})),setTimeout(()=>{s.app.customCss.setTheme(e)},500),!0}),ve=(s,t,e)=>a(void 0,null,function*(){let n=Pe(s),i=s.app.vault.adapter;(yield i.exists(n))===!1&&(yield i.mkdir(n)),yield i.write(n+t+".css",e)}),Se=s=>a(void 0,null,function*(){let t=yield H(s.settings.debuggingMode),e=Object.values(t).map(i=>({display:`Theme: ${i.name} (${i.repo})`,info:i})),n=new S(s);n.setSuggesterData(e),yield n.display(i=>a(void 0,null,function*(){yield ie(s,i.info.repo,i.info.name)}))}),Q=s=>("BRAT-"+s.replace("/","----")).substr(0,100),Ne=(s,t)=>a(void 0,null,function*(){s.settings.themesList=s.settings.themesList.filter(n=>n.repo!=t),s.saveSettings(),yield s.app.vault.adapter.remove(Pe(s)+Q(t)+".css");let e=`Removed ${t} from BRAT themes list and deleted from vault`;s.log(e,!0),m(s,`${e}`)}),G=(s,t)=>a(void 0,null,function*(){if((yield J())===!1){console.log("BRAT: No internet detected.");return}let e,n="Checking for beta theme updates STARTED";s.log(n,!0),t&&s.settings.notificationsEnabled&&(e=new W.Notice(`BRAT
${n}`,3e4));for(let o of s.settings.themesList){let r=yield j(o.repo,"obsidian.css");r!==o.lastUpdate&&(yield tt(s,o.repo,o.lastUpdate,r))}let i="Checking for beta theme updates COMPLETED";s.log(i,!0),t&&(s.settings.notificationsEnabled&&e.hide(),m(s,i))}),tt=(s,t,e="",n="")=>a(void 0,null,function*(){let i=yield ne(t,s.settings.debuggingMode);if(!i)return m(s,"There is no obsidian.css file in the root path of the ${cssGithubRepository} repository, so this theme cannot be updated."),!1;let o=Q(t);yield ve(s,o,i),Te(s,t,n);let r=`${o}themeupdatedfrom${t}.Fromdate:${e}to${n}`;return s.log(r+`[ThemeInfo](https://github.com/${t})`,!1),m(s,`${r}`,20,()=>a(void 0,null,function*(){window.open(`https://github.com/${t}`)})),!0});var K=require("obsidian");var C=class extends K.Modal{constructor(e,n=!1){super(e.app);this.plugin=e,this.address="",this.openSettingsTabAfterwards=n}submitForm(){return a(this,null,function*(){if(this.address==="")return;let e=this.address.replace("https://github.com/","");if(yield ye(this.plugin,e)){m(this.plugin,"This plugin is already in the list for beta testing",10);return}(yield ie(this.plugin,e,Q(e)))&&(yield we(this.plugin,e),this.close())})}onOpen(){this.contentEl.createEl("h4",{text:"Github repository for beta theme:"}),this.contentEl.createEl("form",{},e=>{new K.Setting(e).addText(n=>{n.setPlaceholder("Repository (example: https://github.com/GitubUserName/repository-name"),n.onChange(i=>{this.address=i.trim()}),n.inputEl.addEventListener("keydown",i=>a(this,null,function*(){i.key==="Enter"&&this.address!==" "&&(i.preventDefault(),yield this.submitForm())})),n.inputEl.style.width="100%",window.setTimeout(()=>{let i=document.querySelector(".setting-item-info");i&&i.remove(),n.inputEl.focus()},10)}),e.createDiv("modal-button-container",n=>{n.createEl("button",{attr:{type:"button"},text:"Never mind"}).addEventListener("click",()=>this.close()),n.createEl("button",{attr:{type:"submit"},cls:"mod-cta",text:"Add Theme"})}),e.addEventListener("submit",n=>a(this,null,function*(){n.preventDefault(),this.address!==""&&(yield this.submitForm())}))})}onClose(){return a(this,null,function*(){this.openSettingsTabAfterwards&&(yield this.plugin.app.setting.open(),yield this.plugin.app.setting.openTabById("obsidian42-brat"))})}};var Z=class extends v.PluginSettingTab{constructor(e,n){super(e,n);this.plugin=n}display(){let{containerEl:e}=this;e.empty(),e.createEl("h2",{text:this.plugin.appName}),new v.Setting(e).setName("Auto-update plugins at startup").setDesc("If enabled all beta plugins will be checked for updates each time Obsidian starts. Note: this does not update frozen version plugins.").addToggle(i=>{i.setValue(this.plugin.settings.updateAtStartup),i.onChange(o=>a(this,null,function*(){this.plugin.settings.updateAtStartup=o,yield this.plugin.saveSettings()}))}),new v.Setting(e).setName("Auto-update themes at startup").setDesc("If enabled all beta themes will be checked for updates each time Obsidian starts.").addToggle(i=>{i.setValue(this.plugin.settings.updateThemesAtStartup),i.onChange(o=>a(this,null,function*(){this.plugin.settings.updateThemesAtStartup=o,yield this.plugin.saveSettings()}))}),new v.Setting(e).setName("Ribbon Button").setDesc("Toggle ribbon button off and on.").addToggle(i=>{i.setValue(this.plugin.settings.ribbonIconEnabled),i.onChange(o=>a(this,null,function*(){this.plugin.settings.ribbonIconEnabled=o,this.plugin.settings.ribbonIconEnabled===!1?this.plugin.ribbonIcon.remove():this.plugin.showRibbonButton(),yield this.plugin.saveSettings()}))}),e.createEl("hr"),e.createEl("h2",{text:"Beta Plugin List"}),e.createEl("div",{text:'The following is a list of beta plugins added via the command palette "Add a beta plugin for testing" or "Add a beta plugin with frozen version for testing". A frozen version is a specific release of a plugin based on its releease tag. '}),e.createEl("p"),e.createEl("div",{text:"Click the x button next to a plugin to remove it from the list."}),e.createEl("p"),e.createEl("span").createEl("b",{text:"Note: "}),e.createSpan({text:"This does not delete th
Pluginhasbeenupdatedfromversion${T.version}to${l.version}.`;this.plugin.log(f+`[ReleaseInfo](https://github.com/${t}/releases/tag/${l.version})`,!1),m(this.plugin,f,30,()=>a(this,null,function*(){window.open(`https://github.com/${t}/releases/tag/${l.version}`)}))}}else i&&m(this.plugin,`No update available for ${t}`,3)}return!0})}reloadPlugin(t){return a(this,null,function*(){let e=this.plugin.app.plugins;try{yield e.disablePlugin(t),yield e.enablePlugin(t)}catch(n){this.plugin.settings.debuggingMode&&console.log("reload plugin",n)}})}updatePlugin(t,e=!1,n=!1){return a(this,null,function*(){let i=yield this.addPlugin(t,!0,e,n);return i===!1&&e===!1&&m(this.plugin,`${t}
Updateofpluginfailed.`),i})}checkForUpdatesAndInstallUpdates(t=!1,e=!1){return a(this,null,function*(){if((yield J())===!1){console.log("BRAT: No internet detected.");return}let n,i="Checking for plugin updates STARTED";this.plugin.log(i,!0),t&&this.plugin.settings.notificationsEnabled&&(n=new A.Notice(`BRAT
${i}`,3e4));let o=new Set(this.plugin.settings.pluginSubListFrozenVersion.map(l=>l.repo));for(let l of this.plugin.settings.pluginList)o.has(l)||(yield this.updatePlugin(l,e));let r="Checking for plugin updates COMPLETED";this.plugin.log(r,!0),t&&(n.hide(),m(this.plugin,r,10))})}deletePlugin(t){return a(this,null,function*(){let e=`Removed${t}fromBRATpluginlist`;this.plugin.log(e,!0),this.plugin.settings.pluginList=this.plugin.settings.pluginList.filter(n=>n!=t),this.plugin.settings.pluginSubListFrozenVersion=this.plugin.settings.pluginSubListFrozenVersion.filter(n=>n.repo!=t),this.plugin.saveSettings()})}getEnabledDisabledPlugins(t){let e=this.plugin.app.plugins,n=Object.values(e.manifests),i=Object.values(e.plugins).map(o=>o.manifest);return t?n.filter(o=>i.find(r=>o.id===r.id)):n.filter(o=>!i.find(r=>o.id===r.id))}};var Ae=require("obsidian");function Fe(){(0,Ae.addIcon)("BratIcon",'<path fill="currentColor" stroke="currentColor" d="M 41.667969 41.667969 C 41.667969 39.367188 39.800781 37.5 37.5 37.5 C 35.199219 37.5 33.332031 39.367188 33.332031 41.667969 C 33.332031 43.96875 35.199219 45.832031 37.5 45.832031 C 39.800781 45.832031 41.667969 43.96875 41.667969 41.667969 Z M 60.417969 58.582031 C 59.460938 58.023438 58.320312 57.867188 57.25 58.148438 C 56.179688 58.429688 55.265625 59.125 54.707031 60.082031 C 53.746094 61.777344 51.949219 62.820312 50 62.820312 C 48.050781 62.820312 46.253906 61.777344 45.292969 60.082031 C 44.734375 59.125 43.820312 58.429688 42.75 58.148438 C 41.679688 57.867188 40.539062 58.023438 39.582031 58.582031 C 37.597656 59.726562 36.910156 62.257812 38.042969 64.25 C 40.5 68.53125 45.0625 71.171875 50 71.171875 C 54.9375 71.171875 59.5 68.53125 61.957031 64.25 C 63.089844 62.257812 62.402344 59.726562 60.417969 58.582031 Z M 62.5 37.5 C 60.199219 37.5 58.332031 39.367188 58.332031 41.667969 C 58.332031 43.96875 60.199219 45.832031 62.5 45.832031 C 64.800781 45.832031 66.667969 43.96875 66.667969 41.667969 C 66.667969 39.367188 64.800781 37.5 62.5 37.5 Z M 50 8.332031 C 26.988281 8.332031 8.332031 26.988281 8.332031 50 C 8.332031 73.011719 26.988281 91.667969 50 91.667969 C 73.011719 91.667969 91.667969 73.011719 91.667969 50 C 91.667969 26.988281 73.011719 8.332031 50 8.332031 Z M 50 83.332031 C 33.988281 83.402344 20.191406 72.078125 17.136719 56.363281 C 14.078125 40.644531 22.628906 24.976562 37.5 19.042969 C 37.457031 19.636719 37.457031 20.238281 37.5 20.832031 C 37.5 27.738281 43.097656 33.332031 50 33.332031 C 52.300781 33.332031 54.167969 31.46875 54.167969 29.167969 C 54.167969 26.867188 52.300781 25 50 25 C 47.699219 25 45.832031 23.132812 45.832031 20.832031 C 45.832031 18.53125 47.699219 16.667969 50 16.667969 C 68.410156 16.667969 83.332031 31.589844 83.332031 50 C 83.332031 68.410156 68.410156 83.332031 50 83.332031 Z M 50 83.332031 " />')}var z=require("obsidian"),_e=Ke(ze());function Ve(s,t,e=!1){if(s.settings.debuggingMode&&console.log("BRAT: "+t),s.settings.loggingEnabled){if(s.settings.loggingVerboseEnabled===!1&&e===!0)return;{let n=s.settings.loggingPath+".md",i="[["+(0,z.moment)().format((0,_e.getDailyNoteSettings)().format).toString()+"]] "+(0,z.moment)().format("HH:mm"),o=z.Platform.isDesktop?window.require("os").hostname():"MOBILE",r=i+" "+o+" "+t.replace(`
`;setTimeout(()=>a(this,null,function*(){if((yield s.app.vault.adapter.exists(n))===!0){let l=yield s.app.vault.adapter.read(n);r=r+l;let g=s.app.vault.getAbstractFileByPath(n);yield s.app.vault.modify(g,r)}else yield s.app.vault.create(n,r)}),10)}}}var _=class{constructor(t){this.bratCommands=[{id:"BRAT-AddBetaPlugin",icon:"BratIcon",name:"Plugins: Add a beta plugin for testing",showInRibbon:!0,callback:()=>a(this,null,function*(){yield this.plugin.betaPlugins.displayAddNewPluginModal(!1,!1)})},{id:"BRAT-AddBetaPluginWithFrozenVersion",icon:"BratIcon",name:"Plugins: Add a beta plugin with frozen version based on a release tag",showInRibbon:!0,callback:()=>a(this,null,function*(){yield this.plugin.betaPlugins.displayAddNewPluginModal(!1,!0)})},{id:"BRAT-checkForUpdatesAndUpdate",icon:"BratIcon",name:"Plugins: Check for updates to all beta plugins and UPDATE",showInRibbon:!0,callback:()=>a(this,null,function*(){yield this.plugin.betaPlugins.checkForUpdatesAndInstallUpdates(!0,!1)})},{id:"BRAT-checkForUpdatesAndDontUpdate",icon:"BratIcon",name:"Plugins: Only check for updates to beta plugins, but don't Update",showInRibbon:!0,callback:()=>a(this,null,function*(){yield this.plugin.betaPlugins.checkForUpdatesAndInstallUpdates(!0,!0)})},{id:"BRAT-updateOnePlugin",icon:"BratIcon",name:"Plugins: Choose a single plugin version to update",showInRibbon:!0,callback:()=>a(this,null,function*(){let t=new Set(this.plugin.settings.pluginSubListFrozenVersion.map(i=>i.repo)),e=Object.values(this.plugin.settings.pluginList).filter(i=>!t.has(i)).map(i=>({display:i,info:i})),n=new S(this.plugin);n.setSuggesterData(e),yield n.display(i=>a(this,null,function*(){let o=`Checkingforupdatesfor${i.info}`;this.plugin.log(o,!0),m(this.plugin,`
${o}`,3),yield this.plugin.betaPlugins.updatePlugin(i.info,!1,!0)}))})},{id:"BRAT-restartPlugin",icon:"BratIcon",name:"Plugins: Restart a plugin that is already installed",showInRibbon:!0,callback:()=>a(this,null,function*(){let t=Object.values(this.plugin.app.plugins.manifests).map(n=>({display:n.id,info:n.id})),e=new S(this.plugin);e.setSuggesterData(t),yield e.display(n=>a(this,null,function*(){m(this.plugin,`${n.info}
Pluginreloading.....`,5),yield this.plugin.betaPlugins.reloadPlugin(n.info)}))})},{id:"BRAT-disablePlugin",icon:"BratIcon",name:"Plugins: Disable a plugin - toggle it off",showInRibbon:!0,callback:()=>a(this,null,function*(){let t=this.plugin.betaPlugins.getEnabledDisabledPlugins(!0).map(n=>({display:`${n.name}(${n.id})`,info:n.id})),e=new S(this.plugin);e.setSuggesterData(t),yield e.display(n=>a(this,null,function*(){this.plugin.log(`${n.display}plugindisabled`,!1),this.plugin.settings.debuggingMode&&console.log(n.info),yield this.plugin.app.plugins.disablePluginAndSave(n.info)}))})},{id:"BRAT-enablePlugin",icon:"BratIcon",name:"Plugins: Enable a plugin - toggle it on",showInRibbon:!0,callback:()=>a(this,null,function*(){let t=this.plugin.betaPlugins.getEnabledDisabledPlugins(!1).map(n=>({display:`${n.name}(${n.id})`,info:n.id})),e=new S(this.plugin);e.setSuggesterData(t),yield e.display(n=>a(this,null,function*(){this.plugin.log(`${n.display}pluginenabled`,!1),yield this.plugin.app.plugins.enablePluginAndSave(n.info)}))})},{id:"BRAT-openGitHubZRepository",icon:"BratIcon",name:"Plugins: Open the GitHub repository for a plugin",showInRibbon:!0,callback:()=>a(this,null,function*(){let t=yield pe(this.plugin.settings.debuggingMode),e=Object.values(t).map(o=>({display:`Plugin:${o.name}(${o.repo})`,info:o.repo})),n=Object.values(this.plugin.settings.pluginList).map(o=>({display:"BRAT: "+o,info:o}));e.forEach(o=>n.push(o));let i=new S(this.plugin);i.setSuggesterData(n),yield i.display(o=>a(this,null,function*(){o.info&&window.open(`https://github.com/${o.info}`)}))})},{id:"BRAT-openGitHubRepoTheme",icon:"BratIcon",name:"Themes: Open the GitHub repository for a theme (appearance)",showInRibbon:!0,callback:()=>a(this,null,function*(){let t=yield H(this.plugin.settings.debuggingMode),e=Object.values(t).map(i=>({display:`Theme: ${i.name} (${i.repo})`,info:i.repo})),n=new S(this.plugin);n.setSuggesterData(e),yield n.display(i=>a(this,null,function*(){i.info&&window.open(`https://github.com/${i.info}`)}))})},{id:"BRAT-opentPluginSettings",icon:"BratIcon",name:"Plugins: Open Plugin Settings Tab",showInRibbon:!0,callback:()=>a(this,null,function*(){let t=this.plugin.app.setting,e=Object.values(t.pluginTabs).map(o=>({display:"Plugin: "+o.name,info:o.id})),n=new S(this.plugin),i=Object.values(t.settingTabs).map(o=>({display:"Core: "+o.name,info:o.id}));e.forEach(o=>i.push(o)),n.setSuggesterData(i),yield n.display(o=>a(this,null,function*(){t.open(),t.openTabById(o.info)}))})},{id:"BRAT-GrabCommunityTheme",icon:"BratIcon",name:"Themes: Grab a community theme",showInRibbon:!0,callback:()=>a(this,null,function*(){return yield Se(this.plugin)})},{id:"BRAT-GrabBetaTheme",icon:"BratIcon",name:"Themes: Grab a beta theme for testing from a Github repository",showInRibbon:!0,callback:()=>a(this,null,function*(){new C(this.plugin).open()})},{id:"BRAT-updateBetaThemes",icon:"BratIcon",name:"Themes: Update beta themes",showInRibbon:!0,callback:()=>a(this,null,function*(){return yield G(this.plugin,!0)})},{id:"BRAT-switchTheme",icon:"BratIcon",name:"Themes: Switch Active Theme ",showInRibbon:!0,callback:()=>a(this,null,function*(){let t=Object.values(this.plugin.app.customCss.themes).map(n=>({display:n,info:n}));t.unshift({display:"Obsidian Default Theme",info:""});let e=new S(this.plugin);e.setSuggesterData(t),yield e.display(n=>a(this,null,function*(){this.plugin.log(`Switched to theme ${n.display}`,!1),this.plugin.app.customCss.setTheme(n.info)}))})},{id:"BRAT-allCommands",icon:"BratIcon",name:"All Commands list",showInRibbon:!1,callback:()=>a(this,null,function*(){return this.ribbonDisplayCommands()})}];this.plugin=t,this.bratCommands.forEach(e=>a(this,null,function*(){this.plugin.addCommand({id:e.id,name:e.name,icon:e.icon,callback:()=>a(this,null,function*(){yield e.callback()})})}))}ribbonDisplayCommands(){return a(this,null,function*(){let t=[];this.bratCommands.forEach(r=>{r.showInRibbon&&t.push({display:r.name,info:r.callback})});let e=new S(this.plugin),n=this.plugin.app.setting,i=Object.values(n.settingTabs).map(r=>({displa