You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
46 KiB

1 week ago
"use strict";var qt=Object.create;var Q=Object.defineProperty;var Jt=Object.getOwnPropertyDescriptor;var Wt=Object.getOwnPropertyNames;var Qt=Object.getPrototypeOf,Kt=Object.prototype.hasOwnProperty;var Gt=(s,t)=>()=>(t||s((t={exports:{}}).exports,t),t.exports),Zt=(s,t)=>{for(var n in t)Q(s,n,{get:t[n],enumerable:!0})},pt=(s,t,n,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Wt(t))!Kt.call(s,i)&&i!==n&&Q(s,i,{get:()=>t[i],enumerable:!(e=Jt(t,i))||e.enumerable});return s};var Xt=(s,t,n)=>(n=s!=null?qt(Qt(s)):{},pt(t||!s||!s.__esModule?Q(n,"default",{value:s,enumerable:!0}):n,s)),te=s=>pt(Q({},"__esModule",{value:!0}),s);var Ht=Gt(u=>{"use strict";Object.defineProperty(u,"__esModule",{value:!0});var b=require("obsidian"),rt="YYYY-MM-DD",lt="gggg-[W]ww",It="YYYY-MM",Et="YYYY-[Q]Q",Bt="YYYY";function _(s){var n,e;let t=window.app.plugins.getPlugin("periodic-notes");return t&&((e=(n=t.settings)==null?void 0:n[s])==null?void 0:e.enabled)}function H(){var s,t,n,e;try{let{internalPlugins:i,plugins:o}=window.app;if(_("daily")){let{format:r,folder:p,template:T}=((t=(s=o.getPlugin("periodic-notes"))==null?void 0:s.settings)==null?void 0:t.daily)||{};return{format:r||rt,folder:(p==null?void 0:p.trim())||"",template:(T==null?void 0:T.trim())||""}}let{folder:a,format:l,template:g}=((e=(n=i.getPluginById("daily-notes"))==null?void 0:n.instance)==null?void 0:e.options)||{};return{format:l||rt,folder:(a==null?void 0:a.trim())||"",template:(g==null?void 0:g.trim())||""}}catch(i){console.info("No custom daily note settings found!",i)}}function V(){var s,t,n,e,i,o,a;try{let l=window.app.plugins,g=(s=l.getPlugin("calendar"))==null?void 0:s.options,r=(n=(t=l.getPlugin("periodic-notes"))==null?void 0:t.settings)==null?void 0:n.weekly;if(_("weekly"))return{format:r.format||lt,folder:((e=r.folder)==null?void 0:e.trim())||"",template:((i=r.template)==null?void 0:i.trim())||""};let p=g||{};return{format:p.weeklyNoteFormat||lt,folder:((o=p.weeklyNoteFolder)==null?void 0:o.trim())||"",template:((a=p.weeklyNoteTemplate)==null?void 0:a.trim())||""}}catch(l){console.info("No custom weekly note settings found!",l)}}function Y(){var t,n,e,i;let s=window.app.plugins;try{let o=_("monthly")&&((n=(t=s.getPlugin("periodic-notes"))==null?void 0:t.settings)==null?void 0:n.monthly)||{};return{format:o.format||It,folder:((e=o.folder)==null?void 0:e.trim())||"",template:((i=o.template)==null?void 0:i.trim())||""}}catch(o){console.info("No custom monthly note settings found!",o)}}function j(){var t,n,e,i;let s=window.app.plugins;try{let o=_("quarterly")&&((n=(t=s.getPlugin("periodic-notes"))==null?void 0:t.settings)==null?void 0:n.quarterly)||{};return{format:o.format||Et,folder:((e=o.folder)==null?void 0:e.trim())||"",template:((i=o.template)==null?void 0:i.trim())||""}}catch(o){console.info("No custom quarterly note settings found!",o)}}function q(){var t,n,e,i;let s=window.app.plugins;try{let o=_("yearly")&&((n=(t=s.getPlugin("periodic-notes"))==null?void 0:t.settings)==null?void 0:n.yearly)||{};return{format:o.format||Bt,folder:((e=o.folder)==null?void 0:e.trim())||"",template:((i=o.template)==null?void 0:i.trim())||""}}catch(o){console.info("No custom yearly note settings found!",o)}}function Lt(...s){let t=[];for(let e=0,i=s.length;e<i;e++)t=t.concat(s[e].split("/"));let n=[];for(let e=0,i=t.length;e<i;e++){let o=t[e];!o||o==="."||n.push(o)}return t[0]===""&&n.unshift(""),n.join("/")}function ae(s){let t=s.substring(s.lastIndexOf("/")+1);return t.lastIndexOf(".")!=-1&&(t=t.substring(0,t.lastIndexOf("."))),t}async function re(s){let t=s.replace(/\\/g,"/").split("/");if(t.pop(),t.length){let n=Lt(...t);window.app.vault.getAbstractFileByPath(n)||await window.app.vault.createFolder(n)}}async function J(s,t){t.endsWith(".md")||(t+=".md");let n=b.normalizePath(Lt(s,t));return await re(n),n}async function L(s){let{metadataCache:t,vault:n}=window.app,e=b.normalizePath(s);if(e==="/")return Promise.resolve(["",null]);try{let i=t.getFirstLinkpathDest(e,""),o=await n.cachedRead(i),a=window.app.foldManager.load(i);return[o,a]}catch(i){return console.err
${t}
${i}`,n*1e3);e&&(o.noticeEl.oncontextmenu=()=>{e()})}var E=(s,t=!0)=>{let n=s.createEl("div");n.style.float="right",t?(n.style.padding="15px",n.style.paddingLeft="15px",n.style.paddingRight="15px",n.style.marginLeft="15px"):(n.style.padding="10px",n.style.paddingLeft="15px",n.style.paddingRight="15px");let e=n.createDiv("coffee");e.addClass("ex-twitter-span"),e.style.paddingLeft="10px";let i=e.createDiv();i.innerText="Learn more about my work at:",e.appendChild(i);let o=e.createEl("a",{href:"https://tfthacker.com"});return o.innerText="https://tfthacker.com",n};var N=class extends x.Modal{constructor(t,n,e=!1,i=!1){super(t.app),this.plugin=t,this.betaPlugins=n,this.address="",this.openSettingsTabAfterwards=e,this.useFrozenVersion=i,this.enableAfterInstall=t.settings.enableAfterInstall,this.version=""}async submitForm(){if(this.address==="")return;let t=this.address.replace("https://github.com/","");if(t.endsWith(".git")&&(t=t.slice(0,-4)),Pt(this.plugin,t)){d(this.plugin,"This plugin is already in the list for beta testing",10);return}await this.betaPlugins.addPlugin(t,!1,!1,!1,this.version,!1,this.enableAfterInstall)&&this.close()}onOpen(){this.contentEl.createEl("h4",{text:"Github repository for beta plugin:"}),this.contentEl.createEl("form",{},t=>{t.addClass("brat-modal"),new x.Setting(t).addText(i=>{i.setPlaceholder("Repository (example: https://github.com/GitubUserName/repository-name)"),i.setValue(this.address),i.onChange(o=>{this.address=o.trim()}),i.inputEl.addEventListener("keydown",o=>{o.key==="Enter"&&this.address!==" "&&(this.useFrozenVersion&&this.version!==""||!this.useFrozenVersion)&&(o.preventDefault(),this.submitForm())}),i.inputEl.style.width="100%"}),this.useFrozenVersion&&new x.Setting(t).addText(i=>{i.setPlaceholder("Specify the release version tag (example: 1.0.0)"),i.onChange(o=>{this.version=o.trim()}),i.inputEl.style.width="100%"}),t.createDiv("modal-button-container",i=>{i.createEl("label",{cls:"mod-checkbox"},o=>{let a=o.createEl("input",{attr:{tabindex:-1},type:"checkbox"});a.checked=this.enableAfterInstall,a.addEventListener("click",()=>{this.enableAfterInstall=a.checked}),o.appendText("Enable after installing the plugin")}),i.createEl("button",{attr:{type:"button"},text:"Never mind"}).addEventListener("click",()=>{this.close()}),i.createEl("button",{attr:{type:"submit"},cls:"mod-cta",text:"Add Plugin"})});let n=t.createDiv();n.style.borderTop="1px solid #ccc",n.style.marginTop="30px";let e=n.createSpan();e.innerHTML="BRAT by <a href='https://bit.ly/o42-twitter'>TFTHacker</a>",e.style.fontStyle="italic",n.appendChild(e),E(n,!1),window.setTimeout(()=>{let i=t.querySelectorAll(".brat-modal .setting-item-info");for(let o of Array.from(i))o.remove()},50),t.addEventListener("submit",i=>{i.preventDefault(),this.address!==""&&(this.useFrozenVersion&&this.version!==""||!this.useFrozenVersion)&&this.submitForm()})})}onClose(){this.openSettingsTabAfterwards&&(this.plugin.app.setting.open(),this.plugin.app.setting.openTabById(this.plugin.APP_ID))}};var Ft=require("obsidian");async function Z(){try{let s=await(0,Ft.requestUrl)(`https://obsidian.md/?${Math.random()}`);return s.status>=200&&s.status<300}catch(s){return!1}}var R=class{constructor(t){this.plugin=t}displayAddNewPluginModal(t=!1,n=!1){new N(this.plugin,this,t,n).open()}async validateRepository(t,n=!1,e=!1){let o=await ft(t,!n,this.plugin.settings.debuggingMode,this.plugin.settings.personalAccessToken);return o?"id"in o?"version"in o?o:(e&&d(this.plugin,`${t}
The version attribute for the release is missing from the manifest file`,15),null):(e&&d(this.plugin,`${t}
The plugin id attribute for the release is missing from the manifest file`,15),null):(e&&(d(this.plugin,`${t}
This does not seem to be an obsidian plugin, as there is no manifest.json file.`,15),console.error("BRAT: validateRepository",t,n,e)),null)}async getAllReleaseFiles(t,n,e,i=""){let o=i===""?n.version:i,a=e||i!=="";return console.log({reallyGetManifestOrNot:a,version:o}),{mainJs:await K(t,o,"main.js",this.plugin.settings.debuggingMode,this.plugin.settings.personalAccessToken),manifest:a?await K(t,o,"manifest.json",this.plugin.settings.debuggingMode,this.plugin.settings.personalAccessToken):"",styles:await K(t,o,"styles.css",this.plugin.settings.debuggingMode,this.plugin.settings.personalAccessToken)}}async writeReleaseFilesToPluginFolder(t,n){var o,a;let e=`${(0,F.normalizePath)(`${this.plugin.app.vault.configDir}/plugins/${t}`)}/`,{adapter:i}=this.plugin.app.vault;await i.exists(e)||await i.mkdir(e),await i.write(`${e}main.js`,(o=n.mainJs)!=null?o:""),await i.write(`${e}manifest.json`,(a=n.manifest)!=null?a:""),n.styles&&await i.write(`${e}styles.css`,n.styles)}async addPlugin(t,n=!1,e=!1,i=!1,o="",a=!1,l=this.plugin.settings.enableAfterInstall){this.plugin.settings.debuggingMode&&console.log("BRAT: addPlugin",t,n,e,i,o,a,l);let g=10,r=await this.validateRepository(t,!0,!1),p=!!r;if(p||(r=await this.validateRepository(t,!1,!0)),r===null){let c=`${t}
A manifest.json or manifest-beta.json file does not exist in the root directory of the repository. This plugin cannot be installed.`;return await this.plugin.log(c,!0),d(this.plugin,c,g),!1}if(!Object.hasOwn(r,"version")){let c=`${t}
The manifest${p?"-beta":""}.json file in the root directory of the repository does not have a version number in the file. This plugin cannot be installed.`;return await this.plugin.log(c,!0),d(this.plugin,c,g),!1}if(!Object.hasOwn(r,"minAppVersion")&&!(0,F.requireApiVersion)(r.minAppVersion)){let c=`Plugin: ${t}
The manifest${p?"-beta":""}.json for this plugin indicates that the Obsidian version of the app needs to be ${r.minAppVersion}, but this installation of Obsidian is ${F.apiVersion}.
You will need to update your Obsidian to use this plugin or contact the plugin developer for more information.`;return await this.plugin.log(c,!0),d(this.plugin,c,30),!1}let T=async()=>{let c=await this.getAllReleaseFiles(t,r,p,o);if(console.log("rFiles",c),(p||c.manifest==="")&&(c.manifest=JSON.stringify(r)),this.plugin.settings.debuggingMode&&console.log("BRAT: rFiles.manifest",p,c),c.mainJs===null){let m=`${t}
The release is not complete and cannot be download. main.js is missing from the Release`;return await this.plugin.log(m,!0),d(this.plugin,m,g),null}return c};if(!n||a){let c=await T();if(c===null)return!1;if(await this.writeReleaseFilesToPluginFolder(r.id,c),a||Tt(this.plugin,t,o),l){let{plugins:m}=this.plugin.app,f=(0,F.normalizePath)(`${m.getPluginFolder()}/${r.id}`);await m.loadManifest(f),await m.enablePluginAndSave(r.id)}if(await this.plugin.app.plugins.loadManifests(),a)await this.reloadPlugin(r.id),await this.plugin.log(`${t} reinstalled`,!0),d(this.plugin,`${t}
Plugin has been reinstalled and reloaded.`,g);else{let m=o===""?"":` (version: ${o})`,f=`${t}${m}
The plugin has been registered with BRAT.`;l||(f+=" You may still need to enable it the Community Plugin List."),await this.plugin.log(f,!0),d(this.plugin,f,g)}}else{let c=`${this.plugin.app.vault.configDir}/plugins/${r.id}/`,m="";try{m=await this.plugin.app.vault.adapter.read(`${c}manifest.json`)}catch(w){if(w.errno===-4058||w.errno===-2)return await this.addPlugin(t,!1,p,!1,o),!0;console.log("BRAT - Local Manifest Load",r.id,JSON.stringify(w,null,2))}if(o!==""||this.plugin.settings.pluginSubListFrozenVersion.map(w=>w.repo).includes(t))return d(this.plugin,`The version of ${t} is frozen, not updating.`,3),!1;let f=await JSON.parse(m);if(f.version!==r.version){let w=await T();if(w===null)return!1;if(e){let h=`There is an update available for ${r.id} from version ${f.version} to ${r.version}. `;await this.plugin.log(`${h}[Release Info](https://github.com/${t}/releases/tag/${r.version})`,!0),d(this.plugin,h,30,()=>{r&&window.open(`https://github.com/${t}/releases/tag/${r.version}`)})}else{await this.writeReleaseFilesToPluginFolder(r.id,w),await this.plugin.app.plugins.loadManifests(),await this.reloadPlugin(r.id);let h=`${r.id}
Plugin has been updated from version ${f.version} to ${r.version}. `;await this.plugin.log(`${h}[Release Info](https://github.com/${t}/releases/tag/${r.version})`,!0),d(this.plugin,h,30,()=>{r&&window.open(`https://github.com/${t}/releases/tag/${r.version}`)})}}else i&&d(this.plugin,`No update available for ${t}`,3)}return!0}async reloadPlugin(t){let{plugins:n}=this.plugin.app;try{await n.disablePlugin(t),await n.enablePlugin(t)}catch(e){this.plugin.settings.debuggingMode&&console.log("reload plugin",e)}}async updatePlugin(t,n=!1,e=!1,i=!1){let o=await this.addPlugin(t,!0,n,e,"",i);return!o&&!n&&d(this.plugin,`${t}
Update of plugin failed.`),o}async checkForPluginUpdatesAndInstallUpdates(t=!1,n=!1){if(!await Z()){console.log("BRAT: No internet detected.");return}let e,i="Checking for plugin updates STARTED";await this.plugin.log(i,!0),t&&this.plugin.settings.notificationsEnabled&&(e=new F.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)||await this.updatePlugin(l,n);let a="Checking for plugin updates COMPLETED";await this.plugin.log(a,!0),t&&(e&&e.hide(),d(this.plugin,a,10))}deletePlugin(t){let n=`Removed ${t} from BRAT plugin list`;this.plugin.log(n,!0),this.plugin.settings.pluginList=this.plugin.settings.pluginList.filter(e=>e!==t),this.plugin.settings.pluginSubListFrozenVersion=this.plugin.settings.pluginSubListFrozenVersion.filter(e=>e.repo!==t),this.plugin.saveSettings()}getEnabledDisabledPlugins(t){let n=this.plugin.app.plugins,e=Object.values(n.manifests),i=Object.values(n.plugins).map(o=>o.manifest);return t?e.filter(o=>i.find(a=>o.id===a.id)):e.filter(o=>!i.find(a=>o.id===a.id))}};var k=require("obsidian");var O=async(s,t,n)=>{let e=await I(t,!0,s.settings.debuggingMode);if(e||(e=await I(t,!1,s.settings.debuggingMode)),!e)return d(s,"There is no theme.css or theme-beta.css file in the root path of this repository, so there is no theme to install."),!1;let i=await wt(t,s.settings.debuggingMode);if(!i)return d(s,"There is no manifest.json file in the root path of this repository, so theme cannot be installed."),!1;let o=await JSON.parse(i),a=(0,k.normalizePath)(oe(s)+o.name),{adapter:l}=s.app.vault;await l.exists(a)||await l.mkdir(a),await l.write((0,k.normalizePath)(`${a}/theme.css`),e),await l.write((0,k.normalizePath)(`${a}/manifest.json`),i),At(s,t,M(e));let g="";return n?(vt(s,t,e),g=`${o.name} theme installed from ${t}. `,setTimeout(()=>{s.app.customCss.setTheme(o.name)},500)):g=`${o.name} theme updated from ${t}.`,s.log(`${g}[Theme Info](https://github.com/${t})`,!1),d(s,g,20,()=>{window.open(`https://github.com/${t}`)}),!0},B=async(s,t)=>{if(!await Z()){console.log("BRAT: No internet detected.");return}let n,e="Checking for beta theme updates STARTED";await s.log(e,!0),t&&s.settings.notificationsEnabled&&(n=new k.Notice(`BRAT
${e}`,3e4));for(let o of s.settings.themesList){let a=await $(o.repo,!0,s.settings.debuggingMode);a==="0"&&(a=await $(o.repo,!1,s.settings.debuggingMode)),console.log("BRAT: lastUpdateOnline",a),a!==o.lastUpdate&&await O(s,o.repo,!1)}let i="Checking for beta theme updates COMPLETED";(async()=>await s.log(i,!0))(),t&&(s.settings.notificationsEnabled&&n&&n.hide(),d(s,i))},X=(s,t)=>{s.settings.themesList=s.settings.themesList.filter(e=>e.repo!==t),s.saveSettings();let n=`Removed ${t} from BRAT themes list and will no longer be updated. However, the theme files still exist in the vault. To remove them, go into Settings > Appearance and remove the theme.`;s.log(n,!0),d(s,n)},oe=s=>`${(0,k.normalizePath)(`${s.app.vault.configDir}/themes`)}/`;var tt=require("obsidian");var S=class extends tt.Modal{constructor(t,n=!1){super(t.app),this.plugin=t,this.address="",this.openSettingsTabAfterwards=n}async submitForm(){if(this.address==="")return;let t=this.address.replace("https://github.com/","");if(Ct(this.plugin,t)){d(this.plugin,"This theme is already in the list for beta testing",10);return}await O(this.plugin,t,!0)&&this.close()}onOpen(){this.contentEl.createEl("h4",{text:"Github repository for beta theme:"}),this.contentEl.createEl("form",{},t=>{t.addClass("brat-modal"),new tt.Setting(t).addText(i=>{i.setPlaceholder("Repository (example: https://github.com/GitubUserName/repository-name"),i.setValue(this.address),i.onChange(o=>{this.address=o.trim()}),i.inputEl.addEventListener("keydown",o=>{o.key==="Enter"&&this.address!==" "&&(o.preventDefault(),this.submitForm())}),i.inputEl.style.width="100%",window.setTimeout(()=>{let o=document.querySelector(".setting-item-info");o&&o.remove(),i.inputEl.focus()},10)}),t.createDiv("modal-button-container",i=>{i.createEl("button",{attr:{type:"button"},text:"Never mind"}).addEventListener("click",()=>{this.close()}),i.createEl("button",{attr:{type:"submit"},cls:"mod-cta",text:"Add Theme"})});let n=t.createDiv();n.style.borderTop="1px solid #ccc",n.style.marginTop="30px";let e=n.createSpan();e.innerHTML="BRAT by <a href='https://bit.ly/o42-twitter'>TFTHacker</a>",e.style.fontStyle="italic",n.appendChild(e),E(n,!1),window.setTimeout(()=>{let i=t.querySelectorAll(".brat-modal .setting-item-info");for(let o of Array.from(i))o.remove()},50),t.addEventListener("submit",i=>{i.preventDefault(),this.address!==""&&this.submitForm()})})}onClose(){this.openSettingsTabAfterwards&&(this.plugin.app.setting.openTab(),this.plugin.app.setting.openTabById(this.plugin.APP_ID))}};var St=require("obsidian"),C=class extends St.FuzzySuggestModal{constructor(n){super(n.app);this.data=[];this.scope.register(["Shift"],"Enter",e=>{this.enterTrigger(e)}),this.scope.register(["Ctrl"],"Enter",e=>{this.enterTrigger(e)})}setSuggesterData(n){this.data=n}display(n){this.callbackFunction=n,this.open()}getItems(){return this.data}getItemText(n){return n.display}onChooseItem(){}renderSuggestion(n,e){e.createEl("div",{text:n.item.display})}enterTrigger(n){var o;let e=(o=document.querySelector(".suggestion-item.is-selected div"))==null?void 0:o.textContent,i=this.data.find(a=>a.display===e);i&&(this.invokeCallback(i,n),this.close())}onChooseSuggestion(n,e){this.invokeCallback(n.item,e)}invokeCallback(n,e){typeof this.callbackFunction=="function"&&this.callbackFunction(n,e)}};var U=class{constructor(t){this.bratCommands=[{id:"AddBetaPlugin",icon:"BratIcon",name:"Plugins: Add a beta plugin for testing",showInRibbon:!0,callback:()=>{this.plugin.betaPlugins.displayAddNewPluginModal(!1,!1)}},{id:"AddBetaPluginWithFrozenVersion",icon:"BratIcon",name:"Plugins: Add a beta plugin with frozen version based on a release tag",showInRibbon:!0,callback:()=>{this.plugin.betaPlugins.displayAddNewPluginModal(!1,!0)}},{id:"checkForUpdatesAndUpdate",icon:"BratIcon",name:"Plugins: Check for updates to all beta plugins and UPDATE",showInRibbon:!0,callback:async()=>{await this.plugin.betaPlugins.checkForPluginUpdatesAndInstallUpdates(!0,!1)}},{id:"checkForUpdatesAndDontUpdate",icon:"BratIcon",name:"Plugins: Only check for updates to beta plugins, but do
${o}`,3),this.plugin.betaPlugins.updatePlugin(i.info,!1,!0)})}},{id:"reinstallOnePlugin",icon:"BratIcon",name:"Plugins: Choose a single plugin to reinstall",showInRibbon:!0,callback:()=>{let t=new Set(this.plugin.settings.pluginSubListFrozenVersion.map(i=>i.repo)),n=Object.values(this.plugin.settings.pluginList).filter(i=>!t.has(i)).map(i=>({display:i,info:i})),e=new C(this.plugin);e.setSuggesterData(n),e.display(i=>{let o=`Reinstalling ${i.info}`;d(this.plugin,`
${o}`,3),this.plugin.log(o,!0),this.plugin.betaPlugins.updatePlugin(i.info,!1,!1,!0)})}},{id:"restartPlugin",icon:"BratIcon",name:"Plugins: Restart a plugin that is already installed",showInRibbon:!0,callback:()=>{let t=Object.values(this.plugin.app.plugins.manifests).map(e=>({display:e.id,info:e.id})),n=new C(this.plugin);n.setSuggesterData(t),n.display(e=>{d(this.plugin,`${e.info}
Plugin reloading .....`,5),this.plugin.betaPlugins.reloadPlugin(e.info)})}},{id:"disablePlugin",icon:"BratIcon",name:"Plugins: Disable a plugin - toggle it off",showInRibbon:!0,callback:()=>{let t=this.plugin.betaPlugins.getEnabledDisabledPlugins(!0).map(e=>({display:`${e.name} (${e.id})`,info:e.id})),n=new C(this.plugin);n.setSuggesterData(t),n.display(e=>{this.plugin.log(`${e.display} plugin disabled`,!1),this.plugin.settings.debuggingMode&&console.log(e.info),this.plugin.app.plugins.disablePluginAndSave(e.info)})}},{id:"enablePlugin",icon:"BratIcon",name:"Plugins: Enable a plugin - toggle it on",showInRibbon:!0,callback:()=>{let t=this.plugin.betaPlugins.getEnabledDisabledPlugins(!1).map(e=>({display:`${e.name} (${e.id})`,info:e.id})),n=new C(this.plugin);n.setSuggesterData(t),n.display(e=>{this.plugin.log(`${e.display} plugin enabled`,!1),this.plugin.app.plugins.enablePluginAndSave(e.info)})}},{id:"openGitHubZRepository",icon:"BratIcon",name:"Plugins: Open the GitHub repository for a plugin",showInRibbon:!0,callback:async()=>{let t=await ht(this.plugin.settings.debuggingMode);if(t){let n=Object.values(t).map(o=>({display:`Plugin: ${o.name} (${o.repo})`,info:o.repo})),e=Object.values(this.plugin.settings.pluginList).map(o=>({display:`BRAT: ${o}`,info:o}));for(let o of n)e.push(o);let i=new C(this.plugin);i.setSuggesterData(e),i.display(o=>{o.info&&window.open(`https://github.com/${o.info}`)})}}},{id:"openGitHubRepoTheme",icon:"BratIcon",name:"Themes: Open the GitHub repository for a theme (appearance)",showInRibbon:!0,callback:async()=>{let t=await bt(this.plugin.settings.debuggingMode);if(t){let n=Object.values(t).map(i=>({display:`Theme: ${i.name} (${i.repo})`,info:i.repo})),e=new C(this.plugin);e.setSuggesterData(n),e.display(i=>{i.info&&window.open(`https://github.com/${i.info}`)})}}},{id:"opentPluginSettings",icon:"BratIcon",name:"Plugins: Open Plugin Settings Tab",showInRibbon:!0,callback:()=>{let t=this.plugin.app.setting,n=Object.values(t.pluginTabs).map(o=>({display:`Plugin: ${o.name}`,info:o.id})),e=new C(this.plugin),i=Object.values(t.settingTabs).map(o=>({display:`Core: ${o.name}`,info:o.id}));for(let o of n)i.push(o);e.setSuggesterData(i),e.display(o=>{t.open(),t.openTabById(o.info)})}},{id:"GrabBetaTheme",icon:"BratIcon",name:"Themes: Grab a beta theme for testing from a Github repository",showInRibbon:!0,callback:()=>{new S(this.plugin).open()}},{id:"updateBetaThemes",icon:"BratIcon",name:"Themes: Update beta themes",showInRibbon:!0,callback:async()=>{await B(this.plugin,!0)}},{id:"allCommands",icon:"BratIcon",name:"All Commands list",showInRibbon:!1,callback:()=>{this.ribbonDisplayCommands()}}];this.plugin=t;for(let n of this.bratCommands)this.plugin.addCommand({id:n.id,name:n.name,icon:n.icon,callback:()=>{n.callback()}})}ribbonDisplayCommands(){let t=[];for(let a of this.bratCommands)a.showInRibbon&&t.push({display:a.name,info:a.callback});let n=new C(this.plugin),e=this.plugin.app.setting,i=Object.values(e.settingTabs).map(a=>({display:`Core: ${a.name}`,info:()=>{e.open(),e.openTabById(a.id)}})),o=Object.values(e.pluginTabs).map(a=>({display:`Plugin: ${a.name}`,info:()=>{e.open(),e.openTabById(a.id)}}));t.push({display:"---- Core Plugin Settings ----",info:()=>{this.ribbonDisplayCommands()}});for(let a of i)t.push(a);t.push({display:"---- Plugin Settings ----",info:()=>{this.ribbonDisplayCommands()}});for(let a of o)t.push(a);n.setSuggesterData(t),n.display(a=>{typeof a.info=="function"&&a.info()})}};var y=require("obsidian");var at=(s,t)=>{let n=new DocumentFragment,e=document.createElement("a");if(e.textContent=s,e.href=`https://github.com/${s}`,n.appendChild(e),t){let i=document.createTextNode(t);n.appendChild(i)}return n},et=class extends y.PluginSettingTab{constructor(t,n){super(t,n),this.plugin=n}display(){let{containerEl:t}=this;t.empty(),new y.Setting(t).setName("Auto-enable plugins after installation").setDesc('If enabled beta plugins will be automatically enabled after installtion by default. Note: you can toggle this on and off for each plugin in the "Add Plugin" form.').addToggle(e=>{
`," ")}
`,g=s.app.vault.getAbstractFileByPath(e);g?await s.app.vault.append(g,l):g=await s.app.vault.create(e,l)}}var nt=class extends jt.Plugin{constructor(){super(...arguments);this.APP_NAME="BRAT";this.APP_ID="obsidian42-brat";this.settings=ot;this.betaPlugins=new R(this);this.commands=new U(this);this.bratApi=new z(this);this.obsidianProtocolHandler=n=>{if(!n.plugin&&!n.theme){d(this,"Could not locate the repository from the URL.",10);return}for(let e of["plugin","theme"])if(n[e]){let i=e==="plugin"?new N(this,this.betaPlugins):new S(this);i.address=n[e],i.open();return}}}onload(){console.log(`loading ${this.APP_NAME}`),this.loadSettings().then(()=>{this.app.workspace.onLayoutReady(()=>{this.addSettingTab(new et(this.app,this)),kt(),this.showRibbonButton(),this.registerObsidianProtocolHandler("brat",this.obsidianProtocolHandler),this.settings.updateAtStartup&&setTimeout(()=>{this.betaPlugins.checkForPluginUpdatesAndInstallUpdates(!1)},6e4),this.settings.updateThemesAtStartup&&setTimeout(()=>{B(this,!1)},12e4),setTimeout(()=>{window.bratAPI=this.bratApi},500)})}).catch(n=>{console.error("Failed to load settings:",n)})}showRibbonButton(){this.addRibbonIcon("BratIcon","BRAT",()=>{this.commands.ribbonDisplayCommands()})}async log(n,e=!1){await Yt(this,n,e)}onunload(){console.log(`unloading ${this.APP_NAME}`)}async loadSettings(){this.settings=Object.assign({},ot,await this.loadData())}async saveSettings(){await this.saveData(this.settings)}};
/* nosourcemap */