45 lines
97 KiB
JavaScript
45 lines
97 KiB
JavaScript
"use strict";var oi=Object.create;var Le=Object.defineProperty;var ai=Object.getOwnPropertyDescriptor;var li=Object.getOwnPropertyNames;var ui=Object.getPrototypeOf,ci=Object.prototype.hasOwnProperty;var E=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),gi=(n,e)=>{for(var t in e)Le(n,t,{get:e[t],enumerable:!0})},xt=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of li(e))!ci.call(n,i)&&i!==t&&Le(n,i,{get:()=>e[i],enumerable:!(s=ai(e,i))||s.enumerable});return n};var Ze=(n,e,t)=>(t=n!=null?oi(ui(n)):{},xt(e||!n||!n.__esModule?Le(t,"default",{value:n,enumerable:!0}):t,n)),di=n=>xt(Le({},"__esModule",{value:!0}),n);var ae=E((Ma,Dt)=>{"use strict";var pi="2.0.0",mi=Number.MAX_SAFE_INTEGER||9007199254740991,hi=16,fi=250,bi=["major","premajor","minor","preminor","patch","prepatch","prerelease"];Dt.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:hi,MAX_SAFE_BUILD_LENGTH:fi,MAX_SAFE_INTEGER:mi,RELEASE_TYPES:bi,SEMVER_SPEC_VERSION:pi,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var le=E((qa,Ot)=>{"use strict";var wi=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...n)=>console.error("SEMVER",...n):()=>{};Ot.exports=wi});var Z=E((_,Ft)=>{"use strict";var{MAX_SAFE_COMPONENT_LENGTH:et,MAX_SAFE_BUILD_LENGTH:Ti,MAX_LENGTH:Ei}=ae(),vi=le();_=Ft.exports={};var yi=_.re=[],Ri=_.safeRe=[],f=_.src=[],Pi=_.safeSrc=[],b=_.t={},$i=0,tt="[a-zA-Z0-9-]",Ii=[["\\s",1],["\\d",Ei],[tt,Ti]],Ni=n=>{for(let[e,t]of Ii)n=n.split(`${e}*`).join(`${e}{0,${t}}`).split(`${e}+`).join(`${e}{1,${t}}`);return n},y=(n,e,t)=>{let s=Ni(e),i=$i++;vi(n,i,e),b[n]=i,f[i]=e,Pi[i]=s,yi[i]=new RegExp(e,t?"g":void 0),Ri[i]=new RegExp(s,t?"g":void 0)};y("NUMERICIDENTIFIER","0|[1-9]\\d*");y("NUMERICIDENTIFIERLOOSE","\\d+");y("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${tt}*`);y("MAINVERSION",`(${f[b.NUMERICIDENTIFIER]})\\.(${f[b.NUMERICIDENTIFIER]})\\.(${f[b.NUMERICIDENTIFIER]})`);y("MAINVERSIONLOOSE",`(${f[b.NUMERICIDENTIFIERLOOSE]})\\.(${f[b.NUMERICIDENTIFIERLOOSE]})\\.(${f[b.NUMERICIDENTIFIERLOOSE]})`);y("PRERELEASEIDENTIFIER",`(?:${f[b.NONNUMERICIDENTIFIER]}|${f[b.NUMERICIDENTIFIER]})`);y("PRERELEASEIDENTIFIERLOOSE",`(?:${f[b.NONNUMERICIDENTIFIER]}|${f[b.NUMERICIDENTIFIERLOOSE]})`);y("PRERELEASE",`(?:-(${f[b.PRERELEASEIDENTIFIER]}(?:\\.${f[b.PRERELEASEIDENTIFIER]})*))`);y("PRERELEASELOOSE",`(?:-?(${f[b.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${f[b.PRERELEASEIDENTIFIERLOOSE]})*))`);y("BUILDIDENTIFIER",`${tt}+`);y("BUILD",`(?:\\+(${f[b.BUILDIDENTIFIER]}(?:\\.${f[b.BUILDIDENTIFIER]})*))`);y("FULLPLAIN",`v?${f[b.MAINVERSION]}${f[b.PRERELEASE]}?${f[b.BUILD]}?`);y("FULL",`^${f[b.FULLPLAIN]}$`);y("LOOSEPLAIN",`[v=\\s]*${f[b.MAINVERSIONLOOSE]}${f[b.PRERELEASELOOSE]}?${f[b.BUILD]}?`);y("LOOSE",`^${f[b.LOOSEPLAIN]}$`);y("GTLT","((?:<|>)?=?)");y("XRANGEIDENTIFIERLOOSE",`${f[b.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);y("XRANGEIDENTIFIER",`${f[b.NUMERICIDENTIFIER]}|x|X|\\*`);y("XRANGEPLAIN",`[v=\\s]*(${f[b.XRANGEIDENTIFIER]})(?:\\.(${f[b.XRANGEIDENTIFIER]})(?:\\.(${f[b.XRANGEIDENTIFIER]})(?:${f[b.PRERELEASE]})?${f[b.BUILD]}?)?)?`);y("XRANGEPLAINLOOSE",`[v=\\s]*(${f[b.XRANGEIDENTIFIERLOOSE]})(?:\\.(${f[b.XRANGEIDENTIFIERLOOSE]})(?:\\.(${f[b.XRANGEIDENTIFIERLOOSE]})(?:${f[b.PRERELEASELOOSE]})?${f[b.BUILD]}?)?)?`);y("XRANGE",`^${f[b.GTLT]}\\s*${f[b.XRANGEPLAIN]}$`);y("XRANGELOOSE",`^${f[b.GTLT]}\\s*${f[b.XRANGEPLAINLOOSE]}$`);y("COERCEPLAIN",`(^|[^\\d])(\\d{1,${et}})(?:\\.(\\d{1,${et}}))?(?:\\.(\\d{1,${et}}))?`);y("COERCE",`${f[b.COERCEPLAIN]}(?:$|[^\\d])`);y("COERCEFULL",f[b.COERCEPLAIN]+`(?:${f[b.PRERELEASE]})?(?:${f[b.BUILD]})?(?:$|[^\\d])`);y("COERCERTL",f[b.COERCE],!0);y("COERCERTLFULL",f[b.COERCEFULL],!0);y("LONETILDE","(?:~>?)");y("TILDETRIM",`(\\s*)${f[b.LONETILDE]}\\s+`,!0);_.tildeTrimReplace="$1~";y("TILDE",`^${f[b.LONETILDE]}${f[b.XRANGEPLAIN]}$`);y("TILDELOOSE",`^${f[b.LONETILDE]}${f[b.XRANGEPLAINLOOSE]}$`);y("LONECARET","(?:\\^)");y("CARETTRIM",`(\\s*)${f[b.LONECARET]}\\s+`,!0);_.caretTrimReplace="$1^";y("CARET",`^${f[b.LONECARET]}${f[b.XRANGEPLAIN]}$`);y("CARETLOOSE",`^${f[b.LONECARET]}${f[b.XRANGEPLAINLOOSE]}$`);y("COMPARATORLOOSE",`^${f[b.GTLT]}\\s*(${f[b.LOOSEPLAIN]})$|^$`);y("COMPARATOR",`^${f[b.GTLT]}\\s*(${f[b.FULLPLAIN]})$|^$`);y("COMPARATORTRIM",`(\\s*)${f[b.GTLT]}\\s*(${f[b.LOOSEPLAIN]}|${f[b.XRANGEPLAIN]})`,!0);_.comparatorTrimReplace="$1$2$3";y("HYPHENRANGE",`^\\s*(${f[b.XRANGEPLAIN]})\\s+-\\s+(${f[b.XRANGEPLAIN]})\\s*$`);y("HYPHENRANGELOOSE",`^\\s*(${f[b.XRANGEPLAINLOOSE]})\\s+-\\s+(${f[b.XRANGEPLAINLOOSE]})\\s*$`);y("STAR","(<|>)?=?\\s*\\*");y("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");y("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var ke=E((Va,Bt)=>{"use strict";var Ai=Object.freeze({loose:!0}),Ci=Object.freeze({}),Si=n=>n?typeof n!="object"?Ai:n:Ci;Bt.exports=Si});var st=E((Ua,Vt)=>{"use strict";var Mt=/^[0-9]+$/,qt=(n,e)=>{if(typeof n=="number"&&typeof e=="number")return n===e?0:n<e?-1:1;let t=Mt.test(n),s=Mt.test(e);return t&&s&&(n=+n,e=+e),n===e?0:t&&!s?-1:s&&!t?1:n<e?-1:1},Li=(n,e)=>qt(e,n);Vt.exports={compareIdentifiers:qt,rcompareIdentifiers:Li}});var C=E((Ha,Ht)=>{"use strict";var xe=le(),{MAX_LENGTH:Ut,MAX_SAFE_INTEGER:De}=ae(),{safeRe:Oe,t:Fe}=Z(),ki=ke(),{compareIdentifiers:nt}=st(),it=class n{constructor(e,t){if(t=ki(t),e instanceof n){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>Ut)throw new TypeError(`version is longer than ${Ut} characters`);xe("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;let s=e.trim().match(t.loose?Oe[Fe.LOOSE]:Oe[Fe.FULL]);if(!s)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+s[1],this.minor=+s[2],this.patch=+s[3],this.major>De||this.major<0)throw new TypeError("Invalid major version");if(this.minor>De||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>De||this.patch<0)throw new TypeError("Invalid patch version");s[4]?this.prerelease=s[4].split(".").map(i=>{if(/^[0-9]+$/.test(i)){let r=+i;if(r>=0&&r<De)return r}return i}):this.prerelease=[],this.build=s[5]?s[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(xe("SemVer.compare",this.version,this.options,e),!(e instanceof n)){if(typeof e=="string"&&e===this.version)return 0;e=new n(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof n||(e=new n(e,this.options)),this.major<e.major?-1:this.major>e.major?1:this.minor<e.minor?-1:this.minor>e.minor?1:this.patch<e.patch?-1:this.patch>e.patch?1:0}comparePre(e){if(e instanceof n||(e=new n(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 s=this.prerelease[t],i=e.prerelease[t];if(xe("prerelease compare",t,s,i),s===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(s===void 0)return-1;if(s===i)continue;return nt(s,i)}while(++t)}compareBuild(e){e instanceof n||(e=new n(e,this.options));let t=0;do{let s=this.build[t],i=e.build[t];if(xe("build compare",t,s,i),s===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(s===void 0)return-1;if(s===i)continue;return nt(s,i)}while(++t)}inc(e,t,s){if(e.startsWith("pre")){if(!t&&s===!1)throw new Error("invalid increment argument: identifier is empty");if(t){let i=`-${t}`.match(this.options.loose?Oe[Fe.PRERELEASELOOSE]:Oe[Fe.PRERELEASE]);if(!i||i[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,s);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t,s);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t,s),this.inc("pre",t,s);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",t,s),this.inc("pre",t,s);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(s)?1:0;if(this.prerelease.length===0)this.prerelease=[i];else{let r=this.prerelease.length;for(;--r>=0;)typeof this.prerelease[r]=="number"&&(this.prerelease[r]++,r=-2);if(r===-1){if(t===this.prerelease.join(".")&&s===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(i)}}if(t){let r=[t,i];s===!1&&(r=[t]),nt(this.prerelease[0],t)===0?isNaN(this.prerelease[1])&&(this.prerelease=r):this.prerelease=r}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};Ht.exports=it});var X=E((_a,Gt)=>{"use strict";var _t=C(),xi=(n,e,t=!1)=>{if(n instanceof _t)return n;try{return new _t(n,e)}catch(s){if(!t)return null;throw s}};Gt.exports=xi});var zt=E((Ga,jt)=>{"use strict";var Di=X(),Oi=(n,e)=>{let t=Di(n,e);return t?t.version:null};jt.exports=Oi});var Xt=E((ja,Yt)=>{"use strict";var Fi=X(),Bi=(n,e)=>{let t=Fi(n.trim().replace(/^[=v]+/,""),e);return t?t.version:null};Yt.exports=Bi});var Kt=E((za,Jt)=>{"use strict";var Wt=C(),Mi=(n,e,t,s,i)=>{typeof t=="string"&&(i=s,s=t,t=void 0);try{return new Wt(n instanceof Wt?n.version:n,t).inc(e,s,i).version}catch(r){return null}};Jt.exports=Mi});var es=E((Ya,Zt)=>{"use strict";var Qt=X(),qi=(n,e)=>{let t=Qt(n,null,!0),s=Qt(e,null,!0),i=t.compare(s);if(i===0)return null;let r=i>0,o=r?t:s,c=r?s:t,l=!!o.prerelease.length;if(!!c.prerelease.length&&!l){if(!c.patch&&!c.minor)return"major";if(c.compareMain(o)===0)return c.minor&&!c.patch?"minor":"patch"}let p=l?"pre":"";return t.major!==s.major?p+"major":t.minor!==s.minor?p+"minor":t.patch!==s.patch?p+"patch":"prerelease"};Zt.exports=qi});var ss=E((Xa,ts)=>{"use strict";var Vi=C(),Ui=(n,e)=>new Vi(n,e).major;ts.exports=Ui});var is=E((Wa,ns)=>{"use strict";var Hi=C(),_i=(n,e)=>new Hi(n,e).minor;ns.exports=_i});var os=E((Ja,rs)=>{"use strict";var Gi=C(),ji=(n,e)=>new Gi(n,e).patch;rs.exports=ji});var ls=E((Ka,as)=>{"use strict";var zi=X(),Yi=(n,e)=>{let t=zi(n,e);return t&&t.prerelease.length?t.prerelease:null};as.exports=Yi});var B=E((Qa,cs)=>{"use strict";var us=C(),Xi=(n,e,t)=>new us(n,t).compare(new us(e,t));cs.exports=Xi});var ds=E((Za,gs)=>{"use strict";var Wi=B(),Ji=(n,e,t)=>Wi(e,n,t);gs.exports=Ji});var ms=E((el,ps)=>{"use strict";var Ki=B(),Qi=(n,e)=>Ki(n,e,!0);ps.exports=Qi});var Be=E((tl,fs)=>{"use strict";var hs=C(),Zi=(n,e,t)=>{let s=new hs(n,t),i=new hs(e,t);return s.compare(i)||s.compareBuild(i)};fs.exports=Zi});var ws=E((sl,bs)=>{"use strict";var er=Be(),tr=(n,e)=>n.sort((t,s)=>er(t,s,e));bs.exports=tr});var Es=E((nl,Ts)=>{"use strict";var sr=Be(),nr=(n,e)=>n.sort((t,s)=>sr(s,t,e));Ts.exports=nr});var ue=E((il,vs)=>{"use strict";var ir=B(),rr=(n,e,t)=>ir(n,e,t)>0;vs.exports=rr});var Me=E((rl,ys)=>{"use strict";var or=B(),ar=(n,e,t)=>or(n,e,t)<0;ys.exports=ar});var rt=E((ol,Rs)=>{"use strict";var lr=B(),ur=(n,e,t)=>lr(n,e,t)===0;Rs.exports=ur});var ot=E((al,Ps)=>{"use strict";var cr=B(),gr=(n,e,t)=>cr(n,e,t)!==0;Ps.exports=gr});var qe=E((ll,$s)=>{"use strict";var dr=B(),pr=(n,e,t)=>dr(n,e,t)>=0;$s.exports=pr});var Ve=E((ul,Is)=>{"use strict";var mr=B(),hr=(n,e,t)=>mr(n,e,t)<=0;Is.exports=hr});var at=E((cl,Ns)=>{"use strict";var fr=rt(),br=ot(),wr=ue(),Tr=qe(),Er=Me(),vr=Ve(),yr=(n,e,t,s)=>{switch(e){case"===":return typeof n=="object"&&(n=n.version),typeof t=="object"&&(t=t.version),n===t;case"!==":return typeof n=="object"&&(n=n.version),typeof t=="object"&&(t=t.version),n!==t;case"":case"=":case"==":return fr(n,t,s);case"!=":return br(n,t,s);case">":return wr(n,t,s);case">=":return Tr(n,t,s);case"<":return Er(n,t,s);case"<=":return vr(n,t,s);default:throw new TypeError(`Invalid operator: ${e}`)}};Ns.exports=yr});var Cs=E((gl,As)=>{"use strict";var Rr=C(),Pr=X(),{safeRe:Ue,t:He}=Z(),$r=(n,e)=>{if(n instanceof Rr)return n;if(typeof n=="number"&&(n=String(n)),typeof n!="string")return null;e=e||{};let t=null;if(!e.rtl)t=n.match(e.includePrerelease?Ue[He.COERCEFULL]:Ue[He.COERCE]);else{let l=e.includePrerelease?Ue[He.COERCERTLFULL]:Ue[He.COERCERTL],d;for(;(d=l.exec(n))&&(!t||t.index+t[0].length!==n.length);)(!t||d.index+d[0].length!==t.index+t[0].length)&&(t=d),l.lastIndex=d.index+d[1].length+d[2].length;l.lastIndex=-1}if(t===null)return null;let s=t[2],i=t[3]||"0",r=t[4]||"0",o=e.includePrerelease&&t[5]?`-${t[5]}`:"",c=e.includePrerelease&&t[6]?`+${t[6]}`:"";return Pr(`${s}.${i}.${r}${o}${c}`,e)};As.exports=$r});var Ls=E((dl,Ss)=>{"use strict";var lt=class{constructor(){this.max=1e3,this.map=new Map}get(e){let t=this.map.get(e);if(t!==void 0)return this.map.delete(e),this.map.set(e,t),t}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&t!==void 0){if(this.map.size>=this.max){let i=this.map.keys().next().value;this.delete(i)}this.map.set(e,t)}return this}};Ss.exports=lt});var M=E((pl,Os)=>{"use strict";var Ir=/\s+/g,ut=class n{constructor(e,t){if(t=Ar(t),e instanceof n)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new n(e.raw,t);if(e instanceof ct)return this.raw=e.value,this.set=[[e]],this.formatted=void 0,this;if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e.trim().replace(Ir," "),this.set=this.raw.split("||").map(s=>this.parseRange(s.trim())).filter(s=>s.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let s=this.set[0];if(this.set=this.set.filter(i=>!xs(i[0])),this.set.length===0)this.set=[s];else if(this.set.length>1){for(let i of this.set)if(i.length===1&&Or(i[0])){this.set=[i];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+="||");let t=this.set[e];for(let s=0;s<t.length;s++)s>0&&(this.formatted+=" "),this.formatted+=t[s].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){let s=((this.options.includePrerelease&&xr)|(this.options.loose&&Dr))+":"+e,i=ks.get(s);if(i)return i;let r=this.options.loose,o=r?L[S.HYPHENRANGELOOSE]:L[S.HYPHENRANGE];e=e.replace(o,jr(this.options.includePrerelease)),$("hyphen replace",e),e=e.replace(L[S.COMPARATORTRIM],Sr),$("comparator trim",e),e=e.replace(L[S.TILDETRIM],Lr),$("tilde trim",e),e=e.replace(L[S.CARETTRIM],kr),$("caret trim",e);let c=e.split(" ").map(a=>Fr(a,this.options)).join(" ").split(/\s+/).map(a=>Gr(a,this.options));r&&(c=c.filter(a=>($("loose invalid filter",a,this.options),!!a.match(L[S.COMPARATORLOOSE])))),$("range list",c);let l=new Map,d=c.map(a=>new ct(a,this.options));for(let a of d){if(xs(a))return[a];l.set(a.value,a)}l.size>1&&l.has("")&&l.delete("");let p=[...l.values()];return ks.set(s,p),p}intersects(e,t){if(!(e instanceof n))throw new TypeError("a Range is required");return this.set.some(s=>Ds(s,t)&&e.set.some(i=>Ds(i,t)&&s.every(r=>i.every(o=>r.intersects(o,t)))))}test(e){if(!e)return!1;if(typeof e=="string")try{e=new Cr(e,this.options)}catch(t){return!1}for(let t=0;t<this.set.length;t++)if(zr(this.set[t],e,this.options))return!0;return!1}};Os.exports=ut;var Nr=Ls(),ks=new Nr,Ar=ke(),ct=ce(),$=le(),Cr=C(),{safeRe:L,t:S,comparatorTrimReplace:Sr,tildeTrimReplace:Lr,caretTrimReplace:kr}=Z(),{FLAG_INCLUDE_PRERELEASE:xr,FLAG_LOOSE:Dr}=ae(),xs=n=>n.value==="<0.0.0-0",Or=n=>n.value==="",Ds=(n,e)=>{let t=!0,s=n.slice(),i=s.pop();for(;t&&s.length;)t=s.every(r=>i.intersects(r,e)),i=s.pop();return t},Fr=(n,e)=>(n=n.replace(L[S.BUILD],""),$("comp",n,e),n=qr(n,e),$("caret",n),n=Br(n,e),$("tildes",n),n=Ur(n,e),$("xrange",n),n=_r(n,e),$("stars",n),n),k=n=>!n||n.toLowerCase()==="x"||n==="*",Br=(n,e)=>n.trim().split(/\s+/).map(t=>Mr(t,e)).join(" "),Mr=(n,e)=>{let t=e.loose?L[S.TILDELOOSE]:L[S.TILDE];return n.replace(t,(s,i,r,o,c)=>{$("tilde",n,s,i,r,o,c);let l;return k(i)?l="":k(r)?l=`>=${i}.0.0 <${+i+1}.0.0-0`:k(o)?l=`>=${i}.${r}.0 <${i}.${+r+1}.0-0`:c?($("replaceTilde pr",c),l=`>=${i}.${r}.${o}-${c} <${i}.${+r+1}.0-0`):l=`>=${i}.${r}.${o} <${i}.${+r+1}.0-0`,$("tilde return",l),l})},qr=(n,e)=>n.trim().split(/\s+/).map(t=>Vr(t,e)).join(" "),Vr=(n,e)=>{$("caret",n,e);let t=e.loose?L[S.CARETLOOSE]:L[S.CARET],s=e.includePrerelease?"-0":"";return n.replace(t,(i,r,o,c,l)=>{$("caret",n,i,r,o,c,l);let d;return k(r)?d="":k(o)?d=`>=${r}.0.0${s} <${+r+1}.0.0-0`:k(c)?r==="0"?d=`>=${r}.${o}.0${s} <${r}.${+o+1}.0-0`:d=`>=${r}.${o}.0${s} <${+r+1}.0.0-0`:l?($("replaceCaret pr",l),r==="0"?o==="0"?d=`>=${r}.${o}.${c}-${l} <${r}.${o}.${+c+1}-0`:d=`>=${r}.${o}.${c}-${l} <${r}.${+o+1}.0-0`:d=`>=${r}.${o}.${c}-${l} <${+r+1}.0.0-0`):($("no pr"),r==="0"?o==="0"?d=`>=${r}.${o}.${c}${s} <${r}.${o}.${+c+1}-0`:d=`>=${r}.${o}.${c}${s} <${r}.${+o+1}.0-0`:d=`>=${r}.${o}.${c} <${+r+1}.0.0-0`),$("caret return",d),d})},Ur=(n,e)=>($("replaceXRanges",n,e),n.split(/\s+/).map(t=>Hr(t,e)).join(" ")),Hr=(n,e)=>{n=n.trim();let t=e.loose?L[S.XRANGELOOSE]:L[S.XRANGE];return n.replace(t,(s,i,r,o,c,l)=>{$("xRange",n,s,i,r,o,c,l);let d=k(r),p=d||k(o),a=p||k(c),u=a;return i==="="&&u&&(i=""),l=e.includePrerelease?"-0":"",d?i===">"||i==="<"?s="<0.0.0-0":s="*":i&&u?(p&&(o=0),c=0,i===">"?(i=">=",p?(r=+r+1,o=0,c=0):(o=+o+1,c=0)):i==="<="&&(i="<",p?r=+r+1:o=+o+1),i==="<"&&(l="-0"),s=`${i+r}.${o}.${c}${l}`):p?s=`>=${r}.0.0${l} <${+r+1}.0.0-0`:a&&(s=`>=${r}.${o}.0${l} <${r}.${+o+1}.0-0`),$("xRange return",s),s})},_r=(n,e)=>($("replaceStars",n,e),n.trim().replace(L[S.STAR],"")),Gr=(n,e)=>($("replaceGTE0",n,e),n.trim().replace(L[e.includePrerelease?S.GTE0PRE:S.GTE0],"")),jr=n=>(e,t,s,i,r,o,c,l,d,p,a,u)=>(k(s)?t="":k(i)?t=`>=${s}.0.0${n?"-0":""}`:k(r)?t=`>=${s}.${i}.0${n?"-0":""}`:o?t=`>=${t}`:t=`>=${t}${n?"-0":""}`,k(d)?l="":k(p)?l=`<${+d+1}.0.0-0`:k(a)?l=`<${d}.${+p+1}.0-0`:u?l=`<=${d}.${p}.${a}-${u}`:n?l=`<${d}.${p}.${+a+1}-0`:l=`<=${l}`,`${t} ${l}`.trim()),zr=(n,e,t)=>{for(let s=0;s<n.length;s++)if(!n[s].test(e))return!1;if(e.prerelease.length&&!t.includePrerelease){for(let s=0;s<n.length;s++)if($(n[s].semver),n[s].semver!==ct.ANY&&n[s].semver.prerelease.length>0){let i=n[s].semver;if(i.major===e.major&&i.minor===e.minor&&i.patch===e.patch)return!0}return!1}return!0}});var ce=E((ml,Us)=>{"use strict";var ge=Symbol("SemVer ANY"),pt=class n{static get ANY(){return ge}constructor(e,t){if(t=Fs(t),e instanceof n){if(e.loose===!!t.loose)return e;e=e.value}e=e.trim().split(/\s+/).join(" "),dt("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===ge?this.value="":this.value=this.operator+this.semver.version,dt("comp",this)}parse(e){let t=this.options.loose?Bs[Ms.COMPARATORLOOSE]:Bs[Ms.COMPARATOR],s=e.match(t);if(!s)throw new TypeError(`Invalid comparator: ${e}`);this.operator=s[1]!==void 0?s[1]:"",this.operator==="="&&(this.operator=""),s[2]?this.semver=new qs(s[2],this.options.loose):this.semver=ge}toString(){return this.value}test(e){if(dt("Comparator.test",e,this.options.loose),this.semver===ge||e===ge)return!0;if(typeof e=="string")try{e=new qs(e,this.options)}catch(t){return!1}return gt(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof n))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new Vs(e.value,t).test(this.value):e.operator===""?e.value===""?!0:new Vs(this.value,t).test(e.semver):(t=Fs(t),t.includePrerelease&&(this.value==="<0.0.0-0"||e.value==="<0.0.0-0")||!t.includePrerelease&&(this.value.startsWith("<0.0.0")||e.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&e.operator.startsWith(">")||this.operator.startsWith("<")&&e.operator.startsWith("<")||this.semver.version===e.semver.version&&this.operator.includes("=")&&e.operator.includes("=")||gt(this.semver,"<",e.semver,t)&&this.operator.startsWith(">")&&e.operator.startsWith("<")||gt(this.semver,">",e.semver,t)&&this.operator.startsWith("<")&&e.operator.startsWith(">")))}};Us.exports=pt;var Fs=ke(),{safeRe:Bs,t:Ms}=Z(),gt=at(),dt=le(),qs=C(),Vs=M()});var de=E((hl,Hs)=>{"use strict";var Yr=M(),Xr=(n,e,t)=>{try{e=new Yr(e,t)}catch(s){return!1}return e.test(n)};Hs.exports=Xr});var Gs=E((fl,_s)=>{"use strict";var Wr=M(),Jr=(n,e)=>new Wr(n,e).set.map(t=>t.map(s=>s.value).join(" ").trim().split(" "));_s.exports=Jr});var zs=E((bl,js)=>{"use strict";var Kr=C(),Qr=M(),Zr=(n,e,t)=>{let s=null,i=null,r=null;try{r=new Qr(e,t)}catch(o){return null}return n.forEach(o=>{r.test(o)&&(!s||i.compare(o)===-1)&&(s=o,i=new Kr(s,t))}),s};js.exports=Zr});var Xs=E((wl,Ys)=>{"use strict";var eo=C(),to=M(),so=(n,e,t)=>{let s=null,i=null,r=null;try{r=new to(e,t)}catch(o){return null}return n.forEach(o=>{r.test(o)&&(!s||i.compare(o)===1)&&(s=o,i=new eo(s,t))}),s};Ys.exports=so});var Ks=E((Tl,Js)=>{"use strict";var mt=C(),no=M(),Ws=ue(),io=(n,e)=>{n=new no(n,e);let t=new mt("0.0.0");if(n.test(t)||(t=new mt("0.0.0-0"),n.test(t)))return t;t=null;for(let s=0;s<n.set.length;++s){let i=n.set[s],r=null;i.forEach(o=>{let c=new mt(o.semver.version);switch(o.operator){case">":c.prerelease.length===0?c.patch++:c.prerelease.push(0),c.raw=c.format();case"":case">=":(!r||Ws(c,r))&&(r=c);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${o.operator}`)}}),r&&(!t||Ws(t,r))&&(t=r)}return t&&n.test(t)?t:null};Js.exports=io});var Zs=E((El,Qs)=>{"use strict";var ro=M(),oo=(n,e)=>{try{return new ro(n,e).range||"*"}catch(t){return null}};Qs.exports=oo});var _e=E((vl,nn)=>{"use strict";var ao=C(),sn=ce(),{ANY:lo}=sn,uo=M(),co=de(),en=ue(),tn=Me(),go=Ve(),po=qe(),mo=(n,e,t,s)=>{n=new ao(n,s),e=new uo(e,s);let i,r,o,c,l;switch(t){case">":i=en,r=go,o=tn,c=">",l=">=";break;case"<":i=tn,r=po,o=en,c="<",l="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(co(n,e,s))return!1;for(let d=0;d<e.set.length;++d){let p=e.set[d],a=null,u=null;if(p.forEach(g=>{g.semver===lo&&(g=new sn(">=0.0.0")),a=a||g,u=u||g,i(g.semver,a.semver,s)?a=g:o(g.semver,u.semver,s)&&(u=g)}),a.operator===c||a.operator===l||(!u.operator||u.operator===c)&&r(n,u.semver))return!1;if(u.operator===l&&o(n,u.semver))return!1}return!0};nn.exports=mo});var on=E((yl,rn)=>{"use strict";var ho=_e(),fo=(n,e,t)=>ho(n,e,">",t);rn.exports=fo});var ln=E((Rl,an)=>{"use strict";var bo=_e(),wo=(n,e,t)=>bo(n,e,"<",t);an.exports=wo});var gn=E((Pl,cn)=>{"use strict";var un=M(),To=(n,e,t)=>(n=new un(n,t),e=new un(e,t),n.intersects(e,t));cn.exports=To});var pn=E(($l,dn)=>{"use strict";var Eo=de(),vo=B();dn.exports=(n,e,t)=>{let s=[],i=null,r=null,o=n.sort((p,a)=>vo(p,a,t));for(let p of o)Eo(p,e,t)?(r=p,i||(i=p)):(r&&s.push([i,r]),r=null,i=null);i&&s.push([i,null]);let c=[];for(let[p,a]of s)p===a?c.push(p):!a&&p===o[0]?c.push("*"):a?p===o[0]?c.push(`<=${a}`):c.push(`${p} - ${a}`):c.push(`>=${p}`);let l=c.join(" || "),d=typeof e.raw=="string"?e.raw:String(e);return l.length<d.length?l:e}});var Tn=E((Il,wn)=>{"use strict";var mn=M(),ft=ce(),{ANY:ht}=ft,pe=de(),bt=B(),yo=(n,e,t={})=>{if(n===e)return!0;n=new mn(n,t),e=new mn(e,t);let s=!1;e:for(let i of n.set){for(let r of e.set){let o=Po(i,r,t);if(s=s||o!==null,o)continue e}if(s)return!1}return!0},Ro=[new ft(">=0.0.0-0")],hn=[new ft(">=0.0.0")],Po=(n,e,t)=>{if(n===e)return!0;if(n.length===1&&n[0].semver===ht){if(e.length===1&&e[0].semver===ht)return!0;t.includePrerelease?n=Ro:n=hn}if(e.length===1&&e[0].semver===ht){if(t.includePrerelease)return!0;e=hn}let s=new Set,i,r;for(let g of n)g.operator===">"||g.operator===">="?i=fn(i,g,t):g.operator==="<"||g.operator==="<="?r=bn(r,g,t):s.add(g.semver);if(s.size>1)return null;let o;if(i&&r){if(o=bt(i.semver,r.semver,t),o>0)return null;if(o===0&&(i.operator!==">="||r.operator!=="<="))return null}for(let g of s){if(i&&!pe(g,String(i),t)||r&&!pe(g,String(r),t))return null;for(let h of e)if(!pe(g,String(h),t))return!1;return!0}let c,l,d,p,a=r&&!t.includePrerelease&&r.semver.prerelease.length?r.semver:!1,u=i&&!t.includePrerelease&&i.semver.prerelease.length?i.semver:!1;a&&a.prerelease.length===1&&r.operator==="<"&&a.prerelease[0]===0&&(a=!1);for(let g of e){if(p=p||g.operator===">"||g.operator===">=",d=d||g.operator==="<"||g.operator==="<=",i){if(u&&g.semver.prerelease&&g.semver.prerelease.length&&g.semver.major===u.major&&g.semver.minor===u.minor&&g.semver.patch===u.patch&&(u=!1),g.operator===">"||g.operator===">="){if(c=fn(i,g,t),c===g&&c!==i)return!1}else if(i.operator===">="&&!pe(i.semver,String(g),t))return!1}if(r){if(a&&g.semver.prerelease&&g.semver.prerelease.length&&g.semver.major===a.major&&g.semver.minor===a.minor&&g.semver.patch===a.patch&&(a=!1),g.operator==="<"||g.operator==="<="){if(l=bn(r,g,t),l===g&&l!==r)return!1}else if(r.operator==="<="&&!pe(r.semver,String(g),t))return!1}if(!g.operator&&(r||i)&&o!==0)return!1}return!(i&&d&&!r&&o!==0||r&&p&&!i&&o!==0||u||a)},fn=(n,e,t)=>{if(!n)return e;let s=bt(n.semver,e.semver,t);return s>0?n:s<0||e.operator===">"&&n.operator===">="?e:n},bn=(n,e,t)=>{if(!n)return e;let s=bt(n.semver,e.semver,t);return s<0?n:s>0||e.operator==="<"&&n.operator==="<="?e:n};wn.exports=yo});var Tt=E((Nl,yn)=>{"use strict";var wt=Z(),En=ae(),$o=C(),vn=st(),Io=X(),No=zt(),Ao=Xt(),Co=Kt(),So=es(),Lo=ss(),ko=is(),xo=os(),Do=ls(),Oo=B(),Fo=ds(),Bo=ms(),Mo=Be(),qo=ws(),Vo=Es(),Uo=ue(),Ho=Me(),_o=rt(),Go=ot(),jo=qe(),zo=Ve(),Yo=at(),Xo=Cs(),Wo=ce(),Jo=M(),Ko=de(),Qo=Gs(),Zo=zs(),ea=Xs(),ta=Ks(),sa=Zs(),na=_e(),ia=on(),ra=ln(),oa=gn(),aa=pn(),la=Tn();yn.exports={parse:Io,valid:No,clean:Ao,inc:Co,diff:So,major:Lo,minor:ko,patch:xo,prerelease:Do,compare:Oo,rcompare:Fo,compareLoose:Bo,compareBuild:Mo,sort:qo,rsort:Vo,gt:Uo,lt:Ho,eq:_o,neq:Go,gte:jo,lte:zo,cmp:Yo,coerce:Xo,Comparator:Wo,Range:Jo,satisfies:Ko,toComparators:Qo,maxSatisfying:Zo,minSatisfying:ea,minVersion:ta,validRange:sa,outside:na,gtr:ia,ltr:ra,intersects:oa,simplifyRange:aa,subset:la,SemVer:$o,re:wt.re,src:wt.src,tokens:wt.t,SEMVER_SPEC_VERSION:En.SEMVER_SPEC_VERSION,RELEASE_TYPES:En.RELEASE_TYPES,compareIdentifiers:vn.compareIdentifiers,rcompareIdentifiers:vn.rcompareIdentifiers}});var si=E(R=>{"use strict";Object.defineProperty(R,"__esModule",{value:!0});var I=require("obsidian"),It="YYYY-MM-DD",Nt="gggg-[W]ww",_n="YYYY-MM",Gn="YYYY-[Q]Q",jn="YYYY";function Pe(n){var t,s;let e=window.app.plugins.getPlugin("periodic-notes");return e&&((s=(t=e.settings)==null?void 0:t[n])==null?void 0:s.enabled)}function $e(){var n,e,t,s;try{let{internalPlugins:i,plugins:r}=window.app;if(Pe("daily")){let{format:d,folder:p,template:a}=((e=(n=r.getPlugin("periodic-notes"))==null?void 0:n.settings)==null?void 0:e.daily)||{};return{format:d||It,folder:(p==null?void 0:p.trim())||"",template:(a==null?void 0:a.trim())||""}}let{folder:o,format:c,template:l}=((s=(t=i.getPluginById("daily-notes"))==null?void 0:t.instance)==null?void 0:s.options)||{};return{format:c||It,folder:(o==null?void 0:o.trim())||"",template:(l==null?void 0:l.trim())||""}}catch(i){console.info("No custom daily note settings found!",i)}}function Ie(){var n,e,t,s,i,r,o;try{let c=window.app.plugins,l=(n=c.getPlugin("calendar"))==null?void 0:n.options,d=(t=(e=c.getPlugin("periodic-notes"))==null?void 0:e.settings)==null?void 0:t.weekly;if(Pe("weekly"))return{format:d.format||Nt,folder:((s=d.folder)==null?void 0:s.trim())||"",template:((i=d.template)==null?void 0:i.trim())||""};let p=l||{};return{format:p.weeklyNoteFormat||Nt,folder:((r=p.weeklyNoteFolder)==null?void 0:r.trim())||"",template:((o=p.weeklyNoteTemplate)==null?void 0:o.trim())||""}}catch(c){console.info("No custom weekly note settings found!",c)}}function Ne(){var e,t,s,i;let n=window.app.plugins;try{let r=Pe("monthly")&&((t=(e=n.getPlugin("periodic-notes"))==null?void 0:e.settings)==null?void 0:t.monthly)||{};return{format:r.format||_n,folder:((s=r.folder)==null?void 0:s.trim())||"",template:((i=r.template)==null?void 0:i.trim())||""}}catch(r){console.info("No custom monthly note settings found!",r)}}function Ae(){var e,t,s,i;let n=window.app.plugins;try{let r=Pe("quarterly")&&((t=(e=n.getPlugin("periodic-notes"))==null?void 0:e.settings)==null?void 0:t.quarterly)||{};return{format:r.format||Gn,folder:((s=r.folder)==null?void 0:s.trim())||"",template:((i=r.template)==null?void 0:i.trim())||""}}catch(r){console.info("No custom quarterly note settings found!",r)}}function Ce(){var e,t,s,i;let n=window.app.plugins;try{let r=Pe("yearly")&&((t=(e=n.getPlugin("periodic-notes"))==null?void 0:e.settings)==null?void 0:t.yearly)||{};return{format:r.format||jn,folder:((s=r.folder)==null?void 0:s.trim())||"",template:((i=r.template)==null?void 0:i.trim())||""}}catch(r){console.info("No custom yearly note settings found!",r)}}function zn(...n){let e=[];for(let s=0,i=n.length;s<i;s++)e=e.concat(n[s].split("/"));let t=[];for(let s=0,i=e.length;s<i;s++){let r=e[s];!r||r==="."||t.push(r)}return e[0]===""&&t.unshift(""),t.join("/")}function ha(n){let e=n.substring(n.lastIndexOf("/")+1);return e.lastIndexOf(".")!=-1&&(e=e.substring(0,e.lastIndexOf("."))),e}async function fa(n){let e=n.replace(/\\/g,"/").split("/");if(e.pop(),e.length){let t=zn(...e);window.app.vault.getAbstractFileByPath(t)||await window.app.vault.createFolder(t)}}async function Se(n,e){e.endsWith(".md")||(e+=".md");let t=I.normalizePath(zn(n,e));return await fa(t),t}async function ie(n){let{metadataCache:e,vault:t}=window.app,s=I.normalizePath(n);if(s==="/")return Promise.resolve(["",null]);try{let i=e.getFirstLinkpathDest(s,""),r=await t.cachedRead(i),o=window.app.foldManager.load(i);return[r,o]}catch(i){return console.error(`Failed to read the daily note template '${s}'`,i),new I.Notice("Failed to read the daily note template"),["",null]}}function H(n,e="day"){let t=n.clone().startOf(e).format();return`${e}-${t}`}function Yn(n){return n.replace(/\[[^\]]*\]/g,"")}function ba(n,e){if(e==="week"){let t=Yn(n);return/w{1,2}/i.test(t)&&(/M{1,4}/.test(t)||/D{1,4}/.test(t))}return!1}function re(n,e){return Xn(n.basename,e)}function wa(n,e){return Xn(ha(n),e)}function Xn(n,e){let s={day:$e,week:Ie,month:Ne,quarter:Ae,year:Ce}[e]().format.split("/").pop(),i=window.moment(n,s,!0);if(!i.isValid())return null;if(ba(s,e)&&e==="week"){let r=Yn(s);if(/w{1,2}/i.test(r))return window.moment(n,s.replace(/M{1,4}/g,"").replace(/D{1,4}/g,""),!1)}return i}var At=class extends Error{};async function Wn(n){let e=window.app,{vault:t}=e,s=window.moment,{template:i,format:r,folder:o}=$e(),[c,l]=await ie(i),d=n.format(r),p=await Se(o,d);try{let a=await t.create(p,c.replace(/{{\s*date\s*}}/gi,d).replace(/{{\s*time\s*}}/gi,s().format("HH:mm")).replace(/{{\s*title\s*}}/gi,d).replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi,(u,g,h,w,m,T)=>{let D=s(),N=n.clone().set({hour:D.get("hour"),minute:D.get("minute"),second:D.get("second")});return h&&N.add(parseInt(w,10),m),T?N.format(T.substring(1).trim()):N.format(r)}).replace(/{{\s*yesterday\s*}}/gi,n.clone().subtract(1,"day").format(r)).replace(/{{\s*tomorrow\s*}}/gi,n.clone().add(1,"d").format(r)));return e.foldManager.save(a,l),a}catch(a){console.error(`Failed to create file: '${p}'`,a),new I.Notice("Unable to create new file.")}}function Ta(n,e){var t;return(t=e[H(n,"day")])!=null?t:null}function Ea(){let{vault:n}=window.app,{folder:e}=$e(),t=n.getAbstractFileByPath(I.normalizePath(e));if(!t)throw new At("Failed to find daily notes folder");let s={};return I.Vault.recurseChildren(t,i=>{if(i instanceof I.TFile){let r=re(i,"day");if(r){let o=H(r,"day");s[o]=i}}}),s}var Ct=class extends Error{};function va(){let{moment:n}=window,e=n.localeData()._week.dow,t=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];for(;e;)t.push(t.shift()),e--;return t}function ya(n){return va().indexOf(n.toLowerCase())}async function Jn(n){let{vault:e}=window.app,{template:t,format:s,folder:i}=Ie(),[r,o]=await ie(t),c=n.format(s),l=await Se(i,c);try{let d=await e.create(l,r.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi,(p,a,u,g,h,w)=>{let m=window.moment(),T=n.clone().set({hour:m.get("hour"),minute:m.get("minute"),second:m.get("second")});return u&&T.add(parseInt(g,10),h),w?T.format(w.substring(1).trim()):T.format(s)}).replace(/{{\s*title\s*}}/gi,c).replace(/{{\s*time\s*}}/gi,window.moment().format("HH:mm")).replace(/{{\s*(sunday|monday|tuesday|wednesday|thursday|friday|saturday)\s*:(.*?)}}/gi,(p,a,u)=>{let g=ya(a);return n.weekday(g).format(u.trim())}));return window.app.foldManager.save(d,o),d}catch(d){console.error(`Failed to create file: '${l}'`,d),new I.Notice("Unable to create new file.")}}function Ra(n,e){var t;return(t=e[H(n,"week")])!=null?t:null}function Pa(){let n={};if(!Qn())return n;let{vault:e}=window.app,{folder:t}=Ie(),s=e.getAbstractFileByPath(I.normalizePath(t));if(!s)throw new Ct("Failed to find weekly notes folder");return I.Vault.recurseChildren(s,i=>{if(i instanceof I.TFile){let r=re(i,"week");if(r){let o=H(r,"week");n[o]=i}}}),n}var St=class extends Error{};async function Kn(n){let{vault:e}=window.app,{template:t,format:s,folder:i}=Ne(),[r,o]=await ie(t),c=n.format(s),l=await Se(i,c);try{let d=await e.create(l,r.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi,(p,a,u,g,h,w)=>{let m=window.moment(),T=n.clone().set({hour:m.get("hour"),minute:m.get("minute"),second:m.get("second")});return u&&T.add(parseInt(g,10),h),w?T.format(w.substring(1).trim()):T.format(s)}).replace(/{{\s*date\s*}}/gi,c).replace(/{{\s*time\s*}}/gi,window.moment().format("HH:mm")).replace(/{{\s*title\s*}}/gi,c));return window.app.foldManager.save(d,o),d}catch(d){console.error(`Failed to create file: '${l}'`,d),new I.Notice("Unable to create new file.")}}function $a(n,e){var t;return(t=e[H(n,"month")])!=null?t:null}function Ia(){let n={};if(!Zn())return n;let{vault:e}=window.app,{folder:t}=Ne(),s=e.getAbstractFileByPath(I.normalizePath(t));if(!s)throw new St("Failed to find monthly notes folder");return I.Vault.recurseChildren(s,i=>{if(i instanceof I.TFile){let r=re(i,"month");if(r){let o=H(r,"month");n[o]=i}}}),n}var Lt=class extends Error{};async function Na(n){let{vault:e}=window.app,{template:t,format:s,folder:i}=Ae(),[r,o]=await ie(t),c=n.format(s),l=await Se(i,c);try{let d=await e.create(l,r.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi,(p,a,u,g,h,w)=>{let m=window.moment(),T=n.clone().set({hour:m.get("hour"),minute:m.get("minute"),second:m.get("second")});return u&&T.add(parseInt(g,10),h),w?T.format(w.substring(1).trim()):T.format(s)}).replace(/{{\s*date\s*}}/gi,c).replace(/{{\s*time\s*}}/gi,window.moment().format("HH:mm")).replace(/{{\s*title\s*}}/gi,c));return window.app.foldManager.save(d,o),d}catch(d){console.error(`Failed to create file: '${l}'`,d),new I.Notice("Unable to create new file.")}}function Aa(n,e){var t;return(t=e[H(n,"quarter")])!=null?t:null}function Ca(){let n={};if(!ei())return n;let{vault:e}=window.app,{folder:t}=Ae(),s=e.getAbstractFileByPath(I.normalizePath(t));if(!s)throw new Lt("Failed to find quarterly notes folder");return I.Vault.recurseChildren(s,i=>{if(i instanceof I.TFile){let r=re(i,"quarter");if(r){let o=H(r,"quarter");n[o]=i}}}),n}var kt=class extends Error{};async function Sa(n){let{vault:e}=window.app,{template:t,format:s,folder:i}=Ce(),[r,o]=await ie(t),c=n.format(s),l=await Se(i,c);try{let d=await e.create(l,r.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi,(p,a,u,g,h,w)=>{let m=window.moment(),T=n.clone().set({hour:m.get("hour"),minute:m.get("minute"),second:m.get("second")});return u&&T.add(parseInt(g,10),h),w?T.format(w.substring(1).trim()):T.format(s)}).replace(/{{\s*date\s*}}/gi,c).replace(/{{\s*time\s*}}/gi,window.moment().format("HH:mm")).replace(/{{\s*title\s*}}/gi,c));return window.app.foldManager.save(d,o),d}catch(d){console.error(`Failed to create file: '${l}'`,d),new I.Notice("Unable to create new file.")}}function La(n,e){var t;return(t=e[H(n,"year")])!=null?t:null}function ka(){let n={};if(!ti())return n;let{vault:e}=window.app,{folder:t}=Ce(),s=e.getAbstractFileByPath(I.normalizePath(t));if(!s)throw new kt("Failed to find yearly notes folder");return I.Vault.recurseChildren(s,i=>{if(i instanceof I.TFile){let r=re(i,"year");if(r){let o=H(r,"year");n[o]=i}}}),n}function xa(){var s,i;let{app:n}=window,e=n.internalPlugins.plugins["daily-notes"];if(e&&e.enabled)return!0;let t=n.plugins.getPlugin("periodic-notes");return t&&((i=(s=t.settings)==null?void 0:s.daily)==null?void 0:i.enabled)}function Qn(){var t,s;let{app:n}=window;if(n.plugins.getPlugin("calendar"))return!0;let e=n.plugins.getPlugin("periodic-notes");return e&&((s=(t=e.settings)==null?void 0:t.weekly)==null?void 0:s.enabled)}function Zn(){var t,s;let{app:n}=window,e=n.plugins.getPlugin("periodic-notes");return e&&((s=(t=e.settings)==null?void 0:t.monthly)==null?void 0:s.enabled)}function ei(){var t,s;let{app:n}=window,e=n.plugins.getPlugin("periodic-notes");return e&&((s=(t=e.settings)==null?void 0:t.quarterly)==null?void 0:s.enabled)}function ti(){var t,s;let{app:n}=window,e=n.plugins.getPlugin("periodic-notes");return e&&((s=(t=e.settings)==null?void 0:t.yearly)==null?void 0:s.enabled)}function Da(n){let e={day:$e,week:Ie,month:Ne,quarter:Ae,year:Ce}[n];return e()}function Oa(n,e){return{day:Wn,month:Kn,week:Jn}[n](e)}R.DEFAULT_DAILY_NOTE_FORMAT=It;R.DEFAULT_MONTHLY_NOTE_FORMAT=_n;R.DEFAULT_QUARTERLY_NOTE_FORMAT=Gn;R.DEFAULT_WEEKLY_NOTE_FORMAT=Nt;R.DEFAULT_YEARLY_NOTE_FORMAT=jn;R.appHasDailyNotesPluginLoaded=xa;R.appHasMonthlyNotesPluginLoaded=Zn;R.appHasQuarterlyNotesPluginLoaded=ei;R.appHasWeeklyNotesPluginLoaded=Qn;R.appHasYearlyNotesPluginLoaded=ti;R.createDailyNote=Wn;R.createMonthlyNote=Kn;R.createPeriodicNote=Oa;R.createQuarterlyNote=Na;R.createWeeklyNote=Jn;R.createYearlyNote=Sa;R.getAllDailyNotes=Ea;R.getAllMonthlyNotes=Ia;R.getAllQuarterlyNotes=Ca;R.getAllWeeklyNotes=Pa;R.getAllYearlyNotes=ka;R.getDailyNote=Ta;R.getDailyNoteSettings=$e;R.getDateFromFile=re;R.getDateFromPath=wa;R.getDateUID=H;R.getMonthlyNote=$a;R.getMonthlyNoteSettings=Ne;R.getPeriodicNoteSettings=Da;R.getQuarterlyNote=Aa;R.getQuarterlyNoteSettings=Ae;R.getTemplateInfo=ie;R.getWeeklyNote=Ra;R.getWeeklyNoteSettings=Ie;R.getYearlyNote=La;R.getYearlyNoteSettings=Ce});var Fa={};gi(Fa,{default:()=>Qe});module.exports=di(Fa);var ri=require("obsidian");var F=require("obsidian"),Y=Ze(Tt());var me=require("obsidian"),Et=class extends me.Modal{constructor(t,s){super(t.app);this.resolve=s;this.isConfirmed=!1;let i={app:t.app,cancelButtonText:"Cancel",cssClass:"",message:t.message,okButtonText:"OK",title:""};this.options={...i,...t},this.containerEl.addClass("confirm-modal")}onClose(){super.onClose(),this.resolve(this.isConfirmed)}onOpen(){super.onOpen(),this.titleEl.setText(this.options.title),this.contentEl.createEl("p",{text:this.options.message});let t=new me.ButtonComponent(this.contentEl);t.setClass("ok-button"),t.setButtonText(this.options.okButtonText),t.setCta(),t.onClick(()=>{this.isConfirmed=!0,this.close()});let s=new me.ButtonComponent(this.contentEl);s.setButtonText(this.options.cancelButtonText),s.onClick(this.close.bind(this))}};async function vt(n){return await new Promise(e=>{new Et(n,e).open()})}var U=class extends Error{constructor(t,s,i,r){let o=Math.ceil((i-Math.floor(Date.now()/1e3))/60);super(`GitHub API rate limit exceeded. Reset in ${o} minutes.`);this.limit=t;this.remaining=s;this.reset=i;this.requestUrl=r}getMinutesToReset(){return Math.ceil((this.reset-Math.floor(Date.now()/1e3))/60)}},G=class extends Error{constructor(e){var s,i;super(`GitHub API error ${e}: ${e.message}`),this.message=e.message;let t=e;this.status=(s=t.status)!=null?s:400,this.headers=(i=t.headers)!=null?i:{},this.name="GitHubResponseError"}};var z=require("obsidian"),he=Ze(Tt());var Ge=n=>{let e=n.replace(/https?:\/\/github\.com\//i,"");return e.endsWith("/")&&(e=e.slice(0,-1)),e.toLowerCase().endsWith(".git")&&(e=e.slice(0,-4)),e},Rn=["ghp_","github_pat_"],ua=/^(gh[ps]_[a-zA-Z0-9]{36}|github_pat_[a-zA-Z0-9]{22}_[a-zA-Z0-9]{59})$/,Pn=n=>Object.keys(n).reduce((e,t)=>(e[t.toLowerCase()]=n[t],e),{}),$n=async(n,e)=>{var r,o,c,l,d,p,a,u,g,h,w;let t=["repo","public_repo","metadata=read"],s=Rn.some(m=>n.toLowerCase().startsWith(m.toLowerCase())),i=ua.test(n);if(!s||!i)return{validToken:!1,currentScopes:[],acceptedScopes:[],acceptedPermissions:[],expirationDate:null,rateLimit:{limit:0,remaining:0,reset:0,resource:"",used:0},error:{type:s?"invalid_format":"invalid_prefix",message:"Invalid token format",details:{validPrefixes:Rn}}};try{let m=Date.now()%1e3,T=e||`user${m}/repo${m%100}`;if(await je({url:`https://api.github.com/repos/${T}`,headers:{Authorization:`Token ${n}`,Accept:"application/vnd.github.v3+json"}}),e)return{validToken:!0,currentScopes:[],acceptedScopes:[],acceptedPermissions:[],expirationDate:null,rateLimit:{limit:0,remaining:0,reset:0,resource:"",used:0},error:{type:"none",message:"No error",details:{}}};throw new Error("Expected request to fail")}catch(m){if(!(m instanceof G))throw m;let T=Pn(m.headers);if(!T)throw new Error("No headers in GitHub response");let D=T["github-authentication-token-expiration"],N=D?new Date(D):null,A=N&&!Number.isNaN(N.getTime())?N.toISOString():null,P={validToken:!1,currentScopes:(o=(r=T["x-oauth-scopes"])==null?void 0:r.split(", "))!=null?o:[],acceptedScopes:(l=(c=T["x-accepted-oauth-scopes"])==null?void 0:c.split(", "))!=null?l:[],acceptedPermissions:(p=(d=T["x-accepted-github-permissions"])==null?void 0:d.split(", "))!=null?p:[],expirationDate:A,rateLimit:{limit:Number.parseInt((a=T["x-ratelimit-limit"])!=null?a:"0",10),remaining:Number.parseInt((u=T["x-ratelimit-remaining"])!=null?u:"0",10),reset:Number.parseInt((g=T["x-ratelimit-reset"])!=null?g:"0",10),resource:(h=T["x-ratelimit-resource"])!=null?h:"",used:Number.parseInt((w=T["x-ratelimit-used"])!=null?w:"0",10)},error:{type:"none",message:"No error",details:{}}};return P.expirationDate&&new Date(P.expirationDate)<new Date?(P.error={type:"expired",message:"Token has expired",details:{expirationDate:P.expirationDate}},P):P.currentScopes.some(V=>t.includes(V))||P.acceptedPermissions.some(V=>t.includes(V))?(P.validToken=m.status===404,P):(P.error={type:"insufficient_scope",message:"Token lacks required scopes. Check documentation for requirements.",details:{currentScopes:[...P.acceptedScopes,...P.acceptedPermissions]}},P)}},yt=async(n,e=!0,t="")=>{let s=`https://api.github.com/repos/${n}`;try{let r=(await je({url:s,headers:t?{Authorization:`Token ${t}`}:{}})).json;return typeof r=="object"&&r!==null&&"private"in r?!!r.private:!1}catch(i){if(i instanceof U)throw i;return e&&console.error("error in isPrivateRepo",s,i),!1}},In=async(n,e=!0,t="")=>{let s=`https://api.github.com/repos/${n}/releases`;try{let r=(await je({url:`${s}?per_page=100`,headers:t?{Authorization:`Token ${t}`}:{}})).json;return Array.isArray(r)?r.map(o=>({version:o.tag_name,prerelease:o.prerelease})):null}catch(i){if(i instanceof U||i instanceof G)throw i;return e&&console.error("Error in fetchReleaseVersions",s,i),null}},fe=async(n,e,t=!0,s=!1,i="")=>{try{let r=n.assets.find(d=>d.name===e);if(!r)return null;let o={Accept:"application/octet-stream"};s&&i&&(o.Authorization=`Token ${i}`);let c=s?r.url:r.browser_download_url,l=await(0,z.requestUrl)({url:c,headers:o});return l.status!==200?null:l.text}catch(r){if(r instanceof U)throw r;return t&&console.error("error in grabReleaseFileFromRepository",n,r),null}},Nn=async(n=!0)=>{let e="https://raw.githubusercontent.com/obsidianmd/obsidian-releases/HEAD/community-plugins.json";try{let t=await(0,z.requestUrl)({url:e});return t.status===404?null:t.json}catch(t){return n&&console.error("error in grabCommmunityPluginList",t),null}},An=async(n=!0)=>{let e="https://raw.githubusercontent.com/obsidianmd/obsidian-releases/HEAD/community-css-themes.json";try{let t=await(0,z.requestUrl)({url:e});return t.status===404?null:t.json}catch(t){return n&&console.error("error in grabCommmunityThemesList",t),null}},ee=async(n,e=!1,t=!1)=>{let s=`https://raw.githubusercontent.com/${n}/HEAD/theme${e?"-beta":""}.css`;try{let i=await(0,z.requestUrl)({url:s});return i.status===404?null:i.text}catch(i){return t&&console.error("error in grabCommmunityThemeCssFile",i),null}},Cn=async(n,e=!0)=>{let t=`https://raw.githubusercontent.com/${n}/HEAD/manifest.json`;try{let s=await(0,z.requestUrl)({url:t});return s.status===404?null:s.text}catch(s){return e&&console.error("error in grabCommmunityThemeManifestFile",s),null}},ca=n=>{let e=0;for(let t=0;t<n.length;t++)e+=n.charCodeAt(t);return e},be=n=>ca(n).toString(),we=async(n,e,t)=>{let s=await ee(n,e,t);return s?be(s):"0"},ga=async(n,e,t=!0)=>{let s=`https://api.github.com/repos/${n}/commits?path=${e}&page=1&per_page=1`;try{let i=await(0,z.requestUrl)({url:s});return i.status===404?null:i.json}catch(i){return t&&console.error("error in grabLastCommitInfoForAFile",i),null}},Sn=async(n,e)=>{var s;let t=await ga(n,e);return t&&t.length>0&&((s=t[0].commit.committer)!=null&&s.date)?t[0].commit.committer.date:""},Rt=async(n,e,t=!1,s=!1,i=!1,r)=>{var o;try{let c=e&&e!=="latest"?`https://api.github.com/repos/${n}/releases/tags/${e}`:`https://api.github.com/repos/${n}/releases`,l={Accept:"application/vnd.github.v3+json"};(i&&r||r)&&(l.Authorization=`Token ${r}`);let d=await je({url:c,headers:l});if(d.status===404)return null;let p=d.json,a=e&&e!=="latest"?p&&typeof p=="object"?[p]:[]:Array.isArray(p)?p:[];return s&&console.error(`grabReleaseFromRepository for ${n}:`,a),(o=a.sort((u,g)=>{let h=(0,he.coerce)(u.tag_name,{includePrerelease:!0,loose:!0}),w=(0,he.coerce)(g.tag_name,{includePrerelease:!0,loose:!0});if(h&&w)return(0,he.compare)(w.version,h.version);if(h&&!w)return-1;if(!h&&w)return 1;let m=new Date(u.published_at).getTime(),T=new Date(g.published_at).getTime();return m<T?1:m>T?-1:0}).filter(u=>t||!u.prerelease)[0])!=null?o:null}catch(c){throw s&&console.error(`Error in grabReleaseFromRepository for ${n}:`,c),c}},je=async(n,e)=>{let t=0,s=0,i=0;n.headers={...n.headers,"User-Agent":"Obsidian/BRAT-Plugin"};try{return await(0,z.requestUrl)(n)}catch(r){let o=new G(r),c=Pn(o.headers);if(c&&(t=Number.parseInt(c["x-ratelimit-limit"],10),s=Number.parseInt(c["x-ratelimit-remaining"],10),i=Number.parseInt(c["x-ratelimit-reset"],10)),o.status===403&&s===0){let l=new U(t,s,i,n.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.error("GitHub request failed:",r),o}};var Pt={pluginList:[],pluginSubListFrozenVersion:[],themesList:[],updateAtStartup:!0,updateThemesAtStartup:!0,enableAfterInstall:!0,loggingEnabled:!1,loggingPath:"BRAT-log",loggingVerboseEnabled:!1,debuggingMode:!1,notificationsEnabled:!0,globalTokenName:"",personalAccessToken:"",selectLatestPluginVersionByDefault:!1,allowIncompatiblePlugins:!1};function Ln(n,e,t="latest",s=!1,i=""){let r=!1;n.settings.pluginList.contains(e)||(n.settings.pluginList.unshift(e),r=!0);let o=n.settings.pluginSubListFrozenVersion.find(c=>c.repo===e);o?(Object.assign(o,{repo:e,version:t,token:void 0,tokenName:i||o.tokenName,isIncompatible:s||void 0}),r=!0):(n.settings.pluginSubListFrozenVersion.unshift({repo:e,version:t,token:void 0,tokenName:i||void 0,isIncompatible:s||void 0}),r=!0),r&&n.saveSettings()}function ze(n,e){return n.settings.pluginList.contains(e)}function kn(n,e,t){let s={repo:e,lastUpdate:be(t)};n.settings.themesList.unshift(s),n.saveSettings()}function xn(n,e){return!!n.settings.themesList.find(s=>s.repo===e)}function $t(n,e,t){let s=n.settings.pluginSubListFrozenVersion.find(i=>i.repo===e);s&&(s.tokenName=t||void 0,n.saveSettings())}function Dn(n,e,t){for(let s of n.settings.themesList)s.repo===e&&(s.lastUpdate=t,n.saveSettings())}var O=require("obsidian");var te=class{constructor(e){this.statusEl=e}async validateToken(e,t){var s,i,r,o,c,l,d,p,a;if(!e)return(s=this.statusEl)==null||s.setText("No token provided"),(i=this.statusEl)==null||i.addClass("invalid"),(r=this.statusEl)==null||r.removeClass("valid"),!1;try{let u=await $n(e,t);return(o=this.statusEl)==null||o.removeClass("invalid","valid"),(c=this.statusEl)==null||c.empty(),u.validToken?((l=this.statusEl)==null||l.addClass("valid"),this.showValidTokenInfo(u),!0):((d=this.statusEl)==null||d.addClass("invalid"),this.showErrorMessage(u.error),!1)}catch(u){return console.error("Token validation error:",u),(p=this.statusEl)==null||p.setText("Failed to validate token"),(a=this.statusEl)==null||a.addClass("invalid"),!1}}showValidTokenInfo(e){var s,i;let t=(s=this.statusEl)==null?void 0:s.createDiv({cls:"brat-token-details"});if(t&&(t.createDiv({text:"\u2713 Valid token",cls:"brat-token-status valid"}),(i=e.currentScopes)!=null&&i.length&&t.createDiv({text:`Scopes: ${e.currentScopes.join(", ")}`,cls:"brat-token-scopes"}),e.rateLimit&&t.createDiv({text:`Rate Limit: ${e.rateLimit.remaining}/${e.rateLimit.limit}`,cls:"brat-token-rate"}),e.expirationDate)){let r=new Date(e.expirationDate),o=Math.ceil((r.getTime()-Date.now())/(1e3*60*60*24));o<7&&t.createDiv({text:`\u26A0\uFE0F Token expires in ${o} days`,cls:"brat-token-warning"})}}showErrorMessage(e){var s,i,r;let t=(s=this.statusEl)==null?void 0:s.createDiv({cls:"brat-token-error"});if(t&&(t.createDiv({text:e.message}),e.details))switch(e.type){case"invalid_prefix":t.createDiv({text:`Valid prefixes: ${(i=e.details.validPrefixes)==null?void 0:i.join(", ")}`});break;case"insufficient_scope":t.createDiv({text:`Required scopes: ${(r=e.details.requiredScopes)==null?void 0:r.join(", ")}`});break}}};function Te(n,e){let t=new DocumentFragment,s=document.createElement("a");if(s.textContent=n,s.href=`https://github.com/${n}`,s.target="_blank",t.appendChild(s),e){let i=document.createTextNode(e);t.appendChild(i)}return t}function On({prependText:n,url:e,text:t,appendText:s}){let i=new DocumentFragment,r=document.createElement("a");if(r.textContent=t,r.href=e,n){let o=document.createTextNode(n);i.appendChild(o)}if(i.appendChild(r),s){let o=document.createTextNode(s);i.appendChild(o)}return i}var Ye=require("obsidian");function v(n,e,t=10,s){if(!n.settings.notificationsEnabled)return;let i=s?Ye.Platform.isDesktop?"(click=dismiss, right-click=Info)":"(click=dismiss)":"",r=new Ye.Notice(`BRAT
|
|
${e}
|
|
${i}`,t*1e3);s&&(r.messageEl.oncontextmenu=()=>{s()})}var se=(n,e=!0)=>{let t=n.createEl("div",{cls:"brat-promotional-links"});e?t.addClass("brat-promotional-links-settings"):t.addClass("brat-promotional-links-modal");let s=t.createDiv("coffee");s.addClass("ex-twitter-span"),s.addClass("brat-promotional-links-coffee");let i=s.createDiv();i.innerText="Learn more about my work at:",s.appendChild(i);let r=s.createEl("a",{href:"https://tfthacker.com"});return r.innerText="https://tfthacker.com",t};var Fn=require("obsidian"),Xe=class extends Fn.SuggestModal{constructor(e,t,s,i,r){super(e),this.versions=s,this.selected=i,this.onChoose=r,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(s=>s.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 W=class extends O.Modal{constructor(t,s,i=!1,r=!1,o="",c="",l=""){super(t.app);this.versionSetting=null;this.repositoryAddressEl=null;this.tokenInputEl=null;this.validateButton=null;this.validator=null;this.addPluginButton=null;this.cancelButton=null;this.plugin=t,this.betaPlugins=s,this.address=o,this.version=c,this.secretName=l,this.openSettingsTabAfterwards=i,this.updateVersion=r,this.enableAfterInstall=t.settings.enableAfterInstall}async submitForm(){var r,o,c,l,d,p,a,u;if(this.address==="")return;let t=Ge(this.address);if(this.plugin.settings.pluginSubListFrozenVersion.find(g=>g.repo===t)){await this.betaPlugins.addPlugin(t,!1,!1,!1,this.version,!0,this.enableAfterInstall,this.secretName)&&this.close(),(r=this.cancelButton)==null||r.setDisabled(!1),(o=this.addPluginButton)==null||o.setDisabled(!1),(c=this.addPluginButton)==null||c.setButtonText("Add plugin"),(l=this.versionSetting)==null||l.setDisabled(!1);return}if(!this.version&&ze(this.plugin,t)){v(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.secretName)&&this.close(),(d=this.cancelButton)==null||d.setDisabled(!1),(p=this.addPluginButton)==null||p.setDisabled(!1),(a=this.addPluginButton)==null||a.setButtonText("Add plugin"),(u=this.versionSetting)==null||u.setDisabled(!1)}updateVersionDropdown(t,s,i=""){let r;t.clear(),s.length>0&&!i&&this.plugin.settings.selectLatestPluginVersionByDefault?(r="latest",this.version="latest"):r=i,s.length<20||O.Platform.isMobile?t.addDropdown(c=>{c.addOption("","Select a version"),c.addOption("latest","Latest version");for(let l of s)c.addOption(l.version,`${l.version} ${l.prerelease?"(Prerelease)":""}`);c.onChange(l=>{var d;this.version=l,(d=this.addPluginButton)==null||d.setDisabled(this.version==="")}),c.setValue(r),c.selectEl.addClass("brat-version-selector")}):t.addButton(c=>{c.setButtonText(r==="latest"?"Latest version":r||"Select a version...").setClass("brat-version-selector").setClass("button").onClick(()=>{let d=[{version:"latest",prerelease:!1},...s];new Xe(this.app,this.address,d,r,a=>{var u;this.version=a,c.setButtonText(a==="latest"?"Latest version":a||"Select a version..."),(u=this.addPluginButton)==null||u.setDisabled(this.version==="")}).open()})})}onOpen(){let t=this.contentEl.createEl("h4");this.address?(t.appendText("Change plugin version: "),t.appendChild(Te(this.address))):t.setText("GitHub repository for beta plugin:"),this.contentEl.createEl("form",{},s=>{var d;s.addClass("brat-modal"),(!this.address||!this.updateVersion)&&new O.Setting(s).setClass("repository-setting").then(a=>{a.addText(u=>{this.repositoryAddressEl=u,u.setPlaceholder("Repository (example: https://GitHub.com/githubusername/repository-name)"),u.setValue(this.address),u.onChange(g=>{var h,w;this.address=Ge(g.trim()),this.version!==""&&(!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.version||(this.isGitHubRepositoryMatch(this.address)?(h=this.addPluginButton)==null||h.setDisabled(!1):(w=this.addPluginButton)==null||w.setDisabled(!0))}),u.inputEl.addEventListener("keydown",g=>{g.key==="Enter"&&(async()=>{var h,w,m;this.address&&(this.updateVersion&&this.version!==""||!this.updateVersion)&&(g.preventDefault(),(h=this.addPluginButton)==null||h.setDisabled(!0),(w=this.cancelButton)==null||w.setDisabled(!0),(m=this.versionSetting)==null||m.setDisabled(!0),this.submitForm()),await this.updateRepositoryVersionInfo(this.version,i)})()}),u.inputEl.addEventListener("blur",()=>{this.updateRepositoryVersionInfo(this.version,i)}),a.setDesc("Repository"),u.inputEl.addClass("brat-full-width-input")})});let i=s.createDiv("validation-status");this.address||i.setText("Enter a GitHub repository address to validate it."),this.versionSetting=new O.Setting(s).setClass("version-setting").setClass("disabled-setting"),this.updateVersionDropdown(this.versionSetting,[],this.version),this.versionSetting.setDisabled(!0);let r=s.createDiv("token-setting");if(new O.Setting(r).setName("GitHub token").setDesc("Select a secret as token for this repository (optional)").addComponent(p=>new O.SecretComponent(this.plugin.app,p).setValue(this.secretName).onChange(a=>{(async()=>{var g,h,w,m,T;if(this.secretName=(a==null?void 0:a.trim())||"",!this.secretName){this.address&&ze(this.plugin,this.address)&&($t(this.plugin,this.address,""),v(this.plugin,`Token setting cleared for ${this.address}`,3)),this.updateRepositoryVersionInfo(this.version,i);return}let u=this.secretName?this.plugin.app.secretStorage.getSecret(this.secretName):null;u&&(this.validToken=await((g=this.validator)==null?void 0:g.validateToken(u,this.address)),this.validToken?((m=this.validateButton)==null||m.setButtonText("Valid"),(T=this.validateButton)==null||T.setDisabled(!0),this.address&&(await this.updateRepositoryVersionInfo(this.version,i),ze(this.plugin,this.address)&&($t(this.plugin,this.address,this.secretName),v(this.plugin,`Token setting updated for ${this.address}`,3)))):((h=this.validateButton)==null||h.setButtonText("Invalid"),(w=this.validateButton)==null||w.setDisabled(!1)))})()})),this.validator=new te,this.secretName){let p=this.plugin.app.secretStorage.getSecret(this.secretName);p&&((d=this.validator)==null||d.validateToken(p,this.address).then(a=>{var u,g;this.validToken=a,this.validToken&&((u=this.validateButton)==null||u.setButtonText("Valid"),(g=this.validateButton)==null||g.setDisabled(!0))}))}s.createDiv("modal-button-container",p=>{var a;p.createEl("label",{cls:"mod-checkbox"},u=>{let g=u.createEl("input",{attr:{tabindex:-1},type:"checkbox"});g.checked=this.enableAfterInstall,g.addEventListener("click",()=>{this.enableAfterInstall=g.checked}),u.appendText("Enable after installing the plugin")}),this.cancelButton=new O.ButtonComponent(p).setButtonText("Never mind").setClass("mod-cancel").onClick(()=>{this.close()}),this.addPluginButton=new O.ButtonComponent(p).setButtonText(this.updateVersion&&this.address?"Change version":"Add plugin").setCta().onClick(()=>{var u,g,h,w;this.address!==""&&(this.updateVersion&&this.version!==""||!this.updateVersion)&&((u=this.addPluginButton)==null||u.setDisabled(!0),(g=this.addPluginButton)==null||g.setButtonText("Installing \u2026"),(h=this.cancelButton)==null||h.setDisabled(!0),(w=this.versionSetting)==null||w.setDisabled(!0),this.submitForm())}),(this.updateVersion||this.address==="")&&((a=this.addPluginButton)==null||a.setDisabled(!0))});let o=s.createDiv();o.addClass("brat-modal-divider");let c=o.createSpan();c.createEl("a",{href:"https://bit.ly/o42-twitter",text:"TFTHacker"}),c.appendText(" and "),c.createEl("a",{href:"https://github.com/johannrichard",text:"johannrichard"}),c.addClass("brat-credits"),o.appendChild(c),se(o,!1);let l=s.querySelectorAll("button");for(let p of Array.from(l))p.setAttribute("type","button");s.addEventListener("submit",p=>{p.preventDefault(),p.stopPropagation()})}),this.address&&window.setTimeout(async()=>{await this.updateRepositoryVersionInfo(this.version)},100)}async updateRepositoryVersionInfo(t="",s){var o,c,l,d,p,a;let i=this.repositoryAddressEl;if(this.plugin.settings.debuggingMode&&console.debug(`[BRAT] Updating version dropdown for ${this.address} with selected version ${t}`),!this.address){s==null||s.setText("Repository address is required."),s==null||s.addClass("validation-status-error");return}s==null||s.setText("Validating repository address..."),s==null||s.removeClass("validation-status-error"),this.versionSetting&&this.updateVersion&&this.updateVersionDropdown(this.versionSetting,[]);let r=Ge(this.address);try{let u="";if(this.secretName){let h=this.plugin.app.secretStorage.getSecret(this.secretName);h&&(u=h)}else if(this.plugin.settings.globalTokenName){let h=this.plugin.app.secretStorage.getSecret(this.plugin.settings.globalTokenName);h&&(u=h)}let g=await In(r,this.plugin.settings.debuggingMode,u);g&&g.length>0?(i==null||i.inputEl.classList.remove("invalid-repository"),i==null||i.inputEl.classList.add("valid-repository"),s==null||s.setText(""),this.versionSetting&&(this.versionSetting.settingEl.classList.remove("disabled-setting"),this.versionSetting.setDisabled(!1),this.updateVersionDropdown(this.versionSetting,g,t))):(i==null||i.inputEl.classList.remove("valid-repository"),i==null||i.inputEl.classList.add("invalid-repository"),s==null||s.setText("Error: No releases found in this repository."),s==null||s.addClass("validation-status-error"),(o=this.versionSetting)==null||o.settingEl.classList.add("disabled-setting"),(c=this.versionSetting)==null||c.setDisabled(!0),(l=this.addPluginButton)==null||l.setDisabled(!0))}catch(u){if(u instanceof U&&(i==null||i.inputEl.classList.remove("valid-repository"),i==null||i.inputEl.classList.add("validation-error"),s==null||s.setText(`GitHub API rate limit exceeded. Try again in ${u.getMinutesToReset()} minutes.`),this.versionSetting&&(this.versionSetting.settingEl.classList.add("disabled-setting"),this.versionSetting.setDisabled(!0),(d=this.addPluginButton)==null||d.setDisabled(!0)),v(this.plugin,`${u.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")})),u instanceof G){let g=u;switch(g.status){case 404:s==null||s.setText("Repository not found. Check the address or provide a valid token for access to a private repository.");break;case 403:s==null||s.setText("Access denied. Check your personal access token.");break;default:s==null||s.setText(`Error: ${g.message}`);break}s==null||s.addClass("validation-status-error"),(p=this.versionSetting)==null||p.setDisabled(!0),(a=this.addPluginButton)==null||a.setDisabled(!0),v(this.plugin,`${g.message} `,20)}}}onClose(){this.openSettingsTabAfterwards&&(this.plugin.app.setting.open(),this.plugin.app.setting.openTabById(this.plugin.APP_ID))}isGitHubRepositoryMatch(t){let s=t.trim().replace(/\.git$/,"").toLowerCase();return/^(?:https?:\/\/github\.com\/)?([a-zA-Z0-9._-]+)\/([a-zA-Z0-9._-]+)$/i.test(s)}};var Bn=require("obsidian");async function We(){try{let n=await(0,Bn.requestUrl)(`https://obsidian.md/?${Math.random()}`);return n.status>=200&&n.status<300}catch(n){return!1}}var Ee=class{constructor(e){this.plugin=e}displayAddNewPluginModal(e=!1,t=!1,s="",i="",r=""){new W(this.plugin,this,e,t,s,i,r).open()}async validateRepository(e,t=!1,s=!1,i="",r=""){let c=r;try{let l=await yt(e,this.plugin.settings.debuggingMode,c),d=await Rt(e,i,t,this.plugin.settings.debuggingMode,l,c);if(!d)return s&&(v(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,s)),null;let p=await fe(d,"manifest.json",this.plugin.settings.debuggingMode,l,c);if(!p)return s&&(v(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,s)),null;let a=JSON.parse(p);if(!("id"in a))return s&&v(this.plugin,`${e}
|
|
The plugin id attribute for the release is missing from the manifest file`,15),null;if(!("version"in a))return s&&v(this.plugin,`${e}
|
|
The version attribute for the release is missing from the manifest file`,15),null;let u=(0,Y.coerce)(d.tag_name,{includePrerelease:!0,loose:!0}),g=(0,Y.coerce)(a.version,{includePrerelease:!0,loose:!0});return(u&&g?(0,Y.compare)(u.version,g.version)!==0:u!==null&&a.version!==d.tag_name)&&u&&(s&&v(this.plugin,`${e}
|
|
Version mismatch detected:
|
|
Release tag version: ${d.tag_name}
|
|
Manifest version: ${a.version}
|
|
|
|
The release tag version will be used to ensure consistency.`,15),a.version=u.version),a}catch(l){if(l instanceof U){let d=`GitHub API rate limit exceeded. Reset in ${l.getMinutesToReset()} minutes.`;throw s&&v(this.plugin,d,15),console.error(`BRAT: validateRepository ${l}`),v(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}if(l instanceof G)throw s&&(l.status===401?v(this.plugin,`${e}
|
|
GitHub API Authentication error. Please verify that your personal access token is valid and set correctly.`,15):v(this.plugin,`${e}
|
|
GitHub API error ${l.status}: ${l.message}`,15)),console.error(`BRAT: validateRepository ${l}`),l;return s&&v(this.plugin,`${e}
|
|
Unspecified error encountered: ${String(l)}, verify debug for more information.`,15),null}}async getAllReleaseFiles(e,t,s="",i=""){let r=i,o=await yt(e,this.plugin.settings.debuggingMode,r),c=await Rt(e,s,t,this.plugin.settings.debuggingMode,o,r);if(!c)throw new Error("No release found");let l=t||s!=="";return console.debug({reallyGetManifestOrNot:l,version:c.tag_name}),{mainJs:await fe(c,"main.js",this.plugin.settings.debuggingMode,o,r),manifest:l?await fe(c,"manifest.json",this.plugin.settings.debuggingMode,o,r):"",styles:await fe(c,"styles.css",this.plugin.settings.debuggingMode,o,r)}}async writeReleaseFilesToPluginFolder(e,t){var r,o;let s=`${(0,F.normalizePath)(`${this.plugin.app.vault.configDir}/plugins/${e}`)}/`,{adapter:i}=this.plugin.app.vault;await i.exists(s)||await i.mkdir(s),await i.write(`${s}main.js`,(r=t.mainJs)!=null?r:""),await i.write(`${s}manifest.json`,(o=t.manifest)!=null?o:""),t.styles&&await i.write(`${s}styles.css`,t.styles)}async addPlugin(e,t=!1,s=!1,i=!1,r="",o=!1,c=this.plugin.settings.enableAfterInstall,l=""){try{this.plugin.settings.debuggingMode&&console.debug("BRAT: addPlugin",e,t,s,i,r,o,c,l?"with secret":"public");let d="";l&&l.trim()!==""?(d=this.plugin.app.secretStorage.getSecret(l)||"",d||v(this.plugin,`Secret not found for token name: ${l}. Please add it to SecretStorage or clear the token name for this plugin.`,10)):this.plugin.settings.globalTokenName&&(d=this.plugin.app.secretStorage.getSecret(this.plugin.settings.globalTokenName)||"");let p=10,a=await this.validateRepository(e,!0,!0,r,d),u=!!a;if(u||(a=await this.validateRepository(e,!1,!0,r,d)),a===null){let w=`${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(w,!0),v(this.plugin,w,p),!1}if(!Object.hasOwn(a,"version")){let w=`${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(w,!0),v(this.plugin,w,p),!1}let g=!1;if(Object.hasOwn(a,"minAppVersion")&&!(0,F.requireApiVersion)(a.minAppVersion)){if(r===""||r==="latest"||!this.plugin.settings.allowIncompatiblePlugins){let m=`Plugin: ${e}
|
|
|
|
The manifest.json for this plugin indicates that the Obsidian version of the app needs to be ${a.minAppVersion}, but this installation of Obsidian is ${F.apiVersion}.
|
|
|
|
You will need to update your Obsidian to use this plugin or contact the plugin developer for more information.`;return await this.plugin.log(m,!0),v(this.plugin,m,30),!1}if(!await vt({app:this.plugin.app,message:createFragment(m=>{m.appendText("Plugin: "),m.createEl("code",{text:e}),m.createEl("br"),m.appendText("The "),m.createEl("code",{text:"manifest.json"}),m.appendText(" for this plugin indicates that the Obsidian version of the app needs to be "),m.createEl("code",{text:a.minAppVersion}),m.appendText(", but this installation of Obsidian is "),m.createEl("code",{text:F.apiVersion}),m.appendText("."),m.createEl("br"),m.appendText("Using this plugin is not recommended and may not work as expected. Use at your own risk."),m.createEl("br"),m.appendText("Do you want to install it anyways?")})}))return!1;g=!0}let h=async()=>{var T,D;let w=await this.getAllReleaseFiles(e,u,r,d);console.debug("rFiles",w),(u||w.manifest==="")&&(w.manifest=JSON.stringify(a));let m=JSON.parse((T=w.manifest)!=null?T:"");if(g&&(m.brat={isIncompatible:!0,minAppVersionOriginal:m.minAppVersion},m.minAppVersion=F.apiVersion),F.Platform.isMobile&&m.isDesktopOnly)if(this.plugin.settings.allowIncompatiblePlugins){if(!await vt({app:this.plugin.app,message:createFragment(A=>{A.appendText("Plugin: "),A.createEl("code",{text:e}),A.createEl("br"),A.appendText("The "),A.createEl("code",{text:"manifest.json"}),A.appendText(" for this plugin indicates that the plugin has "),A.createEl("code",{text:"isDesktopOnly: true"}),A.appendText(", but you are using a mobile device."),A.createEl("br"),A.appendText("Using this plugin is not recommended and may not work as expected. Use at your own risk."),A.createEl("br"),A.appendText("Do you want to forcefully run it on mobile anyways?")})}))return null;m.isDesktopOnly=!1,(D=m.brat)!=null||(m.brat={}),m.brat.isDesktopOnlyOriginal=!0,m.brat.isIncompatible=!0,g=!0}else{let N=`Plugin: ${e}
|
|
|
|
The manifest.json for this plugin indicates that the plugin has isDesktopOnly: true, but you are using a mobile device.
|
|
|
|
The plugin will not be installed.`;return await this.plugin.log(N,!0),v(this.plugin,N,30),null}if(g&&(w.manifest=JSON.stringify(m)),this.plugin.settings.debuggingMode&&console.debug("BRAT: rFiles.manifest",u,w),w.mainJs===null){let N=`${e}
|
|
The release is not complete and cannot be downloaded. main.js is missing from the Release`;return await this.plugin.log(N,!0),v(this.plugin,N,p),null}return w};if(!t||o){let w=await h();if(w===null)return!1;if(await this.writeReleaseFilesToPluginFolder(a.id,w),Ln(this.plugin,e,r,g,l),c){let{plugins:m}=this.plugin.app,T=(0,F.normalizePath)(`${m.getPluginFolder()}/${a.id}`);await m.loadManifest(T),await m.enablePluginAndSave(a.id)}if(await this.plugin.app.plugins.loadManifests(),o)await this.reloadPlugin(a.id),await this.plugin.log(`${e} reinstalled`,!0),v(this.plugin,`${e}
|
|
Plugin has been reinstalled and reloaded with version ${a.version}`,p);else{let m=r===""?"":` (version: ${r})`,T=`${e}${m}
|
|
The plugin has been registered with BRAT.`;c||(T+=" You may still need to enable it the Community Plugin List."),await this.plugin.log(T,!0),v(this.plugin,T,p)}}else{let w=`${this.plugin.app.vault.configDir}/plugins/${a.id}/`,m="";try{m=await this.plugin.app.vault.adapter.read(`${w}manifest.json`)}catch(P){if(P.errno===-4058||P.errno===-2)return await this.addPlugin(e,!1,u,!1,r,!1,c,l),!0;console.error("BRAT - Local Manifest Load",a.id,JSON.stringify(P,null,2))}if(r!==""&&r!=="latest")return v(this.plugin,`The version of ${e} is frozen, not updating.`,3),!1;let T=JSON.parse(m),D=(0,Y.coerce)(T.version,{includePrerelease:!0,loose:!0}),N=(0,Y.coerce)(a.version,{includePrerelease:!0,loose:!0});if(D&&N?(0,Y.compare)(D.version,N.version)===-1:T.version!==a.version){let P=await h();if(P===null)return!1;if(s){let V=`There is an update available for ${a.id} from version ${T.version} to ${a.version}. `;return await this.plugin.log(`${V}[Release Info](https://github.com/${e}/releases/tag/${a.version})`,!0),v(this.plugin,V,30,()=>{a&&window.open(`https://github.com/${e}/releases/tag/${a.version}`)}),!1}await this.writeReleaseFilesToPluginFolder(a.id,P),await this.plugin.app.plugins.loadManifests(),await this.reloadPlugin(a.id);let oe=`${a.id}
|
|
Plugin has been updated from version ${T.version} to ${a.version}. `;return await this.plugin.log(`${oe}[Release Info](https://github.com/${e}/releases/tag/${a.version})`,!0),v(this.plugin,oe,30,()=>{a&&window.open(`https://github.com/${e}/releases/tag/${a.version}`)}),!0}return i&&v(this.plugin,`No update available for ${e}`,3),!0}}catch(d){console.error(`BRAT: Error adding plugin ${e}:`,{error:d,updatePluginFiles:t,seeIfUpdatedOnly:s,specifyVersion:r,forceReinstall:o});let p=d instanceof Error?d.message:"Unknown error occurred";return await this.plugin.log(`Error ${t?"updating":"adding"} plugin ${e}: ${p}`,!0),!1}return!0}async reloadPlugin(e){let{plugins:t}=this.plugin.app;try{await t.disablePlugin(e),await t.enablePlugin(e)}catch(s){this.plugin.settings.debuggingMode&&console.error("reload plugin",s)}}async updatePlugin(e,t=!1,s=!1,i=!1,r=""){let o=await this.addPlugin(e,!0,t,s,"",i,!1,r);return!o&&!t&&v(this.plugin,`${e}
|
|
Update of plugin failed.`),o}async checkForPluginUpdatesAndInstallUpdates(e=!1,t=!1){if(!await We()){console.debug("BRAT: No internet detected.");return}let s,i="Checking for plugin updates STARTED";await this.plugin.log(i,!0),e&&this.plugin.settings.notificationsEnabled&&(s=new F.Notice(`BRAT
|
|
${i}`,3e4));let r=new Map(this.plugin.settings.pluginSubListFrozenVersion.map(l=>[l.repo,l.version])),o=new Map(this.plugin.settings.pluginSubListFrozenVersion.map(l=>[l.repo,l.tokenName||""]));for(let l of this.plugin.settings.pluginList){let d=r.get(l);d&&d!=="latest"||await this.updatePlugin(l,t,!1,!1,o.get(l)||"")}let c="Checking for plugin updates COMPLETED";await this.plugin.log(c,!0),e&&(s&&s.hide(),v(this.plugin,c,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(s=>s!==e),this.plugin.settings.pluginSubListFrozenVersion=this.plugin.settings.pluginSubListFrozenVersion.filter(s=>s.repo!==e),this.plugin.saveSettings()}getEnabledDisabledPlugins(e){let t=this.plugin.app.plugins,s=Object.values(t.manifests),i=Object.values(t.plugins).map(r=>r.manifest);return e?s.filter(r=>i.find(o=>r.id===o.id)):s.filter(r=>!i.find(o=>r.id===o.id))}checkIncompatiblePlugins(){let e=this.plugin.settings.pluginSubListFrozenVersion.filter(t=>t.isIncompatible).map(t=>t.repo);e.length>0&&v(this.plugin,`The following incompatible plugins were forcefully installed by BRAT and may not work as expected:
|
|
${e.join(`
|
|
`)}`,30)}};var J=require("obsidian");var ve=async(n,e,t)=>{let s=await ee(e,!0,n.settings.debuggingMode);if(s||(s=await ee(e,!1,n.settings.debuggingMode)),!s)return v(n,"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 Cn(e,n.settings.debuggingMode);if(!i)return v(n,"There is no manifest.json file in the root path of this repository, so theme cannot be installed."),!1;let r=await JSON.parse(i),o=(0,J.normalizePath)(da(n)+r.name),{adapter:c}=n.app.vault;await c.exists(o)||await c.mkdir(o),await c.write((0,J.normalizePath)(`${o}/theme.css`),s),await c.write((0,J.normalizePath)(`${o}/manifest.json`),i),Dn(n,e,be(s));let l="";return t?(kn(n,e,s),l=`${r.name} theme installed from ${e}. `,window.setTimeout(()=>{n.app.customCss.setTheme(r.name)},500)):l=`${r.name} theme updated from ${e}.`,n.log(`${l}[Theme Info](https://github.com/${e})`,!1),v(n,l,20,()=>{window.open(`https://github.com/${e}`)}),!0},ne=async(n,e)=>{if(!await We()){console.debug("BRAT: No internet detected.");return}let t,s="Checking for beta theme updates STARTED";await n.log(s,!0),e&&n.settings.notificationsEnabled&&(t=new J.Notice(`BRAT
|
|
${s}`,3e4));for(let r of n.settings.themesList){let o=await we(r.repo,!0,n.settings.debuggingMode);o==="0"&&(o=await we(r.repo,!1,n.settings.debuggingMode)),console.debug("BRAT: lastUpdateOnline",o),o!==r.lastUpdate&&await ve(n,r.repo,!1)}let i="Checking for beta theme updates COMPLETED";await n.log(i,!0),e&&(n.settings.notificationsEnabled&&t&&t.hide(),v(n,i))},Je=(n,e)=>{n.settings.themesList=n.settings.themesList.filter(s=>s.repo!==e),n.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.`;n.log(t,!0),v(n,t)},da=n=>`${(0,J.normalizePath)(`${n.app.vault.configDir}/themes`)}/`;var Mn="brat-migrations";async function pa(n,e){try{let t=await n.vault.adapter.read(`${n.vault.configDir}/plugins/obsidian42-brat/${Mn}.json`);return JSON.parse(t).appliedMigrations.includes(e)}catch(t){return!1}}async function ma(n,e){try{let t=`${n.vault.configDir}/plugins/obsidian42-brat/${Mn}.json`,s={appliedMigrations:[]};try{let i=await n.vault.adapter.read(t);s=JSON.parse(i)}catch(i){}s.appliedMigrations.includes(e)||(s.appliedMigrations.push(e),await n.vault.adapter.write(t,JSON.stringify(s,null,2)))}catch(t){console.error(`BRAT: Failed to mark migration ${e} complete:`,t)}}async function qn(n,e,t){let s="tokens-to-secretstorage-v1";if(!await pa(n,s))try{let i=0,r=l=>{let p=`brat-gh-${l.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}`;return p.length>64?p.substring(0,64).replace(/-$/,""):p},o=l=>{let d=n.secretStorage.listSecrets();for(let p of d)if(n.secretStorage.getSecret(p)===l)return p;return null},c=(l,d)=>{let p=o(l);return p?(console.debug(`BRAT: Reusing existing secret "${p}"`),p):(n.secretStorage.setSecret(d,l),console.debug(`BRAT: Created new secret "${d}"`),d)};if(e.personalAccessToken&&e.personalAccessToken.trim()!==""){let l=e.personalAccessToken.trim(),p=c(l,"brat-gh-global");e.globalTokenName=p,e.personalAccessToken="",i++}if(e.pluginSubListFrozenVersion){for(let l of e.pluginSubListFrozenVersion)if(l.token&&l.token.trim()!==""){let d=l.token.trim(),p=r(l.repo),a=c(d,p);l.tokenName=a,l.token=void 0,i++}}i>0&&(await t(),console.debug(`BRAT: Migrated ${i} token(s) to SecretStorage`)),await ma(n,s)}catch(i){console.error("BRAT: Failed to migrate tokens to SecretStorage:",i)}}var K=require("obsidian");var j=class extends K.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(xn(this.plugin,e)){v(this.plugin,"This theme is already in the list for beta testing",10);return}await ve(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 K.Setting(e).addText(i=>{i.setPlaceholder("Repository (example: https://github.com/GitHubUserName/repository-name"),i.setValue(this.address),i.onChange(r=>{this.address=r.trim()}),i.inputEl.addEventListener("keydown",r=>{r.key==="Enter"&&this.address!==" "&&(r.preventDefault(),this.submitForm())}),i.inputEl.addClass("brat-full-width-input"),window.setTimeout(()=>{let r=document.querySelector(".setting-item-info");r&&r.remove(),i.inputEl.focus()},10)}),e.createDiv("modal-button-container",i=>{new K.ButtonComponent(i).setButtonText("Never mind").onClick(()=>{this.close()}),new K.ButtonComponent(i).setButtonText("Add theme").setCta().onClick(r=>{r.preventDefault(),console.debug("Add theme button clicked"),this.address!==""&&this.submitForm()})});let t=e.createDiv();t.addClass("brat-modal-divider");let s=t.createSpan();s.createEl("a",{href:"https://bit.ly/o42-twitter",text:"TFTHacker"}),s.appendText(" and "),s.createEl("a",{href:"https://github.com/johannrichard",text:"johannrichard"}),s.addClass("brat-credits"),t.appendChild(s),se(t,!1),window.setTimeout(()=>{let i=e.querySelectorAll(".brat-modal .setting-item-info");for(let r of Array.from(i))r.remove()},50)})}onClose(){this.openSettingsTabAfterwards&&(this.plugin.app.setting.openTab(),this.plugin.app.setting.openTabById(this.plugin.APP_ID))}};var Vn=require("obsidian");function Un(){(0,Vn.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 Hn=require("obsidian"),q=class extends Hn.FuzzySuggestModal{constructor(t){super(t.app);this.data=[];this.scope.register(["Shift"],"Enter",s=>{this.enterTrigger(s)}),this.scope.register(["Ctrl"],"Enter",s=>{this.enterTrigger(s)})}setSuggesterData(t){this.data=t}display(t){this.callbackFunction=t,this.open()}getItems(){return this.data}getItemText(t){return t.display}onChooseItem(){}renderSuggestion(t,s){s.createEl("div",{text:t.item.display})}enterTrigger(t){var r;let s=(r=document.querySelector(".suggestion-item.is-selected div"))==null?void 0:r.textContent,i=this.data.find(o=>o.display===s);i&&(this.invokeCallback(i,t),this.close())}onChooseSuggestion(t,s){this.invokeCallback(t.item,s)}invokeCallback(t,s){typeof this.callbackFunction=="function"&&this.callbackFunction(t,s)}};var ye=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 r=e.get(i);return!(r!=null&&r.version)||r.version==="latest"}).map(i=>({display:i,info:i})),s=new q(this.plugin);s.setSuggesterData(t),s.display(i=>{let r=`Checking for updates for ${i.info}`,o=e.get(i.info);this.plugin.log(r,!0),v(this.plugin,`
|
|
${r}`,3),this.plugin.betaPlugins.updatePlugin(i.info,!1,!0,!1,o==null?void 0:o.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})),s=new q(this.plugin);s.setSuggesterData(t),s.display(i=>{let r=`Reinstalling ${i.info}`;v(this.plugin,`
|
|
${r}`,3),this.plugin.log(r,!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(s=>({display:s.id,info:s.id})),t=new q(this.plugin);t.setSuggesterData(e),t.display(s=>{v(this.plugin,`${s.info}
|
|
Plugin reloading .....`,5),this.plugin.betaPlugins.reloadPlugin(s.info)})}},{id:"disablePlugin",icon:"BratIcon",name:"Plugins: Disable a plugin - toggle it off",showInRibbon:!0,callback:()=>{let e=this.plugin.betaPlugins.getEnabledDisabledPlugins(!0).map(s=>({display:`${s.name} (${s.id})`,info:s.id})),t=new q(this.plugin);t.setSuggesterData(e),t.display(s=>{this.plugin.log(`${s.display} plugin disabled`,!1),this.plugin.settings.debuggingMode&&console.debug(s.info),this.plugin.app.plugins.disablePluginAndSave(s.info)})}},{id:"enablePlugin",icon:"BratIcon",name:"Plugins: Enable a plugin - toggle it on",showInRibbon:!0,callback:()=>{let e=this.plugin.betaPlugins.getEnabledDisabledPlugins(!1).map(s=>({display:`${s.name} (${s.id})`,info:s.id})),t=new q(this.plugin);t.setSuggesterData(e),t.display(s=>{this.plugin.log(`${s.display} plugin enabled`,!1),this.plugin.app.plugins.enablePluginAndSave(s.info)})}},{id:"openGitHubZRepository",icon:"BratIcon",name:"Plugins: Open the GitHub repository for a plugin",showInRibbon:!0,callback:async()=>{let e=await Nn(this.plugin.settings.debuggingMode);if(e){let t=Object.values(e).map(r=>({display:`Plugin: ${r.name} (${r.repo})`,info:r.repo})),s=Object.values(this.plugin.settings.pluginList).map(r=>({display:`BRAT: ${r}`,info:r}));for(let r of t)s.push(r);let i=new q(this.plugin);i.setSuggesterData(s),i.display(r=>{r.info&&window.open(`https://github.com/${r.info}`)})}}},{id:"openGitHubRepoTheme",icon:"BratIcon",name:"Themes: Open the GitHub repository for a theme (appearance)",showInRibbon:!0,callback:async()=>{let e=await An(this.plugin.settings.debuggingMode);if(e){let t=Object.values(e).map(i=>({display:`Theme: ${i.name} (${i.repo})`,info:i.repo})),s=new q(this.plugin);s.setSuggesterData(t),s.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(r=>({display:`Plugin: ${r.name}`,info:r.id})),s=new q(this.plugin),i=Object.values(e.settingTabs).map(r=>({display:`Core: ${r.name}`,info:r.id}));for(let r of t)i.push(r);s.setSuggesterData(i),s.display(r=>{e.open(),e.openTabById(r.info)})}},{id:"GrabBetaTheme",icon:"BratIcon",name:"Themes: Grab a beta theme for testing from a Github repository",showInRibbon:!0,callback:()=>{new j(this.plugin).open()}},{id:"updateBetaThemes",icon:"BratIcon",name:"Themes: Update beta themes",showInRibbon:!0,callback:async()=>{await ne(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 o of this.bratCommands)o.showInRibbon&&e.push({display:o.name,info:o.callback});let t=new q(this.plugin),s=this.plugin.app.setting,i=Object.values(s.settingTabs).map(o=>({display:`Core: ${o.name}`,info:()=>{s.open(),s.openTabById(o.id)}})),r=Object.values(s.pluginTabs).map(o=>({display:`Plugin: ${o.name}`,info:()=>{s.open(),s.openTabById(o.id)}}));e.push({display:"---- Core Plugin Settings ----",info:()=>{this.ribbonDisplayCommands()}});for(let o of i)e.push(o);e.push({display:"---- Plugin Settings ----",info:()=>{this.ribbonDisplayCommands()}});for(let o of r)e.push(o);t.setSuggesterData(e),t.display(o=>{typeof o.info=="function"&&o.info()})}};var x=require("obsidian");var Ke=class extends x.PluginSettingTab{constructor(t,s){super(t,s);this.accessTokenSetting=null;this.accessTokenButton=null;this.tokenInfo=null;this.validator=null;this.plugin=s}display(){let{containerEl:t}=this;t.empty(),t.addClass("brat-settings"),new x.Setting(t).setName("Auto-enable plugins after installation").setDesc('If enabled beta plugins will be automatically enabled after installtion by default. Note: you can toggle this on and off for each plugin in the "add plugin" form.').addToggle(a=>{a.setValue(this.plugin.settings.enableAfterInstall).onChange(async u=>{this.plugin.settings.enableAfterInstall=u,await this.plugin.saveSettings()})}),new x.Setting(t).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(a=>{a.setValue(this.plugin.settings.updateAtStartup).onChange(async u=>{this.plugin.settings.updateAtStartup=u,await this.plugin.saveSettings()})}),new x.Setting(t).setName("Auto-update themes at startup").setDesc("If enabled all beta themes will be checked for updates each time Obsidian starts.").addToggle(a=>{a.setValue(this.plugin.settings.updateThemesAtStartup).onChange(async u=>{this.plugin.settings.updateThemesAtStartup=u,await this.plugin.saveSettings()})}),new x.Setting(t).setName("Select latest plugin version by default").setDesc("If enabled the latest version will be selected by default when adding a new plugin.").addToggle(a=>{a.setValue(this.plugin.settings.selectLatestPluginVersionByDefault).onChange(async u=>{this.plugin.settings.selectLatestPluginVersionByDefault=u,await this.plugin.saveSettings()})}),new x.Setting(t).setName("Allow incompatible plugins").setDesc("If enabled, plugins with higher app versions will be allowed to be installed. Also it allows desktop-only plugins to be installed on mobile devices.").addToggle(a=>{a.setValue(this.plugin.settings.allowIncompatiblePlugins).onChange(async u=>{this.plugin.settings.allowIncompatiblePlugins=u,await this.plugin.saveSettings()})}),se(t,!0),t.createEl("hr");let s=new Map(this.plugin.settings.pluginSubListFrozenVersion.map(a=>[a.repo,a])),i=new Map,r=new x.SettingGroup(t).setHeading("Beta plugin list");r.addSearch(a=>{a.setPlaceholder("Filter plugins"),a.onChange(u=>{let g=u.toLowerCase().trim();i.forEach(({container:h,pluginName:w})=>{g===""||w.includes(g)?h.removeAttribute("hidden"):h.setAttribute("hidden","true")})})}),r.addSetting(a=>{let u=document.createDocumentFragment();u.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.'}),u.createEl("p"),u.createEl("div",{text:'Click the "edit" button next to a plugin to change the installed version. Click the "X" button next to a plugin to remove it from the list.'}),u.createEl("p"),u.createEl("span").createEl("b",{text:"Note: "}),u.createSpan({text:"Removing from the list does not delete the plugin, this should be done from the Community Plugins tab in Settings."}),a.setDesc(u),a.addButton(g=>{g.setButtonText("Add beta plugin").setCta().onClick(()=>{this.plugin.betaPlugins.displayAddNewPluginModal(!0)})})});for(let a of this.plugin.settings.pluginList){let u=s.get(a);r.addSetting(g=>{let h=(u==null?void 0:u.tokenName)||"",w=h?this.plugin.app.secretStorage.getSecret(h):"",m=!!(h&&!w),T=document.createDocumentFragment(),D=u!=null&&u.version?` Tracked version: ${u.version} ${u.version==="latest"?"":"(frozen)"}`:"",N=u!=null&&u.isIncompatible?" (incompatible)":"";T.createDiv({text:`${D}${N}`}),m&&T.createDiv({text:` Secret not defined or empty: ${h}`,cls:"mod-warning",title:"Token name configured but secret is missing. Add the secret or update the plugin configuration."}),g.setName(Te(a)).setDesc(T);let A=g.settingEl;A.addClass("brat-plugin-item"),i.set(a,{container:A,pluginName:a.toLowerCase()}),(!(u!=null&&u.version)||u.version==="latest")&&g.addButton(P=>{m?P.setIcon("sync").setTooltip(`Secret missing: ${h}. Please add the secret or update the plugin configuration.`).setWarning().setDisabled(!0):P.setIcon("sync").setTooltip("Check and update plugin").onClick(async()=>{await this.plugin.betaPlugins.updatePlugin(a,!1,!0,!1,(u==null?void 0:u.tokenName)||"")})}),g.addButton(P=>{P.setIcon("edit").setTooltip("Change version and update settings"),m&&P.setWarning(),P.onClick(()=>{this.plugin.betaPlugins.displayAddNewPluginModal(!0,!0,a,u==null?void 0:u.version,(u==null?void 0:u.tokenName)||""),this.plugin.app.setting.updatePluginSection()})}).addButton(P=>{P.setIcon("cross").setTooltip("Remove this beta plugin").setWarning().onClick(()=>{if(P.buttonEl.textContent==="")P.setButtonText("Click once more to confirm removal");else{let{buttonEl:oe}=P,{parentElement:V}=oe;V!=null&&V.parentElement&&(V.parentElement.remove(),this.plugin.betaPlugins.deletePlugin(a))}})})})}let o=new Map,c=new x.SettingGroup(t).setHeading("Beta themes list");c.addSetting(a=>{a.addButton(u=>{u.setButtonText("Add beta theme").setCta().onClick(()=>{this.plugin.app.setting.close(),new j(this.plugin).open()})})}),c.addSearch(a=>{a.setPlaceholder("Filter themes"),a.onChange(u=>{let g=u.toLowerCase().trim();o.forEach(({container:h,themeName:w})=>{g===""||w.includes(g)?h.removeAttribute("hidden"):h.setAttribute("hidden","true")})})});for(let a of this.plugin.settings.themesList)c.addSetting(u=>{u.setName(Te(a.repo));let g=u.settingEl;g.addClass("brat-theme-item"),o.set(a.repo,{container:g,themeName:a.repo.toLowerCase()}),u.addButton(h=>{h.setIcon("cross").setTooltip("Delete this beta theme").onClick(()=>{if(h.buttonEl.textContent==="")h.setButtonText("Click once more to confirm removal");else{let{buttonEl:w}=h,{parentElement:m}=w;m!=null&&m.parentElement&&(m.parentElement.remove(),Je(this.plugin,a.repo))}})})});let l=new x.SettingGroup(t).setHeading("Monitoring");l.addSetting(a=>{a.setName("Enable notifications").setDesc("BRAT will provide popup notifications for its various activities. Turn this off means no notifications.").addToggle(u=>{u.setValue(this.plugin.settings.notificationsEnabled),u.onChange(g=>{this.plugin.settings.notificationsEnabled=g,this.plugin.saveSettings()})})}),l.addSetting(a=>{a.setName("Enable logging").setDesc("Plugin updates will be logged to a file in the log file.").addToggle(u=>{u.setValue(this.plugin.settings.loggingEnabled).onChange(g=>{this.plugin.settings.loggingEnabled=g,this.plugin.saveSettings()})})}),l.addSetting(a=>{a.setName("BRAT log file location").setDesc("Logs will be saved to this file. Don't add .md to the file name.").addSearch(u=>{u.setPlaceholder("Example: BRAT-log").setValue(this.plugin.settings.loggingPath).onChange(g=>{this.plugin.settings.loggingPath=g,this.plugin.saveSettings()})})}),l.addSetting(a=>{a.setName("Enable verbose logging").setDesc("Get a lot more information in the log.").addToggle(u=>{u.setValue(this.plugin.settings.loggingVerboseEnabled).onChange(g=>{this.plugin.settings.loggingVerboseEnabled=g,this.plugin.saveSettings()})})}),l.addSetting(a=>{a.setName("Debugging mode").setDesc("Atomic bomb level console logging. Can be used for troubleshooting and development.").addToggle(u=>{u.setValue(this.plugin.settings.debuggingMode).onChange(g=>{this.plugin.settings.debuggingMode=g,this.plugin.saveSettings()})})});let d=new x.SettingGroup(t).setHeading("GitHub Personal Access Token"),p="";d.addSetting(a=>{a.setName("Personal access token").setDesc(On({prependText:"Set a personal access token to increase rate limits for public repositories on GitHub. You can create one in ",url:"https://github.com/settings/tokens/new?scopes=public_repo",text:"your GitHub account settings",appendText:" and then add it here. Please consult the documentation for more details."})),this.accessTokenSetting=new x.SecretComponent(this.plugin.app,a.controlEl),this.accessTokenSetting.setValue(this.plugin.settings.globalTokenName||"").onChange(u=>{(async()=>{var h,w,m;let g=(u==null?void 0:u.trim())||"";this.plugin.settings.globalTokenName=g,await this.plugin.saveSettings(),g?(p=this.plugin.app.secretStorage.getSecret(g)||"",(h=this.accessTokenButton)==null||h.setDisabled(!1)):(p="",(w=this.accessTokenButton)==null||w.setDisabled(!0),await((m=this.validator)==null?void 0:m.validateToken("")))})()}),this.plugin.settings.globalTokenName&&(p=this.plugin.app.secretStorage.getSecret(this.plugin.settings.globalTokenName)||""),a.addExtraButton(u=>{u.setIcon("cross").setTooltip("Clear personal access token").onClick(async()=>{var g,h;this.plugin.settings.globalTokenName="",await this.plugin.saveSettings(),(g=this.accessTokenSetting)==null||g.setValue(""),p="",await((h=this.validator)==null?void 0:h.validateToken(""))})}).addButton(u=>{this.accessTokenButton=u,u.setButtonText("Validate").setCta().onClick(async()=>{var g;p&&await((g=this.validator)==null?void 0:g.validateToken(p))})}).then(()=>{var u;this.tokenInfo=this.createTokenInfoElement(t),this.validator=new te(this.tokenInfo),(u=this.validator)==null||u.validateToken(p).then(g=>{var h;(h=this.accessTokenButton)==null||h.setDisabled(g||!this.plugin.settings.globalTokenName)})})})}createTokenInfoElement(t){let s=t.createDiv({cls:"brat-token-info"});return s.createDiv({cls:"brat-token-status"}),s.createDiv({cls:"brat-token-details"}),s}};var Re=class{constructor(e){this.console=(e,...t)=>{console.debug(`BRAT: ${e}`,...t)};this.themes={themeseCheckAndUpates:async e=>{await ne(this.plugin,e)},themeInstallTheme:async e=>{let t=e.replace("https://github.com/","");await ve(this.plugin,t,!0)},themesDelete:e=>{let t=e.replace("https://github.com/","");Je(this.plugin,t)},grabCommmunityThemeCssFile:async(e,t=!1)=>await ee(e,t,this.plugin.settings.debuggingMode),grabChecksumOfThemeCssFile:async(e,t=!1)=>await we(e,t,this.plugin.settings.debuggingMode),grabLastCommitDateForFile:async(e,t)=>await Sn(e,t)};this.plugin=e}};var Q=require("obsidian"),ni=Ze(si());async function ii(n,e,t=!1){if(n.settings.debuggingMode&&console.debug(`BRAT: ${e}`),n.settings.loggingEnabled){if(!n.settings.loggingVerboseEnabled&&t)return;let s=`${n.settings.loggingPath}.md`,i=Q.moment.unix(Math.floor(Date.now()/1e3)),r=`[[${i.format((0,ni.getDailyNoteSettings)().format).toString()}]] ${i.format("HH:mm")}`,o=Q.Platform.isDesktop?window.require("os"):null,c=Q.Platform.isDesktop?o==null?void 0:o.hostname():"MOBILE",l=`${r} ${c} ${e.replace(`
|
|
`," ")}
|
|
`,d=n.app.vault.getAbstractFileByPath(s);d instanceof Q.TFile?await n.app.vault.append(d,l):await n.app.vault.create(s,l)}}var Qe=class extends ri.Plugin{constructor(){super(...arguments);this.APP_NAME="BRAT";this.APP_ID="obsidian42-brat";this.settings=Pt;this.betaPlugins=new Ee(this);this.commands=new ye(this);this.bratApi=new Re(this);this.obsidianProtocolHandler=t=>{if(!t.plugin&&!t.theme){v(this,"Could not locate the repository from the URL.",10);return}for(let s of["plugin","theme"])if(t[s]){let i;switch(s){case"plugin":i=new W(this,this.betaPlugins,!0,!1,t[s],t.version?t.version:void 0),i.open();break;case"theme":i=new j(this),i.address=t[s],i.open();break}return}}}onload(){console.debug(`loading ${this.APP_NAME}`),Un(),this.addRibbonIcon("BratIcon","BRAT",()=>{this.commands.ribbonDisplayCommands()}),this.loadSettings().then(async()=>{await qn(this.app,this.settings,()=>this.saveSettings()),this.app.workspace.onLayoutReady(()=>{this.addSettingTab(new Ke(this.app,this)),this.registerObsidianProtocolHandler("brat",this.obsidianProtocolHandler),this.betaPlugins.checkIncompatiblePlugins(),this.settings.updateAtStartup&&window.setTimeout(()=>{this.betaPlugins.checkForPluginUpdatesAndInstallUpdates(!1)},6e4),this.settings.updateThemesAtStartup&&window.setTimeout(()=>{ne(this,!1)},12e4),window.setTimeout(()=>{window.bratAPI=this.bratApi},500)})}).catch(t=>{console.error("Failed to load settings:",t)})}async log(t,s=!1){await ii(this,t,s)}onunload(){console.debug(`unloading ${this.APP_NAME}`)}async loadSettings(){this.settings=Object.assign({},Pt,await this.loadData())}async saveSettings(){await this.saveData(this.settings)}};
|
|
|
|
/* nosourcemap */ |