39 lines
No EOL
65 KiB
JavaScript
39 lines
No EOL
65 KiB
JavaScript
"use strict";var _t=Object.create;var le=Object.defineProperty;var Gt=Object.getOwnPropertyDescriptor;var jt=Object.getOwnPropertyNames;var zt=Object.getPrototypeOf,qt=Object.prototype.hasOwnProperty;var $=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports),Yt=(s,e)=>{for(var t in e)le(s,t,{get:e[t],enumerable:!0})},_e=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of jt(e))!qt.call(s,i)&&i!==t&&le(s,i,{get:()=>e[i],enumerable:!(n=Gt(e,i))||n.enumerable});return s};var Xt=(s,e,t)=>(t=s!=null?_t(zt(s)):{},_e(e||!s||!s.__esModule?le(t,"default",{value:s,enumerable:!0}):t,s)),Wt=s=>_e(le({},"__esModule",{value:!0}),s);var Pe=$((Jn,Ge)=>{var Jt=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...s)=>console.error("SEMVER",...s):()=>{};Ge.exports=Jt});var Re=$((Qn,je)=>{var Qt="2.0.0",Zt=Number.MAX_SAFE_INTEGER||9007199254740991,Kt=16,en=250,tn=["major","premajor","minor","preminor","patch","prepatch","prerelease"];je.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:Kt,MAX_SAFE_BUILD_LENGTH:en,MAX_SAFE_INTEGER:Zt,RELEASE_TYPES:tn,SEMVER_SPEC_VERSION:Qt,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var Ae=$((S,ze)=>{var{MAX_SAFE_COMPONENT_LENGTH:ve,MAX_SAFE_BUILD_LENGTH:nn,MAX_LENGTH:sn}=Re(),on=Pe();S=ze.exports={};var rn=S.re=[],an=S.safeRe=[],g=S.src=[],ln=S.safeSrc=[],c=S.t={},un=0,Ne="[a-zA-Z0-9-]",gn=[["\\s",1],["\\d",sn],[Ne,nn]],cn=s=>{for(let[e,t]of gn)s=s.split(`${e}*`).join(`${e}{0,${t}}`).split(`${e}+`).join(`${e}{1,${t}}`);return s},p=(s,e,t)=>{let n=cn(e),i=un++;on(s,i,e),c[s]=i,g[i]=e,ln[i]=n,rn[i]=new RegExp(e,t?"g":void 0),an[i]=new RegExp(n,t?"g":void 0)};p("NUMERICIDENTIFIER","0|[1-9]\\d*");p("NUMERICIDENTIFIERLOOSE","\\d+");p("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${Ne}*`);p("MAINVERSION",`(${g[c.NUMERICIDENTIFIER]})\\.(${g[c.NUMERICIDENTIFIER]})\\.(${g[c.NUMERICIDENTIFIER]})`);p("MAINVERSIONLOOSE",`(${g[c.NUMERICIDENTIFIERLOOSE]})\\.(${g[c.NUMERICIDENTIFIERLOOSE]})\\.(${g[c.NUMERICIDENTIFIERLOOSE]})`);p("PRERELEASEIDENTIFIER",`(?:${g[c.NUMERICIDENTIFIER]}|${g[c.NONNUMERICIDENTIFIER]})`);p("PRERELEASEIDENTIFIERLOOSE",`(?:${g[c.NUMERICIDENTIFIERLOOSE]}|${g[c.NONNUMERICIDENTIFIER]})`);p("PRERELEASE",`(?:-(${g[c.PRERELEASEIDENTIFIER]}(?:\\.${g[c.PRERELEASEIDENTIFIER]})*))`);p("PRERELEASELOOSE",`(?:-?(${g[c.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${g[c.PRERELEASEIDENTIFIERLOOSE]})*))`);p("BUILDIDENTIFIER",`${Ne}+`);p("BUILD",`(?:\\+(${g[c.BUILDIDENTIFIER]}(?:\\.${g[c.BUILDIDENTIFIER]})*))`);p("FULLPLAIN",`v?${g[c.MAINVERSION]}${g[c.PRERELEASE]}?${g[c.BUILD]}?`);p("FULL",`^${g[c.FULLPLAIN]}$`);p("LOOSEPLAIN",`[v=\\s]*${g[c.MAINVERSIONLOOSE]}${g[c.PRERELEASELOOSE]}?${g[c.BUILD]}?`);p("LOOSE",`^${g[c.LOOSEPLAIN]}$`);p("GTLT","((?:<|>)?=?)");p("XRANGEIDENTIFIERLOOSE",`${g[c.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);p("XRANGEIDENTIFIER",`${g[c.NUMERICIDENTIFIER]}|x|X|\\*`);p("XRANGEPLAIN",`[v=\\s]*(${g[c.XRANGEIDENTIFIER]})(?:\\.(${g[c.XRANGEIDENTIFIER]})(?:\\.(${g[c.XRANGEIDENTIFIER]})(?:${g[c.PRERELEASE]})?${g[c.BUILD]}?)?)?`);p("XRANGEPLAINLOOSE",`[v=\\s]*(${g[c.XRANGEIDENTIFIERLOOSE]})(?:\\.(${g[c.XRANGEIDENTIFIERLOOSE]})(?:\\.(${g[c.XRANGEIDENTIFIERLOOSE]})(?:${g[c.PRERELEASELOOSE]})?${g[c.BUILD]}?)?)?`);p("XRANGE",`^${g[c.GTLT]}\\s*${g[c.XRANGEPLAIN]}$`);p("XRANGELOOSE",`^${g[c.GTLT]}\\s*${g[c.XRANGEPLAINLOOSE]}$`);p("COERCEPLAIN",`(^|[^\\d])(\\d{1,${ve}})(?:\\.(\\d{1,${ve}}))?(?:\\.(\\d{1,${ve}}))?`);p("COERCE",`${g[c.COERCEPLAIN]}(?:$|[^\\d])`);p("COERCEFULL",g[c.COERCEPLAIN]+`(?:${g[c.PRERELEASE]})?(?:${g[c.BUILD]})?(?:$|[^\\d])`);p("COERCERTL",g[c.COERCE],!0);p("COERCERTLFULL",g[c.COERCEFULL],!0);p("LONETILDE","(?:~>?)");p("TILDETRIM",`(\\s*)${g[c.LONETILDE]}\\s+`,!0);S.tildeTrimReplace="$1~";p("TILDE",`^${g[c.LONETILDE]}${g[c.XRANGEPLAIN]}$`);p("TILDELOOSE",`^${g[c.LONETILDE]}${g[c.XRANGEPLAINLOOSE]}$`);p("LONECARET","(?:\\^)");p("CARETTRIM",`(\\s*)${g[c.LONECARET]}\\s+`,!0);S.caretTrimReplace="$1^";p("CARET",`^${g[c.LONECARET]}${g[c.XRANGEPLAIN]}$`);p("CARETLOOSE",`^${g[c.LONECARET]}${g[c.XRANGEPLAINLOOSE]}$`);p("COMPARATORLOOSE",`^${g[c.GTLT]}\\s*(${g[c.LOOSEPLAIN]})$|^$`);p("COMPARATOR",`^${g[c.GTLT]}\\s*(${g[c.FULLPLAIN]})$|^$`);p("COMPARATORTRIM",`(\\s*)${g[c.GTLT]}\\s*(${g[c.LOOSEPLAIN]}|${g[c.XRANGEPLAIN]})`,!0);S.comparatorTrimReplace="$1$2$3";p("HYPHENRANGE",`^\\s*(${g[c.XRANGEPLAIN]})\\s+-\\s+(${g[c.XRANGEPLAIN]})\\s*$`);p("HYPHENRANGELOOSE",`^\\s*(${g[c.XRANGEPLAINLOOSE]})\\s+-\\s+(${g[c.XRANGEPLAINLOOSE]})\\s*$`);p("STAR","(<|>)?=?\\s*\\*");p("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");p("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var Ye=$((Zn,qe)=>{var dn=Object.freeze({loose:!0}),pn=Object.freeze({}),mn=s=>s?typeof s!="object"?dn:s:pn;qe.exports=mn});var Qe=$((Kn,Je)=>{var Xe=/^[0-9]+$/,We=(s,e)=>{let t=Xe.test(s),n=Xe.test(e);return t&&n&&(s=+s,e=+e),s===e?0:t&&!n?-1:n&&!t?1:s<e?-1:1},hn=(s,e)=>We(e,s);Je.exports={compareIdentifiers:We,rcompareIdentifiers:hn}});var de=$((ei,tt)=>{var ue=Pe(),{MAX_LENGTH:Ze,MAX_SAFE_INTEGER:ge}=Re(),{safeRe:Ke,safeSrc:et,t:ce}=Ae(),fn=Ye(),{compareIdentifiers:V}=Qe(),Ie=class s{constructor(e,t){if(t=fn(t),e instanceof s){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if(typeof e!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>Ze)throw new TypeError(`version is longer than ${Ze} characters`);ue("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;let n=e.trim().match(t.loose?Ke[ce.LOOSE]:Ke[ce.FULL]);if(!n)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>ge||this.major<0)throw new TypeError("Invalid major version");if(this.minor>ge||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>ge||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map(i=>{if(/^[0-9]+$/.test(i)){let o=+i;if(o>=0&&o<ge)return o}return i}):this.prerelease=[],this.build=n[5]?n[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(ue("SemVer.compare",this.version,this.options,e),!(e instanceof s)){if(typeof e=="string"&&e===this.version)return 0;e=new s(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof s||(e=new s(e,this.options)),V(this.major,e.major)||V(this.minor,e.minor)||V(this.patch,e.patch)}comparePre(e){if(e instanceof s||(e=new s(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let t=0;do{let n=this.prerelease[t],i=e.prerelease[t];if(ue("prerelease compare",t,n,i),n===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(n===void 0)return-1;if(n===i)continue;return V(n,i)}while(++t)}compareBuild(e){e instanceof s||(e=new s(e,this.options));let t=0;do{let n=this.build[t],i=e.build[t];if(ue("build compare",t,n,i),n===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(n===void 0)return-1;if(n===i)continue;return V(n,i)}while(++t)}inc(e,t,n){if(e.startsWith("pre")){if(!t&&n===!1)throw new Error("invalid increment argument: identifier is empty");if(t){let i=new RegExp(`^${this.options.loose?et[ce.PRERELEASELOOSE]:et[ce.PRERELEASE]}$`),o=`-${t}`.match(i);if(!o||o[1]!==t)throw new Error(`invalid identifier: ${t}`)}}switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t,n);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t,n);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t,n),this.inc("pre",t,n);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",t,n),this.inc("pre",t,n);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{let i=Number(n)?1:0;if(this.prerelease.length===0)this.prerelease=[i];else{let o=this.prerelease.length;for(;--o>=0;)typeof this.prerelease[o]=="number"&&(this.prerelease[o]++,o=-2);if(o===-1){if(t===this.prerelease.join(".")&&n===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(i)}}if(t){let o=[t,i];n===!1&&(o=[t]),V(this.prerelease[0],t)===0?isNaN(this.prerelease[1])&&(this.prerelease=o):this.prerelease=o}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};tt.exports=Ie});var Le=$((ti,it)=>{var nt=de(),bn=(s,e,t)=>new nt(s,t).compare(new nt(e,t));it.exports=bn});var rt=$((ni,ot)=>{var st=de(),wn=(s,e,t=!1)=>{if(s instanceof st)return s;try{return new st(s,e)}catch(n){if(!t)return null;throw n}};ot.exports=wn});var Ce=$((ii,at)=>{var En=de(),yn=rt(),{safeRe:pe,t:me}=Ae(),Tn=(s,e)=>{if(s instanceof En)return s;if(typeof s=="number"&&(s=String(s)),typeof s!="string")return null;e=e||{};let t=null;if(!e.rtl)t=s.match(e.includePrerelease?pe[me.COERCEFULL]:pe[me.COERCE]);else{let l=e.includePrerelease?pe[me.COERCERTLFULL]:pe[me.COERCERTL],u;for(;(u=l.exec(s))&&(!t||t.index+t[0].length!==s.length);)(!t||u.index+u[0].length!==t.index+t[0].length)&&(t=u),l.lastIndex=u.index+u[1].length+u[2].length;l.lastIndex=-1}if(t===null)return null;let n=t[2],i=t[3]||"0",o=t[4]||"0",r=e.includePrerelease&&t[5]?`-${t[5]}`:"",a=e.includePrerelease&&t[6]?`+${t[6]}`:"";return yn(`${n}.${i}.${o}${r}${a}`,e)};at.exports=Tn});var Bt=$(f=>{"use strict";Object.defineProperty(f,"__esModule",{value:!0});var T=require("obsidian"),De="YYYY-MM-DD",ke="gggg-[W]ww",Nt="YYYY-MM",At="YYYY-[Q]Q",It="YYYY";function ee(s){var t,n;let e=window.app.plugins.getPlugin("periodic-notes");return e&&((n=(t=e.settings)==null?void 0:t[s])==null?void 0:n.enabled)}function te(){var s,e,t,n;try{let{internalPlugins:i,plugins:o}=window.app;if(ee("daily")){let{format:u,folder:d,template:h}=((e=(s=o.getPlugin("periodic-notes"))==null?void 0:s.settings)==null?void 0:e.daily)||{};return{format:u||De,folder:(d==null?void 0:d.trim())||"",template:(h==null?void 0:h.trim())||""}}let{folder:r,format:a,template:l}=((n=(t=i.getPluginById("daily-notes"))==null?void 0:t.instance)==null?void 0:n.options)||{};return{format:a||De,folder:(r==null?void 0:r.trim())||"",template:(l==null?void 0:l.trim())||""}}catch(i){console.info("No custom daily note settings found!",i)}}function ne(){var s,e,t,n,i,o,r;try{let a=window.app.plugins,l=(s=a.getPlugin("calendar"))==null?void 0:s.options,u=(t=(e=a.getPlugin("periodic-notes"))==null?void 0:e.settings)==null?void 0:t.weekly;if(ee("weekly"))return{format:u.format||ke,folder:((n=u.folder)==null?void 0:n.trim())||"",template:((i=u.template)==null?void 0:i.trim())||""};let d=l||{};return{format:d.weeklyNoteFormat||ke,folder:((o=d.weeklyNoteFolder)==null?void 0:o.trim())||"",template:((r=d.weeklyNoteTemplate)==null?void 0:r.trim())||""}}catch(a){console.info("No custom weekly note settings found!",a)}}function ie(){var e,t,n,i;let s=window.app.plugins;try{let o=ee("monthly")&&((t=(e=s.getPlugin("periodic-notes"))==null?void 0:e.settings)==null?void 0:t.monthly)||{};return{format:o.format||Nt,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 se(){var e,t,n,i;let s=window.app.plugins;try{let o=ee("quarterly")&&((t=(e=s.getPlugin("periodic-notes"))==null?void 0:e.settings)==null?void 0:t.quarterly)||{};return{format:o.format||At,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 oe(){var e,t,n,i;let s=window.app.plugins;try{let o=ee("yearly")&&((t=(e=s.getPlugin("periodic-notes"))==null?void 0:e.settings)==null?void 0:t.yearly)||{};return{format:o.format||It,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 Lt(...s){let e=[];for(let n=0,i=s.length;n<i;n++)e=e.concat(s[n].split("/"));let t=[];for(let n=0,i=e.length;n<i;n++){let o=e[n];!o||o==="."||t.push(o)}return e[0]===""&&t.unshift(""),t.join("/")}function An(s){let e=s.substring(s.lastIndexOf("/")+1);return e.lastIndexOf(".")!=-1&&(e=e.substring(0,e.lastIndexOf("."))),e}async function In(s){let e=s.replace(/\\/g,"/").split("/");if(e.pop(),e.length){let t=Lt(...e);window.app.vault.getAbstractFileByPath(t)||await window.app.vault.createFolder(t)}}async function re(s,e){e.endsWith(".md")||(e+=".md");let t=T.normalizePath(Lt(s,e));return await In(t),t}async function j(s){let{metadataCache:e,vault:t}=window.app,n=T.normalizePath(s);if(n==="/")return Promise.resolve(["",null]);try{let i=e.getFirstLinkpathDest(n,""),o=await t.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 T.Notice("Failed to read the daily note template"),["",null]}}function L(s,e="day"){let t=s.clone().startOf(e).format();return`${e}-${t}`}function Ct(s){return s.replace(/\[[^\]]*\]/g,"")}function Ln(s,e){if(e==="week"){let t=Ct(s);return/w{1,2}/i.test(t)&&(/M{1,4}/.test(t)||/D{1,4}/.test(t))}return!1}function z(s,e){return $t(s.basename,e)}function Cn(s,e){return $t(An(s),e)}function $t(s,e){let n={day:te,week:ne,month:ie,quarter:se,year:oe}[e]().format.split("/").pop(),i=window.moment(s,n,!0);if(!i.isValid())return null;if(Ln(n,e)&&e==="week"){let o=Ct(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 xe=class extends Error{};async function St(s){let e=window.app,{vault:t}=e,n=window.moment,{template:i,format:o,folder:r}=te(),[a,l]=await j(i),u=s.format(o),d=await re(r,u);try{let h=await t.create(d,a.replace(/{{\s*date\s*}}/gi,u).replace(/{{\s*time\s*}}/gi,n().format("HH:mm")).replace(/{{\s*title\s*}}/gi,u).replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi,(w,b,E,y,R,P)=>{let C=n(),U=s.clone().set({hour:C.get("hour"),minute:C.get("minute"),second:C.get("second")});return E&&U.add(parseInt(y,10),R),P?U.format(P.substring(1).trim()):U.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 e.foldManager.save(h,l),h}catch(h){console.error(`Failed to create file: '${d}'`,h),new T.Notice("Unable to create new file.")}}function $n(s,e){var t;return(t=e[L(s,"day")])!=null?t:null}function Sn(){let{vault:s}=window.app,{folder:e}=te(),t=s.getAbstractFileByPath(T.normalizePath(e));if(!t)throw new xe("Failed to find daily notes folder");let n={};return T.Vault.recurseChildren(t,i=>{if(i instanceof T.TFile){let o=z(i,"day");if(o){let r=L(o,"day");n[r]=i}}}),n}var Me=class extends Error{};function Fn(){let{moment:s}=window,e=s.localeData()._week.dow,t=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];for(;e;)t.push(t.shift()),e--;return t}function On(s){return Fn().indexOf(s.toLowerCase())}async function Ft(s){let{vault:e}=window.app,{template:t,format:n,folder:i}=ne(),[o,r]=await j(t),a=s.format(n),l=await re(i,a);try{let u=await e.create(l,o.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi,(d,h,w,b,E,y)=>{let R=window.moment(),P=s.clone().set({hour:R.get("hour"),minute:R.get("minute"),second:R.get("second")});return w&&P.add(parseInt(b,10),E),y?P.format(y.substring(1).trim()):P.format(n)}).replace(/{{\s*title\s*}}/gi,a).replace(/{{\s*time\s*}}/gi,window.moment().format("HH:mm")).replace(/{{\s*(sunday|monday|tuesday|wednesday|thursday|friday|saturday)\s*:(.*?)}}/gi,(d,h,w)=>{let b=On(h);return s.weekday(b).format(w.trim())}));return window.app.foldManager.save(u,r),u}catch(u){console.error(`Failed to create file: '${l}'`,u),new T.Notice("Unable to create new file.")}}function Dn(s,e){var t;return(t=e[L(s,"week")])!=null?t:null}function kn(){let s={};if(!Dt())return s;let{vault:e}=window.app,{folder:t}=ne(),n=e.getAbstractFileByPath(T.normalizePath(t));if(!n)throw new Me("Failed to find weekly notes folder");return T.Vault.recurseChildren(n,i=>{if(i instanceof T.TFile){let o=z(i,"week");if(o){let r=L(o,"week");s[r]=i}}}),s}var Be=class extends Error{};async function Ot(s){let{vault:e}=window.app,{template:t,format:n,folder:i}=ie(),[o,r]=await j(t),a=s.format(n),l=await re(i,a);try{let u=await e.create(l,o.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi,(d,h,w,b,E,y)=>{let R=window.moment(),P=s.clone().set({hour:R.get("hour"),minute:R.get("minute"),second:R.get("second")});return w&&P.add(parseInt(b,10),E),y?P.format(y.substring(1).trim()):P.format(n)}).replace(/{{\s*date\s*}}/gi,a).replace(/{{\s*time\s*}}/gi,window.moment().format("HH:mm")).replace(/{{\s*title\s*}}/gi,a));return window.app.foldManager.save(u,r),u}catch(u){console.error(`Failed to create file: '${l}'`,u),new T.Notice("Unable to create new file.")}}function xn(s,e){var t;return(t=e[L(s,"month")])!=null?t:null}function Mn(){let s={};if(!kt())return s;let{vault:e}=window.app,{folder:t}=ie(),n=e.getAbstractFileByPath(T.normalizePath(t));if(!n)throw new Be("Failed to find monthly notes folder");return T.Vault.recurseChildren(n,i=>{if(i instanceof T.TFile){let o=z(i,"month");if(o){let r=L(o,"month");s[r]=i}}}),s}var Ue=class extends Error{};async function Bn(s){let{vault:e}=window.app,{template:t,format:n,folder:i}=se(),[o,r]=await j(t),a=s.format(n),l=await re(i,a);try{let u=await e.create(l,o.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi,(d,h,w,b,E,y)=>{let R=window.moment(),P=s.clone().set({hour:R.get("hour"),minute:R.get("minute"),second:R.get("second")});return w&&P.add(parseInt(b,10),E),y?P.format(y.substring(1).trim()):P.format(n)}).replace(/{{\s*date\s*}}/gi,a).replace(/{{\s*time\s*}}/gi,window.moment().format("HH:mm")).replace(/{{\s*title\s*}}/gi,a));return window.app.foldManager.save(u,r),u}catch(u){console.error(`Failed to create file: '${l}'`,u),new T.Notice("Unable to create new file.")}}function Un(s,e){var t;return(t=e[L(s,"quarter")])!=null?t:null}function Vn(){let s={};if(!xt())return s;let{vault:e}=window.app,{folder:t}=se(),n=e.getAbstractFileByPath(T.normalizePath(t));if(!n)throw new Ue("Failed to find quarterly notes folder");return T.Vault.recurseChildren(n,i=>{if(i instanceof T.TFile){let o=z(i,"quarter");if(o){let r=L(o,"quarter");s[r]=i}}}),s}var Ve=class extends Error{};async function Hn(s){let{vault:e}=window.app,{template:t,format:n,folder:i}=oe(),[o,r]=await j(t),a=s.format(n),l=await re(i,a);try{let u=await e.create(l,o.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi,(d,h,w,b,E,y)=>{let R=window.moment(),P=s.clone().set({hour:R.get("hour"),minute:R.get("minute"),second:R.get("second")});return w&&P.add(parseInt(b,10),E),y?P.format(y.substring(1).trim()):P.format(n)}).replace(/{{\s*date\s*}}/gi,a).replace(/{{\s*time\s*}}/gi,window.moment().format("HH:mm")).replace(/{{\s*title\s*}}/gi,a));return window.app.foldManager.save(u,r),u}catch(u){console.error(`Failed to create file: '${l}'`,u),new T.Notice("Unable to create new file.")}}function _n(s,e){var t;return(t=e[L(s,"year")])!=null?t:null}function Gn(){let s={};if(!Mt())return s;let{vault:e}=window.app,{folder:t}=oe(),n=e.getAbstractFileByPath(T.normalizePath(t));if(!n)throw new Ve("Failed to find yearly notes folder");return T.Vault.recurseChildren(n,i=>{if(i instanceof T.TFile){let o=z(i,"year");if(o){let r=L(o,"year");s[r]=i}}}),s}function jn(){var n,i;let{app:s}=window,e=s.internalPlugins.plugins["daily-notes"];if(e&&e.enabled)return!0;let t=s.plugins.getPlugin("periodic-notes");return t&&((i=(n=t.settings)==null?void 0:n.daily)==null?void 0:i.enabled)}function Dt(){var t,n;let{app:s}=window;if(s.plugins.getPlugin("calendar"))return!0;let e=s.plugins.getPlugin("periodic-notes");return e&&((n=(t=e.settings)==null?void 0:t.weekly)==null?void 0:n.enabled)}function kt(){var t,n;let{app:s}=window,e=s.plugins.getPlugin("periodic-notes");return e&&((n=(t=e.settings)==null?void 0:t.monthly)==null?void 0:n.enabled)}function xt(){var t,n;let{app:s}=window,e=s.plugins.getPlugin("periodic-notes");return e&&((n=(t=e.settings)==null?void 0:t.quarterly)==null?void 0:n.enabled)}function Mt(){var t,n;let{app:s}=window,e=s.plugins.getPlugin("periodic-notes");return e&&((n=(t=e.settings)==null?void 0:t.yearly)==null?void 0:n.enabled)}function zn(s){let e={day:te,week:ne,month:ie,quarter:se,year:oe}[s];return e()}function qn(s,e){return{day:St,month:Ot,week:Ft}[s](e)}f.DEFAULT_DAILY_NOTE_FORMAT=De;f.DEFAULT_MONTHLY_NOTE_FORMAT=Nt;f.DEFAULT_QUARTERLY_NOTE_FORMAT=At;f.DEFAULT_WEEKLY_NOTE_FORMAT=ke;f.DEFAULT_YEARLY_NOTE_FORMAT=It;f.appHasDailyNotesPluginLoaded=jn;f.appHasMonthlyNotesPluginLoaded=kt;f.appHasQuarterlyNotesPluginLoaded=xt;f.appHasWeeklyNotesPluginLoaded=Dt;f.appHasYearlyNotesPluginLoaded=Mt;f.createDailyNote=St;f.createMonthlyNote=Ot;f.createPeriodicNote=qn;f.createQuarterlyNote=Bn;f.createWeeklyNote=Ft;f.createYearlyNote=Hn;f.getAllDailyNotes=Sn;f.getAllMonthlyNotes=Mn;f.getAllQuarterlyNotes=Vn;f.getAllWeeklyNotes=kn;f.getAllYearlyNotes=Gn;f.getDailyNote=$n;f.getDailyNoteSettings=te;f.getDateFromFile=z;f.getDateFromPath=Cn;f.getDateUID=L;f.getMonthlyNote=xn;f.getMonthlyNoteSettings=ie;f.getPeriodicNoteSettings=zn;f.getQuarterlyNote=Un;f.getQuarterlyNoteSettings=se;f.getTemplateInfo=j;f.getWeeklyNote=Dn;f.getWeeklyNoteSettings=ne;f.getYearlyNote=_n;f.getYearlyNoteSettings=oe});var Yn={};Yt(Yn,{default:()=>Te});module.exports=Wt(Yn);var Ht=require("obsidian");var O=require("obsidian");var A=class extends Error{constructor(t,n,i,o){let r=Math.ceil((i-Math.floor(Date.now()/1e3))/60);super(`GitHub API rate limit exceeded. Reset in ${r} minutes.`);this.limit=t;this.remaining=n;this.reset=i;this.requestUrl=o}getMinutesToReset(){return Math.ceil((this.reset-Math.floor(Date.now()/1e3))/60)}},F=class extends Error{constructor(e){var n,i;super(`GitHub API error ${e}: ${e.message}`),this.message=e.message;let t=e;this.status=(n=t.status)!=null?n:400,this.headers=(i=t.headers)!=null?i:{},this.name="GitHubResponseError"}};var k=require("obsidian");var Pn=Le(),lt=Ce(),$e=async(s,e=!0,t="")=>{let n=`https://api.github.com/repos/${s}`;try{let i=await Fe({url:n,headers:t?{Authorization:`Token ${t}`}:{}});return(await JSON.parse(i)).private}catch(i){if(i instanceof A)throw i;return e&&console.log("error in isPrivateRepo",n,i),!1}},ut=async(s,e=!0,t="")=>{let n=`https://api.github.com/repos/${s}/releases`;try{let i=await Fe({url:`${n}?per_page=100`,headers:t?{Authorization:`Token ${t}`}:{}});return(await JSON.parse(i)).map(r=>({version:r.tag_name,prerelease:r.prerelease}))}catch(i){if(i instanceof A||i instanceof F)throw i;return e&&console.log("Error in fetchReleaseVersions",n,i),null}},q=async(s,e,t=!0,n=!1,i="")=>{try{let o=s.assets.find(l=>l.name===e);if(!o)return null;let r={Accept:"application/octet-stream"};(n&&i||i)&&(r.Authorization=`Token ${i}`);let a=await(0,k.request)({url:o.url,headers:r});return a==="Not Found"||a==='{"error":"Not Found"}'?null:a}catch(o){if(o instanceof A)throw o;return t&&console.log("error in grabReleaseFileFromRepository",URL,o),null}},gt=async(s=!0)=>{let e="https://raw.githubusercontent.com/obsidianmd/obsidian-releases/HEAD/community-plugins.json";try{let t=await(0,k.request)({url:e});return t==="404: Not Found"?null:await JSON.parse(t)}catch(t){return s&&console.log("error in grabCommmunityPluginList",t),null}},ct=async(s=!0)=>{let e="https://raw.githubusercontent.com/obsidianmd/obsidian-releases/HEAD/community-css-themes.json";try{let t=await(0,k.request)({url:e});return t==="404: Not Found"?null:await JSON.parse(t)}catch(t){return s&&console.log("error in grabCommmunityThemesList",t),null}},H=async(s,e=!1,t=!1)=>{let n=`https://raw.githubusercontent.com/${s}/HEAD/theme${e?"-beta":""}.css`;try{let i=await(0,k.request)({url:n});return i==="404: Not Found"?null:i}catch(i){return t&&console.log("error in grabCommmunityThemeCssFile",i),null}},dt=async(s,e=!0)=>{let t=`https://raw.githubusercontent.com/${s}/HEAD/manifest.json`;try{let n=await(0,k.request)({url:t});return n==="404: Not Found"?null:n}catch(n){return e&&console.log("error in grabCommmunityThemeManifestFile",n),null}},Rn=s=>{let e=0;for(let t=0;t<s.length;t++)e+=s.charCodeAt(t);return e},Y=s=>Rn(s).toString(),X=async(s,e,t)=>{let n=await H(s,e,t);return n?Y(n):"0"},vn=async(s,e,t=!0)=>{let n=`https://api.github.com/repos/${s}/commits?path=${e}&page=1&per_page=1`;try{let i=await(0,k.request)({url:n});return i==="404: Not Found"?null:JSON.parse(i)}catch(i){return t&&console.log("error in grabLastCommitInfoForAFile",i),null}},pt=async(s,e)=>{var n;let t=await vn(s,e);return t&&t.length>0&&((n=t[0].commit.committer)!=null&&n.date)?t[0].commit.committer.date:""},Se=async(s,e,t=!1,n=!1,i=!1,o)=>{var r;try{let a=e&&e!=="latest"?`https://api.github.com/repos/${s}/releases/tags/${e}`:`https://api.github.com/repos/${s}/releases`,l={Accept:"application/vnd.github.v3+json"};(i&&o||o)&&(l.Authorization=`Token ${o}`);let u=await Fe({url:a,headers:l});if(u==="404: Not Found")return null;let d=e&&e!=="latest"?[JSON.parse(u)]:JSON.parse(u);return n&&console.log(`grabReleaseFromRepository for ${s}:`,d),(r=d.sort((h,w)=>{let b=lt(h.tag_name,{includePrerelease:!0,loose:!0}),E=lt(w.tag_name,{includePrerelease:!0,loose:!0});return Pn(E,b)}).filter(h=>t||!h.prerelease)[0])!=null?r:null}catch(a){throw n&&console.log(`Error in grabReleaseFromRepository for ${s}:`,a),a}},Fe=async(s,e)=>{let t=0,n=0,i=0;try{return await(0,k.request)(s)}catch(o){let r=new F(o),a=r.headers;if(a&&(t=Number.parseInt(a["x-ratelimit-limit"]),n=Number.parseInt(a["x-ratelimit-remaining"]),i=Number.parseInt(a["x-ratelimit-reset"])),r.status===403&&n===0){let l=new A(t,n,i,s.url);throw e&&console.error(`BRAT
|
|
GitHub API rate limit exceeded:`,`
|
|
Request: ${l.requestUrl}`,`
|
|
Rate limits - Remaining: ${l.remaining}`,`
|
|
Reset in: ${l.getMinutesToReset()} minutes`),l}throw e&&console.log("GitHub request failed:",o),r}};var Oe={pluginList:[],pluginSubListFrozenVersion:[],themesList:[],updateAtStartup:!0,updateThemesAtStartup:!0,enableAfterInstall:!0,loggingEnabled:!1,loggingPath:"BRAT-log",loggingVerboseEnabled:!1,debuggingMode:!1,notificationsEnabled:!0,personalAccessToken:""};function mt(s,e,t="latest",n=""){let i=!1;s.settings.pluginList.contains(e)||(s.settings.pluginList.unshift(e),i=!0),s.settings.pluginSubListFrozenVersion.filter(o=>o.repo===e).length===0&&(s.settings.pluginSubListFrozenVersion.unshift({repo:e,version:t,token:n||void 0}),i=!0),i&&s.saveSettings()}function ht(s,e){return s.settings.pluginList.contains(e)}function ft(s,e,t){let n={repo:e,lastUpdate:Y(t)};s.settings.themesList.unshift(n),s.saveSettings()}function bt(s,e){return!!s.settings.themesList.find(n=>n.repo===e)}function wt(s,e,t){for(let n of s.settings.themesList)n.repo===e&&(n.lastUpdate=t,s.saveSettings())}var I=require("obsidian");function W(s,e){let t=new DocumentFragment,n=document.createElement("a");if(n.textContent=s,n.href=`https://github.com/${s}`,n.target="_blank",t.appendChild(n),e){let i=document.createTextNode(e);t.appendChild(i)}return t}var he=require("obsidian");function m(s,e,t=10,n){if(!s.settings.notificationsEnabled)return;let i=n?he.Platform.isDesktop?"(click=dismiss, right-click=Info)":"(click=dismiss)":"",o=new he.Notice(`BRAT
|
|
${e}
|
|
${i}`,t*1e3);n&&(o.noticeEl.oncontextmenu=()=>{n()})}var _=(s,e=!0)=>{let t=s.createEl("div");t.style.float="right",e?(t.style.padding="15px",t.style.paddingLeft="15px",t.style.paddingRight="15px",t.style.marginLeft="15px"):(t.style.padding="10px",t.style.paddingLeft="15px",t.style.paddingRight="15px");let n=t.createDiv("coffee");n.addClass("ex-twitter-span"),n.style.paddingLeft="10px";let i=n.createDiv();i.innerText="Learn more about my work at:",n.appendChild(i);let o=n.createEl("a",{href:"https://tfthacker.com"});return o.innerText="https://tfthacker.com",t};var Et=require("obsidian"),fe=class extends Et.SuggestModal{constructor(e,t,n,i,o){super(e),this.versions=n,this.selected=i,this.onChoose=o,this.setTitle("Select a version"),this.setPlaceholder(`Type to search for a version for ${t}`),this.setInstructions([{command:"\u2191\u2193",purpose:"Navigate versions"},{command:"\u21B5",purpose:"Select version"},{command:"esc",purpose:"Dismiss modal"}])}getSuggestions(e){let t=e.toLowerCase();return this.versions.filter(n=>n.version.toLowerCase().contains(t))}renderSuggestion(e,t){t.createEl("div",{text:`${e.version} ${e.prerelease?"(Prerelease)":""}`})}onChooseSuggestion(e){this.onChoose(e.version)}onNoSuggestion(){this.onChoose(this.selected?this.selected:""),this.close()}};var x=class extends I.Modal{constructor(t,n,i=!1,o=!1,r="",a="",l=""){super(t.app);this.versionSetting=null;this.addPluginButton=null;this.cancelButton=null;this.plugin=t,this.betaPlugins=n,this.address=r,this.version=a,this.privateApiKey=l,this.openSettingsTabAfterwards=i,this.trackFixedVersion=o,this.enableAfterInstall=t.settings.enableAfterInstall}async submitForm(){if(this.address==="")return;let t=this.address.replace("https://github.com/","");t.endsWith(".git")&&(t=t.slice(0,-4));let n=this.plugin.settings.pluginSubListFrozenVersion.find(o=>o.repo===t);if(n){n.version=this.version,n.token=this.privateApiKey||"",await this.plugin.saveSettings(),await this.betaPlugins.addPlugin(t,!1,!1,!1,this.version,!0,this.enableAfterInstall,this.privateApiKey)&&this.close();return}if(!this.version&&ht(this.plugin,t)){m(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.privateApiKey)&&this.close()}updateVersionDropdown(t,n,i=""){t.clear(),n.length<20||I.Platform.isMobile?t.addDropdown(r=>{r.addOption("","Select a version"),r.addOption("latest","Latest version");for(let a of n)r.addOption(a.version,`${a.version} ${a.prerelease?"(Prerelease)":""}`);r.setValue(i),r.onChange(a=>{this.version=a,this.updateAddButtonState()}),r.selectEl.addClass("brat-version-selector"),r.selectEl.style.width="100%"}):t.addButton(r=>{r.setButtonText(i==="latest"?"Latest version":i||"Select a version...").setClass("brat-version-selector").setClass("button").onClick(a=>{a.preventDefault();let u=[{version:"latest",prerelease:!1},...n];new fe(this.app,this.address,u,i,h=>{this.version=h,r.setButtonText(h==="latest"?"Latest version":h||"Select a version..."),this.updateAddButtonState()}).open()})})}updateAddButtonState(){this.addPluginButton&&this.addPluginButton.setDisabled(this.version==="")}onOpen(){let t=this.contentEl.createEl("h4");this.address?(t.appendText("Change plugin version: "),t.appendChild(W(this.address))):t.setText("Github repository for beta plugin:"),this.contentEl.createEl("form",{},n=>{if(n.addClass("brat-modal"),!this.address||!this.trackFixedVersion){let r=new I.Setting(n).setClass("repository-setting"),a=r.settingEl.createDiv("validation-status");a.style.color="var(--text-error)",a.style.marginTop="6px",a.style.fontSize="0.8em",r.then(l=>{l.addText(u=>{u.setPlaceholder("Repository (example: https://github.com/GitubUserName/repository-name)"),u.setValue(this.address),u.onChange(d=>{var h,w;this.address=d.trim(),this.trackFixedVersion&&(!this.address||!this.isGitHubRepositoryMatch(this.address))&&this.versionSetting&&(this.updateVersionDropdown(this.versionSetting,[]),this.versionSetting.settingEl.classList.add("disabled-setting"),this.versionSetting.setDisabled(!0),u.inputEl.classList.remove("valid-repository"),u.inputEl.classList.remove("invalid-repository")),this.trackFixedVersion||(this.isGitHubRepositoryMatch(this.address)?(h=this.addPluginButton)==null||h.setDisabled(!1):(w=this.addPluginButton)==null||w.setDisabled(!0))}),u.inputEl.addEventListener("keydown",async d=>{var h,w,b;d.key==="Enter"&&(this.address&&(this.trackFixedVersion&&this.version!==""||!this.trackFixedVersion)&&(d.preventDefault(),(h=this.addPluginButton)==null||h.setDisabled(!0),(w=this.cancelButton)==null||w.setDisabled(!0),(b=this.versionSetting)==null||b.setDisabled(!0),this.submitForm()),await this.updateRepositoryVersionInfo(this.version,u))}),this.trackFixedVersion&&u.inputEl.addEventListener("blur",async()=>{await this.updateRepositoryVersionInfo(this.version,u,a)}),u.inputEl.style.width="100%"})})}this.trackFixedVersion&&(new I.Setting(n).setClass("api-setting").addText(r=>{r.setPlaceholder("GitHub API key for private repository (optional)").setValue(this.privateApiKey).onChange(async a=>{this.privateApiKey=a.trim(),this.address&&await this.updateRepositoryVersionInfo(this.version,r)}),r.inputEl.type="password",r.inputEl.style.width="100%"}),this.versionSetting=new I.Setting(n).setClass("version-setting").setClass("disabled-setting"),this.updateVersionDropdown(this.versionSetting,[],this.version),this.versionSetting.setDisabled(!0)),n.createDiv("modal-button-container",r=>{var a;r.createEl("label",{cls:"mod-checkbox"},l=>{let u=l.createEl("input",{attr:{tabindex:-1},type:"checkbox"});u.checked=this.enableAfterInstall,u.addEventListener("click",()=>{this.enableAfterInstall=u.checked}),l.appendText("Enable after installing the plugin")}),this.cancelButton=new I.ButtonComponent(r).setButtonText("Never mind").setClass("mod-cancel").onClick(l=>{this.close()}),this.addPluginButton=new I.ButtonComponent(r).setButtonText(this.trackFixedVersion&&this.address?"Change version":"Add plugin").setCta().onClick(l=>{var u,d,h,w;l.preventDefault(),this.address!==""&&(this.trackFixedVersion&&this.version!==""||!this.trackFixedVersion)&&((u=this.addPluginButton)==null||u.setDisabled(!0),(d=this.addPluginButton)==null||d.setButtonText("Installing \u2026"),(h=this.cancelButton)==null||h.setDisabled(!0),(w=this.versionSetting)==null||w.setDisabled(!0),this.submitForm())}),(this.trackFixedVersion||this.address==="")&&((a=this.addPluginButton)==null||a.setDisabled(!0))});let i=n.createDiv();i.style.borderTop="1px solid #ccc",i.style.marginTop="30px";let o=i.createSpan();o.innerHTML="BRAT by <a href='https://bit.ly/o42-twitter'>TFTHacker</a>",o.style.fontStyle="italic",i.appendChild(o),_(i,!1),window.setTimeout(()=>{let r=n.querySelectorAll(".brat-modal .setting-item-info");for(let a of Array.from(r))a.remove()},50),n.addEventListener("submit",r=>{var a;r.preventDefault(),this.address!==""&&(this.trackFixedVersion&&this.version!==""||!this.trackFixedVersion)&&((a=this.addPluginButton)==null||a.setDisabled(!0),this.submitForm())})}),this.address&&window.setTimeout(async()=>{await this.updateRepositoryVersionInfo(this.version)},100)}async updateRepositoryVersionInfo(t="",n,i){var r,a;if(this.plugin.settings.debuggingMode&&console.log(`[BRAT] Updating version dropdown for ${this.address} with selected version ${t}`),!this.address){i&&i.setText("Repository address is required.");return}this.versionSetting&&this.trackFixedVersion&&this.updateVersionDropdown(this.versionSetting,[],t);let o=this.address.replace("https://github.com/","");o.endsWith(".git")&&(o=o.slice(0,-4));try{let l=await ut(o,this.plugin.settings.debuggingMode,this.privateApiKey||this.plugin.settings.personalAccessToken);l&&l.length>0?(n==null||n.inputEl.classList.remove("invalid-repository"),n==null||n.inputEl.classList.add("valid-repository"),this.versionSetting&&(this.versionSetting.settingEl.classList.remove("disabled-setting"),this.versionSetting.setDisabled(!1),this.updateVersionDropdown(this.versionSetting,l,t))):(n==null||n.inputEl.classList.remove("valid-repository"),n==null||n.inputEl.classList.add("invalid-repository"),this.versionSetting&&(this.versionSetting.settingEl.classList.add("disabled-setting"),this.versionSetting.setDisabled(!0),(r=this.addPluginButton)==null||r.setDisabled(!0)))}catch(l){if(l instanceof A&&(n==null||n.inputEl.classList.remove("valid-repository"),n==null||n.inputEl.classList.add("validation-error"),i==null||i.setText(`GitHub API rate limit exceeded. Try again in ${l.getMinutesToReset()} minutes.`),this.versionSetting&&(this.versionSetting.settingEl.classList.add("disabled-setting"),this.versionSetting.setDisabled(!0),(a=this.addPluginButton)==null||a.setDisabled(!0)),m(this.plugin,`${l.message} Consider adding a personal access token in BRAT settings for higher limits. See documentation for details.`,20,()=>{window.open("https://github.com/TfTHacker/obsidian42-brat/blob/main/BRAT-DEVELOPER-GUIDE.md#github-api-rate-limits")})),l instanceof F){let u=l;switch(u.status){case 404:i==null||i.setText("Repository not found.");break;case 403:i==null||i.setText("Access denied. Check your personal access token.");break;default:i==null||i.setText(`Error: ${u.message}`);break}m(this.plugin,`${u.message} `,20)}}}onClose(){this.openSettingsTabAfterwards&&(this.plugin.app.setting.open(),this.plugin.app.setting.openTabById(this.plugin.APP_ID))}isGitHubRepositoryMatch(t){let n=t.trim().replace(/\.git$/,"").toLowerCase();return/^(?:https:\/\/github\.com\/)?([a-zA-Z0-9._-]+)\/([a-zA-Z0-9._-]+)$/.test(n)}};var yt=require("obsidian");async function be(){try{let s=await(0,yt.requestUrl)(`https://obsidian.md/?${Math.random()}`);return s.status>=200&&s.status<300}catch(s){return!1}}var Tt=Le(),we=Ce(),J=class{constructor(e){this.plugin=e}displayAddNewPluginModal(e=!1,t=!1,n="",i="",o=""){new x(this.plugin,this,e,t,n,i,o).open()}async validateRepository(e,t=!1,n=!1,i="",o=""){try{let a=await $e(e,this.plugin.settings.debuggingMode,o||this.plugin.settings.personalAccessToken),l=await Se(e,i,t,this.plugin.settings.debuggingMode,a,o||this.plugin.settings.personalAccessToken);if(!l)return n&&(m(this.plugin,`${e}
|
|
This does not seem to be an obsidian plugin with valid releases, as there are no releases available.`,15),console.error("BRAT: validateRepository",e,t,n)),null;let u=await q(l,"manifest.json",this.plugin.settings.debuggingMode,a,o||this.plugin.settings.personalAccessToken);if(!u)return n&&(m(this.plugin,`${e}
|
|
This does not seem to be an obsidian plugin, as there is no manifest.json file.`,15),console.error("BRAT: validateRepository",e,t,n)),null;let d=JSON.parse(u);if(!("id"in d))return n&&m(this.plugin,`${e}
|
|
The plugin id attribute for the release is missing from the manifest file`,15),null;if(!("version"in d))return n&&m(this.plugin,`${e}
|
|
The version attribute for the release is missing from the manifest file`,15),null;let h=we(l.tag_name,{includePrerelease:!0,loose:!0}),w=we(d.version,{includePrerelease:!0,loose:!0});return Tt(h,w)!==0&&(n&&m(this.plugin,`${e}
|
|
Version mismatch detected:
|
|
Release tag version: ${l.tag_name}
|
|
Manifest version: ${d.version}
|
|
|
|
The release tag version will be used to ensure consistency.`,15),d.version=h.version),d}catch(a){if(a instanceof A){let l=`GitHub API rate limit exceeded. Reset in ${a.getMinutesToReset()} minutes.`;throw n&&m(this.plugin,l,15),console.error(`BRAT: validateRepository ${a}`),m(this.plugin,`${a.message} Consider adding a personal access token in BRAT settings for higher limits. See documentation for details.`,20,()=>{window.open("https://github.com/TfTHacker/obsidian42-brat/blob/main/BRAT-DEVELOPER-GUIDE.md#github-api-rate-limits")}),a}if(a instanceof F)throw n&&(a.status===401?m(this.plugin,`${e}
|
|
GitHub API Authentication error. Please verify that your personal access token is valid and set correctly.`,15):m(this.plugin,`${e}
|
|
GitHub API error ${a.status}: ${a.message}`,15)),console.error(`BRAT: validateRepository ${a}`),a;return n&&m(this.plugin,`${e}
|
|
Unspecified error encountered: ${a}, verify debug for more information.`,15),null}}async getAllReleaseFiles(e,t,n,i="",o=""){let r=await $e(e,this.plugin.settings.debuggingMode,o),a=await Se(e,i,n,this.plugin.settings.debuggingMode,r,o||this.plugin.settings.personalAccessToken);if(!a)return Promise.reject("No release found");let l=n||i!=="";return console.log({reallyGetManifestOrNot:l,version:a.tag_name}),{mainJs:await q(a,"main.js",this.plugin.settings.debuggingMode,r,o||this.plugin.settings.personalAccessToken),manifest:l?await q(a,"manifest.json",this.plugin.settings.debuggingMode,r,o||this.plugin.settings.personalAccessToken):"",styles:await q(a,"styles.css",this.plugin.settings.debuggingMode,r,o||this.plugin.settings.personalAccessToken)}}async writeReleaseFilesToPluginFolder(e,t){var o,r;let n=`${(0,O.normalizePath)(`${this.plugin.app.vault.configDir}/plugins/${e}`)}/`,{adapter:i}=this.plugin.app.vault;await i.exists(n)||await i.mkdir(n),await i.write(`${n}main.js`,(o=t.mainJs)!=null?o:""),await i.write(`${n}manifest.json`,(r=t.manifest)!=null?r:""),t.styles&&await i.write(`${n}styles.css`,t.styles)}async addPlugin(e,t=!1,n=!1,i=!1,o="",r=!1,a=this.plugin.settings.enableAfterInstall,l=""){try{this.plugin.settings.debuggingMode&&console.log("BRAT: addPlugin",e,t,n,i,o,r,a,l?"private":"public");let u=10,d=await this.validateRepository(e,!0,!0,o,l),h=!!d;if(h||(d=await this.validateRepository(e,!1,!0,o,l)),d===null){let b=`${e}
|
|
A manifest.json file does not exist in the latest release of the repository. This plugin cannot be installed.`;return await this.plugin.log(b,!0),m(this.plugin,b,u),!1}if(!Object.hasOwn(d,"version")){let b=`${e}
|
|
The manifest.json file in the latest release or pre-release of the repository does not have a version number in the file. This plugin cannot be installed.`;return await this.plugin.log(b,!0),m(this.plugin,b,u),!1}if(!Object.hasOwn(d,"minAppVersion")&&!(0,O.requireApiVersion)(d.minAppVersion)){let b=`Plugin: ${e}
|
|
|
|
The manifest.json for this plugin indicates that the Obsidian version of the app needs to be ${d.minAppVersion}, but this installation of Obsidian is ${O.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(b,!0),m(this.plugin,b,30),!1}let w=async()=>{let b=await this.getAllReleaseFiles(e,d,h,o,l);if(console.log("rFiles",b),(h||b.manifest==="")&&(b.manifest=JSON.stringify(d)),this.plugin.settings.debuggingMode&&console.log("BRAT: rFiles.manifest",h,b),b.mainJs===null){let E=`${e}
|
|
The release is not complete and cannot be download. main.js is missing from the Release`;return await this.plugin.log(E,!0),m(this.plugin,E,u),null}return b};if(!t||r){let b=await w();if(b===null)return!1;if(await this.writeReleaseFilesToPluginFolder(d.id,b),r||mt(this.plugin,e,o,l),a){let{plugins:E}=this.plugin.app,y=(0,O.normalizePath)(`${E.getPluginFolder()}/${d.id}`);await E.loadManifest(y),await E.enablePluginAndSave(d.id)}if(await this.plugin.app.plugins.loadManifests(),r)await this.reloadPlugin(d.id),await this.plugin.log(`${e} reinstalled`,!0),m(this.plugin,`${e}
|
|
Plugin has been reinstalled and reloaded with version ${d.version}`,u);else{let E=o===""?"":` (version: ${o})`,y=`${e}${E}
|
|
The plugin has been registered with BRAT.`;a||(y+=" You may still need to enable it the Community Plugin List."),await this.plugin.log(y,!0),m(this.plugin,y,u)}}else{let b=`${this.plugin.app.vault.configDir}/plugins/${d.id}/`,E="";try{E=await this.plugin.app.vault.adapter.read(`${b}manifest.json`)}catch(C){if(C.errno===-4058||C.errno===-2)return await this.addPlugin(e,!1,h,!1,o,!1,a,l),!0;console.log("BRAT - Local Manifest Load",d.id,JSON.stringify(C,null,2))}if(o!==""&&o!=="latest")return m(this.plugin,`The version of ${e} is frozen, not updating.`,3),!1;let y=await JSON.parse(E),R=we(y.version,{includePrerelease:!0,loose:!0}),P=we(d.version,{includePrerelease:!0,loose:!0});if(Tt(R,P)===-1){let C=await w();if(C===null)return!1;if(n){let He=`There is an update available for ${d.id} from version ${y.version} to ${d.version}. `;return await this.plugin.log(`${He}[Release Info](https://github.com/${e}/releases/tag/${d.version})`,!0),m(this.plugin,He,30,()=>{d&&window.open(`https://github.com/${e}/releases/tag/${d.version}`)}),!1}await this.writeReleaseFilesToPluginFolder(d.id,C),await this.plugin.app.plugins.loadManifests(),await this.reloadPlugin(d.id);let U=`${d.id}
|
|
Plugin has been updated from version ${y.version} to ${d.version}. `;return await this.plugin.log(`${U}[Release Info](https://github.com/${e}/releases/tag/${d.version})`,!0),m(this.plugin,U,30,()=>{d&&window.open(`https://github.com/${e}/releases/tag/${d.version}`)}),!0}return i&&m(this.plugin,`No update available for ${e}`,3),!0}}catch(u){console.error(`BRAT: Error adding plugin ${e}:`,{error:u,updatePluginFiles:t,seeIfUpdatedOnly:n,specifyVersion:o,forceReinstall:r});let d=u instanceof Error?u.message:"Unknown error occurred";return await this.plugin.log(`Error ${t?"updating":"adding"} plugin ${e}: ${d}`,!0),!1}return!0}async reloadPlugin(e){let{plugins:t}=this.plugin.app;try{await t.disablePlugin(e),await t.enablePlugin(e)}catch(n){this.plugin.settings.debuggingMode&&console.log("reload plugin",n)}}async updatePlugin(e,t=!1,n=!1,i=!1,o=""){let r=await this.addPlugin(e,!0,t,n,"",i,!1,o);return!r&&!t&&m(this.plugin,`${e}
|
|
Update of plugin failed.`),r}async checkForPluginUpdatesAndInstallUpdates(e=!1,t=!1){var a,l;if(!await be()){console.log("BRAT: No internet detected.");return}let n,i="Checking for plugin updates STARTED";await this.plugin.log(i,!0),e&&this.plugin.settings.notificationsEnabled&&(n=new O.Notice(`BRAT
|
|
${i}`,3e4));let o=new Map(this.plugin.settings.pluginSubListFrozenVersion.map(u=>[u.repo,{version:u.version,token:u.token}]));for(let u of this.plugin.settings.pluginList)o.has(u)&&((a=o.get(u))==null?void 0:a.version)!=="latest"||await this.updatePlugin(u,t,!1,!1,(l=o.get(u))==null?void 0:l.token);let r="Checking for plugin updates COMPLETED";await this.plugin.log(r,!0),e&&(n&&n.hide(),m(this.plugin,r,10))}deletePlugin(e){let t=`Removed ${e} from BRAT plugin list`;this.plugin.log(t,!0),this.plugin.settings.pluginList=this.plugin.settings.pluginList.filter(n=>n!==e),this.plugin.settings.pluginSubListFrozenVersion=this.plugin.settings.pluginSubListFrozenVersion.filter(n=>n.repo!==e),this.plugin.saveSettings()}getEnabledDisabledPlugins(e){let t=this.plugin.app.plugins,n=Object.values(t.manifests),i=Object.values(t.plugins).map(o=>o.manifest);return e?n.filter(o=>i.find(r=>o.id===r.id)):n.filter(o=>!i.find(r=>o.id===r.id))}};var M=require("obsidian");var Q=async(s,e,t)=>{let n=await H(e,!0,s.settings.debuggingMode);if(n||(n=await H(e,!1,s.settings.debuggingMode)),!n)return m(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 dt(e,s.settings.debuggingMode);if(!i)return m(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),r=(0,M.normalizePath)(Nn(s)+o.name),{adapter:a}=s.app.vault;await a.exists(r)||await a.mkdir(r),await a.write((0,M.normalizePath)(`${r}/theme.css`),n),await a.write((0,M.normalizePath)(`${r}/manifest.json`),i),wt(s,e,Y(n));let l="";return t?(ft(s,e,n),l=`${o.name} theme installed from ${e}. `,setTimeout(()=>{s.app.customCss.setTheme(o.name)},500)):l=`${o.name} theme updated from ${e}.`,s.log(`${l}[Theme Info](https://github.com/${e})`,!1),m(s,l,20,()=>{window.open(`https://github.com/${e}`)}),!0},G=async(s,e)=>{if(!await be()){console.log("BRAT: No internet detected.");return}let t,n="Checking for beta theme updates STARTED";await s.log(n,!0),e&&s.settings.notificationsEnabled&&(t=new M.Notice(`BRAT
|
|
${n}`,3e4));for(let o of s.settings.themesList){let r=await X(o.repo,!0,s.settings.debuggingMode);r==="0"&&(r=await X(o.repo,!1,s.settings.debuggingMode)),console.log("BRAT: lastUpdateOnline",r),r!==o.lastUpdate&&await Q(s,o.repo,!1)}let i="Checking for beta theme updates COMPLETED";(async()=>await s.log(i,!0))(),e&&(s.settings.notificationsEnabled&&t&&t.hide(),m(s,i))},Ee=(s,e)=>{s.settings.themesList=s.settings.themesList.filter(n=>n.repo!==e),s.saveSettings();let t=`Removed ${e} 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(t,!0),m(s,t)},Nn=s=>`${(0,M.normalizePath)(`${s.app.vault.configDir}/themes`)}/`;var B=require("obsidian");var D=class extends B.Modal{constructor(e,t=!1){super(e.app),this.plugin=e,this.address="",this.openSettingsTabAfterwards=t}async submitForm(){if(this.address==="")return;let e=this.address.replace("https://github.com/","");if(bt(this.plugin,e)){m(this.plugin,"This theme is already in the list for beta testing",10);return}await Q(this.plugin,e,!0)&&this.close()}onOpen(){this.contentEl.createEl("h4",{text:"Github repository for beta theme:"}),this.contentEl.createEl("form",{},e=>{e.addClass("brat-modal"),new B.Setting(e).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)}),e.createDiv("modal-button-container",i=>{new B.ButtonComponent(i).setButtonText("Never mind").onClick(()=>{this.close()}),new B.ButtonComponent(i).setButtonText("Add theme").setCta().onClick(o=>{o.preventDefault(),console.log("Add theme button clicked"),this.address!==""&&this.submitForm()})});let t=e.createDiv();t.style.borderTop="1px solid #ccc",t.style.marginTop="30px";let n=t.createSpan();n.innerHTML="BRAT by <a href='https://bit.ly/o42-twitter'>TFTHacker</a>",n.style.fontStyle="italic",t.appendChild(n),_(t,!1),window.setTimeout(()=>{let i=e.querySelectorAll(".brat-modal .setting-item-info");for(let o of Array.from(i))o.remove()},50)})}onClose(){this.openSettingsTabAfterwards&&(this.plugin.app.setting.openTab(),this.plugin.app.setting.openTabById(this.plugin.APP_ID))}};var Pt=require("obsidian"),N=class extends Pt.FuzzySuggestModal{constructor(t){super(t.app);this.data=[];this.scope.register(["Shift"],"Enter",n=>{this.enterTrigger(n)}),this.scope.register(["Ctrl"],"Enter",n=>{this.enterTrigger(n)})}setSuggesterData(t){this.data=t}display(t){this.callbackFunction=t,this.open()}getItems(){return this.data}getItemText(t){return t.display}onChooseItem(){}renderSuggestion(t,n){n.createEl("div",{text:t.item.display})}enterTrigger(t){var o;let n=(o=document.querySelector(".suggestion-item.is-selected div"))==null?void 0:o.textContent,i=this.data.find(r=>r.display===n);i&&(this.invokeCallback(i,t),this.close())}onChooseSuggestion(t,n){this.invokeCallback(t.item,n)}invokeCallback(t,n){typeof this.callbackFunction=="function"&&this.callbackFunction(t,n)}};var Z=class{constructor(e){this.bratCommands=[{id:"AddBetaPlugin",icon:"BratIcon",name:"Plugins: Add a beta plugin for testing (with or without version)",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 don't Update",showInRibbon:!0,callback:async()=>{await this.plugin.betaPlugins.checkForPluginUpdatesAndInstallUpdates(!0,!0)}},{id:"updateOnePlugin",icon:"BratIcon",name:"Plugins: Choose a single plugin version to update",showInRibbon:!0,callback:()=>{let e=new Map(this.plugin.settings.pluginSubListFrozenVersion.map(i=>[i.repo,{version:i.version,token:i.token}])),t=Object.values(this.plugin.settings.pluginList).filter(i=>{let o=e.get(i);return!(o!=null&&o.version)||o.version==="latest"}).map(i=>{let o=e.get(i);return{display:i,info:i}}),n=new N(this.plugin);n.setSuggesterData(t),n.display(i=>{let o=`Checking for updates for ${i.info}`,r=e.get(i.info);this.plugin.log(o,!0),m(this.plugin,`
|
|
${o}`,3),this.plugin.betaPlugins.updatePlugin(i.info,!1,!0,!1,r==null?void 0:r.token)})}},{id:"reinstallOnePlugin",icon:"BratIcon",name:"Plugins: Choose a single plugin to reinstall",showInRibbon:!0,callback:()=>{let e=new Set(this.plugin.settings.pluginSubListFrozenVersion.map(i=>i.repo)),t=Object.values(this.plugin.settings.pluginList).filter(i=>!e.has(i)).map(i=>({display:i,info:i})),n=new N(this.plugin);n.setSuggesterData(t),n.display(i=>{let o=`Reinstalling ${i.info}`;m(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 e=Object.values(this.plugin.app.plugins.manifests).map(n=>({display:n.id,info:n.id})),t=new N(this.plugin);t.setSuggesterData(e),t.display(n=>{m(this.plugin,`${n.info}
|
|
Plugin reloading .....`,5),this.plugin.betaPlugins.reloadPlugin(n.info)})}},{id:"disablePlugin",icon:"BratIcon",name:"Plugins: Disable a plugin - toggle it off",showInRibbon:!0,callback:()=>{let e=this.plugin.betaPlugins.getEnabledDisabledPlugins(!0).map(n=>({display:`${n.name} (${n.id})`,info:n.id})),t=new N(this.plugin);t.setSuggesterData(e),t.display(n=>{this.plugin.log(`${n.display} plugin disabled`,!1),this.plugin.settings.debuggingMode&&console.log(n.info),this.plugin.app.plugins.disablePluginAndSave(n.info)})}},{id:"enablePlugin",icon:"BratIcon",name:"Plugins: Enable a plugin - toggle it on",showInRibbon:!0,callback:()=>{let e=this.plugin.betaPlugins.getEnabledDisabledPlugins(!1).map(n=>({display:`${n.name} (${n.id})`,info:n.id})),t=new N(this.plugin);t.setSuggesterData(e),t.display(n=>{this.plugin.log(`${n.display} plugin enabled`,!1),this.plugin.app.plugins.enablePluginAndSave(n.info)})}},{id:"openGitHubZRepository",icon:"BratIcon",name:"Plugins: Open the GitHub repository for a plugin",showInRibbon:!0,callback:async()=>{let e=await gt(this.plugin.settings.debuggingMode);if(e){let t=Object.values(e).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}));for(let o of t)n.push(o);let i=new N(this.plugin);i.setSuggesterData(n),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 e=await ct(this.plugin.settings.debuggingMode);if(e){let t=Object.values(e).map(i=>({display:`Theme: ${i.name} (${i.repo})`,info:i.repo})),n=new N(this.plugin);n.setSuggesterData(t),n.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 e=this.plugin.app.setting,t=Object.values(e.pluginTabs).map(o=>({display:`Plugin: ${o.name}`,info:o.id})),n=new N(this.plugin),i=Object.values(e.settingTabs).map(o=>({display:`Core: ${o.name}`,info:o.id}));for(let o of t)i.push(o);n.setSuggesterData(i),n.display(o=>{e.open(),e.openTabById(o.info)})}},{id:"GrabBetaTheme",icon:"BratIcon",name:"Themes: Grab a beta theme for testing from a Github repository",showInRibbon:!0,callback:()=>{new D(this.plugin).open()}},{id:"updateBetaThemes",icon:"BratIcon",name:"Themes: Update beta themes",showInRibbon:!0,callback:async()=>{await G(this.plugin,!0)}},{id:"allCommands",icon:"BratIcon",name:"All Commands list",showInRibbon:!1,callback:()=>{this.ribbonDisplayCommands()}}];this.plugin=e;for(let t of this.bratCommands)this.plugin.addCommand({id:t.id,name:t.name,icon:t.icon,callback:()=>{t.callback()}})}ribbonDisplayCommands(){let e=[];for(let r of this.bratCommands)r.showInRibbon&&e.push({display:r.name,info:r.callback});let t=new N(this.plugin),n=this.plugin.app.setting,i=Object.values(n.settingTabs).map(r=>({display:`Core: ${r.name}`,info:()=>{n.open(),n.openTabById(r.id)}})),o=Object.values(n.pluginTabs).map(r=>({display:`Plugin: ${r.name}`,info:()=>{n.open(),n.openTabById(r.id)}}));e.push({display:"---- Core Plugin Settings ----",info:()=>{this.ribbonDisplayCommands()}});for(let r of i)e.push(r);e.push({display:"---- Plugin Settings ----",info:()=>{this.ribbonDisplayCommands()}});for(let r of o)e.push(r);t.setSuggesterData(e),t.display(r=>{typeof r.info=="function"&&r.info()})}};var v=require("obsidian");var ye=class extends v.PluginSettingTab{constructor(e,t){super(e,t),this.plugin=t}display(){let{containerEl:e}=this;e.empty(),new v.Setting(e).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(n=>{n.setValue(this.plugin.settings.enableAfterInstall).onChange(async i=>{this.plugin.settings.enableAfterInstall=i,await this.plugin.saveSettings()})}),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(n=>{n.setValue(this.plugin.settings.updateAtStartup).onChange(async i=>{this.plugin.settings.updateAtStartup=i,await 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(n=>{n.setValue(this.plugin.settings.updateThemesAtStartup).onChange(async i=>{this.plugin.settings.updateThemesAtStartup=i,await this.plugin.saveSettings()})}),_(e,!0),e.createEl("hr"),new v.Setting(e).setName("Beta plugin list").setHeading(),e.createEl("div",{text:'The following is a list of beta plugins added via the command "Add a beta plugin for testing". You can chose to add the latest version or a frozen version. A frozen version is a specific release of a plugin based on its release tag.'}),e.createEl("p"),e.createEl("div",{text:"Click the 'Edit' button next to a plugin to change the installed version and 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:"Removing from the list does not delete the plugin, this should be done from the Community Plugins tab in Settings."}),new v.Setting(e).addButton(n=>{n.setButtonText("Add beta plugin").setCta().onClick(()=>{this.plugin.betaPlugins.displayAddNewPluginModal(!0,!0)})});let t=new Map(this.plugin.settings.pluginSubListFrozenVersion.map(n=>[n.repo,{version:n.version,token:n.token}]));for(let n of this.plugin.settings.pluginList){let i=t.get(n),o=new v.Setting(e).setName(W(n)).setDesc(i!=null&&i.version?` Tracked version: ${i.version} ${i.version==="latest"?"":"(frozen)"}`:"");(!(i!=null&&i.version)||i.version==="latest")&&o.addButton(r=>{r.setIcon("sync").setTooltip("Check and update plugin").onClick(async()=>{await this.plugin.betaPlugins.updatePlugin(n,!1,!0,!1,i==null?void 0:i.token)})}),o.addButton(r=>{r.setIcon("edit").setTooltip("Change version").onClick(()=>{this.plugin.betaPlugins.displayAddNewPluginModal(!0,!0,n,i==null?void 0:i.version,i==null?void 0:i.token),this.plugin.app.setting.updatePluginSection()})}).addButton(r=>{r.setIcon("cross").setTooltip("Remove this beta plugin").setWarning().onClick(()=>{if(r.buttonEl.textContent==="")r.setButtonText("Click once more to confirm removal");else{let{buttonEl:a}=r,{parentElement:l}=a;l!=null&&l.parentElement&&(l.parentElement.remove(),this.plugin.betaPlugins.deletePlugin(n))}})})}new v.Setting(e).setName("Beta themes list").setHeading(),new v.Setting(e).addButton(n=>{n.setButtonText("Add beta theme").setCta().onClick(()=>{this.plugin.app.setting.close(),new D(this.plugin).open()})});for(let n of this.plugin.settings.themesList)new v.Setting(e).setName(W(n.repo)).addButton(i=>{i.setIcon("cross").setTooltip("Delete this beta theme").onClick(()=>{if(i.buttonEl.textContent==="")i.setButtonText("Click once more to confirm removal");else{let{buttonEl:o}=i,{parentElement:r}=o;r!=null&&r.parentElement&&(r.parentElement.remove(),Ee(this.plugin,n.repo))}})});new v.Setting(e).setName("Monitoring").setHeading(),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(n=>{n.setValue(this.plugin.settings.notificationsEnabled),n.onChange(async i=>{this.plugin.settings.notificationsEnabled=i,await this.plugin.saveSettings()})}),new v.Setting(e).setName("Enable logging").setDesc("Plugin updates will be logged to a file in the log file.").addToggle(n=>{n.setValue(this.plugin.settings.loggingEnabled).onChange(async i=>{this.plugin.settings.loggingEnabled=i,await 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(n=>{n.setPlaceholder("Example: BRAT-log").setValue(this.plugin.settings.loggingPath).onChange(async i=>{this.plugin.settings.loggingPath=i,await this.plugin.saveSettings()})}),new v.Setting(e).setName("Enable verbose logging").setDesc("Get a lot more information in the log.").addToggle(n=>{n.setValue(this.plugin.settings.loggingVerboseEnabled).onChange(async i=>{this.plugin.settings.loggingVerboseEnabled=i,await this.plugin.saveSettings()})}),new v.Setting(e).setName("Debugging mode").setDesc("Atomic Bomb level console logging. Can be used for troubleshoting and development.").addToggle(n=>{n.setValue(this.plugin.settings.debuggingMode).onChange(async i=>{this.plugin.settings.debuggingMode=i,await this.plugin.saveSettings()})}),new v.Setting(e).setName("Personal access token").setDesc("If you need to access private repositories, enter the personal access token here.").addText(n=>{var i;n.setPlaceholder("Enter your personal access token").setValue((i=this.plugin.settings.personalAccessToken)!=null?i:"").onChange(async o=>{this.plugin.settings.personalAccessToken=o,await this.plugin.saveSettings()})})}};var Rt=require("obsidian");function vt(){(0,Rt.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 K=class{constructor(e){this.console=(e,...t)=>{console.log(`BRAT: ${e}`,...t)};this.themes={themeseCheckAndUpates:async e=>{await G(this.plugin,e)},themeInstallTheme:async e=>{let t=e.replace("https://github.com/","");await Q(this.plugin,t,!0)},themesDelete:e=>{let t=e.replace("https://github.com/","");Ee(this.plugin,t)},grabCommmunityThemeCssFile:async(e,t=!1)=>await H(e,t,this.plugin.settings.debuggingMode),grabChecksumOfThemeCssFile:async(e,t=!1)=>await X(e,t,this.plugin.settings.debuggingMode),grabLastCommitDateForFile:async(e,t)=>await pt(e,t)};this.plugin=e}};var ae=require("obsidian"),Ut=Xt(Bt());async function Vt(s,e,t=!1){if(s.settings.debuggingMode&&console.log(`BRAT: ${e}`),s.settings.loggingEnabled){if(!s.settings.loggingVerboseEnabled&&t)return;let n=`${s.settings.loggingPath}.md`,i=`[[${(0,ae.moment)().format((0,Ut.getDailyNoteSettings)().format).toString()}]] ${(0,ae.moment)().format("HH:mm")}`,o=window.require("os"),r=ae.Platform.isDesktop?o.hostname():"MOBILE",a=`${i} ${r} ${e.replace(`
|
|
`," ")}
|
|
`,l=s.app.vault.getAbstractFileByPath(n);l?await s.app.vault.append(l,a):l=await s.app.vault.create(n,a)}}var Te=class extends Ht.Plugin{constructor(){super(...arguments);this.APP_NAME="BRAT";this.APP_ID="obsidian42-brat";this.settings=Oe;this.betaPlugins=new J(this);this.commands=new Z(this);this.bratApi=new K(this);this.obsidianProtocolHandler=t=>{if(!t.plugin&&!t.theme){m(this,"Could not locate the repository from the URL.",10);return}for(let n of["plugin","theme"])if(t[n]){let i=n==="plugin"?new x(this,this.betaPlugins):new D(this);i.address=t[n],i.open();return}}}onload(){console.log(`loading ${this.APP_NAME}`),vt(),this.addRibbonIcon("BratIcon","BRAT",()=>{this.commands.ribbonDisplayCommands()}),this.loadSettings().then(()=>{this.app.workspace.onLayoutReady(()=>{this.addSettingTab(new ye(this.app,this)),this.registerObsidianProtocolHandler("brat",this.obsidianProtocolHandler),this.settings.updateAtStartup&&setTimeout(()=>{this.betaPlugins.checkForPluginUpdatesAndInstallUpdates(!1)},6e4),this.settings.updateThemesAtStartup&&setTimeout(()=>{G(this,!1)},12e4),setTimeout(()=>{window.bratAPI=this.bratApi},500)})}).catch(t=>{console.error("Failed to load settings:",t)})}async log(t,n=!1){await Vt(this,t,n)}onunload(){console.log(`unloading ${this.APP_NAME}`)}async loadSettings(){this.settings=Object.assign({},Oe,await this.loadData())}async saveSettings(){await this.saveData(this.settings)}};
|
|
|
|
/* nosourcemap */ |