vault backup: 2025-10-21 15:57:10

This commit is contained in:
CrazyJasonwell committed 2025-10-21 15:57:10 +08:00
1 parent a540f5b81a
commit 6f343b7538
38 files changed
+44893 -4450

No files matched your search

+3 -1
View File
@@ -4,12 +4,14 @@
"devMode": false,
"templateFolderPath": "",
"announceUpdates": true,
"version": "2.4.0",
"version": "2.6.0",
"globalVariables": {},
"onePageInputEnabled": false,
"disableOnlineFeatures": true,
"enableRibbonIcon": false,
"showCaptureNotification": true,
"showInputCancellationNotification": false,
"enableTemplatePropertyTypes": false,
"ai": {
"defaultModel": "Ask me",
"defaultSystemPrompt": "As an AI assistant within Obsidian, your primary goal is to help users manage their ideas and knowledge more effectively. Format your responses using Markdown syntax. Please use the [[Obsidian]] link format. You can write aliases for the links by writing [[Obsidian|the alias after the pipe symbol]]. To use mathematical notation, use LaTeX syntax. LaTeX syntax for larger equations should be on separate lines, surrounded with double dollar signs ($$). You can also inline math expressions by wrapping it in $ symbols. For example, use $$w_{ij}^{\text{new}}:=w_{ij}^{\text{current}}+etacdotdelta_jcdot x_{ij}$$ on a separate line, but you can write \"($eta$ = learning rate, $delta_j$ = error term, $x_{ij}$ = input)\" inline.",
+56 -48
View File
@@ -3,86 +3,94 @@ THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
var lw=Object.create;var Ud=Object.defineProperty;var bw=Object.getOwnPropertyDescriptor;var Zw=Object.getOwnPropertyNames;var cw=Object.getPrototypeOf,Ww=Object.prototype.hasOwnProperty;var dw=(b,I,G)=>I in b?Ud(b,I,{enumerable:!0,configurable:!0,writable:!0,value:G}):b[I]=G;var bV=(b,I)=>()=>(I||b((I={exports:{}}).exports,I),I.exports),Vl=(b,I)=>{for(var G in I)Ud(b,G,{get:I[G],enumerable:!0})},Sp=(b,I,G,l)=>{if(I&&typeof I=="object"||typeof I=="function")for(let Z of Zw(I))!Ww.call(b,Z)&&Z!==G&&Ud(b,Z,{get:()=>I[Z],enumerable:!(l=bw(I,Z))||l.enumerable});return b};var JI=(b,I,G)=>(G=b!=null?lw(cw(b)):{},Sp(I||!b||!b.__esModule?Ud(G,"default",{value:b,enumerable:!0}):G,b)),mw=b=>Sp(Ud({},"__esModule",{value:!0}),b);var j=(b,I,G)=>dw(b,typeof I!="symbol"?I+"":I,G);var LQ=bV((o2,i2)=>{(function(b,I){typeof o2=="object"&&typeof i2<"u"?i2.exports=I():typeof define=="function"&&define.amd?define(I):(b=typeof globalThis<"u"?globalThis:b||self).dayjs_plugin_quarterOfYear=I()})(o2,function(){"use strict";var b="month",I="quarter";return function(G,l){var Z=l.prototype;Z.quarter=function(d){return this.$utils().u(d)?Math.ceil((this.month()+1)/3):this.month(this.month()%3+3*(d-1))};var c=Z.add;Z.add=function(d,m){return d=Number(d),this.$utils().p(m)===I?this.add(3*d,b):c.bind(this)(d,m)};var W=Z.startOf;Z.startOf=function(d,m){var N=this.$utils(),Y=!!N.u(m)||m;if(N.p(d)===I){var V=this.quarter()-1;return Y?this.month(3*V).startOf(b).startOf("day"):this.month(3*V+2).endOf(b).endOf("day")}return W.bind(this)(d,m)}}})});var oI=bV((A2,L2)=>{(function(b,I){typeof A2=="object"&&typeof L2<"u"?L2.exports=I():typeof define=="function"&&define.amd?define(I):(b=typeof globalThis<"u"?globalThis:b||self).dayjs=I()})(A2,function(){"use strict";var b=1e3,I=6e4,G=36e5,l="millisecond",Z="second",c="minute",W="hour",d="day",m="week",N="month",Y="quarter",V="year",a="date",h="Invalid Date",F=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,H=/\[([^\]]+)]|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(O){var k=["th","st","nd","rd"],E=O%100;return"["+O+(k[(E-20)%10]||k[E]||k[0])+"]"}},Q=function(O,k,E){var B=String(O);return!B||B.length>=k?O:""+Array(k+1-B.length).join(E)+O},u={s:Q,z:function(O){var k=-O.utcOffset(),E=Math.abs(k),B=Math.floor(E/60),y=E%60;return(k<=0?"+":"-")+Q(B,2,"0")+":"+Q(y,2,"0")},m:function O(k,E){if(k.date()<E.date())return-O(E,k);var B=12*(E.year()-k.year())+(E.month()-k.month()),y=k.clone().add(B,N),D=E-y<0,bI=k.clone().add(B+(D?-1:1),N);return+(-(B+(E-y)/(D?y-bI:bI-y))||0)},a:function(O){return O<0?Math.ceil(O)||0:Math.floor(O)},p:function(O){return{M:N,y:V,w:m,d,D:a,h:W,m:c,s:Z,ms:l,Q:Y}[O]||String(O||"").toLowerCase().replace(/s$/,"")},u:function(O){return O===void 0}},s="en",R={};R[s]=p;var J="$isDayjsObject",v=function(O){return O instanceof K||!(!O||!O[J])},w=function O(k,E,B){var y;if(!k)return s;if(typeof k=="string"){var D=k.toLowerCase();R[D]&&(y=D),E&&(R[D]=E,y=D);var bI=k.split("-");if(!y&&bI.length>1)return O(bI[0])}else{var YI=k.name;R[YI]=k,y=YI}return!B&&y&&(s=y),y||!B&&s},i=function(O,k){if(v(O))return O.clone();var E=typeof k=="object"?k:{};return E.date=O,E.args=arguments,new K(E)},C=u;C.l=w,C.i=v,C.w=function(O,k){return i(O,{locale:k.$L,utc:k.$u,x:k.$x,$offset:k.$offset})};var K=function(){function O(E){this.$L=w(E.locale,null,!0),this.parse(E),this.$x=this.$x||E.x||{},this[J]=!0}var k=O.prototype;return k.parse=function(E){this.$d=function(B){var y=B.date,D=B.utc;if(y===null)return new Date(NaN);if(C.u(y))return new Date;if(y instanceof Date)return new Date(y);if(typeof y=="string"&&!/Z$/i.test(y)){var bI=y.match(F);if(bI){var YI=bI[2]-1||0,tI=(bI[7]||"0").substring(0,3);return D?new Date(Date.UTC(bI[1],YI,bI[3]||1,bI[4]||0,bI[5]||0,bI[6]||0,tI)):new Date(bI[1],YI,bI[3]||1,bI[4]||0,bI[5]||0,bI[6]||0,tI)}}return new Date(y)}(E),this.init()},k.init=function(){var E=this.$d;this.$y=E.getFullYear(),this.$M=E.getMonth(),this.$D=E.getDate(),this.$W=E.getDay(),this.$H=E.getHours(),this.$m=E.getMinutes(),this.$s=E.getSeconds(),this.$ms=E.getMilliseconds()},k.$utils=function(){return C},k.isValid=function(){return this.$d.toString()!==h},k.isSame=function(E,B){var y=i(E);return this.startOf(B)<=y&&y<=this.endOf(B)},k.isAfter=function(E,B){return i(E)<this.startOf(B)},k.isBefore=function(E,B){return this.endOf(B)<i(E)},k.$g=function(E,B,y){return C.u(E)?this[B]:this.set(y,E)},k.unix=function(){return Math.floor(this.valueOf()/1e3)},k.valueOf=function(){return this.$d.getTime()},k.startOf=function(E,B){var y=this,D=!!C.u(B)||B,bI=C.p(E),YI=function(aG,MI){var U=C.w(y.$u?Date.UTC(y.$y,MI,aG):new Date(y.$y,MI,aG),y);return D?U:U.endOf(d)},tI=function(aG,MI){return C.w(y.toDate()[aG].apply(y.toDate("s"),(D?[0,0,0,0]:[23,Line truncated
`||X.charAt(f)==="\r"&&X.charAt(f+1)!==`
`)&&(T++,S===0&&(S=f+1)),f--}var XI=r+T,SI=t-S;return g[t]={line:XI,lineStart:S},{offset:t,line:XI+1,column:SI+1}}function O(X){if(!R(X))throw new Error("not a parser: "+X)}function k(X,t){return typeof X=="string"?X.charAt(t):X[t]}function E(X){if(typeof X!="number")throw new Error("not a number: "+X)}function B(X){if(typeof X!="function")throw new Error("not a function: "+X)}function y(X){if(typeof X!="string")throw new Error("not a string: "+X)}var D=2,bI=3,YI=8,tI=5*YI,HI=4*YI,EI=" ";function DI(X,t){return new Array(t+1).join(X)}function OI(X,t,g){var r=t-X.length;return r<=0?X:DI(g,r)+X}function LI(X,t,g,r){return{from:X-t>0?X-t:0,to:X+g>r?r:X+g}}function TI(X,t){var g,r,T,S,f,XI=t.index,SI=XI.offset,Zl=1;if(SI===X.length)return"Got the end of the input";if(v(X)){var BG=SI-SI%YI,Mb=SI-BG,el=LI(BG,tI,HI+YI,X.length),jb=N(function(HG){return N(function(fc){return OI(fc.toString(16),2,"0")},HG)},function(HG,fc){var Pc=HG.length,BZ=[],_c=0;if(Pc<=fc)return[HG.slice()];for(var $c=0;$c<Pc;$c++)BZ[_c]||BZ.push([]),BZ[_c].push(HG[$c]),($c+1)%fc==0&&_c++;return BZ}(X.slice(el.from,el.to).toJSON().data,YI));S=function(HG){return HG.from===0&&HG.to===1?{from:HG.from,to:HG.to}:{from:HG.from/YI,to:Math.floor(HG.to/YI)}}(el),r=BG/YI,g=3*Mb,Mb>=4&&(g+=1),Zl=2,T=N(function(HG){return HG.length<=4?HG.join(" "):HG.slice(0,4).join(" ")+" "+HG.slice(4).join(" ")},jb),(f=(8*(S.to>0?S.to-1:S.to)).toString(16).length)<2&&(f=2)}else{var qc=X.split(/\r\n|[\n\r\u2028\u2029]/);g=XI.column-1,r=XI.line-1,S=LI(r,D,bI,qc.length),T=qc.slice(S.from,S.to),f=S.to.toString().length}var Gw=r-S.from;return v(X)&&(f=(8*(S.to>0?S.to-1:S.to)).toString(16).length)<2&&(f=2),m(function(HG,fc,Pc){var BZ,_c=Pc===Gw,$c=_c?"> ":EI;return BZ=v(X)?OI((8*(S.from+Pc)).toString(16),f,"0"):OI((S.from+Pc+1).toString(),f," "),[].concat(HG,[$c+BZ+" | "+fc],_c?[EI+DI(" ",f)+" | "+OI("",g," ")+DI("^",Zl)]:[])},[],T).join(`
`)}function aG(X,t){return[`
`,"-- PARSING FAILED "+DI("-",50),`
var cE=Object.create;var Vm=Object.defineProperty;var WE=Object.getOwnPropertyDescriptor;var dE=Object.getOwnPropertyNames;var mE=Object.getPrototypeOf,NE=Object.prototype.hasOwnProperty;var YE=(b,I,G)=>I in b?Vm(b,I,{enumerable:!0,configurable:!0,writable:!0,value:G}):b[I]=G;var ya=(b,I)=>()=>(I||b((I={exports:{}}).exports,I),I.exports),yl=(b,I)=>{for(var G in I)Vm(b,G,{get:I[G],enumerable:!0})},Tp=(b,I,G,l)=>{if(I&&typeof I=="object"||typeof I=="function")for(let Z of dE(I))!NE.call(b,Z)&&Z!==G&&Vm(b,Z,{get:()=>I[Z],enumerable:!(l=WE(I,Z))||l.enumerable});return b};var UI=(b,I,G)=>(G=b!=null?cE(mE(b)):{},Tp(I||!b||!b.__esModule?Vm(G,"default",{value:b,enumerable:!0}):G,b)),aE=b=>Tp(Vm({},"__esModule",{value:!0}),b);var GI=(b,I,G)=>YE(b,typeof I!="symbol"?I+"":I,G);var rt=ya((sR,wR)=>{(function(b,I){typeof sR=="object"&&typeof wR<"u"?wR.exports=I():typeof define=="function"&&define.amd?define(I):(b=typeof globalThis<"u"?globalThis:b||self).dayjs_plugin_quarterOfYear=I()})(sR,function(){"use strict";var b="month",I="quarter";return function(G,l){var Z=l.prototype;Z.quarter=function(d){return this.$utils().u(d)?Math.ceil((this.month()+1)/3):this.month(this.month()%3+3*(d-1))};var c=Z.add;Z.add=function(d,m){return d=Number(d),this.$utils().p(m)===I?this.add(3*d,b):c.bind(this)(d,m)};var W=Z.startOf;Z.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=ya((vR,ER)=>{(function(b,I){typeof vR=="object"&&typeof ER<"u"?ER.exports=I():typeof define=="function"&&define.amd?define(I):(b=typeof globalThis<"u"?globalThis:b||self).dayjs=I()})(vR,function(){"use strict";var b=1e3,I=6e4,G=36e5,l="millisecond",Z="second",c="minute",W="hour",d="day",m="week",N="month",Y="quarter",a="year",V="date",h="Invalid Date",R=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,t=/\[([^\]]+)]|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(r){var z=["th","st","nd","rd"],L=r%100;return"["+r+(z[(L-20)%10]||z[L]||z[0])+"]"}},e=function(r,z,L){var w=String(r);return!w||w.length>=z?r:""+Array(z+1-w.length).join(L)+r},H={s:e,z:function(r){var z=-r.utcOffset(),L=Math.abs(z),w=Math.floor(L/60),i=L%60;return(z<=0?"+":"-")+e(w,2,"0")+":"+e(i,2,"0")},m:function r(z,L){if(z.date()<L.date())return-r(L,z);var w=12*(L.year()-z.year())+(L.month()-z.month()),i=z.clone().add(w,N),C=L-i<0,B=z.clone().add(w+(C?-1:1),N);return+(-(w+(L-i)/(C?i-B:B-i))||0)},a:function(r){return r<0?Math.ceil(r)||0:Math.floor(r)},p:function(r){return{M:N,y:a,w:m,d,D:V,h:W,m:c,s:Z,ms:l,Q:Y}[r]||String(r||"").toLowerCase().replace(/s$/,"")},u:function(r){return r===void 0}},s="en",F={};F[s]=p;var J="$isDayjsObject",E=function(r){return r instanceof k||!(!r||!r[J])},Q=function r(z,L,w){var i;if(!z)return s;if(typeof z=="string"){var C=z.toLowerCase();F[C]&&(i=C),L&&(F[C]=L,i=C);var B=z.split("-");if(!i&&B.length>1)return r(B[0])}else{var M=z.name;F[M]=z,i=M}return!w&&i&&(s=i),i||!w&&s},g=function(r,z){if(E(r))return r.clone();var L=typeof z=="object"?z:{};return L.date=r,L.args=arguments,new k(L)},o=H;o.l=Q,o.i=E,o.w=function(r,z){return g(r,{locale:z.$L,utc:z.$u,x:z.$x,$offset:z.$offset})};var k=function(){function r(L){this.$L=Q(L.locale,null,!0),this.parse(L),this.$x=this.$x||L.x||{},this[J]=!0}var z=r.prototype;return z.parse=function(L){this.$d=function(w){var i=w.date,C=w.utc;if(i===null)return new Date(NaN);if(o.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(R);if(B){var M=B[2]-1||0,_=(B[7]||"0").substring(0,3);return C?new Date(Date.UTC(B[1],M,B[3]||1,B[4]||0,B[5]||0,B[6]||0,_)):new Date(B[1],M,B[3]||1,B[4]||0,B[5]||0,B[6]||0,_)}}return new Date(i)}(L),this.init()},z.init=function(){var L=this.$d;this.$y=L.getFullYear(),this.$M=L.getMonth(),this.$D=L.getDate(),this.$W=L.getDay(),this.$H=L.getHours(),this.$m=L.getMinutes(),this.$s=L.getSeconds(),this.$ms=L.getMilliseconds()},z.$utils=function(){return o},z.isValid=function(){return this.$d.toString()!==h},z.isSame=function(L,w){var i=g(L);return this.startOf(w)<=i&&i<=this.endOf(w)},z.isAfter=function(L,w){return g(L)<this.startOf(w)},z.isBefore=function(L,w){return this.endOf(w)<g(L)},z.$g=function(L,w,i){return o.u(L)?this[w]:this.set(i,L)},z.unix=function(){return Math.floor(this.valueOf()/1e3)},z.valueOf=function(){return this.$d.getTime()},z.startOf=function(L,w){var i=this,C=!!o.u(w)||w,B=o.p(L),M=function(EI,PI){var hG=o.w(i.$u?Date.UTC(i.$y,PI,EI):new Date(i.$y,PI,EI),i);return C?hG:hG.endOf(d)},_=function(EI,PI){return o.w(i.toDate()[EI].apply(i.toDate("s"),(C?[0,0,0,0]:[23,59,59,999]).slice(PI)),i)},YLine truncated
`||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 r(u){if(!F(u))throw new Error("not a parser: "+u)}function z(u,A){return typeof u=="string"?u.charAt(A):u[A]}function L(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 C=2,B=3,M=8,_=5*M,YI=4*M,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 XI(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,wG=1;if(_I===u.length)return"Got the end of the input";if(E(u)){var lG=_I-_I%M,_l=_I-lG,UG=XI(lG,_,YI+M,u.length),BG=N(function(gG){return N(function(eW){return vI(eW.toString(16),2,"0")},gG)},function(gG,eW){var QW=gG.length,hc=[],HW=0;if(QW<=eW)return[gG.slice()];for(var uW=0;uW<QW;uW++)hc[HW]||hc.push([]),hc[HW].push(gG[uW]),(uW+1)%eW==0&&HW++;return hc}(u.slice(UG.from,UG.to).toJSON().data,M));II=function(gG){return gG.from===0&&gG.to===1?{from:gG.from,to:gG.to}:{from:gG.from/M,to:Math.floor(gG.to/M)}}(UG),D=lG/M,x=3*_l,_l>=4&&(x+=1),wG=2,$=N(function(gG){return gG.length<=4?gG.join(" "):gG.slice(0,4).join(" ")+" "+gG.slice(4).join(" ")},BG),(P=(8*(II.to>0?II.to-1:II.to)).toString(16).length)<2&&(P=2)}else{var OG=u.split(/\r\n|[\n\r\u2028\u2029]/);x=hI.column-1,D=hI.line-1,II=XI(D,C,B,OG.length),$=OG.slice(II.from,II.to),P=II.to.toString().length}var RG=D-II.from;return E(u)&&(P=(8*(II.to>0?II.to-1:II.to)).toString(16).length)<2&&(P=2),m(function(gG,eW,QW){var hc,HW=QW===RG,uW=HW?"> ":aI;return hc=E(u)?vI((8*(II.from+QW)).toString(16),P,"0"):vI((II.from+QW+1).toString(),P," "),[].concat(gG,[uW+hc+" | "+eW],HW?[aI+QI(" ",P)+" | "+vI("",x," ")+QI("^",wG)]:[])},[],$).join(`
`)}function EI(u,A){return[`
`,"-- PARSING FAILED "+QI("-",50),`
`,TI(X,t),`
`,VI(u,A),`
`,(g=t.expected,g.length===1?`Expected:
`,(x=A.expected,x.length===1?`Expected:
`+g[0]:`Expected one of the following:
`+x[0]:`Expected one of the following:
`+g.join(", ")),`
`].join("");var g}function MI(X){return X.flags!==void 0?X.flags:[X.global?"g":"",X.ignoreCase?"i":"",X.multiline?"m":"",X.unicode?"u":"",X.sticky?"y":""].join("")}function U(){for(var X=[].slice.call(arguments),t=X.length,g=0;g<t;g+=1)O(X[g]);return c(function(r,T){for(var S,f=new Array(t),XI=0;XI<t;XI+=1){if(!(S=C(X[XI]._(r,T),S)).status)return S;f[XI]=S.value,T=S.index}return C(w(T,f),S)})}function pI(){var X=[].slice.call(arguments);if(X.length===0)throw new Error("seqMap needs at least one argument");var t=X.pop();return B(t),U.apply(null,X).map(function(g){return t.apply(null,g)})}function uI(){var X=[].slice.call(arguments),t=X.length;if(t===0)return xZ("zero alternates");for(var g=0;g<t;g+=1)O(X[g]);return c(function(r,T){for(var S,f=0;f<X.length;f+=1)if((S=C(X[f]._(r,T),S)).status)return S;return S})}function TG(X,t){return Kc(X,t).or(ub([]))}function Kc(X,t){return O(X),O(t),pI(X,t.then(X).many(),function(g,r){return[g].concat(r)})}function zZ(X){y(X);var t="'"+X+"'";return c(function(g,r){var T=r+X.length,S=g.slice(r,T);return S===X?w(T,S):i(r,t)})}function lb(X,t){(function(T){if(!(T instanceof RegExp))throw new Error("not a regexp: "+T);for(var S=MI(T),f=0;f<S.length;f++){var XI=S.charAt(f);if(XI!=="i"&&XI!=="m"&&XI!=="u"&&XI!=="s")throw new Error('unsupported regexp flag "'+XI+'": '+T)}})(X),arguments.length>=2?E(t):t=0;var g=function(T){return RegExp("^(?:"+T.source+")",MI(T))}(X),r=""+X;return c(function(T,S){var f=g.exec(T.slice(S));if(f){if(0<=t&&t<=f.length){var XI=f[0],SI=f[t];return w(S+XI.length,SI)}return i(S,"valid match group (0 to "+f.length+") in "+r)}return i(S,r)})}function ub(X){return c(function(t,g){return w(g,X)})}function xZ(X){return c(function(t,g){return i(g,X)})}function Dc(X){if(R(X))return c(function(t,g){var r=X._(t,g);return r.index=g,r.value="",r});if(typeof X=="string")return Dc(zZ(X));if(X instanceof RegExp)return Dc(lb(X));throw new Error("not a string, regexp, or parser: "+X)}function $Y(X){return O(X),c(function(t,g){var r=X._(t,g),T=t.slice(g,r.index);return r.status?i(g,'not "'+T+'"'):w(g,null)})}function il(X){return B(X),c(function(t,g){var r=k(t,g);return g<t.length&&X(r)?w(g+1,r):i(g,"a character/byte matching "+X)})}function UZ(X,t){arguments.length<2&&(t=X,X=void 0);var g=c(function(r,T){return g._=t()._,g._(r,T)});return X?g.desc(X):g}function Tc(){return xZ("fantasy-land/empty")}W.parse=function(X){if(typeof X!="string"&&!v(X))throw new Error(".parse must be called with a string or Buffer as its argument");var t,g=this.skip(Sc)._(X,0);return t=g.status?{status:!0,value:g.value}:{status:!1,index:GI(X,g.furthest),expected:g.expected},delete K[X],t},W.tryParse=function(X){var t=this.parse(X);if(t.status)return t.value;var g=aG(X,t),r=new Error(g);throw r.type="ParsimmonError",r.result=t,r},W.assert=function(X,t){return this.chain(function(g){return X(g)?ub(g):xZ(t)})},W.or=function(X){return uI(this,X)},W.trim=function(X){return this.wrap(X,X)},W.wrap=function(X,t){return pI(X,this,t,function(g,r){return r})},W.thru=function(X){return X(this)},W.then=function(X){return O(X),U(this,X).map(function(t){return t[1]})},W.many=function(){var X=this;return c(function(t,g){for(var r=[],T=void 0;;){if(!(T=C(X._(t,g),T)).status)return C(w(g,r),T);if(g===T.index)throw new Error("infinite loop detected in .many() parser --- calling .many() on a parser which can accept zero characters is usually the cause");g=T.index,r.push(T.value)}})},W.tieWith=function(X){return y(X),this.map(function(t){if(function(T){if(!J(T))throw new Error("not an array: "+T)}(t),t.length){y(t[0]);for(var g=t[0],r=1;r<t.length;r++)y(t[r]),g+=X+t[r];return g}return""})},W.tie=function(){return this.tieWith("")},W.times=function(X,t){var g=this;return arguments.length<2&&(t=X),E(X),E(t),c(function(r,T){for(var S=[],f=void 0,XI=void 0,SI=0;SI<X;SI+=1){if(XI=C(f=g._(r,T),XI),!f.status)return XI;T=f.index,S.push(f.value)}for(;SI<t&&(XI=C(f=g._(r,T),XI),f.status);SI+=1)T=f.index,S.push(f.value);return C(w(T,S),XI)})},W.result=function(X){return this.map(function(){return X})},W.atMost=function(X){return this.times(0,X)},W.atLeast=function(X){return pI(this.times(X),this.many(),function(t,g){return t.concat(g)})},W.map=function(X){B(X);var t=this;return c(function(g,r){var T=t._(g,r);return T.status?C(w(T.index,X(T.value)),T):T})},W.contramap=function(X){B(X);var t=this;return c(function(g,r){var T=t.parse(X(g.slice(r)));return T.status?w(r+g.length,T.value):T})},W.promap=function(X,t){return B(X),B(t),this.contramap(X).map(t)},W.skip=function(X){return U(this,X).map(function(t){return t[0]})},W.mark=function(){return pI(VZ,this,VZ,function(X,t,g){return{start:X,value:t,end:g}})},W.node=function(X){return pI(VZ,this,VZ,function(t,g,r){return{name:X,value:g,start:t,end:r}})},W.sepBy=function(X){return TG(this,X)},W.sepBy1=function(X){return Kc(this,X)},W.lookahead=function(X){return this.skip(Dc(X))},W.notFollowedBy=function(X){return this.skip($Y(X))},W.desc=function(X){J(X)||(X=[X]);var t=this;ret Line truncated
`),Dp=zZ(`\r
`),Tp=uI(Dp,Kp,jp).desc("newline"),Iw=uI(Tp,Sc);c.all=IV,c.alt=uI,c.any=xd,c.cr=jp,c.createLanguage=function(X){var t={};for(var g in X)({}).hasOwnProperty.call(X,g)&&function(r){t[r]=UZ(function(){return X[r](t)})}(g);return t},c.crlf=Dp,c.custom=function(X){return c(X(w,i))},c.digit=GV,c.digits=lV,c.empty=Tc,c.end=Iw,c.eof=Sc,c.fail=xZ,c.formatError=aG,c.index=VZ,c.isParser=R,c.lazy=UZ,c.letter=fs,c.letters=Ps,c.lf=Kp,c.lookahead=Dc,c.makeFailure=i,c.makeSuccess=w,c.newline=Tp,c.noneOf=function(X){return il(function(t){return X.indexOf(t)<0}).desc("none of '"+X+"'")},c.notFollowedBy=$Y,c.of=ub,c.oneOf=function(X){for(var t=X.split(""),g=0;g<t.length;g++)t[g]="'"+t[g]+"'";return il(function(r){return X.indexOf(r)>=0}).desc(t)},c.optWhitespace=_s,c.Parser=c,c.range=function(X,t){return il(function(g){return X<=g&&g<=t}).desc(X+"-"+t)},c.regex=lb,c.regexp=lb,c.sepBy=TG,c.sepBy1=Kc,c.seq=U,c.seqMap=pI,c.seqObj=function(){for(var X,t={},g=0,r=(X=arguments,Array.prototype.slice.call(X)),T=r.length,S=0;S<T;S+=1){var f=r[S];if(!R(f)){if(J(f)&&f.length===2&&typeof f[0]=="string"&&R(f[1])){var XI=f[0];if(Object.prototype.hasOwnProperty.call(t,XI))throw new Error("seqObj: duplicate key "+XI);t[XI]=!0,g++;continue}throw new Error("seqObj arguments must be parsers or [string, parser] array pairs.")}}if(g===0)throw new Error("seqObj expects at least one named parser, found zero");return c(function(SI,Zl){for(var BG,Mb={},el=0;el<T;el+=1){var jb,qc;if(J(r[el])?(jb=r[el][0],qc=r[el][1]):(jb=null,qc=r[el]),!(BG=C(qc._(SI,Zl),BG)).status)return BG;jb&&(Mb[jb]=BG.value),Zl=BG.index}return C(w(Zl,Mb),BG)})},c.string=zZ,c.succeed=ub,c.takeWhile=function(X){return B(X),c(function(t,g){for(var r=g;r<t.length&&X(k(t,r));)r++;return w(r,t.slice(g,r))})},c.test=il,c.whitespace=$s,c["fantasy-land/empty"]=Tc,c["fantasy-land/of"]=ub,c.Binary={bitSeq:h,bitSeqObj:function(X){a();var t={},g=0,r=N(function(S){if(J(S)){var f=S;if(f.length!==2)throw new Error("["+f.join(", ")+"] should be length 2, got length "+f.length);if(y(f[0]),E(f[1]),Object.prototype.hasOwnProperty.call(t,f[0]))throw new Error("duplicate key in bitSeqObj: "+f[0]);return t[f[0]]=!0,g++,f}return E(S),[null,S]},X);if(g<1)throw new Error("bitSeqObj expects at least one named pair, got ["+X.join(", ")+"]");var T=N(function(S){return S[0]},r);return h(N(function(S){return S[1]},r)).map(function(S){return m(function(f,XI){return XI[0]!==null&&(f[XI[0]]=XI[1]),f},{},N(function(f,XI){return[f,S[XI]]},T))})},byte:function(X){if(a(),E(X),X>255)throw new Error("Value specified to byte constructor ("+X+"=0x"+X.toString(16)+") is larger in value than a single byte.");var t=(X>15?"0x":"0x0")+X.toString(16);return c(function(g,r){var T=k(g,r);return T===X?w(r+1,T):i(r,t)})},buffer:function(X){return F("buffer",X).map(function(t){return Buffer.from(t)})},encodedString:function(X,t){return F("string",t).map(function(g){return g.toString(X)})},uintBE:p,uint8BE:p(1),uint16BE:p(2),uint32BE:p(4),uintLE:Q,uint8LE:Q(1),uint16LE:Q(2),uint32LE:Q(4),intBE:u,int8BE:u(1),int16BE:u(2),int32BE:u(4),intLE:s,int8LE:s(1),int16LE:s(2),int32LE:s(4),floatBE:F("floatBE",4).map(function(X){return X.readFloatBE(0)}),floatLE:F("floatLE",4).map(function(X){return X.readFloatLE(0)}),doubleBE:F("doubleBE",8).map(function(X){return X.readDoubleBE(0)}),doubleLE:F("doubleLE",8).map(function(X){return X.readDoubleLE(0)})},G.exports=c}])})})(Ta,Ta.exports);var n=Ta.exports,OX=()=>/[#*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\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26F9(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC3\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uLine truncated
`)[0];let l=G.substring(2).trim();return n.makeSuccess(I+G.length,l)}),namedField:b=>n.alt(b.explicitNamedField,ig(hb.field).map(([I,G])=>qa.named(Ag(G),I))),sortField:b=>n.seqMap(hb.field.skip(n.optWhitespace),n.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 Pu(()=>({type:I,fields:[],showId:!0}),n.seqMap(n.regexp(/WITHOUT\s+ID/i).skip(n.optWhitespace).atMost(1),n.sepBy(b.namedField,n.string(",").trim(n.optWhitespace)),(G,l)=>({type:I,fields:l,showId:G.length==0})));case"list":return Pu(()=>({type:I,format:void 0,showId:!0}),n.seqMap(n.regexp(/WITHOUT\s+ID/i).skip(n.optWhitespace).atMost(1),hb.field.atMost(1),(G,l)=>({type:I,format:l.length==1?l[0]:void 0,showId:G.length==0})));case"task":return n.succeed({type:I});case"calendar":return n.whitespace.then(n.seqMap(b.namedField,G=>({type:I,showId:!0,field:G})));default:return n.fail(`Unrecognized query type '${I}'`)}}).desc("TABLE or LIST or TASK or CALENDAR"),fromClause:b=>n.seqMap(n.regexp(/FROM/i),n.whitespace,hb.source,(I,G,l)=>l),whereClause:b=>n.seqMap(n.regexp(/WHERE/i),n.whitespace,hb.field,(I,G,l)=>({type:"where",clause:l})).desc("WHERE <expression>"),sortByClause:b=>n.seqMap(n.regexp(/SORT/i),n.whitespace,b.sortField.sepBy1(n.string(",").trim(n.optWhitespace)),(I,G,l)=>({type:"sort",fields:l})).desc("SORT field [ASC/DESC]"),limitClause:b=>n.seqMap(n.regexp(/LIMIT/i),n.whitespace,hb.field,(I,G,l)=>({type:"limit",amount:l})).desc("LIMIT <value>"),flattenClause:b=>n.seqMap(n.regexp(/FLATTEN/i).skip(n.whitespace),b.namedField,(I,G)=>({type:"flatten",field:G})).desc("FLATTEN <value> [AS <name>]"),groupByClause:b=>n.seqMap(n.regexp(/GROUP BY/i).skip(n.whitespace),b.namedField,(I,G)=>({type:"group",field:G})).desc("GROUP BY <value> [AS <name>]"),clause:b=>n.alt(b.fromClause,b.whereClause,b.sortByClause,b.limitClause,b.groupByClause,b.flattenClause),query:b=>n.seqMap(b.headerClause.trim(RX),b.fromClause.trim(RX).atMost(1),b.clause.trim(RX).many(),(I,G,l)=>({header:I,source:G.length==0?ib.folder(""):G[0],operations:l,settings:BX}))}),RX=n.alt(n.whitespace,Pt.comment).many().map(b=>b.join("")),Lg=b=>b?b.plugins.plugins.dataview?.api:window.DataviewAPI,kg=b=>b.plugins.enabledPlugins.has("dataview");Ab.DATE_SHORTHANDS=iX;Ab.DURATION_TYPES=oX;Ab.EXPRESSION=hb;Ab.KEYWORDS=AX;Ab.QUERY_LANGUAGE=Pt;Ab.getAPI=Lg;Ab.isPluginEnabled=kg;Ab.parseField=og});var MA={};Vl(MA,{default:()=>UI});module.exports=mw(MA);var qs=require("obsidian");var tl=require("obsidian");function mG(){}function h2(b){return b()}function ZV(){return Object.create(null)}function QI(b){b.forEach(h2)}function xI(b){return typeof b=="function"}function kI(b,I){return b!=b?I==I:b!==I||b&&typeof b=="object"||typeof b=="function"}function qp(b){return Object.keys(b).length===0}function OZ(b){return b&&xI(b.destroy)?b.destroy:mG}var R2=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;var cV=class b{constructor(I){j(this,"_listeners","WeakMap"in R2?new WeakMap:void 0);j(this,"_observer");j(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)}))}};cV.entries="WeakMap"in R2?new WeakMap:void 0;var fp=!1;function Pp(){fp=!0}function _p(){fp=!1}function L(b,I){b.appendChild(I)}function hG(b,I,G){let l=$p(b);if(!l.getElementById(I)){let Z=z("style");Z.id=I,Z.textContent=G,Vw(l,Z)}}function $p(b){if(!b)return document;let I=b.getRootNode?b.getRootNode():b.ownerDocument;return I&&I.host?I:b.ownerDocument}function Vw(b,I){return L(b.head||b,I),I.sheet}function RI(b,I,G){b.insertBefore(I,G||null)}function aI(b){b.parentNode&&b.parentNode.removeChild(b)}function WV(b,I){for(let G=0;G<b.length;G+=1)b[G]&&b[G].d(I)}function z(b){return document.createElement(b)}function EG(b){return document.createTextNode(b)}function dI(){return EG(" ")}function aZ(){return EG("")}function P(b,I,G,l){return b.addEventListener(I,G,l),()=>b.removeEventListener(I,G,l)}function e(b,I,G){G==null?b.removeAttribute(I):b.getAttribute(I)!==G&&b.setAttribute(I,G)}function F2(b){return b===""?null:+b}function IQ(b){return Array.from(b.childNodes)}function al(b,I){I=""+I,b.data!==I&&(b.data=I)}function JG(b,I){b.value=I??""}function IW(b,I,G,l){G==null?b.style.removeProperty(I):b.style.setProperty(I,G,l?"important":"")}function X2(b,I,G){for(let l=0;l<b.options.length;l+=1){let Z=b.options[l];if(Z.__value===I){Z.selected=!0;return}}(!G||I!==void 0)&&(b.selectedIndex=-1)}function GQ(b){let I=b.querySelector(":checked");return I&&I.__value}function dV(b,I,{bubbles:G=!1,cancelable:l=!1}={}){return new CustomEvent(b,{detail:I,bubbles:G,cancelable:l Line truncated
`+x.join(", ")),`
`].join("");var x}function PI(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 hG(){for(var u=[].slice.call(arguments),A=u.length,x=0;x<A;x+=1)r(u[x]);return c(function(D,$){for(var II,P=new Array(A),hI=0;hI<A;hI+=1){if(!(II=o(u[hI]._(D,$),II)).status)return II;P[hI]=II.value,$=II.index}return o(Q($,P),II)})}function sG(){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),hG.apply(null,u).map(function(x){return A.apply(null,x)})}function nG(){var u=[].slice.call(arguments),A=u.length;if(A===0)return T("zero alternates");for(var x=0;x<A;x+=1)r(u[x]);return c(function(D,$){for(var II,P=0;P<u.length;P+=1)if((II=o(u[P]._(D,$),II)).status)return II;return II})}function tb(u,A){return xl(u,A).or(Nl([]))}function xl(u,A){return r(u),r(A),sG(u,A.then(u).many(),function(x,D){return[x].concat(D)})}function Ul(u){i(u);var A="'"+u+"'";return c(function(x,D){var $=D+u.length,II=x.slice(D,$);return II===u?Q($,II):g(D,A)})}function ml(u,A){(function($){if(!($ instanceof RegExp))throw new Error("not a regexp: "+$);for(var II=PI($),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?L(A):A=0;var x=function($){return RegExp("^(?:"+$.source+")",PI($))}(u),D=""+u;return c(function($,II){var P=x.exec($.slice(II));if(P){if(0<=A&&A<=P.length){var hI=P[0],_I=P[A];return Q(II+hI.length,_I)}return g(II,"valid match group (0 to "+P.length+") in "+D)}return g(II,D)})}function Nl(u){return c(function(A,x){return Q(x,u)})}function T(u){return c(function(A,x){return g(x,u)})}function rI(u){if(F(u))return c(function(A,x){var D=u._(A,x);return D.index=x,D.value="",D});if(typeof u=="string")return rI(Ul(u));if(u instanceof RegExp)return rI(ml(u));throw new Error("not a string, regexp, or parser: "+u)}function xI(u){return r(u),c(function(A,x){var D=u._(A,x),$=A.slice(x,D.index);return D.status?g(x,'not "'+$+'"'):Q(x,null)})}function KI(u){return w(u),c(function(A,x){var D=z(A,x);return x<A.length&&u(D)?Q(x+1,D):g(x,"a character/byte matching "+u)})}function ql(u,A){arguments.length<2&&(A=u,u=void 0);var x=c(function(D,$){return x._=A()._,x._(D,$)});return u?x.desc(u):x}function Yl(){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(Pl)._(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)?Nl(x):T(A)})},W.or=function(u){return nG(this,u)},W.trim=function(u){return this.wrap(u,u)},W.wrap=function(u,A){return sG(u,this,A,function(x,D){return D})},W.thru=function(u){return u(this)},W.then=function(u){return r(u),hG(this,u).map(function(A){return A[1]})},W.many=function(){var u=this;return c(function(A,x){for(var D=[],$=void 0;;){if(!($=o(u._(A,x),$)).status)return o(Q(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),L(u),L(A),c(function(D,$){for(var II=[],P=void 0,hI=void 0,_I=0;_I<u;_I+=1){if(hI=o(P=x._(D,$),hI),!P.status)return hI;$=P.index,II.push(P.value)}for(;_I<A&&(hI=o(P=x._(D,$),hI),P.status);_I+=1)$=P.index,II.push(P.value);return o(Q($,II),hI)})},W.result=function(u){return this.map(function(){return u})},W.atMost=function(u){return this.times(0,u)},W.atLeast=function(u){return sG(this.times(u),this.many(),function(A,x){return A.concat(x)})},W.map=function(u){w(u);var A=this;return c(function(x,D){var $=A._(x,D);return $.status?o(Q($.index,u($.value)),$):$})},W.contramap=function(u){w(u);var A=this;return c(function(x,D){var $=A.parse(u(x.slice(D)));return $.status?Q(D+x.length,$.value):$})},W.promap=function(u,A){return w(u),w(A),this.contramap(u).map(A)},W.skip=function(u){return hG(this,u).map(function(A){return A[0]})},W.mark=function(){return sG(Bl,this,Bl,function(u,A,x){return{start:u,value:A,end:x}})},W.node=function(u){return sG(Bl,this,Bl,function(A,x,D){return{name:u,value:x,start:A,end:D}})},W.sepBy=function(u){return tb(this,u)},W.sepBy1=function(u){return xl(this,u)},W.lookahead=function(u){return this.skip(rI(u))},W.notFollowedBy=function(u){return this.skip(xI(u))},W.desc=function(u){J( Line truncated
`),Vc=Ul(`\r
`),Hb=nG(Vc,am,ac).desc("newline"),Ja=nG(Hb,Pl);c.all=aZ,c.alt=nG,c.any=gZ,c.cr=ac,c.createLanguage=function(u){var A={};for(var x in u)({}).hasOwnProperty.call(u,x)&&function(D){A[D]=ql(function(){return u[D](A)})}(x);return A},c.crlf=Vc,c.custom=function(u){return c(u(Q,g))},c.digit=AZ,c.digits=Yc,c.empty=Yl,c.end=Ja,c.eof=Pl,c.fail=T,c.formatError=EI,c.index=Bl,c.isParser=F,c.lazy=ql,c.letter=LZ,c.letters=eb,c.lf=am,c.lookahead=rI,c.makeFailure=g,c.makeSuccess=Q,c.newline=Hb,c.noneOf=function(u){return KI(function(A){return u.indexOf(A)<0}).desc("none of '"+u+"'")},c.notFollowedBy=xI,c.of=Nl,c.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)},c.optWhitespace=Ea,c.Parser=c,c.range=function(u,A){return KI(function(x){return u<=x&&x<=A}).desc(u+"-"+A)},c.regex=ml,c.regexp=ml,c.sepBy=tb,c.sepBy1=xl,c.seq=hG,c.seqMap=sG,c.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(!F(P)){if(J(P)&&P.length===2&&typeof P[0]=="string"&&F(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 c(function(_I,wG){for(var lG,_l={},UG=0;UG<$;UG+=1){var BG,OG;if(J(D[UG])?(BG=D[UG][0],OG=D[UG][1]):(BG=null,OG=D[UG]),!(lG=o(OG._(_I,wG),lG)).status)return lG;BG&&(_l[BG]=lG.value),wG=lG.index}return o(Q(wG,_l),lG)})},c.string=Ul,c.succeed=Nl,c.takeWhile=function(u){return w(u),c(function(A,x){for(var D=x;D<A.length&&u(z(A,D));)D++;return Q(D,A.slice(x,D))})},c.test=KI,c.whitespace=Qb,c["fantasy-land/empty"]=Yl,c["fantasy-land/of"]=Nl,c.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]),L(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 L(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(),L(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 c(function(x,D){var $=z(x,D);return $===u?Q(D+1,$):g(D,A)})},buffer:function(u){return R("buffer",u).map(function(A){return Buffer.from(A)})},encodedString:function(u,A){return R("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:H,int8BE:H(1),int16BE:H(2),int32BE:H(4),intLE:s,int8LE:s(1),int16LE:s(2),int32LE:s(4),floatBE:R("floatBE",4).map(function(u){return u.readFloatBE(0)}),floatLE:R("floatLE",4).map(function(u){return u.readFloatLE(0)}),doubleBE:R("doubleBE",8).map(function(u){return u.readDoubleBE(0)}),doubleLE:R("doubleLE",8).map(function(u){return u.readDoubleLE(0)})},G.exports=c}])})})(uh,uh.exports);var y=uh.exports,LX=()=>/[#*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\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26F9(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC3\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C Line truncated
`)[0];let l=G.substring(2).trim();return y.makeSuccess(I+G.length,l)}),namedField:b=>y.alt(b.explicitNamedField,Og(ib.field).map(([I,G])=>wh.named(Mg(G),I))),sortField:b=>y.seqMap(ib.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 b0(()=>({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 b0(()=>({type:I,format:void 0,showId:!0}),y.seqMap(y.regexp(/WITHOUT\s+ID/i).skip(y.optWhitespace).atMost(1),ib.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,ib.source,(I,G,l)=>l),whereClause:b=>y.seqMap(y.regexp(/WHERE/i),y.whitespace,ib.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,ib.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(dX),b.fromClause.trim(dX).atMost(1),b.clause.trim(dX).many(),(I,G,l)=>({header:I,source:G.length==0?IZ.folder(""):G[0],operations:l,settings:AX}))}),dX=y.alt(y.whitespace,bs.comment).many().map(b=>b.join("")),jg=b=>b?b.plugins.plugins.dataview?.api:window.DataviewAPI,Kg=b=>b.plugins.enabledPlugins.has("dataview");GZ.DATE_SHORTHANDS=vX;GZ.DURATION_TYPES=wX;GZ.EXPRESSION=ib;GZ.KEYWORDS=EX;GZ.QUERY_LANGUAGE=bs;GZ.getAPI=jg;GZ.isPluginEnabled=Kg;GZ.parseField=Bg});var $r={};yl($r,{default:()=>fI});module.exports=aE($r);var ZE=require("obsidian");var dl=require("obsidian");function SI(){}function cR(b){return b()}function Ca(){return Object.create(null)}function uI(b){b.forEach(cR)}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 Sp(b){return Object.keys(b).length===0}function WR(b){return b??""}function Rc(b){return b&&gI(b.destroy)?b.destroy:SI}var hm=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;var oa=class b{constructor(I){GI(this,"_listeners","WeakMap"in hm?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)}))}};oa.entries="WeakMap"in hm?new WeakMap:void 0;var fp=!1;function qp(){fp=!0}function Pp(){fp=!1}function n(b,I){b.appendChild(I)}function bG(b,I,G){let l=_p(b);if(!l.getElementById(I)){let Z=v("style");Z.id=I,Z.textContent=G,RE(l,Z)}}function _p(b){if(!b)return document;let I=b.getRootNode?b.getRootNode():b.ownerDocument;return I&&I.host?I:b.ownerDocument}function RE(b,I){return n(b.head||b,I),I.sheet}function ZI(b,I,G){b.insertBefore(I,G||null)}function lI(b){b.parentNode&&b.parentNode.removeChild(b)}function VZ(b,I){for(let G=0;G<b.length;G+=1)b[G]&&b[G].d(I)}function v(b){return document.createElement(b)}function NI(b){return document.createTextNode(b)}function j(){return NI(" ")}function Ob(){return NI("")}function S(b,I,G,l){return b.addEventListener(I,G,l),()=>b.removeEventListener(I,G,l)}function X(b,I,G){G==null?b.removeAttribute(I):b.getAttribute(I)!==G&&b.setAttribute(I,G)}function dR(b){return b===""?null:+b}function $p(b){return Array.from(b.childNodes)}function sI(b,I){I=""+I,b.data!==I&&(b.data=I)}function DI(b,I){b.value=I??""}function mR(b,I,G,l){G==null?b.style.removeProperty(I):b.style.setProperty(I,G,l?"important":"")}function rZ(b,I,G){for(let l=0;l<b.options.length;l+=1){let Z=b.options[l];if(Z.__value===I){Z.selected=!0;return}}(!G||I!==void 0)&&(b.selectedIndex=-1)}function It(b){let I=b.querySelector(":checked");return I&&I.__value}function ia(b,I,{bubbles:G=!1,cancelable:l=!1}={}){return new CustomEvent(b,{d Line truncated
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,r2.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=UQ(I.getDateWithAdjustedTimezone(),G),Z=new b(I);return Z.addTag("result/relativeDate"),G.hour||G.minute||G.second?(Z.addTag("result/relativeDateAndTime"),rQ(Z,l),kQ(Z,l),Z.assign("timezoneOffset",I.getTimezoneOffset())):(zQ(Z,l),Z.imply("timezoneOffset",I.getTimezoneOffset()),G.day?(Z.assign("day",l.getDate()),Z.assign("month",l.getMonth()+1),Z.assign("year",l.getFullYear()),Z.assign("weekday",l.getDay())):G.week?(Z.assign("day",l.getDate()),Z.assign("month",l.getMonth()+1),Z.assign("year",l.getFullYear()),Z.imply("weekday",l.getDay())):(Z.imply("day",l.getDate()),G.month?(Z.assign("month",l.getMonth()+1),Z.assign("year",l.getFullYear())):(Z.imply("month",l.getMonth()+1),G.year?Z.assign("year",l.getFullYear()):Z.imply("year",l.getFullYear())))),Z}},CI=class b{constructor(I,G,l,Z,c){j(this,"refDate");j(this,"index");j(this,"text");j(this,"reference");j(this,"start");j(this,"end");this.reference=I,this.refDate=I.instant,this.index=G,this.text=l,this.start=Z||new x(I),this.end=c}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 cl(b,I,G="\\s{0,5},?\\s{0,5}"){let l=I.replace(/\((?!\?)/g,"(?:");return`${b}${l}(?:${G}${l}){0,10}`}function gw(b){let I;return b instanceof Array?I=[...b]:b instanceof Map?I=Array.from(b.keys()):I=Object.keys(b),I}function q(b){return`(?:${gw(b).sort((G,l)=>l.length-G.length).join("|").replace(/\./g,"\\.")})`}var OQ=JI(oI(),1);function Rl(b){return b<100&&(b>50?b=b+1900:b=b+2e3),b}function zI(b,I,G){let l=(0,OQ.default)(b),Z=l;Z=Z.month(G-1),Z=Z.date(I),Z=Z.year(l.year());let c=Z.add(1,"y"),W=Z.add(-1,"y");return Math.abs(c.diff(l))<Math.abs(Z.diff(l))?Z=c:Math.abs(W.diff(l))<Math.abs(Z.diff(l))&&(Z=W),Z.year()}var HV={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},U2={january:1,february:2,march:3,april:4,may:5,june:6,july:7,august:8,september:9,october:10,november:11,december:12},Al={...U2,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},z2={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x2={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,"thirty first":31,"thirty-first":31},jQ={second:"second",seconds:"second",minute:"minute",minutes:"minute",hour:"hour",hours:"hour",day:"d",days:"d",week:"week",weeks:"week",month:"month",months:"month",quarter:"quarter",quarters:"quarter",year:"year",years:"year"},Dd={s:"second",sec:"second",second:"second",seconds:"second",m:"minute",min:"minute",mins:"minute",minute:"minute",minutes:"minute",h:"hour",hr:"hour",hrs:"hour",hour:"hour",hours:"hour",d:"d",day:"d",days:"d",w:"w",week:"week",weeks:"week",mo:"month",mon:"month",mos:"month",month:"month",months:"month",qtr:"quarter",quarter:"quarter",quarters:"quarter",y:"year",yr:"year",year:"year",years:"year",...jQ},KQ=`(?:${q(z2)}|[0-9]+|[0-9]+\\.[0-9]+|half(?:\\s{0,2}an?)?|an?\\b(?:\\s{0,2}few)?|few|several|the|a?\\s{0,2}couple\\s{0,2}(?:of)?)`;function ow(b){let I=b.toLowerCase();return z2[I]!==void 0?z2[I]:I==="a"||I==="an"||I=="the"?1:I.match(/ Line truncated
reference: ${JSON.stringify(this.reference)}]`}dayjs(){return(0,yR.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=Bt(I.getDateWithAdjustedTimezone(),G),Z=new b(I);return Z.addTag("result/relativeDate"),G.hour||G.minute||G.second?(Z.addTag("result/relativeDateAndTime"),zt(Z,l),kt(Z,l),Z.assign("timezoneOffset",I.getTimezoneOffset())):(xt(Z,l),Z.imply("timezoneOffset",I.getTimezoneOffset()),G.day?(Z.assign("day",l.getDate()),Z.assign("month",l.getMonth()+1),Z.assign("year",l.getFullYear()),Z.assign("weekday",l.getDay())):G.week?(Z.assign("day",l.getDate()),Z.assign("month",l.getMonth()+1),Z.assign("year",l.getFullYear()),Z.imply("weekday",l.getDay())):(Z.imply("day",l.getDate()),G.month?(Z.assign("month",l.getMonth()+1),Z.assign("year",l.getFullYear())):(Z.imply("month",l.getMonth()+1),G.year?Z.assign("year",l.getFullYear()):Z.imply("year",l.getFullYear())))),Z}},BI=class b{constructor(I,G,l,Z,c){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=Z||new q(I),this.end=c}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 Hl(b,I,G="\\s{0,5},?\\s{0,5}"){let l=I.replace(/\((?!\?)/g,"(?:");return`${b}${l}(?:${G}${l}){0,10}`}function AE(b){let I;return b instanceof Array?I=[...b]:b instanceof Map?I=Array.from(b.keys()):I=Object.keys(b),I}function cI(b){return`(?:${AE(b).sort((G,l)=>l.length-G.length).join("|").replace(/\./g,"\\.")})`}var Mt=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,Mt.default)(b),Z=l;Z=Z.month(G-1),Z=Z.date(I),Z=Z.year(l.year());let c=Z.add(1,"y"),W=Z.add(-1,"y");return Math.abs(c.diff(l))<Math.abs(Z.diff(l))?Z=c:Math.abs(W.diff(l))<Math.abs(Z.diff(l))&&(Z=W),Z.year()}var Da={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},iR={january:1,february:2,march:3,april:4,may:5,june:6,july:7,august:8,september:9,october:10,november:11,december:12},$l={...iR,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},CR={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},oR={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,"thirty first":31,"thirty-first":31},Kt={second:"second",seconds:"second",minute:"minute",minutes:"minute",hour:"hour",hours:"hour",day:"d",days:"d",week:"week",weeks:"week",month:"month",months:"month",quarter:"quarter",quarters:"quarter",year:"year",years:"year"},tm={s:"second",sec:"second",second:"second",seconds:"second",m:"minute",min:"minute",mins:"minute",minute:"minute",minutes:"minute",h:"hour",hr:"hour",hrs:"hour",hour:"hour",hours:"hour",d:"d",day:"d",days:"d",w:"w",week:"week",weeks:"week",mo:"month",mon:"month",mos:"month",month:"month",months:"month",qtr:"quarter",quarter:"quarter",quarters:"quarter",y:"year",yr:"year",year:"year",years:"year",...Kt},Dt=`(?:${cI(CR)}|[0-9]+|[0-9]+\\.[0-9]+|half(?:\\s{0,2}an?)?|an?\\b(?:\\s{0,2}few)?|few|several|the|a?\\s{0,2}couple\\s{0,2}(?:of)?)`;function LE(b){let I=b.toLowerCase();return CR[I]!==void 0?CR[I]:I==="a"||I==="an"||I=="the"?1:I Line truncated
`,{line:W,ch:0}),Z.setCursor({line:W,ch:b.length});else{let d=Z.getLine(W);Z.replaceRange(`
`+b,{line:W,ch:d.length}),Z.setCursor({line:W+1,ch:b.length})}}catch{M.logError(`unable to insert '${b}' on new line ${I}.`)}}function n0(b,I){Q0(b,"above",I)}function H0(b,I){Q0(b,"below",I)}function Ga(b,I,G="replaceSelection",l={}){let{requireActiveView:Z=!0}=l,c=b.workspace.getActiveViewOfType(Wb.MarkdownView);if(!c){let Y="Cannot append link because no active Markdown view is available.";if(Z)throw new Error(Y);M.logMessage(Y);return}let W=c.editor,d=W.listSelections().map(Y=>({anchor:{...Y.anchor},head:{...Y.head}}));if(G==="replaceSelection"){W.replaceSelection(I);return}let m=({line:Y,ch:V})=>W.posToOffset({line:Y,ch:V}),N=d.sort((Y,V)=>m(V.head)-m(Y.head));for(let Y of N){let V=m(Y.anchor)>m(Y.head)?Y.anchor:Y.head;switch(G){case"afterSelection":{W.replaceRange(I,V);break}case"endOfLine":{let a=W.getLine(V.line),h={line:V.line,ch:a.length};W.replaceRange(I,h);break}case"newLine":{let a=W.getLine(V.line),h={line:V.line,ch:a.length},F=a.endsWith(`
`)?"":`
`;W.replaceRange(F+I,h);break}}}}function B1(b,I){return b.commands.findCommand(I)}function u0(b,I){B1(b,I)&&(delete b.commands.commands[I],delete b.commands.editorCommands[I])}function GY(b){return b.vault.getAllLoadedFiles().filter(I=>I instanceof Wb.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 AW(b,I,G={}){let{location:l="tab",direction:Z="vertical",mode:c,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",Z);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),c&&c!=="default"&&!(typeof c=="object"&&c.mode==="default")){let Y=N.getViewState(),V={...Y.state??{}};c==="preview"||typeof c=="object"&&c.mode==="preview"?(V.mode="preview",delete V.source):c==="source"?(V.mode="source",V.source=!0):c==="live"||c==="live-preview"?(V.mode="source",V.source=!1):typeof c=="object"&&c.mode==="source"&&(V.mode="source",V.source=c.source),await N.setViewState({...Y,state:{...V,...d}})}return W&&b.workspace.setActiveLeaf(N,{focus:!0}),N}function la(b,I){let G;return b.workspace.iterateRootLeaves(l=>{let Z=l.view;if(Z instanceof Wb.FileView&&Z.file&&I.path===Z.file.path){G=l;return}}),G!==void 0?(b.workspace.setActiveLeaf(G),!0):!1}async function LW(b,I){let G=I.vault.getAbstractFileByPath(b.path);if(!G){M.logError(`failed to load file ${b.path}.`);return}if(G instanceof Wb.TFile){let l=V=>window.require&&window.require(V),Z={},c={exports:Z},W=await I.vault.read(G);window.eval(`(function(require, module, exports) { ${W}
})`)(l,c,Z);let m=Z.default||c.exports;if(!m)return;let N=m,{memberAccess:Y}=lY(b.name);if(Y&&Y.length>0){let V;for(;V=Y.shift();)N=N[V]}return N}}function t0(b,I){let G=structuredClone(b);for(let l of I)delete G[l];return G}function ba(b,I){let G=b.vault.getAbstractFileByPath(I);return!!G&&G instanceof Wb.TFolder}function sZ(b,I){return b.vault.getMarkdownFiles().filter(G=>G.path.startsWith(I))}function O1(b){let I=b.frontmatter;if(!I)return[];let G=Object.entries(I);if(!G.length)return[];let l=G.filter(([c,W])=>{let d=c.toLowerCase();return d==="tags"||d==="tag"});return l?l.flatMap(([c,W])=>{if(typeof W=="string")return W.split(/,|\s+/).map(d=>d.trim());if(Array.isArray(W))return W}).filter(c=>!!c):[]}function M1(b,I){let G=b.metadataCache.getFileCache(I);if(!G)return[];let l=[];return G.frontmatter&&l.push(...O1(G)),G.tags&&Array.isArray(G.tags)&&l.push(...G.tags.map(Z=>Z.tag.replace(/^\#/,""))),l}function Za(b,I){let G=I.replace(/^\#/,"");return b.vault.getMarkdownFiles().filter(l=>M1(b,l).includes(G))}var vb=class{constructor(){this.variables=new Map;this.linkToCurrentFileBehavior="required"}hasConcreteVariable(I){if(!this.variables.has(I))return!1;let G=this.variables.get(I);return G!=null}setTitle(I){this.variables.set("title",I)}replacer(I,G,l){return I.replace(G,function(){return l})}replaceDateInString(I){let G=I;for(;XV.test(G);){let l=XV.exec(G),Z;if(l&&l[1]){let c=l[1].replace("+","").trim();s2.test(c)&&(Z=parseInt(c))}G=this.replacer(G,XV,fb({offset:Z}))}for(;bW.test(G);){let l=bW.exec(G);if(!l)throw new Error(`Unable to parse date format. Invalid syntax in: "${G.substring(Math.max(0,G.search(bW)-10),Math.min(G.length,G.search(bW)+30))}..."`);let Z=l[1],c;if(l[2]){let W=l[2].replace("+","").trim();s2.test(W)&&(c=parseInt(W))}G=this.replacer(G,bW,fb({format:Z,offset:c}))}return G}replaceTimeInString(I){let G=I;for(;ZW.test(G);){if(!ZW.exec(G))throw new Error(`Unable to parse time format. Invalid syntax in: "${G.substring(Math.max(0,G.search(ZW)-10),Math.min(G.length,G.search(ZW)+30))}..."`);G=this.replacer(G,ZW,fb({format:"HH:mm"}))}for(;cW.test(G);){let l=cW.exec(G);if(!l)throw new Error(`Unable to parse formatted time. Invalid syntax in: "${G.substring(Math.max(0,G.search(cW)-10),Math.min(G.length,G.search(cW)+30))}..."`);let Z=l[1];G=this.replacer(G,cW,fb({format:Z}))}return G}async replaceValueInString(I){let G=I;for(this.variables.has("value")&&(this.value=this.variables.get("value"));w2.test(G);)this.value||(this.value=await this.promptForValue()),G=this.replacer(G,w2,this.value);return G}async replaceSelectedInString(I){let G=I,l=await this.getSelectedText();for(;J2.test(G);)G=this.replacer(G,J2,l);return G}async replaceClipboardInString(I){let G=I,l=await this.getClipboardContent();for(;y2.test(G);)G=this.replacer(G,y2,l);return G}async replaceLinkToCurrentFileInString(I){let G=this.getCurrentFileLink(),l=I;if(!G&&dW.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.");dW.test(l);)l=this.replacer(l,dW,"");return l}else if(!G)return l;for(;dW.test(l);)l=this.replacer(l,dW,G);return l}setLinkToCurrentFileBehavior(I){this.linkToCurrentFileBehavior=I}async replaceVariableInString(I){let G=I;for(;RZ.test(G);){let l=RZ.exec(G);if(!l)throw new Error(`Unable to parse variable. Invalid syntax in: "${G.substring(Math.max(0,G.search(RZ)-10),Math.min(G.length,G.search(RZ)+30))}..."`);let Z=l[1],c="";if(Z){let W=Z.indexOf("|");if(W!==-1&&(c=Z.substring(W+1).trim(),Z=Z.substring(0,W).trim()),!this.hasConcreteVariable(Z)){let d=Z.split(","),m="";d.length===1?m=await this.promptForVariable(Z):m=await this.suggestForValue(d),!m&&c&&(m=c),this.variables.set(Z,m)}G=this.replacer(G,RZ,this.getVariableValue(Z))}else break}return G}async replaceFieldVarInString(I){let G=I;for(;WW.test(G);){let l=WW.exec(G);if(!l)throw new Error(`Unable to parse field variable. Invalid syntax in: "${G.substring(Math.max(0,G.search(WW)-10),Math.min(G.length,G.search(WW)+30))}..."`);let Z=l[1]+(l[2]||"");if(Z)this.hasConcreteVariable(Z)||this.variables.set(Z,await this.suggestForField(Z)),G=this.replacer(G,WW,this.getVariableValue(Z));else break}return G}async replaceMathValueInString(I){let G=I;for(;v2.test(G);){let l=await this.promptForMathValue();G=this.replacer(G,v2,l)}return G}async replaceMacrosInString(I){let G=I;for(;pV.test(G);){let l=pV.exec(G);if(!l||!l[1])continue;let Z=l[1],c=await this.getMacroValue(Z);G=this.replacer(G,pV,c?c.toString():"")}return G}async replaceDateVariableInString(I){let G=I;for(;TZ.test(G);){let l=TZ.exec(G);if(!l||!l[1]||!l[2])break;let Z=l[1].trim(),c=l[2].trim(),W=l[3]?.trim()||void 0;if(!Z||!c)break;if(Z&&c){if(!this.variables.get(Z)){let Y=await this.promptForVariable(Z,{type:"VDATE",dateFormat:c,defaultValue:W});if(this.variables.set(Z,Y),!this.dateParser)throw new Error("Date parser is not av Line truncated
`,l++):c=="\\"?(G+="\\",l++):G+="\\":G+=Z}return G}replaceRandomInString(I){let G=I;for(;C2.test(G);){let l=C2.exec(G);if(!l||!l[1])continue;let Z=parseInt(l[1]);if(Z<=0||Z>100)throw new Error(`Random string length must be between 1 and 100. Got: ${Z}`);let c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",W="";for(let d=0;d<Z;d++)W+=c.charAt(Math.floor(Math.random()*c.length));G=G.replace(l[0],W)}return G}replaceTitleInString(I){let G=I,l=this.getVariableValue("title");for(;E2.test(G);)G=this.replacer(G,E2,l);return G}};var j1={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"},K1={clipboard:"clipboard_content",date:"formatted_date",time:"current_time",random:"random_value",uuid:"unique_id"},D1=[{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 ca(b){let I=b.toLowerCase(),G=j1[I];return G||`${b}_example`}function Wa(b){return K1[b.toLowerCase()]||`${b}_output`}function da(b){for(let{pattern:I,example:G}of D1)if(I.test(b))return G;return`${b}_value`}function ma(b){return b.length>0?`${b[0]} (${b.length} options)`:"suggestion_list"}function Na(b){return b?.path?b.basename:"current_file"}var Eb=class{static generate(I,G=new Date){let l=G.getFullYear(),Z=(G.getMonth()+1).toString().padStart(2,"0"),c=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,Z).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,c).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)}};Eb.MONTH_NAMES=["January","February","March","April","May","June","July","August","September","October","November","December"],Eb.MONTH_NAMES_SHORT=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Eb.DAY_NAMES=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Eb.DAY_NAMES_SHORT=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];var kW=class extends vb{constructor(G,l,Z){super();this.app=G;this.plugin=l;this.dateParser=Z||cb}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=this.replaceRandomInString(l)}catch{return G}return`Preview: ${l}`}async replaceGlobalVarInString(G){let l=G,Z=0,c=new RegExp(FZ.source,"gi");for(;c.test(l)&&!(++Z>5);)l=l.replace(c,(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 ca(G)}getCurrentFileLink(){return Na(this.app.workspace.getActiveFile())}suggestForValue(G){return ma(G)}promptForMathValue(){return Promise.resolve("calculation_result")}getMacroValue(G){return Wa(G)}async promptForVariable(G,l){return da(G)}async getTemplateContent(G){return`[${G.split("/").pop()?.replace(".md","")||G} template content...]`}async getSelectedText(){return"selected_text"}async getClipboardContent(){return"clipboard_content"}async suggestForField(G){return`${G}_field_value`}async replaceDateVariableInString(G){let l=G;return l=l.replace(new RegExp(TZ.source,"gi"),(Z,c,W)=>{let d=c?.trim(),m=W?.trim();if(!d||!m)return Z;let N=new Date,Y;try{Y=Eb.generate(m,N)}catch{Y=`[${m}]`}return Y}),l}replaceRandomInString(G){let l=G;return l=l.replace(/{{RANDOM:(\d+)}}/gi,(Z,c)=>{let W=parseInt(c);if(W<=0||W>100)return Z;let d="ABC123",m="";for(let N=0;N<Math.min(W,6);N++)m+=d.charAt(N%d.length);return W>6&&(m+="..."),m}),l}};var bY=require("obsidian");var rW=class{constructor(I){this.app=I}async createFolder(I){await this.app. Line truncated
`+b,{line:W,ch:d.length}),Z.setCursor({line:W+1,ch:b.length})}}catch{K.logError(`unable to insert '${b}' on new line ${I}.`)}}function eH(b,I){tH(b,"above",I)}function QH(b,I){tH(b,"below",I)}function jC(b,I,G="replaceSelection",l={}){let{requireActiveView:Z=!0}=l,c=b.workspace.getActiveViewOfType(db.MarkdownView);if(!c){let Y="Cannot append link because no active Markdown view is available.";if(Z)throw new Error(Y);K.logMessage(Y);return}let W=c.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},t=V.length===0?"":`
`;W.replaceRange(t+I,h);break}}}}function EV(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(db.MarkdownView)){if(G.requireActiveFile)throw new Error("Cannot append link because no active Markdown view is available.");return!1}let c=l?.path??"";return jC(b,b.fileManager.generateMarkdownLink(I,c),G.placement,{requireActiveView:!1}),!0}function KC(b,I){return b.commands.findCommand(I)}function HH(b,I){KC(b,I)&&(delete b.commands.commands[I],delete b.commands.editorCommands[I])}function JY(b){return b.vault.getAllLoadedFiles().filter(I=>I instanceof db.TFolder).map(I=>I.path)}function yY(b){let I=b.split("::").map(G=>G.trim()).filter(Boolean);return{basename:I[0],memberAccess:I.slice(1)}}async function cd(b,I,G={}){let{location:l="tab",direction:Z="vertical",mode:c,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",Z);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),c&&c!=="default"&&!(typeof c=="object"&&c.mode==="default")){let Y=N.getViewState(),a={...Y.state??{}};c==="preview"||typeof c=="object"&&c.mode==="preview"?(a.mode="preview",delete a.source):c==="source"?(a.mode="source",a.source=!0):c==="live"||c==="live-preview"?(a.mode="source",a.source=!1):typeof c=="object"&&c.mode==="source"&&(a.mode="source",a.source=c.source),await N.setViewState({...Y,state:{...a,...d}})}return W&&b.workspace.setActiveLeaf(N,{focus:!0}),N}function JV(b,I){let G;return b.workspace.iterateRootLeaves(l=>{let Z=l.view;if(Z instanceof db.FileView&&Z.file&&I.path===Z.file.path){G=l;return}}),G!==void 0?(b.workspace.setActiveLeaf(G),!0):!1}async function tZ(b,I){let G=I.vault.getAbstractFileByPath(b.path);if(!G){K.logError(`failed to load file ${b.path}.`);return}if(G instanceof db.TFile){let l=a=>window.require&&window.require(a),Z={},c={exports:Z},W=await I.vault.read(G);window.eval(`(function(require, module, exports) { ${W}
})`)(l,c,Z);let m=Z.default||c.exports;if(!m)return;let N=m,{memberAccess:Y}=yY(b.name);if(Y&&Y.length>0){let a;for(;a=Y.shift();)N=N[a]}return N}}function uH(b,I){let G=structuredClone(b);for(let l of I)delete G[l];return G}function yV(b,I){let G=b.vault.getAbstractFileByPath(I);return!!G&&G instanceof db.TFolder}function TZ(b,I){return b.vault.getMarkdownFiles().filter(G=>G.path.startsWith(I))}function DC(b){let I=b.frontmatter;if(!I)return[];let G=Object.entries(I);if(!G.length)return[];let l=G.filter(([c,W])=>{let d=c.toLowerCase();return d==="tags"||d==="tag"});return l?l.flatMap(([c,W])=>{if(typeof W=="string")return W.split(/,|\s+/).map(d=>d.trim());if(Array.isArray(W))return W}).filter(c=>!!c):[]}function TC(b,I){let G=b.metadataCache.getFileCache(I);if(!G)return[];let l=[];return G.frontmatter&&l.push(...DC(G)),G.tags&&Array.isArray(G.tags)&&l.push(...G.tags.map(Z=>Z.tag.replace(/^\#/,""))),l}function CV(b,I){let G=I.replace(/^\#/,"");return b.vault.getMarkdownFiles().filter(l=>TC(b,l).includes(G))}function oV(b){let G=/^(\s*---\r?\n)([\s\S]*?)(\r?\n(?:---|\.\.\.)\s*(?:\r?\n|$))/.exec(b);return G?[0,G[0].length]:null}function sH(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 c=b.lastIndexOf(`
`,I-1)+1,W=b.indexOf(`
`,I),d=W===-1?b.length:W,m=b.slice(c,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(/^["']/,""),R=/:\s*$/.test(V)&&h.trim().length===0;return{isInYaml:!0,isQuoted:a,lineStart:c,lineEnd:d,baseIndent:Y,isKeyValuePosition:R}}var wH={"[":"]","(":")","{":"}","<":">"};function SC(b,I=","){let G=[],l="",Z=[],c=null;for(let d=0;d<b.length;d++){let m=b[d];if(c){if(l+=m,m===c){let N=0;for(let Y=d-1;Y>=0&&b[Y]==="\\";Y--)N++;N%2===0&&(c=null)}continue}if(m==='"'||m==="'"){c=m,l+=m;continue}if(m in wH){Z.push(wH[m]),l+=m;continue}if(Z.length>0){let N=Z[Z.length-1];m===N&&Z.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 fC(b){return b.includes(`
`)?b.replace(/\r?\n/g,`
`):b.includes("\\n")?b.replace(/\\n/g,`
`):b}function qC(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 Z=l.getTypeInfo(I),c=Z?.expected?.type??Z?.inferred?.type;return typeof c=="string"?c:null}function PC(b){if(!b)return!1;let I=b.toLowerCase();return I==="list"||I==="tags"||I==="multitext"}function vH(b,I){let G=b.trim();if(!G)return;let l=fC(G),Z=I?.propertyType??qC(I?.app,I?.propertyKey),c=PC(Z),d=c||Z===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(Z&&!c&&Z!=="list")return;try{return JSON.parse(l)}catch{}}if(l.includes(",")&&d){let Y=SC(l);if(Y.length>1)return Y}}var EH="\0",SZ=class{constructor(I){this.app=I;this.map=new Map;this.propertyTypeCache=new Map}maybeCollect(I){let{input:G,matchStart:l,matchEnd:Z,rawValue:c,fallbackKey:W,featureEnabled:d}=I;if(!d)return;let m=oV(G),N=sH(G,l,Z,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,R=/^-\s*['"]?\{\{VALUE:[^}]+\}\}['"]?\s*$/i,t=null;if(N.isKeyValuePosition?t=[h]:R.test(a)&&(t=this.findListParentPath(G,N.lineStart,N.baseIndent??"")),!t||t.length===0)return;let p=t[t.length-1],e=c;if(typeof c=="string"){let F=vH(c,this.buildParseOptions(p));F!==void 0&&(e=F)}if(!(typeof e!="string"&&(Array.isArray(e)||typeof e=="object"&&e!==null||typeof e=="number"||typeof e=="boolean"||e===null)))return;let s=t.join(EH);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 Z=G-1,c=[],W=l.length;for(;Z>=0;){let d=I.lastIndexOf(`
`,Z),m=d===-1?0:d+1,N=I.slice(m,Z+1),Y=N.trim();if(Y.length===0){Z=m-2;continue}if(Y==="---"||Y==="...")break;if(Y.startsWith("-")){Z=m-2;continue}let a=N.match(/^(\s*)([^:\n]+):/);if(a){let h=(a[1]??"").length;if(h<W&&(c.unshift(a[2].trim()),W=h,W===0))break}Z=m-2}return c.length>0?c: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 Z=l.getTypeInfo(I),c=Z?.expected?.type??Z?.inferred?.type??null,W=typeof c=="string"?c:null;return this.propertyTypeCache.set(I,W),W}};SZ.PATH_SEPARATOR=EH;var iV=class iV{constructor(I){this.app=I;this.variables=new Map;this.linkToCurrentFileBehavior="required";this.propertyCollector=new SZ(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(;Ua.test(G);){let l=Ua.exec(G),Z;if(l&&l[1]){let c=l[1].replace("+","").trim();nR.test(c)&&(Z=parseInt(c))}G=this.replacer(G,Ua,pZ({offset:Z}))}for(;EW.test(G);){let l=EW.exec(G);if(!l)throw new Error(`Unable to parse date format. Invalid syntax in: "${G.substring(Math.max(0,G.search(EW)-10),Math.min(G.length,G.search(EW)+30))}..."`);let Z=l[1],c;if(l[2]){let W=l[2].replace("+","").trim();nR.test(W)&&(c=parseInt(W))}G=this.replacer(G,EW,pZ({format:Z,offset:c}))}return G}replaceTimeInString(I){let G=I;for(;JW.test(G);){if(!JW.exec(G))throw new Error(`Unable to parse time format. Invalid syntax in: "${G.substring(Math.max(0,G.search(JW)-10),Math.min(G.length,G.search(JW)+30))}..."`);G=this.replacer(G,JW,pZ({format:"HH:mm"}))}for(;yW.test(G);){let l=yW.exec(G);if(!l)throw new Error(`Unable to parse formatted time. Invalid syntax in: "${G.substring(Math.max(0,G.search(yW)-10),Math.min(G.length,G.search(yW)+30))}..."`);let Z=l[1];G=this.replacer(G,yW,pZ({format:Z}))}return G}async replaceValueInString(I){let G=I;for(this.variables.has("value")&&(this.value=this.variables.get("value"));XR.test(G);)this.value||(this.value=await this.promptForValue()),G=this.replacer(G,XR,this.value);return G}async replaceSelectedInString(I){let G=I,l=await this.getSelectedText();for(;eR.test(G);)G=this.replacer(G,eR,l);return G}async replaceClipboardInString(I){let G=I,l=await this.getClipboardContent();for(;QR.test(G);)G=this.replacer(G,QR,l);return G}async replaceLinkToCurrentFileInString(I){let G=this.getCurrentFileLink(),l=I;if(!G&&oW.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(K.logMessage("Skipping {{LINKCURRENT}} replacement because no active file is available.");oW.test(l);)l=this.replacer(l,oW,"");return l}else if(!G)return l;for(;oW.test(l);)l=this.replacer(l,oW,G);return l}async replaceCurrentFileNameInString(I){let G=this.getCurrentFileName(),l=I;if(!G&&iW.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(K.logMessage("Skipping {{FILENAMECURRENT}} replacement because no active file is available.");iW.test(l);)l=this.replacer(l,iW,"");return l}else if(!G)return l;for(;iW.test(l);)l=this.replacer(l,iW,G);return l}setLinkToCurrentFileBehavior(I){this.linkToCurrentFileBehavior=I}getAndClearTemplatePropertyVars(){return this.propertyCollector.drain()}async replaceVariableInString(I){let G=I,l=new RegExp(Ba.source,"gi"),Z=this.isTemplatePropertyTypesEnabled(),c;for(;(c=l.exec(G))!==null;){if(!c[1])throw new Error(`Unable to parse variable. Invalid syntax in: "${G.substring(Math.max(0,c.index-10),Math.min(G.length,c.index+30))}..."`);let W=c[1],d="",m=W.indexOf("|");if(m!==-1&&(d=W.substring(m+1).trim(),W=W.substring(0,m).trim()),!this.hasConcreteVariable(W)){let a=W.split(","),V="",h=d;if(a.length===1)V=await this.promptForVariable(W,{defaultValue:h});else{let R=d.toLowerCase()==="custom";h=R?"":d,V=await this.suggestForValue(a,R)}!V&&h&&(V=h),this.variables.set(W,V)}let N=this.variables.get(W);this.propertyCollector.maybeCollect({input:G,matchStart:c.index,matchEnd:c.index+c[0].length,rawValue:N,fallbackKey:W,featureEnabled:Z});let Y=this.getVariableValue(W);G=G.slice(0,c.index)+Y+G.slice(c.index+c[0].length),l.lastIndex=c.index+Y.length}return G}async replaceFieldVarInString(I){let G=I;for(;CW.test(G);){let l=CW.exec(G);if(!l)throw new Error(`Unable to parse field variable. Invalid syntax in: "${G.substring(Math.max(0,G.search(CW)-10),Math.min(G.length,G.search(CW)+30))}..."`);let Z=l[1]+(l[2]||"");if(Z){let c=this.getFieldVariableKey(Z);this.hasConcreteVariable(c)||this.variables.set(c,await this.suggestForField(Z));let W=this.hasConcreteVariable(c)?String(this.variables. Line truncated
`,l++):c=="\\"?(G+="\\",l++):G+="\\":G+=Z}return G}replaceRandomInString(I){let G=I;for(;HR.test(G);){let l=HR.exec(G);if(!l||!l[1])continue;let Z=parseInt(l[1]);if(Z<=0||Z>100)throw new Error(`Random string length must be between 1 and 100. Got: ${Z}`);let c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",W="";for(let d=0;d<Z;d++)W+=c.charAt(Math.floor(Math.random()*c.length));G=G.replace(l[0],W)}return G}replaceTitleInString(I){let G=I,l=this.getVariableValue("title");for(;tR.test(G);)G=this.replacer(G,tR,l);return G}};iV.FIELD_VARIABLE_PREFIX="FIELD:";var Tb=iV;var _C={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"},$C={clipboard:"clipboard_content",date:"formatted_date",time:"current_time",random:"random_value",uuid:"unique_id"},I5=[{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 gV(b){let I=b.toLowerCase(),G=_C[I];return G||`${b}_example`}function AV(b){return $C[b.toLowerCase()]||`${b}_output`}function LV(b){for(let{pattern:I,example:G}of I5)if(I.test(b))return G;return`${b}_value`}function rV(b){return b.length>0?`${b[0]} (${b.length} options)`:"suggestion_list"}function kV(b){return b?.path?b.basename:"current_file"}function zV(b){return b?.basename||"current_filename"}var Sb=class{static generate(I,G=new Date){let l=G.getFullYear(),Z=(G.getMonth()+1).toString().padStart(2,"0"),c=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,Z).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,c).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)}};Sb.MONTH_NAMES=["January","February","March","April","May","June","July","August","September","October","November","December"],Sb.MONTH_NAMES_SHORT=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Sb.DAY_NAMES=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Sb.DAY_NAMES_SHORT=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];var Wd=class extends Tb{constructor(G,l,Z){super(G);this.plugin=l;this.dateParser=Z||wb}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,Z=0,c=new RegExp(zZ.source,"gi");for(;c.test(l)&&!(++Z>5);)l=l.replace(c,(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 gV(G)}getCurrentFileLink(){return this.app?kV(this.app.workspace.getActiveFile()):null}getCurrentFileName(){return this.app?zV(this.app.workspace.getActiveFile()):"current_filename"}suggestForValue(G,l=!1){return rV(G)}promptForMathValue(){return Promise.resolve("calculation_result")}getMacroValue(G){return AV(G)}async promptForVariable(G,l){return LV(G)}async getTemplateContent(G){return`[${G.split("/").pop()?.replace(".md","")||G} template content...]`}async getSelectedText(){return"selected_text"}async getClipboardContent(){return"clipboard_content"}async suggestForField(G){return`${G}_field_value`}async replaceDateVariableInString(G){let l=G;return l=l.replace(new RegExp(tc.source,"gi"),(Z,c,W)=>{let d=c?.trim(),m=W?.trim();if(!d||!m)return Z;let N=new Date,Y;try{Y=Sb.generate(m,N)}catch{Y=`[${m}]`}return Y}),l}replaceRandomInString(G){let l=G;return l=l.replace(/{{RANDOM:(\d+)}}/gi,(Z,c)=>{let W=parseInt(c Line truncated
<div class="qa-suggestion-content">
<span class="suggestion-main-text">${d}</span>
${N}
</div>
<span class="suggestion-sub-text">${m}</span>
`,this.addHoverTooltip(l,Z)}addHoverTooltip(G,l){let Z,c=()=>{clearTimeout(Z),document.querySelector(".qa-file-tooltip")?.remove()};G.addEventListener("mouseenter",()=>{c(),Z=setTimeout(async()=>{let d=this.createTooltip(l);d&&(document.body.appendChild(d),this.positionTooltip(d,G))},200)}),G.addEventListener("mouseleave",c),G.addEventListener("blur",c);let W=()=>c();document.addEventListener("scroll",W,{passive:!0}),G._tooltipCleanup=()=>{c(),document.removeEventListener("scroll",W)}}createTooltip(G){let l=this.app.vault.getAbstractFileByPath(G.path);if(!l||!(l instanceof IX.TFile))return null;let Z=document.createElement("div");return Z.className="qa-file-tooltip",Z.innerHTML=`
`,this.addHoverTooltip(l,Z)}addHoverTooltip(G,l){let Z,c=()=>{clearTimeout(Z),document.querySelector(".qa-file-tooltip")?.remove()};G.addEventListener("mouseenter",()=>{c(),Z=setTimeout(async()=>{let d=this.createTooltip(l);d&&(document.body.appendChild(d),this.positionTooltip(d,G))},200)}),G.addEventListener("mouseleave",c),G.addEventListener("blur",c);let W=()=>c();document.addEventListener("scroll",W,{passive:!0}),G._tooltipCleanup=()=>{c(),document.removeEventListener("scroll",W)}}createTooltip(G){let l=this.app.vault.getAbstractFileByPath(G.path);if(!l||!(l instanceof Tn.TFile))return null;let Z=document.createElement("div");return Z.className="qa-file-tooltip",Z.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>
`,Z}positionTooltip(G,l){let Z=l.getBoundingClientRect();G.style.position="fixed",G.style.left=`${Z.right+10}px`,G.style.top=`${Z.top}px`,G.style.zIndex="1000"}close(){document.querySelectorAll(".qaFileSuggestionItem").forEach(Z=>{let c=Z;c._tooltipCleanup&&c._tooltipCleanup()}),document.querySelectorAll(".qa-file-tooltip").forEach(Z=>Z.remove()),super.close()}async selectSuggestion(G){if(this.inputEl.selectionStart===null)return;let l=this.inputEl.selectionStart,Z=this.lastInput.length,c=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(c,G.displayText.replace(/.md$/,""),l,Z);else if(G.matchType==="heading"||G.matchType==="block"){let m=G.displayText;W=this.makeLinkManually(c,m,l,Z)}else if(d)W=this.makeLinkManually(c,G.displayText,l,Z);else{let m=this.app.vault.getAbstractFileByPath(G.file.path);if(m instanceof IX.TFile){let N=G.matchType==="alias"?G.displayText:void 0;W=this.makeLinkObsidianMethod(m,c,l,Z,N)}else W=this.makeLinkManually(c,G.displayText,l,Z)}this.inputEl.trigger("input"),this.close(),this.inputEl.setSelectionRange(W,W)}makeLinkObsidianMethod(G,l,Z,c,W){let d=this.app.vault.getAbstractFileByPath(G.path),m=this.app.fileManager.generateMarkdownLink(d,"","",W??"");return this.inputEl.value=this.getNewInputValueForFileLink(l,m,Z,c),Z-c+m.length+2}makeLinkManually(G,l,Z,c){return this.inputEl.value=this.getNewInputValueForFileName(G,l,Z,c),Z-c+l.length+2}getNewInputValueForFileLink(G,l,Z,c){return`${G.substr(0,Z-c-2)}${l}${G.substr(Z)}`}getNewInputValueForFileName(G,l,Z,c){return`${G.substr(0,Z-c)}${l}]]${G.substr(Z)}`}};var KW=class extends PG{constructor(G,l){super(G,l);this.app=G;this.inputEl=l;this.lastInput="";this.lastInputStart=0;this.lastInputLength=0;this.refreshTagIndex(),UI.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((Z,c)=>Z.length!==c.length?Z.length-c.length:Z.localeCompare(c)),this.fuse=new Ql(this.sortedTags,{threshold:.4,includeScore:!0,keys:[""]})}getSuggestions(G){if(this.inputEl.selectionStart===null)return[];let l=this.inputEl.selectionStart,Z=G.slice(0,l),c=pQ.exec(Z);if(!c)return[];let W=Z.lastIndexOf("[[");if(c.index===void 0)return[];if(W!==-1&&W<c.index)return[];let d=c[1];this.lastInput=d,this.lastInputStart=c.index,this.lastInputLength=c[0].length;let m=this.sortedTags.filter(a=>a.toLowerCase().startsWith(d.toLowerCase())).slice(0,5),N=this.fuse.search(d).filter(a=>a.score!==void 0&&a.score<.8).map(a=>a.item).slice(0,10),Y=new Set(m),V=[...m];for(let a of N)!Y.has(a)&&V.length<15&&(V.push(a),Y.add(a));return V}renderSuggestion(G,l){let Z=this.renderMatch(G,this.lastInput);l.innerHTML=Z}selectSuggestion(G){let l=this.inputEl;if(l.selectionStart===null)return;let Z=this.lastInputStart,c=Z+this.lastInputLength,W=G.startsWith("#")?G:`#${G}`;Xa(l,Z,c,W,{fromCompletion:!0}),this.close()}};var IG=class b extends DW.Modal{constructor(G,l,Z,c){super(G);this.header=l;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=Z??"",this.input=c??"",this.waitForClose=new Promise((W,d)=>{this.resolvePromise=W,this.rejectPromise=d}),this.display(),this.open(),this.fileSuggester=new jW(G,this.inputComponent.inputEl),this.tagSuggester=new KW(G,this.inputComponent.inputEl)}static Prompt(G,l,Z,c){return new b(G,l,Z,c).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,Z){let c=new DW.TextComponent(G);return c.inputEl.style.width="100%",c.setPlaceholder(l??"").setValue(Z??"").onChange(W=>this.input=W).inputEl.addEventListener("keydown",this.submitEnterCallback),c}createButton(G,l,Z){let c=new DW.ButtonComponent(G);return c.setButtonText(l).onClick(Z),c}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"}submit(){this.didSubmit=!0,this.close()}cancel(){this.close()}resolveInput(){this.didSubmit?this.resolvePromise(this.input):this.rejectPromise("No input given.")}removeInputListener(){this.inputComponent.inputEl.removeEventListener("keydown",this.submitEnterCallback)}onOpen(){super.onOpen(),this.inputComponent.inputEl.focus(),this.inputComponent.inputEl.select()}onClose(){super.onClose(),this.resolveInput(),this.removeInputListener()}};var cu=require Line truncated
`).filter(Boolean).reduce((l,Z)=>{let[c,W,...d]=Z.split(" "),m=Number.parseInt(W,10);return d.forEach((N,Y)=>l[N]=m+Y),l},{});for(let[l,Z]of Object.entries(G)){let c=Vu.default.toByteArray(l);this.rankMap.set(c.join(","),Z),this.textMap.set(Z,c)}this.specialTokens={...b.special_tokens,...I},this.inverseSpecialTokens=Object.entries(this.specialTokens).reduce((l,[Z,c])=>(l[c]=this.textEncoder.encode(Z),l),{})}encode(b,I=[],G="all"){let l=new RegExp(this.patStr,"ug"),Z=lX.specialTokenRegex(Object.keys(this.specialTokens)),c=[],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=lX.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(;Z.lastIndex=Y,N=Z.exec(b),!(N==null||W.has(N[0]));)Y=N.index+1;let V=N?.index??b.length;for(let h of b.substring(m,V).matchAll(l)){let F=this.textEncoder.encode(h[0]),H=this.rankMap.get(F.join(","));if(H!=null){c.push(H);continue}c.push(...Q5(F,this.rankMap))}if(N==null)break;let a=this.specialTokens[N[0]];c.push(a),m=N.index+N[0].length}return c}decode(b){let I=[],G=0;for(let c=0;c<b.length;++c){let W=b[c],d=this.textMap.get(W)??this.inverseSpecialTokens[W];d!=null&&(I.push(d),G+=d.length)}let l=new Uint8Array(G),Z=0;for(let c of I)l.set(c,Z),Z+=c.length;return this.textDecoder.decode(l)}},GZ=lX;X5(GZ,"specialTokenRegex",b=>new RegExp(b.map(I=>n5(I)).join("|"),"g"));function bX(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":return"o200k_base";default:throw new Error("Unknown model")}}var H5={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== Line truncated
! 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==`},t5={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 IHNvbWU= IHdoZW4= b3VnaA== YWNo IHRoYW4= cnU= b25k aWNr IG92ZXI= dmVs IHF1 Cgo= IHNj cmVhdA== cmVl IEl0 b3VuZA== cG9ydA== IGFsc28= IHBhcnQ= ZnRlcg== IGtu IGJlYw== IHRpbWU= ZW5z IDU= b3BsZQ== IHdoYXQ= IG5v ZHU= bWVy YW5n IG5ldw== LS0tLQ== IGdldA== b3J5 aXRpb24= aW5ncw== IGp1c3Q= IGludG8= IDA= ZW50cw== b3Zl dGU= IHBlb3BsZQ== IHByZQ== IGl0cw== IHJlYw== IHR3 aWFu aXJzdA== YXJr b3Jz IHdvcms= YWRl b2I= IHNoZQ== IG91cg== d24= aW5r bGlj IDE5 IEhl aXNo bmRlcg== YXVzZQ== IGhpbQ== b25z IFs= IHJv Zm9ybQ== aWxk YXRlcw== dmVycw== IG9ubHk= b2xs IHNwZQ== Y2s= ZWxs YW1w IGFjYw== IGJs aW91cw== dXJu ZnQ= b29k IGhvdw== aGVk ICc= IGFmdGVy YXc= IGF0dA== b3Y= bmU= IHBsYXk= ZXJ2 aWN0 IGNvdWxk aXR0 IGFt IGZpcnN0 IDY= IGFjdA== ICQ= ZWM= aGluZw== dWFs dWxs IGNvbW0= b3k= b2xk Y2Vz YXRlcg== IGZl IGJldA== d2U= aWZm IHR3bw== b2Nr IGJhY2s= KS4= aWRlbnQ= IHVuZGVy cm91Z2g= c2Vs eHQ= IG1heQ== cm91bmQ= IHBv cGg= aXNz IGRlcw== IG1vLine truncated
! 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==`},e5={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 aWNr IG92ZXI= dmVs IHF1 Cgo= IHNj cmVhdA== cmVl IEl0 b3VuZA== cG9ydA== IGFsc28= IHBhcnQ= ZnRlcg== IGtu IGJlYw== IHRpbWU= ZW5z IDU= b3BsZQ== IHdoYXQ= IG5v ZHU= bWVy YW5n IG5ldw== LS0tLQ== IGdldA== b3J5 aXRpb24= aW5ncw== IGp1c3Q= IGludG8= IDA= ZW50cw== b3Zl dGU= IHBlb3BsZQ== IHByZQ== IGl0cw== IHJlYw== IHR3 aWFu aXJzdA== YXJr b3Jz IHdvcms= YWRl b2I= IHNoZQ== IG91cg== d24= aW5r bGlj IDE5 IEhl aXNo bmRlcg== YXVzZQ== IGhpbQ== b25z IFs= IHJv Zm9ybQ== aWxk YXRlcw== dmVycw== IG9ubHk= b2xs IHNwZQ== Y2s= ZWxs YW1w IGFjYw== IGJs aW91cw== dXJu ZnQ= b29k IGhvdw== aGVk ICc= IGFmdGVy YXc= IGF0dA== b3Y= bmU= IHBsYXk= ZXJ2 aWN0 IGNvdWxk aXR0 IGFt IGZpcnN0 IDY= IGFjdA== ICQ= ZWM= aGluZw== dWFs dWxs IGNvbW0= b3k= b2xk Y2Vz YXRlcg== IGZl IGJldA== d2U= aWZm IHR3bw== b2Nr IGJhY2s= KS4= aWRlbnQ= IHVuZGVy cm91Z2g= c2Vs eHQ= IG1heQ== cm91bmQ= IHBv cGg= aXNz IGRlcw== IG1vc3Q= IGRpZA== IGFkZA== amVjdA== IGluYw== Zm9yZ Line truncated
`,Z}positionTooltip(G,l){let Z=l.getBoundingClientRect();G.style.position="fixed",G.style.left=`${Z.right+10}px`,G.style.top=`${Z.top}px`,G.style.zIndex="1000"}close(){document.querySelectorAll(".qaFileSuggestionItem").forEach(Z=>{let c=Z;c._tooltipCleanup&&c._tooltipCleanup()}),document.querySelectorAll(".qa-file-tooltip").forEach(Z=>Z.remove()),super.close()}async selectSuggestion(G){if(this.inputEl.selectionStart===null)return;let l=this.inputEl.selectionStart,Z=this.lastInput.length,c=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(c,G.displayText.replace(/.md$/,""),l,Z);else if(G.matchType==="heading"||G.matchType==="block"){let m=G.displayText;W=this.makeLinkManually(c,m,l,Z)}else if(d)W=this.makeLinkManually(c,G.displayText,l,Z);else{let m=this.app.vault.getAbstractFileByPath(G.file.path);if(m instanceof Tn.TFile){let N=G.matchType==="alias"?G.displayText:void 0;W=this.makeLinkObsidianMethod(m,c,l,Z,N)}else W=this.makeLinkManually(c,G.displayText,l,Z)}this.inputEl.trigger("input"),this.close(),this.inputEl.setSelectionRange(W,W)}makeLinkObsidianMethod(G,l,Z,c,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,Z,c),Z-c+m.length+2}makeLinkManually(G,l,Z,c){return this.inputEl.value=this.getNewInputValueForFileName(G,l,Z,c),Z-c+l.length+2}getNewInputValueForFileLink(G,l,Z,c){return`${G.substr(0,Z-c-2)}${l}${G.substr(Z)}`}getNewInputValueForFileName(G,l,Z,c){return`${G.substr(0,Z-c)}${l}]]${G.substr(Z)}`}};var Fd=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((Z,c)=>Z.length!==c.length?Z.length-c.length:Z.localeCompare(c)),this.fuse=new Al(this.sortedTags,{threshold:.4,includeScore:!0,keys:[""]})}getSuggestions(G){if(this.inputEl.selectionStart===null)return[];let l=this.inputEl.selectionStart,Z=G.slice(0,l),c=Xt.exec(Z);if(!c)return[];let W=Z.lastIndexOf("[[");if(c.index===void 0)return[];if(W!==-1&&W<c.index)return[];let d=c[1];this.lastInput=d,this.lastInputStart=c.index,this.lastInputLength=c[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 Z=this.lastInputStart,c=Z+this.lastInputLength,W=G.startsWith("#")?G:`#${G}`;DV(l,Z,c,W,{fromCompletion:!0}),this.close()}};var aG=class b extends nd.Modal{constructor(G,l,Z,c,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=Z??"",this.input=c??"",this.waitForClose=new Promise((d,m)=>{this.resolvePromise=d,this.rejectPromise=m}),this.display(),this.open(),this.fileSuggester=new Rd(G,this.inputComponent.inputEl,{sourcePath:this.linkSourcePath}),this.tagSuggester=new Fd(G,this.inputComponent.inputEl)}static Prompt(G,l,Z,c){return new b(G,l,Z,c,void 0).waitForClose}static PromptWithContext(G,l,Z,c,W){return new b(G,l,Z,c,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,Z){let c=new nd.TextComponent(G);return c.inputEl.style.width="100%",c.setPlaceholder(l??"").setValue(Z??"").onChange(W=>this.input=W).inputEl.addEventListener("keydown",this.submitEnterCallback),c}createButton(G,l,Z){let c=new nd.ButtonComponent(G);return c.setButtonText(l).onClick(Z),c}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"}submit(){this.didSubmit=!0,this.close()}cancel(){this.close()}resolveInput(){this.didSubmit?this.resolvePromise(this.input):this.rejectPromise("No input given.")}removeInputListener(){this.inputComponent.inputEl.removeEventListener("keydown",this.submitEnterCallback)}onOpen(){super.onOpen(),this.inputComponent.input Line truncated
`).filter(Boolean).reduce((l,Z)=>{let[c,W,...d]=Z.split(" "),m=Number.parseInt(W,10);return d.forEach((N,Y)=>l[N]=m+Y),l},{});for(let[l,Z]of Object.entries(G)){let c=nu.default.toByteArray(l);this.rankMap.set(c.join(","),Z),this.textMap.set(Z,c)}this.specialTokens={...b.special_tokens,...I},this.inverseSpecialTokens=Object.entries(this.specialTokens).reduce((l,[Z,c])=>(l[c]=this.textEncoder.encode(Z),l),{})}encode(b,I=[],G="all"){let l=new RegExp(this.patStr,"ug"),Z=fn.specialTokenRegex(Object.keys(this.specialTokens)),c=[],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=fn.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(;Z.lastIndex=Y,N=Z.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 R=this.textEncoder.encode(h[0]),t=this.rankMap.get(R.join(","));if(t!=null){c.push(t);continue}c.push(...Eo(R,this.rankMap))}if(N==null)break;let V=this.specialTokens[N[0]];c.push(V),m=N.index+N[0].length}return c}decode(b){let I=[],G=0;for(let c=0;c<b.length;++c){let W=b[c],d=this.textMap.get(W)??this.inverseSpecialTokens[W];d!=null&&(I.push(d),G+=d.length)}let l=new Uint8Array(G),Z=0;for(let c of I)l.set(c,Z),Z+=c.length;return this.textDecoder.decode(l)}},sZ=fn;wo(sZ,"specialTokenRegex",b=>new RegExp(b.map(I=>Jo(I)).join("|"),"g"));function qn(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":return"o200k_base";default:throw new Error("Unknown model")}}var yo={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== Line truncated
! 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==`},oo={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 IHNvbWU= IHdoZW4= b3VnaA== YWNo IHRoYW4= cnU= b25k aWNr IG92ZXI= dmVs IHF1 Cgo= IHNj cmVhdA== cmVl IEl0 b3VuZA== cG9ydA== IGFsc28= IHBhcnQ= ZnRlcg== IGtu IGJlYw== IHRpbWU= ZW5z IDU= b3BsZQ== IHdoYXQ= IG5v ZHU= bWVy YW5n IG5ldw== LS0tLQ== IGdldA== b3J5 aXRpb24= aW5ncw== IGp1c3Q= IGludG8= IDA= ZW50cw== b3Zl dGU= IHBlb3BsZQ== IHByZQ== IGl0cw== IHJlYw== IHR3 aWFu aXJzdA== YXJr b3Jz IHdvcms= YWRl b2I= IHNoZQ== IG91cg== d24= aW5r bGlj IDE5 IEhl aXNo bmRlcg== YXVzZQ== IGhpbQ== b25z IFs= IHJv Zm9ybQ== aWxk YXRlcw== dmVycw== IG9ubHk= b2xs IHNwZQ== Y2s= ZWxs YW1w IGFjYw== IGJs aW91cw== dXJu ZnQ= b29k IGhvdw== aGVk ICc= IGFmdGVy YXc= IGF0dA== b3Y= bmU= IHBsYXk= ZXJ2 aWN0 IGNvdWxk aXR0 IGFt IGZpcnN0 IDY= IGFjdA== ICQ= ZWM= aGluZw== dWFs dWxs IGNvbW0= b3k= b2xk Y2Vz YXRlcg== IGZl IGJldA== d2U= aWZm IHR3bw== b2Nr IGJhY2s= KS4= aWRlbnQ= IHVuZGVy cm91Z2g= c2Vs eHQ= IG1heQ== cm91bmQ= IHBv cGg= aXNz IGRlcw== IG1vLine truncated
! 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==`},io={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 aWNr IG92ZXI= dmVs IHF1 Cgo= IHNj cmVhdA== cmVl IEl0 b3VuZA== cG9ydA== IGFsc28= IHBhcnQ= ZnRlcg== IGtu IGJlYw== IHRpbWU= ZW5z IDU= b3BsZQ== IHdoYXQ= IG5v ZHU= bWVy YW5n IG5ldw== LS0tLQ== IGdldA== b3J5 aXRpb24= aW5ncw== IGp1c3Q= IGludG8= IDA= ZW50cw== b3Zl dGU= IHBlb3BsZQ== IHByZQ== IGl0cw== IHJlYw== IHR3 aWFu aXJzdA== YXJr b3Jz IHdvcms= YWRl b2I= IHNoZQ== IG91cg== d24= aW5r bGlj IDE5 IEhl aXNo bmRlcg== YXVzZQ== IGhpbQ== b25z IFs= IHJv Zm9ybQ== aWxk YXRlcw== dmVycw== IG9ubHk= b2xs IHNwZQ== Y2s= ZWxs YW1w IGFjYw== IGJs aW91cw== dXJu ZnQ= b29k IGhvdw== aGVk ICc= IGFmdGVy YXc= IGF0dA== b3Y= bmU= IHBsYXk= ZXJ2 aWN0 IGNvdWxk aXR0 IGFt IGZpcnN0 IDY= IGFjdA== ICQ= ZWM= aGluZw== dWFs dWxs IGNvbW0= b3k= b2xk Y2Vz YXRlcg== IGZl IGJldA== d2U= aWZm IHR3bw== b2Nr IGJhY2s= KS4= aWRlbnQ= IHVuZGVy cm91Z2g= c2Vs eHQ= IG1heQ== cm91bmQ= IHBv cGg= aXNz IGRlcw== IG1vc3Q= IGRpZA== IGFkZA== amVjdA== IGluYw== Zm9yZ Line truncated
${I}`:""}`;function Ca(b){if(b){let I=new Xu.Notice(Fu("starting",""),1e6);return{setMessage:(G,l)=>{I.setMessage(Fu(G,l))},hide:()=>I.hide()}}return{setMessage:(I,G)=>{M.logMessage(`(${I}) ${G}`)},hide:()=>{}}}var Jl=(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 au(G).encode(b).length}catch{return ZX("cl100k_base").encode(b).length}};async function o5(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 i5(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 _G.Suggest(b,d,G)}El(l,"Prompt template does not exist");let Z=l.path,c=b.vault.getAbstractFileByPath(Z);El(c instanceof pu.TFile,`${Z} is not a file`);let W=await b.vault.cachedRead(c);return[l.basename,W]}async function Qu(b,I,G){if(lI.getState().disableOnlineFeatures)throw new Error("Blocking request to OpenAI: Online features are disabled in settings.");let l=Ca(I.showAssistantMessages);try{let{apiKey:Z,model:c,outputVariableName:W,promptTemplate:d,systemPrompt:m,promptTemplateFolder:N}=I,Y=sZ(b,N),[V,a]=await i5(b,d,Y);l.setMessage("waiting","QuickAdd is formatting the prompt template.");let h=await G(a),F=["prompting",`Using prompt template "${V}".`];l.setMessage(F[0],F[1]);let p=ya(b,Z,c,m,I.modelOptions)(h),u=(await WX(p,100,J=>{l.setMessage(F[0],`${F[1]} (${(J/1e3).toFixed(2)}s)`)},J=>{l.setMessage("finished",`Took ${(J/1e3).toFixed(2)}s.`)})).content,s=("> "+u).replace(/\n/g,`
> `),R={[W]:u,[`${W}-quoted`]:s};return setTimeout(()=>l.hide(),5e3),R}catch(Z){l.setMessage("dead",Z.message),setTimeout(()=>l.hide(),5e3)}}async function WX(b,I,G,l){let Z=Date.now();return await o5(()=>G(Date.now()-Z),b,I),l(Date.now()-Z),await b}async function nu(b,I,G){if(lI.getState().disableOnlineFeatures)throw new Error("Blocking request to OpenAI: Online features are disabled in settings.");let l=Ca(I.showAssistantMessages);try{let{apiKey:Z,model:c,outputVariableName:W,systemPrompt:d,prompt:m,modelOptions:N}=I;l.setMessage("waiting","QuickAdd is formatting the prompt template.");let Y=await G(m),V=["prompting","Using custom prompt."];l.setMessage(V[0],V[1]);let h=ya(b,Z,c,d,N)(Y),H=(await WX(h,100,u=>{l.setMessage(V[0],`${V[1]} (${(u/1e3).toFixed(2)}s)`)},u=>{l.setMessage("finished",`Took ${(u/1e3).toFixed(2)}s.`)})).content,p=("> "+H).replace(/\n/g,`
> `),Q={[W]:H,[`${W}-quoted`]:p};return setTimeout(()=>l.hide(),5e3),Q}catch(Z){l.setMessage("dead",Z.message),setTimeout(()=>l.hide(),5e3)}}var cX=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(Z){l(Z)}}),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 Hu(b,I,G){if(lI.getState().disableOnlineFeatures)throw new Error("Blocking request to OpenAI: Online features are disabled in settings.");let l=Ca(I.showAssistantMessages);try{let{apiKey:Z,model:c,outputVariableName:W,systemPrompt:d,promptTemplate:m,text:N,modelOptions:Y}=I;l.setMessage("chunking","Creating prompt chunks with text and prompt template");let V=I.chunkSeparator||/\n/g,a=N.split(V),h=Jl(d,c),F=await G(m,{chunk:" "}),H=Jl(F,c),p=Ru(c.name)/2-h,Q=I.shouldMerge??!0,u=[],s=p-H;if(Q){let k=[],E="",B=0;for(let y of a){let D=Jl(y,c)+1;if(D>s)throw new Error(`The chunk "${y.slice(0,25)}..." is too large to fit in a single prompt.`);B+D<s?(E+=y,B+=D):(k.push(E),E=y,B=D)}E!==""&&k.push(E);for(let y of k){let D=await G(m,{chunk:y});u.push(D)}}else for(let k of a){let E=Jl(k,c);if(E>p)throw new Error(`Chunk size (${E}) is larger than the maximum chunk size (${p}). Please check your chunk separator.`);let B=await G(m,{chunk:k});u.push(B)}let R=ya(b,Z,c,d,Y),J=["prompting",`${u.length} prompts being sent.`];l.setMessage(J[0],J[1]);let v=new cX(5,1e3*30),w=Promise.all(u.map(k=>v.add(()=>R(k)))),K=(await WX(w,100,k=>{l.setMessage(J[0],`${J[1]} (${(k/1e3).toFixed(2)}s)`)},k=>{l.setMessage("finished",`Took ${(k/1e3).toFixed(2)}s.`)})).map(k=>k.content).join(I.resultJoiner),GI=("> "+K).replace(/\n/g,`
> `),O={[W]:K,[`${W}-quoted`]:GI};return setTimeout(()=>l.hide(),5e3),O}catch(Z){l.setMessage("dead",Z.message),setTimeout(()=>l.hide(),5e3)}}var SW=require("obsidian"),hY=class b extends SW.Modal{constructor(G,l,Z=[]){super(G);this.items=l;this.selectedItems=Z;this._selectedItems=[...Z],this.promise=new Promise((c,W)=>{this.resolvePromise=c,this.rejectPromise=W}),this.display(),this.open()}static Open(G,l,Z){return new b(G,l,Z).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 Z=l.createDiv("checkboxRow");Z.createEl("span",{text:G}),new SW.ToggleComponent(Z).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 SW.ButtonComponent(G).setButtonText("Submit").setCta().onClick(Z=>{this.resolved=!0,this.resolvePromise(this._selectedItems),this.close()})}};var ga=require("obsidian"),RY=class b extends ga.Modal{constructor(G,l,Z){super(G);this.header=l;this.text=Z;this.waitForClose=new Promise(c=>{this.resolvePromise=c}),this.open(),this.display()}static Show(G,l,Z){return new b(G,l,Z).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(Z=>this.contentEl.createEl("p",{text:Z}));let G=this.contentEl.createDiv(),l=new ga.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 qW=require("obsidian");var gc=class b extends qW.Modal{constructor(G,l,Z,c){super(G);this.header=l;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=Z??"",this.input=c??"",this.waitForClose=new Promise((W,d)=>{this.resolvePromise=W,this.rejectPromise=d}),this.display(),this.open(),this.fileSuggester=new jW(G,this.inputComponent.inputEl),this.tagSuggester=new KW(G,this.inputComponent.inputEl)}static Prompt(G,l,Z,c){return new b(G,l,Z,c).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,Z){let c=new qW.TextAreaComponent(G);return c.inputEl.classList.add("wideInputPromptInputEl"),c.inputEl.setAttribute("dir","auto"),c.setPlaceholder(l??"").setValue(Z??"").onChange(W=>this.input=W).inputEl.addEventListener("keydown",this.submitEnterCallback),c}createButton(G,l,Z){let c=new qW.ButtonComponent(G);return c.setButtonText(l).onClick(Z),c}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"}submit(){this.didSubmit=!0,this.close()}cancel(){this.close()}resolveInput(){this.didSubmit?this.resolvePromise(this.input):this.rejectPromise("No input given.")}removeInputListener(){this.inputComponent.inputEl.removeEventListener("keydown",this.submitEnterCallback)}onOpen(){super.onOpen(),this.inputComponent.inputEl.focus(),this.inputComponent.inputEl.select()}onClose(){super.onClose(),this.resolveInput(),this.removeInputListener()}};var FY=require("obsidian"),Tl=class b extends FY.Modal{constructor(G,l,Z){super(G);this.header=l;this.text=Z;this.didSubmit=!1;this.waitForClose=new Promise((c,W)=>{this.resolvePromise=c,this.rejectPromise=W}),this.open(),this.display()}static Prompt(G,l,Z){return new b(G,l,Z).waitForClose}display(){this.containerEl.addClass("quickAddModal","qaYesNoPrompt"),this.contentEl.empty(),this.titleEl.textContent=this.header,this.contentEl.createEl("p",{text:this.text});let G=this.contentEl.createDiv({cls:"yesNoPromptButtonContainer"}),l=new FY.ButtonComponent(G).setButtonText("No").onClick(()=>this.submit(!1)),Z=new FY.ButtonComponent(G).setButtonText("Yes").onClick(()=>this.submit(!0)).setWarning();Z.buttonEl.focus(),A5([l.buttonEl,Z.buttonEl])}submit(G){this.input=G,this.didSubmit=!0,this.close()}onClose(){super.onClose(),this.didSubmit?this.resolvePromise(this.input):this.rejectPromise("No answer given.")}};function A5(b){b.forEach(I Line truncated
`,shouldMerge:d?.shouldMerge??!0},(H,p)=>{let Q={...m,...p};return V(H,Q,!1)});return F?(d?.shouldAssignVariables&&Object.assign(l.variables,F),F):(jI(new Error("AI Assistant returned null"),"Chunked AI Prompt error"),{})},getModels:()=>gb(),getMaxTokens:Z=>{let c=Yb(Z);if(!c)throw new Error(`Model ${Z} not found.`);return c.maxTokens},countTokens(Z,c){return Jl(Z,c)}},utility:{getClipboard:async()=>await navigator.clipboard.readText(),setClipboard:async Z=>await navigator.clipboard.writeText(Z),getSelectedText:()=>{let Z=I.workspace.getActiveViewOfType(Ge.MarkdownView);if(!Z){jI(new Error("No active view"),"Could not get selected text");return}if(!Z.editor.somethingSelected()){jI(new Error("No text selected"),"Could not get selected text");return}return Z.editor.getSelection()}},date:{now:(Z,c)=>fb({format:Z,offset:c}),tomorrow:Z=>fb({format:Z,offset:1}),yesterday:Z=>fb({format:Z,offset:-1})},fieldSuggestions:{getFieldValues:async(Z,c)=>{let W={folder:c?.folder,tags:c?.tags,inline:c?.includeInline??!1},d=I.vault.getMarkdownFiles();d=Zh.filterFiles(d,W,N=>I.metadataCache.getFileCache(N));let m=new Set;for(let N of d){let V=I.metadataCache.getFileCache(N)?.frontmatter?.[Z];if(V!=null){if(Array.isArray(V))V.forEach(a=>{let h=a.toString().trim();h&&m.add(h)});else if(typeof V!="object"){let a=V.toString().trim();a&&m.add(a)}}if(W.inline){let a=await I.vault.read(N);md.getFieldValues(a,Z).forEach(F=>m.add(F))}}return Array.from(m).sort()},clearCache:Z=>{Lb.getInstance().clear(Z)}}}}static async inputPrompt(I,G,l,Z){try{return await IG.Prompt(I,G,l,Z)}catch{return}}static async wideInputPrompt(I,G,l,Z){try{return await gc.Prompt(I,G,l,Z)}catch{return}}static async yesNoPrompt(I,G,l){try{return await Tl.Prompt(I,G,l)}catch{return}}static async infoDialog(I,G,l){try{return await RY.Show(I,G,l)}catch{return}}static async suggester(I,G,l,Z,c=!1,W){try{let d;return typeof G=="function"?d=l.map(G):d=G,c?await Kl.Suggest(I,d,l,{...Z?{placeholder:Z}:{},...W?.renderItem?{renderItem:W.renderItem}:{}}):await _G.Suggest(I,d,l,Z,W?.renderItem)}catch{return}}static async checkboxPrompt(I,G,l){try{return await hY.Open(I,G,l)}catch{return}}};var Vd=class extends rW{};var jG=[];for(let b=0;b<256;++b)jG.push((b+256).toString(16).slice(1));function le(b,I=0){return(jG[b[I+0]]+jG[b[I+1]]+jG[b[I+2]]+jG[b[I+3]]+"-"+jG[b[I+4]]+jG[b[I+5]]+"-"+jG[b[I+6]]+jG[b[I+7]]+"-"+jG[b[I+8]]+jG[b[I+9]]+"-"+jG[b[I+10]]+jG[b[I+11]]+jG[b[I+12]]+jG[b[I+13]]+jG[b[I+14]]+jG[b[I+15]]).toLowerCase()}var jX,zg=new Uint8Array(16);function KX(){if(!jX){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");jX=crypto.getRandomValues.bind(crypto)}return jX(zg)}var xg=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),DX={randomUUID:xg};function Ug(b,I,G){if(DX.randomUUID&&!I&&!b)return DX.randomUUID();b=b||{};let l=b.random??b.rng?.()??KX();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 Z=0;Z<16;++Z)I[G+Z]=l[Z];return I}return le(l)}var Pl=Ug;var $G=class{constructor(I,G){this.name=I,this.type=G,this.id=Pl()}};var be=require("obsidian");var YG=class extends $G{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(be.MarkdownView);if(!G)throw M.logError("no active markdown view."),new Error("no active markdown view.");return G}};var ad=class extends YG{constructor(){super("Cut")}static async run(I){let G=YG.getSelectedText(I),l=YG.getActiveMarkdownView(I);if(!G){M.logError("nothing selected.");return}await navigator.clipboard.writeText(G),l.editor.replaceSelection("")}};var hd=class extends YG{constructor(){super("Copy")}static async run(I){let G=YG.getSelectedText(I);await navigator.clipboard.writeText(G)}};var Rd=class extends YG{constructor(){super("Paste")}static async run(I){let G=await navigator.clipboard.readText(),l=YG.getActiveMarkdownView(I);if(!l){M.logError("no active markdown view.");return}l.editor.replaceSelection(G)}};var Ze=require("obsidian");var Fd=class extends YG{constructor(){super("Paste with format")}static async run(I){let G=YG.getActiveMarkdownView(I);if(!G){M.logError("no active markdown view.");return}let l="";try{if("read"in navigator.clipboard&&navigator.clipboard.read){let Z=await navigator.clipboard.read(),c=!1;for(let W of Z)if(W.types.includes("text/html")){let m=await(await W.getType("text/html")).text();l=await(0,Ze.htmlToMarkdown)(m),c=!0;break}c||(l=await navigator.clipboard.readText())}else l=await navigator.clipboard.readText();G.editor.replaceSelection(l)}catch(Z){M.logWarning(`Formatted paste failed. Falling back to plain text: ${Z}`);try{let c=await navig Line truncated
`)}var We=require("obsidian"),kb=class extends Vd{constructor(I,G,l,Z,c){super(I),this.choice=l,this.plugin=G,this.macro=l?.macro,this.choiceExecutor=Z,this.params={app:this.app,quickAddApi:Yd.GetApi(I,G,Z),variables:{},obsidian:Bg},c?.forEach((W,d)=>{this.params.variables[d]=W})}async run(){if(!this.macro||!this.macro.commands){M.logError(`No commands in the macro for choice '${this.choice.name}'`);return}await this.executeCommands(this.macro.commands)}getOutput(){return this.output}async executeCommands(I){for(let G of I)G?.type==="Obsidian"&&this.executeObsidianCommand(G),G?.type==="UserScript"&&await this.executeUserScript(G),G?.type==="Choice"&&await this.executeChoice(G),G?.type==="Wait"&&await ce(G.time),G?.type==="NestedChoice"&&await this.executeNestedChoice(G),G?.type==="EditorCommand"&&await this.executeEditorCommand(G),G?.type==="AIAssistant"&&await this.executeAIAssistant(G),G?.type==="OpenFile"&&await this.executeOpenFile(G),Object.keys(this.params.variables).forEach(l=>{this.choiceExecutor.variables.set(l,this.params.variables[l])})}async executeUserScript(I){let G=await LW(I,this.app);if(!G){M.logError(`failed to load user script ${I.path}.`);return}G.settings&&(this.userScriptCommand=I);try{await this.userScriptDelegator(G)}catch(l){jI(l,`Failed to run user script ${I.name}`)}this.userScriptCommand&&(this.userScriptCommand=null)}async runScriptWithSettings(I,G){if(typeof I!="function"&&I.entry&&typeof I.entry=="function")return await this.onExportIsFunction(I.entry,G.settings);if(typeof I=="function")return await this.onExportIsFunction(I,G.settings)}async userScriptDelegator(I){switch(typeof I){case"function":this.userScriptCommand?await this.runScriptWithSettings(I,this.userScriptCommand):await this.onExportIsFunction(I);break;case"object":await this.onExportIsObject(I);break;case"bigint":case"boolean":case"number":case"string":this.output=I.toString();break;default:M.logError(`user script in macro for '${this.choice.name}' is invalid`)}}async onExportIsFunction(I,G){this.output=await I(this.params,G||{})}async onExportIsObject(I){if(Object.keys(I).length===0)throw new Error(`user script in macro for '${this.choice.name}' is an empty object`);if(this.userScriptCommand&&I.entry!==null){await this.runScriptWithSettings(I,this.userScriptCommand);return}try{let G=Object.keys(I),l=await _G.Suggest(this.app,G,G);await this.userScriptDelegator(I[l])}catch(G){jI(G,"Error in script object handling","LOG")}}executeObsidianCommand(I){this.app.commands.executeCommandById(I.commandId)}async executeChoice(I){let G=this.plugin.getChoiceById(I.choiceId);if(!G){M.logError("choice could not be found.");return}await this.choiceExecutor.execute(G)}async executeNestedChoice(I){let G=I.choice;if(!G){M.logError(`choice in ${I.name} is invalid`);return}await this.choiceExecutor.execute(G)}async executeEditorCommand(I){switch(I.editorCommandType){case"Cut":await ad.run(this.app);break;case"Copy":await hd.run(this.app);break;case"Paste":await Rd.run(this.app);break;case"Paste with format":await Fd.run(this.app);break;case"Select active line":Xd.run(this.app);break;case"Select link on active line":pd.run(this.app);break}}async executeAIAssistant(I){if(lI.getState().disableOnlineFeatures)throw new Error("Blocking request to OpenAI: Online features are disabled in settings.");let G=lI.getState().ai,l=gb(),Z=I.model==="Ask me"?await _G.Suggest(this.app,l,l):I.model,c=Yb(Z);if(!c)throw new Error(`Model ${Z} not found with any provider.`);let W=new Fb(this.app,UI.instance,this.choiceExecutor),d=Cc(c.name);if(!d)throw new Error(`Model ${c.name} not found in the AI providers settings.`);let m=await Qu(this.app,{apiKey:d.apiKey,model:c,outputVariableName:I.outputVariableName,promptTemplate:I.promptTemplate,promptTemplateFolder:G.promptTemplatesFolderPath,systemPrompt:I.systemPrompt,showAssistantMessages:G.showAssistant,modelOptions:I.modelParameters},async N=>W.formatFileContent(N));for(let N in m)this.choiceExecutor.variables.set(N,m[N])}async executeOpenFile(I){try{let Z=(await new Fb(this.app,UI.instance,this.choiceExecutor).formatFileName(I.filePath,"")).replace(/\\/g,"/"),c="/"+Z;if(c.includes("..")||c.includes("//")){M.logError(`OpenFile: Path traversal not allowed in '${Z}'`);return}let W=this.app.vault.getAbstractFileByPath(Z);if(!W||!(W instanceof We.TFile)){M.logError(`OpenFile: '${Z}' does not exist or is not a file`);return}await AW(this.app,W,{location:I.openInNewTab?"split":"tab",direction:I.direction==="horizontal"?"horizontal":"vertical",focus:!0,mode:"default"})}catch(G){M.logError(`OpenFile: Failed to open file '${I.filePath}': ${G.message}`)}}};var ch=class extends kb{constructor(I,G,l,Z){super(I,G,null,l,Z)}async runAndGetOutput(I){let G=Object.getPrototypeOf(async function(){}).constructor;return await new G(I).bind(this.params,this).call()}};function Og(b){return b.type==="Multi"}function ZZ(b){let I=[],G=l=>{I.push(l),Og(l)&&l.choices&&l.choices.forEach(G)};return b.forEach(G),I}var Wh=class{constru Line truncated
${vI}
\\end{${b}}${vI}`}var de=[...Mg,...jg.map(Kg)];var me=require("obsidian");var Dg=new RegExp(/\\([a-z{}A-Z0-9]*)$/),dh=class extends PG{constructor(G){super(UI.instance.app,G);this.inputEl=G;this.lastInput="";this.symbols=Object.assign([],de),this.elementsRendered=this.symbols.reduce((l,Z)=>{try{l[Z.toString()]=(0,me.renderMath)(Z,!0)}catch{}return l},{})}getSuggestions(G){if(this.inputEl.selectionStart===null)return[];let l=this.inputEl.selectionStart,Z=G.substr(0,l),c=Z.lastIndexOf("\\"),W=Z.substr(c),d=Dg.exec(W),m=[];return d&&(this.lastInput=d[1],m=this.symbols.filter(V=>V.toLowerCase().contains(this.lastInput))),new Ql(m,{findAllMatches:!0,threshold:.8}).search(this.lastInput).map(V=>V.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,Z=this.lastInput.length,c=this.inputEl.value,W=0,d=G.replace(/\\\\/g,"\\");if(this.inputEl.value=`${c.substr(0,l-Z-1)}${d}${c.substr(l)}`,W=l-Z+G.length-1,this.inputEl.trigger("input"),this.close(),G.contains(vI)){let m=this.inputEl.value.indexOf(vI);this.inputEl.value=this.inputEl.value.replace(vI,""),this.inputEl.setSelectionRange(m,m)}else this.inputEl.setSelectionRange(W,W)}};var mh=class b extends Hl.Modal{constructor(){super(UI.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 dh(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 Hl.TextAreaComponent(this.contentEl);l.inputEl.style.width="100%",l.inputEl.style.height="10rem",this.inputEl=l.inputEl,l.onChange((0,Hl.debounce)(async Z=>await this.mathjaxLoop(G,Z),50)),l.inputEl.addEventListener("keydown",this.keybindListener),this.createButtonBar(this.contentEl.createDiv())}async onOpen(){super.onOpen(),await(0,Hl.loadMathJax)()}async mathjaxLoop(G,l){let Z=(0,Hl.renderMath)(l,!0);await(0,Hl.finishRenderMath)(),G.empty(),G.append(Z)}cursorToGoTo(){if(this.inputEl.value.contains(vI)){let G=this.inputEl.value.indexOf(vI);this.inputEl.value=this.inputEl.value.replace(vI,""),this.inputEl.setSelectionRange(G,G)}}createButton(G,l,Z){let c=new Hl.ButtonComponent(G);return c.setButtonText(l).onClick(Z),c}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(vI,"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 Fb=class extends vb{constructor(G,l,Z,c){super();this.app=G;this.plugin=l;this.choiceExecutor=Z;this.dateParser=c||cb,Z&&(this.variables=Z?.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),l=this.replaceRandomInString(l),l}async replaceGlobalVarInString(G){let l=G,Z=0,c=new RegExp(FZ.source,"gi");for(;c.test(l)&&!(++Z>5);)l=l.replace(c,(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}async formatFileName(G,l){if(/\{\{title\}\}/i.test(G))throw new Error("{{title}} cannot be used in file names as it would create a circular dependency. The title is derived from the filename itself.");return this.valueHeader=l,await this.format(G)}async formatFileContent(G){let l=G;return l=await this.format(l),l=await this.replaceLinkToCurrentFileInString(l),l=this.replaceTitleInString(l),l}async formatFolderPath(G){if(/\{\{title\}\}/i.test(G))throw new Error("{{title}} cannot be used in folder paths as it would create a circular dependency. The title is derived from the filename itself.");return await th Line truncated
${I}`:""}`;function Wh(b){if(b){let I=new Hu.Notice(Qu("starting",""),1e6);return{setMessage:(G,l)=>{I.setMessage(Qu(G,l))},hide:()=>I.hide()}}return{setMessage:(I,G)=>{K.logMessage(`(${I}) ${G}`)},hide:()=>{}}}var Dl=(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 Xu(G).encode(b).length}catch{return Pn("cl100k_base").encode(b).length}};async function Bo(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 Oo(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 Rl.Suggest(b,d,G)}Kl(l,"Prompt template does not exist");let Z=l.path,c=b.vault.getAbstractFileByPath(Z);Kl(c instanceof uu.TFile,`${Z} is not a file`);let W=await b.vault.cachedRead(c);return[l.basename,W]}async function su(b,I,G){if(dI.getState().disableOnlineFeatures)throw new Error("Blocking request to OpenAI: Online features are disabled in settings.");let l=Wh(I.showAssistantMessages);try{let{apiKey:Z,model:c,outputVariableName:W,promptTemplate:d,systemPrompt:m,promptTemplateFolder:N}=I,Y=TZ(b,N),[a,V]=await Oo(b,d,Y);l.setMessage("waiting","QuickAdd is formatting the prompt template.");let h=await G(V),R=["prompting",`Using prompt template "${a}".`];l.setMessage(R[0],R[1]);let p=ch(b,Z,c,m,I.modelOptions)(h),H=(await $n(p,100,J=>{l.setMessage(R[0],`${R[1]} (${(J/1e3).toFixed(2)}s)`)},J=>{l.setMessage("finished",`Took ${(J/1e3).toFixed(2)}s.`)})).content,s=("> "+H).replace(/\n/g,`
> `),F={[W]:H,[`${W}-quoted`]:s};return setTimeout(()=>l.hide(),5e3),F}catch(Z){throw l.setMessage("dead",Z.message),setTimeout(()=>l.hide(),5e3),JG(Z)?new GG("Input cancelled by user"):Z}}async function $n(b,I,G,l){let Z=Date.now();return await Bo(()=>G(Date.now()-Z),b,I),l(Date.now()-Z),await b}async function wu(b,I,G){if(dI.getState().disableOnlineFeatures)throw new Error("Blocking request to OpenAI: Online features are disabled in settings.");let l=Wh(I.showAssistantMessages);try{let{apiKey:Z,model:c,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=ch(b,Z,c,d,N)(Y),t=(await $n(h,100,H=>{l.setMessage(a[0],`${a[1]} (${(H/1e3).toFixed(2)}s)`)},H=>{l.setMessage("finished",`Took ${(H/1e3).toFixed(2)}s.`)})).content,p=("> "+t).replace(/\n/g,`
> `),e={[W]:t,[`${W}-quoted`]:p};return setTimeout(()=>l.hide(),5e3),e}catch(Z){throw l.setMessage("dead",Z.message),setTimeout(()=>l.hide(),5e3),Z}}var _n=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(Z){l(Z)}}),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 vu(b,I,G){if(dI.getState().disableOnlineFeatures)throw new Error("Blocking request to OpenAI: Online features are disabled in settings.");let l=Wh(I.showAssistantMessages);try{let{apiKey:Z,model:c,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=Dl(d,c),R=await G(m,{chunk:" "}),t=Dl(R,c),p=eu(c.name)/2-h,e=I.shouldMerge??!0,H=[],s=p-t;if(e){let z=[],L="",w=0;for(let i of V){let C=Dl(i,c)+1;if(C>s)throw new Error(`The chunk "${i.slice(0,25)}..." is too large to fit in a single prompt.`);w+C<s?(L+=i,w+=C):(z.push(L),L=i,w=C)}L!==""&&z.push(L);for(let i of z){let C=await G(m,{chunk:i});H.push(C)}}else for(let z of V){let L=Dl(z,c);if(L>p)throw new Error(`Chunk size (${L}) is larger than the maximum chunk size (${p}). Please check your chunk separator.`);let w=await G(m,{chunk:z});H.push(w)}let F=ch(b,Z,c,d,Y),J=["prompting",`${H.length} prompts being sent.`];l.setMessage(J[0],J[1]);let E=new _n(5,1e3*30),Q=Promise.all(H.map(z=>E.add(()=>F(z)))),k=(await $n(Q,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,`
> `),r={[W]:k,[`${W}-quoted`]:f};return setTimeout(()=>l.hide(),5e3),r}catch(Z){throw l.setMessage("dead",Z.message),setTimeout(()=>l.hide(),5e3),Z}}var pd=require("obsidian"),UY=class b extends pd.Modal{constructor(G,l,Z=[]){super(G);this.items=l;this.selectedItems=Z;this._selectedItems=[...Z],this.promise=new Promise((c,W)=>{this.resolvePromise=c,this.rejectPromise=W}),this.display(),this.open()}static Open(G,l,Z){return new b(G,l,Z).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 Z=l.createDiv("checkboxRow");Z.createEl("span",{text:G}),new pd.ToggleComponent(Z).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 pd.ButtonComponent(G).setButtonText("Submit").setCta().onClick(Z=>{this.resolved=!0,this.resolvePromise(this._selectedItems),this.close()})}};var dh=require("obsidian"),BY=class b extends dh.Modal{constructor(G,l,Z){super(G);this.header=l;this.text=Z;this.waitForClose=new Promise(c=>{this.resolvePromise=c}),this.open(),this.display()}static Show(G,l,Z){return new b(G,l,Z).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(Z=>this.contentEl.createEl("p",{text:Z}));let G=this.contentEl.createDiv(),l=new dh.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 td=require("obsidian");var bW=class b extends td.Modal{constructor(G,l,Z,c,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=Z??"",this.input=c??"",this.waitForClose=new Promise((d,m)=>{this.resolvePromise=d,this.rejectPromise=m}),this.display(),this.open(),this.fileSuggester=new Rd(G,this.inputComponent.inputEl,{sourcePath:this.linkSourcePath}),this.tagSuggester=new Fd(G,this.inputComponent.inputEl)}static Prompt(G,l,Z,c){return new b(G,l,Z,c,void 0).waitForClose}static PromptWithContext(G,l,Z,c,W){return new b(G,l,Z,c,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,Z){let c=new td.TextAreaComponent(G);return c.inputEl.classList.add("wideInputPromptInputEl"),c.inputEl.setAttribute("dir","auto"),c.setPlaceholder(l??"").setValue(Z??"").onChange(W=>this.input=W).inputEl.addEventListener("keydown",this.submitEnterCallback),c}createButton(G,l,Z){let c=new td.ButtonComponent(G);return c.setButtonText(l).onClick(Z),c}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.removeEventListener("keydown",this.submitEnterCallback)}onOpen(){super.onOpen(),this.inputComponent.inputEl.focus(),this.inputComponent.inputEl.select()}onClose(){super.onClose(),this.resolveInput(),this.removeInputListener()}};var OY=require("obsidian"),Vb=class b extends OY.Modal{constructor(G,l,Z){super(G);this.header=l;this.text=Z;this.didSubmit=!1;this.waitForClose=new Promise((c,W)=>{this.resolvePromise=c,this.rejectPromise=W}),this.open(),this.display()}static Prompt(G,l,Z){return new b(G,l,Z).waitForClose}display(){this.containerEl.addClass("quickAddModal","qaYesNoPrompt"),this.contentEl.empty(),this.titleEl.textContent=this.header,this.contentEl.createEl("p",{text:this.text});let G=this.contentEl.createDiv({cls:"yesNoPromptButtonContainer"}),l=new OY.ButtonComponent(G).setButtonText("No").onClick(()=>this.submit(!1)),Z=new OY.ButtonComponent(G).setButtonText("Yes").onClick(()=>this.submit Line truncated
`,shouldMerge:d?.shouldMerge??!0},(e,H)=>{let s={...m,...H};return a(e,s,!1)});return p?(d?.shouldAssignVariables&&Object.assign(l.variables,p),p):($I(new Error("AI Assistant returned null"),"Chunked AI Prompt error"),{})},getModels:()=>_b(),getMaxTokens:Z=>{let c=yb(Z);if(!c)throw new Error(`Model ${Z} not found.`);return c.maxTokens},countTokens(Z,c){return Dl(Z,c)}},utility:{getClipboard:async()=>await navigator.clipboard.readText(),setClipboard:async Z=>await navigator.clipboard.writeText(Z),getSelectedText:()=>{let Z=I.workspace.getActiveViewOfType(ds.MarkdownView);if(!Z){$I(new Error("No active view"),"Could not get selected text");return}if(!Z.editor.somethingSelected()){$I(new Error("No text selected"),"Could not get selected text");return}return Z.editor.getSelection()}},date:{now:(Z,c)=>pZ({format:Z,offset:c}),tomorrow:Z=>pZ({format:Z,offset:1}),yesterday:Z=>pZ({format:Z,offset:-1})},fieldSuggestions:{getFieldValues:async(Z,c)=>{let W={folder:c?.folder,tags:c?.tags,inline:c?.includeInline??!1},d=I.vault.getMarkdownFiles();d=Lh.filterFiles(d,W,N=>I.metadataCache.getFileCache(N));let m=new Set;for(let N of d){let a=I.metadataCache.getFileCache(N)?.frontmatter?.[Z];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);id.getFieldValues(V,Z).forEach(R=>m.add(R))}}return Array.from(m).sort()},clearCache:Z=>{lZ.getInstance().clear(Z)}}}}static async inputPrompt(I,G,l,Z){try{return await aG.Prompt(I,G,l,Z)}catch{return}}static async wideInputPrompt(I,G,l,Z){try{return await bW.Prompt(I,G,l,Z)}catch{return}}static async yesNoPrompt(I,G,l){try{return await Vb.Prompt(I,G,l)}catch{return}}static async infoDialog(I,G,l){try{return await BY.Show(I,G,l)}catch{return}}static async suggester(I,G,l,Z,c=!1,W){try{let d;return typeof G=="function"?d=l.map(G):d=G,c?await wl.Suggest(I,d,l,{...Z?{placeholder:Z}:{},...W?.renderItem?{renderItem:W.renderItem}:{}}):await Rl.Suggest(I,d,l,Z,W?.renderItem)}catch{return}}static async checkboxPrompt(I,G,l){try{return await UY.Open(I,G,l)}catch{return}}};var Ld=class extends dd{};var cl=[];for(let b=0;b<256;++b)cl.push((b+256).toString(16).slice(1));function ms(b,I=0){return(cl[b[I+0]]+cl[b[I+1]]+cl[b[I+2]]+cl[b[I+3]]+"-"+cl[b[I+4]]+cl[b[I+5]]+"-"+cl[b[I+6]]+cl[b[I+7]]+"-"+cl[b[I+8]]+cl[b[I+9]]+"-"+cl[b[I+10]]+cl[b[I+11]]+cl[b[I+12]]+cl[b[I+13]]+cl[b[I+14]]+cl[b[I+15]]).toLowerCase()}var kX,Tg=new Uint8Array(16);function zX(){if(!kX){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");kX=crypto.getRandomValues.bind(crypto)}return kX(Tg)}var Sg=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),xX={randomUUID:Sg};function fg(b,I,G){if(xX.randomUUID&&!I&&!b)return xX.randomUUID();b=b||{};let l=b.random??b.rng?.()??zX();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 Z=0;Z<16;++Z)I[G+Z]=l[Z];return I}return ms(l)}var Fl=fg;var $G=class{constructor(I,G){this.name=I,this.type=G,this.id=Fl()}};var Ns=require("obsidian");var HG=class extends $G{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(Ns.MarkdownView);if(!G)throw K.logError("no active markdown view."),new Error("no active markdown view.");return G}};var rd=class extends HG{constructor(){super("Cut")}static async run(I){let G=HG.getSelectedText(I),l=HG.getActiveMarkdownView(I);if(!G){K.logError("nothing selected.");return}await navigator.clipboard.writeText(G),l.editor.replaceSelection("")}};var kd=class extends HG{constructor(){super("Copy")}static async run(I){let G=HG.getSelectedText(I);await navigator.clipboard.writeText(G)}};var zd=class extends HG{constructor(){super("Paste")}static async run(I){let G=await navigator.clipboard.readText(),l=HG.getActiveMarkdownView(I);if(!l){K.logError("no active markdown view.");return}l.editor.replaceSelection(G)}};var Ys=require("obsidian");var xd=class extends HG{constructor(){super("Paste with format")}static async run(I){let G=HG.getActiveMarkdownView(I);if(!G){K.logError("no active markdown view.");return}let l="";try{if("read"in navigator.clipboard&&navigator.clipboard.read){let Z=await navigator.clipboard.read(),c=!1;for(let W of Z)if(W.types.includes("text/html")){let m=await(await W.getType("text/html")).text();l=await(0,Ys.htmlToMarkdown)(m),c=!0;break}c||(l=await navigator.clipboard.readText())}else l=await navigator.clipboard.readText();G.editor.replaceSelection(l)}catch(Z){K.logWarning(`Formatted paste failed. Falling back to plain text: ${Z}`);try{let c=await navig Line truncated
`)}var es=require("obsidian");function Od(b,I){if(I.options)for(let G in I.options){let l=b[G]===void 0,Z="defaultValue"in I.options[G]&&I.options[G].defaultValue!==void 0;l&&Z&&(b[G]=I.options[G].defaultValue)}}var qg=["equals","notEquals","lessThan","lessThanOrEqual","greaterThan","greaterThanOrEqual","contains","notContains"],Vs=new Set(["true","1","yes","on"]),hs=new Set(["false","0","no","off"]);function Gc(b){return qg.includes(b)}function Rs(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 Fs(b){if(!Gc(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 Vs.has(G)?!0:hs.has(G)?!1:!!I}case"string":default:return I}}function BX(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(Vs.has(G))return!0;if(hs.has(G))return!1}return!!b;case"string":default:return b==null?"":String(b)}}function Pg(b){if(!Gc(b.operator))return"";let I=b.expectedValue??"";return I.length===0?"(empty)":b.valueType==="string"?`"${I}"`:I}function _g(b){let I=b.variableName?`$${b.variableName}`:"(missing variable)",G=IA(b.operator),l=Gc(b.operator)?` ${Pg(b)}`:"";return`${I} ${G}${l}`.trim()}function $g(b){let I=b.exportName?`::${b.exportName}`:"";return`script ${b.scriptPath}${I}`}function Md(b){return b.mode==="variable"?_g(b):$g(b)}function IA(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 Xs(b,I){return b.mode==="script"?await I.evaluateScriptCondition(b):GA(b,I.variables)}function GA(b,I){let G=b.variableName?.trim();if(!G)return K.logWarning("Conditional command skipped: No variable name configured."),!1;if(!(G in I))return K.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(Gc(b.operator)){let Z=Fs(b);return Z===void 0?(K.logWarning(`Conditional command: Operator '${b.operator}' requires a comparison value.`),!1):b.operator==="contains"?ns(l,Z,b):b.operator==="notContains"?!ns(l,Z,b):lA(l,Z,b)}return!1}function ns(b,I,G){return b==null?!1:typeof I=="string"&&I.length===0?(K.logWarning("Conditional command: 'contains' operator requires a non-empty comparison value."),!1):Array.isArray(b)?b.map(l=>BX(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=BX(b,G.valueType);switch(G.operator){case"equals":return l===I;case"notEquals":return l!==I;case"lessThan":return rh(l,I,(Z,c)=>Z<c);case"lessThanOrEqual":return rh(l,I,(Z,c)=>Z<=c);case"greaterThan":return rh(l,I,(Z,c)=>Z>c);case"greaterThanOrEqual":return rh(l,I,(Z,c)=>Z>=c);default:return!1}}function rh(b,I,G){let l=Number(b),Z=Number(I);return Number.isNaN(l)||Number.isNaN(Z)?(K.logWarning("Conditional command numeric comparison failed: non-numeric value encountered."),!1):G(l,Z)}var ps=require("obsidian");function lc(b,{logPrefix:I,noticePrefix:G=I,defaultReason:l}){if(!(b instanceof GG))return!1;let Z=typeof b.message=="string"&&b.message.trim().length>0?b.message:l;return K.logMessage(`${I}: ${Z}`),(!(typeof b.message=="string"&&b.message.toLowerCase().includes("cancelled by user"))||dI.getState().showInputCancellationNotification)&&new ps.Notice(`${G}: ${Z}`),!0}function ts(b){return`${b.scriptPath}::${b.exportName??"default"}`}var bZ=class extends Ld{constructor(G,l,Z,c,W,d){super(G);this.conditionalScriptCache=new Map;this.choice=Z,this.plugin=l,this.macro=Z?.macro,this.choiceExecutor=c,this.preloadedUserScripts=d??new Map,this.params={app:this.app,quickAddApi:Ad.GetApi(G,l,c),variables:{},obsidian:bA,abort:m=>{throw new GG(m)}},W?.forEach((m,N)=>{this.params.variables[N]=m})}async run(){if(!this.macro||!this.macro.commands){K.logError(`No commands in the macro for choice '${this.choice.name}'`);return}await this.executeCommands(this.macro.commands)}getOutput(){return this.output}async executeCommands(G){try{for(let l of G)l?.type==="Obsidian"&&this.executeObsidianCommand(l),l?.type==="UserScript"&&await this.executeUserScript(l),l?.type==="Choice"&&await this.executeChoice(l),l?.type==="Wait"&&await as(l.time),l?.type==="NestedChoice"&&awai Line truncated
${LI}
\\end{${b}}${LI}`}var Qs=[...cA,...WA.map(dA)];var Hs=require("obsidian");var mA=new RegExp(/\\([a-z{}A-Z0-9]*)$/),xh=class extends _G{constructor(G){super(fI.instance.app,G);this.inputEl=G;this.lastInput="";this.symbols=Object.assign([],Qs),this.elementsRendered=this.symbols.reduce((l,Z)=>{try{l[Z.toString()]=(0,Hs.renderMath)(Z,!0)}catch{}return l},{})}getSuggestions(G){if(this.inputEl.selectionStart===null)return[];let l=this.inputEl.selectionStart,Z=G.substr(0,l),c=Z.lastIndexOf("\\"),W=Z.substr(c),d=mA.exec(W),m=[];return d&&(this.lastInput=d[1],m=this.symbols.filter(a=>a.toLowerCase().contains(this.lastInput))),new Al(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,Z=this.lastInput.length,c=this.inputEl.value,W=0,d=G.replace(/\\\\/g,"\\");if(this.inputEl.value=`${c.substr(0,l-Z-1)}${d}${c.substr(l)}`,W=l-Z+G.length-1,this.inputEl.trigger("input"),this.close(),G.contains(LI)){let m=this.inputEl.value.indexOf(LI);this.inputEl.value=this.inputEl.value.replace(LI,""),this.inputEl.setSelectionRange(m,m)}else this.inputEl.setSelectionRange(W,W)}};var Uh=class b extends rl.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 xh(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 rl.TextAreaComponent(this.contentEl);l.inputEl.style.width="100%",l.inputEl.style.height="10rem",this.inputEl=l.inputEl,l.onChange((0,rl.debounce)(async Z=>await this.mathjaxLoop(G,Z),50)),l.inputEl.addEventListener("keydown",this.keybindListener),this.createButtonBar(this.contentEl.createDiv())}async onOpen(){super.onOpen(),await(0,rl.loadMathJax)()}async mathjaxLoop(G,l){let Z=(0,rl.renderMath)(l,!0);await(0,rl.finishRenderMath)(),G.empty(),G.append(Z)}cursorToGoTo(){if(this.inputEl.value.contains(LI)){let G=this.inputEl.value.indexOf(LI);this.inputEl.value=this.inputEl.value.replace(LI,""),this.inputEl.setSelectionRange(G,G)}}createButton(G,l,Z){let c=new rl.ButtonComponent(G);return c.setButtonText(l).onClick(Z),c}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(LI,"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 Ab=class extends Tb{constructor(G,l,Z,c){super(G);this.app=G;this.plugin=l;this.choiceExecutor=Z;this.dateParser=c||wb,Z&&(this.variables=Z?.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),l=this.replaceRandomInString(l),l}async replaceGlobalVarInString(G){let l=G,Z=0,c=new RegExp(zZ.source,"gi");for(;c.test(l)&&!(++Z>5);)l=l.replace(c,(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}async formatFileName(G,l){if(/\{\{title\}\}/i.test(G))throw new Error("{{title}} cannot be used in file names as it would create a circular dependency. The title is derived from the filename itself.");this.valueHeader=l;let Z=await this.format(G);return Z=await this.replaceCurrentFileNameInString(Z),Z}async formatFileContent(G){let l=G;return l=await this.format(l),l=await this.replaceLinkToCurrentFileInString(l),l=await this.replaceCurrentFileNameInString(l),l=this.replaceTitleInString(l),l}async formatFolderPath(G){if(/\{\{title\}\}/i.test(G))throw new Error("{{title}} cannot be used in folder paths as Line truncated
Suggested values for ${l}: ${N.slice(0,3).join(", ")}`)}return await IG.Prompt(this.app,`Enter value for ${l}`,m)}let d=`Enter value for ${l}`;return W&&(d=`Enter value for ${l} (default: ${Z.defaultValue})`),await Kl.Suggest(this.app,c,c,{placeholder:d})}generateCacheKey(G){return Gh(G)}async getMacroValue(G){let l=new Wh(this.app,this.plugin,this.plugin.settings.choices,this.choiceExecutor,this.variables),Z=await l.runAndGetOutput(G)??"";return l.getVariables().forEach((c,W)=>{this.variables.set(W,c)}),Z}async getTemplateContent(G){return await new gZ(this.app,this.plugin,G,this.choiceExecutor).run()}async getSelectedText(){let G=this.app.workspace.getActiveViewOfType(Ne.MarkdownView);return G?G.editor.getSelection():""}async getClipboardContent(){try{return await navigator.clipboard.readText()}catch{return""}}async replaceInlineJavascriptInString(G){let l=G;for(;Md.test(l);){let c=Md.exec(l)?.at(1)?.trim();if(c){let W=new ch(this.app,this.plugin,this.choiceExecutor,this.variables),d=await W.runAndGetOutput(c);for(let m in W.params.variables)this.variables.set(m,W.params.variables[m]);l=typeof d=="string"?this.replacer(l,Md,d):this.replacer(l,Md,"")}}return l}async collectValuesManually(G,l){return await lh(this.app,G,l)}};var ae=require("obsidian");var Ye=require("obsidian");function Ve(b){return((0,Ye.normalizePath)(b).split("/").pop()??"").replace(/\.(md|canvas)$/i,"")}var nd=class extends rW{constructor(G,l,Z){super(G);this.plugin=l;this.templater=$V(G),this.formatter=new Fb(G,l,Z)}async getOrCreateFolder(G){let l;if(G.length>1){if(l=await _G.Suggest(this.app,G,G),!l)throw new Error("No folder selected.")}else l=G[0];return l?await this.createFolder(l):l="",l}async getFormattedFilePath(G,l,Z){let c=await this.formatter.formatFileName(l,Z);return this.normalizeMarkdownFilePath(G,c)}getTemplateExtension(G){return Od.test(G)?".canvas":".md"}normalizeTemplateFilePath(G,l,Z){let c=G?`${G}/`:"",W=this.getTemplateExtension(Z),d=l.replace(SZ,"").replace(Od,"");return`${c}${d}${W}`}async incrementFileName(G){let l=await this.app.vault.adapter.exists(G),Z=G,c=Od.test(G)?".canvas":".md",W=c.replace(/\./g,"\\."),d=new RegExp(`(\\d*)${W}$`),N=d.exec(G)?.[1];if(l&&N!==void 0)if(N.length>0){let V=parseInt(N,10);if(Number.isNaN(V))throw new Error("detected numbers but couldn't get them.");Z=Z.replace(d,`${V+1}${c}`)}else Z=Z.replace(new RegExp(`${W}$`),`1${c}`);else l&&(Z=Z.replace(new RegExp(`${W}$`),`1${c}`));return await this.app.vault.adapter.exists(Z)&&(Z=await this.incrementFileName(Z)),Z}async createFileWithTemplate(G,l){try{let Z=await this.getTemplateContent(l),c=Ve(G);this.formatter.setTitle(c);let W=await this.formatter.formatFileContent(Z),d=await this.createFileWithInput(G,W);return await nc(this.app,d),d}catch(Z){return jI(Z,`Could not create file with template at ${G}`),null}}setLinkToCurrentFileBehavior(G){this.formatter.setLinkToCurrentFileBehavior(G)}async overwriteFileWithTemplate(G,l){try{let Z=await this.getTemplateContent(l),c=G.basename;this.formatter.setTitle(c);let W=await this.formatter.formatFileContent(Z);return await this.app.vault.modify(G,W),await nc(this.app,G),G}catch(Z){return jI(Z,"Could not overwrite file with template"),null}}async appendToFileWithTemplate(G,l,Z){try{let c=await this.getTemplateContent(l),W=G.basename;this.formatter.setTitle(W);let d=await this.formatter.formatFileContent(c),m=await this.app.vault.cachedRead(G),N=Z==="top"?`${d}
Suggested values for ${l}: ${N.slice(0,3).join(", ")}`)}return await aG.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: ${Z.defaultValue})`),await wl.Suggest(this.app,c,c,{placeholder:d})}catch(l){throw JG(l)?new GG("Input cancelled by user"):l}}generateCacheKey(G){return oh(G)}async getMacroValue(G){let l=new zh(this.app,this.plugin,this.plugin.settings.choices,this.choiceExecutor,this.variables),Z=await l.runAndGetOutput(G)??"";return l.getVariables().forEach((c,W)=>{this.variables.set(W,c)}),Z}async getTemplateContent(G){return await new bc(this.app,this.plugin,G,this.choiceExecutor).run()}async getSelectedText(){let G=this.app.workspace.getActiveViewOfType(us.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(;nm.test(l);){let c=nm.exec(l)?.at(1)?.trim();if(c){let W=new kh(this.app,this.plugin,this.choiceExecutor,this.variables),d=await W.runAndGetOutput(c);for(let m in W.params.variables)this.variables.set(m,W.params.variables[m]);l=typeof d=="string"?this.replacer(l,nm,d):this.replacer(l,nm,"")}}return l}async collectValuesManually(G,l){return await ih(this.app,G,l)}};var vs=require("obsidian");var ss=require("obsidian");function ws(b){return((0,ss.normalizePath)(b).split("/").pop()??"").replace(/\.(md|canvas)$/i,"")}var jd=class extends dd{constructor(G,l,Z){super(G);this.plugin=l;this.templater=wV(G),this.formatter=new Ab(G,l,Z)}async getOrCreateFolder(G){let l;if(G.length>1)try{if(l=await Rl.Suggest(this.app,G,G),!l)throw new Error("No folder selected.")}catch(Z){throw JG(Z)?new GG("Input cancelled by user"):Z}else l=G[0];return l?await this.createFolder(l):l="",l}async getFormattedFilePath(G,l,Z){let c=await this.formatter.formatFileName(l,Z);return this.normalizeMarkdownFilePath(G,c)}getTemplateExtension(G){return Fm.test(G)?".canvas":".md"}normalizeTemplateFilePath(G,l,Z){let c=G?`${G}/`:"",W=this.getTemplateExtension(Z),d=l.replace(ec,"").replace(Fm,"");return`${c}${d}${W}`}async incrementFileName(G){let l=await this.app.vault.adapter.exists(G),Z=G,c=Fm.test(G)?".canvas":".md",W=c.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.");Z=Z.replace(d,`${a+1}${c}`)}else Z=Z.replace(new RegExp(`${W}$`),`1${c}`);else l&&(Z=Z.replace(new RegExp(`${W}$`),`1${c}`));return await this.app.vault.adapter.exists(Z)&&(Z=await this.incrementFileName(Z)),Z}async createFileWithTemplate(G,l){try{let Z=await this.getTemplateContent(l),c=ws(G);this.formatter.setTitle(c);let W=await this.formatter.formatFileContent(Z),d=this.formatter.getAndClearTemplatePropertyVars();K.logMessage(`TemplateEngine.createFileWithTemplate: Collected ${d.size} template property variables for ${G}`),d.size>0&&K.logMessage(`Variables: ${Array.from(d.keys()).join(", ")}`);let m=await this.createFileWithInput(G,W);return this.shouldPostProcessFrontMatter(m,d)&&await this.postProcessFrontMatter(m,d),await Kc(this.app,m),m}catch(Z){return $I(Z,`Could not create file with template at ${G}`),null}}setLinkToCurrentFileBehavior(G){this.formatter.setLinkToCurrentFileBehavior(G)}async overwriteFileWithTemplate(G,l){try{let Z=await this.getTemplateContent(l),c=G.basename;this.formatter.setTitle(c);let W=await this.formatter.formatFileContent(Z),d=this.formatter.getAndClearTemplatePropertyVars();return K.logMessage(`TemplateEngine.overwriteFileWithTemplate: Collected ${d.size} template property variables for ${G.path}`),d.size>0&&K.logMessage(`Variables: ${Array.from(d.keys()).join(", ")}`),await this.app.vault.modify(G,W),this.shouldPostProcessFrontMatter(G,d)&&await this.postProcessFrontMatter(G,d),await Kc(this.app,G),G}catch(Z){return $I(Z,"Could not overwrite file with template"),null}}async appendToFileWithTemplate(G,l,Z){try{let c=await this.getTemplateContent(l),W=G.basename;this.formatter.setTitle(W);let d=await this.formatter.formatFileContent(c),m=await this.app.vault.cachedRead(G),N=Z==="top"?`${d}
${m}`:`${m}
${d}`;return await this.app.vault.modify(G,N),await nc(this.app,G),G}catch(c){return jI(c,"Could not append to file with template"),null}}async getTemplateContent(G){let l=G;!SZ.test(G)&&!Od.test(G)&&(l+=".md");let Z=this.app.vault.getAbstractFileByPath(l);if(!(Z instanceof ae.TFile))throw new Error(`Template file not found at path "${l}".`);return await this.app.vault.cachedRead(Z)}};var gZ=class extends nd{constructor(G,l,Z,c){super(G,l,c);this.templatePath=Z}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}};var ml=class extends vb{constructor(G,l,Z){super();this.app=G;this.plugin=l;this.dateParser=Z||cb}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.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,Z=0,c=new RegExp(FZ.source,"gi");for(;c.test(l)&&!(++Z>5);)l=l.replace(c,(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 ca(G)}getCurrentFileLink(){return Na(this.app.workspace.getActiveFile())}suggestForValue(G){return ma(G)}getMacroValue(G){return Wa(G)}promptForMathValue(){return Promise.resolve("calculation_result")}promptForVariable(G,l){return Promise.resolve(da(G))}async getTemplateContent(G){try{return await new gZ(this.app,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(TZ.source,"gi"),(Z,c,W,d)=>{let m=c?.trim(),N=W?.trim(),Y=d?.trim();if(!m||!N)return Z;let V=new Date,a;try{a=Eb.generate(N,V)}catch{a=`[${N} format]`}return Y&&(a+=` (default: ${Y})`),a}),l}replaceRandomInString(G){let l=G;return l=l.replace(/{{RANDOM:(\d+)}}/gi,(Z,c)=>{let W=parseInt(c);if(W<=0||W>100)return Z;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}};function Tg(b){return typeof b=="object"&&b!==null&&"enabled"in b&&"placement"in b}function oZ(b){return Tg(b)?{enabled:b.enabled,placement:b.placement??"replaceSelection",requireActiveFile:b.requireActiveFile??!0}:{enabled:b,placement:"replaceSelection",requireActiveFile:!!b}}var rG=class extends PG{constructor(G,l,Z,c=!1){super(G,l);this.app=G;this.inputEl=l;this.plugin=Z;this.suggestForFileNames=c;this.lastInput="";this.lastInputStart=0;this.tokenDefinitions=[{regex:nQ,token:1,suggestion:"{{DATE:}}",cursorOffset:2},{regex:QQ,token:0,suggestion:t2},{regex:iQ,token:10,suggestion:mQ},{regex:HQ,token:4,suggestion:e2},{regex:uQ,token:3,suggestion:DZ},{regex:EQ,token:9,suggestion:NQ},{regex:yQ,token:11,suggestion:aQ},{regex:CQ,token:12,suggestion:hQ},{regex:gQ,token:13,suggestion:"{{RANDOM:}}",cursorOffset:2},{regex:oQ,token:15,suggestion:"{{GLOBAL_VAR:}}",cursorOffset:2},{regex:tQ,token:5,suggestion:"{{VALUE:}}",cursorOffset:2},{regex:eQ,token:2,suggestion:"{{VDATE:}}",cursorOffset:2}];this.contextualTokens=[{regex:sQ,token:6,suggestion:YQ},{regex:JQ,token:14,suggestion:VQ},{regex:wQ,token:8,suggestion:"{{TEMPLATE:"},{regex:vQ,token:7,suggestion:"{{MACRO:"}];this.macroNames=ZZ(this.plugin.settings.choices).filter(W=>W.type==="Macro").map(W=>W.name),this.templatePaths=this.plugin.getTemplateFiles().map(W=>W.path)}async getSuggestions(G){if(this.inputEl.selectionStart===null)return[];let l=this.inputEl.selectionStart,Z=G.lastIndexOf("{{",l-1);if(Z===-1)return[];let c=G.slice(Z,l);if(c.includes("}}"))return[];if(c.includes(":"))return[];let W=[],d=[...this.tokenDefinitions,...this.suggestForFileNames?[]:this.contextualTokens];for(let m of d){let N=m.regex.exec(c);if(N&&N.index+N[0].length===c.length){if(this.lastInput=N[0],this.lastInputType=m.token,this.lastInputStart=l-N[0].length,W.includes(m.suggestion)||W.push(m.suggestion),m.token===8)W.push(...this.templatePaths.map(Y=>`{{TEMPLATE:${Y}}}`));else if(m.token===7)W.push(...this.macroNames.map(Y=>`{{MACRO:${Y}}}`));else if(m.token===2)W.push("{{VDATE:date,YYYY-MM-DD}}","{{VDATE:date,YYYY-MM-DD|today}}","{{VDATE:dueDate,YYYY-MM-DD|next monday}}");else if(m.token===15){let Y=Object.keys(this.plugin?.settings?.globa Line truncated
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function No(){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 zY(b,I){var G=typeof Symbol<"u"&&b[Symbol.iterator]||b["@@iterator"];if(!G){if(Array.isArray(b)||(G=cp(b))||I&&b&&typeof b.length=="number"){G&&(b=G);var l=0,Z=function(){};return{s:Z,n:function(){return l>=b.length?{done:!0}:{done:!1,value:b[l++]}},e:function(m){throw m},f:Z}}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 c=!0,W=!1,d;return{s:function(){G=G.call(b)},n:function(){var m=G.next();return c=m.done,m},e:function(m){W=!0,d=m},f:function(){try{!c&&G.return!=null&&G.return()}finally{if(W)throw d}}}}var Yo="finalize",Vo="consider";function Ed(b,I,G){b.dispatchEvent(new CustomEvent(Yo,{detail:{items:I,info:G}}))}function kZ(b,I,G){b.dispatchEvent(new CustomEvent(Vo,{detail:{items:I,info:G}}))}var Hh="draggedEntered",xY="draggedLeft",uh="draggedOverIndex",Wp="draggedLeftDocument",Rh={LEFT_FOR_ANOTHER:"leftForAnother",OUTSIDE_OF_ANY:"outsideOfAny"};function ao(b,I,G){b.dispatchEvent(new CustomEvent(Hh,{detail:{indexObj:I,draggedEl:G}}))}function ho(b,I,G){b.dispatchEvent(new CustomEvent(xY,{detail:{draggedEl:I,type:Rh.LEFT_FOR_ANOTHER,theOtherDz:G}}))}function Ro(b,I){b.dispatchEvent(new CustomEvent(xY,{detail:{draggedEl:I,type:Rh.OUTSIDE_OF_ANY}}))}function Fo(b,I,G){b.dispatchEvent(new CustomEvent(uh,{detail:{indexObj:I,draggedEl:G}}))}function Xo(b){window.dispatchEvent(new CustomEvent(Wp,{detail:{draggedEl:b}}))}var Yl={DRAG_STARTED:"dragStarted",DRAGGED_ENTERED:Hh,DRAGGED_ENTERED_ANOTHER:"dragEnteredAnother",DRAGGED_OVER_INDEX:uh,DRAGGED_LEFT:xY,DRAGGED_LEFT_ALL:"draggedLeftAll",DROPPED_INTO_ZONE:"droppedIntoZone",DROPPED_INTO_ANOTHER:"droppedIntoAnother",DROPPED_OUTSIDE_OF_ANY:"droppedOutsideOfAny",DRAG_STOPPED:"dragStopped"},ll={POINTER:"pointer",KEYBOARD:"keyboard"},th="isDndShadowItem",eh="data-is-dnd-shadow-item-internal",po="data-is-dnd-shadow-item-hint",Mc="id:dnd-shadow-placeholder-0000",Qo="dnd-action-dragged-el",UG="id",_X=0;function ye(){_X++}function Ce(){if(_X===0)throw new Error("Bug! trying to decrement when there are no dropzones");_X--}var dp=typeof window>"u",nI=function(){};function $X(b){var I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,G,l=I?to(b):b.getBoundingClientRect(),Z=getComputedStyle(b),c=Z.transform;if(c){var W,d,m,N;if(c.startsWith("matrix3d("))G=c.slice(9,-1).split(/, /),W=+G[0],d=+G[5],m=+G[12],N=+G[13];else if(c.startsWith("matrix("))G=c.slice(7,-1).split(/, /),W=+G[0],d=+G[3],m=+G[4],N=+G[5];else return l;var Y=Z.transformOrigin,V=l.x-m-(1-W)*parseFloat(Y),a=l.y-N-(1-d)*parseFloat(Y.slice(Y.indexOf(" ")+1)),h=W?l.width/W:b.offsetWidth,F=d?l.height/d:b.offsetHeight;return{x:V,y:a,width:h,height:F,top:a,right:V+h,bottom:a+F,left:V}}else return l}function ge(b){var I=$X(b);return{top:I.top+window.scrollY,bottom:I.bottom+window.scrollY,left:I.left+window.scrollX,right:I.right+window.scrollX}}function oe(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 ie(b){return{x:(b.left+b.right)/2,y:(b.top+b.bottom)/2}}function no(b,I){return Math.sqrt(Math.pow(b.x-I.x,2)+Math.pow(b.y-I.y,2))}function sh(b,I){return b.y<=I.bottom&&b.y>=I.top&&b.x>=I.left&&b.x<=I.right}function LY(b){return ie(oe(b))}function Qe(b,I){var G=LY(b),l=ge(I);return sh(G,l)}function Ho(b,I){var G=LY(b),l=LY(I);return no(G,l)}function uo(b){var I=oe(b);return I.right<0||I.left>document.documentElement.scrollWidth||I.bottom<0||I.top>document.documentElement.scrollHeight}function to(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 Z=l.getBoundingClientRect(),c=window.getComputedStyle(l).overflowY,W=window.getComputedStyle(l).overflowX,d=c==="scroll"||c==="auto",m=W==="scroll"||W==="auto";d&&(G.top=Math.max(G.top,Z.top),G.bottom=Math.min(G.bottom,Z.bottom)),m&&(G.left=Math.max(G.left,Z.left),G.right=Math.min(G.right,Z.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 sd;function mp(){nI(function(){return"resetting indexes cache"}),sd=new Map}mp();function eo(b){var I=Array.from(b.children).findIndex(function(G){return G.getAttribute(eh)});if(I>=0)return sd.has(b)||sd.set(b,new Map),sd.get(b).set(I,ge(b.children[I])),I}function so(b,I){if(!Qe(b,I))return null;var G=I.children;if(G.length===0)return{index:0,isProximityBased:!0};for(var l=eo(I),Z=0;Z<G.length;Z++)if(Qe(b,G[Z])){var c=sd.has(I)&&sd.get(I).get(Z);return c&&!sh(LY(b),c)?{index:l,isProximityBased:!1}:{index:Z,isProximityBased:!1}}for(var W=Number.MAX_VALUE,d=void 0,m=0;m<G.length;m++){var N=Ho(b,G[m]);N<W&&(W=N,d=m)}return{index:d,isProximityBased:!0}}function pb(b){return JSON.stringify(b,null,2)}function Fh(b){if(!b)throw new Error("cannot get depth of a falsy node");return Ae(b,0)}function Ae(b){var I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return b.parentElement?Ae(b.parentElement,I+1):I-1}function wo(b,I){if(Object.keys(b).length!==Object.keys(I).length)return!1;for(var G in b)if(!{}.hasOwnProper Line truncated
${d}`;return await this.app.vault.modify(G,N),await Kc(this.app,G),G}catch(c){return $I(c,"Could not append to file with template"),null}}async getTemplateContent(G){let l=G;!ec.test(G)&&!Fm.test(G)&&(l+=".md");let Z=this.app.vault.getAbstractFileByPath(l);if(!(Z instanceof vs.TFile))throw new Error(`Template file not found at path "${l}".`);return await this.app.vault.cachedRead(Z)}};var bc=class extends jd{constructor(G,l,Z,c){super(G,l,c);this.templatePath=Z}async run(){let G=await this.getTemplateContent(this.templatePath);return G||K.logError(`Template ${this.templatePath} not found.`),G=await this.formatter.formatFileContent(G),G}getAndClearTemplatePropertyVars(){return this.formatter.getAndClearTemplatePropertyVars()}};var vl=class extends Tb{constructor(G,l,Z){super(G);this.plugin=l;this.dateParser=Z||wb}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,Z=0,c=new RegExp(zZ.source,"gi");for(;c.test(l)&&!(++Z>5);)l=l.replace(c,(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 gV(G)}getCurrentFileLink(){return this.app?kV(this.app.workspace.getActiveFile()):null}getCurrentFileName(){return this.app?zV(this.app.workspace.getActiveFile()):"current_filename"}suggestForValue(G,l=!1){return rV(G)}getMacroValue(G){return AV(G)}promptForMathValue(){return Promise.resolve("calculation_result")}promptForVariable(G,l){return Promise.resolve(LV(G))}async getTemplateContent(G){let l=this.app;if(!l)return`Template (app unavailable): ${G}`;try{return await new bc(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(tc.source,"gi"),(Z,c,W,d)=>{let m=c?.trim(),N=W?.trim(),Y=d?.trim();if(!m||!N)return Z;let a=new Date,V;try{V=Sb.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,(Z,c)=>{let W=parseInt(c);if(W<=0||W>100)return Z;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}};function NA(b){return typeof b=="object"&&b!==null&&"enabled"in b&&"placement"in b}function Zc(b){return NA(b)?{enabled:b.enabled,placement:b.placement??"replaceSelection",requireActiveFile:b.requireActiveFile??!0}:{enabled:b,placement:"replaceSelection",requireActiveFile:!!b}}var Bh=require("obsidian");var Xl=class extends _G{constructor(G,l,Z,c=1/0){super(G,l);this.app=G;this.inputEl=l;this.items=Z;this.maxSuggestions=c}getSuggestions(G){let l=G.toLowerCase(),Z=this.items.filter(W=>W.toLowerCase().includes(l));return Z.length===0&&this.close(),Z.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 hW(b){let{app:I,parent:G,initialValue:l="",placeholder:Z,required:c=!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:R,fullWidth:t=!0,marginBottomPx:p=8,onChange:e}=b,H=a==="textarea"?new Bh.TextAreaComponent(G):new Bh.TextComponent(G),s=H.inputEl;t&&(s.style.width="100%"),s.style.marginBottom=`${p}px`,a==="textarea"&&(s.style.minHeight="10rem"),Z&&H.setPlaceholder(Z),H.setValue(l);let F=G.createDiv({cls:"qa-field-hint"});F.setAttr("aria-live","polite");let J=R??`qa-hint-${Math.random().toString(36).slice(2)}`;F.setAttr("id",J),s.setAttribute("aria-describedby",J);let E;m&&m.length&&(E=new Xl(I,s,m,N)),Y.forEach(w=>w(s));let Q=!1,g=0,o=c,k=w=>h?w.trim():w,f=w=>{let i=!!w;s.toggleClass("is-invalid",i),s.setAttribute("aria-invalid",String(i)),F.textContent=w??""},r=async w=>{if(o&&k(w).length===0)return f(W),!1;if(!d)return f(void 0),!0;let i=++g,C=await Promise.resolve(d(w));if(i!==g||Q)return!0;let B,M;return typeof C=="boolean"?(B=C, Line truncated
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function sA(){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 Na(b,I){var G=typeof Symbol<"u"&&b[Symbol.iterator]||b["@@iterator"];if(!G){if(Array.isArray(b)||(G=$X(b))||I&&b&&typeof b.length=="number"){G&&(b=G);var l=0,Z=function(){};return{s:Z,n:function(){return l>=b.length?{done:!0}:{done:!1,value:b[l++]}},e:function(m){throw m},f:Z}}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 c=!0,W=!1,d;return{s:function(){G=G.call(b)},n:function(){var m=G.next();return c=m.done,m},e:function(m){W=!0,d=m},f:function(){try{!c&&G.return!=null&&G.return()}finally{if(W)throw d}}}}var wA="finalize",vA="consider";function _d(b,I,G){b.dispatchEvent(new CustomEvent(wA,{detail:{items:I,info:G}}))}function mc(b,I,G){b.dispatchEvent(new CustomEvent(vA,{detail:{items:I,info:G}}))}var $h="draggedEntered",Ya="draggedLeft",I2="draggedOverIndex",Ip="draggedLeftDocument",Th={LEFT_FOR_ANOTHER:"leftForAnother",OUTSIDE_OF_ANY:"outsideOfAny"};function EA(b,I,G){b.dispatchEvent(new CustomEvent($h,{detail:{indexObj:I,draggedEl:G}}))}function JA(b,I,G){b.dispatchEvent(new CustomEvent(Ya,{detail:{draggedEl:I,type:Th.LEFT_FOR_ANOTHER,theOtherDz:G}}))}function yA(b,I){b.dispatchEvent(new CustomEvent(Ya,{detail:{draggedEl:I,type:Th.OUTSIDE_OF_ANY}}))}function CA(b,I,G){b.dispatchEvent(new CustomEvent(I2,{detail:{indexObj:I,draggedEl:G}}))}function oA(b){window.dispatchEvent(new CustomEvent(Ip,{detail:{draggedEl:b}}))}var Jl={DRAG_STARTED:"dragStarted",DRAGGED_ENTERED:$h,DRAGGED_ENTERED_ANOTHER:"dragEnteredAnother",DRAGGED_OVER_INDEX:I2,DRAGGED_LEFT:Ya,DRAGGED_LEFT_ALL:"draggedLeftAll",DROPPED_INTO_ZONE:"droppedIntoZone",DROPPED_INTO_ANOTHER:"droppedIntoAnother",DROPPED_OUTSIDE_OF_ANY:"droppedOutsideOfAny",DRAG_STOPPED:"dragStopped"},el={POINTER:"pointer",KEYBOARD:"keyboard"},G2="isDndShadowItem",l2="data-is-dnd-shadow-item-internal",iA="data-is-dnd-shadow-item-hint",XW="id:dnd-shadow-placeholder-0000",gA="dnd-action-dragged-el",bl="id",DX=0;function Ms(){DX++}function js(){if(DX===0)throw new Error("Bug! trying to decrement when there are no dropzones");DX--}var Gp=typeof window>"u",oI=function(){};function TX(b){var I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,G,l=I?kA(b):b.getBoundingClientRect(),Z=getComputedStyle(b),c=Z.transform;if(c){var W,d,m,N;if(c.startsWith("matrix3d("))G=c.slice(9,-1).split(/, /),W=+G[0],d=+G[5],m=+G[12],N=+G[13];else if(c.startsWith("matrix("))G=c.slice(7,-1).split(/, /),W=+G[0],d=+G[3],m=+G[4],N=+G[5];else return l;var Y=Z.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,R=d?l.height/d:b.offsetHeight;return{x:a,y:V,width:h,height:R,top:V,right:a+h,bottom:V+R,left:a}}else return l}function Ks(b){var I=TX(b);return{top:I.top+window.scrollY,bottom:I.bottom+window.scrollY,left:I.left+window.scrollX,right:I.right+window.scrollX}}function Ds(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 Ts(b){return{x:(b.left+b.right)/2,y:(b.top+b.bottom)/2}}function AA(b,I){return Math.sqrt(Math.pow(b.x-I.x,2)+Math.pow(b.y-I.y,2))}function b2(b,I){return b.y<=I.bottom&&b.y>=I.top&&b.x>=I.left&&b.x<=I.right}function Wa(b){return Ts(Ds(b))}function is(b,I){var G=Wa(b),l=Ks(I);return b2(G,l)}function LA(b,I){var G=Wa(b),l=Wa(I);return AA(G,l)}function rA(b){var I=Ds(b);return I.right<0||I.left>document.documentElement.scrollWidth||I.bottom<0||I.top>document.documentElement.scrollHeight}function kA(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 Z=l.getBoundingClientRect(),c=window.getComputedStyle(l).overflowY,W=window.getComputedStyle(l).overflowX,d=c==="scroll"||c==="auto",m=W==="scroll"||W==="auto";d&&(G.top=Math.max(G.top,Z.top),G.bottom=Math.min(G.bottom,Z.bottom)),m&&(G.left=Math.max(G.left,Z.left),G.right=Math.min(G.right,Z.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 fd;function lp(){oI(function(){return"resetting indexes cache"}),fd=new Map}lp();function zA(b){var I=Array.from(b.children).findIndex(function(G){return G.getAttribute(l2)});if(I>=0)return fd.has(b)||fd.set(b,new Map),fd.get(b).set(I,Ks(b.children[I])),I}function xA(b,I){if(!is(b,I))return null;var G=I.children;if(G.length===0)return{index:0,isProximityBased:!0};for(var l=zA(I),Z=0;Z<G.length;Z++)if(is(b,G[Z])){var c=fd.has(I)&&fd.get(I).get(Z);return c&&!b2(Wa(b),c)?{index:l,isProximityBased:!1}:{index:Z,isProximityBased:!1}}for(var W=Number.MAX_VALUE,d=void 0,m=0;m<G.length;m++){var N=LA(b,G[m]);N<W&&(W=N,d=m)}return{index:d,isProximityBased:!0}}function kb(b){return JSON.stringify(b,null,2)}function Sh(b){if(!b)throw new Error("cannot get depth of a falsy node");return Ss(b,0)}function Ss(b){var I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return b.parentElement?Ss(b.parentElement,I+1):I-1}function UA(b,I){if(Object.keys(b).length!==Object.keys(I).length)return!1;for(var G in b)if(!{}.hasOwnProper Line truncated
${G?"Deleting this choice will delete all ("+b.choices.length+") choices inside it!":""}
${l?"Deleting this choice will delete its macro commands!":""}
`)}async function Zs(b,I,G){if(b.type==="Multi"){let Z=await IG.Prompt(I,`Rename ${b.name}`,"",b.name);return Z?{...b,name:Z}:void 0}let l=ri(b,I,G);if(!l)throw new Error("Invalid choice type");return await l.waitForClose}function cs(b){return{...b,command:!b.command}}var Uh=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 Ws(b,I,G){if(!I||!G)return b;let l=np(b,I),Z=np(b,G);if(!l||!Z||Z.type!=="Multi"||l.type==="Multi"&&(l.id===Z.id||zi(l).has(Z.id)))return b;let{updated:c,removed:W}=ds(b,I);return W?ms(c,G,W)??b:b}function np(b,I){for(let G of b){if(G.id===I)return G;if(G.type==="Multi"){let l=np(G.choices,I);if(l)return l}}}function zi(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 ds(b,I){let G;return{updated:b.map(Z=>{if(Z.id===I){G=Z;return}if(Z.type!=="Multi")return Z;let c=ds(Z.choices,I);return c.removed&&(G=c.removed),c.removed?{...Z,choices:c.updated}:Z}).filter(Boolean),removed:G}}function ms(b,I,G){let l=!1,Z=b.map(c=>{if(c.id===I&&c.type==="Multi"){l=!0;let d=c;return{...d,choices:[...d.choices,G]}}if(c.type!=="Multi")return c;let W=ms(c.choices,I,G);return W?(l=!0,{...c,choices:W}):c});return l?Z:void 0}var Bb=require("obsidian");var sG=require("obsidian");var Ns=require("obsidian");var Bh=null,xi=24*60*60*1e3;async function KY(){if(Bh&&Date.now()-Bh.fetchedAt<xi)return Bh.data;if(lI.getState().disableOnlineFeatures)throw new Error("Fetching models directory is disabled: Online features are turned off.");let I=await(await(0,Ns.requestUrl)({url:"https://models.dev/api.json",method:"GET"})).json;return Bh={data:I,fetchedAt:Date.now()},I}function Ui(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}async function Oh(b){let I=await KY(),G=Ui(b.endpoint);if(!G||!(G in I))throw new Error(`Could not determine models.dev provider for endpoint: ${b.endpoint}`);let l=I[G];return Object.values(l.models)}function Mh(b){return b.map(I=>({name:I.id,maxTokens:Math.max(1,Math.floor(I.limit?.context??128e3))}))}function tp(b,I){let G=new Set(b.map(Z=>Z.name)),l=I.filter(Z=>!G.has(Z.name));return b.concat(l)}var Ub=require("obsidian");var jh=class extends Ub.Modal{constructor(G,l){super(G);this.allModels=[];this.filtered=[];this.selectedIds=new Set;this.mode="add";this.provider=l,this.waitForClose=new Promise((Z,c)=>{this.resolvePromise=Z,this.rejectPromise=c}),this.open(),this.loadData().then(()=>this.display())}async loadData(){try{await KY(),this.allModels=await Oh(this.provider),this.filtered=this.allModels.slice()}catch(G){new Ub.Notice(`Failed to load model directory: ${G.message??G}`)}}display(){this.contentEl.empty(),this.modalEl.style.width="min(100vw - 32px, 980px)",this.modalEl.style.maxWidth="980px",this.contentEl.style.maxHeight="min(85vh, 800px)",this.contentEl.style.overflowY="auto",this.contentEl.createEl("h2",{text:`Browse models for ${this.provider.name}`}).style.textAlign="center",new Ub.Setting(this.contentEl).setName("Search").addText(l=>{l.setPlaceholder("Filter by name or id").onChange(Z=>{let c=Z.trim().toLowerCase();this.filtered=this.allModels.filter(W=>W.id.toLowerCase().includes(c)||(W.name??"").toLowerCase().includes(c)),this.renderList()})}).addExtraButton(l=>{l.setIcon("check"),l.setTooltip("Select all"),l.onClick(()=>{this.filtered.forEach(Z=>this.selectedIds.add(Z.id)),this.renderList()})}).addExtraButton(l=>{l.setIcon("x"),l.setTooltip("Clear selection"),l.onClick(()=>{this.selectedIds.clear(),this.renderList()})}),new Ub.Setting(this.contentEl).setName("Import mode").setDesc("Add will append new models. Replace Line truncated
`)}async function Qw(b,I,G){if(b.type==="Multi"){let Z=await aG.Prompt(I,`Rename ${b.name}`,"",b.name);return Z?{...b,name:Z}:void 0}let l=dL(b,I,G);if(!l)throw new Error("Invalid choice type");return await l.waitForClose}function Hw(b){return{...b,command:!b.command}}var s2=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 uw(b,I,G){if(!I||!G)return b;let l=Rp(b,I),Z=Rp(b,G);if(!l||!Z||Z.type!=="Multi"||l.type==="Multi"&&(l.id===Z.id||mL(l).has(Z.id)))return b;let{updated:c,removed:W}=sw(b,I);return W?ww(c,G,W)??b:b}function Rp(b,I){for(let G of b){if(G.id===I)return G;if(G.type==="Multi"){let l=Rp(G.choices,I);if(l)return l}}}function mL(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 sw(b,I){let G;return{updated:b.map(Z=>{if(Z.id===I){G=Z;return}if(Z.type!=="Multi")return Z;let c=sw(Z.choices,I);return c.removed&&(G=c.removed),c.removed?{...Z,choices:c.updated}:Z}).filter(Boolean),removed:G}}function ww(b,I,G){let l=!1,Z=b.map(c=>{if(c.id===I&&c.type==="Multi"){l=!0;let d=c;return{...d,choices:[...d.choices,G]}}if(c.type!=="Multi")return c;let W=ww(c.choices,I,G);return W?(l=!0,{...c,choices:W}):c});return l?Z:void 0}var mZ=require("obsidian");var kG=require("obsidian");var vw=require("obsidian");var w2=null,NL=24*60*60*1e3;async function ta(){if(w2&&Date.now()-w2.fetchedAt<NL)return w2.data;if(dI.getState().disableOnlineFeatures)throw new Error("Fetching models directory is disabled: Online features are turned off.");let I=await(await(0,vw.requestUrl)({url:"https://models.dev/api.json",method:"GET"})).json;return w2={data:I,fetchedAt:Date.now()},I}function YL(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}async function v2(b){let I=await ta(),G=YL(b.endpoint);if(!G||!(G in I))throw new Error(`Could not determine models.dev provider for endpoint: ${b.endpoint}`);let l=I[G];return Object.values(l.models)}function E2(b){return b.map(I=>({name:I.id,maxTokens:Math.max(1,Math.floor(I.limit?.context??128e3))}))}function Xp(b,I){let G=new Set(b.map(Z=>Z.name)),l=I.filter(Z=>!G.has(Z.name));return b.concat(l)}var dZ=require("obsidian");var J2=class extends dZ.Modal{constructor(G,l){super(G);this.allModels=[];this.filtered=[];this.selectedIds=new Set;this.mode="add";this.provider=l,this.waitForClose=new Promise((Z,c)=>{this.resolvePromise=Z,this.rejectPromise=c}),this.open(),this.loadData().then(()=>this.display())}async loadData(){try{await ta(),this.allModels=await v2(this.provider),this.filtered=this.allModels.slice()}catch(G){new dZ.Notice(`Failed to load model directory: ${G.message??G}`)}}display(){this.contentEl.empty(),this.modalEl.style.width="min(100vw - 32px, 980px)",this.modalEl.style.maxWidth="980px",this.contentEl.style.maxHeight="min(85vh, 800px)",this.contentEl.style.overflowY="auto",this.contentEl.createEl("h2",{text:`Browse models for ${this.provider.name}`}).style.textAlign="center",new dZ.Setting(this.contentEl).setName("Search").addText(l=>{l.setPlaceholder("Filter by name or id").onChange(Z=>{let c=Z.trim().toLowerCase();this.filtered=this.allModels.filter(W=>W.id.toLowerCase().includes(c)||(W.name??"").toLowerCase().includes(c)),this.renderList()})}).addExtraButton(l=>{l.setIcon("check"),l.setTooltip("Select all"),l.onClick(()=>{this.filtered.forEach(Z=>this.selectedIds.add(Z.id)),this.renderList()})}).addExtraButton(l=>{l.setIcon("x"),l.setTooltip("Clear selection"),l.onClick(()=>{this.selectedIds.clear(),this.renderList()})}),new dZ.Setting(this.contentEl).setName("Import mode").setDesc("Add will append new models. Replace Line truncated
`),d=NI(W),X(I,"class","warning svelte-iqd8ho")},m(m,N){ZI(m,I,N),n(I,G),n(I,l),n(I,Z),n(Z,c),n(Z,d)},p(m,N){N[0]&256&&W!==(W=m[8].missingChoiceIds.join(", ")+"")&&sI(d,W)},d(m){m&&lI(I)}}}function av(b){let I,G,l,Z,c=b[4].missingChoices.length>0&&Vv(b),W=b[4].missingAssets.length>0&&hv(b);return{c(){I=v("section"),G=v("h4"),G.textContent="Warnings",l=j(),c&&c.c(),Z=j(),W&&W.c(),X(I,"class","warning svelte-iqd8ho")},m(d,m){ZI(d,I,m),n(I,G),n(I,l),c&&c.m(I,null),n(I,Z),W&&W.m(I,null)},p(d,m){d[4].missingChoices.length>0?c?c.p(d,m):(c=Vv(d),c.c(),c.m(I,Z)):c&&(c.d(1),c=null),d[4].missingAssets.length>0?W?W.p(d,m):(W=hv(d),W.c(),W.m(I,null)):W&&(W.d(1),W=null)},d(d){d&&lI(I),c&&c.d(),W&&W.d()}}}function Vv(b){let I,G,l=b[4].missingChoices.map(b[23]).join(", ")+"",Z;return{c(){I=v("p"),G=NI(`Missing choices:
`),Z=NI(l)},m(c,W){ZI(c,I,W),n(I,G),n(I,Z)},p(c,W){W[0]&144&&l!==(l=c[4].missingChoices.map(c[23]).join(", ")+"")&&sI(Z,l)},d(c){c&&lI(I)}}}function hv(b){let I,G,l,Z,c=mG(b[4].missingAssets),W=[];for(let d=0;d<c.length;d+=1)W[d]=Rv(Wv(b,c,d));return{c(){I=v("div"),G=v("p"),G.textContent="Missing assets:",l=j(),Z=v("ul");for(let d=0;d<W.length;d+=1)W[d].c();X(Z,"class","svelte-iqd8ho")},m(d,m){ZI(d,I,m),n(I,G),n(I,l),n(I,Z);for(let N=0;N<W.length;N+=1)W[N]&&W[N].m(Z,null)},p(d,m){if(m[0]&528){c=mG(d[4].missingAssets);let N;for(N=0;N<c.length;N+=1){let Y=Wv(d,c,N);W[N]?W[N].p(Y,m):(W[N]=Rv(Y),W[N].c(),W[N].m(Z,null))}for(;N<W.length;N+=1)W[N].d(1);W.length=c.length}},d(d){d&&lI(I),VZ(W,d)}}}function Rv(b){let I,G=b[28].path+"",l,Z,c,W,d=b[9][b[28].kind]+"",m,N;return{c(){I=v("li"),l=NI(G),Z=j(),c=v("span"),W=NI("("),m=NI(d),N=NI(")"),X(c,"class","assetKind svelte-iqd8ho")},m(Y,a){ZI(Y,I,a),n(I,l),n(I,Z),n(I,c),n(c,W),n(c,m),n(c,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 lr(b){let I;return{c(){I=NI("Copy JSON")},m(G,l){ZI(G,I,l)},d(G){G&&lI(I)}}}function br(b){let I;return{c(){I=NI("Copying\u2026")},m(G,l){ZI(G,I,l)},d(G){G&&lI(I)}}}function Zr(b){let I;return{c(){I=NI("Save to file")},m(G,l){ZI(G,I,l)},d(G){G&&lI(I)}}}function cr(b){let I;return{c(){I=NI("Saving\u2026")},m(G,l){ZI(G,I,l)},d(G){G&&lI(I)}}}function Wr(b){let I,G,l,Z,c,W,d,m,N,Y,a,V,h,R,t,p,e,H,s,F,J=b[8].rootCount+"",E,Q,g,o,k,f,r=b[8].totalChoices+"",z,L,w,i,C,B,M=b[8].dependencyCount+"",_,YI,aI,QI,vI,XI,VI=b[8].userScripts+b[8].conditionalScripts+"",EI,PI,hG,sG,nG,tb,xl=b[8].templateFiles+b[8].captureTemplates+"",Ul,ml,Nl,T,rI,xI,KI,ql,Yl,Bl,gZ,aZ,Pl,AZ,Yc,LZ,eb,Ea,Qb,ac,am,Vc,Hb,Ja,u,A,x;function D(OG,RG){return OG[6].length===0?Gr:Ir}let $=D(b,[-1,-1]),II=$(b),P=b[8].missingChoiceIds.length>0&&Yv(b),hI=b[4]&&av(b);function _I(OG,RG){return OG[5]==="copy"?br:lr}let wG=_I(b,[-1,-1]),lG=wG(b);function _l(OG,RG){return OG[5]==="save"?cr:Zr}let UG=_l(b,[-1,-1]),BG=UG(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=j(),Z=v("section"),c=v("input"),d=j(),m=v("div"),N=v("button"),N.textContent="Select visible",Y=j(),a=v("button"),a.textContent="Clear selection",V=j(),h=v("section"),II.c(),R=j(),t=v("section"),p=v("h3"),p.textContent="Package summary",e=j(),H=v("div"),s=v("div"),F=v("strong"),E=NI(J),Q=j(),g=v("span"),g.textContent="Selected choices",o=j(),k=v("div"),f=v("strong"),z=NI(r),L=j(),w=v("span"),w.textContent="Total packaged",i=j(),C=v("div"),B=v("strong"),_=NI(M),YI=j(),aI=v("span"),aI.textContent="Auto-included",QI=j(),vI=v("div"),XI=v("strong"),EI=NI(VI),PI=j(),hG=v("span"),hG.textContent="Scripts embedded",sG=j(),nG=v("div"),tb=v("strong"),Ul=NI(xl),ml=j(),Nl=v("span"),Nl.textContent="Templates embedded",T=j(),P&&P.c(),rI=j(),hI&&hI.c(),xI=j(),KI=v("section"),ql=v("div"),Yl=v("button"),lG.c(),gZ=j(),aZ=v("div"),Pl=v("label"),AZ=v("span"),AZ.textContent="Save to file",Yc=j(),LZ=v("div"),eb=v("input"),Ea=j(),Qb=v("button"),BG.c(),am=j(),Vc=v("section"),Hb=v("button"),Ja=NI("Cancel"),X(G,"class","svelte-iqd8ho"),X(c,"type","text"),X(c,"placeholder","Filter choices"),X(c,"autocapitalize","off"),X(c,"autocorrect","off"),X(c,"spellcheck",W=!1),X(c,"class","svelte-iqd8ho"),X(N,"type","button"),X(N,"class","svelte-iqd8ho"),X(a,"type","button"),X(a,"class","svelte-iqd8ho"),X(m,"class","controlButtons svelte-iqd8ho"),X(Z,"class","controls svelte-iqd8ho"),X(h,"class","choiceList svelte-iqd8ho"),X(p,"class","svelte-iqd8ho"),X(F,"class","svelte-iqd8ho"),X(s,"class","svelte-iqd8ho"),X(f,"class","svelte-iqd8ho"),X(k,"class","svelte-iqd8ho"),X(B,"class","svelte-iqd8ho"),X(C,"class","svelte-iqd8ho"),X(XI,"class","svelte-iqd8ho"),X(vI,"class","svelte-iqd8ho"),X(tb,"class","svelte-iqd8ho"),X(nG,"class","svelte-iqd8ho"),X(H,"class","summaryGrid svelte-iqd8ho"),X(t,"class","summary svelte-iqd8ho"),X(Yl,"type","button"),X(Yl,"class","secondary svelte-iqd8ho"),Yl.disabled=Bl=b[5]!==null,X(ql,"class","actionGroup svelte-iqd8ho"),X(eb,"type","text"),X(eb,"placeholder","QuickAdd Packages/quickadd-package-YYYY-MM-DD.quickadd.json"),X(eb,"class","svelte-iqd8ho"),X(Qb,"type","button"),Qb.disabled=ac=b[5]!==null,X(Qb,"class","svelte-iqd8ho"),X(LZ,"class","saveRow svelte-iqd8ho"),X(aZ,"class","actionGroup svelte-iqd8ho"),X(KI,"class","actions svelte-iqd8ho"),X(Hb,"type","button"),X(Hb,"class","secondary svelte-iqd8ho"),Hb.disabled=u=b[5]!==null,X(Vc,"class","footer svelte-iqd8ho"),X(I,"class","exportPackageModal svelte-iqd8ho")},m(OG,RG){ZI(OG,I,RG),n(I,G),n(I,l),n(I,Z),n(Z,c),DI(c,b[1]),n(Z,d),n(Z,m),n(m,N),n(m,Y),n(m,a),n(I,V),n(I,h),II.m(h,null),n(I,R),n(I,t),n(t,p),n(t,e),n(t,H),n(H,s),n(s,F),n(F,E),n(s,Q),n(s,g),n(H,o),n(H,k),n(k,f),n(f,z),n(k,L),n(k,w),n(H,i),n(H,C),n(C,B),n(B,_),n(C,YI),n(C,aI),n(H,QI),n(H,vI),n(vI,XI),n(XI,EI),n(vI,PI),n(vI,h Line truncated
`)}}).join(`
`)}}var gs=b=>b.join(""),QA=b=>b.split(/\b/),nA=Cs("<<<<<<< YOUR CHANGES","=======",">>>>>>> APP AUTHORS CHANGES",gs),HA={splitFunction:QA,joinFunction:gs,conflictFunction:nA};function rp(b,I,G,l={}){l=Object.assign({},HA,l);let[Z,c,W]=[b,I,G].map(N=>l.splitFunction.call(l,N)),d=fY.merge(Z,c,W);return PY.collateMerge(d,l.joinFunction,l.conflictFunction)}var os=rp;var Ls=require("obsidian");function is(b,I){return b.line===I.line}function uA(b){let I=[];return b.forEach((G,l)=>{let Z=G.match(/^(#+)[\s]+(.*)$/);Z&&I.push({level:Z[1].length,text:Z[2],line:l})}),I}function c2(b,I,G=!1){let l=uA(b),Z=l.find(N=>N.line===I),c=!!Z;if(!c&&G)throw new Error(`Target line ${I} is not a heading, but we are trying to find the end of its section.`);if(!c&&!G){let N=As(b,I,Y=>Y.trim()==="");return N!==null&&N>I?N-1:I}let W=b.length-1,d=tA(Z,l,b,G),m=wA(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 tA(b,I,G,l){let Z=I.findIndex(Y=>is(Y,b)),c=Z===I.length-1,W=G.length-1;if(c)return W;let[d,m]=eA(b,I);if(m&&d===I.length)return W;if(m&&l)return I[d].line-1;if(m&&!l)return I[Z+1].line;if(!l&&!m){let Y=sA(b.line,I);return Y===null?W:Y}return W}function eA(b,I){let G=I.findIndex(Z=>is(Z,b)),l=As(I,G,Z=>Z.level<=b.level);return l===null?[-1,!1]:[l,!0]}function sA(b,I){let G=I.findIndex(l=>l.line>b);return G===-1?null:G}function wA(b,I,G){for(let l=I-1;l>=0;l--)if(G(b[l]))return l;return null}function As(b,I,G){for(let l=I+1;l<b.length;l++)if(G(b[l]))return l;return null}var W2=class extends Fb{constructor(){super(...arguments);this.file=null;this.fileContent="";this.templaterProcessed=!1}async formatContentWithFile(G,l,Z,c){if(this.choice=l,this.file=c,this.fileContent=Z,!l||!c||Z===null)return G;let W=l.insertAfter.enabled||l.prepend||!l.captureToActiveFile;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 Z=await super.formatFileContent(G);if(Z=this.replaceLinebreakInString(Z),l&&this.file&&!this.templaterProcessed){let d=await Ia(this.app,Z,this.file);d&&(Z=d),this.templaterProcessed=!0}if(Z.trim()==="")return this.fileContent;if(this.choice.prepend){let d=!this.choice.task;return`${this.fileContent}${d?`
`:""}${Z}`}if(this.choice.insertAfter.enabled)return await this.insertAfterHandler(Z);let W=this.file?this.getFrontmatterEndPosition(this.file):null;return W?this.insertTextAfterPositionInBody(Z,this.fileContent,W):`${Z}${this.fileContent}`}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 Z=this.normalizeTarget(l),c=-1;for(let W=0;W<G.length;W++){let d=G[W].trimStart();if(d===Z)return W;if(d.startsWith(Z)){let m=d.slice(Z.length);if(/^\s*$/.test(m))return W;c===-1&&(c=W)}}return c}async insertAfterHandler(G){let l=await this.formatLocationString(this.choice.insertAfter.after),Z=TX(this.fileContent),c=this.findInsertAfterIndex(Z,l);if(c===-1){if(this.choice.insertAfter?.createIfNotFound)return await this.createInsertAfterIfNotFound(G);jI(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.");c=c2(Z,c,!!this.choice.insertAfter.considerSubsections)??Z.length-1}return this.insertTextAfterPositionInBody(G,this.fileContent,c)}async createInsertAfterIfNotFound(G){let Z=`${this.replaceLinebreakInString(await this.formatLocationString(this.choice.insertAfter.after))}
${G}`;if(this.choice.insertAfter?.createIfNotFoundLocation===Bd){let c=this.file?this.getFrontmatterEndPosition(this.file):-1;return this.insertTextAfterPositionInBody(Z,this.fileContent,c)}if(this.choice.insertAfter?.createIfNotFoundLocation===RV)return`${this.fileContent}
${Z}`;if(this.choice.insertAfter?.createIfNotFoundLocation===FV)try{let c=this.app.workspace.getActiveViewOfType(Ls.MarkdownView);if(!c)throw new Error("No active view.");let d=c.editor.getCursor().line;if(this.choice.insertAfter?.insertAtEnd){if(!this.file)throw new Error("Tried to get sections without file.");let N=TX(this.fileContent);d=c2(N,d,!!this.choice.insertAfter.considerSubsections)??N.length-1}return this.insertTextAfterPositionInBody(Z,this.fileContent,d)}catch(c){jI(c,`Unable to insert line '${this.choice.insertAfter.after}' at cursor position`)}}getFrontmatterEndPosition(G){let l=this.app.metadataCache.getFileCache(G);return!l||!l.frontmatter?(M.logMessage("could not get frontmatter. Maybe there isn't any."),-1):l.frontmatterPosition?l.frontmatterPosition.end.line:-1}insertTextAfterPositionInBody(G,l,Z){if(Z===-1){let m=!this.choice.task;return`${G}${m?`
`)}}var Uv=b=>b.join(""),Jr=b=>b.split(/\b/),yr=xv("<<<<<<< YOUR CHANGES","=======",">>>>>>> APP AUTHORS CHANGES",Uv),Cr={splitFunction:Jr,joinFunction:Uv,conflictFunction:yr};function Up(b,I,G,l={}){l=Object.assign({},Cr,l);let[Z,c,W]=[b,I,G].map(N=>l.splitFunction.call(l,N)),d=sa.merge(Z,c,W);return wa.collateMerge(d,l.joinFunction,l.conflictFunction)}var Bv=Up;var jv=require("obsidian");function Ov(b,I){return b.line===I.line}function or(b){let I=[];return b.forEach((G,l)=>{let Z=G.match(/^(#+)[\s]+(.*)$/);Z&&I.push({level:Z[1].length,text:Z[2],line:l})}),I}function P2(b,I,G=!1){let l=or(b),Z=l.find(N=>N.line===I),c=!!Z;if(!c&&G)throw new Error(`Target line ${I} is not a heading, but we are trying to find the end of its section.`);if(!c&&!G){let N=Mv(b,I,Y=>Y.trim()==="");return N!==null&&N>I?N-1:I}let W=b.length-1,d=ir(Z,l,b,G),m=Lr(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 ir(b,I,G,l){let Z=I.findIndex(Y=>Ov(Y,b)),c=Z===I.length-1,W=G.length-1;if(c)return W;let[d,m]=gr(b,I);if(m&&d===I.length)return W;if(m&&l)return I[d].line-1;if(m&&!l)return I[Z+1].line;if(!l&&!m){let Y=Ar(b.line,I);return Y===null?W:Y}return W}function gr(b,I){let G=I.findIndex(Z=>Ov(Z,b)),l=Mv(I,G,Z=>Z.level<=b.level);return l===null?[-1,!1]:[l,!0]}function Ar(b,I){let G=I.findIndex(l=>l.line>b);return G===-1?null:G}function Lr(b,I,G){for(let l=I-1;l>=0;l--)if(G(b[l]))return l;return null}function Mv(b,I,G){for(let l=I+1;l<b.length;l++)if(G(b[l]))return l;return null}var _2=class extends Ab{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,Z,c){if(this.choice=l,this.file=c,this.fileContent=Z,!l||!c||Z===null)return G;let W=l.insertAfter.enabled||l.prepend||!l.captureToActiveFile;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 Z=await super.formatFileContent(G);if(Z=this.replaceLinebreakInString(Z),l&&this.file&&!this.templaterProcessed){let d=await vV(this.app,Z,this.file);d&&(Z=d),this.templaterProcessed=!0}if(Z.trim()==="")return this.fileContent;if(this.choice.prepend){let d=!this.choice.task;return`${this.fileContent}${d?`
`:""}${Z}`}if(this.choice.insertAfter.enabled)return await this.insertAfterHandler(Z);let W=this.file?this.getFrontmatterEndPosition(this.file,this.fileContent):null;return W==null||W<0?`${Z}${this.fileContent}`:this.insertTextAfterPositionInBody(Z,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 Z=this.normalizeTarget(l),c=-1;for(let W=0;W<G.length;W++){let d=G[W].trimStart();if(d===Z)return W;if(d.startsWith(Z)){let m=d.slice(Z.length);if(/^\s*$/.test(m))return W;c===-1&&(c=W)}}return c}async insertAfterHandler(G){let l=await this.formatLocationString(this.choice.insertAfter.after),Z=UX(this.fileContent),c=this.findInsertAfterIndex(Z,l);if(c===-1){if(this.choice.insertAfter?.createIfNotFound)return await this.createInsertAfterIfNotFound(G);$I(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.");c=P2(Z,c,!!this.choice.insertAfter.considerSubsections)??Z.length-1}return this.insertTextAfterPositionInBody(G,this.fileContent,c)}async createInsertAfterIfNotFound(G){let Z=`${this.replaceLinebreakInString(await this.formatLocationString(this.choice.insertAfter.after))}
${G}`;if(this.choice.insertAfter?.createIfNotFoundLocation===Rm){let c=this.file?this.getFrontmatterEndPosition(this.file,this.fileContent):-1;return this.insertTextAfterPositionInBody(Z,this.fileContent,c)}if(this.choice.insertAfter?.createIfNotFoundLocation===za)return`${this.fileContent}
${Z}`;if(this.choice.insertAfter?.createIfNotFoundLocation===xa)try{let c=this.app.workspace.getActiveViewOfType(jv.MarkdownView);if(!c)throw new Error("No active view.");let d=c.editor.getCursor().line;if(this.choice.insertAfter?.insertAtEnd){if(!this.file)throw new Error("Tried to get sections without file.");let N=UX(this.fileContent);d=P2(N,d,!!this.choice.insertAfter.considerSubsections)??N.length-1}return this.insertTextAfterPositionInBody(Z,this.fileContent,d)}catch(c){$I(c,`Unable to insert line '${this.choice.insertAfter.after}' at cursor position`)}}getFrontmatterEndPosition(G,l){let Z=this.app.metadataCache.getFileCache(G);if(Z?.frontmatterPosition)return Z.frontmatterPosition.end.line;if(l){let c=this.inferFrontmatterEndLineFromContent(l);if(c!==null)return c}return K.logMessage("could not get frontmatter. Maybe there isn't any."),-1}inferFrontmatterEndLineFromContent(G){let l=oV(G);if(!l)return null;let Z=G.slice(0,l[1]),c=Z.split(/\r?\n/);return c.length===0?null:Z.endsWith(`
`)?c.length-2:c.length-1}insertTextAfterPositionInBody(G,l,Z){if(Z===-1){let m=!this.choice.task;return`${G}${m?`
`:""}${l}`}let c=l.split(`
`),W=c.slice(0,Z+1).join(`
`),d=c.slice(Z+1).join(`
`);return`${W}
${G}${d}`}};function zp(b){return b.captureToActiveFile&&b.newLineCapture?.enabled?b.newLineCapture.direction==="above"?"newLineAbove":"newLineBelow":b.captureToActiveFile&&!b.prepend&&!b.insertAfter.enabled?"currentLine":b.insertAfter.enabled?"insertAfter":b.prepend?"prepend":"append"}var ks=4e3,d2=class extends Vd{constructor(G,l,Z,c){super(G);this.choiceExecutor=c;this.choice=Z,this.plugin=l,this.formatter=new W2(G,l,c)}showSuccessNotice(G,{wasNewFile:l,action:Z}){let c=`'${G.basename}'`;if(l){new xp.Notice(`Created and captured to ${c}`,ks);return}let W="";switch(Z){case"currentLine":W=`Captured to current line in ${c}`;break;case"prepend":W=`Captured to top of ${c}`;break;case"append":W=`Captured to ${c}`;break;case"insertAfter":{let d=this.choice.insertAfter.after;W=d?`Captured to ${c} under '${d}'`:`Captured to ${c}`;break}}new xp.Notice(W,ks)}async run(){try{let G=oZ(this.choice.appendLink);this.formatter.setLinkToCurrentFileBehavior(G.enabled&&!G.requireActiveFile?"optional":"required");let l=await this.getFormattedPathToCaptureTo(this.choice.captureToActiveFile),Z=this.getCaptureContent(),c,W=await this.fileExists(l);if(W)c=this.onFileExists.bind(this);else if(this.choice?.createFileIfItDoesntExist?.enabled)c=(V,a,h)=>this.onCreateFileIfItDoesntExist(V,a,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 c(l,Z),Y=zp(this.choice);if(Y==="currentLine"||Y==="newLineAbove"||Y==="newLineBelow"){let V=await Ia(this.app,N,d);switch(Y){case"currentLine":p0(V,this.app);break;case"newLineAbove":n0(V,this.app);break;case"newLineBelow":H0(V,this.app);break}}else await this.app.vault.modify(d,m),await nc(this.app,d);if(this.plugin.settings.showCaptureNotification){let V=zp(this.choice);this.showSuccessNotice(d,{wasNewFile:!W,action:V})}G.enabled&&Ga(this.app,this.app.fileManager.generateMarkdownLink(d,""),G.placement,{requireActiveView:G.requireActiveFile}),this.choice.openFile&&d&&(la(this.app,d)||await AW(this.app,d,this.choice.fileOpening))}catch(G){jI(G,`Error running capture choice "${this.choice.name}"`)}}getCaptureContent(){let G;return this.choice.format.enabled?G=this.choice.format.format:G=DZ,this.choice.task&&(G=`- [ ] ${G}
`),G}async getFormattedPathToCaptureTo(G){let l=this.choiceExecutor?.variables?.get(jd);if(!G&&l&&typeof l=="string"&&l.length>0)return l;if(G){let Y=this.app.workspace.getActiveFile();return El(Y,"Cannot capture to active file - no active file."),Y.path}let Z=this.choice.captureTo,c=await this.formatFilePath(Z),W=c.replace(/^\/$|\/\.md$|^\.md$/,""),d=W==="",m=d||ba(this.app,W),N=c.startsWith("#");if(m)return this.selectFileInFolder(W,d);if(N){let Y=c.replace(/\.md$/,"");return this.selectFileWithTag(Y)}return c}async selectFileInFolder(G,l){let Z=G.endsWith("/")||l?G:`${G}/`,c=sZ(this.app,Z);El(c.length>0,`Folder ${Z} is empty.`);let W=c.map(N=>N.path),d=await Kl.Suggest(this.app,W.map(N=>N.replace(Z,"")),W);El(!!d&&d.length>0,"No file selected for capture.");let m=d.startsWith(`${Z}`)?d:`${Z}/${d}`;return await this.formatFilePath(m)}async selectFileWithTag(G){let l=G.startsWith("#")?G:`#${G}`,Z=Za(this.app,l);El(Z.length>0,`No files with tag ${G}.`);let c=Z.map(d=>d.path),W=await Kl.Suggest(this.app,c,c);return El(!!W&&W.length>0,"No file selected for capture."),await this.formatFilePath(W)}async onFileExists(G,l){let Z=this.getFileByPath(G);if(!Z)throw new Error("File not found");this.formatter.setTitle(Z.basename);let c=await this.formatter.formatContentOnly(l),W=await this.app.vault.read(Z),d=await this.formatter.formatContentWithFile(c,this.choice,W,Z),m=await this.app.vault.read(Z),N=d;if(m!==W){let Y=os(m,W,d);El(!Y.isSuccess,()=>`The file ${G} has been modified since the last read.
${G}${d}`}};function Bp(b){return b.captureToActiveFile&&b.newLineCapture?.enabled?b.newLineCapture.direction==="above"?"newLineAbove":"newLineBelow":b.captureToActiveFile&&!b.prepend&&!b.insertAfter.enabled?"currentLine":b.insertAfter.enabled?"insertAfter":b.prepend?"prepend":"append"}var Kv=4e3,$2=class extends Ld{constructor(G,l,Z,c){super(G);this.choiceExecutor=c;this.choice=Z,this.plugin=l,this.formatter=new _2(G,l,c)}showSuccessNotice(G,{wasNewFile:l,action:Z}){let c=`'${G.basename}'`;if(l){new Op.Notice(`Created and captured to ${c}`,Kv);return}let W="";switch(Z){case"currentLine":W=`Captured to current line in ${c}`;break;case"prepend":W=`Captured to top of ${c}`;break;case"append":W=`Captured to ${c}`;break;case"insertAfter":{let d=this.choice.insertAfter.after;W=d?`Captured to ${c} under '${d}'`:`Captured to ${c}`;break}}new Op.Notice(W,Kv)}async run(){try{let G=Zc(this.choice.appendLink);this.formatter.setLinkToCurrentFileBehavior(G.enabled&&!G.requireActiveFile?"optional":"required");let l=await this.getFormattedPathToCaptureTo(this.choice.captureToActiveFile),Z=this.getCaptureContent(),c,W=await this.fileExists(l);if(W)c=this.onFileExists.bind(this);else if(this.choice?.createFileIfItDoesntExist?.enabled)c=(a,V,h)=>this.onCreateFileIfItDoesntExist(a,V,G);else{K.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 c(l,Z),Y=Bp(this.choice);if(Y==="currentLine"||Y==="newLineAbove"||Y==="newLineBelow"){let a=await vV(this.app,N,d);switch(Y){case"currentLine":pH(a,this.app);break;case"newLineAbove":eH(a,this.app);break;case"newLineBelow":QH(a,this.app);break}}else await this.app.vault.modify(d,m),await Kc(this.app,d);if(this.plugin.settings.showCaptureNotification){let a=Bp(this.choice);this.showSuccessNotice(d,{wasNewFile:!W,action:a})}G.enabled&&EV(this.app,d,G),this.choice.openFile&&d&&(JV(this.app,d)||await cd(this.app,d,this.choice.fileOpening))}catch(G){if(lc(G,{logPrefix:"Capture execution aborted",noticePrefix:"Capture execution aborted",defaultReason:"Capture aborted"}))return;$I(G,`Error running capture choice "${this.choice.name}"`)}}getCaptureContent(){let G;return this.choice.format.enabled?G=this.choice.format.format:G=pc,this.choice.task&&(G=`- [ ] ${G}
`),G}async getFormattedPathToCaptureTo(G){let l=this.choiceExecutor?.variables?.get(Xm);if(!G&&l&&typeof l=="string"&&l.length>0)return l;if(G){let Y=this.app.workspace.getActiveFile();return Kl(Y,"Cannot capture to active file - no active file."),Y.path}let Z=this.choice.captureTo,c=await this.formatFilePath(Z),W=c.replace(/^\/$|\/\.md$|^\.md$/,""),d=W==="",m=d||yV(this.app,W),N=c.startsWith("#");if(m)return this.selectFileInFolder(W,d);if(N){let Y=c.replace(/\.md$/,"");return this.selectFileWithTag(Y)}return c}async selectFileInFolder(G,l){let Z=G.endsWith("/")||l?G:`${G}/`,c=TZ(this.app,Z);Kl(c.length>0,`Folder ${Z} is empty.`);let W=c.map(N=>N.path),d;try{d=await wl.Suggest(this.app,W.map(N=>N.replace(Z,"")),W)}catch(N){throw JG(N)?new GG("Input cancelled by user"):N}Kl(!!d&&d.length>0,"No file selected for capture.");let m=d.startsWith(`${Z}`)?d:`${Z}/${d}`;return await this.formatFilePath(m)}async selectFileWithTag(G){let l=G.startsWith("#")?G:`#${G}`,Z=CV(this.app,l);Kl(Z.length>0,`No files with tag ${G}.`);let c=Z.map(d=>d.path),W;try{W=await wl.Suggest(this.app,c,c)}catch(d){throw JG(d)?new GG("Input cancelled by user"):d}return Kl(!!W&&W.length>0,"No file selected for capture."),await this.formatFilePath(W)}async onFileExists(G,l){let Z=this.getFileByPath(G);if(!Z)throw new Error("File not found");this.formatter.setTitle(Z.basename),this.formatter.setDestinationFile(Z);let c=await this.formatter.formatContentOnly(l),W=await this.app.vault.read(Z),d=await this.formatter.formatContentWithFile(c,this.choice,W,Z),m=await this.app.vault.read(Z),N=d;if(m!==W){let Y=Bv(m,W,d);Kl(!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:Z,newFileContent:N,captureContent:c}}async onCreateFileIfItDoesntExist(G,l,Z){let c=G.split("/").pop()?.replace(/\.md$/,"")||"";this.formatter.setTitle(c);let W=await this.formatter.formatContentOnly(l),d="";if(this.choice.createFileIfItDoesntExist.createWithTemplate){let V=new gZ(this.app,this.plugin,this.choice.createFileIfItDoesntExist.template,this.choiceExecutor);Z?.enabled&&!Z.requireActiveFile&&V.setLinkToCurrentFileBehavior("optional"),d=await V.run()}let m=await this.createFileWithInput(G,d);this.choice.createFileIfItDoesntExist.createWithTemplate&&d&&await nc(this.app,m);let N=await this.app.vault.read(m),Y=await this.formatter.formatContentWithFile(W,this.choice,N,m);return{file:m,newFileContent:Y,captureContent:W}}async formatFilePath(G){let l=await this.formatter.formatFileName(G,this.choice.name);return this.normalizeMarkdownFilePath("",l)}};var m2=require("obsidian");var rZ=class b extends m2.FuzzySuggestModal{constructor(G,l,Z){super(G.app);this.plugin=G;this.choices=l;this.choiceExecutor=new YZ(this.app,this.plugin);Z&&(this.choiceExecutor=Z)}static Open(G,l,Z){new b(G,l,Z).open()}renderSuggestion(G,l){l.empty(),m2.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 od("\u2190 Back").addChoices(this.choices)),b.Open(this.plugin,l)}};var rs=require("obsidian");var _Y=class extends vb{constructor(G,l,Z){super();this.app=G;this.plugin=l;this.choiceExecutor=Z;this.requirements=new Map;this.templatesToScan=new Set;this.dateParser=cb,Z&&(this.variables=new Map(Z.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 Z=new RegExp(mW.source,"gi"),c;for(;(c=Z.exec(l))!==null;){let W=c[1];W&&this.templatesToScan.add(W)}}return l}async replaceGlobalVarInString(G){let l=G,Z=0,c=new RegExp(FZ.source,"gi");for(;c.test(l)&&!(++Z>5);)l=l.replace(c,(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}scanVariableTokens(G){let l=new RegExp(RZ.source,"gi"),Z;for(;(Z=l.exec(G))!==null;){let c=(Z[1]??"").trim();if(!c)continue;let W=c.indexOf("|"),d=c,m;if(W!==-1&&(m=c.substring(W+1).trim(),d=c.substring(0,W).trim()),!d)continue;let N=W===-1&&d.includes(",");if(this.requirements.has(d)){if(m){let Y=this.requirements.get(d);Y.defaultValue===void 0&&(Y.defaultValue=m)}}else{let Y={id:d,label:d,type:N?"dropdown":"text"};N&&(Y.options=d.split(",").map(V=>V.trim()).filter(Boolean)),m&&(Y.defaultValue=m),this.requirements.set(d,Y)}}}async promptForValue(G){let l="value";return this.requirements.has(l)||this.requirements.set(l,{id:l,label:G||"Enter value",type:this.plugin.settings.inputPrompt==="multi-line"?"textarea":"text",source:"collected"}),""}async promptForVariable(G,l){if(!G)return"";if(l?.type==="VDATE"&&l.dateFormat)return this.requirements.has(G)||this.requirements.set(G,{id:G,label:G,type:"date",defaultValue:l.defaultValue,dateFormat:l.dateFormat,source:"collected"}),l.defaultValue??"";if(!this.requirements.has(G)){let Z=G.includes(","),c={id:G,label:G,type:Z?"dropdown":"text",source:"collected"};Z&&(c.options=G.split(",").map(W=>W.trim()).filter(Boolean)),l?.defaultValue&&(c.defaultValue=l.defaultValue),this.requirements.set(G,c)}return l?.defaultValue??""}async promptForMathValue(){let G="mvalue";return this.requirements.has(G)||this.requirements.set(G,{id:G,label:"Math expression",type:"text",placeholder:"e.g., 2+2*3"}),""}async suggestForField(G){return this.requirements.has(G)||this.requirements.set(G,{id:G,label:G,type:"field-suggest",source:"collected"}),""}async suggestForValue(G){return""}getVariableValue(G){return""}async getTemplateContent(G){return""}async getSelectedText(){return""}async getClipboardContent(){return""}getCurrentFileLink(){return null}async getMacroValue(G){return""}};async function vA(b,I){let l=!SZ.test(I)&&!I.endsWith(".canvas")?`${I}.md`:I,Z=b.vault.getAbstractFileByPath(l);return Z instanceof rs.TFile?await b.vault.cachedRead(Z):""}async function EA(b,I,G,l){let Z=new _Y(b,I,G);if(l.fileNameFormat?.enabled&&await Z.scanString(l.fileNameFormat.format),l.folder?.enabled)for(let c of l.folder.folders??[])await Z.scanStrin Line truncated
This is in order to prevent data loss.`),N=Y.joinedResults()}return{file:Z,newFileContent:N,captureContent:c}}async onCreateFileIfItDoesntExist(G,l,Z){let c=G.split("/").pop()?.replace(/\.md$/,"")||"";this.formatter.setTitle(c),this.formatter.setDestinationSourcePath(G);let W=await this.formatter.formatContentOnly(l),d="";if(this.choice.createFileIfItDoesntExist.createWithTemplate){let a=new bc(this.app,this.plugin,this.choice.createFileIfItDoesntExist.template,this.choiceExecutor);Z?.enabled&&!Z.requireActiveFile&&a.setLinkToCurrentFileBehavior("optional"),d=await a.run();let V=a.getAndClearTemplatePropertyVars();K.logMessage(`CaptureChoiceEngine: Collected ${V.size} template property variables`),V.size>0&&K.logMessage(`Variables: ${Array.from(V.keys()).join(", ")}`),this.templatePropertyVars=V}let m=await this.createFileWithInput(G,d);this.choice.createFileIfItDoesntExist.createWithTemplate&&this.templatePropertyVars&&this.shouldPostProcessFrontMatter(m,this.templatePropertyVars)&&await this.postProcessFrontMatter(m,this.templatePropertyVars),this.choice.createFileIfItDoesntExist.createWithTemplate&&d&&await Kc(this.app,m);let N=await this.app.vault.read(m),Y=await this.formatter.formatContentWithFile(W,this.choice,N,m);return{file:m,newFileContent:Y,captureContent:W}}async formatFilePath(G){let l=await this.formatter.formatFileName(G,this.choice.name);return this.normalizeMarkdownFilePath("",l)}};var IR=require("obsidian");var Nc=class b extends IR.FuzzySuggestModal{constructor(G,l,Z){super(G.app);this.plugin=G;this.choices=l;this.choiceExecutor=new iZ(this.app,this.plugin);Z&&(this.choiceExecutor=Z)}static Open(G,l,Z){new b(G,l,Z).open()}renderSuggestion(G,l){l.empty(),IR.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 Zm("\u2190 Back").addChoices(this.choices)),b.Open(this.plugin,l)}};var Dv=require("obsidian");var va=class extends Tb{constructor(G,l,Z){super(G);this.app=G;this.plugin=l;this.choiceExecutor=Z;this.requirements=new Map;this.templatesToScan=new Set;this.dateParser=wb,Z&&(this.variables=new Map(Z.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 Z=new RegExp(gW.source,"gi"),c;for(;(c=Z.exec(l))!==null;){let W=c[1];W&&this.templatesToScan.add(W)}}return l}async replaceGlobalVarInString(G){let l=G,Z=0,c=new RegExp(zZ.source,"gi");for(;c.test(l)&&!(++Z>5);)l=l.replace(c,(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}scanVariableTokens(G){let l=new RegExp(Ba.source,"gi"),Z;for(;(Z=l.exec(G))!==null;){let c=(Z[1]??"").trim();if(!c)continue;let W=c.indexOf("|"),d=c,m;if(W!==-1&&(m=c.substring(W+1).trim(),d=c.substring(0,W).trim()),!d)continue;let N=W===-1&&d.includes(",");if(this.requirements.has(d)){if(m){let Y=this.requirements.get(d);Y.defaultValue===void 0&&(Y.defaultValue=m)}}else{let Y={id:d,label:d,type:N?"dropdown":"text"};N&&(Y.options=d.split(",").map(a=>a.trim()).filter(Boolean)),m&&(Y.defaultValue=m),this.requirements.set(d,Y)}}}async promptForValue(G){let l="value";return this.requirements.has(l)||this.requirements.set(l,{id:l,label:G||"Enter value",type:this.plugin.settings.inputPrompt==="multi-line"?"textarea":"text",source:"collected"}),""}async promptForVariable(G,l){if(!G)return"";if(l?.type==="VDATE"&&l.dateFormat)return this.requirements.has(G)||this.requirements.set(G,{id:G,label:G,type:"date",defaultValue:l.defaultValue,dateFormat:l.dateFormat,source:"collected"}),l.defaultValue??"";if(!this.requirements.has(G)){let Z=G.includes(","),c={id:G,label:G,type:Z?"dropdown":"text",source:"collected"};Z&&(c.options=G.split(",").map(W=>W.trim()).filter(Boolean)),l?.defaultValue&&(c.defaultValue=l.defaultValue),this.requirements.set(G,c)}return l?.defaultValue??""}async promptForMathValue(){let G="mvalue";return this.requirements.has(G)||this.requirements.set(G,{id:G,label:"Math expression",type:"text",placeholder:"e.g., 2+2*3"}),""}async suggestForField(G){return this.requirements.has(G)||this.requirements.set(G,{id:G,label:G,type:"field-suggest",source:"collected"}),""}async suggestForValue(G){return""}getVariableValue(G){return""}async getTemplateContent(G){return""}async getSelecte Line truncated
${Z}
QuickAdd will now revert to backup.`),b.settings=l}}b.saveSettings()}var Ss=UA;var zd=require("obsidian");async function BA(b,I,G){let l=await fetch(`https://api.github.com/repos/${b}/${I}/releases`),Z=await l.json();if(!l.ok&&"message"in Z||!Array.isArray(Z))throw new Error(`Failed to fetch releases: ${Z.message??"Unknown error"}`);let c=Z.findIndex(W=>W.tag_name===G);if(c===-1)throw new Error(`Could not find release with tag ${G}`);return Z.slice(0,c).filter(W=>!W.draft&&!W.prerelease)}function OA(b,I=1){let G=b.split(`
QuickAdd will now revert to backup.`),b.settings=l}}b.saveSettings()}var bE=qr;var Ym=require("obsidian");async function Pr(b,I,G){let l=await fetch(`https://api.github.com/repos/${b}/${I}/releases`),Z=await l.json();if(!l.ok&&"message"in Z||!Array.isArray(Z))throw new Error(`Failed to fetch releases: ${Z.message??"Unknown error"}`);let c=Z.findIndex(W=>W.tag_name===G);if(c===-1)throw new Error(`Could not find release with tag ${G}`);return Z.slice(0,c).filter(W=>!W.draft&&!W.prerelease)}function _r(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 V2=class extends zd.Modal{constructor(I,G){super(I),this.previousVersion=G,this.releaseNotesPromise=BA("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}
`)}var bR=class extends Ym.Modal{constructor(I,G){super(I),this.previousVersion=G,this.releaseNotesPromise=Pr("chhoumann","quickadd",G),this.releaseNotesPromise.then(l=>{if(this.releases=l,this.releases.length===0){this.close();return}this.display()}).catch(l=>{K.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.",Z='<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>',c=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}
@@ -94,6 +102,6 @@ ${d}
---
${OA(W)}`;zd.MarkdownRenderer.renderMarkdown(N,c,this.app.vault.getRoot().path,new zd.Component)}};var vG=require("obsidian");var a2=class extends vG.Modal{constructor(G,l){super(G);this.showAdvancedSettings=!1;this.settings=l,this.waitForClose=new Promise((Z,c)=>{this.rejectPromise=c,this.resolvePromise=Z}),this.open(),this.display()}get systemPromptTokenLength(){let G=Yb(this.settings.model);return G?Jl(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 IG.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 vG.Setting(G).setName("Model").setDesc("The model the AI Assistant will use").addDropdown(l=>{let Z=gb();for(let c of Z)l.addOption(c,c);l.addOption("Ask me","Ask me"),l.setValue(this.settings.model),l.onChange(c=>{this.settings.model=c,this.reload()})})}addOutputVariableNameSetting(G){new vG.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(Z=>{this.settings.outputVariableName=Z})})}addSystemPromptSetting(G){new vG.Setting(G).setName("System Prompt").setDesc("The system prompt for the AI Assistant");let l=this.contentEl.createEl("div"),Z=l.createEl("span");Z.style.color="var(--text-muted-color)",l.appendChild(Z);let c=new vG.TextAreaComponent(G);c.setValue(this.settings.systemPrompt).onChange(async N=>{this.settings.systemPrompt=N,d.innerText=await W.format(N),m()}),new rG(this.app,c.inputEl,UI.instance);let W=new ml(this.app,UI.instance);c.inputEl.style.width="100%",c.inputEl.style.height="100px",c.inputEl.style.minHeight="100px",c.inputEl.style.marginBottom="1em";let d=this.contentEl.createEl("span"),m=(0,vG.debounce)(()=>{Z.innerText=`Token count: ${this.systemPromptTokenLength}`},50);m(),(async()=>d.innerText=await W.format(this.settings.systemPrompt??""))()}addShowAdvancedSettingsToggle(G){new vG.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(Z=>{this.showAdvancedSettings=Z,this.reload()})})}addTemperatureSetting(G){new vG.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(Z=>{this.settings.modelParameters.temperature=Z})})}addTopPSetting(G){new vG.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(Z=>{this.settings.modelParameters.top_p=Z})})}addFrequencyPenaltySetting(G){new vG.Setting(G).setName("Frequency Penalty").setDesc("Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. The default is 0.").addSlider(l=>{l.setLimits(0,2,.1),l.setDynamicTooltip(),l.setValue(this.settings.modelParameters.frequency_penalty??0),l.onChange(Z=>{this.settings.modelParameters.frequency_penalty=Z})})}addPresencePenaltySetting(G){new vG.Setting(G).setName("Presence Penalty").setDesc("Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. The default is 0.").addSlider(l=>{l.setLimits(0,2,.1),l.setDynamicTooltip(),l.setValue(this.settings.modelParameters.presence_penalty??0),l.onChange(Z=>{this.settings.modelParameters.presence_penalty=Z})})}addResultJoinerSetting(G){new vG.Setting(G).setName("Result Jo Line truncated
${_r(W)}`;Ym.MarkdownRenderer.renderMarkdown(N,c,this.app.vault.getRoot().path,new Ym.Component)}};var xG=require("obsidian");var ZR=class extends xG.Modal{constructor(G,l){super(G);this.showAdvancedSettings=!1;this.settings=l,this.waitForClose=new Promise((Z,c)=>{this.rejectPromise=c,this.resolvePromise=Z}),this.open(),this.display()}get systemPromptTokenLength(){let G=yb(this.settings.model);return G?Dl(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 aG.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 xG.Setting(G).setName("Model").setDesc("The model the AI Assistant will use").addDropdown(l=>{let Z=_b();for(let c of Z)l.addOption(c,c);l.addOption("Ask me","Ask me"),l.setValue(this.settings.model),l.onChange(c=>{this.settings.model=c,this.reload()})})}addOutputVariableNameSetting(G){new xG.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(Z=>{this.settings.outputVariableName=Z})})}addSystemPromptSetting(G){new xG.Setting(G).setName("System Prompt").setDesc("The system prompt for the AI Assistant");let l=this.contentEl.createEl("div"),Z=l.createEl("span");Z.style.color="var(--text-muted-color)",l.appendChild(Z);let c=new xG.TextAreaComponent(G);c.setValue(this.settings.systemPrompt).onChange(async N=>{this.settings.systemPrompt=N,d.innerText=await W.format(N),m()}),new Il(this.app,c.inputEl,fI.instance);let W=new vl(this.app,fI.instance);c.inputEl.style.width="100%",c.inputEl.style.height="100px",c.inputEl.style.minHeight="100px",c.inputEl.style.marginBottom="1em";let d=this.contentEl.createEl("span"),m=(0,xG.debounce)(()=>{Z.innerText=`Token count: ${this.systemPromptTokenLength}`},50);m(),(async()=>d.innerText=await W.format(this.settings.systemPrompt??""))()}addShowAdvancedSettingsToggle(G){new xG.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(Z=>{this.showAdvancedSettings=Z,this.reload()})})}addTemperatureSetting(G){new xG.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(Z=>{this.settings.modelParameters.temperature=Z})})}addTopPSetting(G){new xG.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(Z=>{this.settings.modelParameters.top_p=Z})})}addFrequencyPenaltySetting(G){new xG.Setting(G).setName("Frequency Penalty").setDesc("Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. The default is 0.").addSlider(l=>{l.setLimits(0,2,.1),l.setDynamicTooltip(),l.setValue(this.settings.modelParameters.frequency_penalty??0),l.onChange(Z=>{this.settings.modelParameters.frequency_penalty=Z})})}addPresencePenaltySetting(G){new xG.Setting(G).setName("Presence Penalty").setDesc("Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. The default is 0.").addSlider(l=>{l.setLimits(0,2,.1),l.setDynamicTooltip(),l.setValue(this.settings.modelParameters.presence_penalty??0),l.onChange(Z=>{this.settings.modelParameters.presence_penalty=Z})})}addResultJoinerSetting(G){new xG.Setting(G).setName("Result Jo Line truncated
/* nosourcemap */
+1 -1
View File
@@ -1,7 +1,7 @@
{
"id": "quickadd",
"name": "QuickAdd",
"version": "2.4.0",
"version": "2.6.0",
"minAppVersion": "1.6.0",
"description": "Quickly add new pages or content to your vault.",
"author": "Christian B. B. Houmann",
+1 -1
View File
@@ -1 +1 @@
@media screen and (max-width: 540px){.qaWideInputPrompt .modal{bottom:10vh}.wideInputPromptInputEl{width:100%;min-width:100%;max-width:100%;height:6rem;direction:inherit;text-align:inherit}}@media screen and (min-width: 541px){.wideInputPromptInputEl{width:40rem;max-width:100%;height:20rem;direction:inherit;text-align:inherit}}.captureToActiveFileContainer{display:flex;align-content:center;justify-content:space-between;margin-bottom:10px}.choiceNameHeader{text-align:center}.choiceNameHeader:hover{cursor:pointer}.folderInputContainer{display:flex;align-content:center;justify-content:space-between;margin-bottom:8px;gap:4px}.quickAddModal .modal{min-width:35%;overflow-y:auto;max-height:70%}.quickAddModal .qa-preview-row{margin:6px 0}.quickAddModal .qa-preview-label{font-weight:600}.checkboxRowContainer{margin:30px 0;display:grid;grid-template-rows:auto;align-content:center;gap:5px}.checkboxRow{display:flex;justify-content:space-between;align-content:center}.checkboxRow .checkbox-container{flex-shrink:0}.checkboxRow span{font-size:16px;word-break:break-all}.submitButtonContainer{display:flex;align-content:center;justify-content:center;gap:.5rem}.chooseFolderWhenCreatingNoteContainer{display:flex;align-content:center;justify-content:space-between;margin-bottom:10px}.chooseFolderFromSubfolderContainer{margin:20px 0 0}.clickable:hover{cursor:pointer}.quickAddCommandListItem{display:flex;flex:1 1 auto;align-items:center;justify-content:space-between}.quickCommandContainer{display:flex;justify-content:flex-end;align-content:center;margin-bottom:1em;gap:4px}.yesNoPromptButtonContainer{display:flex;align-items:center;justify-content:space-around;margin-top:2rem;gap:.5rem}.suggestion-container{background-color:var(--modal-background);z-index:100000;overflow-y:auto}.qaFileSuggestionItem{display:flex;align-items:center;justify-content:space-between;padding:6px 12px;margin:1px 0;cursor:pointer;border-radius:3px;transition:all .12s cubic-bezier(.25,.46,.45,.94);position:relative;min-height:32px;font-size:13px;line-height:1.3;width:100%}.qaFileSuggestionItem:hover{background-color:var(--background-modifier-hover);transform:translate(2px)}.qaFileSuggestionItem.is-selected{background-color:var(--interactive-accent);color:var(--text-on-accent);box-shadow:0 2px 8px #0000001a}.qaFileSuggestionItem.is-selected .suggestion-sub-text{color:var(--text-on-accent-inverted);opacity:.8}.qa-suggest-exact:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--interactive-accent);border-radius:0 1px 1px 0}.qa-suggest-alias:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--color-orange, #ff8c00);border-radius:0 1px 1px 0}.qa-suggest-fuzzy:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--text-faint);border-radius:0 1px 1px 0}.qa-suggest-unresolved:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--color-red, #e74c3c);border-radius:0 1px 1px 0}.qa-suggest-heading:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--color-blue, #3498db);border-radius:0 1px 1px 0}.qa-suggest-block:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--color-purple, #9b59b6);border-radius:0 1px 1px 0}.qa-suggestion-content{display:flex;align-items:center;gap:8px;flex:1;min-width:0}.qaFileSuggestionItem .suggestion-main-text{font-weight:500;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:200px}.qaFileSuggestionItem .suggestion-sub-text{font-size:11px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:150px;margin-left:auto;padding-left:8px;opacity:.7}.qa-suggestion-pill{display:inline-block;padding:1px 4px;border-radius:2px;font-size:9px;font-weight:600;text-transform:uppercase;letter-spacing:.3px;line-height:1;opacity:.8}.qa-alias-pill{background:var(--color-orange, #ff8c00);color:#fff}.qa-unresolved-pill{background:var(--color-red, #e74c3c);color:#fff}.qa-create-pill{background:var(--color-green, #27ae60);color:#fff}.qa-heading-pill{background:var(--color-blue, #3498db);color:#fff}.qa-block-pill{background:var(--color-purple, #9b59b6);color:#fff}.qa-file-tooltip{background:var(--background-primary);border:1px solid var(--background-modifier-border);border-radius:4px;padding:8px 10px;max-width:280px;box-shadow:0 4px 20px #0000001f;z-index:1000;pointer-events:none;font-size:12px}.qa-tooltip-header{font-weight:600;font-size:13px;margin-bottom:4px;color:var(--text-normal)}.qa-tooltip-content{color:var(--text-muted);line-height:1.3}.qa-tooltip-content div{margin-bottom:2px}.qaFileSuggestionItem{will-change:transform,background-color;backface-visibility:hidden}.qaFileSuggestionItem:focus-visible{outline:2px solid var(--interactive-accent);outline-offset:-2px}.theme-dark .qa-file-tooltip{box-shadow:0 4px 20px #0000004d;border-color:var(--background-modifier-border-hover)}.theme-dark .qaFileLine truncated
@media screen and (max-width: 540px){.qaWideInputPrompt .modal{bottom:10vh}.wideInputPromptInputEl{width:100%;min-width:100%;max-width:100%;height:6rem;font-size:16px;direction:inherit;text-align:inherit}}@media screen and (min-width: 541px){.wideInputPromptInputEl{width:40rem;max-width:100%;height:20rem;font-size:16px;direction:inherit;text-align:inherit}}.captureToActiveFileContainer{display:flex;align-content:center;justify-content:space-between;margin-bottom:10px}.choiceNameHeader{text-align:center}.choiceNameHeader:hover{cursor:pointer}.folderInputContainer{display:flex;align-content:center;justify-content:space-between;margin-bottom:8px;gap:4px}.quickAddModal .modal{min-width:35%;overflow-y:auto;max-height:70%}.quickAddModal .qa-preview-row{margin:6px 0}.quickAddModal .qa-preview-label{font-weight:600}.checkboxRowContainer{margin:30px 0;display:grid;grid-template-rows:auto;align-content:center;gap:5px}.checkboxRow{display:flex;justify-content:space-between;align-content:center}.checkboxRow .checkbox-container{flex-shrink:0}.checkboxRow span{font-size:16px;word-break:break-all}.submitButtonContainer{display:flex;align-content:center;justify-content:center;gap:.5rem}.chooseFolderWhenCreatingNoteContainer{display:flex;align-content:center;justify-content:space-between;margin-bottom:10px}.chooseFolderFromSubfolderContainer{margin:20px 0 0}.clickable:hover{cursor:pointer}.quickAddCommandListItem{display:flex;flex:1 1 auto;align-items:center;justify-content:space-between}.quickCommandContainer{display:flex;justify-content:flex-end;align-content:center;margin-bottom:1em;gap:4px}.yesNoPromptButtonContainer{display:flex;align-items:center;justify-content:space-around;margin-top:2rem;gap:.5rem}.suggestion-container{background-color:var(--modal-background);z-index:100000;overflow-y:auto}.qaFileSuggestionItem{display:flex;align-items:center;justify-content:space-between;padding:6px 12px;margin:1px 0;cursor:pointer;border-radius:3px;transition:all .12s cubic-bezier(.25,.46,.45,.94);position:relative;min-height:32px;font-size:13px;line-height:1.3;width:100%}.qaFileSuggestionItem:hover{background-color:var(--background-modifier-hover);transform:translate(2px)}.qaFileSuggestionItem.is-selected{background-color:var(--interactive-accent);color:var(--text-on-accent);box-shadow:0 2px 8px #0000001a}.qaFileSuggestionItem.is-selected .suggestion-sub-text{color:var(--text-on-accent-inverted);opacity:.8}.qa-suggest-exact:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--interactive-accent);border-radius:0 1px 1px 0}.qa-suggest-alias:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--color-orange, #ff8c00);border-radius:0 1px 1px 0}.qa-suggest-fuzzy:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--text-faint);border-radius:0 1px 1px 0}.qa-suggest-unresolved:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--color-red, #e74c3c);border-radius:0 1px 1px 0}.qa-suggest-heading:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--color-blue, #3498db);border-radius:0 1px 1px 0}.qa-suggest-block:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--color-purple, #9b59b6);border-radius:0 1px 1px 0}.qa-suggestion-content{display:flex;align-items:center;gap:8px;flex:1;min-width:0}.qaFileSuggestionItem .suggestion-main-text{font-weight:500;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:200px}.qaFileSuggestionItem .suggestion-sub-text{font-size:11px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:150px;margin-left:auto;padding-left:8px;opacity:.7}.qa-suggestion-pill{display:inline-block;padding:1px 4px;border-radius:2px;font-size:9px;font-weight:600;text-transform:uppercase;letter-spacing:.3px;line-height:1;opacity:.8}.qa-alias-pill{background:var(--color-orange, #ff8c00);color:#fff}.qa-unresolved-pill{background:var(--color-red, #e74c3c);color:#fff}.qa-create-pill{background:var(--color-green, #27ae60);color:#fff}.qa-heading-pill{background:var(--color-blue, #3498db);color:#fff}.qa-block-pill{background:var(--color-purple, #9b59b6);color:#fff}.qa-file-tooltip{background:var(--background-primary);border:1px solid var(--background-modifier-border);border-radius:4px;padding:8px 10px;max-width:280px;box-shadow:0 4px 20px #0000001f;z-index:1000;pointer-events:none;font-size:12px}.qa-tooltip-header{font-weight:600;font-size:13px;margin-bottom:4px;color:var(--text-normal)}.qa-tooltip-content{color:var(--text-muted);line-height:1.3}.qa-tooltip-content div{margin-bottom:2px}.qaFileSuggestionItem{will-change:transform,background-color;backface-visibility:hidden}.qaFileSuggestionItem:focus-visible{outline:2px solid var(--interactive-accent);outline-offset:-2px}.theme-dark .qa-file-tooltip{box-shadow:0 4px 20px #0000004d;border-color:var(--background-modifier-borLine truncated