107 lines
6.1 MiB
JavaScript
107 lines
6.1 MiB
JavaScript
/*
|
|||
|
|
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||
|
|
if you want to view the source, please visit the github repository of this plugin
|
||
|
|
*/
|
||
|
|
|
||
|
|
var yE=Object.create;var Xm=Object.defineProperty;var oE=Object.getOwnPropertyDescriptor;var CE=Object.getOwnPropertyNames;var iE=Object.getPrototypeOf,gE=Object.prototype.hasOwnProperty;var AE=(b,I,G)=>I in b?Xm(b,I,{enumerable:!0,configurable:!0,writable:!0,value:G}):b[I]=G;var La=(b,I)=>()=>(I||b((I={exports:{}}).exports,I),I.exports),ol=(b,I)=>{for(var G in I)Xm(b,G,{get:I[G],enumerable:!0})},cp=(b,I,G,l)=>{if(I&&typeof I=="object"||typeof I=="function")for(let c of CE(I))!gE.call(b,c)&&c!==G&&Xm(b,c,{get:()=>I[c],enumerable:!(l=oE(I,c))||l.enumerable});return b};var UI=(b,I,G)=>(G=b!=null?yE(iE(b)):{},cp(I||!b||!b.__esModule?Xm(G,"default",{value:b,enumerable:!0}):G,b)),rE=b=>cp(Xm({},"__esModule",{value:!0}),b);var GI=(b,I,G)=>AE(b,typeof I!="symbol"?I+"":I,G);var Sp=La((on,Cn)=>{(function(b,I){typeof on=="object"&&typeof Cn<"u"?Cn.exports=I():typeof define=="function"&&define.amd?define(I):(b=typeof globalThis<"u"?globalThis:b||self).dayjs_plugin_quarterOfYear=I()})(on,function(){"use strict";var b="month",I="quarter";return function(G,l){var c=l.prototype;c.quarter=function(d){return this.$utils().u(d)?Math.ceil((this.month()+1)/3):this.month(this.month()%3+3*(d-1))};var Z=c.add;c.add=function(d,m){return d=Number(d),this.$utils().p(m)===I?this.add(3*d,b):Z.bind(this)(d,m)};var W=c.startOf;c.startOf=function(d,m){var N=this.$utils(),Y=!!N.u(m)||m;if(N.p(d)===I){var a=this.quarter()-1;return Y?this.month(3*a).startOf(b).startOf("day"):this.month(3*a+2).endOf(b).endOf("day")}return W.bind(this)(d,m)}}})});var MI=La((gn,An)=>{(function(b,I){typeof gn=="object"&&typeof An<"u"?An.exports=I():typeof define=="function"&&define.amd?define(I):(b=typeof globalThis<"u"?globalThis:b||self).dayjs=I()})(gn,function(){"use strict";var b=1e3,I=6e4,G=36e5,l="millisecond",c="second",Z="minute",W="hour",d="day",m="week",N="month",Y="quarter",a="year",V="date",h="Invalid Date",n=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,X=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,p={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(L){var z=["th","st","nd","rd"],r=L%100;return"["+L+(z[(r-20)%10]||z[r]||z[0])+"]"}},e=function(L,z,r){var w=String(L);return!w||w.length>=z?L:""+Array(z+1-w.length).join(r)+L},Q={s:e,z:function(L){var z=-L.utcOffset(),r=Math.abs(z),w=Math.floor(r/60),i=r%60;return(z<=0?"+":"-")+e(w,2,"0")+":"+e(i,2,"0")},m:function L(z,r){if(z.date()<r.date())return-L(r,z);var w=12*(r.year()-z.year())+(r.month()-z.month()),i=z.clone().add(w,N),o=r-i<0,B=z.clone().add(w+(o?-1:1),N);return+(-(w+(r-i)/(o?i-B:B-i))||0)},a:function(L){return L<0?Math.ceil(L)||0:Math.floor(L)},p:function(L){return{M:N,y:a,w:m,d,D:V,h:W,m:Z,s:c,ms:l,Q:Y}[L]||String(L||"").toLowerCase().replace(/s$/,"")},u:function(L){return L===void 0}},s="en",R={};R[s]=p;var J="$isDayjsObject",E=function(L){return L instanceof k||!(!L||!L[J])},H=function L(z,r,w){var i;if(!z)return s;if(typeof z=="string"){var o=z.toLowerCase();R[o]&&(i=o),r&&(R[o]=r,i=o);var B=z.split("-");if(!i&&B.length>1)return L(B[0])}else{var j=z.name;R[j]=z,i=j}return!w&&i&&(s=i),i||!w&&s},g=function(L,z){if(E(L))return L.clone();var r=typeof z=="object"?z:{};return r.date=L,r.args=arguments,new k(r)},C=Q;C.l=H,C.i=E,C.w=function(L,z){return g(L,{locale:z.$L,utc:z.$u,x:z.$x,$offset:z.$offset})};var k=function(){function L(r){this.$L=H(r.locale,null,!0),this.parse(r),this.$x=this.$x||r.x||{},this[J]=!0}var z=L.prototype;return z.parse=function(r){this.$d=function(w){var i=w.date,o=w.utc;if(i===null)return new Date(NaN);if(C.u(i))return new Date;if(i instanceof Date)return new Date(i);if(typeof i=="string"&&!/Z$/i.test(i)){var B=i.match(n);if(B){var j=B[2]-1||0,_=(B[7]||"0").substring(0,3);return o?new Date(Date.UTC(B[1],j,B[3]||1,B[4]||0,B[5]||0,B[6]||0,_)):new Date(B[1],j,B[3]||1,B[4]||0,B[5]||0,B[6]||0,_)}}return new Date(i)}(r),this.init()},z.init=f
|
||
|
|
`||u.charAt(P)==="\r"&&u.charAt(P+1)!==`
|
||
|
|
`)&&($++,II===0&&(II=P+1)),P--}var hI=D+$,$I=A-II;return x[A]={line:hI,lineStart:II},{offset:A,line:hI+1,column:$I+1}}function L(u){if(!R(u))throw new Error("not a parser: "+u)}function z(u,A){return typeof u=="string"?u.charAt(A):u[A]}function r(u){if(typeof u!="number")throw new Error("not a number: "+u)}function w(u){if(typeof u!="function")throw new Error("not a function: "+u)}function i(u){if(typeof u!="string")throw new Error("not a string: "+u)}var o=2,B=3,j=8,_=5*j,YI=4*j,aI=" ";function QI(u,A){return new Array(A+1).join(u)}function vI(u,A,x){var D=A-u.length;return D<=0?u:QI(x,D)+u}function tI(u,A,x,D){return{from:u-A>0?u-A:0,to:u+x>D?D:u+x}}function VI(u,A){var x,D,$,II,P,hI=A.index,$I=hI.offset,JG=1;if($I===u.length)return"Got the end of the input";if(E(u)){var lG=$I-$I%j,$l=$I-lG,BG=tI(lG,_,YI+j,u.length),OG=N(function(rG){return N(function(uW){return vI(uW.toString(16),2,"0")},rG)},function(rG,uW){var sW=rG.length,FZ=[],wW=0;if(sW<=uW)return[rG.slice()];for(var vW=0;vW<sW;vW++)FZ[wW]||FZ.push([]),FZ[wW].push(rG[vW]),(vW+1)%uW==0&&wW++;return FZ}(u.slice(BG.from,BG.to).toJSON().data,j));II=function(rG){return rG.from===0&&rG.to===1?{from:rG.from,to:rG.to}:{from:rG.from/j,to:Math.floor(rG.to/j)}}(BG),D=lG/j,x=3*$l,$l>=4&&(x+=1),JG=2,$=N(function(rG){return rG.length<=4?rG.join(" "):rG.slice(0,4).join(" ")+" "+rG.slice(4).join(" ")},OG),(P=(8*(II.to>0?II.to-1:II.to)).toString(16).length)<2&&(P=2)}else{var MG=u.split(/\r\n|[\n\r\u2028\u2029]/);x=hI.column-1,D=hI.line-1,II=tI(D,o,B,MG.length),$=MG.slice(II.from,II.to),P=II.to.toString().length}var FG=D-II.from;return E(u)&&(P=(8*(II.to>0?II.to-1:II.to)).toString(16).length)<2&&(P=2),m(function(rG,uW,sW){var FZ,wW=sW===FG,vW=wW?"> ":aI;return FZ=E(u)?vI((8*(II.from+sW)).toString(16),P,"0"):vI((II.from+sW+1).toString(),P," "),[].concat(rG,[vW+FZ+" | "+uW],wW?[aI+QI(" ",P)+" | "+vI("",x," ")+QI("^",JG)]:[])},[],$).join(`
|
||
|
|
`)}function EI(u,A){return[`
|
||
|
|
`,"-- PARSING FAILED "+QI("-",50),`
|
||
|
|
|
||
|
|
`,VI(u,A),`
|
||
|
|
|
||
|
|
`,(x=A.expected,x.length===1?`Expected:
|
||
|
|
|
||
|
|
`+x[0]:`Expected one of the following:
|
||
|
|
|
||
|
|
`+x.join(", ")),`
|
||
|
|
`].join("");var x}function _I(u){return u.flags!==void 0?u.flags:[u.global?"g":"",u.ignoreCase?"i":"",u.multiline?"m":"",u.unicode?"u":"",u.sticky?"y":""].join("")}function RG(){for(var u=[].slice.call(arguments),A=u.length,x=0;x<A;x+=1)L(u[x]);return Z(function(D,$){for(var II,P=new Array(A),hI=0;hI<A;hI+=1){if(!(II=C(u[hI]._(D,$),II)).status)return II;P[hI]=II.value,$=II.index}return C(H($,P),II)})}function EG(){var u=[].slice.call(arguments);if(u.length===0)throw new Error("seqMap needs at least one argument");var A=u.pop();return w(A),RG.apply(null,u).map(function(x){return A.apply(null,x)})}function tG(){var u=[].slice.call(arguments),A=u.length;if(A===0)return T("zero alternates");for(var x=0;x<A;x+=1)L(u[x]);return Z(function(D,$){for(var II,P=0;P<u.length;P+=1)if((II=C(u[P]._(D,$),II)).status)return II;return II})}function eb(u,A){return Ul(u,A).or(al([]))}function Ul(u,A){return L(u),L(A),EG(u,A.then(u).many(),function(x,D){return[x].concat(D)})}function Bl(u){i(u);var A="'"+u+"'";return Z(function(x,D){var $=D+u.length,II=x.slice(D,$);return II===u?H($,II):g(D,A)})}function Yl(u,A){(function($){if(!($ instanceof RegExp))throw new Error("not a regexp: "+$);for(var II=_I($),P=0;P<II.length;P++){var hI=II.charAt(P);if(hI!=="i"&&hI!=="m"&&hI!=="u"&&hI!=="s")throw new Error('unsupported regexp flag "'+hI+'": '+$)}})(u),arguments.length>=2?r(A):A=0;var x=function($){return RegExp("^(?:"+$.source+")",_I($))}(u),D=""+u;return Z(function($,II){var P=x.exec($.slice(II));if(P){if(0<=A&&A<=P.length){var hI=P[0],$I=P[A];return H(II+hI.length,$I)}return g(II,"valid match group (0 to "+P.length+") in "+D)}return g(II,D)})}function al(u){return Z(function(A,x){return H(x,u)})}function T(u){return Z(function(A,x){return g(x,u)})}function LI(u){if(R(u))return Z(function(A,x){var D=u._(A,x);return D.index=x,D.value="",D});if(typeof u=="string")return LI(Bl(u));if(u instanceof RegExp)return LI(Yl(u));throw new Error("not a string, regexp, or parser: "+u)}function xI(u){return L(u),Z(function(A,x){var D=u._(A,x),$=A.slice(x,D.index);return D.status?g(x,'not "'+$+'"'):H(x,null)})}function KI(u){return w(u),Z(function(A,x){var D=z(A,x);return x<A.length&&u(D)?H(x+1,D):g(x,"a character/byte matching "+u)})}function Pl(u,A){arguments.length<2&&(A=u,u=void 0);var x=Z(function(D,$){return x._=A()._,x._(D,$)});return u?x.desc(u):x}function Vl(){return T("fantasy-land/empty")}W.parse=function(u){if(typeof u!="string"&&!E(u))throw new Error(".parse must be called with a string or Buffer as its argument");var A,x=this.skip(_l)._(u,0);return A=x.status?{status:!0,value:x.value}:{status:!1,index:f(u,x.furthest),expected:x.expected},delete k[u],A},W.tryParse=function(u){var A=this.parse(u);if(A.status)return A.value;var x=EI(u,A),D=new Error(x);throw D.type="ParsimmonError",D.result=A,D},W.assert=function(u,A){return this.chain(function(x){return u(x)?al(x):T(A)})},W.or=function(u){return tG(this,u)},W.trim=function(u){return this.wrap(u,u)},W.wrap=function(u,A){return EG(u,this,A,function(x,D){return D})},W.thru=function(u){return u(this)},W.then=function(u){return L(u),RG(this,u).map(function(A){return A[1]})},W.many=function(){var u=this;return Z(function(A,x){for(var D=[],$=void 0;;){if(!($=C(u._(A,x),$)).status)return C(H(x,D),$);if(x===$.index)throw new Error("infinite loop detected in .many() parser --- calling .many() on a parser which can accept zero characters is usually the cause");x=$.index,D.push($.value)}})},W.tieWith=function(u){return i(u),this.map(function(A){if(function($){if(!J($))throw new Error("not an array: "+$)}(A),A.length){i(A[0]);for(var x=A[0],D=1;D<A.length;D++)i(A[D]),x+=u+A[D];return x}return""})},W.tie=function(){return this.tieWith("")},W.times=function(u,A){var x=this;return arguments.length<2&&(A=u),r(u),r(A),Z(function(D,$){for(var II=[],P=void 0,hI=void 0,$I=0;$I<u;$I+=1){if(hI=C(P=x._(D,$),hI),!P.status)return hI;$=P.index,II.push(P.value)}for(;$I<A&&(hI=C(P=x._(D,$),hI),P.status);$I+=1)$=P.index,II.push(P.value);return C(H($,II),hI)})},W.result=function(u){return this.map(function(){return u})},W.atMost=f
|
||
|
|
`),RZ=Bl(`\r
|
||
|
|
`),ub=tG(RZ,tm,nZ).desc("newline"),ra=tG(ub,_l);Z.all=nc,Z.alt=tG,Z.any=rc,Z.cr=nZ,Z.createLanguage=function(u){var A={};for(var x in u)({}).hasOwnProperty.call(u,x)&&function(D){A[D]=Pl(function(){return u[D](A)})}(x);return A},Z.crlf=RZ,Z.custom=function(u){return Z(u(H,g))},Z.digit=Lc,Z.digits=hZ,Z.empty=Vl,Z.end=ra,Z.eof=_l,Z.fail=T,Z.formatError=EI,Z.index=Ol,Z.isParser=R,Z.lazy=Pl,Z.letter=kc,Z.letters=Qb,Z.lf=tm,Z.lookahead=LI,Z.makeFailure=g,Z.makeSuccess=H,Z.newline=ub,Z.noneOf=function(u){return KI(function(A){return u.indexOf(A)<0}).desc("none of '"+u+"'")},Z.notFollowedBy=xI,Z.of=al,Z.oneOf=function(u){for(var A=u.split(""),x=0;x<A.length;x++)A[x]="'"+A[x]+"'";return KI(function(D){return u.indexOf(D)>=0}).desc(A)},Z.optWhitespace=Aa,Z.Parser=Z,Z.range=function(u,A){return KI(function(x){return u<=x&&x<=A}).desc(u+"-"+A)},Z.regex=Yl,Z.regexp=Yl,Z.sepBy=eb,Z.sepBy1=Ul,Z.seq=RG,Z.seqMap=EG,Z.seqObj=function(){for(var u,A={},x=0,D=(u=arguments,Array.prototype.slice.call(u)),$=D.length,II=0;II<$;II+=1){var P=D[II];if(!R(P)){if(J(P)&&P.length===2&&typeof P[0]=="string"&&R(P[1])){var hI=P[0];if(Object.prototype.hasOwnProperty.call(A,hI))throw new Error("seqObj: duplicate key "+hI);A[hI]=!0,x++;continue}throw new Error("seqObj arguments must be parsers or [string, parser] array pairs.")}}if(x===0)throw new Error("seqObj expects at least one named parser, found zero");return Z(function($I,JG){for(var lG,$l={},BG=0;BG<$;BG+=1){var OG,MG;if(J(D[BG])?(OG=D[BG][0],MG=D[BG][1]):(OG=null,MG=D[BG]),!(lG=C(MG._($I,JG),lG)).status)return lG;OG&&($l[OG]=lG.value),JG=lG.index}return C(H(JG,$l),lG)})},Z.string=Bl,Z.succeed=al,Z.takeWhile=function(u){return w(u),Z(function(A,x){for(var D=x;D<A.length&&u(z(A,D));)D++;return H(D,A.slice(x,D))})},Z.test=KI,Z.whitespace=Hb,Z["fantasy-land/empty"]=Vl,Z["fantasy-land/of"]=al,Z.Binary={bitSeq:h,bitSeqObj:function(u){V();var A={},x=0,D=N(function(II){if(J(II)){var P=II;if(P.length!==2)throw new Error("["+P.join(", ")+"] should be length 2, got length "+P.length);if(i(P[0]),r(P[1]),Object.prototype.hasOwnProperty.call(A,P[0]))throw new Error("duplicate key in bitSeqObj: "+P[0]);return A[P[0]]=!0,x++,P}return r(II),[null,II]},u);if(x<1)throw new Error("bitSeqObj expects at least one named pair, got ["+u.join(", ")+"]");var $=N(function(II){return II[0]},D);return h(N(function(II){return II[1]},D)).map(function(II){return m(function(P,hI){return hI[0]!==null&&(P[hI[0]]=hI[1]),P},{},N(function(P,hI){return[P,II[hI]]},$))})},byte:function(u){if(V(),r(u),u>255)throw new Error("Value specified to byte constructor ("+u+"=0x"+u.toString(16)+") is larger in value than a single byte.");var A=(u>15?"0x":"0x0")+u.toString(16);return Z(function(x,D){var $=z(x,D);return $===u?H(D+1,$):g(D,A)})},buffer:function(u){return n("buffer",u).map(function(A){return Buffer.from(A)})},encodedString:function(u,A){return n("string",A).map(function(x){return x.toString(u)})},uintBE:p,uint8BE:p(1),uint16BE:p(2),uint32BE:p(4),uintLE:e,uint8LE:e(1),uint16LE:e(2),uint32LE:e(4),intBE:Q,int8BE:Q(1),int16BE:Q(2),int32BE:Q(4),intLE:s,int8LE:s(1),int16LE:s(2),int32LE:s(4),floatBE:n("floatBE",4).map(function(u){return u.readFloatBE(0)}),floatLE:n("floatLE",4).map(function(u){return u.readFloatLE(0)}),doubleBE:n("doubleBE",8).map(function(u){return u.readDoubleBE(0)}),doubleLE:n("doubleLE",8).map(function(u){return u.readDoubleLE(0)})},G.exports=Z}])})})(ih,ih.exports);var y=ih.exports,Kt=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1
|
||
|
|
`)[0];let l=G.substring(2).trim();return y.makeSuccess(I+G.length,l)}),namedField:b=>y.alt(b.explicitNamedField,pA(gb.field).map(([I,G])=>Ah.named(eA(G),I))),sortField:b=>y.seqMap(gb.field.skip(y.optWhitespace),y.regexp(/ASCENDING|DESCENDING|ASC|DESC/i).atMost(1),(I,G)=>{let l=G.length==0?"ascending":G[0].toLowerCase();return l=="desc"&&(l="descending"),l=="asc"&&(l="ascending"),{field:I,direction:l}}),headerClause:b=>b.queryType.chain(I=>{switch(I){case"table":return F0(()=>({type:I,fields:[],showId:!0}),y.seqMap(y.regexp(/WITHOUT\s+ID/i).skip(y.optWhitespace).atMost(1),y.sepBy(b.namedField,y.string(",").trim(y.optWhitespace)),(G,l)=>({type:I,fields:l,showId:G.length==0})));case"list":return F0(()=>({type:I,format:void 0,showId:!0}),y.seqMap(y.regexp(/WITHOUT\s+ID/i).skip(y.optWhitespace).atMost(1),gb.field.atMost(1),(G,l)=>({type:I,format:l.length==1?l[0]:void 0,showId:G.length==0})));case"task":return y.succeed({type:I});case"calendar":return y.whitespace.then(y.seqMap(b.namedField,G=>({type:I,showId:!0,field:G})));default:return y.fail(`Unrecognized query type '${I}'`)}}).desc("TABLE or LIST or TASK or CALENDAR"),fromClause:b=>y.seqMap(y.regexp(/FROM/i),y.whitespace,gb.source,(I,G,l)=>l),whereClause:b=>y.seqMap(y.regexp(/WHERE/i),y.whitespace,gb.field,(I,G,l)=>({type:"where",clause:l})).desc("WHERE <expression>"),sortByClause:b=>y.seqMap(y.regexp(/SORT/i),y.whitespace,b.sortField.sepBy1(y.string(",").trim(y.optWhitespace)),(I,G,l)=>({type:"sort",fields:l})).desc("SORT field [ASC/DESC]"),limitClause:b=>y.seqMap(y.regexp(/LIMIT/i),y.whitespace,gb.field,(I,G,l)=>({type:"limit",amount:l})).desc("LIMIT <value>"),flattenClause:b=>y.seqMap(y.regexp(/FLATTEN/i).skip(y.whitespace),b.namedField,(I,G)=>({type:"flatten",field:G})).desc("FLATTEN <value> [AS <name>]"),groupByClause:b=>y.seqMap(y.regexp(/GROUP BY/i).skip(y.whitespace),b.namedField,(I,G)=>({type:"group",field:G})).desc("GROUP BY <value> [AS <name>]"),clause:b=>y.alt(b.fromClause,b.whereClause,b.sortByClause,b.limitClause,b.groupByClause,b.flattenClause),query:b=>y.seqMap(b.headerClause.trim(tt),b.fromClause.trim(tt).atMost(1),b.clause.trim(tt).many(),(I,G,l)=>({header:I,source:G.length==0?Gc.folder(""):G[0],operations:l,settings:jt}))}),tt=y.alt(y.whitespace,Fs.comment).many().map(b=>b.join("")),QA=b=>b?b.plugins.plugins.dataview?.api:window.DataviewAPI,HA=b=>b.plugins.enabledPlugins.has("dataview");lc.DATE_SHORTHANDS=Lt;lc.DURATION_TYPES=rt;lc.EXPRESSION=gb;lc.KEYWORDS=kt;lc.QUERY_LANGUAGE=Fs;lc.getAPI=QA;lc.isPluginEnabled=HA;lc.parseField=XA});var k3={};ol(k3,{default:()=>fI});module.exports=rE(k3);var JE=require("obsidian");var Zl=require("obsidian");function SI(){}function Vn(b){return b()}function ka(){return Object.create(null)}function uI(b){b.forEach(Vn)}function gI(b){return typeof b=="function"}function kI(b,I){return b!=b?I==I:b!==I||b&&typeof b=="object"||typeof b=="function"}function Zp(b){return Object.keys(b).length===0}function hn(b){return b??""}function tZ(b){return b&&gI(b.destroy)?b.destroy:SI}var pm=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;var za=class b{constructor(I){GI(this,"_listeners","WeakMap"in pm?new WeakMap:void 0);GI(this,"_observer");GI(this,"options");this.options=I}observe(I,G){return this._listeners.set(I,G),this._getObserver().observe(I,this.options),()=>{this._listeners.delete(I),this._observer.unobserve(I)}}_getObserver(){return this._observer??(this._observer=new ResizeObserver(I=>{for(let G of I)b.entries.set(G.target,G),this._listeners.get(G.target)?.(G)}))}};za.entries="WeakMap"in pm?new WeakMap:void 0;var Wp=!1;function dp(){Wp=!0}function mp(){Wp=!1}function F(b,I){b.appendChild(I)}function bG(b,I,G){let l=Np(b);if(!l.getElementById(I)){let c=v("style");c.id=I,c.textContent=G,zE(l,c)}}function Np(b){if(!b)return document;let I=b.getRootNode?b.getRootNode():b.ownerDocument;return I&&I.host?I:b.ownerDocument}function zE(b,I){return F(b.head||b,I),I.sheet}function cI(b,I,G){b.insertBefore(I,G||null)}function lI(b){b.parentNode&&b.parentNode.removeChild(b)}function Rc(b,I){for(let G=0;G<b.length;G+=1)
|
||
|
|
tags: ${JSON.stringify(Array.from(this._tags).sort())},
|
||
|
|
knownValues: ${JSON.stringify(this.knownValues)},
|
||
|
|
impliedValues: ${JSON.stringify(this.impliedValues)}},
|
||
|
|
reference: ${JSON.stringify(this.reference)}]`}dayjs(){return(0,Ln.default)(this.dateWithoutTimezoneAdjustment())}date(){let I=this.dateWithoutTimezoneAdjustment(),G=this.reference.getSystemTimezoneAdjustmentMinute(I,this.get("timezoneOffset"));return new Date(I.getTime()+G*6e4)}addTag(I){return this._tags.add(I),this}addTags(I){for(let G of I)this._tags.add(G);return this}tags(){return new Set(this._tags)}dateWithoutTimezoneAdjustment(){let I=new Date(this.get("year"),this.get("month")-1,this.get("day"),this.get("hour"),this.get("minute"),this.get("second"),this.get("millisecond"));return I.setFullYear(this.get("year")),I}static createRelativeFromReference(I,G){let l=$p(I.getDateWithAdjustedTimezone(),G),c=new b(I);return c.addTag("result/relativeDate"),G.hour||G.minute||G.second?(c.addTag("result/relativeDateAndTime"),qp(c,l),fp(c,l),c.assign("timezoneOffset",I.getTimezoneOffset())):(Pp(c,l),c.imply("timezoneOffset",I.getTimezoneOffset()),G.day?(c.assign("day",l.getDate()),c.assign("month",l.getMonth()+1),c.assign("year",l.getFullYear()),c.assign("weekday",l.getDay())):G.week?(c.assign("day",l.getDate()),c.assign("month",l.getMonth()+1),c.assign("year",l.getFullYear()),c.imply("weekday",l.getDay())):(c.imply("day",l.getDate()),G.month?(c.assign("month",l.getMonth()+1),c.assign("year",l.getFullYear())):(c.imply("month",l.getMonth()+1),G.year?c.assign("year",l.getFullYear()):c.imply("year",l.getFullYear())))),c}},BI=class b{constructor(I,G,l,c,Z){GI(this,"refDate");GI(this,"index");GI(this,"text");GI(this,"reference");GI(this,"start");GI(this,"end");this.reference=I,this.refDate=I.instant,this.index=G,this.text=l,this.start=c||new q(I),this.end=Z}clone(){let I=new b(this.reference,this.index,this.text);return I.start=this.start?this.start.clone():null,I.end=this.end?this.end.clone():null,I}date(){return this.start.date()}addTag(I){return this.start.addTag(I),this.end&&this.end.addTag(I),this}addTags(I){return this.start.addTags(I),this.end&&this.end.addTags(I),this}tags(){let I=new Set(this.start.tags());if(this.end)for(let G of this.end.tags())I.add(G);return I}toString(){let I=Array.from(this.tags()).sort();return`[ParsingResult {index: ${this.index}, text: '${this.text}', tags: ${JSON.stringify(I)} ...}]`}};function ul(b,I,G="\\s{0,5},?\\s{0,5}"){let l=I.replace(/\((?!\?)/g,"(?:");return`${b}${l}(?:${G}${l}){0,10}`}function cJ(b){let I;return b instanceof Array?I=[...b]:b instanceof Map?I=Array.from(b.keys()):I=Object.keys(b),I}function ZI(b){return`(?:${cJ(b).sort((G,l)=>l.length-G.length).join("|").replace(/\./g,"\\.")})`}var Ge=UI(MI(),1);function Cl(b){return b<100&&(b>50?b=b+1900:b=b+2e3),b}function TI(b,I,G){let l=(0,Ge.default)(b),c=l;c=c.month(G-1),c=c.date(I),c=c.year(l.year());let Z=c.add(1,"y"),W=c.add(-1,"y");return Math.abs(Z.diff(l))<Math.abs(c.diff(l))?c=Z:Math.abs(W.diff(l))<Math.abs(c.diff(l))&&(c=W),c.year()}var $a={sunday:0,sun:0,"sun.":0,monday:1,mon:1,"mon.":1,tuesday:2,tue:2,"tue.":2,wednesday:3,wed:3,"wed.":3,thursday:4,thurs:4,"thurs.":4,thur:4,"thur.":4,thu:4,"thu.":4,friday:5,fri:5,"fri.":5,saturday:6,sat:6,"sat.":6},xn={january:1,february:2,march:3,april:4,may:5,june:6,july:7,august:8,september:9,october:10,november:11,december:12},Ib={...xn,jan:1,"jan.":1,feb:2,"feb.":2,mar:3,"mar.":3,apr:4,"apr.":4,jun:6,"jun.":6,jul:7,"jul.":7,aug:8,"aug.":8,sep:9,"sep.":9,sept:9,"sept.":9,oct:10,"oct.":10,nov:11,"nov.":11,dec:12,"dec.":12},kn={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},zn={first:1,second:2,third:3,fourth:4,fifth:5,sixth:6,seventh:7,eighth:8,ninth:9,tenth:10,eleventh:11,twelfth:12,thirteenth:13,fourteenth:14,fifteenth:15,sixteenth:16,seventeenth:17,eighteenth:18,nineteenth:19,twentieth:20,"twenty first":21,"twenty-first":21,"twenty second":22,"twenty-second":22,"twenty third":23,"twenty-third":23,"twenty fourth":24,"twenty-fourth":24,"twenty fifth":25,"twenty-fifth":25,"twenty sixth":26,"twenty-sixth":26,"twenty seventh":27,"twenty-seventh":27,"twenty eighth":28,"twenty-eighth":28,"twenty ninth":29,"twenty-ninth":29,thirtieth:30
|
||
|
|
`,{line:W,ch:0}),c.setCursor({line:W,ch:b.length});else{let d=c.getLine(W);c.replaceRange(`
|
||
|
|
`+b,{line:W,ch:d.length}),c.setCursor({line:W+1,ch:b.length})}}catch{M.logError(`unable to insert '${b}' on new line ${I}.`)}}function AH(b,I){gH(b,"above",I)}function rH(b,I){gH(b,"below",I)}function eC(b,I,G="replaceSelection",l={}){let{requireActiveView:c=!0}=l,Z=b.workspace.getActiveViewOfType(mb.MarkdownView);if(!Z){let Y="Cannot append link because no active Markdown view is available.";if(c)throw new Error(Y);M.logMessage(Y);return}let W=Z.editor,d=W.listSelections().map(Y=>({anchor:{...Y.anchor},head:{...Y.head}}));if(G==="replaceSelection"){W.replaceSelection(I);return}let m=({line:Y,ch:a})=>W.posToOffset({line:Y,ch:a}),N=d.sort((Y,a)=>m(a.head)-m(Y.head));for(let Y of N){let a=m(Y.anchor)>m(Y.head)?Y.anchor:Y.head;switch(G){case"afterSelection":{W.replaceRange(I,a);break}case"endOfLine":{let V=W.getLine(a.line),h={line:a.line,ch:V.length};W.replaceRange(I,h);break}case"newLine":{let V=W.getLine(a.line),h={line:a.line,ch:V.length},X=V.length===0?"":`
|
||
|
|
`;W.replaceRange(X+I,h);break}}}}function QC(b){let I=/^\s*!?\[[^\]]*\]\((.+)\)\s*$/,G=b.match(I);if(!G)return null;let l=G[1].trim();return l?(l.startsWith("<")&&l.endsWith(">")&&(l=l.slice(1,-1).trim()),l):null}function HC(b){let I=b.trim();if(I.startsWith("![[")&&I.includes("]]"))return b;let G=b.indexOf("[["),l=b.indexOf("]]",G+2);if(G!==-1&&l!==-1)return(G>0?b.charAt(G-1):"")==="!"?b:`${b.slice(0,G)}!${b.slice(G)}`;let c=QC(b);return c?`![[${c}]]`:b.startsWith("!")?b:`!${b}`}function rV(b,I,G){if(!G?.enabled)return!1;let l=b.workspace.getActiveFile();if(!l&&G.requireActiveFile)throw new Error("Append link is enabled but there's no active file to insert into.");if(!b.workspace.getActiveViewOfType(mb.MarkdownView)){if(G.requireActiveFile)throw new Error("Cannot append link because no active Markdown view is available.");return!1}let Z=l?.path??"",W=b.fileManager.generateMarkdownLink(I,Z),m=G.linkType==="embed"&&Qc(G.placement)?HC(W):W;return eC(b,m,G.placement,{requireActiveView:!1}),!0}function uC(b,I){return b.commands.findCommand(I)}function LH(b,I){uC(b,I)&&(delete b.commands.commands[I],delete b.commands.editorCommands[I])}function rY(b){return b.vault.getAllLoadedFiles().filter(I=>I instanceof mb.TFolder).map(I=>I.path)}function LY(b){let I=b.split("::").map(G=>G.trim()).filter(Boolean);return{basename:I[0],memberAccess:I.slice(1)}}async function ad(b,I,G={}){let{location:l="tab",direction:c="vertical",mode:Z,focus:W=!0,eState:d}=G,m=typeof I=="string"?b.vault.getAbstractFileByPath(I):I;if(!m)throw new Error(`File not found: ${String(I)}`);let N;switch(l){case"reuse":N=b.workspace.getLeaf(!1);break;case"tab":N=b.workspace.getLeaf("tab");break;case"split":N=b.workspace.getLeaf("split",c);break;case"window":N=b.workspace.getLeaf("window");break;case"left-sidebar":N=b.workspace.getLeftLeaf(!0);break;case"right-sidebar":N=b.workspace.getRightLeaf(!0);break;default:N=b.workspace.getLeaf("tab")}if(!N)throw new Error("Could not obtain a workspace leaf.");if(await N.openFile(m),Z&&Z!=="default"&&!(typeof Z=="object"&&Z.mode==="default")){let Y=N.getViewState(),a={...Y.state??{}};Z==="preview"||typeof Z=="object"&&Z.mode==="preview"?(a.mode="preview",delete a.source):Z==="source"?(a.mode="source",a.source=!0):Z==="live"||Z==="live-preview"?(a.mode="source",a.source=!1):typeof Z=="object"&&Z.mode==="source"&&(a.mode="source",a.source=Z.source),await N.setViewState({...Y,state:{...a,...d}})}return W&&b.workspace.setActiveLeaf(N,{focus:!0}),N}function LV(b,I,G=!0){let l;return b.workspace.iterateRootLeaves(c=>{let Z=c.view;if(Z instanceof mb.FileView&&Z.file&&I.path===Z.file.path){l=c;return}}),l!==void 0?(G&&b.workspace.setActiveLeaf(l,{focus:!0}),l):null}async function uc(b,I){let G=I.vault.getAbstractFileByPath(b.path);if(!G){M.logError(`failed to load file ${b.path}.`);return}if(G instanceof mb.TFile){let l=a=>window.require&&window.require(a),c={},Z={exports:c},W=await I.vault.read(G);window.eval(`(function(require, module, exports) { ${W}
|
||
|
|
})`)(l,Z,c);let m=c.default||Z.exports;if(!m)return;let N=m,{memberAccess:Y}=LY(b.name);if(Y&&Y.length>0){let a;for(;a=Y.shift();)N=N[a]}return N}}function kH(b,I){let G=cG(b);for(let l of I)delete G[l];return G}function kV(b,I){let G=b.vault.getAbstractFileByPath(I);return!!G&&G instanceof mb.TFolder}function Pc(b,I){return b.vault.getMarkdownFiles().filter(G=>G.path.startsWith(I))}function sC(b){let I=b.frontmatter;if(!I)return[];let G=Object.entries(I);if(!G.length)return[];let l=G.filter(([Z,W])=>{let d=Z.toLowerCase();return d==="tags"||d==="tag"});return l?l.flatMap(([Z,W])=>{if(typeof W=="string")return W.split(/,|\s+/).map(d=>d.trim());if(Array.isArray(W))return W}).filter(Z=>!!Z):[]}function wC(b,I){let G=b.metadataCache.getFileCache(I);if(!G)return[];let l=[];return G.frontmatter&&l.push(...sC(G)),G.tags&&Array.isArray(G.tags)&&l.push(...G.tags.map(c=>c.tag.replace(/^\#/,""))),l}function zV(b,I){let G=I.replace(/^\#/,"");return b.vault.getMarkdownFiles().filter(l=>wC(b,l).includes(G))}function xV(b){let G=/^(\s*---\r?\n)([\s\S]*?)(\r?\n(?:---|\.\.\.)\s*(?:\r?\n|$))/.exec(b);return G?[0,G[0].length]:null}function zH(b,I,G,l){if(!(l!==null&&I>=l[0]&&I<=l[1]))return{isInYaml:!1,isQuoted:!1,lineStart:0,lineEnd:0,baseIndent:"",isKeyValuePosition:!1};let Z=b.lastIndexOf(`
|
||
|
|
`,I-1)+1,W=b.indexOf(`
|
||
|
|
`,I),d=W===-1?b.length:W,m=b.slice(Z,I),N=b.slice(G,d),Y=(m.match(/^\s*/)||[""])[0],a=b[I-1]==='"'&&b[G]==='"'||b[I-1]==="'"&&b[G]==="'",V=m.replace(/["']$/,""),h=N.replace(/^["']/,""),n=/:\s*$/.test(V)&&h.trim().length===0;return{isInYaml:!0,isQuoted:a,lineStart:Z,lineEnd:d,baseIndent:Y,isKeyValuePosition:n}}var xH={"[":"]","(":")","{":"}","<":">"};function vC(b,I=","){let G=[],l="",c=[],Z=null;for(let d=0;d<b.length;d++){let m=b[d];if(Z){if(l+=m,m===Z){let N=0;for(let Y=d-1;Y>=0&&b[Y]==="\\";Y--)N++;N%2===0&&(Z=null)}continue}if(m==='"'||m==="'"){Z=m,l+=m;continue}if(m in xH){c.push(xH[m]),l+=m;continue}if(c.length>0){let N=c[c.length-1];m===N&&c.pop(),l+=m;continue}if(m===I){let N=l.trim();N.length>0&&G.push(N),l="";continue}l+=m}let W=l.trim();return W.length>0&&G.push(W),G}function EC(b){return b.includes(`
|
||
|
|
`)?b.replace(/\r?\n/g,`
|
||
|
|
`):b.includes("\\n")?b.replace(/\\n/g,`
|
||
|
|
`):b}function JC(b,I){if(!b||!I)return null;let G=b.metadataCache,l=b.metadataTypeManager??G?.app?.metadataTypeManager;if(!l||typeof l.getTypeInfo!="function")return null;let c=l.getTypeInfo(I),Z=c?.expected?.type??c?.inferred?.type;return typeof Z=="string"?Z:null}function yC(b){if(!b)return!1;let I=b.toLowerCase();return I==="list"||I==="tags"||I==="multitext"}function UH(b,I){let G=b.trim();if(!G)return;let l=EC(G),c=I?.propertyType??JC(I?.app,I?.propertyKey),Z=yC(c),d=Z||c===null,N=l.split(/\n/).map(Y=>Y.trim()).filter(Y=>Y.length>0);if(d&&N.length>0&&N.every(Y=>/^-\s+/.test(Y)))return N.map(Y=>Y.replace(/^-[\s]*/,"").trim());if(l.startsWith("[")&&l.endsWith("]")||l.startsWith("{")&&l.endsWith("}")){if(c&&!Z&&c!=="list")return;try{return JSON.parse(l)}catch{}}if(l.includes(",")&&d){let Y=vC(l);if(Y.length>1)return Y}}var BH="\0",_c=class{constructor(I){this.app=I;this.map=new Map;this.propertyTypeCache=new Map}maybeCollect(I){let{input:G,matchStart:l,matchEnd:c,rawValue:Z,fallbackKey:W,featureEnabled:d}=I;if(!d)return;let m=xV(G),N=zH(G,l,c,m);if(!N.isInYaml)return;let Y=G.slice(N.lineStart,N.lineEnd),a=Y.trim(),V=Y.match(/^\s*([^:]+):/),h=V?V[1].trim():W,n=/^-\s*['"]?\{\{VALUE:[^}]+\}\}['"]?\s*$/i,X=null;if(N.isKeyValuePosition?X=[h]:n.test(a)&&(X=this.findListParentPath(G,N.lineStart,N.baseIndent??"")),!X||X.length===0)return;let p=X[X.length-1],e=Z;if(typeof Z=="string"){let R=UH(Z,this.buildParseOptions(p));R!==void 0&&(e=R)}if(!(typeof e!="string"&&(Array.isArray(e)||typeof e=="object"&&e!==null||typeof e=="number"||typeof e=="boolean"||e===null)))return;let s=X.join(BH);this.map.set(s,e)}drain(){let I=new Map(this.map);return this.map.clear(),I}buildParseOptions(I){return{propertyKey:I,propertyType:this.resolvePropertyType(I),app:this.app}}findListParentPath(I,G,l){let c=G-1,Z=[],W=l.length;for(;c>=0;){let d=I.lastIndexOf(`
|
||
|
|
`,c),m=d===-1?0:d+1,N=I.slice(m,c+1),Y=N.trim();if(Y.length===0){c=m-2;continue}if(Y==="---"||Y==="...")break;if(Y.startsWith("-")){c=m-2;continue}let a=N.match(/^(\s*)([^:\n]+):/);if(a){let h=(a[1]??"").length;if(h<W&&(Z.unshift(a[2].trim()),W=h,W===0))break}c=m-2}return Z.length>0?Z:null}resolvePropertyType(I){if(!this.app)return null;if(this.propertyTypeCache.has(I))return this.propertyTypeCache.get(I)??null;let G=this.app,l=G.metadataTypeManager??G.metadataCache?.app?.metadataTypeManager;if(!l||typeof l.getTypeInfo!="function")return this.propertyTypeCache.set(I,null),null;let c=l.getTypeInfo(I),Z=c?.expected?.type??c?.inferred?.type??null,W=typeof Z=="string"?Z:null;return this.propertyTypeCache.set(I,W),W}};_c.PATH_SEPARATOR=BH;var UV=class UV{constructor(I){this.app=I;this.variables=new Map;this.linkToCurrentFileBehavior="required";this.propertyCollector=new _c(I)}hasConcreteVariable(I){if(!this.variables.has(I))return!1;let G=this.variables.get(I);return G!=null}setTitle(I){this.hasConcreteVariable("title")||this.variables.set("title",I)}replacer(I,G,l){return I.replace(G,function(){return l})}replaceDateInString(I){let G=I;for(;Ta.test(G);){let l=Ta.exec(G),c;if(l&&l[1]){let Z=l[1].replace("+","").trim();un.test(Z)&&(c=parseInt(Z))}G=this.replacer(G,Ta,Hc({offset:c}))}for(;oW.test(G);){let l=oW.exec(G);if(!l)throw new Error(`Unable to parse date format. Invalid syntax in: "${G.substring(Math.max(0,G.search(oW)-10),Math.min(G.length,G.search(oW)+30))}..."`);let c=l[1],Z;if(l[2]){let W=l[2].replace("+","").trim();un.test(W)&&(Z=parseInt(W))}G=this.replacer(G,oW,Hc({format:c,offset:Z}))}return G}replaceTimeInString(I){let G=I;for(;CW.test(G);){if(!CW.exec(G))throw new Error(`Unable to parse time format. Invalid syntax in: "${G.substring(Math.max(0,G.search(CW)-10),Math.min(G.length,G.search(CW)+30))}..."`);G=this.replacer(G,CW,Hc({format:"HH:mm"}))}for(;iW.test(G);){let l=iW.exec(G);if(!l)throw new Error(`Unable to parse formatted time. Invalid syntax in: "${G.substring(Math.max(0,G.search(iW)-10),Math.min(G.length,G.search(iW)+30))}..."`);let c=l[1];G=this.replacer(G,iW,Hc({format:c}))}return G}async replaceValueInString(I){let G=I;if(!sn.test(G))return G;this.hasConcreteVariable("value")&&(this.value=String(this.variables.get("value"))),this.value===void 0&&(this.value=await this.promptForValue());let l=new RegExp(sn.source,"gi");return G=G.replace(l,()=>this.value),G}async replaceSelectedInString(I){let G=I,l=await this.getSelectedText();for(;vn.test(G);)G=this.replacer(G,vn,l);return G}async replaceClipboardInString(I){let G=I,l=await this.getClipboardContent();for(;En.test(G);)G=this.replacer(G,En,l);return G}async replaceLinkToCurrentFileInString(I){let G=this.getCurrentFileLink(),l=I;if(!G&&AW.test(l)){if(this.linkToCurrentFileBehavior==="required")throw new Error("Unable to get current file path. Make sure you have a file open in the editor.");for(M.logMessage("Skipping {{LINKCURRENT}} replacement because no active file is available.");AW.test(l);)l=this.replacer(l,AW,"");return l}else if(!G)return l;for(;AW.test(l);)l=this.replacer(l,AW,G);return l}async replaceCurrentFileNameInString(I){let G=this.getCurrentFileName(),l=I;if(!G&&rW.test(l)){if(this.linkToCurrentFileBehavior==="required")throw new Error("Unable to get current file name. Make sure you have a file open in the editor.");for(M.logMessage("Skipping {{FILENAMECURRENT}} replacement because no active file is available.");rW.test(l);)l=this.replacer(l,rW,"");return l}else if(!G)return l;for(;rW.test(l);)l=this.replacer(l,rW,G);return l}setLinkToCurrentFileBehavior(I){this.linkToCurrentFileBehavior=I}getAndClearTemplatePropertyVars(){return this.propertyCollector.drain()}async replaceVariableInString(I){let G=I,l=new RegExp(Sa.source,"gi"),c=this.isTemplatePropertyTypesEnabled(),Z;for(;(Z=l.exec(G))!==null;){if(!Z[1])throw new Error(`Unable to parse variable. Invalid syntax in: "${G.substring(Math.max(0,Z.index-10),Math.min(G.length,Z.index+30))}..."`);let W=Z[1],d="",m=W.indexOf("|");if(m!==-1&&(d=W.substring(m+1).trim(),W=W.substring(0,m).trim())
|
||
|
|
`,l++):Z=="\\"?(G+="\\",l++):G+="\\":G+=c}return G}replaceRandomInString(I){let G=I;for(;Jn.test(G);){let l=Jn.exec(G);if(!l||!l[1])continue;let c=parseInt(l[1]);if(c<=0||c>100)throw new Error(`Random string length must be between 1 and 100. Got: ${c}`);let Z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",W="";for(let d=0;d<c;d++)W+=Z.charAt(Math.floor(Math.random()*Z.length));G=G.replace(l[0],W)}return G}replaceTitleInString(I){let G=I,l=this.getVariableValue("title");for(;wn.test(G);)G=this.replacer(G,wn,l);return G}};UV.FIELD_VARIABLE_PREFIX="FIELD:";var Sb=UV;var oC={title:"My Document Title",name:"Document Name",project:"Project Alpha",category:"Notes",author:"Your Name",status:"Draft",priority:"High",tag:"important",type:"meeting",client:"Acme Corp"},CC={clipboard:"clipboard_content",date:"formatted_date",time:"current_time",random:"random_value",uuid:"unique_id"},iC=[{pattern:/date|time/i,example:"2024-01-15"},{pattern:/title|name/i,example:"Example Title"},{pattern:/tag/i,example:"important"},{pattern:/category|type/i,example:"Notes"},{pattern:/author|user/i,example:"Your Name"},{pattern:/project/i,example:"Project Alpha"},{pattern:/status/i,example:"In Progress"},{pattern:/priority/i,example:"High"},{pattern:/number|count|id/i,example:"001"}];function BV(b){let I=b.toLowerCase(),G=oC[I];return G||`${b}_example`}function OV(b){return CC[b.toLowerCase()]||`${b}_output`}function MV(b){for(let{pattern:I,example:G}of iC)if(I.test(b))return G;return`${b}_value`}function jV(b){return b.length>0?`${b[0]} (${b.length} options)`:"suggestion_list"}function KV(b){return b?.path?b.basename:"current_file"}function DV(b){return b?.basename||"current_filename"}var fb=class{static generate(I,G=new Date){let l=G.getFullYear(),c=(G.getMonth()+1).toString().padStart(2,"0"),Z=G.getDate().toString().padStart(2,"0"),W=G.getHours().toString().padStart(2,"0"),d=G.getMinutes().toString().padStart(2,"0"),m=G.getSeconds().toString().padStart(2,"0");return I.replace(/YYYY/g,l.toString()).replace(/YY/g,l.toString().slice(-2)).replace(/MMMM/g,this.MONTH_NAMES[G.getMonth()]).replace(/MMM/g,this.MONTH_NAMES_SHORT[G.getMonth()]).replace(/MM/g,c).replace(/M/g,(G.getMonth()+1).toString()).replace(/dddd/g,this.DAY_NAMES[G.getDay()]).replace(/ddd/g,this.DAY_NAMES_SHORT[G.getDay()]).replace(/DD/g,Z).replace(/D/g,G.getDate().toString()).replace(/HH/g,W).replace(/H/g,G.getHours().toString()).replace(/mm/g,d).replace(/m/g,G.getMinutes().toString()).replace(/ss/g,m).replace(/s/g,G.getSeconds().toString()).replace(/ww/g,this.getWeekNumber(G).toString().padStart(2,"0")).replace(/w/g,this.getWeekNumber(G).toString())}static getWeekNumber(I){let G=new Date(I.getFullYear(),0,1),l=(I.getTime()-G.getTime())/864e5;return Math.ceil((l+G.getDay()+1)/7)}};fb.MONTH_NAMES=["January","February","March","April","May","June","July","August","September","October","November","December"],fb.MONTH_NAMES_SHORT=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],fb.DAY_NAMES=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],fb.DAY_NAMES_SHORT=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];var Vd=class extends Sb{constructor(G,l,c){super(G);this.plugin=l;this.dateParser=c||vb}async format(G){let l=G;try{l=await this.replaceGlobalVarInString(l),l=await this.replaceMacrosInString(l),l=this.replaceDateInString(l),l=this.replaceTimeInString(l),l=await this.replaceValueInString(l),l=await this.replaceSelectedInString(l),l=await this.replaceClipboardInString(l),l=await this.replaceDateVariableInString(l),l=await this.replaceVariableInString(l),l=await this.replaceFieldVarInString(l),l=await this.replaceCurrentFileNameInString(l),l=this.replaceRandomInString(l)}catch{return G}return l}async replaceGlobalVarInString(G){let l=G,c=0,Z=new RegExp(Bc.source,"gi");for(;Z.test(l)&&!(++c>5);)l=l.replace(Z,(W,d)=>{let m=String(d??"").trim();if(!m)return W;let N=this.plugin?.settings?.globalVariables?.[m];return typeof N=="string"?N:""});return l}promptForValue(G){return G||"user input"}getVariableValue(G){return BV(G)}getCurrentFile
|
||
|
|
<div class="qa-suggestion-content">
|
||
|
|
<span class="suggestion-main-text">${d}</span>
|
||
|
|
${N}
|
||
|
|
</div>
|
||
|
|
<span class="suggestion-sub-text">${m}</span>
|
||
|
|
`,this.addHoverTooltip(l,c)}addHoverTooltip(G,l){let c,Z=()=>{clearTimeout(c),document.querySelector(".qa-file-tooltip")?.remove()};G.addEventListener("mouseenter",()=>{Z(),c=setTimeout(async()=>{let d=this.createTooltip(l);d&&(document.body.appendChild(d),this.positionTooltip(d,G))},200)}),G.addEventListener("mouseleave",Z),G.addEventListener("blur",Z);let W=()=>Z();document.addEventListener("scroll",W,{passive:!0}),G._tooltipCleanup=()=>{Z(),document.removeEventListener("scroll",W)}}createTooltip(G){let l=this.app.vault.getAbstractFileByPath(G.path);if(!l||!(l instanceof bt.TFile))return null;let c=document.createElement("div");return c.className="qa-file-tooltip",c.innerHTML=`
|
||
|
|
<div class="qa-tooltip-header">${l.basename}</div>
|
||
|
|
<div class="qa-tooltip-content">
|
||
|
|
<div>Path: ${l.path}</div>
|
||
|
|
<div>Modified: ${new Date(l.stat.mtime).toLocaleDateString()}</div>
|
||
|
|
</div>
|
||
|
|
`,c}positionTooltip(G,l){let c=l.getBoundingClientRect();G.style.position="fixed",G.style.left=`${c.right+10}px`,G.style.top=`${c.top}px`,G.style.zIndex="1000"}close(){document.querySelectorAll(".qaFileSuggestionItem").forEach(c=>{let Z=c;Z._tooltipCleanup&&Z._tooltipCleanup()}),document.querySelectorAll(".qa-file-tooltip").forEach(c=>c.remove()),super.close()}async selectSuggestion(G){if(this.inputEl.selectionStart===null)return;let l=this.inputEl.selectionStart,c=this.lastInput.length,Z=this.inputEl.value,W=0,d=this.inputEl.value.slice(l-this.lastInput.length-3,l-this.lastInput.length)==="![[";if(G.matchType==="unresolved")W=this.makeLinkManually(Z,G.displayText.replace(/.md$/,""),l,c);else if(G.matchType==="heading"||G.matchType==="block"){let m=G.displayText;W=this.makeLinkManually(Z,m,l,c)}else if(d)W=this.makeLinkManually(Z,G.displayText,l,c);else{let m=this.app.vault.getAbstractFileByPath(G.file.path);if(m instanceof bt.TFile){let N=G.matchType==="alias"?G.displayText:void 0;W=this.makeLinkObsidianMethod(m,Z,l,c,N)}else W=this.makeLinkManually(Z,G.displayText,l,c)}this.inputEl.trigger("input"),this.close(),this.inputEl.setSelectionRange(W,W)}makeLinkObsidianMethod(G,l,c,Z,W){let d=this.app.vault.getAbstractFileByPath(G.path),m=this.app.fileManager.generateMarkdownLink(d,this.getSourcePath(),"",W??"");return this.inputEl.value=this.getNewInputValueForFileLink(l,m,c,Z),c-Z+m.length+2}makeLinkManually(G,l,c,Z){return this.inputEl.value=this.getNewInputValueForFileName(G,l,c,Z),c-Z+l.length+2}getNewInputValueForFileLink(G,l,c,Z){return`${G.substr(0,c-Z-2)}${l}${G.substr(c)}`}getNewInputValueForFileName(G,l,c,Z){return`${G.substr(0,c-Z)}${l}]]${G.substr(c)}`}};var Qd=class extends $G{constructor(G,l){super(G,l);this.app=G;this.inputEl=l;this.lastInput="";this.lastInputStart=0;this.lastInputLength=0;this.refreshTagIndex(),fI.instance.registerEvent(this.app.metadataCache.on("resolved",()=>this.refreshTagIndex()))}refreshTagIndex(){let G=this.app.metadataCache.getTags(),l=Object.keys(G);this.tagSet=new Set(l),this.sortedTags=l.sort((c,Z)=>c.length!==Z.length?c.length-Z.length:c.localeCompare(Z)),this.fuse=new rl(this.sortedTags,{threshold:.4,includeScore:!0,keys:[""]})}getSuggestions(G){if(this.inputEl.selectionStart===null)return[];let l=this.inputEl.selectionStart,c=G.slice(0,l),Z=yp.exec(c);if(!Z)return[];let W=c.lastIndexOf("[[");if(Z.index===void 0)return[];if(W!==-1&&W<Z.index)return[];let d=Z[1];this.lastInput=d,this.lastInputStart=Z.index,this.lastInputLength=Z[0].length;let m=this.sortedTags.filter(V=>V.toLowerCase().startsWith(d.toLowerCase())).slice(0,5),N=this.fuse.search(d).filter(V=>V.score!==void 0&&V.score<.8).map(V=>V.item).slice(0,10),Y=new Set(m),a=[...m];for(let V of N)!Y.has(V)&&a.length<15&&(a.push(V),Y.add(V));return a}renderSuggestion(G,l){this.renderMatch(l,G,this.lastInput)}selectSuggestion(G){let l=this.inputEl;if(l.selectionStart===null)return;let c=this.lastInputStart,Z=c+this.lastInputLength,W=G.startsWith("#")?G:`#${G}`;Ih(l,c,Z,W,{fromCompletion:!0}),this.close()}};var hG=class b extends Hd.Modal{constructor(G,l,c,Z,W){super(G);this.header=l;this.linkSourcePath=W;this.didSubmit=!1;this.submitClickCallback=G=>this.submit();this.cancelClickCallback=G=>this.cancel();this.submitEnterCallback=G=>{!G.isComposing&&G.key==="Enter"&&(G.preventDefault(),this.submit())};this.placeholder=c??"",this.input=Z??"",this.waitForClose=new Promise((d,m)=>{this.resolvePromise=d,this.rejectPromise=m}),this.display(),this.open(),this.fileSuggester=new ed(G,this.inputComponent.inputEl,{sourcePath:this.linkSourcePath}),this.tagSuggester=new Qd(G,this.inputComponent.inputEl)}static Prompt(G,l,c,Z){return new b(G,l,c,Z,void 0).waitForClose}static PromptWithContext(G,l,c,Z,W){return new b(G,l,c,Z,W).waitForClose}display(){this.containerEl.addClass("quickAddModal","qaInputPrompt"),this.contentEl.empty(),this.titleEl.textContent=this.header;let G=this.contentEl.createDiv();this.inputComponent=this.createInputField(G,this.placeholder,this.input),this.createButtonBar(G)}createInputField(G,l,c){let Z=new Hd.TextComponen
|
||
|
|
`).filter(Boolean).reduce((l,c)=>{let[Z,W,...d]=c.split(" "),m=Number.parseInt(W,10);return d.forEach((N,Y)=>l[N]=m+Y),l},{});for(let[l,c]of Object.entries(G)){let Z=yu.default.toByteArray(l);this.rankMap.set(Z.join(","),c),this.textMap.set(c,Z)}this.specialTokens={...b.special_tokens,...I},this.inverseSpecialTokens=Object.entries(this.specialTokens).reduce((l,[c,Z])=>(l[Z]=this.textEncoder.encode(c),l),{})}encode(b,I=[],G="all"){let l=new RegExp(this.patStr,"ug"),c=Zt.specialTokenRegex(Object.keys(this.specialTokens)),Z=[],W=new Set(I==="all"?Object.keys(this.specialTokens):I),d=new Set(G==="all"?Object.keys(this.specialTokens).filter(N=>!W.has(N)):G);if(d.size>0){let N=Zt.specialTokenRegex([...d]),Y=b.match(N);if(Y!=null)throw new Error(`The text contains a special token that is not allowed: ${Y[0]}`)}let m=0;for(;;){let N=null,Y=m;for(;c.lastIndex=Y,N=c.exec(b),!(N==null||W.has(N[0]));)Y=N.index+1;let a=N?.index??b.length;for(let h of b.substring(m,a).matchAll(l)){let n=this.textEncoder.encode(h[0]),X=this.rankMap.get(n.join(","));if(X!=null){Z.push(X);continue}Z.push(...ci(n,this.rankMap))}if(N==null)break;let V=this.specialTokens[N[0]];Z.push(V),m=N.index+N[0].length}return Z}decode(b){let I=[],G=0;for(let Z=0;Z<b.length;++Z){let W=b[Z],d=this.textMap.get(W)??this.inverseSpecialTokens[W];d!=null&&(I.push(d),G+=d.length)}let l=new Uint8Array(G),c=0;for(let Z of I)l.set(Z,c),c+=Z.length;return this.textDecoder.decode(l)}},Jc=Zt;li(Jc,"specialTokenRegex",b=>new RegExp(b.map(I=>Zi(I)).join("|"),"g"));function Wt(b){switch(b){case"gpt2":return"gpt2";case"code-cushman-001":case"code-cushman-002":case"code-davinci-001":case"code-davinci-002":case"cushman-codex":case"davinci-codex":case"davinci-002":case"text-davinci-002":case"text-davinci-003":return"p50k_base";case"code-davinci-edit-001":case"text-davinci-edit-001":return"p50k_edit";case"ada":case"babbage":case"babbage-002":case"code-search-ada-code-001":case"code-search-babbage-code-001":case"curie":case"davinci":case"text-ada-001":case"text-babbage-001":case"text-curie-001":case"text-davinci-001":case"text-search-ada-doc-001":case"text-search-babbage-doc-001":case"text-search-curie-doc-001":case"text-search-davinci-doc-001":case"text-similarity-ada-001":case"text-similarity-babbage-001":case"text-similarity-curie-001":case"text-similarity-davinci-001":return"r50k_base";case"gpt-3.5-turbo-instruct-0914":case"gpt-3.5-turbo-instruct":case"gpt-3.5-turbo-16k-0613":case"gpt-3.5-turbo-16k":case"gpt-3.5-turbo-0613":case"gpt-3.5-turbo-0301":case"gpt-3.5-turbo":case"gpt-4-32k-0613":case"gpt-4-32k-0314":case"gpt-4-32k":case"gpt-4-0613":case"gpt-4-0314":case"gpt-4":case"gpt-3.5-turbo-1106":case"gpt-35-turbo":case"gpt-4-1106-preview":case"gpt-4-vision-preview":case"gpt-3.5-turbo-0125":case"gpt-4-turbo":case"gpt-4-turbo-2024-04-09":case"gpt-4-turbo-preview":case"gpt-4-0125-preview":case"text-embedding-ada-002":case"text-embedding-3-small":case"text-embedding-3-large":return"cl100k_base";case"gpt-4o":case"gpt-4o-2024-05-13":case"gpt-4o-2024-08-06":case"gpt-4o-2024-11-20":case"gpt-4o-mini-2024-07-18":case"gpt-4o-mini":case"gpt-4o-search-preview":case"gpt-4o-search-preview-2025-03-11":case"gpt-4o-mini-search-preview":case"gpt-4o-mini-search-preview-2025-03-11":case"gpt-4o-audio-preview":case"gpt-4o-audio-preview-2024-12-17":case"gpt-4o-audio-preview-2024-10-01":case"gpt-4o-mini-audio-preview":case"gpt-4o-mini-audio-preview-2024-12-17":case"o1":case"o1-2024-12-17":case"o1-mini":case"o1-mini-2024-09-12":case"o1-preview":case"o1-preview-2024-09-12":case"o1-pro":case"o1-pro-2025-03-19":case"o3":case"o3-2025-04-16":case"o3-mini":case"o3-mini-2025-01-31":case"o4-mini":case"o4-mini-2025-04-16":case"chatgpt-4o-latest":case"gpt-4o-realtime":case"gpt-4o-realtime-preview-2024-10-01":case"gpt-4o-realtime-preview-2024-12-17":case"gpt-4o-mini-realtime-preview":case"gpt-4o-mini-realtime-preview-2024-12-17":case"gpt-4.1":case"gpt-4.1-2025-04-14":case"gpt-4.1-mini":case"gpt-4.1-mini-2025-04-14":case"gpt-4.1-nano":case"gpt-4.1-nano-2025-04-14":case"gpt-4.5-preview":case"gpt-4.5-preview-2025-02-27":retur
|
||
|
|
! 50257 ICA= ICAg ICAgIA== ICAgICA= ICAgICAg ICAgICAgIA== ICAgICAgICA= ICAgICAgICAg ICAgICAgICAgIA== ICAgICAgICAgICA= ICAgICAgICAgICAg ICAgICAgICAgICAgIA== ICAgICAgICAgICAgICA= ICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgIA== ICAgICAgICAgICAgICAgICA= ICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgIA== ICAgICAgICAgICAgICAgICAgICA= ICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgIA== ICAgICAgICAgICAgICAgICAgICAgICA= ICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgIA==`},mi={pat_str:"'s|'t|'re|'ve|'m|'ll|'d| ?\\p{L}+| ?\\p{N}+| ?[^\\s\\p{L}\\p{N}]+|\\s+(?!\\S)|\\s+",special_tokens:{"<|endoftext|>":50256,"<|fim_prefix|>":50281,"<|fim_middle|>":50282,"<|fim_suffix|>":50283},bpe_ranks:`! 0 IQ== Ig== Iw== JA== JQ== Jg== Jw== KA== KQ== Kg== Kw== LA== LQ== Lg== Lw== MA== MQ== Mg== Mw== NA== NQ== Ng== Nw== OA== OQ== Og== Ow== PA== PQ== Pg== Pw== QA== QQ== Qg== Qw== RA== RQ== Rg== Rw== SA== SQ== Sg== Sw== TA== TQ== Tg== Tw== UA== UQ== Ug== Uw== VA== VQ== Vg== Vw== WA== WQ== Wg== Ww== XA== XQ== Xg== Xw== YA== YQ== Yg== Yw== ZA== ZQ== Zg== Zw== aA== aQ== ag== aw== bA== bQ== bg== bw== cA== cQ== cg== cw== dA== dQ== dg== dw== eA== eQ== eg== ew== fA== fQ== fg== oQ== og== ow== pA== pQ== pg== pw== qA== qQ== qg== qw== rA== rg== rw== sA== sQ== sg== sw== tA== tQ== tg== tw== uA== uQ== ug== uw== vA== vQ== vg== vw== wA== wQ== wg== ww== xA== xQ== xg== xw== yA== yQ== yg== yw== zA== zQ== zg== zw== 0A== 0Q== 0g== 0w== 1A== 1Q== 1g== 1w== 2A== 2Q== 2g== 2w== 3A== 3Q== 3g== 3w== 4A== 4Q== 4g== 4w== 5A== 5Q== 5g== 5w== 6A== 6Q== 6g== 6w== 7A== 7Q== 7g== 7w== 8A== 8Q== 8g== 8w== 9A== 9Q== 9g== 9w== +A== +Q== +g== +w== /A== /Q== /g== /w== AA== AQ== Ag== Aw== BA== BQ== Bg== Bw== CA== CQ== Cg== Cw== DA== DQ== Dg== Dw== EA== EQ== Eg== Ew== FA== FQ== Fg== Fw== GA== GQ== Gg== Gw== HA== HQ== Hg== Hw== IA== fw== gA== gQ== gg== gw== hA== hQ== hg== hw== iA== iQ== ig== iw== jA== jQ== jg== jw== kA== kQ== kg== kw== lA== lQ== lg== lw== mA== mQ== mg== mw== nA== nQ== ng== nw== oA== rQ== IHQ= IGE= aGU= aW4= cmU= b24= IHRoZQ== ZXI= IHM= YXQ= IHc= IG8= ZW4= IGM= aXQ= aXM= YW4= b3I= ZXM= IGI= ZWQ= IGY= aW5n IHA= b3U= IGFu YWw= YXI= IHRv IG0= IG9m IGlu IGQ= IGg= IGFuZA== aWM= YXM= bGU= IHRo aW9u b20= bGw= ZW50 IG4= IGw= c3Q= IHJl dmU= IGU= cm8= bHk= IGJl IGc= IFQ= Y3Q= IFM= aWQ= b3Q= IEk= dXQ= ZXQ= IEE= IGlz IG9u aW0= YW0= b3c= YXk= YWQ= c2U= IHRoYXQ= IEM= aWc= IGZvcg== YWM= IHk= dmVy dXI= IHU= bGQ= IHN0 IE0= J3M= IGhl IGl0 YXRpb24= aXRo aXI= Y2U= IHlvdQ== aWw= IEI= IHdo b2w= IFA= IHdpdGg= IDE= dGVy Y2g= IGFz IHdl ICg= bmQ= aWxs IEQ= aWY= IDI= YWc= ZXJz a2U= ICI= IEg= ZW0= IGNvbg== IFc= IFI= aGVy IHdhcw== IHI= b2Q= IEY= dWw= YXRl IGF0 cmk= cHA= b3Jl IFRoZQ== IHNl dXM= IHBybw== IGhh dW0= IGFyZQ== IGRl YWlu YW5k IG9y aWdo ZXN0 aXN0 YWI= cm9t IE4= dGg= IGNvbQ== IEc= dW4= b3A= MDA= IEw= IG5vdA== ZXNz IGV4 IHY= cmVz IEU= ZXc= aXR5 YW50 IGJ5 ZWw= b3M= b3J0 b2M= cXU= IGZyb20= IGhhdmU= IHN1 aXZl b3VsZA== IHNo IHRoaXM= bnQ= cmE= cGU= aWdodA== YXJ0 bWVudA== IGFs dXN0 ZW5k LS0= YWxs IE8= YWNr IGNo IGxl aWVz cmVk YXJk 4oA= b3V0 IEo= IGFi ZWFy aXY= YWxseQ== b3Vy b3N0 Z2g= cHQ= IHBs YXN0 IGNhbg== YWs= b21l dWQ= VGhl IGhpcw== IGRv IGdv IGhhcw== Z2U= J3Q= IFU= cm91 IHNh IGo= IGJ1dA== IHdvcg== IGFsbA== ZWN0 IGs= YW1l IHdpbGw= b2s= IHdoZQ== IHRoZXk= aWRl MDE= ZmY= aWNo cGw= dGhlcg== IHRy Li4= IGludA== aWU= dXJl YWdl IG5l aWFs YXA= aW5l aWNl IG1l IG91dA== YW5z b25l b25n aW9ucw== IHdobw== IEs= IHVw IHRoZWly IGFk IDM= IHVz YXRlZA== b3Vz IG1vcmU= dWU= b2c= IFN0 aW5k aWtl IHNv aW1l cGVy LiI= YmVy aXo= YWN0 IG9uZQ== IHNhaWQ= IC0= YXJl IHlvdXI= Y2M= IFRo IGNs ZXA= YWtl YWJsZQ== aXA= IGNvbnQ= IHdoaWNo aWE= IGlt IGFib3V0 IHdlcmU= dmVyeQ== dWI= IGhhZA== IGVu IGNvbXA= LCI= IElu IHVu IGFn aXJl YWNl YXU= YXJ5 IHdvdWxk YXNz cnk= IOKA Y2w= b29r ZXJl c28= IFY= aWdu aWI= IG9mZg== IHRl dmVu IFk= aWxl b3Nl aXRl b3Jt IDIwMQ== IHJlcw== IG1hbg== IHBlcg== IG90aGVy b3Jk dWx0 IGJlZW4= IGxpa2U= YXNl YW5jZQ== a3M= YXlz b3du ZW5jZQ== IGRpcw== Y3Rpb24= IGFueQ== IGFwcA== IHNw aW50 cmVzcw== YXRpb25z YWls IDQ= aWNhbA== IHRoZW0= IGhlcg== b3VudA== IENo IGFy IGlm IHRoZXJl IHBl IHllYXI= YXY= IG15 IHNv
|
||
|
|
! 50257 ICA= ICAg ICAgIA== ICAgICA= ICAgICAg ICAgICAgIA== ICAgICAgICA= ICAgICAgICAg ICAgICAgICAgIA== ICAgICAgICAgICA= ICAgICAgICAgICAg ICAgICAgICAgICAgIA== ICAgICAgICAgICAgICA= ICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgIA== ICAgICAgICAgICAgICAgICA= ICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgIA== ICAgICAgICAgICAgICAgICAgICA= ICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgIA== ICAgICAgICAgICAgICAgICAgICAgICA= ICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgIA==`},Ni={explicit_n_vocab:50257,pat_str:"'s|'t|'re|'ve|'m|'ll|'d| ?\\p{L}+| ?\\p{N}+| ?[^\\s\\p{L}\\p{N}]+|\\s+(?!\\S)|\\s+",special_tokens:{"<|endoftext|>":50256},bpe_ranks:"! 0 IQ== Ig== Iw== JA== JQ== Jg== Jw== KA== KQ== Kg== Kw== LA== LQ== Lg== Lw== MA== MQ== Mg== Mw== NA== NQ== Ng== Nw== OA== OQ== Og== Ow== PA== PQ== Pg== Pw== QA== QQ== Qg== Qw== RA== RQ== Rg== Rw== SA== SQ== Sg== Sw== TA== TQ== Tg== Tw== UA== UQ== Ug== Uw== VA== VQ== Vg== Vw== WA== WQ== Wg== Ww== XA== XQ== Xg== Xw== YA== YQ== Yg== Yw== ZA== ZQ== Zg== Zw== aA== aQ== ag== aw== bA== bQ== bg== bw== cA== cQ== cg== cw== dA== dQ== dg== dw== eA== eQ== eg== ew== fA== fQ== fg== oQ== og== ow== pA== pQ== pg== pw== qA== qQ== qg== qw== rA== rg== rw== sA== sQ== sg== sw== tA== tQ== tg== tw== uA== uQ== ug== uw== vA== vQ== vg== vw== wA== wQ== wg== ww== xA== xQ== xg== xw== yA== yQ== yg== yw== zA== zQ== zg== zw== 0A== 0Q== 0g== 0w== 1A== 1Q== 1g== 1w== 2A== 2Q== 2g== 2w== 3A== 3Q== 3g== 3w== 4A== 4Q== 4g== 4w== 5A== 5Q== 5g== 5w== 6A== 6Q== 6g== 6w== 7A== 7Q== 7g== 7w== 8A== 8Q== 8g== 8w== 9A== 9Q== 9g== 9w== +A== +Q== +g== +w== /A== /Q== /g== /w== AA== AQ== Ag== Aw== BA== BQ== Bg== Bw== CA== CQ== Cg== Cw== DA== DQ== Dg== Dw== EA== EQ== Eg== Ew== FA== FQ== Fg== Fw== GA== GQ== Gg== Gw== HA== HQ== Hg== Hw== IA== fw== gA== gQ== gg== gw== hA== hQ== hg== hw== iA== iQ== ig== iw== jA== jQ== jg== jw== kA== kQ== kg== kw== lA== lQ== lg== lw== mA== mQ== mg== mw== nA== nQ== ng== nw== oA== rQ== IHQ= IGE= aGU= aW4= cmU= b24= IHRoZQ== ZXI= IHM= YXQ= IHc= IG8= ZW4= IGM= aXQ= aXM= YW4= b3I= ZXM= IGI= ZWQ= IGY= aW5n IHA= b3U= IGFu YWw= YXI= IHRv IG0= IG9m IGlu IGQ= IGg= IGFuZA== aWM= YXM= bGU= IHRo aW9u b20= bGw= ZW50 IG4= IGw= c3Q= IHJl dmU= IGU= cm8= bHk= IGJl IGc= IFQ= Y3Q= IFM= aWQ= b3Q= IEk= dXQ= ZXQ= IEE= IGlz IG9u aW0= YW0= b3c= YXk= YWQ= c2U= IHRoYXQ= IEM= aWc= IGZvcg== YWM= IHk= dmVy dXI= IHU= bGQ= IHN0 IE0= J3M= IGhl IGl0 YXRpb24= aXRo aXI= Y2U= IHlvdQ== aWw= IEI= IHdo b2w= IFA= IHdpdGg= IDE= dGVy Y2g= IGFz IHdl ICg= bmQ= aWxs IEQ= aWY= IDI= YWc= ZXJz a2U= ICI= IEg= ZW0= IGNvbg== IFc= IFI= aGVy IHdhcw== IHI= b2Q= IEY= dWw= YXRl IGF0 cmk= cHA= b3Jl IFRoZQ== IHNl dXM= IHBybw== IGhh dW0= IGFyZQ== IGRl YWlu YW5k IG9y aWdo ZXN0 aXN0 YWI= cm9t IE4= dGg= IGNvbQ== IEc= dW4= b3A= MDA= IEw= IG5vdA== ZXNz IGV4 IHY= cmVz IEU= ZXc= aXR5 YW50 IGJ5 ZWw= b3M= b3J0 b2M= cXU= IGZyb20= IGhhdmU= IHN1 aXZl b3VsZA== IHNo IHRoaXM= bnQ= cmE= cGU= aWdodA== YXJ0 bWVudA== IGFs dXN0 ZW5k LS0= YWxs IE8= YWNr IGNo IGxl aWVz cmVk YXJk 4oA= b3V0 IEo= IGFi ZWFy aXY= YWxseQ== b3Vy b3N0 Z2g= cHQ= IHBs YXN0 IGNhbg== YWs= b21l dWQ= VGhl IGhpcw== IGRv IGdv IGhhcw== Z2U= J3Q= IFU= cm91 IHNh IGo= IGJ1dA== IHdvcg== IGFsbA== ZWN0 IGs= YW1l IHdpbGw= b2s= IHdoZQ== IHRoZXk= aWRl MDE= ZmY= aWNo cGw= dGhlcg== IHRy Li4= IGludA== aWU= dXJl YWdl IG5l aWFs YXA= aW5l aWNl IG1l IG91dA== YW5z b25l b25n aW9ucw== IHdobw== IEs= IHVw IHRoZWly IGFk IDM= IHVz YXRlZA== b3Vz IG1vcmU= dWU= b2c= IFN0 aW5k aWtl IHNv aW1l cGVy LiI= YmVy aXo= YWN0 IG9uZQ== IHNhaWQ= IC0= YXJl IHlvdXI= Y2M= IFRo IGNs ZXA= YWtl YWJsZQ== aXA= IGNvbnQ= IHdoaWNo aWE= IGlt IGFib3V0 IHdlcmU= dmVyeQ== dWI= IGhhZA== IGVu IGNvbXA= LCI= IElu IHVu IGFn aXJl YWNl YXU= YXJ5 IHdvdWxk YXNz cnk= IOKA Y2w= b29r ZXJl c28= IFY= aWdu aWI= IG9mZg== IHRl dmVu IFk= aWxl b3Nl aXRl b3Jt IDIwMQ== IHJlcw== IG1hbg== IHBlcg== IG90aGVy b3Jk dWx0 IGJlZW4= IGxpa2U= YXNl YW5jZQ== a3M= YXlz b3du ZW5jZQ== IGRpcw== Y3Rpb24= IGFueQ== IGFwcA== IHNw aW50 cmVzcw== YXRpb25z YWls IDQ= aWNhbA== IHRoZW0= IGhlcg== b3VudA== IENo IGFy IGlm IHRoZXJl IHBl IHllYXI= YXY= IG15 IHNvbWU= IHdoZW4= b3VnaA== YWNo IHRoYW4= cnU= b25k
|
||
|
|
|
||
|
|
${I}`:""}`;function Rh(b){if(b){let I=new ru.Notice(Au("starting",""),1e6);return{setMessage:(G,l)=>{I.setMessage(Au(G,l))},hide:()=>I.hide()}}return{setMessage:(I,G)=>{M.logMessage(`(${I}) ${G}`)},hide:()=>{}}}var Tl=(b,I)=>{let G=I.name==="gpt-3.5-turbo-16k"?"gpt-3.5-turbo":I.name;G=G==="gpt-4-1106-preview"?"gpt-4":G,G=G==="gpt-3.5-turbo-1106"?"gpt-3.5-turbo":G;try{return ou(G).encode(b).length}catch{return dt("cl100k_base").encode(b).length}};async function Xi(b,I,G){if(typeof b!="function")throw new TypeError("Callback must be a function.");if(!(I instanceof Promise))throw new TypeError("Promise must be an instance of Promise.");if(typeof G!="number"||G<=0)throw new TypeError("Interval must be a positive number.");let l=!1;for(I.finally(()=>{l=!0});!l;)b(),await sleep(G)}async function pi(b,I,G){let l;if(I.enable)l=G.find(d=>d.path.endsWith(I.name));else{let d=G.map(m=>m.basename);l=await Fl.Suggest(b,d,G)}Dl(l,"Prompt template does not exist");let c=l.path,Z=b.vault.getAbstractFileByPath(c);Dl(Z instanceof Lu.TFile,`${c} is not a file`);let W=await b.vault.cachedRead(Z);return[l.basename,W]}async function ku(b,I,G){if(dI.getState().disableOnlineFeatures)throw new Error("Blocking request to OpenAI: Online features are disabled in settings.");let l=Rh(I.showAssistantMessages);try{let{apiKey:c,model:Z,outputVariableName:W,promptTemplate:d,systemPrompt:m,promptTemplateFolder:N}=I,Y=Pc(b,N),[a,V]=await pi(b,d,Y);l.setMessage("waiting","QuickAdd is formatting the prompt template.");let h=await G(V),n=["prompting",`Using prompt template "${a}".`];l.setMessage(n[0],n[1]);let p=nh(b,c,Z,m,I.modelOptions)(h),Q=(await Nt(p,100,J=>{l.setMessage(n[0],`${n[1]} (${(J/1e3).toFixed(2)}s)`)},J=>{l.setMessage("finished",`Took ${(J/1e3).toFixed(2)}s.`)})).content,s=("> "+Q).replace(/\n/g,`
|
||
|
|
> `),R={[W]:Q,[`${W}-quoted`]:s};return setTimeout(()=>l.hide(),5e3),R}catch(c){throw l.setMessage("dead",c.message),setTimeout(()=>l.hide(),5e3),XG(c)?new qI("Input cancelled by user"):c}}async function Nt(b,I,G,l){let c=Date.now();return await Xi(()=>G(Date.now()-c),b,I),l(Date.now()-c),await b}async function zu(b,I,G){if(dI.getState().disableOnlineFeatures)throw new Error("Blocking request to OpenAI: Online features are disabled in settings.");let l=Rh(I.showAssistantMessages);try{let{apiKey:c,model:Z,outputVariableName:W,systemPrompt:d,prompt:m,modelOptions:N}=I;l.setMessage("waiting","QuickAdd is formatting the prompt template.");let Y=await G(m),a=["prompting","Using custom prompt."];l.setMessage(a[0],a[1]);let h=nh(b,c,Z,d,N)(Y),X=(await Nt(h,100,Q=>{l.setMessage(a[0],`${a[1]} (${(Q/1e3).toFixed(2)}s)`)},Q=>{l.setMessage("finished",`Took ${(Q/1e3).toFixed(2)}s.`)})).content,p=("> "+X).replace(/\n/g,`
|
||
|
|
> `),e={[W]:X,[`${W}-quoted`]:p};return setTimeout(()=>l.hide(),5e3),e}catch(c){throw l.setMessage("dead",c.message),setTimeout(()=>l.hide(),5e3),c}}var mt=class{constructor(I,G){this.maxRequests=I;this.intervalMs=G;this.queue=[];this.pendingPromises=[]}add(I){return new Promise((G,l)=>{this.queue.push(async()=>{try{G(await I())}catch(c){l(c)}}),this.schedule()})}schedule(){if(this.queue.length===0||this.pendingPromises.length>=this.maxRequests)return;let I=this.queue.shift();if(!I)return;let G=I();this.pendingPromises.push(G),G.finally(()=>{this.pendingPromises=this.pendingPromises.filter(l=>l!==G),this.schedule()}),setTimeout(()=>this.schedule(),this.intervalMs)}};async function xu(b,I,G){if(dI.getState().disableOnlineFeatures)throw new Error("Blocking request to OpenAI: Online features are disabled in settings.");let l=Rh(I.showAssistantMessages);try{let{apiKey:c,model:Z,outputVariableName:W,systemPrompt:d,promptTemplate:m,text:N,modelOptions:Y}=I;l.setMessage("chunking","Creating prompt chunks with text and prompt template");let a=I.chunkSeparator||/\n/g,V=N.split(a),h=Tl(d,Z),n=await G(m,{chunk:" "}),X=Tl(n,Z),p=gu(Z.name)/2-h,e=I.shouldMerge??!0,Q=[],s=p-X;if(e){let z=[],r="",w=0;for(let i of V){let o=Tl(i,Z)+1;if(o>s)throw new Error(`The chunk "${i.slice(0,25)}..." is too large to fit in a single prompt.`);w+o<s?(r+=i,w+=o):(z.push(r),r=i,w=o)}r!==""&&z.push(r);for(let i of z){let o=await G(m,{chunk:i});Q.push(o)}}else for(let z of V){let r=Tl(z,Z);if(r>p)throw new Error(`Chunk size (${r}) is larger than the maximum chunk size (${p}). Please check your chunk separator.`);let w=await G(m,{chunk:z});Q.push(w)}let R=nh(b,c,Z,d,Y),J=["prompting",`${Q.length} prompts being sent.`];l.setMessage(J[0],J[1]);let E=new mt(5,1e3*30),H=Promise.all(Q.map(z=>E.add(()=>R(z)))),k=(await Nt(H,100,z=>{l.setMessage(J[0],`${J[1]} (${(z/1e3).toFixed(2)}s)`)},z=>{l.setMessage("finished",`Took ${(z/1e3).toFixed(2)}s.`)})).map(z=>z.content).join(I.resultJoiner),f=("> "+k).replace(/\n/g,`
|
||
|
|
> `),L={[W]:k,[`${W}-quoted`]:f};return setTimeout(()=>l.hide(),5e3),L}catch(c){throw l.setMessage("dead",c.message),setTimeout(()=>l.hide(),5e3),c}}var sd=require("obsidian"),TY=class b extends sd.Modal{constructor(G,l,c=[]){super(G);this.items=l;this.selectedItems=c;this._selectedItems=[...c],this.promise=new Promise((Z,W)=>{this.resolvePromise=Z,this.rejectPromise=W}),this.display(),this.open()}static Open(G,l,c){return new b(G,l,c).promise}display(){this.contentEl.empty(),this.containerEl.addClass("quickAddModal","checkboxPrompt"),this.addCheckboxRows(),this.addSubmitButton()}onClose(){super.onClose(),this.resolved||this.rejectPromise("no input given.")}addCheckboxRows(){let G=this.contentEl.createDiv("checkboxRowContainer");this.items.forEach(l=>this.addCheckboxRow(l,G))}addCheckboxRow(G,l){let c=l.createDiv("checkboxRow");c.createEl("span",{text:G}),new sd.ToggleComponent(c).setTooltip(`Toggle ${G}`).setValue(this._selectedItems.contains(G)).onChange(W=>{if(W)this._selectedItems.push(G);else{let d=this._selectedItems.findIndex(m=>G===m);this._selectedItems.splice(d,1)}})}addSubmitButton(){let G=this.contentEl.createDiv("submitButtonContainer");new sd.ButtonComponent(G).setButtonText("Submit").setCta().onClick(c=>{this.resolved=!0,this.resolvePromise(this._selectedItems),this.close()})}};var Fh=require("obsidian"),SY=class b extends Fh.Modal{constructor(G,l,c){super(G);this.header=l;this.text=c;this.waitForClose=new Promise(Z=>{this.resolvePromise=Z}),this.open(),this.display()}static Show(G,l,c){return new b(G,l,c).waitForClose}display(){this.contentEl.empty(),this.titleEl.textContent=this.header,String.isString(this.text)?this.contentEl.createEl("p",{text:this.text}):Array.isArray(this.text)&&this.text.forEach(c=>this.contentEl.createEl("p",{text:c}));let G=this.contentEl.createDiv(),l=new Fh.ButtonComponent(G).setButtonText("OK").onClick(()=>this.close());Object.assign(G.style,{display:"flex",justifyContent:"flex-end"}),l.buttonEl.focus()}onClose(){super.onClose(),this.resolvePromise()}};var wd=require("obsidian");var ZW=class b extends wd.Modal{constructor(G,l,c,Z,W){super(G);this.header=l;this.linkSourcePath=W;this.didSubmit=!1;this.submitClickCallback=G=>this.submit();this.cancelClickCallback=G=>this.cancel();this.submitEnterCallback=G=>{(G.ctrlKey||G.metaKey)&&G.key==="Enter"&&(G.preventDefault(),this.submit())};this.placeholder=c??"",this.input=Z??"",this.waitForClose=new Promise((d,m)=>{this.resolvePromise=d,this.rejectPromise=m}),this.display(),this.open(),this.fileSuggester=new ed(G,this.inputComponent.inputEl,{sourcePath:this.linkSourcePath}),this.tagSuggester=new Qd(G,this.inputComponent.inputEl)}static Prompt(G,l,c,Z){return new b(G,l,c,Z,void 0).waitForClose}static PromptWithContext(G,l,c,Z,W){return new b(G,l,c,Z,W).waitForClose}display(){this.containerEl.addClass("quickAddModal","qaWideInputPrompt"),this.contentEl.empty(),this.titleEl.textContent=this.header;let G=this.contentEl.createDiv();this.inputComponent=this.createInputField(G,this.placeholder,this.input),this.createButtonBar(G)}createInputField(G,l,c){let Z=new wd.TextAreaComponent(G);return Z.inputEl.classList.add("wideInputPromptInputEl"),Z.inputEl.setAttribute("dir","auto"),Z.setPlaceholder(l??"").setValue(c??"").onChange(W=>this.input=W).inputEl.addEventListener("keydown",this.submitEnterCallback),Z}createButton(G,l,c){let Z=new wd.ButtonComponent(G);return Z.setButtonText(l).onClick(c),Z}createButtonBar(G){let l=G.createDiv();this.createButton(l,"Ok",this.submitClickCallback).setCta().buttonEl.style.marginRight="0",this.createButton(l,"Cancel",this.cancelClickCallback),l.style.display="flex",l.style.flexDirection="row-reverse",l.style.justifyContent="flex-start",l.style.marginTop="1rem",l.style.gap="0.5rem"}escapeBackslashes(G){return G.replace(/\\/g,"\\\\")}submit(){this.didSubmit||(this.didSubmit=!0,this.input=this.escapeBackslashes(this.input),this.close())}cancel(){this.close()}resolveInput(){this.didSubmit?this.resolvePromise(this.input):this.rejectPromise("No input given.")}removeInputListener(){this.inputComponent.inputEl.remove
|
||
|
|
`,shouldMerge:d?.shouldMerge??!0},(e,Q)=>{let s={...m,...Q};return a(e,s,!1)});return p?(d?.shouldAssignVariables&&Object.entries(p).forEach(([e,Q])=>{l.variables.set(e,Q)}),p):(IG(new Error("AI Assistant returned null"),"Chunked AI Prompt error"),{})},getModels:()=>$b(),getMaxTokens:c=>{let Z=ob(c);if(!Z)throw new Error(`Model ${c} not found.`);return Z.maxTokens},countTokens(c,Z){return Tl(c,Z)}},utility:{getClipboard:async()=>await navigator.clipboard.readText(),setClipboard:async c=>await navigator.clipboard.writeText(c),getSelectedText:()=>{let c=I.workspace.getActiveViewOfType(es.MarkdownView);if(!c){IG(new Error("No active view"),"Could not get selected text");return}if(!c.editor.somethingSelected()){IG(new Error("No text selected"),"Could not get selected text");return}return c.editor.getSelection()}},date:{now:(c,Z)=>Hc({format:c,offset:Z}),tomorrow:c=>Hc({format:c,offset:1}),yesterday:c=>Hc({format:c,offset:-1})},fieldSuggestions:{getFieldValues:async(c,Z)=>{let W={folder:Z?.folder,tags:Z?.tags,inline:Z?.includeInline??!1},d=I.vault.getMarkdownFiles();d=Mh.filterFiles(d,W,N=>I.metadataCache.getFileCache(N));let m=new Set;for(let N of d){let a=I.metadataCache.getFileCache(N)?.frontmatter?.[c];if(a!=null){if(Array.isArray(a))a.forEach(V=>{let h=V.toString().trim();h&&m.add(h)});else if(typeof a!="object"){let V=a.toString().trim();V&&m.add(V)}}if(W.inline){let V=await I.vault.read(N);zd.getFieldValues(V,c).forEach(n=>m.add(n))}}return Array.from(m).sort()},clearCache:c=>{bc.getInstance().clear(c)}}}}static async inputPrompt(I,G,l,c){try{return await hG.Prompt(I,G,l,c)}catch(Z){hW(Z);return}}static async wideInputPrompt(I,G,l,c){try{return await ZW.Prompt(I,G,l,c)}catch(Z){hW(Z);return}}static async yesNoPrompt(I,G,l){try{return await hb.Prompt(I,G,l)}catch(c){hW(c);return}}static async infoDialog(I,G,l){try{return await SY.Show(I,G,l)}catch(c){hW(c);return}}static async suggester(I,G,l,c,Z=!1,W){try{let d;return typeof G=="function"?d=l.map(G):d=G,Z?await vl.Suggest(I,d,l,{...c?{placeholder:c}:{},...W?.renderItem?{renderItem:W.renderItem}:{}}):await Fl.Suggest(I,d,l,c,W?.renderItem)}catch(d){hW(d);return}}static async checkboxPrompt(I,G,l){try{return await TY.Open(I,G,l)}catch(c){hW(c);return}}};function hW(b){if(b instanceof qI)throw b;if(XG(b))throw new qI("Input cancelled by user")}var Bd=class extends hd{};var dl=[];for(let b=0;b<256;++b)dl.push((b+256).toString(16).slice(1));function Qs(b,I=0){return(dl[b[I+0]]+dl[b[I+1]]+dl[b[I+2]]+dl[b[I+3]]+"-"+dl[b[I+4]]+dl[b[I+5]]+"-"+dl[b[I+6]]+dl[b[I+7]]+"-"+dl[b[I+8]]+dl[b[I+9]]+"-"+dl[b[I+10]]+dl[b[I+11]]+dl[b[I+12]]+dl[b[I+13]]+dl[b[I+14]]+dl[b[I+15]]).toLowerCase()}var Tt,EA=new Uint8Array(16);function St(){if(!Tt){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Tt=crypto.getRandomValues.bind(crypto)}return Tt(EA)}var JA=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ft={randomUUID:JA};function yA(b,I,G){if(ft.randomUUID&&!I&&!b)return ft.randomUUID();b=b||{};let l=b.random??b.rng?.()??St();if(l.length<16)throw new Error("Random bytes length must be >= 16");if(l[6]=l[6]&15|64,l[8]=l[8]&63|128,I){if(G=G||0,G<0||G+16>I.length)throw new RangeError(`UUID byte range ${G}:${G+15} is out of buffer bounds`);for(let c=0;c<16;++c)I[G+c]=l[c];return I}return Qs(l)}var tl=yA;var Il=class{constructor(I,G){this.name=I,this.type=G,this.id=tl()}};var Hs=require("obsidian");var sG=class extends Il{constructor(I){super(I,"EditorCommand"),this.editorCommandType=I}static getSelectedText(I){return this.getActiveMarkdownView(I).editor.getSelection()}static getActiveMarkdownView(I){let G=I.workspace.getActiveViewOfType(Hs.MarkdownView);if(!G)throw M.logError("no active markdown view."),new Error("no active markdown view.");return G}};var Od=class extends sG{constructor(){super("Cut")}static async run(I){let G=sG.getSelectedText(I),l=sG.getActiveMarkdownView(I);if(!G){M.logError("nothing selected.");return}await navigator.clipboard.writeText(G),
|
||
|
|
`)}var rs=require("obsidian");function Sd(b,I){if(I.options)for(let G in I.options){let l=b[G]===void 0,c="defaultValue"in I.options[G]&&I.options[G].defaultValue!==void 0;l&&c&&(b[G]=I.options[G].defaultValue)}}var oA=["equals","notEquals","lessThan","lessThanOrEqual","greaterThan","greaterThanOrEqual","contains","notContains"],ws=new Set(["true","1","yes","on"]),vs=new Set(["false","0","no","off"]);function ZZ(b){return oA.includes(b)}function Es(b){switch(b){case"lessThan":case"lessThanOrEqual":case"greaterThan":case"greaterThanOrEqual":return"number";case"equals":case"notEquals":return"string";case"contains":case"notContains":return"string";case"isTruthy":case"isFalsy":default:return"boolean"}}function Js(b){if(!ZZ(b.operator)||b.expectedValue===void 0||b.expectedValue===null)return;let I=b.expectedValue.trim();switch(b.valueType){case"number":{let G=Number(I);return Number.isNaN(G)?NaN:G}case"boolean":{let G=I.toLowerCase();return ws.has(G)?!0:vs.has(G)?!1:!!I}case"string":default:return I}}function Pt(b,I){switch(I){case"number":return typeof b=="number"?b:typeof b=="boolean"?b?1:0:Number(b);case"boolean":if(typeof b=="boolean")return b;if(typeof b=="string"){let G=b.trim().toLowerCase();if(ws.has(G))return!0;if(vs.has(G))return!1}return!!b;case"string":default:return b==null?"":String(b)}}function CA(b){if(!ZZ(b.operator))return"";let I=b.expectedValue??"";return I.length===0?"(empty)":b.valueType==="string"?`"${I}"`:I}function iA(b){let I=b.variableName?`$${b.variableName}`:"(missing variable)",G=AA(b.operator),l=ZZ(b.operator)?` ${CA(b)}`:"";return`${I} ${G}${l}`.trim()}function gA(b){let I=b.exportName?`::${b.exportName}`:"";return`script ${b.scriptPath}${I}`}function fd(b){return b.mode==="variable"?iA(b):gA(b)}function AA(b){switch(b){case"equals":return"equals";case"notEquals":return"does not equal";case"lessThan":return"is less than";case"lessThanOrEqual":return"is less than or equal to";case"greaterThan":return"is greater than";case"greaterThanOrEqual":return"is greater than or equal to";case"contains":return"contains";case"notContains":return"does not contain";case"isTruthy":return"is truthy";case"isFalsy":return"is falsy";default:return b}}async function os(b,I){return b.mode==="script"?await I.evaluateScriptCondition(b):rA(b,I.variables)}function rA(b,I){let G=b.variableName?.trim();if(!G)return M.logWarning("Conditional command skipped: No variable name configured."),!1;if(!(G in I))return M.logWarning(`Conditional command skipped: Variable '${G}' is not defined.`),!1;let l=I[G];switch(b.operator){case"isTruthy":return!!l;case"isFalsy":return!l}if(ZZ(b.operator)){let c=Js(b);return c===void 0?(M.logWarning(`Conditional command: Operator '${b.operator}' requires a comparison value.`),!1):b.operator==="contains"?ys(l,c,b):b.operator==="notContains"?!ys(l,c,b):LA(l,c,b)}return!1}function ys(b,I,G){return b==null?!1:typeof I=="string"&&I.length===0?(M.logWarning("Conditional command: 'contains' operator requires a non-empty comparison value."),!1):Array.isArray(b)?b.map(l=>Pt(l,G.valueType)).some(l=>l===I):typeof b=="string"?b.includes(String(I)):typeof b=="number"&&typeof I=="number"?b===I:String(b).includes(String(I))}function LA(b,I,G){let l=Pt(b,G.valueType);switch(G.operator){case"equals":return l===I;case"notEquals":return l!==I;case"lessThan":return jh(l,I,(c,Z)=>c<Z);case"lessThanOrEqual":return jh(l,I,(c,Z)=>c<=Z);case"greaterThan":return jh(l,I,(c,Z)=>c>Z);case"greaterThanOrEqual":return jh(l,I,(c,Z)=>c>=Z);default:return!1}}function jh(b,I,G){let l=Number(b),c=Number(I);return Number.isNaN(l)||Number.isNaN(c)?(M.logWarning("Conditional command numeric comparison failed: non-numeric value encountered."),!1):G(l,c)}var Cs=require("obsidian");function WZ(b,{logPrefix:I,noticePrefix:G=I,defaultReason:l}){if(!(b instanceof qI))return!1;let c=typeof b.message=="string"&&b.message.trim().length>0?b.message:l;return M.logMessage(`${I}: ${c}`),(!(typeof b.message=="string"&&b.message.toLowerCase().includes("cancelled by user"))||dI.getState().showInputCancellationNotification)&&new Cs.Notice(`${G}: ${c}
|
||
|
|
${rI}
|
||
|
|
\\end{${b}}${rI}`}var Ls=[...xA,...UA.map(BA)];var ks=require("obsidian");var OA=new RegExp(/\\([a-z{}A-Z0-9]*)$/),Th=class extends $G{constructor(G){super(fI.instance.app,G);this.inputEl=G;this.lastInput="";this.symbols=Object.assign([],Ls),this.elementsRendered=this.symbols.reduce((l,c)=>{try{l[c.toString()]=(0,ks.renderMath)(c,!0)}catch{}return l},{})}getSuggestions(G){if(this.inputEl.selectionStart===null)return[];let l=this.inputEl.selectionStart,c=G.substr(0,l),Z=c.lastIndexOf("\\"),W=c.substr(Z),d=OA.exec(W),m=[];return d&&(this.lastInput=d[1],m=this.symbols.filter(a=>a.toLowerCase().contains(this.lastInput))),new rl(m,{findAllMatches:!0,threshold:.8}).search(this.lastInput).map(a=>a.item)}renderSuggestion(G,l){G&&(l.setText(G),l.append(this.elementsRendered[G]))}selectSuggestion(G){if(this.inputEl.selectionStart===null)return;let l=this.inputEl.selectionStart,c=this.lastInput.length,Z=this.inputEl.value,W=0,d=G.replace(/\\\\/g,"\\");if(this.inputEl.value=`${Z.substr(0,l-c-1)}${d}${Z.substr(l)}`,W=l-c+G.length-1,this.inputEl.trigger("input"),this.close(),G.contains(rI)){let m=this.inputEl.value.indexOf(rI);this.inputEl.value=this.inputEl.value.replace(rI,""),this.inputEl.setSelectionRange(m,m)}else this.inputEl.setSelectionRange(W,W)}};var Sh=class b extends kl.Modal{constructor(){super(fI.instance.app);this.didSubmit=!1;this.keybindListener=G=>{G.ctrlKey&&G.key==="Enter"&&this.submit(),G.key==="Tab"&&(G.preventDefault(),this.cursorToGoTo())};this.submitClickCallback=G=>this.submit();this.cancelClickCallback=G=>this.cancel();this.open(),this.display(),this.waitForClose=new Promise((G,l)=>{this.resolvePromise=G,this.rejectPromise=l}),new Th(this.inputEl),this.inputEl.focus(),this.inputEl.select()}static Prompt(){return new b().waitForClose}display(){this.containerEl.addClass("quickAddModal","qaMathModal"),this.contentEl.empty();let G=this.contentEl.createDiv();G.className="math math-block is-loaded";let l=new kl.TextAreaComponent(this.contentEl);l.inputEl.style.width="100%",l.inputEl.style.height="10rem",this.inputEl=l.inputEl,l.onChange((0,kl.debounce)(async c=>await this.mathjaxLoop(G,c),50)),l.inputEl.addEventListener("keydown",this.keybindListener),this.createButtonBar(this.contentEl.createDiv())}async onOpen(){super.onOpen(),await(0,kl.loadMathJax)()}async mathjaxLoop(G,l){let c=(0,kl.renderMath)(l,!0);await(0,kl.finishRenderMath)(),G.empty(),G.append(c)}cursorToGoTo(){if(this.inputEl.value.contains(rI)){let G=this.inputEl.value.indexOf(rI);this.inputEl.value=this.inputEl.value.replace(rI,""),this.inputEl.setSelectionRange(G,G)}}createButton(G,l,c){let Z=new kl.ButtonComponent(G);return Z.setButtonText(l).onClick(c),Z}createButtonBar(G){let l=G.createDiv();this.createButton(l,"Ok",this.submitClickCallback).setCta().buttonEl.style.marginRight="0",this.createButton(l,"Cancel",this.cancelClickCallback),l.style.display="flex",l.style.flexDirection="row-reverse",l.style.justifyContent="flex-start",l.style.marginTop="1rem",l.style.gap="0.5rem"}removeInputListeners(){this.inputEl.removeEventListener("keydown",this.keybindListener)}resolveInput(){let G=this.inputEl.value.replace("\\n","\\\\n").replace(new RegExp(rI,"g"),"");this.didSubmit?this.resolvePromise(G):this.rejectPromise("No input given.")}submit(){this.didSubmit=!0,this.close()}cancel(){this.close()}onClose(){super.onClose(),this.resolveInput(),this.removeInputListeners()}};var rb=class extends Sb{constructor(G,l,c,Z){super(G);this.app=G;this.plugin=l;this.choiceExecutor=c;this.dateParser=Z||vb,c&&(this.variables=c?.variables)}async format(G){let l=G;return l=await this.replaceInlineJavascriptInString(l),l=await this.replaceMacrosInString(l),l=await this.replaceTemplateInString(l),l=await this.replaceGlobalVarInString(l),l=this.replaceDateInString(l),l=this.replaceTimeInString(l),l=await this.replaceValueInString(l),l=await this.replaceSelectedInString(l),l=await this.replaceClipboardInString(l),l=await this.replaceDateVariableInString(l),l=await this.replaceVariableInString(l),l=await this.replaceFieldVarInString(l),l=await this.replaceMathValueInString(l)
|
||
|
|
|
||
|
|
Suggested values for ${l}: ${N.slice(0,3).join(", ")}`)}return await hG.PromptWithContext(this.app,`Enter value for ${l}`,m,void 0,this.getLinkSourcePath()??void 0)}let d=`Enter value for ${l}`;return W&&(d=`Enter value for ${l} (default: ${c.defaultValue})`),await vl.Suggest(this.app,Z,Z,{placeholder:d})}catch(l){throw XG(l)?new qI("Input cancelled by user"):l}}generateCacheKey(G){return xh(G)}async getMacroValue(G){let l=new Dh(this.app,this.plugin,this.plugin.settings.choices,this.choiceExecutor,this.variables),c=await l.runAndGetOutput(G)??"";return l.getVariables().forEach((Z,W)=>{this.variables.set(W,Z)}),c}async getTemplateContent(G){return await new dZ(this.app,this.plugin,G,this.choiceExecutor).run()}async getSelectedText(){let G=this.app.workspace.getActiveViewOfType(zs.MarkdownView);return G?G.editor.getSelection():""}async getClipboardContent(){try{return await navigator.clipboard.readText()}catch{return""}}isTemplatePropertyTypesEnabled(){return this.plugin.settings.enableTemplatePropertyTypes}async replaceInlineJavascriptInString(G){let l=G;for(;Hm.test(l);){let Z=Hm.exec(l)?.at(1)?.trim();if(Z){let W=new Kh(this.app,this.plugin,this.choiceExecutor,this.variables),d=await W.runAndGetOutput(Z);for(let m in W.params.variables)this.variables.set(m,W.params.variables[m]);l=typeof d=="string"?this.replacer(l,Hm,d):this.replacer(l,Hm,"")}}return l}async collectValuesManually(G,l){return await Uh(this.app,G,l)}};var Bs=require("obsidian");var xs=require("obsidian");function Us(b){return((0,xs.normalizePath)(b).split("/").pop()??"").replace(/\.(md|canvas)$/i,"")}function _t(b){return b instanceof qI||!!b&&typeof b=="object"&&"name"in b&&b.name==="MacroAbortError"}var qd=class extends hd{constructor(G,l,c){super(G);this.plugin=l;this.templater=sF(G),this.formatter=new rb(G,l,c)}async getOrCreateFolder(G){let l;if(G.length>1)try{if(l=await Fl.Suggest(this.app,G,G),!l)throw new Error("No folder selected.")}catch(c){throw XG(c)?new qI("Input cancelled by user"):c}else l=G[0];return l?await this.createFolder(l):l="",l}async getFormattedFilePath(G,l,c){let Z=await this.formatter.formatFileName(l,c);return this.normalizeMarkdownFilePath(G,Z)}getTemplateExtension(G){return Qm.test(G)?".canvas":".md"}normalizeTemplateFilePath(G,l,c){let Z=G?`${G}/`:"",W=this.getTemplateExtension(c),d=l.replace(uZ,"").replace(Qm,"");return`${Z}${d}${W}`}async incrementFileName(G){let l=await this.app.vault.adapter.exists(G),c=G,Z=Qm.test(G)?".canvas":".md",W=Z.replace(/\./g,"\\."),d=new RegExp(`(\\d*)${W}$`),N=d.exec(G)?.[1];if(l&&N!==void 0)if(N.length>0){let a=parseInt(N,10);if(Number.isNaN(a))throw new Error("detected numbers but couldn't get them.");c=c.replace(d,`${a+1}${Z}`)}else c=c.replace(new RegExp(`${W}$`),`1${Z}`);else l&&(c=c.replace(new RegExp(`${W}$`),`1${Z}`));return await this.app.vault.adapter.exists(c)&&(c=await this.incrementFileName(c)),c}async createFileWithTemplate(G,l){try{let c=await this.getTemplateContent(l),Z=Us(G);this.formatter.setTitle(Z);let W=await this.formatter.formatFileContent(c),d=this.formatter.getAndClearTemplatePropertyVars();M.logMessage(`TemplateEngine.createFileWithTemplate: Collected ${d.size} template property variables for ${G}`),d.size>0&&M.logMessage(`Variables: ${Array.from(d.keys()).join(", ")}`);let m=G.toLowerCase().endsWith(".md"),N=await this.createFileWithInput(G,W,{suppressTemplaterOnCreate:m});return this.shouldPostProcessFrontMatter(N,d)&&await this.postProcessFrontMatter(N,d),await Nd(this.app,N),N}catch(c){if(_t(c))throw c;return IG(c,`Could not create file with template at ${G}`),null}}setLinkToCurrentFileBehavior(G){this.formatter.setLinkToCurrentFileBehavior(G)}async overwriteFileWithTemplate(G,l){try{let c=await this.getTemplateContent(l),Z=G.basename;this.formatter.setTitle(Z);let W=await this.formatter.formatFileContent(c),d=this.formatter.getAndClearTemplatePropertyVars();return M.logMessage(`TemplateEngine.overwriteFileWithTemplate: Collected ${d.size} template property variables for ${G.path}`),d.size>0&&M.logMessage(`Variables: ${Array.from(d.keys()).join(", ")}`),await
|
||
|
|
${m}`:`${m}
|
||
|
|
${d}`;return await this.app.vault.modify(G,N),G}catch(Z){if(_t(Z))throw Z;return IG(Z,"Could not append to file with template"),null}}async getTemplateContent(G){let l=G;!uZ.test(G)&&!Qm.test(G)&&(l+=".md");let c=this.app.vault.getAbstractFileByPath(l);if(!(c instanceof Bs.TFile))throw new Error(`Template file not found at path "${l}".`);return await this.app.vault.cachedRead(c)}};var dZ=class extends qd{constructor(G,l,c,Z){super(G,l,Z);this.templatePath=c}async run(){let G=await this.getTemplateContent(this.templatePath);return G||M.logError(`Template ${this.templatePath} not found.`),G=await this.formatter.formatFileContent(G),G}getAndClearTemplatePropertyVars(){return this.formatter.getAndClearTemplatePropertyVars()}};var El=class extends Sb{constructor(G,l,c){super(G);this.plugin=l;this.dateParser=c||vb}async format(G){let l=G;try{l=await this.replaceGlobalVarInString(l),l=this.replaceDateInString(l),l=this.replaceTimeInString(l),l=await this.replaceValueInString(l),l=await this.replaceSelectedInString(l),l=await this.replaceClipboardInString(l),l=await this.replaceDateVariableInString(l),l=await this.replaceVariableInString(l),l=await this.replaceLinkToCurrentFileInString(l),l=await this.replaceCurrentFileNameInString(l),l=await this.replaceMacrosInString(l),l=await this.replaceTemplateInString(l),l=await this.replaceFieldVarInString(l),l=this.replaceRandomInString(l),l=this.replaceLinebreakInString(l)}catch{return G}return l}async replaceGlobalVarInString(G){let l=G,c=0,Z=new RegExp(Bc.source,"gi");for(;Z.test(l)&&!(++c>5);)l=l.replace(Z,(W,d)=>{let m=String(d??"").trim();if(!m)return W;let N=this.plugin?.settings?.globalVariables?.[m];return typeof N=="string"?N:""});return l}promptForValue(G){return G||"user input"}getVariableValue(G){return BV(G)}getCurrentFileLink(){return this.app?KV(this.app.workspace.getActiveFile()):null}getCurrentFileName(){return this.app?DV(this.app.workspace.getActiveFile()):"current_filename"}suggestForValue(G,l=!1){return jV(G)}getMacroValue(G){return OV(G)}promptForMathValue(){return Promise.resolve("calculation_result")}promptForVariable(G,l){return Promise.resolve(MV(G))}async getTemplateContent(G){let l=this.app;if(!l)return`Template (app unavailable): ${G}`;try{return await new dZ(l,this.plugin,G,void 0).run()}catch{return`Template (not found): ${G}`}}async getSelectedText(){return"selected_text"}async getClipboardContent(){return"clipboard_content"}async suggestForField(G){return Promise.resolve(`${G}_field_value`)}async replaceDateVariableInString(G){let l=G;return l=l.replace(new RegExp(HZ.source,"gi"),(c,Z,W,d)=>{let m=Z?.trim(),N=W?.trim(),Y=d?.trim();if(!m||!N)return c;let a=new Date,V;try{V=fb.generate(N,a)}catch{V=`[${N} format]`}return Y&&(V+=` (default: ${Y})`),V}),l}replaceRandomInString(G){let l=G;return l=l.replace(/{{RANDOM:(\d+)}}/gi,(c,Z)=>{let W=parseInt(Z);if(W<=0||W>100)return c;let d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",m="";for(let N=0;N<Math.min(W,8);N++)m+=d.charAt(Math.floor(Math.random()*d.length));return W>8&&(m+=`... (${W} chars)`),m}),l}isTemplatePropertyTypesEnabled(){return!1}};var fh=require("obsidian");var Xl=class extends $G{constructor(G,l,c,Z=1/0){super(G,l);this.app=G;this.inputEl=l;this.items=c;this.maxSuggestions=Z}getSuggestions(G){let l=G.toLowerCase(),c=this.items.filter(W=>W.toLowerCase().includes(l));return c.length===0&&this.close(),c.slice(0,this.maxSuggestions)}selectSuggestion(G){this.inputEl.value=G,this.inputEl.trigger("input"),this.close()}renderSuggestion(G,l){G&&this.renderMatch(l,G,this.getCurrentQuery())}getCurrentQuery(){return this.inputEl.value}};function FW(b){let{app:I,parent:G,initialValue:l="",placeholder:c,required:Z=!1,requiredMessage:W="This field is required",validator:d,suggestions:m,maxSuggestions:N=1/0,attachSuggesters:Y=[],inputKind:a="text",debounceMs:V=0,trim:h=!0,ariaHintId:n,fullWidth:X=!0,marginBottomPx:p=8,onChange:e}=b,Q=a==="textarea"?new fh.TextAreaComponent(G):new fh.TextComponent(G),s=Q.inputEl;X&&(s.style.width="100%"),s.style.marginBottom=`${p}px`,a==="textarea"&&(s.sty
|
||
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function b4(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
||
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ta(b,I){var G=typeof Symbol<"u"&&b[Symbol.iterator]||b["@@iterator"];if(!G){if(Array.isArray(b)||(G=YX(b))||I&&b&&typeof b.length=="number"){G&&(b=G);var l=0,c=function(){};return{s:c,n:function(){return l>=b.length?{done:!0}:{done:!1,value:b[l++]}},e:function(m){throw m},f:c}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
||
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var Z=!0,W=!1,d;return{s:function(){G=G.call(b)},n:function(){var m=G.next();return Z=m.done,m},e:function(m){W=!0,d=m},f:function(){try{!Z&&G.return!=null&&G.return()}finally{if(W)throw d}}}}var c4="finalize",Z4="consider";function cm(b,I,G){b.dispatchEvent(new CustomEvent(c4,{detail:{items:I,info:G}}))}function aZ(b,I,G){b.dispatchEvent(new CustomEvent(Z4,{detail:{items:I,info:G}}))}var d2="draggedEntered",Xa="draggedLeft",m2="draggedOverIndex",aX="draggedLeftDocument",G2={LEFT_FOR_ANOTHER:"leftForAnother",OUTSIDE_OF_ANY:"outsideOfAny"};function W4(b,I,G){b.dispatchEvent(new CustomEvent(d2,{detail:{indexObj:I,draggedEl:G}}))}function d4(b,I,G){b.dispatchEvent(new CustomEvent(Xa,{detail:{draggedEl:I,type:G2.LEFT_FOR_ANOTHER,theOtherDz:G}}))}function m4(b,I){b.dispatchEvent(new CustomEvent(Xa,{detail:{draggedEl:I,type:G2.OUTSIDE_OF_ANY}}))}function N4(b,I,G){b.dispatchEvent(new CustomEvent(m2,{detail:{indexObj:I,draggedEl:G}}))}function Y4(b){window.dispatchEvent(new CustomEvent(aX,{detail:{draggedEl:b}}))}var yl={DRAG_STARTED:"dragStarted",DRAGGED_ENTERED:d2,DRAGGED_ENTERED_ANOTHER:"dragEnteredAnother",DRAGGED_OVER_INDEX:m2,DRAGGED_LEFT:Xa,DRAGGED_LEFT_ALL:"draggedLeftAll",DROPPED_INTO_ZONE:"droppedIntoZone",DROPPED_INTO_ANOTHER:"droppedIntoAnother",DROPPED_OUTSIDE_OF_ANY:"droppedOutsideOfAny",DRAG_STOPPED:"dragStopped"},Ql={POINTER:"pointer",KEYBOARD:"keyboard"},N2="isDndShadowItem",Y2="data-is-dnd-shadow-item-internal",a4="data-is-dnd-shadow-item-hint",eW="id:dnd-shadow-placeholder-0000",V4="dnd-action-dragged-el",cl="id",bX=0;function cw(){bX++}function Zw(){if(bX===0)throw new Error("Bug! trying to decrement when there are no dropzones");bX--}var VX=typeof window>"u",CI=function(){};function cX(b){var I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,G,l=I?F4(b):b.getBoundingClientRect(),c=getComputedStyle(b),Z=c.transform;if(Z){var W,d,m,N;if(Z.startsWith("matrix3d("))G=Z.slice(9,-1).split(/, /),W=+G[0],d=+G[5],m=+G[12],N=+G[13];else if(Z.startsWith("matrix("))G=Z.slice(7,-1).split(/, /),W=+G[0],d=+G[3],m=+G[4],N=+G[5];else return l;var Y=c.transformOrigin,a=l.x-m-(1-W)*parseFloat(Y),V=l.y-N-(1-d)*parseFloat(Y.slice(Y.indexOf(" ")+1)),h=W?l.width/W:b.offsetWidth,n=d?l.height/d:b.offsetHeight;return{x:a,y:V,width:h,height:n,top:V,right:a+h,bottom:V+n,left:a}}else return l}function Ww(b){var I=cX(b);return{top:I.top+window.scrollY,bottom:I.bottom+window.scrollY,left:I.left+window.scrollX,right:I.right+window.scrollX}}function dw(b){var I=b.getBoundingClientRect();return{top:I.top+window.scrollY,bottom:I.bottom+window.scrollY,left:I.left+window.scrollX,right:I.right+window.scrollX}}function mw(b){return{x:(b.left+b.right)/2,y:(b.top+b.bottom)/2}}function h4(b,I){return Math.sqrt(Math.pow(b.x-I.x,2)+Math.pow(b.y-I.y,2))}function a2(b,I){return b.y<=I.bottom&&b.y>=I.top&&b.x>=I.left&&b.x<=I.right}function na(b){return mw(dw(b))}function Ts(b,I){var G=na(b),l=Ww(I);return a2(G,l)}function n4(b,I){var G=na(b),l=na(I);return h4(G,l)}function R4(b){var I=dw(b);return I.right<0||I.left>document.documentElement.scrollWidth||I.bottom<0||I.top>document.documentElement.scrollHeight}function F4(b){for(var I=b.getBoundingClientRect(),G={top:I.top,bottom:I.bottom,left:I.left,right:I.right},l=b.parentElement;l&&l!==document.body;){var c=l.getBoundingClientRect(),Z=window.getComputedStyle(l).overflowY,W=window.getComputedStyle(l).overflowX,d=Z==="scroll"||Z==="auto",m=W==="scroll"||W==="auto";d&&(G.top=Math.max(G.top,c.top),G.bottom=Math.min(G.bottom,c.bottom)),m&&(G.left=Math.max(G.left,c.left),G.right=Math.min(G.right,c.right)),l=l.parentElement}return G.top=Math.max(G.top,0),G.bottom=Math.min(G.bottom,window.innerHeight),G.left=Math.max(G.left,0),G.right=Math.min(G.right,window.innerWidth),{top:G.top,bottom:G.bottom,left:G.left,right:G.right,width:Math.max(0,G.right-G.left),height:Math.max(0,G.bottom-G.top)}}var Gm;function hX(){CI(function(){return"resetting indexes cache"}),Gm=new Map}hX();function t4(b){var I=Array.from(b.children).f
|
||
|
|
${G?"Deleting this choice will delete all ("+b.choices.length+") choices inside it!":""}
|
||
|
|
${l?"Deleting this choice will delete its macro commands!":""}
|
||
|
|
`)}async function Lw(b,I,G){if(b.type==="Multi"){let c=await hG.Prompt(I,`Rename ${b.name}`,"",b.name);return c?{...b,name:c}:void 0}let l=Ur(b,I,G);if(!l)throw new Error("Invalid choice type");return await l.waitForClose}function kw(b){return{...b,command:!b.command}}var i2=class{constructor(I){this.plugin=I}enableCommand(I){this.plugin.addCommandForChoice(I)}disableCommand(I){this.plugin.removeCommandForChoice(I)}updateCommand(I,G){this.plugin.removeCommandForChoice(I),this.plugin.addCommandForChoice(G)}};function zw(b,I,G){if(!I||!G)return b;let l=wX(b,I),c=wX(b,G);if(!l||!c||c.type!=="Multi"||l.type==="Multi"&&(l.id===c.id||Br(l).has(c.id)))return b;let{updated:Z,removed:W}=xw(b,I);return W?Uw(Z,G,W)??b:b}function wX(b,I){for(let G of b){if(G.id===I)return G;if(G.type==="Multi"){let l=wX(G.choices,I);if(l)return l}}}function Br(b){let I=new Set,G=l=>{I.add(l.id),l.type==="Multi"&&l.choices.forEach(G)};return(b.choices??[]).forEach(G),I}function xw(b,I){let G;return{updated:b.map(c=>{if(c.id===I){G=c;return}if(c.type!=="Multi")return c;let Z=xw(c.choices,I);return Z.removed&&(G=Z.removed),Z.removed?{...c,choices:Z.updated}:c}).filter(Boolean),removed:G}}function Uw(b,I,G){let l=!1,c=b.map(Z=>{if(Z.id===I&&Z.type==="Multi"){l=!0;let d=Z;return{...d,choices:[...d.choices,G]}}if(Z.type!=="Multi")return Z;let W=Uw(Z.choices,I,G);return W?(l=!0,{...Z,choices:W}):Z});return l?c:void 0}var ac=require("obsidian");var AG=require("obsidian");var Bw=require("obsidian");var g2=null,Or=24*60*60*1e3;async function Ow(){if(g2&&Date.now()-g2.fetchedAt<Or)return g2.data;if(dI.getState().disableOnlineFeatures)throw new Error("Fetching models directory is disabled: Online features are turned off.");let I=await(await(0,Bw.requestUrl)({url:"https://models.dev/api.json",method:"GET"})).json;return g2={data:I,fetchedAt:Date.now()},I}function JX(b){let I=b.toLowerCase();return I.includes("openai.com")?"openai":I.includes("openrouter.ai")?"openrouter":I.includes("generativelanguage.googleapis.com")?"google":I.includes("anthropic.com")||I.includes("anthropic")?"anthropic":I.includes("groq.com")?"groq":I.includes("together.ai")?"togetherai":I.includes("huggingface.co")||I.includes("huggingface")?"huggingface":I.includes("github")&&I.includes("models")?"github-models":I.includes("bedrock")||I.includes("aws")?"amazon-bedrock":I.includes("modelscope")?"modelscope":I.includes("dashscope")?"alibaba":I.includes("fireworks.ai")?"fireworks-ai":I.includes("vercel")?"vercel":I.includes("inference.net")?"inference":I.includes("z.ai")||I.includes("zhipu")?"zhipuai":I.includes("deepseek.com")?"deepseek":I.includes("cerebras")?"cerebras":I.includes("venice.ai")?"venice":I.includes("upstage.ai")?"upstage":I.includes("llama.com")||I.includes("api.llama.com")?"llama":I.includes("morphllm")?"morph":I.includes("inceptionlabs.ai")?"inception":I.includes("deepinfra")?"deepinfra":I.includes("gateway.opencode.ai")?"opencode":I.includes("router.huggingface.co")?"huggingface":I.includes("inference.wandb.ai")?"wandb":I.includes("api.githubcopilot.com")?"github-copilot":I.includes("api.openai.com")?"openai":null}function Mw(b){return b.map(I=>({name:I.id,maxTokens:Math.max(1,Math.floor(I.limit?.context??128e3))}))}function yX(b,I){let G=new Set(b.map(c=>c.name)),l=I.filter(c=>!G.has(c.name));return b.concat(l)}var Dw=require("obsidian");var Mr=128e3;async function A2(b){let I=b.modelSource??"providerApi";if(I==="modelsDev")return jw(b);if(I==="providerApi")return Kw(b);try{return await Kw(b)}catch(G){if(!JX(b.endpoint))throw G;return jw(b,G)}}async function jw(b,I){try{let G=await Ow(),l=JX(b.endpoint);if(!l||!(l in G))throw new Error(`models.dev does not list a provider that matches ${b.endpoint}.`);let c=Object.values(G[l].models);return Mw(c)}catch(G){throw I?new Error(`Provider API failed (${I.message}). Fallback to models.dev also failed: ${G.message}`):G}}async function Kw(b){let{disableOnlineFeatures:I}=dI.getState();if(I)throw new Error("Online features are disabled \u2014 enable them to browse provider models.");if(!b.endpoint)throw new Error("Provi
|
||
|
|
`),d=NI(W),t(I,"class","warning svelte-iqd8ho")},m(m,N){cI(m,I,N),F(I,G),F(I,l),F(I,c),F(c,Z),F(c,d)},p(m,N){N[0]&256&&W!==(W=m[8].missingChoiceIds.join(", ")+"")&&sI(d,W)},d(m){m&&lI(I)}}}function Cv(b){let I,G,l,c,Z=b[4].missingChoices.length>0&&iv(b),W=b[4].missingAssets.length>0&&gv(b);return{c(){I=v("section"),G=v("h4"),G.textContent="Warnings",l=K(),Z&&Z.c(),c=K(),W&&W.c(),t(I,"class","warning svelte-iqd8ho")},m(d,m){cI(d,I,m),F(I,G),F(I,l),Z&&Z.m(I,null),F(I,c),W&&W.m(I,null)},p(d,m){d[4].missingChoices.length>0?Z?Z.p(d,m):(Z=iv(d),Z.c(),Z.m(I,c)):Z&&(Z.d(1),Z=null),d[4].missingAssets.length>0?W?W.p(d,m):(W=gv(d),W.c(),W.m(I,null)):W&&(W.d(1),W=null)},d(d){d&&lI(I),Z&&Z.d(),W&&W.d()}}}function iv(b){let I,G,l=b[4].missingChoices.map(b[23]).join(", ")+"",c;return{c(){I=v("p"),G=NI(`Missing choices:
|
||
|
|
`),c=NI(l)},m(Z,W){cI(Z,I,W),F(I,G),F(I,c)},p(Z,W){W[0]&144&&l!==(l=Z[4].missingChoices.map(Z[23]).join(", ")+"")&&sI(c,l)},d(Z){Z&&lI(I)}}}function gv(b){let I,G,l,c,Z=YG(b[4].missingAssets),W=[];for(let d=0;d<Z.length;d+=1)W[d]=Av(vv(b,Z,d));return{c(){I=v("div"),G=v("p"),G.textContent="Missing assets:",l=K(),c=v("ul");for(let d=0;d<W.length;d+=1)W[d].c();t(c,"class","svelte-iqd8ho")},m(d,m){cI(d,I,m),F(I,G),F(I,l),F(I,c);for(let N=0;N<W.length;N+=1)W[N]&&W[N].m(c,null)},p(d,m){if(m[0]&528){Z=YG(d[4].missingAssets);let N;for(N=0;N<Z.length;N+=1){let Y=vv(d,Z,N);W[N]?W[N].p(Y,m):(W[N]=Av(Y),W[N].c(),W[N].m(c,null))}for(;N<W.length;N+=1)W[N].d(1);W.length=Z.length}},d(d){d&&lI(I),Rc(W,d)}}}function Av(b){let I,G=b[28].path+"",l,c,Z,W,d=b[9][b[28].kind]+"",m,N;return{c(){I=v("li"),l=NI(G),c=K(),Z=v("span"),W=NI("("),m=NI(d),N=NI(")"),t(Z,"class","assetKind svelte-iqd8ho")},m(Y,a){cI(Y,I,a),F(I,l),F(I,c),F(I,Z),F(Z,W),F(Z,m),F(Z,N)},p(Y,a){a[0]&16&&G!==(G=Y[28].path+"")&&sI(l,G),a[0]&16&&d!==(d=Y[9][Y[28].kind]+"")&&sI(m,d)},d(Y){Y&&lI(I)}}}function xL(b){let I;return{c(){I=NI("Copy JSON")},m(G,l){cI(G,I,l)},d(G){G&&lI(I)}}}function UL(b){let I;return{c(){I=NI("Copying\u2026")},m(G,l){cI(G,I,l)},d(G){G&&lI(I)}}}function BL(b){let I;return{c(){I=NI("Save to file")},m(G,l){cI(G,I,l)},d(G){G&&lI(I)}}}function OL(b){let I;return{c(){I=NI("Saving\u2026")},m(G,l){cI(G,I,l)},d(G){G&&lI(I)}}}function ML(b){let I,G,l,c,Z,W,d,m,N,Y,a,V,h,n,X,p,e,Q,s,R,J=b[8].rootCount+"",E,H,g,C,k,f,L=b[8].totalChoices+"",z,r,w,i,o,B,j=b[8].dependencyCount+"",_,YI,aI,QI,vI,tI,VI=b[8].userScripts+b[8].conditionalScripts+"",EI,_I,RG,EG,tG,eb,Ul=b[8].templateFiles+b[8].captureTemplates+"",Bl,Yl,al,T,LI,xI,KI,Pl,Vl,Ol,rc,nc,_l,Lc,hZ,kc,Qb,Aa,Hb,nZ,tm,RZ,ub,ra,u,A,x;function D(MG,FG){return MG[6].length===0?zL:kL}let $=D(b,[-1,-1]),II=$(b),P=b[8].missingChoiceIds.length>0&&ov(b),hI=b[4]&&Cv(b);function $I(MG,FG){return MG[5]==="copy"?UL:xL}let JG=$I(b,[-1,-1]),lG=JG(b);function $l(MG,FG){return MG[5]==="save"?OL:BL}let BG=$l(b,[-1,-1]),OG=BG(b);return{c(){I=v("div"),G=v("header"),G.innerHTML='<h2>Export QuickAdd Package</h2> <p class="svelte-iqd8ho">Select choices to bundle. Dependencies are added automatically.</p>',l=K(),c=v("section"),Z=v("input"),d=K(),m=v("div"),N=v("button"),N.textContent="Select visible",Y=K(),a=v("button"),a.textContent="Clear selection",V=K(),h=v("section"),II.c(),n=K(),X=v("section"),p=v("h3"),p.textContent="Package summary",e=K(),Q=v("div"),s=v("div"),R=v("strong"),E=NI(J),H=K(),g=v("span"),g.textContent="Selected choices",C=K(),k=v("div"),f=v("strong"),z=NI(L),r=K(),w=v("span"),w.textContent="Total packaged",i=K(),o=v("div"),B=v("strong"),_=NI(j),YI=K(),aI=v("span"),aI.textContent="Auto-included",QI=K(),vI=v("div"),tI=v("strong"),EI=NI(VI),_I=K(),RG=v("span"),RG.textContent="Scripts embedded",EG=K(),tG=v("div"),eb=v("strong"),Bl=NI(Ul),Yl=K(),al=v("span"),al.textContent="Templates embedded",T=K(),P&&P.c(),LI=K(),hI&&hI.c(),xI=K(),KI=v("section"),Pl=v("div"),Vl=v("button"),lG.c(),rc=K(),nc=v("div"),_l=v("label"),Lc=v("span"),Lc.textContent="Save to file",hZ=K(),kc=v("div"),Qb=v("input"),Aa=K(),Hb=v("button"),OG.c(),tm=K(),RZ=v("section"),ub=v("button"),ra=NI("Cancel"),t(G,"class","svelte-iqd8ho"),t(Z,"type","text"),t(Z,"placeholder","Filter choices"),t(Z,"autocapitalize","off"),t(Z,"autocorrect","off"),t(Z,"spellcheck",W=!1),t(Z,"class","svelte-iqd8ho"),t(N,"type","button"),t(N,"class","svelte-iqd8ho"),t(a,"type","button"),t(a,"class","svelte-iqd8ho"),t(m,"class","controlButtons svelte-iqd8ho"),t(c,"class","controls svelte-iqd8ho"),t(h,"class","choiceList svelte-iqd8ho"),t(p,"class","svelte-iqd8ho"),t(R,"class","svelte-iqd8ho"),t(s,"class","svelte-iqd8ho"),t(f,"class","svelte-iqd8ho"),t(k,"class","svelte-iqd8ho"),t(B,"class","svelte-iqd8ho"),t(o,"class","svelte-iqd8ho"),t(tI,"class","svelte-iqd8ho"),t(vI,"class","svelte-iqd8ho"),t(eb,"class","svelte-iqd8ho"),t(tG,"class","svelte-iqd8ho"),t(Q,"class","summaryGrid svelte-iqd8ho"),t(X,"class","summary svelte-iqd8ho"),t(Vl,"type","button"),t(Vl,"class","secondary svelte-iqd8
|
||
|
|
`)}}).join(`
|
||
|
|
`)}}var WE=b=>b.join(""),a3=b=>b.split(/\b/),V3=ZE("<<<<<<< YOUR CHANGES","=======",">>>>>>> APP AUTHORS CHANGES",WE),h3={splitFunction:a3,joinFunction:WE,conflictFunction:V3};function _X(b,I,G,l={}){l=Object.assign({},h3,l);let[c,Z,W]=[b,I,G].map(N=>l.splitFunction.call(l,N)),d=Ca.merge(c,Z,W);return ia.collateMerge(d,l.joinFunction,l.conflictFunction)}var dE=_X;var YE=require("obsidian");function mE(b,I){return b.line===I.line}function n3(b){let I=[];return b.forEach((G,l)=>{let c=G.match(/^(#+)[\s]+(.*)$/);c&&I.push({level:c[1].length,text:c[2],line:l})}),I}function cn(b,I,G=!1){let l=n3(b),c=l.find(N=>N.line===I),Z=!!c;if(!Z&&G)throw new Error(`Target line ${I} is not a heading, but we are trying to find the end of its section.`);if(!Z&&!G){let N=NE(b,I,Y=>Y.trim()==="");return N!==null&&N>I?N-1:I}let W=b.length-1,d=R3(c,l,b,G),m=X3(b,d,N=>N.trim()!=="");if(m!==null){if(m<I)return I;let N=b[m+1].trim()==="";return m+1===W&&!N?d:m===0?m+1:m}return d}function R3(b,I,G,l){let c=I.findIndex(Y=>mE(Y,b)),Z=c===I.length-1,W=G.length-1;if(Z)return W;let[d,m]=F3(b,I);if(m&&d===I.length)return W;if(m&&l)return I[d].line-1;if(m&&!l)return I[c+1].line;if(!l&&!m){let Y=t3(b.line,I);return Y===null?W:Y}return W}function F3(b,I){let G=I.findIndex(c=>mE(c,b)),l=NE(I,G,c=>c.level<=b.level);return l===null?[-1,!1]:[l,!0]}function t3(b,I){let G=I.findIndex(l=>l.line>b);return G===-1?null:G}function X3(b,I,G){for(let l=I-1;l>=0;l--)if(G(b[l]))return l;return null}function NE(b,I,G){for(let l=I+1;l<b.length;l++)if(G(b[l]))return l;return null}var Zn=class extends rb{constructor(){super(...arguments);this.file=null;this.fileContent="";this.sourcePath=null;this.templaterProcessed=!1}setDestinationFile(G){this.file=G,this.sourcePath=G.path}setDestinationSourcePath(G){this.sourcePath=G,this.file=null}getLinkSourcePath(){return this.sourcePath??this.file?.path??null}getCurrentFileLink(){let G=this.app.workspace.getActiveFile();if(!G)return null;let l=this.sourcePath??this.file?.path??"";return this.app.fileManager.generateMarkdownLink(G,l)}async formatContentWithFile(G,l,c,Z){if(this.choice=l,this.file=Z,this.fileContent=c,!l||!Z||c===null)return G;let W=l.insertAfter.enabled||l.prepend||!l.captureToActiveFile||l.activeFileWritePosition==="top";return await this.formatFileContent(G,W)}async formatContent(G,l){return this.choice=l,l?await this.formatFileContent(G):G}async formatFileContent(G,l=!0){let c=await super.formatFileContent(G);if(c=this.replaceLinebreakInString(c),l&&this.file&&!this.templaterProcessed){let d=await Yd(this.app,c,this.file);d&&(c=d),this.templaterProcessed=!0}if(c.trim()==="")return this.fileContent;if(this.choice.prepend){let d=!this.choice.task;return`${this.fileContent}${d?`
|
||
|
|
`:""}${c}`}if(this.choice.insertAfter.enabled)return await this.insertAfterHandler(c);let W=this.file?this.getFrontmatterEndPosition(this.file,this.fileContent):null;return W==null||W<0?`${c}${this.fileContent}`:this.insertTextAfterPositionInBody(c,this.fileContent,W)}async formatContentOnly(G){let l=await super.formatFileContent(G);return l=this.replaceLinebreakInString(l),l.trim()===""?this.fileContent:l}normalizeTarget(G){return G.replace("\\n","").trimEnd()}findInsertAfterIndex(G,l){let c=this.normalizeTarget(l),Z=-1;for(let W=0;W<G.length;W++){let d=G[W].trimStart();if(d===c)return W;if(d.startsWith(c)){let N=d.slice(c.length);if(/^\s*$/.test(N))return W;Z===-1&&(Z=W);continue}let m=d.indexOf(c);if(m!==-1){let N=d.slice(m+c.length);if(/^\s*$/.test(N))return W;Z===-1&&(Z=W)}}return Z}async insertAfterHandler(G){let l=await this.formatLocationString(this.choice.insertAfter.after),c=qt(this.fileContent),Z=this.findInsertAfterIndex(c,l);if(Z===-1){if(this.choice.insertAfter?.createIfNotFound)return await this.createInsertAfterIfNotFound(G);IG(new Error("Unable to find insert after line in file"),"Insert After Error")}if(this.choice.insertAfter?.insertAtEnd){if(!this.file)throw new Error("Tried to get sections without file.");Z=cn(c,Z,!!this.choice.insertAfter.considerSubsections)??c.length-1}return this.insertTextAfterPositionInBody(G,this.fileContent,Z)}async createInsertAfterIfNotFound(G){let c=`${this.replaceLinebreakInString(await this.formatLocationString(this.choice.insertAfter.after))}
|
||
|
|
${G}`;if(this.choice.insertAfter?.createIfNotFoundLocation===em){let Z=this.file?this.getFrontmatterEndPosition(this.file,this.fileContent):-1;return this.insertTextAfterPositionInBody(c,this.fileContent,Z)}if(this.choice.insertAfter?.createIfNotFoundLocation===Ka)return`${this.fileContent}
|
||
|
|
${c}`;if(this.choice.insertAfter?.createIfNotFoundLocation===Da)try{let Z=this.app.workspace.getActiveViewOfType(YE.MarkdownView);if(!Z)throw new Error("No active view.");let d=Z.editor.getCursor().line;if(this.choice.insertAfter?.insertAtEnd){if(!this.file)throw new Error("Tried to get sections without file.");let N=qt(this.fileContent);d=cn(N,d,!!this.choice.insertAfter.considerSubsections)??N.length-1}return this.insertTextAfterPositionInBody(c,this.fileContent,d)}catch(Z){IG(Z,`Unable to insert line '${this.choice.insertAfter.after}' at cursor position`)}}getFrontmatterEndPosition(G,l){let c=this.app.metadataCache.getFileCache(G);if(c?.frontmatterPosition)return c.frontmatterPosition.end.line;if(l){let Z=this.inferFrontmatterEndLineFromContent(l);if(Z!==null)return Z}return M.logMessage("could not get frontmatter. Maybe there isn't any."),-1}inferFrontmatterEndLineFromContent(G){let l=xV(G);if(!l)return null;let c=G.slice(0,l[1]),Z=c.split(/\r?\n/);return Z.length===0?null:c.endsWith(`
|
||
|
|
`)?Z.length-2:Z.length-1}insertTextAfterPositionInBody(G,l,c){if(c===-1){let m=!this.choice.task;return`${G}${m?`
|
||
|
|
`:""}${l}`}let Z=l.split(`
|
||
|
|
`),W=Z.slice(0,c+1).join(`
|
||
|
|
`),d=Z.slice(c+1).join(`
|
||
|
|
`);return`${W}
|
||
|
|
${G}${d}`}};function aE(b){return b.captureToActiveFile&&b.newLineCapture?.enabled?b.newLineCapture.direction==="above"?"newLineAbove":"newLineBelow":b.captureToActiveFile&&!b.prepend&&!b.insertAfter.enabled?b.activeFileWritePosition==="top"?"activeFileTop":"currentLine":b.insertAfter.enabled?"insertAfter":b.prepend?"prepend":"append"}var VE=4e3,Wn=class extends Bd{constructor(G,l,c,Z){super(G);this.choiceExecutor=Z;this.capturePropertyVars=new Map;this.choice=c,this.plugin=l,this.formatter=new Zn(G,l,Z)}showSuccessNotice(G,{wasNewFile:l,action:c}){let Z=`'${G.basename}'`;if(l){new $X.Notice(`Created and captured to ${Z}`,VE);return}let W="";switch(c){case"currentLine":W=`Captured to current line in ${Z}`;break;case"prepend":case"activeFileTop":W=`Captured to top of ${Z}`;break;case"append":W=`Captured to ${Z}`;break;case"insertAfter":{let d=this.choice.insertAfter.after;W=d?`Captured to ${Z} under '${d}'`:`Captured to ${Z}`;break}}new $X.Notice(W,VE)}async run(){try{this.capturePropertyVars.clear();let G=qc(this.choice.appendLink);this.formatter.setLinkToCurrentFileBehavior(G.enabled&&!G.requireActiveFile?"optional":"required");let l=await this.getFormattedPathToCaptureTo(this.choice.captureToActiveFile),c=this.getCaptureContent(),Z,W=await this.fileExists(l);if(W)Z=this.onFileExists.bind(this);else if(this.choice?.createFileIfItDoesntExist?.enabled)Z=(V,h,n)=>this.onCreateFileIfItDoesntExist(V,h,G);else{M.logWarning(`The file ${l} does not exist and "Create file if it doesn't exist" is disabled.`);return}let{file:d,newFileContent:m,captureContent:N}=await Z(l,c),Y=aE(this.choice);if(Y==="currentLine"||Y==="newLineAbove"||Y==="newLineBelow"){let V=await Yd(this.app,N,d);switch(Y){case"currentLine":iH(V,this.app);break;case"newLineAbove":AH(V,this.app);break;case"newLineBelow":rH(V,this.app);break}}else await this.app.vault.modify(d,m),this.choice.templater?.afterCapture==="wholeFile"&&await Nd(this.app,d),await this.applyCapturePropertyVars(d);if(this.plugin.settings.showCaptureNotification&&this.showSuccessNotice(d,{wasNewFile:!W,action:Y}),G.enabled&&rV(this.app,d,G),this.choice.openFile&&d){let V=this.choice.fileOpening.focus??!0;LV(this.app,d,V)||await ad(this.app,d,this.choice.fileOpening),await AV(this.app,d)}}catch(G){if(WZ(G,{logPrefix:"Capture execution aborted",noticePrefix:"Capture execution aborted",defaultReason:"Capture aborted"})){this.choiceExecutor.signalAbort?.(G);return}IG(G,`Error running capture choice "${this.choice.name}"`)}}getCaptureContent(){let G;return this.choice.format.enabled?G=this.choice.format.format:G=QZ,this.choice.task&&(G=`- [ ] ${G}
|
||
|
|
`),G}async getFormattedPathToCaptureTo(G){let l=this.choiceExecutor?.variables?.get(um);if(!G&&l&&typeof l=="string"&&l.length>0)return l;if(G){let Y=this.app.workspace.getActiveFile();return Dl(Y,"Cannot capture to active file - no active file."),Y.path}let c=this.choice.captureTo,Z=await this.formatFilePath(c),W=Z.replace(/^\/$|\/\.md$|^\.md$/,""),d=W==="",m=d||kV(this.app,W),N=Z.startsWith("#");if(m)return this.selectFileInFolder(W,d);if(N){let Y=Z.replace(/\.md$/,"");return this.selectFileWithTag(Y)}return Z}async selectFileInFolder(G,l){let c=G.endsWith("/")||l?G:`${G}/`,Z=Pc(this.app,c);Dl(Z.length>0,`Folder ${c} is empty.`);let W=Z.map(N=>N.path),d;try{d=await vl.Suggest(this.app,W.map(N=>N.replace(c,"")),W)}catch(N){throw XG(N)?new qI("Input cancelled by user"):N}Dl(!!d&&d.length>0,"No file selected for capture.");let m=d.startsWith(`${c}`)?d:`${c}/${d}`;return await this.formatFilePath(m)}async selectFileWithTag(G){let l=G.startsWith("#")?G:`#${G}`,c=zV(this.app,l);Dl(c.length>0,`No files with tag ${G}.`);let Z=c.map(d=>d.path),W;try{W=await vl.Suggest(this.app,Z,Z)}catch(d){throw XG(d)?new qI("Input cancelled by user"):d}return Dl(!!W&&W.length>0,"No file selected for capture."),await this.formatFilePath(W)}async onFileExists(G,l){let c=this.getFileByPath(G);if(!c)throw new Error("File not found");this.formatter.setTitle(c.basename),this.formatter.setDestinationFile(c);let Z=await this.formatter.formatContentOnly(l);this.mergeCapturePropertyVars(this.formatter.getAndClearTemplatePropertyVars());let W=await this.app.vault.read(c),d=await this.formatter.formatContentWithFile(Z,this.choice,W,c);this.mergeCapturePropertyVars(this.formatter.getAndClearTemplatePropertyVars());let m=await this.app.vault.read(c),N=d;if(m!==W){let Y=dE(m,W,d);Dl(!Y.isSuccess,()=>`The file ${G} has been modified since the last read.
|
||
|
|
QuickAdd could not merge the versions two without conflicts, and will not modify the file.
|
||
|
|
This is in order to prevent data loss.`),N=Y.joinedResults()}return{file:c,newFileContent:N,captureContent:Z}}async onCreateFileIfItDoesntExist(G,l,c){let Z=G.split("/").pop()?.replace(/\.md$/,"")||"";this.formatter.setTitle(Z),this.formatter.setDestinationSourcePath(G);let W=await this.formatter.formatContentOnly(l);this.mergeCapturePropertyVars(this.formatter.getAndClearTemplatePropertyVars());let d="";if(this.choice.createFileIfItDoesntExist.createWithTemplate){let a=new dZ(this.app,this.plugin,this.choice.createFileIfItDoesntExist.template,this.choiceExecutor);c?.enabled&&!c.requireActiveFile&&a.setLinkToCurrentFileBehavior("optional"),d=await a.run();let V=a.getAndClearTemplatePropertyVars();M.logMessage(`CaptureChoiceEngine: Collected ${V.size} template property variables`),V.size>0&&M.logMessage(`Variables: ${Array.from(V.keys()).join(", ")}`),this.templatePropertyVars=V}let m=await this.createFileWithInput(G,d,{suppressTemplaterOnCreate:this.choice.createFileIfItDoesntExist.createWithTemplate});this.choice.createFileIfItDoesntExist.createWithTemplate&&this.templatePropertyVars&&this.shouldPostProcessFrontMatter(m,this.templatePropertyVars)&&await this.postProcessFrontMatter(m,this.templatePropertyVars),this.choice.createFileIfItDoesntExist.createWithTemplate&&d?await Nd(this.app,m):gV(this.app)&&await oH(this.app,m);let N=await this.app.vault.read(m),Y=await this.formatter.formatContentWithFile(W,this.choice,N,m);return this.mergeCapturePropertyVars(this.formatter.getAndClearTemplatePropertyVars()),{file:m,newFileContent:Y,captureContent:W}}async formatFilePath(G){let l=await this.formatter.formatFileName(G,this.choice.name);return this.normalizeMarkdownFilePath("",l)}mergeCapturePropertyVars(G){if(!(!G||G.size===0)){for(let[l,c]of G)this.capturePropertyVars.set(l,c);M.logMessage(`CaptureChoiceEngine: Accumulated ${this.capturePropertyVars.size} structured capture variables`)}}async applyCapturePropertyVars(G){if(this.capturePropertyVars.size!==0){if(!this.shouldPostProcessFrontMatter(G,this.capturePropertyVars)){this.capturePropertyVars.clear();return}M.logMessage(`CaptureChoiceEngine: Post-processing front matter with ${this.capturePropertyVars.size} capture variables`),await this.postProcessFrontMatter(G,this.capturePropertyVars),this.capturePropertyVars.clear()}}};var dn=require("obsidian");var VZ=class b extends dn.FuzzySuggestModal{constructor(G,l,c){super(G.app);this.plugin=G;this.choices=l;this.choiceExecutor=new Ac(this.app,this.plugin);c&&(this.choiceExecutor=c)}static Open(G,l,c){new b(G,l,c).open()}renderSuggestion(G,l){l.empty(),dn.MarkdownRenderer.renderMarkdown(G.item.name,l,"",this.plugin),l.classList.add("quickadd-choice-suggestion")}getItemText(G){return G.name}getItems(){return this.choices}async onChooseItem(G,l){G.type==="Multi"?this.onChooseMultiType(G):await this.choiceExecutor.execute(G)}onChooseMultiType(G){let l=[...G.choices];G.name!="\u2190 Back"&&l.push(new Ym("\u2190 Back").addChoices(this.choices)),b.Open(this.plugin,l)}};var hE=require("obsidian");var ga=class extends Sb{constructor(G,l,c){super(G);this.app=G;this.plugin=l;this.choiceExecutor=c;this.requirements=new Map;this.templatesToScan=new Set;this.dateParser=vb,c&&(this.variables=new Map(c.variables))}async scanString(G){let l=await this.replaceGlobalVarInString(G);this.scanVariableTokens(l),await this.format(l)}async format(G){let l=G;l=await this.replaceGlobalVarInString(l),l=this.replaceDateInString(l),l=this.replaceTimeInString(l),l=await this.replaceValueInString(l),l=await this.replaceSelectedInString(l),l=await this.replaceClipboardInString(l),l=await this.replaceDateVariableInString(l),l=await this.replaceVariableInString(l),l=await this.replaceFieldVarInString(l),l=await this.replaceMathValueInString(l),l=this.replaceRandomInString(l);{let c=new RegExp(LW.source,"gi"),Z;for(;(Z=c.exec(l))!==null;){let W=Z[1];W&&this.templatesToScan.add(W)}}return l}async replaceGlobalVarInString(G){let l=G,c=0,Z=new RegExp(Bc.source,"gi");for(;Z.test(l)&&!(++c>5);)l=l.replace(Z,(W,d)=>{let m=String(d??"").trim();if(!m)return W;let N
|
||
|
|
|
||
|
|
${c}
|
||
|
|
|
||
|
|
QuickAdd will now revert to backup.`),b.settings=l}}b.saveSettings()}var wE=A3;var Fm=require("obsidian");async function r3(b,I,G){let l=await fetch(`https://api.github.com/repos/${b}/${I}/releases`),c=await l.json();if(!l.ok&&"message"in c||!Array.isArray(c))throw new Error(`Failed to fetch releases: ${c.message??"Unknown error"}`);let Z=c.findIndex(W=>W.tag_name===G);if(Z===-1)throw new Error(`Could not find release with tag ${G}`);return c.slice(0,Z).filter(W=>!W.draft&&!W.prerelease)}function L3(b,I=1){let G=b.split(`
|
||
|
|
`);for(let l=0;l<G.length;l++)G[l].startsWith("#")&&(G[l]="#".repeat(I)+G[l]);return G.join(`
|
||
|
|
`)}var Yn=class extends Fm.Modal{constructor(I,G){super(I),this.previousVersion=G,this.releaseNotesPromise=r3("chhoumann","quickadd",G),this.releaseNotesPromise.then(l=>{if(this.releases=l,this.releases.length===0){this.close();return}this.display()}).catch(l=>{M.logError(`Failed to fetch release notes: ${l}`)})}onOpen(){let{contentEl:I}=this;I.empty(),I.createEl("h1",{text:"Fetching release notes..."})}onClose(){let{contentEl:I}=this;I.empty()}display(){let{contentEl:I}=this;I.empty(),I.classList.add("quickadd-update-modal-container");let G=`### New in QuickAdd v${this.releases[0].tag_name}
|
||
|
|
`,l="Thank you for using QuickAdd! If you like the plugin, please consider supporting me by buying me a coffee. With your sponsorship, I'll be able to contribute more to my existing projects, start new ones, and be more responsive to issues & feature requests.",c='<div class="quickadd-bmac-container"><a href="https://www.buymeacoffee.com/chhoumann" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 40px !important;width: 144px !important;" ></a></div>',Z=I.createDiv("quickadd-update-modal"),W=this.releases.map(Y=>Y.body).join(`
|
||
|
|
---
|
||
|
|
`),d=`And now, here is everything new in QuickAdd since your last update (v${this.previousVersion}):`,N=`${G}
|
||
|
|
${l}
|
||
|
|
${c}
|
||
|
|
I'd love to get your feedback on QuickAdd! Please fill out this <a href="https://forms.gle/WRq1ewcKK8qmkqps6">feedback form</a> to let me know what you think.
|
||
|
|
|
||
|
|
${d}
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
${L3(W)}`;Fm.MarkdownRenderer.renderMarkdown(N,Z,this.app.vault.getRoot().path,new Fm.Component)}};var UG=require("obsidian");var an=class extends UG.Modal{constructor(G,l){super(G);this.showAdvancedSettings=!1;this.settings=l,this.waitForClose=new Promise((c,Z)=>{this.rejectPromise=Z,this.resolvePromise=c}),this.open(),this.display()}get systemPromptTokenLength(){let G=ob(this.settings.model);return G?Tl(this.settings.systemPrompt,G):Number.POSITIVE_INFINITY}display(){this.contentEl.empty();let G=this.contentEl.createEl("h2",{text:`${this.settings.name} Settings`});G.style.textAlign="center",G.style.cursor="pointer",G.style.userSelect="none",G.addEventListener("click",async()=>{try{let l=await hG.Prompt(this.app,"New name",this.settings.name,this.settings.name);l&&l!==this.settings.name&&(this.settings.name=l,this.reload())}catch{}}),this.addResultJoinerSetting(this.contentEl),this.addChunkSeparatorSetting(this.contentEl),this.addMaxTokensSetting(this.contentEl),this.addMergeChunksSetting(this.contentEl),this.addModelSetting(this.contentEl),this.addOutputVariableNameSetting(this.contentEl),this.addShowAdvancedSettingsToggle(this.contentEl),this.showAdvancedSettings&&(this.settings.modelParameters||(this.settings.modelParameters={}),this.addTemperatureSetting(this.contentEl),this.addTopPSetting(this.contentEl),this.addFrequencyPenaltySetting(this.contentEl),this.addPresencePenaltySetting(this.contentEl)),this.addSystemPromptSetting(this.contentEl)}reload(){this.contentEl.empty(),this.display()}addModelSetting(G){new UG.Setting(G).setName("Model").setDesc("The model the AI Assistant will use").addDropdown(l=>{let c=$b();for(let Z of c)l.addOption(Z,Z);l.addOption("Ask me","Ask me"),l.setValue(this.settings.model),l.onChange(Z=>{this.settings.model=Z,this.reload()})})}addOutputVariableNameSetting(G){new UG.Setting(G).setName("Output variable name").setDesc("The name of the variable used to store the AI Assistant output, i.e. {{value:output}}.").addText(l=>{l.setValue(this.settings.outputVariableName).onChange(c=>{this.settings.outputVariableName=c})})}addSystemPromptSetting(G){new UG.Setting(G).setName("System Prompt").setDesc("The system prompt for the AI Assistant");let l=this.contentEl.createEl("div"),c=l.createEl("span");c.style.color="var(--text-muted-color)",l.appendChild(c);let Z=new UG.TextAreaComponent(G);Z.setValue(this.settings.systemPrompt).onChange(async N=>{this.settings.systemPrompt=N,d.innerText=await W.format(N),m()}),new Gl(this.app,Z.inputEl,fI.instance);let W=new El(this.app,fI.instance);Z.inputEl.style.width="100%",Z.inputEl.style.height="100px",Z.inputEl.style.minHeight="100px",Z.inputEl.style.marginBottom="1em";let d=this.contentEl.createEl("span"),m=(0,UG.debounce)(()=>{c.innerText=`Token count: ${this.systemPromptTokenLength}`},50);m(),(async()=>d.innerText=await W.format(this.settings.systemPrompt??""))()}addShowAdvancedSettingsToggle(G){new UG.Setting(G).setName("Show advanced settings").setDesc("Show advanced settings such as temperature, top p, and frequency penalty.").addToggle(l=>{l.setValue(this.showAdvancedSettings),l.onChange(c=>{this.showAdvancedSettings=c,this.reload()})})}addTemperatureSetting(G){new UG.Setting(G).setName("Temperature").setDesc("Sampling temperature. Higher values like 0.8 makes the output more random, whereas lower values like 0.2 will make it more focused and deterministic. The default is 1.").addSlider(l=>{l.setLimits(0,1,.1),l.setDynamicTooltip(),l.setValue(this.settings.modelParameters.temperature??1),l.onChange(c=>{this.settings.modelParameters.temperature=c})})}addTopPSetting(G){new UG.Setting(G).setName("Top P").setDesc("Nucleus sampling - consider this an alternative to temperature. The model considers the results of the tokens with top_p probability mass. 0.1 means only tokens compromising the top 10% probability mass are considered. The default is 1.").addSlider(l=>{l.setLimits(0,1,.1),l.setDynamicTooltip(),l.setValue(this.settings.modelParameters.top_p??1),l.onChange(c=>{this.settings.modelParameters.top_p=c})})}addFrequencyPenaltySetting(G){new UG.Setting(
|
||
|
|
|
||
|
|
/* nosourcemap */
|