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.

24 lines
44 KiB

var He=Object.create;var V=Object.defineProperty;var je=Object.getOwnPropertyDescriptor;var qe=Object.getOwnPropertyNames;var Je=Object.getPrototypeOf,We=Object.prototype.hasOwnProperty;var Qe=(s,t)=>()=>(t||s((t={exports:{}}).exports,t),t.exports),Ge=(s,t)=>{for(var e in t)V(s,e,{get:t[e],enumerable:!0})},ce=(s,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of qe(t))!We.call(s,i)&&i!==e&&V(s,i,{get:()=>t[i],enumerable:!(n=je(t,i))||n.enumerable});return s};var Ke=(s,t,e)=>(e=s!=null?He(Je(s)):{},ce(t||!s||!s.__esModule?V(e,"default",{value:s,enumerable:!0}):e,s)),Ze=s=>ce(V({},"__esModule",{value:!0}),s);var a=(s,t,e)=>new Promise((n,i)=>{var o=g=>{try{l(e.next(g))}catch(c){i(c)}},r=g=>{try{l(e.throw(g))}catch(c){i(c)}},l=g=>g.done?n(g.value):Promise.resolve(g.value).then(o,r);l((e=e.apply(s,t)).next())});var ze=Qe(u=>{"use strict";Object.defineProperty(u,"__esModule",{value:!0});var p=require("obsidian"),se="YYYY-MM-DD",oe="gggg-[W]ww",Ce="YYYY-MM",Ee="YYYY-[Q]Q",Ie="YYYY";function R(s){var e,n;let t=window.app.plugins.getPlugin("periodic-notes");return t&&((n=(e=t.settings)==null?void 0:e[s])==null?void 0:n.enabled)}function k(){var s,t,e,n;try{let{internalPlugins:i,plugins:o}=window.app;if(R("daily")){let{format:c,folder:h,template:d}=((t=(s=o.getPlugin("periodic-notes"))==null?void 0:s.settings)==null?void 0:t.daily)||{};return{format:c||se,folder:(h==null?void 0:h.trim())||"",template:(d==null?void 0:d.trim())||""}}let{folder:r,format:l,template:g}=((n=(e=i.getPluginById("daily-notes"))==null?void 0:e.instance)==null?void 0:n.options)||{};return{format:l||se,folder:(r==null?void 0:r.trim())||"",template:(g==null?void 0:g.trim())||""}}catch(i){console.info("No custom daily note settings found!",i)}}function M(){var s,t,e,n,i,o,r;try{let l=window.app.plugins,g=(s=l.getPlugin("calendar"))==null?void 0:s.options,c=(e=(t=l.getPlugin("periodic-notes"))==null?void 0:t.settings)==null?void 0:e.weekly;if(R("weekly"))return{format:c.format||oe,folder:((n=c.folder)==null?void 0:n.trim())||"",template:((i=c.template)==null?void 0:i.trim())||""};let h=g||{};return{format:h.weeklyNoteFormat||oe,folder:((o=h.weeklyNoteFolder)==null?void 0:o.trim())||"",template:((r=h.weeklyNoteTemplate)==null?void 0:r.trim())||""}}catch(l){console.info("No custom weekly note settings found!",l)}}function O(){var t,e,n,i;let s=window.app.plugins;try{let o=R("monthly")&&((e=(t=s.getPlugin("periodic-notes"))==null?void 0:t.settings)==null?void 0:e.monthly)||{};return{format:o.format||Ce,folder:((n=o.folder)==null?void 0:n.trim())||"",template:((i=o.template)==null?void 0:i.trim())||""}}catch(o){console.info("No custom monthly note settings found!",o)}}function $(){var t,e,n,i;let s=window.app.plugins;try{let o=R("quarterly")&&((e=(t=s.getPlugin("periodic-notes"))==null?void 0:t.settings)==null?void 0:e.quarterly)||{};return{format:o.format||Ee,folder:((n=o.folder)==null?void 0:n.trim())||"",template:((i=o.template)==null?void 0:i.trim())||""}}catch(o){console.info("No custom quarterly note settings found!",o)}}function x(){var t,e,n,i;let s=window.app.plugins;try{let o=R("yearly")&&((e=(t=s.getPlugin("periodic-notes"))==null?void 0:t.settings)==null?void 0:e.yearly)||{};return{format:o.format||Ie,folder:((n=o.folder)==null?void 0:n.trim())||"",template:((i=o.template)==null?void 0:i.trim())||""}}catch(o){console.info("No custom yearly note settings found!",o)}}function Le(...s){let t=[];for(let n=0,i=s.length;n<i;n++)t=t.concat(s[n].split("/"));let e=[];for(let n=0,i=t.length;n<i;n++){let o=t[n];!o||o==="."||e.push(o)}return t[0]===""&&e.unshift(""),e.join("/")}function nt(s){let t=s.substring(s.lastIndexOf("/")+1);return t.lastIndexOf(".")!=-1&&(t=t.substring(0,t.lastIndexOf("."))),t}function it(s){return a(this,null,function*(){let t=s.replace(/\\/g,"/").split("/");if(t.pop(),t.length){let e=Le(...t);window.app.vault.getAbstractFileByPath(e)||(yield window.app.vault.createFolder(e))}})}function U(s,t){return a(this,null,function*(){t.endsWith(".md")||(t+=".md");let e=p.normalizePath(Le(s,t));return yield it(e),e})}function E(s){return a(this,null,function*(){let{metadataCache:t,vault:e}=window.app,n=p.normalizePath(s);if(n==="/")return Promise.resolve(["",null]);try{let i=t.getFirstLinkpathDest(n,""),o=yield e.cachedRead(i),r=window.app.foldManager.load(i);return[o,r]}catch(i){return console.error(`Failed to read the daily note template '${n}'`,i),new p.Notice("Failed to read the daily note template"),["",null]}})}function N(s,t="day"){let e=s.clone().startOf(t).format();return`${t}-${e}`}function Be(s){return s.replace(/\[[^\]]*\]/g,"")}function st(s,t){if(t==="week"){let e=Be(s);return/w{1,2}/i.test(e)&&(/M{1,4}/.test(e)||/D{1,4}/.test(e))}return!1}function I(s,t){return De(s.basename,t)}function ot(s,t){return De(nt(s),t)}function De(s,t){let n={day:k,week:M,month:O,quarter:$,year:x}[t]().format.split("/").pop(),i=window.moment(s,n,!0);if(!i.isValid())return null;if(st(n,t)&&t==="week"){let o=Be(n);if(/w{1,2}/i.test(o))return window.moment(s,n.replace(/M{1,4}/g,"").replace(/D{1,4}/g,""),!1)}return i}var ae=class extends Error{};function Re(s){return a(this,null,function*(){let t=window.app,{vault:e}=t,n=window.moment,{template:i,format:o,folder:r}=k(),[l,g]=yield E(i),c=s.format(o),h=yield U(r,c);try{let d=yield e.create(h,l.replace(/{{\s*date\s*}}/gi,c).replace(/{{\s*time\s*}}/gi,n().format("HH:mm")).replace(/{{\s*title\s*}}/gi,c).replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi,(b,T,w,f,P,y)=>{let ee=n(),te=s.clone().set({hour:ee.get("hour"),minute:ee.get("minute"),second:ee.get("second")});return w&&te.add(parseInt(f,10),P),y?te.format(y.substring(1).trim()):te.format(o)}).replace(/{{\s*yesterday\s*}}/gi,s.clone().subtract(1,"day").format(o)).replace(/{{\s*tomorrow\s*}}/gi,s.clone().add(1,"d").format(o)));return t.foldManager.save(d,g),d}catch(d){console.error(`Failed to create file: '${h}'`,d),new p.Notice("Unable to create new file.")}})}function at(s,t){var e;return(e=t[N(s,"day")])!=null?e:null}function rt(){let{vault:s}=window.app,{folder:t}=k(),e=s.getAbstractFileByPath(p.normalizePath(t));if(!e)throw new ae("Failed to find daily notes folder");let n={};return p.Vault.recurseChildren(e,i=>{if(i instanceof p.TFile){let o=I(i,"day");if(o){let r=N(o,"day");n[r]=i}}}),n}var re=class extends Error{};function lt(){let{moment:s}=window,t=s.localeData()._week.dow,e=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];for(;t;)e.push(e.shift()),t--;return e}function ut(s){return lt().indexOf(s.toLowerCase())}function ke(s){return a(this,null,function*(){let{vault:t}=window.app,{template:e,format:n,folder:i}=M(),[o,r]=yield E(e),l=s.format(n),g=yield U(i,l);try{let c=yield t.create(g,o.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi,(h,d,b,T,w,f)=>{let P=window.moment(),y=s.clone().set({hour:P.get("hour"),minute:P.get("minute"),second:P.get("second")});return b&&y.add(parseInt(T,10),w),f?y.format(f.substring(1).trim()):y.format(n)}).replace(/{{\s*title\s*}}/gi,l).replace(/{{\s*time\s*}}/gi,window.moment().format("HH:mm")).replace(/{{\s*(sunday|monday|tuesday|wednesday|thursday|friday|saturday)\s*:(.*?)}}/gi,(h,d,b)=>{let T=ut(d);return s.weekday(T).format(b.trim())}));return window.app.foldManager.save(c,r),c}catch(c){console.error(`Failed to create file: '${g}'`,c),new p.Notice("Unable to create new file.")}})}function gt(s,t){var e;return(e=t[N(s,"week")])!=null?e:null}function ct(){let s={};if(!Oe())return s;let{vault:t}=window.app,{folder:e}=M(),n=t.getAbstractFileByPath(p.normalizePath(e));if(!n)throw new re("Failed to find weekly notes folder");return p.Vault.recurseChildren(n,i=>{if(i instanceof p.TFile){let o=I(i,"week");if(o){let r=N(o,"week");s[r]=i}}}),s}var le=class extends Error{};function Me(s){return a(this,null,function*(){let{vault:t}=window.app,{template:e,format:n,folder:i}=O(),[o,r]=yield E(e),l=s.format(n),g=yield U(i,l);try{let c=yield t.create(g,o.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi,(h,d,b,T,w,f)=>{let P=window.moment(),y=s.clone().set({hour:P.get("hour"),minute:P.get("minute"),second:P.get("second")});return b&&y.add(parseInt(T,10),w),f?y.format(f.substring(1).trim()):y.format(n)}).replace(/{{\s*date\s*}}/gi,l).replace(/{{\s*time\s*}}/gi,window.moment().format("HH:mm")).replace(/{{\s*title\s*}}/gi,l));return window.app.foldManager.save(c,r),c}catch(c){console.error(`Failed to create file: '${g}'`,c),new p.Notice("Unable to create new file.")}})}function dt(s,t){var e;return(e=t[N(s,"month")])!=null?e:null}function mt(){let s={};if(!$e())return s;let{vault:t}=window.app,{folder:e}=O(),n=t.getAbstractFileByPath(p.normalizePath(e));if(!n)throw new le("Failed to find monthly notes folder");return p.Vault.recurseChildren(n,i=>{if(i instanceof p.TFile){let o=I(i,"month");if(o){let r=N(o,"month");s[r]=i}}}),s}var ue=class extends Error{};function pt(s){return a(this,null,function*(){let{vault:t}=window.app,{template:e,format:n,folder:i}=$(),[o,r]=yield E(e),l=s.format(n),g=yield U(i,l);try{let c=yield t.create(g,o.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi,(h,d,b,T,w,f)=>{let P=window.moment(),y=s.clone().set({hour:P.get("hour"),minute:P.get("minute"),second:P.get("second")});return b&&y.add(parseInt(T,10),w),f?y.format(f.substring(1).trim()):y.format(n)}).replace(/{{\s*date\s*}}/gi,l).replace(/{{\s*time\s*}}/gi,window.moment().format("HH:mm")).replace(/{{\s*title\s*}}/gi,l));return window.app.foldManager.save(c,r),c}catch(c){console.error(`Failed to create file: '${g}'`,c),new p.Notice("Unable to create new file.")}})}function ft(s,t){var e;return(e=t[N(s,"quarter")])!=null?e:null}function ht(){let s={};if(!xe())return s;let{vault:t}=window.app,{folder:e}=$(),n=t.getAbstractFileByPath(p.normalizePath(e));if(!n)throw new ue("Failed to find quarterly notes folder");return p.Vault.recurseChildren(n,i=>{if(i instanceof p.TFile){let o=I(i,"quarter");if(o){let r=N(o,"quarter");s[r]=i}}}),s}var ge=class extends Error{};function bt(s){return a(this,null,function*(){let{vault:t}=window.app,{template:e,format:n,folder:i}=x(),[o,r]=yield E(e),l=s.format(n),g=yield U(i,l);try{let c=yield t.create(g,o.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi,(h,d,b,T,w,f)=>{let P=window.moment(),y=s.clone().set({hour:P.get("hour"),minute:P.get("minute"),second:P.get("second")});return b&&y.add(parseInt(T,10),w),f?y.format(f.substring(1).trim()):y.format(n)}).replace(/{{\s*date\s*}}/gi,l).replace(/{{\s*time\s*}}/gi,window.moment().format("HH:mm")).replace(/{{\s*title\s*}}/gi,l));return window.app.foldManager.save(c,r),c}catch(c){console.error(`Failed to create file: '${g}'`,c),new p.Notice("Unable to create new file.")}})}function wt(s,t){var e;return(e=t[N(s,"year")])!=null?e:null}function yt(){let s={};if(!Ue())return s;let{vault:t}=window.app,{folder:e}=x(),n=t.getAbstractFileByPath(p.normalizePath(e));if(!n)throw new ge("Failed to find yearly notes folder");return p.Vault.recurseChildren(n,i=>{if(i instanceof p.TFile){let o=I(i,"year");if(o){let r=N(o,"year");s[r]=i}}}),s}function Tt(){var n,i;let{app:s}=window,t=s.internalPlugins.plugins["daily-notes"];if(t&&t.enabled)return!0;let e=s.plugins.getPlugin("periodic-notes");return e&&((i=(n=e.settings)==null?void 0:n.daily)==null?void 0:i.enabled)}function Oe(){var e,n;let{app:s}=window;if(s.plugins.getPlugin("calendar"))return!0;let t=s.plugins.getPlugin("periodic-notes");return t&&((n=(e=t.settings)==null?void 0:e.weekly)==null?void 0:n.enabled)}function $e(){var e,n;let{app:s}=window,t=s.plugins.getPlugin("periodic-notes");return t&&((n=(e=t.settings)==null?void 0:e.monthly)==null?void 0:n.enabled)}function xe(){var e,n;let{app:s}=window,t=s.plugins.getPlugin("periodic-notes");return t&&((n=(e=t.settings)==null?void 0:e.quarterly)==null?void 0:n.enabled)}function Ue(){var e,n;let{app:s}=window,t=s.plugins.getPlugin("periodic-notes");return t&&((n=(e=t.settings)==null?void 0:e.yearly)==null?void 0:n.enabled)}function Pt(s){let t={day:k,week:M,month:O,quarter:$,year:x}[s];return t()}function vt(s,t){return{day:Re,month:Me,week:ke}[s](t)}u.DEFAULT_DAILY_NOTE_FORMAT=se;u.DEFAULT_MONTHLY_NOTE_FORMAT=Ce;u.DEFAULT_QUARTERLY_NOTE_FORMAT=Ee;u.DEFAULT_WEEKLY_NOTE_FORMAT=oe;u.DEFAULT_YEARLY_NOTE_FORMAT=Ie;u.appHasDailyNotesPluginLoaded=Tt;u.appHasMonthlyNotesPluginLoaded=$e;u.appHasQuarterlyNotesPluginLoaded=xe;u.appHasWeeklyNotesPluginLoaded=Oe;u.appHasYearlyNotesPluginLoaded=Ue;u.createDailyNote=Re;u.createMonthlyNote=Me;u.createPeriodicNote=vt;u.createQuarterlyNote=pt;u.createWeeklyNote=ke;u.createYearlyNote=bt;u.getAllDailyNotes=rt;u.getAllMonthlyNotes=mt;u.getAllQuarterlyNotes=ht;u.getAllWeeklyNotes=ct;u.getAllYearlyNotes=yt;u.getDailyNote=at;u.getDailyNoteSettings=k;u.getDateFromFile=I;u.getDateFromPath=ot;u.getDateUID=N;u.getMonthlyNote=dt;u.getMonthlyNoteSettings=O;u.getPeriodicNoteSettings=Pt;u.getQuarterlyNote=ft;u.getQuarterlyNoteSettings=$;u.getTemplateInfo=E;u.getWeeklyNote=gt;u.getWeeklyNoteSettings=M;u.getYearlyNote=wt;u.getYearlyNoteSettings=x});var St={};Ge(St,{default:()=>X});module.exports=Ze(St);var Ye=require("obsidian");var v=require("obsidian");var W=require("obsidian");var de=require("obsidian");var S=class extends de.FuzzySuggestModal{constructor(e){super(e.app);this.scope.register(["Shift"],"Enter",n=>this.enterTrigger(n)),this.scope.register(["Ctrl"],"Enter",n=>this.enterTrigger(n))}setSuggesterData(e){this.data=e}display(e){return a(this,null,function*(){this.callbackFunction=e,this.open()})}getItems(){return this.data}getItemText(e){return e.display}onChooseItem(){}renderSuggestion(e,n){n.createEl("div",{text:e.item.display})}enterTrigger(e){let n=document.querySelector(".suggestion-item.is-selected div").textContent,i=this.data.find(o=>o.display===n);i&&(this.invokeCallback(i,e),this.close())}onChooseSuggestion(e,n){this.invokeCallback(e.item,n)}invokeCallback(e,n){this.callbackFunction(e,n)}};var F=require("obsidian");var Xe="https://raw.githubusercontent.com/",Y=(s,t,e,n=!0)=>a(void 0,null,function*(){let i=`https://github.com/${s}/releases/download/${t}/${e}`;try{let o=yield(0,F.request)({url:i});return o==="Not Found"||o==='{"error":"Not Found"}'?null:o}catch(o){return n&&console.log("error in grabReleaseFileFromRepository",i,o),null}}),me=(s,t=!0,e=!0)=>a(void 0,null,function*(){let n=Xe+s+(t===!0?"/HEAD/manifest.json":"/HEAD/manifest-beta.json");try{let i=yield(0,F.request)({url:n});return i==="404: Not Found"?null:yield JSON.parse(i)}catch(i){return i!="Error: Request failed, status 404"&&e&&console.log(`error in grabManifestJsonFromRepository for ${n}`,i),null}}),pe=(s=!0)=>a(void 0,null,function*(){let t="https://raw.githubusercontent.com/obsidianmd/obsidian-releases/HEAD/community-plugins.json";try{let e=yield(0,F.request)({url:t});return e==="404: Not Found"?null:yield JSON.parse(e)}catch(e){return s&&console.log("error in grabCommmunityPluginList",e),null}}),H=(s=!0)=>a(void 0,null,function*(){let t="https://raw.githubusercontent.com/obsidianmd/obsidian-releases/HEAD/community-css-themes.json";try{let e=yield(0,F.request)({url:t});return e==="404: Not Found"?null:yield JSON.parse(e)}catch(e){return s&&console.log("error in grabCommmunityThemesList",e),null}}),ne=(s,t=!0)=>a(void 0,null,function*(){let e=`https://raw.githubusercontent.com/${s}/HEAD/obsidian.css`;try{let n=yield(0,F.request)({url:e});return n==="404: Not Found"?null:n}catch(n){return t&&console.log("error in grabCommmunityThemesList",n),null}}),et=(s,t,e=!0)=>a(void 0,null,function*(){let n=`https://api.github.com/repos/${s}/commits?path=${t}&page=1&per_page=1`;try{let i=yield(0,F.request)({url:n});return i==="404: Not Found"?null:JSON.parse(i)}catch(i){return e&&console.log("error in grabCommmunityThemesList",i),null}}),j=(s,t)=>a(void 0,null,function*(){let e=yield et(s,t);return e[0].commit.committer.date?e[0].commit.committer.date:""});var fe={pluginList:[],pluginSubListFrozenVersion:[],themesList:[],updateAtStartup:!1,updateThemesAtStartup:!1,ribbonIconEnabled:!0,loggingEnabled:!1,loggingPath:"BRAT-log",loggingVerboseEnabled:!1,debuggingMode:!0,notificationsEnabled:!0};function he(s,t,e=""){return a(this,null,function*(){let n=!1;s.settings.pluginList.contains(t)||(s.settings.pluginList.unshift(t),n=!0),e!==""&&s.settings.pluginSubListFrozenVersion.filter(i=>i.repo===t).length===0&&(s.settings.pluginSubListFrozenVersion.unshift({repo:t,version:e}),n=!0),n&&s.saveSettings()})}function be(s,t){return a(this,null,function*(){return s.settings.pluginList.contains(t)})}function we(s,t){return a(this,null,function*(){let e={repo:t,lastUpdate:yield j(t,"obsidian.css")};s.settings.themesList.unshift(e),s.saveSettings()})}function ye(s,t){return a(this,null,function*(){return!!s.settings.themesList.find(n=>n.repo===t)})}function Te(s,t,e){s.settings.themesList.forEach(n=>{n.repo===t&&(n.lastUpdate=e,s.saveSettings())})}var q=require("obsidian");function m(s,t,e=10,n=null){if(s.settings.notificationsEnabled===!1)return;let i=n?q.Platform.isDesktop?"(click=dismiss, right-click=Info)":"(click=dismiss)":"",o=new q.Notice(`BRAT
${t}
${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} theme installed from ${t}. `;return s.log(i+`[Theme Info](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} theme updated from ${t}. From date: ${e} to ${n} `;return s.log(r+`[Theme Info](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: 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 the plugin, this should be done from the Community Plugins tab in Settings."}),new v.Setting(e).addButton(i=>{i.setButtonText("Add Beta plugin"),i.onClick(()=>a(this,null,function*(){this.plugin.app.setting.close(),yield this.plugin.betaPlugins.displayAddNewPluginModal(!0,!1)}))});let n=new Set(this.plugin.settings.pluginSubListFrozenVersion.map(i=>i.repo));for(let i of this.plugin.settings.pluginList)n.has(i)||new v.Setting(e).setName(i).addButton(o=>{o.setIcon("cross"),o.setTooltip("Delete this beta plugin"),o.onClick(()=>a(this,null,function*(){o.buttonEl.textContent===""?o.setButtonText("Click once more to confirm removal"):(o.buttonEl.parentElement.parentElement.remove(),yield this.plugin.betaPlugins.deletePlugin(i))}))});new v.Setting(e).addButton(i=>{i.setButtonText("Add Beta plugin with frozen version"),i.onClick(()=>a(this,null,function*(){this.plugin.app.setting.close(),yield this.plugin.betaPlugins.displayAddNewPluginModal(!0,!0)}))});for(let i of this.plugin.settings.pluginSubListFrozenVersion)new v.Setting(e).setName(`${i.repo} (version ${i.version})`).addButton(o=>{o.setIcon("cross"),o.setTooltip("Delete this beta plugin"),o.onClick(()=>a(this,null,function*(){o.buttonEl.textContent===""?o.setButtonText("Click once more to confirm removal"):(o.buttonEl.parentElement.parentElement.remove(),yield this.plugin.betaPlugins.deletePlugin(i.repo))}))});e.createEl("hr"),e.createEl("h2",{text:"Beta Themes List"}),new v.Setting(e).addButton(i=>{i.setButtonText("Add Beta Theme"),i.onClick(()=>a(this,null,function*(){this.plugin.app.setting.close(),new C(this.plugin).open()}))});for(let i of this.plugin.settings.themesList)new v.Setting(e).setName(i.repo).addButton(o=>{o.setIcon("cross"),o.setTooltip("Delete this beta theme"),o.onClick(()=>a(this,null,function*(){o.buttonEl.textContent===""?o.setButtonText("Click once more to confirm removal"):(o.buttonEl.parentElement.parentElement.remove(),yield Ne(this.plugin,i.repo))}))});e.createEl("hr"),e.createEl("h2",{text:"Monitoring"}),new v.Setting(e).setName("Enable Notifications").setDesc("BRAT will provide popup notifications for its various activities. Turn this off means no notifications from BRAT.").addToggle(i=>{i.setValue(this.plugin.settings.notificationsEnabled),i.onChange(o=>a(this,null,function*(){this.plugin.settings.notificationsEnabled=o,yield this.plugin.saveSettings()}))}),new v.Setting(e).setName("Enable Logging").setDesc("Plugin updates will be logged to a file in the log file.").addToggle(i=>{i.setValue(this.plugin.settings.loggingEnabled),i.onChange(o=>a(this,null,function*(){this.plugin.settings.loggingEnabled=o,yield this.plugin.saveSettings()}))}),new v.Setting(this.containerEl).setName("BRAT Log File Location").setDesc("Logs will be saved to this file. Don't add .md to the file name.").addSearch(i=>{i.setPlaceholder("Example: BRAT-log").setValue(this.plugin.settings.loggingPath).onChange(o=>a(this,null,function*(){this.plugin.settings.loggingPath=o,yield this.plugin.saveSettings()}))}),new v.Setting(e).setName("Enable Verbose Logging").setDesc("Get a lot more information in the log.").addToggle(i=>{i.setValue(this.plugin.settings.loggingVerboseEnabled),i.onChange(o=>a(this,null,function*(){this.plugin.settings.loggingVerboseEnabled=o,yield this.plugin.saveSettings()}))}),new v.Setting(e).setName("Debugging Mode").setDesc("Atomic Bomb level console logging. Can be used for troubleshoting and development.").addToggle(i=>{i.setValue(this.plugin.settings.debuggingMode),i.onChange(o=>a(this,null,function*(){this.plugin.settings.debuggingMode=o,yield this.plugin.saveSettings()}))})}};var L=require("obsidian");var B=class extends L.Modal{constructor(e,n,i=!1,o=!1){super(e.app);this.plugin=e,this.betaPlugins=n,this.address="",this.openSettingsTabAfterwards=i,this.useFrozenVersion=o,this.version=""}submitForm(){return a(this,null,function*(){if(this.address==="")return;let e=this.address.replace("https://github.com/","");if(yield be(this.plugin,e)){m(this.plugin,"This plugin is already in the list for beta testing",10);return}(yield this.betaPlugins.addPlugin(e,!1,!1,!1,this.version))&&this.close()})}onOpen(){this.contentEl.createEl("h4",{text:"Github repository for beta plugin:"}),this.contentEl.createEl("form",{},e=>{new L.Setting(e).addText(n=>{n.setPlaceholder("Repository (example: TfTHacker/obsidian-brat)"),n.onChange(i=>{this.address=i.trim()}),n.inputEl.addEventListener("keydown",i=>a(this,null,function*(){i.key==="Enter"&&this.address!==" "&&(this.useFrozenVersion&&this.version!==""||!this.useFrozenVersion)&&(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)}),this.useFrozenVersion&&new L.Setting(e).addText(n=>{n.setPlaceholder("Specify the release version tag (example: 1.0.0)"),n.onChange(i=>{this.version=i.trim()}),n.inputEl.style.width="100%",window.setTimeout(()=>{let i=document.querySelector(".setting-item-info");i&&i.remove()},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 Plugin"})}),e.addEventListener("submit",n=>a(this,null,function*(){n.preventDefault(),this.address!==""&&(this.useFrozenVersion&&this.version!==""||!this.useFrozenVersion)&&(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 A=require("obsidian");var D=class{constructor(t){this.plugin=t}displayAddNewPluginModal(t=!1,e=!1){return a(this,null,function*(){new B(this.plugin,this,t,e).open()})}validateRepository(t,e=!1,n=!1){return a(this,null,function*(){let o=yield me(t,!e,this.plugin.settings.debuggingMode);return o?"id"in o?"version"in o?o:(n&&m(this.plugin,`${t}
The version attribute for the release is missing from the manifest file`,15),null):(n&&m(this.plugin,`${t}
The plugin id attribute for the release is missing from the manifest file`,15),null):(n&&m(this.plugin,`${t}
This does not seem to be an obsidian plugin, as there is no manifest.json file.`,15),null)})}getAllReleaseFiles(t,e,n,i=""){return a(this,null,function*(){let o=i===""?e.version:i,r=n||i!=="";return{mainJs:yield Y(t,o,"main.js",this.plugin.settings.debuggingMode),manifest:r?yield Y(t,o,"manifest.json",this.plugin.settings.debuggingMode):"",styles:yield Y(t,o,"styles.css",this.plugin.settings.debuggingMode)}})}writeReleaseFilesToPluginFolder(t,e){return a(this,null,function*(){let n=(0,A.normalizePath)(this.plugin.app.vault.configDir+"/plugins/"+t)+"/",i=this.plugin.app.vault.adapter;((yield i.exists(n))===!1||!(yield i.exists(n+"manifest.json")))&&(yield i.mkdir(n)),yield i.write(n+"main.js",e.mainJs),yield i.write(n+"manifest.json",e.manifest),e.styles&&(yield i.write(n+"styles.css",e.styles))})}addPlugin(t,e=!1,n=!1,i=!1,o=""){return a(this,null,function*(){var h;let l=yield this.validateRepository(t,!0,!1),g=!!l;if(g===!1&&(l=yield this.validateRepository(t,!1,!0)),l===null){let d=`${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 this.plugin.log(d,!0),m(this.plugin,`${d}`,10),!1}if(!l.hasOwnProperty("version")){let d=`${t}
The manifest${g?"-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 this.plugin.log(d,!0),m(this.plugin,`${d}`,10),!1}if(l.hasOwnProperty("minAppVersion")&&!(0,A.requireApiVersion)(l.minAppVersion)){let d=`Plugin: ${t}
The manifest${g?"-beta":""}.json for this plugin indicates that the Obsidian version of the app needs to be ${l.minAppVersion}, but this installation of Obsidian is ${A.apiVersion}.
You will need to update your Obsidian to use this plugin or contact the plugin developer for more information.`;return this.plugin.log(d,!0),m(this.plugin,`${d}`,30),!1}let c=()=>a(this,null,function*(){let d=yield this.getAllReleaseFiles(t,l,g,o);if((g||d.manifest==="")&&(d.manifest=JSON.stringify(l)),d.mainJs===null){let b=`${t}
The release is not complete and cannot be download. main.js is missing from the Release`;return this.plugin.log(b,!0),m(this.plugin,`${b}`,10),null}return d});if(e===!1){let d=yield c();if(d===null)return!1;yield this.writeReleaseFilesToPluginFolder(l.id,d),yield he(this.plugin,t,o),yield this.plugin.app.plugins.loadManifests();let b=o===""?"":` (version: ${o})`,T=`${t}${b}
The plugin has been registered with BRAT. You may still need to enable it the Community Plugin List.`;this.plugin.log(T,!0),m(this.plugin,T,10)}else{let d=this.plugin.app.vault.configDir+"/plugins/"+l.id+"/",b="";try{b=yield this.plugin.app.vault.adapter.read(d+"manifest.json")}catch(w){if(w.errno===-4058||w.errno===-2)return yield this.addPlugin(t,!1,g,!1,o),!0;console.log("BRAT - Local Manifest Load",l.id,JSON.stringify(w,null,2))}if(o!==""||this.plugin.settings.pluginSubListFrozenVersion.map(w=>w.repo).includes(t))return m(this.plugin,`The version of ${t} is frozen, not updating.`,3),!1;let T=yield JSON.parse(b);if(T.version!==l.version){let w=yield c();if(w===null)return!1;if(n){let f=`There is an update available for ${l.id} from version ${T.version} to ${l.version}. `;this.plugin.log(f+`[Release Info](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{yield this.writeReleaseFilesToPluginFolder(l.id,w),yield this.plugin.app.plugins.loadManifests(),(h=this.plugin.app.plugins.plugins[l.id])!=null&&h.manifest&&(yield this.reloadPlugin(l.id));let f=`${l.id}
Plugin has been updated from version ${T.version} to ${l.version}. `;this.plugin.log(f+`[Release Info](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}
Update of plugin failed.`),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} from BRAT plugin list`;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=`Checking for updates for ${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}
Plugin reloading .....`,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} plugin disabled`,!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} plugin enabled`,!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=>({display:"Core: "+r.name,info:()=>a(this,null,function*(){n.open(),n.openTabById(r.id)})})),o=Object.values(n.pluginTabs).map(r=>({display:"Plugin: "+r.name,info:()=>a(this,null,function*(){n.open(),n.openTabById(r.id)})}));t.push({display:"---- Core Plugin Settings ----",info:()=>a(this,null,function*(){yield this.ribbonDisplayCommands()})}),i.forEach(r=>t.push(r)),t.push({display:"---- Plugin Settings ----",info:()=>a(this,null,function*(){yield this.ribbonDisplayCommands()})}),o.forEach(r=>t.push(r)),e.setSuggesterData(t),yield e.display(r=>a(this,null,function*(){return yield r.info()}))})}};var X=class extends Ye.Plugin{constructor(){super(...arguments);this.appName="Obsidian42 - Beta Reviewer's Auto-update Tool (BRAT)";this.appID="obsidian42-brat"}onload(){return a(this,null,function*(){console.log("loading Obsidian42 - BRAT"),yield this.loadSettings(),this.addSettingTab(new Z(this.app,this)),this.betaPlugins=new D(this),this.commands=new _(this),Fe(),this.settings.ribbonIconEnabled&&this.showRibbonButton(),this.app.workspace.onLayoutReady(()=>{this.settings.updateAtStartup&&setTimeout(()=>a(this,null,function*(){yield this.betaPlugins.checkForUpdatesAndInstallUpdates(!1)}),6e4),this.settings.updateThemesAtStartup&&setTimeout(()=>a(this,null,function*(){yield G(this,!1)}),12e4)})})}showRibbonButton(){this.ribbonIcon=this.addRibbonIcon("BratIcon","BRAT",()=>a(this,null,function*(){return this.commands.ribbonDisplayCommands()}))}log(e,n=!1){Ve(this,e,n)}onunload(){console.log("unloading "+this.appName)}loadSettings(){return a(this,null,function*(){this.settings=Object.assign({},fe,yield this.loadData())})}saveSettings(){return a(this,null,function*(){yield this.saveData(this.settings)})}};