/* THIS IS A GENERATED/BUNDLED FILE BY ESBUILD if you want to view the source, please visit the github repository of this plugin */ var _i=Object.create;var yt=Object.defineProperty;var Mi=Object.getOwnPropertyDescriptor;var vi=Object.getOwnPropertyNames;var Ni=Object.getPrototypeOf,Ui=Object.prototype.hasOwnProperty;var $t=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Hn=(e,t)=>{for(var n in t)yt(e,n,{get:t[n],enumerable:!0})},qn=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of vi(t))!Ui.call(e,i)&&i!==n&&yt(e,i,{get:()=>t[i],enumerable:!(r=Mi(t,i))||r.enumerable});return e};var Et=(e,t,n)=>(n=e!=null?_i(Ni(e)):{},qn(t||!e||!e.__esModule?yt(n,"default",{value:e,enumerable:!0}):n,e)),ji=e=>qn(yt({},"__esModule",{value:!0}),e);var Yn=$t((cs,Ht)=>{(function(){var e;typeof Ht!="undefined"?e=Ht.exports=r:e=function(){return this||(0,eval)("this")}(),e.format=r,e.vsprintf=n,typeof console!="undefined"&&typeof console.log=="function"&&(e.printf=t);function t(){console.log(r.apply(null,arguments))}function n(i,u){return r.apply(null,[i].concat(u))}function r(i){for(var u=1,o=[].slice.call(arguments),s=0,c=i.length,a="",l,h=!1,f,p,F=!1,E,C=function(){return o[u++]},x=function(){for(var b="";/\d/.test(i[s]);)b+=i[s++],l=i[s];return b.length>0?parseInt(b):null};s{Hr.exports=function(t){return t!=null&&t.constructor!=null&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}});var Jr=$t((ah,Gr)=>{"use strict";var It=Object.prototype.hasOwnProperty,Xr=Object.prototype.toString,qr=Object.defineProperty,Wr=Object.getOwnPropertyDescriptor,Yr=function(t){return typeof Array.isArray=="function"?Array.isArray(t):Xr.call(t)==="[object Array]"},Qr=function(t){if(!t||Xr.call(t)!=="[object Object]")return!1;var n=It.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&It.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var i;for(i in t);return typeof i=="undefined"||It.call(t,i)},Kr=function(t,n){qr&&n.name==="__proto__"?qr(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},Zr=function(t,n){if(n==="__proto__")if(It.call(t,n)){if(Wr)return Wr(t,n).value}else return;return t[n]};Gr.exports=function e(){var t,n,r,i,u,o,s=arguments[0],c=1,a=arguments.length,l=!1;for(typeof s=="boolean"&&(l=s,s=arguments[1]||{},c=2),(s==null||typeof s!="object"&&typeof s!="function")&&(s={});cvt,default:()=>Nt,getElectronWindow:()=>Xo});module.exports=ji(Jo);var oe=require("obsidian");var N=require("obsidian");var je={children(e){return e.children},annotatetextnode(e,t){return e.type==="text"?{offset:{end:e.position.end.offset,start:e.position.start.offset},text:t.substring(e.position.start.offset,e.position.end.offset)}:null},interpretmarkup(e=""){return e}};function Vi(e,t,n=je){let r=[];function i(u){let o=n.annotatetextnode(u,t);o!==null&&r.push(o);let s=n.children(u);s!==null&&Array.isArray(s)&&s.forEach(i)}return i(e),r}function $i(e,t,n=je){let r=[],i={offset:{end:0,start:0}};for(let o of t){let s=e.substring(i.offset.end,o.offset.start);r.push({interpretAs:n.interpretmarkup(s),markup:s,offset:{end:o.offset.start,start:i.offset.end}}),r.push(o),i=o}let u=e.substring(i.offset.end,e.length);return r.push({interpretAs:n.interpretmarkup(u),markup:u,offset:{end:e.length,start:i.offset.end}}),{annotation:r}}function Wn(e,t,n=je){let r=Vi(t,e,n);return $i(e,r,n)}var ts=ye(/[A-Za-z]/),ns=ye(/[\dA-Za-z]/),rs=ye(/[#-'*+\--9=?A-Z^-~]/);var is=ye(/\d/),us=ye(/[\dA-Fa-f]/),os=ye(/[!-/:-@[-`{-~]/);function it(e){return e!==null&&e<-2}function ut(e){return e===-2||e===-1||e===32}var ss=ye(/\p{P}|\p{S}/u),as=ye(/\s/);function ye(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}var Qn=Et(Yn(),1),ot=Object.assign(Ie(Error),{eval:Ie(EvalError),range:Ie(RangeError),reference:Ie(ReferenceError),syntax:Ie(SyntaxError),type:Ie(TypeError),uri:Ie(URIError)});function Ie(e){return t.displayName=e.displayName||e.name,t;function t(n,...r){let i=n&&(0,Qn.default)(n,...r);return new e(i)}}var Ft={}.hasOwnProperty,Kn={yaml:"-",toml:"+"};function Ve(e){let t=[],n=-1,r=Array.isArray(e)?e:e?[e]:["yaml"];for(;++ni?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);u0?(Z(e,e.length,0,t),e):t}var er={}.hasOwnProperty;function tr(e){let t={},n=-1;for(;++no))return;let w=t.events.length,S=w,I,H;for(;S--;)if(t.events[S][0]==="exit"&&t.events[S][1].type==="chunkFlow"){if(I){H=t.events[S][1].end;break}I=!0}for(x(r),g=w;gA;){let L=n[O];t.containerState=L[1],L[0].exit.call(t,e)}n.length=A}function b(){i.write([null]),u=void 0,i=void 0,t.containerState._closeFlow=void 0}}function iu(e,t,n){return P(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}var sr=/[!-\/:-@\[-`\{-~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/;var re=Ae(/[A-Za-z]/),ee=Ae(/[\dA-Za-z]/),ar=Ae(/[#-'*+\--9=?A-Z^-~]/);function lr(e){return e!==null&&(e<32||e===127)}var st=Ae(/\d/),cr=Ae(/[\dA-Fa-f]/),pr=Ae(/[!-/:-@[-`{-~]/);function T(e){return e!==null&&e<-2}function Q(e){return e!==null&&(e<0||e===32)}function _(e){return e===-2||e===-1||e===32}var hr=Ae(sr),fr=Ae(/\s/);function Ae(e){return t;function t(n){return n!==null&&e.test(String.fromCharCode(n))}}function Jt(e){if(e===null||Q(e)||fr(e))return 1;if(hr(e))return 2}function He(e,t,n){let r=[],i=-1;for(;++i1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let h=Object.assign({},e[r][1].end),f=Object.assign({},e[n][1].start);mr(h,-c),mr(f,c),o={type:c>1?"strongSequence":"emphasisSequence",start:h,end:Object.assign({},e[r][1].end)},s={type:c>1?"strongSequence":"emphasisSequence",start:Object.assign({},e[n][1].start),end:f},u={type:c>1?"strongText":"emphasisText",start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},i={type:c>1?"strong":"emphasis",start:Object.assign({},o.start),end:Object.assign({},s.end)},e[r][1].end=Object.assign({},o.start),e[n][1].start=Object.assign({},s.end),a=[],e[r][1].end.offset-e[r][1].start.offset&&(a=J(a,[["enter",e[r][1],t],["exit",e[r][1],t]])),a=J(a,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",u,t]]),a=J(a,He(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),a=J(a,[["exit",u,t],["enter",s,t],["exit",s,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(l=2,a=J(a,[["enter",e[n][1],t],["exit",e[n][1],t]])):l=0,Z(e,r-1,n-r+3,a),n=r+a.length-l-2;break}}for(n=-1;++n0&&_(g)?P(e,b,"linePrefix",u+1)(g):b(g)}function b(g){return g===null||T(g)?e.check(gr,E,O)(g):(e.enter("codeFlowValue"),A(g))}function A(g){return g===null||T(g)?(e.exit("codeFlowValue"),b(g)):(e.consume(g),A)}function O(g){return e.exit("codeFenced"),t(g)}function L(g,w,S){let I=0;return H;function H(R){return g.enter("lineEnding"),g.consume(R),g.exit("lineEnding"),$}function $(R){return g.enter("codeFencedFence"),_(R)?P(g,M,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):M(R)}function M(R){return R===s?(g.enter("codeFencedFenceSequence"),D(R)):S(R)}function D(R){return R===s?(I++,g.consume(R),D):I>=o?(g.exit("codeFencedFenceSequence"),_(R)?P(g,z,"whitespace")(R):z(R)):S(R)}function z(R){return R===null||T(R)?(g.exit("codeFencedFence"),w(R)):S(R)}}}function du(e,t,n){let r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),u)}function u(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}var lt={name:"codeIndented",tokenize:xu},gu={tokenize:yu,partial:!0};function xu(e,t,n){let r=this;return i;function i(a){return e.enter("codeIndented"),P(e,u,"linePrefix",5)(a)}function u(a){let l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?o(a):n(a)}function o(a){return a===null?c(a):T(a)?e.attempt(gu,o,c)(a):(e.enter("codeFlowValue"),s(a))}function s(a){return a===null||T(a)?(e.exit("codeFlowValue"),o(a)):(e.consume(a),s)}function c(a){return e.exit("codeIndented"),t(a)}}function yu(e,t,n){let r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):T(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):P(e,u,"linePrefix",5)(o)}function u(o){let s=r.events[r.events.length-1];return s&&s[1].type==="linePrefix"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):T(o)?i(o):n(o)}}var tn={name:"codeText",tokenize:Au,resolve:Eu,previous:Fu};function Eu(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}var xr=/[!-\/:-@\[-`\{-~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/;var tl=we(/[A-Za-z]/),nl=we(/[\dA-Za-z]/),rl=we(/[#-'*+\--9=?A-Z^-~]/);function rn(e){return e!==null&&(e<32||e===127)}var il=we(/\d/),ul=we(/[\dA-Fa-f]/),ol=we(/[!-/:-@[-`{-~]/);function yr(e){return e!==null&&e<-2}function Er(e){return e!==null&&(e<0||e===32)}var sl=we(xr),al=we(/\s/);function we(e){return t;function t(n){return n!==null&&e.test(String.fromCharCode(n))}}function Dt(e,t,n,r,i,u,o,s,c){let a=c||Number.POSITIVE_INFINITY,l=0;return h;function h(x){return x===60?(e.enter(r),e.enter(i),e.enter(u),e.consume(x),e.exit(u),f):x===null||x===32||x===41||rn(x)?n(x):(e.enter(r),e.enter(o),e.enter(s),e.enter("chunkString",{contentType:"string"}),E(x))}function f(x){return x===62?(e.enter(u),e.consume(x),e.exit(u),e.exit(i),e.exit(r),t):(e.enter(s),e.enter("chunkString",{contentType:"string"}),p(x))}function p(x){return x===62?(e.exit("chunkString"),e.exit(s),f(x)):x===null||x===60||yr(x)?n(x):(e.consume(x),x===92?F:p)}function F(x){return x===60||x===62||x===92?(e.consume(x),p):p(x)}function E(x){return!l&&(x===null||x===41||Er(x))?(e.exit("chunkString"),e.exit(s),e.exit(o),e.exit(r),t(x)):l999||p===null||p===91||p===93&&!c||p===94&&!s&&"_hiddenFootnoteSupport"in o.parser.constructs?n(p):p===93?(e.exit(u),e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):un(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),l):(e.enter("chunkString",{contentType:"string"}),h(p))}function h(p){return p===null||p===91||p===93||un(p)||s++>999?(e.exit("chunkString"),l(p)):(e.consume(p),c||(c=!Ar(p)),p===92?f:h)}function f(p){return p===91||p===92||p===93?(e.consume(p),s++,h):h(p)}}var Cr=/[!-\/:-@\[-`\{-~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/;var Dl=be(/[A-Za-z]/),Tl=be(/[\dA-Za-z]/),Ol=be(/[#-'*+\--9=?A-Z^-~]/);var Bl=be(/\d/),Pl=be(/[\dA-Fa-f]/),Ll=be(/[!-/:-@[-`{-~]/);function on(e){return e!==null&&e<-2}var Il=be(Cr),Rl=be(/\s/);function be(e){return t;function t(n){return n!==null&&e.test(String.fromCharCode(n))}}function Ot(e,t,n,r,i,u){let o;return s;function s(f){return f===34||f===39||f===40?(e.enter(r),e.enter(i),e.consume(f),e.exit(i),o=f===40?41:f,c):n(f)}function c(f){return f===o?(e.enter(i),e.consume(f),e.exit(i),e.exit(r),t):(e.enter(u),a(f))}function a(f){return f===o?(e.exit(u),c(o)):f===null?n(f):on(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),P(e,a,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),l(f))}function l(f){return f===o||f===null||on(f)?(e.exit("chunkString"),a(f)):(e.consume(f),f===92?h:l)}function h(f){return f===o||f===92?(e.consume(f),l):l(f)}}var wr=/[!-\/:-@\[-`\{-~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/;var jl=Se(/[A-Za-z]/),Vl=Se(/[\dA-Za-z]/),$l=Se(/[#-'*+\--9=?A-Z^-~]/);var Hl=Se(/\d/),ql=Se(/[\dA-Fa-f]/),Wl=Se(/[!-/:-@[-`{-~]/);function kr(e){return e!==null&&e<-2}function br(e){return e===-2||e===-1||e===32}var Yl=Se(wr),Ql=Se(/\s/);function Se(e){return t;function t(n){return n!==null&&e.test(String.fromCharCode(n))}}function Re(e,t){let n;return r;function r(i){return kr(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):br(i)?P(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}function de(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}var sn={name:"definition",tokenize:Tu},Du={tokenize:Ou,partial:!0};function Tu(e,t,n){let r=this,i;return u;function u(p){return e.enter("definition"),o(p)}function o(p){return Tt.call(r,e,s,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function s(p){return i=de(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),c):n(p)}function c(p){return Q(p)?Re(e,a)(p):a(p)}function a(p){return Dt(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function l(p){return e.attempt(Du,h,h)(p)}function h(p){return _(p)?P(e,f,"whitespace")(p):f(p)}function f(p){return p===null||T(p)?(e.exit("definition"),r.parser.defined.push(i),t(p)):n(p)}}function Ou(e,t,n){return r;function r(s){return Q(s)?Re(e,i)(s):n(s)}function i(s){return Ot(e,u,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(s)}function u(s){return _(s)?P(e,o,"whitespace")(s):o(s)}function o(s){return s===null||T(s)?t(s):n(s)}}var an={name:"hardBreakEscape",tokenize:Bu};function Bu(e,t,n){return r;function r(u){return e.enter("hardBreakEscape"),e.consume(u),i}function i(u){return T(u)?(e.exit("hardBreakEscape"),t(u)):n(u)}}var ln={name:"headingAtx",tokenize:Lu,resolve:Pu};function Pu(e,t){let n=e.length-2,r=3,i,u;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},u={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},Z(e,r,n-r+1,[["enter",i,t],["enter",u,t],["exit",u,t],["exit",i,t]])),e}function Lu(e,t,n){let r=0;return i;function i(l){return e.enter("atxHeading"),u(l)}function u(l){return e.enter("atxHeadingSequence"),o(l)}function o(l){return l===35&&r++<6?(e.consume(l),o):l===null||Q(l)?(e.exit("atxHeadingSequence"),s(l)):n(l)}function s(l){return l===35?(e.enter("atxHeadingSequence"),c(l)):l===null||T(l)?(e.exit("atxHeading"),t(l)):_(l)?P(e,s,"whitespace")(l):(e.enter("atxHeadingText"),a(l))}function c(l){return l===35?(e.consume(l),c):(e.exit("atxHeadingSequence"),s(l))}function a(l){return l===null||l===35||Q(l)?(e.exit("atxHeadingText"),s(l)):(e.consume(l),a)}}var Sr=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],cn=["pre","script","style","textarea"];var pn={name:"htmlFlow",tokenize:_u,resolveTo:zu,concrete:!0},Iu={tokenize:vu,partial:!0},Ru={tokenize:Mu,partial:!0};function zu(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function _u(e,t,n){let r=this,i,u,o,s,c;return a;function a(d){return l(d)}function l(d){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(d),h}function h(d){return d===33?(e.consume(d),f):d===47?(e.consume(d),u=!0,E):d===63?(e.consume(d),i=3,r.interrupt?t:m):re(d)?(e.consume(d),o=String.fromCharCode(d),C):n(d)}function f(d){return d===45?(e.consume(d),i=2,p):d===91?(e.consume(d),i=5,s=0,F):re(d)?(e.consume(d),i=4,r.interrupt?t:m):n(d)}function p(d){return d===45?(e.consume(d),r.interrupt?t:m):n(d)}function F(d){let ne="CDATA[";return d===ne.charCodeAt(s++)?(e.consume(d),s===ne.length?r.interrupt?t:M:F):n(d)}function E(d){return re(d)?(e.consume(d),o=String.fromCharCode(d),C):n(d)}function C(d){if(d===null||d===47||d===62||Q(d)){let ne=d===47,Ne=o.toLowerCase();return!ne&&!u&&cn.includes(Ne)?(i=1,r.interrupt?t(d):M(d)):Sr.includes(o.toLowerCase())?(i=6,ne?(e.consume(d),x):r.interrupt?t(d):M(d)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(d):u?b(d):A(d))}return d===45||ee(d)?(e.consume(d),o+=String.fromCharCode(d),C):n(d)}function x(d){return d===62?(e.consume(d),r.interrupt?t:M):n(d)}function b(d){return _(d)?(e.consume(d),b):H(d)}function A(d){return d===47?(e.consume(d),H):d===58||d===95||re(d)?(e.consume(d),O):_(d)?(e.consume(d),A):H(d)}function O(d){return d===45||d===46||d===58||d===95||ee(d)?(e.consume(d),O):L(d)}function L(d){return d===61?(e.consume(d),g):_(d)?(e.consume(d),L):A(d)}function g(d){return d===null||d===60||d===61||d===62||d===96?n(d):d===34||d===39?(e.consume(d),c=d,w):_(d)?(e.consume(d),g):S(d)}function w(d){return d===c?(e.consume(d),c=null,I):d===null||T(d)?n(d):(e.consume(d),w)}function S(d){return d===null||d===34||d===39||d===47||d===60||d===61||d===62||d===96||Q(d)?L(d):(e.consume(d),S)}function I(d){return d===47||d===62||_(d)?A(d):n(d)}function H(d){return d===62?(e.consume(d),$):n(d)}function $(d){return d===null||T(d)?M(d):_(d)?(e.consume(d),$):n(d)}function M(d){return d===45&&i===2?(e.consume(d),q):d===60&&i===1?(e.consume(d),Y):d===62&&i===4?(e.consume(d),ue):d===63&&i===3?(e.consume(d),m):d===93&&i===5?(e.consume(d),ce):T(d)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(Iu,pe,D)(d)):d===null||T(d)?(e.exit("htmlFlowData"),D(d)):(e.consume(d),M)}function D(d){return e.check(Ru,z,pe)(d)}function z(d){return e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),R}function R(d){return d===null||T(d)?D(d):(e.enter("htmlFlowData"),M(d))}function q(d){return d===45?(e.consume(d),m):M(d)}function Y(d){return d===47?(e.consume(d),o="",se):M(d)}function se(d){if(d===62){let ne=o.toLowerCase();return cn.includes(ne)?(e.consume(d),ue):M(d)}return re(d)&&o.length<8?(e.consume(d),o+=String.fromCharCode(d),se):M(d)}function ce(d){return d===93?(e.consume(d),m):M(d)}function m(d){return d===62?(e.consume(d),ue):d===45&&i===2?(e.consume(d),m):M(d)}function ue(d){return d===null||T(d)?(e.exit("htmlFlowData"),pe(d)):(e.consume(d),ue)}function pe(d){return e.exit("htmlFlow"),t(d)}}function Mu(e,t,n){let r=this;return i;function i(o){return T(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),u):n(o)}function u(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function vu(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Ce,t,n)}}var hn={name:"htmlText",tokenize:Nu};function Nu(e,t,n){let r=this,i,u,o;return s;function s(m){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(m),c}function c(m){return m===33?(e.consume(m),a):m===47?(e.consume(m),L):m===63?(e.consume(m),A):re(m)?(e.consume(m),S):n(m)}function a(m){return m===45?(e.consume(m),l):m===91?(e.consume(m),u=0,F):re(m)?(e.consume(m),b):n(m)}function l(m){return m===45?(e.consume(m),p):n(m)}function h(m){return m===null?n(m):m===45?(e.consume(m),f):T(m)?(o=h,Y(m)):(e.consume(m),h)}function f(m){return m===45?(e.consume(m),p):h(m)}function p(m){return m===62?q(m):m===45?f(m):h(m)}function F(m){let ue="CDATA[";return m===ue.charCodeAt(u++)?(e.consume(m),u===ue.length?E:F):n(m)}function E(m){return m===null?n(m):m===93?(e.consume(m),C):T(m)?(o=E,Y(m)):(e.consume(m),E)}function C(m){return m===93?(e.consume(m),x):E(m)}function x(m){return m===62?q(m):m===93?(e.consume(m),x):E(m)}function b(m){return m===null||m===62?q(m):T(m)?(o=b,Y(m)):(e.consume(m),b)}function A(m){return m===null?n(m):m===63?(e.consume(m),O):T(m)?(o=A,Y(m)):(e.consume(m),A)}function O(m){return m===62?q(m):A(m)}function L(m){return re(m)?(e.consume(m),g):n(m)}function g(m){return m===45||ee(m)?(e.consume(m),g):w(m)}function w(m){return T(m)?(o=w,Y(m)):_(m)?(e.consume(m),w):q(m)}function S(m){return m===45||ee(m)?(e.consume(m),S):m===47||m===62||Q(m)?I(m):n(m)}function I(m){return m===47?(e.consume(m),q):m===58||m===95||re(m)?(e.consume(m),H):T(m)?(o=I,Y(m)):_(m)?(e.consume(m),I):q(m)}function H(m){return m===45||m===46||m===58||m===95||ee(m)?(e.consume(m),H):$(m)}function $(m){return m===61?(e.consume(m),M):T(m)?(o=$,Y(m)):_(m)?(e.consume(m),$):I(m)}function M(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(e.consume(m),i=m,D):T(m)?(o=M,Y(m)):_(m)?(e.consume(m),M):(e.consume(m),z)}function D(m){return m===i?(e.consume(m),i=void 0,R):m===null?n(m):T(m)?(o=D,Y(m)):(e.consume(m),D)}function z(m){return m===null||m===34||m===39||m===60||m===61||m===96?n(m):m===47||m===62||Q(m)?I(m):(e.consume(m),z)}function R(m){return m===47||m===62||Q(m)?I(m):n(m)}function q(m){return m===62?(e.consume(m),e.exit("htmlTextData"),e.exit("htmlText"),t):n(m)}function Y(m){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),se}function se(m){return _(m)?P(e,ce,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(m):ce(m)}function ce(m){return e.enter("htmlTextData"),o(m)}}var ze={name:"labelEnd",tokenize:qu,resolveTo:Hu,resolveAll:$u},Uu={tokenize:Wu},ju={tokenize:Yu},Vu={tokenize:Qu};function $u(e){let t=-1;for(;++t=3&&(a===null||T(a))?(e.exit("thematicBreak"),t(a)):n(a)}function c(a){return a===i?(e.consume(a),r++,c):(e.exit("thematicBreakSequence"),_(a)?P(e,s,"whitespace")(a):s(a))}}var X={name:"list",tokenize:to,continuation:{tokenize:no},exit:io},Ju={tokenize:uo,partial:!0},eo={tokenize:ro,partial:!0};function to(e,t,n){let r=this,i=r.events[r.events.length-1],u=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(p){let F=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(F==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:st(p)){if(r.containerState.type||(r.containerState.type=F,e.enter(F,{_container:!0})),F==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(_e,n,a)(p):a(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(p)}return n(p)}function c(p){return st(p)&&++o<10?(e.consume(p),c):(!r.interrupt||o<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),a(p)):n(p)}function a(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(Ce,r.interrupt?n:l,e.attempt(Ju,f,h))}function l(p){return r.containerState.initialBlankLine=!0,u++,f(p)}function h(p){return _(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),f):n(p)}function f(p){return r.containerState.size=u+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function no(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Ce,i,u);function i(s){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,P(e,t,"listItemIndent",r.containerState.size+1)(s)}function u(s){return r.containerState.furtherBlankLines||!_(s)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(s)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(eo,t,o)(s))}function o(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,P(e,e.attempt(X,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s)}}function ro(e,t,n){let r=this;return P(e,i,"listItemIndent",r.containerState.size+1);function i(u){let o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(u):n(u)}}function io(e){e.exit(this.containerState.type)}function uo(e,t,n){let r=this;return P(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(u){let o=r.events[r.events.length-1];return!_(u)&&o&&o[1].type==="listItemPrefixWhitespace"?t(u):n(u)}}var Bt={name:"setextUnderline",tokenize:so,resolveTo:oo};function oo(e,t){let n=e.length,r,i,u;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!u&&e[n][1].type==="definition"&&(u=n);let o={type:"setextHeading",start:Object.assign({},e[i][1].start),end:Object.assign({},e[e.length-1][1].end)};return e[i][1].type="setextHeadingText",u?(e.splice(i,0,["enter",o,t]),e.splice(u+1,0,["exit",e[r][1],t]),e[r][1].end=Object.assign({},e[u][1].end)):e[r][1]=o,e.push(["exit",o,t]),e}function so(e,t,n){let r=this,i;return u;function u(a){let l=r.events.length,h;for(;l--;)if(r.events[l][1].type!=="lineEnding"&&r.events[l][1].type!=="linePrefix"&&r.events[l][1].type!=="content"){h=r.events[l][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||h)?(e.enter("setextHeadingLine"),i=a,o(a)):n(a)}function o(a){return e.enter("setextHeadingLineSequence"),s(a)}function s(a){return a===i?(e.consume(a),s):(e.exit("setextHeadingLineSequence"),_(a)?P(e,c,"lineSuffix")(a):c(a))}function c(a){return a===null||T(a)?(e.exit("setextHeadingLine"),t(a)):n(a)}}var Dr={tokenize:ao};function ao(e){let t=this,n=e.attempt(Ce,r,e.attempt(this.parser.constructs.flowInitial,i,P(e,e.attempt(this.parser.constructs.flow,i,e.attempt(nn,i)),"linePrefix")));return n;function r(u){if(u===null){e.consume(u);return}return e.enter("lineEndingBlank"),e.consume(u),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(u){if(u===null){e.consume(u);return}return e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),t.currentConstruct=void 0,n}}var Tr={resolveAll:Lr()},Or=Pr("string"),Br=Pr("text");function Pr(e){return{tokenize:t,resolveAll:Lr(e==="text"?lo:void 0)};function t(n){let r=this,i=this.parser.constructs[e],u=n.attempt(i,o,s);return o;function o(l){return a(l)?u(l):s(l)}function s(l){if(l===null){n.consume(l);return}return n.enter("data"),n.consume(l),c}function c(l){return a(l)?(n.exit("data"),u(l)):(n.consume(l),c)}function a(l){if(l===null)return!0;let h=i[l],f=-1;if(h)for(;++f-1){let s=o[0];typeof s=="string"?o[0]=s.slice(r):o.shift()}u>0&&o.push(e[i].slice(0,u))}return o}function po(e,t){let n=-1,r=[],i;for(;++nFo,contentInitial:()=>fo,disable:()=>Ao,document:()=>ho,flow:()=>go,flowInitial:()=>mo,insideSpan:()=>Eo,string:()=>xo,text:()=>yo});var ho={42:X,43:X,45:X,48:X,49:X,50:X,51:X,52:X,53:X,54:X,55:X,56:X,57:X,62:Ct},fo={91:sn},mo={[-2]:lt,[-1]:lt,32:lt},go={35:ln,42:_e,45:[Bt,_e],60:pn,61:Bt,95:_e,96:bt,126:bt},xo={38:kt,92:wt},yo={[-5]:ct,[-4]:ct,[-3]:ct,33:fn,38:kt,42:at,60:[en,hn],91:mn,92:[an,wt],93:ze,95:at,96:tn},Eo={null:[at,Tr]},Fo={null:[42,95]},Ao={null:[]};function Rr(e){let n=tr([dn,...(e||{}).extensions||[]]),r={defined:[],lazy:{},constructs:n,content:i(ir),document:i(or),flow:i(Dr),string:i(Or),text:i(Br)};return r;function i(u){return o;function o(s){return Ir(r,u,s)}}}var zr=/[\0\t\n\r]/g;function _r(){let e=1,t="",n=!0,r;return i;function i(u,o,s){let c=[],a,l,h,f,p;for(u=t+u.toString(o),h=0,t="",n&&(u.charCodeAt(0)===65279&&h++,n=void 0);h13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"\uFFFD":String.fromCharCode(n)}var Co=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function vr(e){return e.replace(Co,wo)}function wo(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let i=n.charCodeAt(1),u=i===120||i===88;return Pt(n.slice(u?2:1),u?16:10)}return qe(n)||e}function De(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Nr(e.position):"start"in e||"end"in e?Nr(e):"line"in e||"column"in e?gn(e):""}function gn(e){return Ur(e&&e.line)+":"+Ur(e&&e.column)}function Nr(e){return gn(e&&e.start)+"-"+gn(e&&e.end)}function Ur(e){return e&&typeof e=="number"?e:1}var Vr={}.hasOwnProperty,xn=function(e,t,n){return typeof t!="string"&&(n=t,t=void 0),ko(n)(Mr(Rr(n).document().write(_r()(e,t,!0))))};function ko(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(Vn),autolinkProtocol:$,autolinkEmail:$,atxHeading:s(Nn),blockQuote:s(Ue),characterEscape:$,characterReference:$,codeFenced:s(Le),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:s(Le,c),codeText:s(jt,c),codeTextData:$,data:$,codeFlowValue:$,definition:s(Ti),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:s(Oi),hardBreakEscape:s(Un),hardBreakTrailing:s(Un),htmlFlow:s(jn,c),htmlFlowData:$,htmlText:s(jn,c),htmlTextData:$,image:s(Bi),label:c,link:s(Vn),listItem:s(Pi),listItemValue:F,listOrdered:s($n,p),listUnordered:s($n),paragraph:s(Li),reference:Ne,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:s(Nn),strong:s(Ii),thematicBreak:s(zi)},exit:{atxHeading:l(),atxHeadingSequence:w,autolink:l(),autolinkEmail:he,autolinkProtocol:tt,blockQuote:l(),characterEscapeValue:M,characterReferenceMarkerHexadecimal:et,characterReferenceMarkerNumeric:et,characterReferenceValue:K,codeFenced:l(b),codeFencedFence:x,codeFencedFenceInfo:E,codeFencedFenceMeta:C,codeFlowValue:M,codeIndented:l(A),codeText:l(Y),codeTextData:M,data:M,definition:l(),definitionDestinationString:g,definitionLabelString:O,definitionTitleString:L,emphasis:l(),hardBreakEscape:l(z),hardBreakTrailing:l(z),htmlFlow:l(R),htmlFlowData:M,htmlText:l(q),htmlTextData:M,image:l(ce),label:ue,labelText:m,lineEnding:D,link:l(se),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:Ut,resourceDestinationString:pe,resourceTitleString:d,resource:ne,setextHeading:l(H),setextHeadingLineSequence:I,setextHeadingText:S,strong:l(),thematicBreak:l()}};$r(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(y){let k={type:"root",children:[]},B={stack:[k],tokenStack:[],config:t,enter:a,exit:h,buffer:c,resume:f,setData:u,getData:o},U=[],V=-1;for(;++V0){let ae=B.tokenStack[B.tokenStack.length-1];(ae[1]||jr).call(B,void 0,ae[0])}for(k.position={start:Te(y.length>0?y[0][1].start:{line:1,column:1,offset:0}),end:Te(y.length>0?y[y.length-2][1].end:{line:1,column:1,offset:0})},V=-1;++V{let r=this.data("settings");return xn(n,Object.assign({},r,e,{extensions:this.data("micromarkExtensions")||[],mdastExtensions:this.data("fromMarkdownExtensions")||[]}))}})}function yn(e){if(e)throw e}var ai=Et(En(),1),Dn=Et(Jr(),1);function pt(e){if(typeof e!="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Fn(){let e=[],t={run:n,use:r};return t;function n(...i){let u=-1,o=i.pop();if(typeof o!="function")throw new TypeError("Expected function as last argument, not "+o);s(null,...i);function s(c,...a){let l=e[++u],h=-1;if(c){o(c);return}for(;++ho.length,c;s&&o.push(i);try{c=e.apply(this,o)}catch(a){let l=a;if(s&&n)throw l;return i(l)}s||(c&&c.then&&typeof c.then=="function"?c.then(u,i):c instanceof Error?i(c):u(c))}function i(o,...s){n||(n=!0,t(o,...s))}function u(o){i(null,o)}}var ii=Et(En(),1);var G=class extends Error{constructor(t,n,r){let i=[null,null],u={start:{line:null,column:null},end:{line:null,column:null}};if(super(),typeof n=="string"&&(r=n,n=void 0),typeof r=="string"){let o=r.indexOf(":");o===-1?i[1]=r:(i[0]=r.slice(0,o),i[1]=r.slice(o+1))}n&&("type"in n||"position"in n?n.position&&(u=n.position):"start"in n||"end"in n?u=n:("line"in n||"column"in n)&&(u.start=n)),this.name=De(n)||"1:1",this.message=typeof t=="object"?t.message:t,this.stack="",typeof t=="object"&&t.stack&&(this.stack=t.stack),this.reason=this.message,this.fatal,this.line=u.start.line,this.column=u.start.column,this.position=u,this.source=i[0],this.ruleId=i[1],this.file,this.actual,this.expected,this.url,this.note}};G.prototype.file="";G.prototype.name="";G.prototype.reason="";G.prototype.message="";G.prototype.stack="";G.prototype.fatal=null;G.prototype.column=null;G.prototype.line=null;G.prototype.source=null;G.prototype.ruleId=null;G.prototype.position=null;var le={basename:So,dirname:Do,extname:To,join:Oo,sep:"/"};function So(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');ht(e);let n=0,r=-1,i=e.length,u;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.charCodeAt(i)===47){if(u){n=i+1;break}}else r<0&&(u=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let o=-1,s=t.length-1;for(;i--;)if(e.charCodeAt(i)===47){if(u){n=i+1;break}}else o<0&&(u=!0,o=i+1),s>-1&&(e.charCodeAt(i)===t.charCodeAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function Do(e){if(ht(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.charCodeAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.charCodeAt(0)===47?"/":".":t===1&&e.charCodeAt(0)===47?"//":e.slice(0,t)}function To(e){ht(e);let t=e.length,n=-1,r=0,i=-1,u=0,o;for(;t--;){let s=e.charCodeAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:u!==1&&(u=1):i>-1&&(u=-1)}return i<0||n<0||u===0||u===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function Oo(...e){let t=-1,n;for(;++t0&&e.charCodeAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function Po(e,t){let n="",r=0,i=-1,u=0,o=-1,s,c;for(;++o<=e.length;){if(o2){if(c=n.lastIndexOf("/"),c!==n.length-1){c<0?(n="",r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf("/")),i=o,u=0;continue}}else if(n.length>0){n="",r=0,i=o,u=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,u=0}else s===46&&u>-1?u++:u=-1}return n}function ht(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}var ti={cwd:Lo};function Lo(){return"/"}function We(e){return e!==null&&typeof e=="object"&&e.href&&e.origin}function ni(e){if(typeof e=="string")e=new URL(e);else if(!We(e)){let t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){let t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return Io(e)}function Io(e){if(e.hostname!==""){let r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}let t=e.pathname,n=-1;for(;++n{if(g||!w||!S)L(g);else{let I=u.stringify(w,S);I==null||(Mo(I)?S.value=I:S.result=I),L(g,S)}});function L(g,w){g||!w?A(g):b?b(w):C(null,w)}}}function F(E){let C;u.freeze(),kn("processSync",u.Parser),bn("processSync",u.Compiler);let x=mt(E);return u.process(x,b),si("processSync","process",C),x;function b(A){C=!0,yn(A)}}}function ui(e,t){return typeof e=="function"&&e.prototype&&(zo(e.prototype)||t in e.prototype)}function zo(e){let t;for(t in e)if(li.call(e,t))return!0;return!1}function kn(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `Parser`")}function bn(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `Compiler`")}function Sn(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function oi(e){if(!pt(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function si(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function mt(e){return _o(e)?e:new ft(e)}function _o(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function Mo(e){return typeof e=="string"||(0,ai.default)(e)}var On={children(e){return je.children(e)},annotatetextnode(e,t){return je.annotatetextnode(e,t)},interpretmarkup(e=""){return` `.repeat((e.match(/\n/g)||[]).length)},remarkoptions:{}};function pi(e,t=On){let n=Tn().use(Lt,t.remarkoptions).use(At,["yaml","toml"]).parse(e);return Wn(e,n,t)}var Be=require("obsidian");var Pn=class{add(t,n,r){if(typeof arguments[0]!="string")for(let i in arguments[0])this.add(i,arguments[0][i],arguments[1]);else(Array.isArray(t)?t:[t]).forEach(function(i){this[i]=this[i]||[],n&&this[i][r?"unshift":"push"](n)},this)}run(t,n){this[t]=this[t]||[],this[t].forEach(function(r){r.call(n&&n.context?n.context:n,n)})}},Ln=class{constructor(t){this.jsep=t,this.registered={}}register(){for(var t=arguments.length,n=new Array(t),r=0;r{if(typeof i!="object"||!i.name||!i.init)throw new Error("Invalid JSEP plugin format");this.registered[i.name]||(i.init(this.jsep),this.registered[i.name]=i)})}},te=class e{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+e.version}static addUnaryOp(t){return e.max_unop_len=Math.max(t.length,e.max_unop_len),e.unary_ops[t]=1,e}static addBinaryOp(t,n,r){return e.max_binop_len=Math.max(t.length,e.max_binop_len),e.binary_ops[t]=n,r?e.right_associative.add(t):e.right_associative.delete(t),e}static addIdentifierChar(t){return e.additional_identifier_chars.add(t),e}static addLiteral(t,n){return e.literals[t]=n,e}static removeUnaryOp(t){return delete e.unary_ops[t],t.length===e.max_unop_len&&(e.max_unop_len=e.getMaxKeyLen(e.unary_ops)),e}static removeAllUnaryOps(){return e.unary_ops={},e.max_unop_len=0,e}static removeIdentifierChar(t){return e.additional_identifier_chars.delete(t),e}static removeBinaryOp(t){return delete e.binary_ops[t],t.length===e.max_binop_len&&(e.max_binop_len=e.getMaxKeyLen(e.binary_ops)),e.right_associative.delete(t),e}static removeAllBinaryOps(){return e.binary_ops={},e.max_binop_len=0,e}static removeLiteral(t){return delete e.literals[t],e}static removeAllLiterals(){return e.literals={},e}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(t){this.expr=t,this.index=0}static parse(t){return new e(t).parse()}static getMaxKeyLen(t){return Math.max(0,...Object.keys(t).map(n=>n.length))}static isDecimalDigit(t){return t>=48&&t<=57}static binaryPrecedence(t){return e.binary_ops[t]||0}static isIdentifierStart(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!e.binary_ops[String.fromCharCode(t)]||e.additional_identifier_chars.has(String.fromCharCode(t))}static isIdentifierPart(t){return e.isIdentifierStart(t)||e.isDecimalDigit(t)}throwError(t){let n=new Error(t+" at character "+this.index);throw n.index=this.index,n.description=t,n}runHook(t,n){if(e.hooks[t]){let r={context:this,node:n};return e.hooks.run(t,r),r.node}return n}searchHook(t){if(e.hooks[t]){let n={context:this};return e.hooks[t].find(function(r){return r.call(n.context,n),n.node}),n.node}}gobbleSpaces(){let t=this.code;for(;t===e.SPACE_CODE||t===e.TAB_CODE||t===e.LF_CODE||t===e.CR_CODE;)t=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let t=this.gobbleExpressions(),n=t.length===1?t[0]:{type:e.COMPOUND,body:t};return this.runHook("after-all",n)}gobbleExpressions(t){let n=[],r,i;for(;this.index0;){if(e.binary_ops.hasOwnProperty(t)&&(!e.isIdentifierStart(this.code)||this.index+t.lengthu.right_a&&h.right_a?r>h.prec:r<=h.prec;for(;i.length>2&&l(i[i.length-2]);)s=i.pop(),n=i.pop().value,o=i.pop(),t={type:e.BINARY_EXP,operator:n,left:o,right:s},i.push(t);t=this.gobbleToken(),t||this.throwError("Expected expression after "+a),i.push(u,t)}for(c=i.length-1,t=i[c];c>1;)t={type:e.BINARY_EXP,operator:i[c-1].value,left:i[c-2],right:t},c-=2;return t}gobbleToken(){let t,n,r,i;if(this.gobbleSpaces(),i=this.searchHook("gobble-token"),i)return this.runHook("after-token",i);if(t=this.code,e.isDecimalDigit(t)||t===e.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===e.SQUOTE_CODE||t===e.DQUOTE_CODE)i=this.gobbleStringLiteral();else if(t===e.OBRACK_CODE)i=this.gobbleArray();else{for(n=this.expr.substr(this.index,e.max_unop_len),r=n.length;r>0;){if(e.unary_ops.hasOwnProperty(n)&&(!e.isIdentifierStart(this.code)||this.index+n.length=n.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}else if(u===e.COMMA_CODE){if(this.index++,i++,i!==n.length){if(t===e.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===e.CBRACK_CODE)for(let o=n.length;o":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10,"**":11},right_associative:new Set(["**"]),additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"});te.max_unop_len=te.getMaxKeyLen(te.unary_ops);te.max_binop_len=te.getMaxKeyLen(te.binary_ops);var ge=e=>new te(e).parse(),Uo=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(te).filter(e=>!Uo.includes(e)&&ge[e]===void 0).forEach(e=>{ge[e]=te[e]});ge.Jsep=te;var jo="ConditionalExpression",Vo={name:"ternary",init(e){e.hooks.add("after-expression",function(n){if(n.node&&this.code===e.QUMARK_CODE){this.index++;let r=n.node,i=this.gobbleExpression();if(i||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let u=this.gobbleExpression();if(u||this.throwError("Expected expression"),n.node={type:jo,test:r,consequent:i,alternate:u},r.operator&&e.binary_ops[r.operator]<=.9){let o=r;for(;o.right.operator&&e.binary_ops[o.right.operator]<=.9;)o=o.right;n.node.test=o.right,o.right=n.node,n.node=r}}else this.throwError("Expected :")}})}};ge.plugins.register(Vo);var hi=47,$o=92,Ho={name:"regex",init(e){e.hooks.add("gobble-token",function(n){if(this.code===hi){let r=++this.index,i=!1;for(;this.index=97&&c<=122||c>=65&&c<=90||c>=48&&c<=57)o+=this.char;else break}let s;try{s=new RegExp(u,o)}catch(c){this.throwError(c.message)}return n.node={type:e.LITERAL,value:s,raw:this.expr.slice(r-1,this.index)},n.node=this.gobbleTokenProperty(n.node),n.node}this.code===e.OBRACK_CODE?i=!0:i&&this.code===e.CBRACK_CODE&&(i=!1),this.index+=this.code===$o?2:1}this.throwError("Unclosed Regex")}})}},Bn=43,qo=45,Ye={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|=","||=","&&=","??="]),updateOperators:[Bn,qo],assignmentPrecedence:.9,init(e){let t=[e.IDENTIFIER,e.MEMBER_EXP];Ye.assignmentOperators.forEach(r=>e.addBinaryOp(r,Ye.assignmentPrecedence,!0)),e.hooks.add("gobble-token",function(i){let u=this.code;Ye.updateOperators.some(o=>o===u&&o===this.expr.charCodeAt(this.index+1))&&(this.index+=2,i.node={type:"UpdateExpression",operator:u===Bn?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},(!i.node.argument||!t.includes(i.node.argument.type))&&this.throwError(`Unexpected ${i.node.operator}`))}),e.hooks.add("after-token",function(i){if(i.node){let u=this.code;Ye.updateOperators.some(o=>o===u&&o===this.expr.charCodeAt(this.index+1))&&(t.includes(i.node.type)||this.throwError(`Unexpected ${i.node.operator}`),this.index+=2,i.node={type:"UpdateExpression",operator:u===Bn?"++":"--",argument:i.node,prefix:!1})}}),e.hooks.add("after-expression",function(i){i.node&&n(i.node)});function n(r){Ye.assignmentOperators.has(r.operator)?(r.type="AssignmentExpression",n(r.left),n(r.right)):r.operator||Object.values(r).forEach(i=>{i&&typeof i=="object"&&n(i)})}}};ge.plugins.register(Ho,Ye);ge.addUnaryOp("typeof");ge.addLiteral("null",null);ge.addLiteral("undefined",void 0);var Wo=new Set(["constructor","__proto__","__defineGetter__","__defineSetter__"]),j={evalAst(e,t){switch(e.type){case"BinaryExpression":case"LogicalExpression":return j.evalBinaryExpression(e,t);case"Compound":return j.evalCompound(e,t);case"ConditionalExpression":return j.evalConditionalExpression(e,t);case"Identifier":return j.evalIdentifier(e,t);case"Literal":return j.evalLiteral(e,t);case"MemberExpression":return j.evalMemberExpression(e,t);case"UnaryExpression":return j.evalUnaryExpression(e,t);case"ArrayExpression":return j.evalArrayExpression(e,t);case"CallExpression":return j.evalCallExpression(e,t);case"AssignmentExpression":return j.evalAssignmentExpression(e,t);default:throw SyntaxError("Unexpected expression",e)}},evalBinaryExpression(e,t){return{"||":(r,i)=>r||i(),"&&":(r,i)=>r&&i(),"|":(r,i)=>r|i(),"^":(r,i)=>r^i(),"&":(r,i)=>r&i(),"==":(r,i)=>r==i(),"!=":(r,i)=>r!=i(),"===":(r,i)=>r===i(),"!==":(r,i)=>r!==i(),"<":(r,i)=>r":(r,i)=>r>i(),"<=":(r,i)=>r<=i(),">=":(r,i)=>r>=i(),"<<":(r,i)=>r<>":(r,i)=>r>>i(),">>>":(r,i)=>r>>>i(),"+":(r,i)=>r+i(),"-":(r,i)=>r-i(),"*":(r,i)=>r*i(),"/":(r,i)=>r/i(),"%":(r,i)=>r%i()}[e.operator](j.evalAst(e.left,t),()=>j.evalAst(e.right,t))},evalCompound(e,t){let n;for(let r=0;r-j.evalAst(r,t),"!":r=>!j.evalAst(r,t),"~":r=>~j.evalAst(r,t),"+":r=>+j.evalAst(r,t),typeof:r=>typeof j.evalAst(r,t)}[e.operator](e.argument)},evalArrayExpression(e,t){return e.elements.map(n=>j.evalAst(n,t))},evalCallExpression(e,t){let n=e.arguments.map(i=>j.evalAst(i,t));return j.evalAst(e.callee,t)(...n)},evalAssignmentExpression(e,t){if(e.left.type!=="Identifier")throw SyntaxError("Invalid left-hand side in assignment");let n=e.left.name,r=j.evalAst(e.right,t);return t[n]=r,t[n]}},In=class{constructor(t){this.code=t,this.ast=ge(this.code)}runInNewContext(t){let n=Object.assign(Object.create(null),t);return j.evalAst(this.ast,n)}};function Oe(e,t){return e=e.slice(),e.push(t),e}function Rn(e,t){return t=t.slice(),t.unshift(e),t}var zn=class extends Error{constructor(t){super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'),this.avoidNew=!0,this.value=t,this.name="NewError"}};function v(e,t,n,r,i){if(!(this instanceof v))try{return new v(e,t,n,r,i)}catch(o){if(!o.avoidNew)throw o;return o.value}typeof e=="string"&&(i=r,r=n,n=t,t=e,e=null);let u=e&&typeof e=="object";if(e=e||{},this.json=e.json||n,this.path=e.path||t,this.resultType=e.resultType||"value",this.flatten=e.flatten||!1,this.wrap=Object.hasOwn(e,"wrap")?e.wrap:!0,this.sandbox=e.sandbox||{},this.eval=e.eval===void 0?"safe":e.eval,this.ignoreEvalErrors=typeof e.ignoreEvalErrors=="undefined"?!1:e.ignoreEvalErrors,this.parent=e.parent||null,this.parentProperty=e.parentProperty||null,this.callback=e.callback||r||null,this.otherTypeCallback=e.otherTypeCallback||i||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},e.autostart!==!1){let o={path:u?e.path:t};u?"json"in e&&(o.json=e.json):o.json=n;let s=this.evaluate(o);if(!s||typeof s!="object")throw new zn(s);return s}}v.prototype.evaluate=function(e,t,n,r){let i=this.parent,u=this.parentProperty,{flatten:o,wrap:s}=this;if(this.currResultType=this.resultType,this.currEval=this.eval,this.currSandbox=this.sandbox,n=n||this.callback,this.currOtherTypeCallback=r||this.otherTypeCallback,t=t||this.json,e=e||this.path,e&&typeof e=="object"&&!Array.isArray(e)){if(!e.path&&e.path!=="")throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!Object.hasOwn(e,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:t}=e),o=Object.hasOwn(e,"flatten")?e.flatten:o,this.currResultType=Object.hasOwn(e,"resultType")?e.resultType:this.currResultType,this.currSandbox=Object.hasOwn(e,"sandbox")?e.sandbox:this.currSandbox,s=Object.hasOwn(e,"wrap")?e.wrap:s,this.currEval=Object.hasOwn(e,"eval")?e.eval:this.currEval,n=Object.hasOwn(e,"callback")?e.callback:n,this.currOtherTypeCallback=Object.hasOwn(e,"otherTypeCallback")?e.otherTypeCallback:this.currOtherTypeCallback,i=Object.hasOwn(e,"parent")?e.parent:i,u=Object.hasOwn(e,"parentProperty")?e.parentProperty:u,e=e.path}if(i=i||null,u=u||null,Array.isArray(e)&&(e=v.toPathString(e)),!e&&e!==""||!t)return;let c=v.toPathArray(e);c[0]==="$"&&c.length>1&&c.shift(),this._hasParentSelector=null;let a=this._trace(c,t,["$"],i,u,n).filter(function(l){return l&&!l.isParentSelector});return a.length?!s&&a.length===1&&!a[0].hasArrExpr?this._getPreferredOutput(a[0]):a.reduce((l,h)=>{let f=this._getPreferredOutput(h);return o&&Array.isArray(f)?l=l.concat(f):l.push(f),l},[]):s?[]:void 0};v.prototype._getPreferredOutput=function(e){let t=this.currResultType;switch(t){case"all":{let n=Array.isArray(e.path)?e.path:v.toPathArray(e.path);return e.pointer=v.toPointer(n),e.path=typeof e.path=="string"?e.path:v.toPathString(e.path),e}case"value":case"parent":case"parentProperty":return e[t];case"path":return v.toPathString(e[t]);case"pointer":return v.toPointer(e.path);default:throw new TypeError("Unknown result type")}};v.prototype._handleCallback=function(e,t,n){if(t){let r=this._getPreferredOutput(e);e.path=typeof e.path=="string"?e.path:v.toPathString(e.path),t(r,n,e)}};v.prototype._trace=function(e,t,n,r,i,u,o,s){let c;if(!e.length)return c={path:n,value:t,parent:r,parentProperty:i,hasArrExpr:o},this._handleCallback(c,u,"value"),c;let a=e[0],l=e.slice(1),h=[];function f(p){Array.isArray(p)?p.forEach(F=>{h.push(F)}):h.push(p)}if((typeof a!="string"||s)&&t&&Object.hasOwn(t,a))f(this._trace(l,t[a],Oe(n,a),t,a,u,o));else if(a==="*")this._walk(t,p=>{f(this._trace(l,t[p],Oe(n,p),t,p,u,!0,!0))});else if(a==="..")f(this._trace(l,t,n,r,i,u,o)),this._walk(t,p=>{typeof t[p]=="object"&&f(this._trace(e.slice(),t[p],Oe(n,p),t,p,u,!0))});else{if(a==="^")return this._hasParentSelector=!0,{path:n.slice(0,-1),expr:l,isParentSelector:!0};if(a==="~")return c={path:Oe(n,a),value:i,parent:r,parentProperty:null},this._handleCallback(c,u,"property"),c;if(a==="$")f(this._trace(l,t,n,null,null,u,o));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(a))f(this._slice(a,l,t,n,r,i,u));else if(a.indexOf("?(")===0){if(this.currEval===!1)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");let p=a.replace(/^\?\((.*?)\)$/u,"$1"),F=/@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(p);F?this._walk(t,E=>{let C=[F[2]],x=F[1]?t[E][F[1]]:t[E];this._trace(C,x,n,r,i,u,!0).length>0&&f(this._trace(l,t[E],Oe(n,E),t,E,u,!0))}):this._walk(t,E=>{this._eval(p,t[E],E,n,r,i)&&f(this._trace(l,t[E],Oe(n,E),t,E,u,!0))})}else if(a[0]==="("){if(this.currEval===!1)throw new Error("Eval [(expr)] prevented in JSONPath expression.");f(this._trace(Rn(this._eval(a,t,n.at(-1),n.slice(0,-1),r,i),l),t,n,r,i,u,o))}else if(a[0]==="@"){let p=!1,F=a.slice(1,-2);switch(F){case"scalar":(!t||!["object","function"].includes(typeof t))&&(p=!0);break;case"boolean":case"string":case"undefined":case"function":typeof t===F&&(p=!0);break;case"integer":Number.isFinite(t)&&!(t%1)&&(p=!0);break;case"number":Number.isFinite(t)&&(p=!0);break;case"nonFinite":typeof t=="number"&&!Number.isFinite(t)&&(p=!0);break;case"object":t&&typeof t===F&&(p=!0);break;case"array":Array.isArray(t)&&(p=!0);break;case"other":p=this.currOtherTypeCallback(t,n,r,i);break;case"null":t===null&&(p=!0);break;default:throw new TypeError("Unknown value type "+F)}if(p)return c={path:n,value:t,parent:r,parentProperty:i},this._handleCallback(c,u,"value"),c}else if(a[0]==="`"&&t&&Object.hasOwn(t,a.slice(1))){let p=a.slice(1);f(this._trace(l,t[p],Oe(n,p),t,p,u,o,!0))}else if(a.includes(",")){let p=a.split(",");for(let F of p)f(this._trace(Rn(F,l),t,n,r,i,u,!0))}else!s&&t&&Object.hasOwn(t,a)&&f(this._trace(l,t[a],Oe(n,a),t,a,u,o,!0))}if(this._hasParentSelector)for(let p=0;p{t(n)})};v.prototype._slice=function(e,t,n,r,i,u,o){if(!Array.isArray(n))return;let s=n.length,c=e.split(":"),a=c[2]&&Number.parseInt(c[2])||1,l=c[0]&&Number.parseInt(c[0])||0,h=c[1]&&Number.parseInt(c[1])||s;l=l<0?Math.max(0,l+s):Math.min(s,l),h=h<0?Math.max(0,h+s):Math.min(s,h);let f=[];for(let p=l;p{f.push(E)});return f};v.prototype._eval=function(e,t,n,r,i,u){this.currSandbox._$_parentProperty=u,this.currSandbox._$_parent=i,this.currSandbox._$_property=n,this.currSandbox._$_root=this.json,this.currSandbox._$_v=t;let o=e.includes("@path");o&&(this.currSandbox._$_path=v.toPathString(r.concat([n])));let s=this.currEval+"Script:"+e;if(!v.cache[s]){let c=e.replaceAll("@parentProperty","_$_parentProperty").replaceAll("@parent","_$_parent").replaceAll("@property","_$_property").replaceAll("@root","_$_root").replaceAll(/@([.\s)[])/gu,"_$_v$1");if(o&&(c=c.replaceAll("@path","_$_path")),this.currEval==="safe"||this.currEval===!0||this.currEval===void 0)v.cache[s]=new this.safeVm.Script(c);else if(this.currEval==="native")v.cache[s]=new this.vm.Script(c);else if(typeof this.currEval=="function"&&this.currEval.prototype&&Object.hasOwn(this.currEval.prototype,"runInNewContext")){let a=this.currEval;v.cache[s]=new a(c)}else if(typeof this.currEval=="function")v.cache[s]={runInNewContext:a=>this.currEval(c,a)};else throw new TypeError(`Unknown "eval" property "${this.currEval}"`)}try{return v.cache[s].runInNewContext(this.currSandbox)}catch(c){if(this.ignoreEvalErrors)return!1;throw new Error("jsonPath: "+c.message+": "+e)}};v.cache={};v.toPathString=function(e){let t=e,n=t.length,r="$";for(let i=1;itypeof t[a]=="function");let u=r.map(a=>t[a]);n=i.reduce((a,l)=>{let h=t[l].toString();return/function/u.test(h)||(h="function "+h),"var "+l+"="+h+";"+a},"")+n,!/(['"])use strict\1/u.test(n)&&!r.includes("arguments")&&(n="var arguments = undefined;"+n),n=n.replace(/;\s*$/u,"");let s=n.lastIndexOf(";"),c=s!==-1?n.slice(0,s+1)+" return "+n.slice(s+1):" return "+n;return new Function(...r,c)(...u)}};v.prototype.vm={Script:_n};var ie;(h=>{async function e(f,p,F,E){var w;let C=pi(F,{...On,interpretmarkup(S=""){var H,$;if(/^`[^`]+`$/.test(S))return S;let I=` `.repeat(($=(H=S.match(/\n/g))==null?void 0:H.length)!=null?$:0);return S.match(/^\s*(-|\d+\.) $/m)?I+"\u2022 ":I}}),x=JSON.stringify(C),b=fi(f.serverUrl);if(x.length>b.maxSize)throw new Error(`Text too long for LanguageTool ${x.length} characters, max is ${b.maxSize} Select a portion of the document and try again!`);let A=(w=E!=null?E:f.staticLanguage)!=null?w:"auto",O={data:x,language:A,enabledOnly:"false",level:f.pickyMode?"picky":"default"};f.motherTongue&&(O.motherTongue=f.motherTongue),f.enabledCategories&&(O.enabledCategories=f.enabledCategories),f.disabledCategories&&(O.disabledCategories=f.disabledCategories),f.enabledRules&&(O.enabledRules=f.enabledRules),f.disabledRules&&(O.disabledRules=f.disabledRules),A=="auto"&&(O.preferredVariants=Object.values(f.languageVariety).join(",")),f.apikey&&f.username&&(O.username=f.username,O.apiKey=f.apikey);let L;try{console.log(`LanguageTool: Checking ${x.length} characters`),L=await(0,Be.requestUrl)({url:`${f.serverUrl}/v2/check`,method:"POST",body:new URLSearchParams(O).toString(),throw:!0,headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"}})}catch(S){throw new Error(`Request to LanguageTool failed: Please check your connection and server URL. ${S}`)}if(L.json==null)throw new Error("Error processing response from LanguageTool.");return a("$.matches[*]",L.json).map(S=>{let I=c("$.offset@number()",S),H=I+c("$.length@number()",S);return{text:F.slice(I,H),from:p+I,to:p+H,title:c("$.shortMessage@string()",S),message:c("$.message@string()",S),replacements:a("$.replacements[*].value@string()",S),categoryId:c("$.rule.category.id@string()",S),ruleId:c("$.rule.id@string()",S)}})}h.check=e;async function t(f){let p=await(0,Be.requestUrl)({url:`${f}/v2/languages`}).json;if(p==null||!(p instanceof Array))throw new Error("Error processing response from LanguageTool.");return p}h.languages=t;async function n(f){if(f.username==null||f.apikey==null)throw Error("Syncing words is only supported for premium users");try{let p=await(0,Be.requestUrl)({url:l(`${f.serverUrl}/v2/words`,{username:f.username,apiKey:f.apikey,limit:"1000"}).href}).json;return a("$.words[*]@string()",p)}catch(p){throw new Error(`Requesting words failed ${p}`)}}h.words=n;async function r(f,p){if(f.username==null||f.apikey==null)throw Error("Syncing words is only supported for premium users");try{let F=await(0,Be.requestUrl)({url:l(`${f.serverUrl}/v2/words/add`,{username:f.username,apiKey:f.apikey,word:p}).href,method:"POST"}).json;return c("$.added@boolean()",F)}catch(F){throw new Error(`Adding words failed ${F}`)}}h.wordsAdd=r;async function i(f,p){if(f.username==null||f.apikey==null)throw Error("Syncing words is only supported for premium users");try{let F=await(0,Be.requestUrl)({url:l(`${f.serverUrl}/v2/words/delete`,{username:f.username,apiKey:f.apikey,word:p}).href,method:"POST"}).json;return c("$.deleted@boolean()",F)}catch(F){throw new Error(`Deleting words failed ${F}`)}}h.wordsDel=i;class u{constructor(){this.url="https://qb-grammar-en.languagetool.org/phrasal-paraphraser/subscribe"}async query(p,F){let E=p.slice(0,F.from).split(/\s+/).length,C=p.slice(F.from,F.to),x={message:{indices:[E],mode:0,phrases:[C],text:p},meta:{clientStatus:"string",product:"string",traceID:"string",userID:"string"},response_queue:"string"};try{let b=await(0,Be.requestUrl)({url:this.url,method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)}).json;return a("$.data.suggestions[*][*]@string()",b)}catch(b){throw new Error(`Requesting synonyms failed ${b}`)}}}class o{constructor(){this.url="https://synonyms.languagetool.org/synonyms/de"}async query(p,F){let E=p.slice(F.from,F.to).trim(),C=p.slice(0,F.from).split(/\s+/).join("+"),x=p.slice(F.to).split(/\s+/).join("+");try{let b=await(0,Be.requestUrl)({url:l(`${this.url}/${E}`,{before:C,after:x}).href,method:"GET"}).json;return a("$.synsets[*].terms[*].term@string()",b)}catch(b){throw new Error(`Requesting synonyms failed ${b}`)}}}h.SYNONYMS={en:new u,de:new o};function c(f,p){let F=v({path:f,json:p,wrap:!1,eval:!1});if(F==null)throw new Error("Error parsing response.");return F}function a(f,p){let F=v({path:f,json:p,wrap:!0,eval:!1});if(F==null||!(F instanceof Array))throw new Error("Error parsing response.");return F}function l(f,p){let F=new URL(f);return F.search=new URLSearchParams(p).toString(),F}})(ie||(ie={}));function Rt(e){switch(e){case"COLLOQUIALISMS":case"REDUNDANCY":case"STYLE":case"SYNONYMS":return"lt-style";case"TYPOS":return"lt-major"}return"lt-minor"}function Qe(e,t){let n=new Set(e);for(let r of t)n.delete(r);return n}function Mn(e,t){let n=new Set(e);for(let r of t)n.add(r);return n}function mi(e,t){let n=new Set;for(let r of t)e.has(r)&&n.add(r);return n}function Ke(e,t){return e=e.toLowerCase(),t=t.toLowerCase(),e>t?1:en.code===t).filter(n=>n.longCode!==n.code),Object.fromEntries(e.map(n=>[n.longCode,n.name]))}var zt=class extends N.PluginSettingTab{constructor(n,r){super(n,r);this.endpointListeners=[];this.languageListeners=[];this.languages=[];this.plugin=r}configureCheckDelay(n,r){let i=Xe[r].minDelay;this.plugin.settings.autoCheckDelay=Math.clamp(this.plugin.settings.autoCheckDelay,i,di),n.setLimits(i,di,Qo)}async notifyEndpointChange(n){for(let r of this.endpointListeners)await r(n.serverUrl)}async configureLanguageVariants(n,r){var o;let i=this.plugin.settings.languageVariety,u=gi(this.languages,r);i[r]=(o=i[r])!=null?o:Object.keys(u)[0],n.addOptions(u).setValue(i[r]).onChange(async s=>{i[r]=s,await this.plugin.saveSettings()}),this.languageListeners.push(async s=>{var a;for(;n.selectEl.options.length>0;)n.selectEl.remove(0);let c=gi(s,r);i[r]=(a=i[r])!=null?a:Object.keys(c)[0],n.addOptions(c).setValue(i[r])})}async display(){let{containerEl:n}=this;n.empty();let r=this.plugin.settings;this.endpointListeners=[],this.endpointListeners.push(async a=>{let l=[];a&&(l=await ie.languages(a)),this.languages=l;for(let h of this.languageListeners)await h(l)}),this.endpointListeners.push(async a=>{await this.plugin.syncDictionary()}),this.languageListeners=[],new N.Setting(n).setName("Error logs").setDesc(`${this.plugin.logs.length} messages`).addButton(a=>{a.setButtonText("Copy to clipboard").onClick(async()=>{await window.navigator.clipboard.writeText(this.plugin.logs.join(` `)),new N.Notice("Logs copied to clipboard")})});let i=Ze(r.serverUrl),u=null;new N.Setting(n).setName("Endpoint").setDesc("Choose the LanguageTool server url").then(a=>{a.controlEl.classList.add("lt-settings-grid");let l=null,h=null;a.addDropdown(f=>{l=f,f.addOptions({standard:"(Standard) api.languagetool.org",premium:"(Premium) api.languagetoolplus.com",custom:"Custom URL"}).setValue(i).onChange(async p=>{i=p,r.serverUrl=Xe[i].url,h&&h.setValue(r.serverUrl).setDisabled(p!=="custom"),u&&this.configureCheckDelay(u,i),await this.notifyEndpointChange(r),await this.plugin.saveSettings()})}),a.addText(f=>{h=f,f.setPlaceholder("https://your-custom-url.com").setValue(r.serverUrl).setDisabled(i!=="custom").onChange(async p=>{r.serverUrl=p.replace(/\/v2\/check\/$/,"").replace(/\/$/,""),i=Ze(r.serverUrl),i!=="custom"&&(l==null||l.setValue(i),h==null||h.setDisabled(!0)),await this.notifyEndpointChange(r),await this.plugin.saveSettings()})})}),new N.Setting(n).setName("API username").setDesc("Enter a username/mail for API access").addText(a=>a.setPlaceholder("peterlustig@example.com").setValue(r.username||"").onChange(async l=>{r.username=l.replace(/\s+/g,""),await this.plugin.saveSettings()})),new N.Setting(n).setName("API key").setDesc(createFragment(a=>{a.createEl("a",{text:"Click here for information about Premium Access",href:"https://github.com/wrenger/obsidian-languagetool#premium-accounts",attr:{target:"_blank"}})})).addText(a=>a.setValue(r.apikey||"").onChange(async l=>{r.apikey=l.replace(/\s+/g,""),r.apikey&&i!=="premium"&&new N.Notice("You have entered an API Key but you are not using the Premium Endpoint"),await this.plugin.saveSettings()})),new N.Setting(n).setName("Auto check text").setDesc("Check text as you type").addToggle(a=>{a.setValue(r.shouldAutoCheck).onChange(async l=>{r.shouldAutoCheck=l,await this.plugin.saveSettings()})}),new N.Setting(n).setName("Auto check delay (ms)").setDesc("Time to wait for autocheck after the last key press").addSlider(a=>{u=a,this.configureCheckDelay(a,i),a.setValue(r.autoCheckDelay).onChange(async l=>{r.autoCheckDelay=l,await this.plugin.saveSettings()}).setDynamicTooltip()});function o(a){if(a.appendText("Enables the context menu for synonyms fetched from"),a.createEl("br"),r.synonyms!=null){let l=ie.SYNONYMS[r.synonyms];if(!l){a.appendText(" (unknown API)");return}a.createEl("a",{text:l.url,href:l.url,attr:{target:"_blank"}})}else a.appendText("(none)")}let s=new N.Setting(n).setName("Find synonyms").setDesc(createFragment(o));s.addDropdown(a=>{var l;a.addOption("none","---");for(let h of Object.keys(ie.SYNONYMS))a.addOption(h,h);a.setValue((l=r.synonyms)!=null?l:"none").onChange(async h=>{r.synonyms=h!=="none"?h:void 0,await this.plugin.saveSettings(),s.setDesc(createFragment(o))})}),new N.Setting(n).setName("Language settings").setHeading(),new N.Setting(n).setName("Mother tongue").setDesc("Set mother tongue if you want to be warned about false friends when writing in other languages. This setting will also be used for automatic language detection.").addDropdown(a=>{this.languageListeners.push(async l=>{var h;for(;a.selectEl.options.length>0;)a.selectEl.remove(0);a.addOption("none","---").addOptions(Object.fromEntries(l.filter(f=>f.longCode==f.code).map(f=>[f.longCode,f.name]))).setValue((h=r.motherTongue)!=null?h:"none").onChange(async f=>{r.motherTongue=f!=="none"?f:void 0,await this.plugin.saveSettings()})})}),new N.Setting(n).setName("Static language").setDesc("Set a static language that will always be used (LanguageTool tries to auto detect the language, this is usually not necessary)").addDropdown(a=>{this.languageListeners.push(async l=>{var h;for(;a.selectEl.options.length>0;)a.selectEl.remove(0);a.addOption("auto","Auto Detect").addOptions(Object.fromEntries(l.map(f=>[f.longCode,f.name]))).setValue((h=r.staticLanguage)!=null?h:"auto").onChange(async f=>{r.staticLanguage=f!=="auto"?f:void 0,await this.plugin.saveSettings()})})}),new N.Setting(n).setName("Language varieties").setHeading().setDesc("Some languages have varieties depending on the country they are spoken in.");let c={en:"English",de:"German",pt:"Portuguese",ca:"Catalan"};for(let[a,l]of Object.entries(c))new N.Setting(n).setName(`Interpret ${l} as`).addDropdown(async h=>{this.configureLanguageVariants(h,a)});new N.Setting(n).setName("Spellcheck Dictionary").setHeading(),new N.Setting(n).setName("Ignored Words").setDesc("Words that should not be highlighted as spelling mistakes.").addButton(a=>{a.setIcon("settings").setTooltip("Edit dictionary").onClick(()=>{new vn(this.app,this.plugin).open()})}),new N.Setting(n).setName("Sync with LanguageTool").setDesc("This is only supported for premium users.").addToggle(a=>{a.setDisabled(i!=="premium").setValue(r.syncDictionary).onChange(async l=>{r.syncDictionary=l,await this.plugin.syncDictionary()}),this.endpointListeners.push(async l=>{a.setDisabled(Ze(l)!=="premium")})}),new N.Setting(n).setName("Rule categories").setHeading().setDesc(createFragment(a=>{a.appendText("The picky mode enables a lot of extra categories and rules. Additionally, you can enable or disable specific rules down below."),a.createEl("br"),a.createEl("a",{text:"Click here for a list of rules and categories",href:"https://community.languagetool.org/rule/list",attr:{target:"_blank"}})})),new N.Setting(n).setName("Picky mode").setDesc("Provides more style and tonality suggestions, detects long or complex sentences, recognizes colloquialism and redundancies, proactively suggests synonyms for commonly overused words").addToggle(a=>{a.setValue(r.pickyMode).onChange(async l=>{r.pickyMode=l,await this.plugin.saveSettings()})}),new N.Setting(n).setName("Enabled categories").setDesc("Comma-separated list of categories").addText(a=>{var l;return a.setPlaceholder("CATEGORY_1,CATEGORY_2").setValue((l=r.enabledCategories)!=null?l:"").onChange(async h=>{r.enabledCategories=h.replace(/\s+/g,""),await this.plugin.saveSettings()})}),new N.Setting(n).setName("Disabled categories").setDesc("Comma-separated list of categories").addText(a=>{var l;return a.setPlaceholder("CATEGORY_1,CATEGORY_2").setValue((l=r.disabledCategories)!=null?l:"").onChange(async h=>{r.disabledCategories=h.replace(/\s+/g,""),await this.plugin.saveSettings()})}),new N.Setting(n).setName("Enabled rules").setDesc("Comma-separated list of rules").addText(a=>{var l;return a.setPlaceholder("RULE_1,RULE_2").setValue((l=r.enabledRules)!=null?l:"").onChange(async h=>{r.enabledRules=h.replace(/\s+/g,""),await this.plugin.saveSettings()})}),new N.Setting(n).setName("Disabled rules").setDesc("Comma-separated list of rules").addText(a=>{var l;return a.setPlaceholder("RULE_1,RULE_2").setValue((l=r.disabledRules)!=null?l:"").onChange(async h=>{r.disabledRules=h.replace(/\s+/g,""),await this.plugin.saveSettings()})}),await this.notifyEndpointChange(r)}},vn=class extends N.Modal{constructor(t,n){super(t),this.setTitle("Spellcheck dictionary"),this.plugin=n,this.words=n.settings.dictionary}async onOpen(){this.words=this.plugin.settings.dictionary;let{contentEl:t}=this,n=s=>{s.replaceChildren(...this.words.map(c=>s.createDiv({cls:"multi-select-pill"},a=>{a.createDiv({cls:"multi-select-pill-content"},l=>l.createSpan({text:c})),a.createDiv({cls:"multi-select-pill-remove-button"},l=>{l.appendChild((0,N.getIcon)("x")),l.onClickEvent(()=>{this.words.remove(c),n(s)})})})))},r=null;t.createDiv({cls:"multi-select-container"},s=>{r=s,n(s)}),this.plugin.syncDictionary().then(s=>{s&&(this.words=this.plugin.settings.dictionary,r&&n(r))});let i="",u=null,o=()=>{i&&(this.words=[...new Set([...this.words,i])].sort(Ke),r&&n(r),u&&u.setValue(""),i="")};new N.Setting(t).setName("Add").addText(s=>{u=s.setValue(i).onChange(c=>i=c.trim()),s.inputEl.addEventListener("keypress",c=>{c.key==="Enter"&&o()})}).addExtraButton(s=>{s.setIcon("plus").setTooltip("Add").onClick(()=>{o()})})}async onClose(){this.contentEl.empty(),this.plugin.settings.dictionary=this.words,await this.plugin.syncDictionary()}};var bi=require("@codemirror/view");var yi=require("@codemirror/view");function Ei(e){let t=-1,n=1/0,r=-1/0;return yi.EditorView.updateListener.of(i=>{if(!i.docChanged||!e.settings.shouldAutoCheck)return;i.changes.iterChangedRanges((o,s,c,a)=>{n=Math.min(n,c,a),r=Math.max(r,c,a)});let u=i.view;clearTimeout(t),t=window.setTimeout(()=>{e.runDetection(u,{from:n,to:r}).catch(o=>{console.error(o)}),n=1/0,r=-1/0},e.settings.autoCheckDelay)})}var Ci=require("@codemirror/view"),wi=require("@codemirror/state");var xt=require("obsidian");var Ge=require("@codemirror/view"),Me=require("@codemirror/state"),Je=require("@codemirror/language");var Ko=/(frontmatter|code|math|templater|blockid|hashtag|internal)/,_t=Me.StateEffect.define(),gt=Me.StateEffect.define(),ve=Me.StateEffect.define(),Mt=Me.StateEffect.define();function Fi(e,t){return e.from<=t.from&&t.from<=e.to||e.from<=t.to&&t.to<=e.to||t.from<=e.from&&e.from<=t.to||t.from<=e.to&&e.to<=t.to}var Pe=Me.StateField.define({create(){return Ge.Decoration.none},update(e,t){e=e.map(t.changes);let n=new Set,r={},i=null,u=s=>{if(r[s]==null){i||(i=(0,Je.syntaxTree)(t.state));let c=i.resolveInner(s,1).type.prop(Je.tokenClassNodeProp);r[s]=!(c&&Ko.test(c))}return r[s]},o=s=>{i||(i=(0,Je.syntaxTree)(t.state));let c=i.resolve(t.newDoc.lineAt(s.from).from,1).type.prop(Je.tokenClassNodeProp);return!(c!=null&&c.includes("table")&&s.ruleId==="WHITESPACE_RULE")};t.docChanged&&t.selection&&e.size&&(e=e.update({filter:(s,c)=>!Fi({from:s,to:c},t.selection.main)}));for(let s of t.effects)if(s.is(_t)){let c=s.value,a=`${c.from},${c.to}`;!n.has(a)&&u(c.from)&&u(c.to)&&o(c)&&(n.add(a),e=e.update({add:[Ge.Decoration.mark({class:`lt-underline ${Rt(c.categoryId)}`,underline:c}).range(c.from,c.to)]}))}else s.is(gt)?e=Ge.Decoration.none:s.is(ve)?e=e.update({filterFrom:s.value.from,filterTo:s.value.to,filter:(c,a)=>!Fi({from:c,to:a},s.value)}):s.is(Mt)&&(e=e.update({filter:(c,a,l)=>!s.value(l.spec.underline)}));return e},provide:e=>Ge.EditorView.decorations.from(e)});function Zo(e,t,n){let r=n.replacements.slice(0,vt),i=n.categoryId,u=n.ruleId;return createDiv({cls:["lt-predictions-container",Rt(i)]},o=>{n.title&&o.createSpan({cls:"lt-title"},c=>{c.createSpan({text:n.title})}),n.message&&o.createSpan({cls:"lt-message",text:n.message});let s=ve.of({...n});o.createDiv({cls:"lt-bottom"},c=>{r.length&&c.createDiv({cls:"lt-buttoncontainer"},a=>{for(let l of r)a.createEl("button",{text:l||"(delete)"},h=>{h.onclick=()=>{t.dispatch({changes:[{from:n.from,to:n.to,insert:l}],effects:[s]})}})}),c.createDiv({cls:"lt-info-container"},a=>{a.createEl("button",{cls:"lt-info-button clickable-icon"},l=>{(0,xt.setIcon)(l,"info"),l.onclick=()=>{let h=document.getElementsByClassName("lt-info-box").item(0);if(!h)throw Error("Programming error: failed to create popup.");h.hasClass("hidden")?h.removeClass("hidden"):h.addClass("hidden")}}),a.createDiv({cls:"lt-info-box hidden"},l=>{l.createDiv({cls:"lt-info",text:`Category:\xA0${i}`}),l.createDiv({cls:"lt-info",text:`Rule:\xA0${u}`})})})}),o.createDiv({cls:"lt-ignorecontainer"},c=>{c.createEl("button",{cls:"lt-ignore-btn"},a=>{i==="TYPOS"?((0,xt.setIcon)(a.createSpan(),"plus-with-circle"),a.createSpan({text:"Add to personal dictionary"}),a.onclick=async()=>{e.settings.dictionary.push(n.text),await e.syncDictionary(),t.dispatch({effects:[Mt.of(l=>l.text===n.text)]})}):((0,xt.setIcon)(a.createSpan(),"cross"),a.createSpan({text:"Ignore suggestion"}),a.onclick=()=>{t.dispatch({effects:[s]})})}),i!=="TYPOS"&&i!=="SYNONYMS"&&c.createEl("button",{cls:"lt-ignore-btn"},a=>{(0,xt.setIcon)(a.createSpan(),"circle-off"),a.createSpan({text:"Disable rule"}),a.onclick=()=>{e.settings.disabledRules?e.settings.disabledRules+=","+u:e.settings.disabledRules=u,e.saveSettings(),t.dispatch({effects:[Mt.of(l=>l.ruleId===u)]})}})})})}function Ai(e,t,n){let r=n.field(Pe);if(r.size===0||n.selection.ranges.length>1)return[];let i=null;if(r.between(n.selection.main.from,n.selection.main.to,(u,o,s)=>{i={...s.spec.underline,from:u,to:o}}),i!=null){let{from:u,to:o}=i;if(e.length){let s=e[0];if(s.pos===u&&s.end===o)return e}return[{pos:u,end:o,above:!0,strictSide:!1,arrow:!1,create:s=>({dom:Zo(t,s,i)})}]}return[]}function ki(e){return wi.StateField.define({create:t=>Ai([],e,t),update:(t,n)=>Ai(t,e,n.state),provide:t=>Ci.showTooltip.computeN([t],n=>n.field(t))})}function Si(e){return[(0,bi.tooltips)({position:"absolute",tooltipSpace:t=>t.dom.getBoundingClientRect()}),Pe,ki(e),Ei(e)]}var Di=require("@codemirror/language");var vt=5;function Xo(){if(window.electronWindow==null)throw Error("Electron not found!");return window.electronWindow}var Nt=class extends oe.Plugin{constructor(){super(...arguments);this.isLoading=!1;this.logs=[]}async onload(){await this.loadSettings(),this.settingTab=new zt(this.app,this),this.addSettingTab(this.settingTab),this.app.workspace.onLayoutReady(()=>{this.statusBarText=this.addStatusBarItem(),this.setStatusBarReady(),this.registerDomEvent(this.statusBarText,"click",()=>this.handleStatusBarClick())}),this.registerEditorExtension(Si(this)),this.registerCommands(),this.registerMenuItems();let n=new Set(this.settings.dictionary.map(r=>r.trim()));n.delete(""),this.settings.dictionary=[...n].sort(Ke),this.syncDictionary(),await this.saveSettings()}onunload(){this.logs=[],this.isLoading=!1}registerCommands(){this.addCommand({id:"check",name:"Check text",editorCallback:(n,r)=>{let i=n.cm;this.runDetection(i).catch(u=>{console.error(u)})}}),this.addCommand({id:"toggle-auto-check",name:"Toggle automatic checking",callback:async()=>{this.settings.shouldAutoCheck=!this.settings.shouldAutoCheck,await this.saveSettings()}}),this.addCommand({id:"clear",name:"Clear suggestions",editorCallback:n=>{n.cm.dispatch({effects:[gt.of(null)]})}}),this.addCommand({id:"accept-all",name:"Accept all suggestions",editorCallback:n=>{let r=n.cm,i=[],u=[];r.state.field(Pe).between(0,1/0,(o,s,c)=>{var a,l,h;(h=(l=(a=c.spec)==null?void 0:a.underline)==null?void 0:l.replacements)!=null&&h.length&&(i.push({from:o,to:s,insert:c.spec.underline.replacements[0]}),u.push(ve.of({from:o,to:s})))}),r.dispatch({changes:i,effects:u})}}),this.addCommand({id:"next",name:"Jump to next suggestion",editorCheckCallback:(n,r)=>{let i=r.cm,u=r.posToOffset(r.getCursor()),o=null;if(i.state.field(Pe).between(u+1,1/0,(s,c)=>{(!o||o.from>s)&&(o={from:s,to:c})}),n)return o!=null;o!=null&&i.dispatch({selection:{anchor:o.from,head:o.to}})}});for(let n=1;n<=vt;n++)this.addCommand(this.applySuggestionCommand(n));this.addCommand({id:"synonyms",name:"Show synonyms",editorCheckCallback:(n,r)=>this.showSynonyms(r,n)})}applySuggestionCommand(n){return{id:`accept-${n}`,name:`Accept suggestion ${n}`,editorCheckCallback(r,i){var p,F,E;let u=i.cm,o=i.posToOffset(i.getCursor()),s=[];u.state.field(Pe).between(o,o,(C,x,b)=>{s.push({from:C,to:x,value:b})});let c=s.length===1&&((E=(F=(p=s[0].value.spec)==null?void 0:p.underline)==null?void 0:F.replacements)==null?void 0:E.length)>=n;if(r)return c;if(!c)return;let{from:a,to:l,value:h}=s[0],f={from:a,to:l,insert:h.spec.underline.replacements[n-1]};u.dispatch({changes:[f],effects:[ve.of({from:a,to:l})]})}}}registerMenuItems(){this.registerEvent(this.app.workspace.on("editor-menu",(n,r,i)=>{this.showSynonyms(r,!0)&&n.addItem(u=>{u.setTitle("Synonyms"),u.setIcon("square-stack"),u.onClick(()=>this.showSynonyms(r))})}))}showSynonyms(n,r=!1){if(!this.settings.synonyms||!(this.settings.synonyms in ie.SYNONYMS))return!1;let i=ie.SYNONYMS[this.settings.synonyms];if(!i)return!1;let u=n.cm,o=u.state.selection.main;if(o.empty)return!1;let s=u.state.sliceDoc(u.state.selection.main.from,u.state.selection.main.to);if(s.match(/[\s\.]/))return!1;if(r)return!0;let c=u.state.doc.lineAt(o.from),a=c.text.slice(0,o.from-c.from).lastIndexOf(".")+1,l=c.text.slice(a),h=l.trimStart(),f=c.from+a+l.length-h.length,p={from:o.from-f,to:o.to-f};h=h.trimEnd();let F=h.indexOf(".");return F!==-1&&(h=h.slice(0,F+1)),i.query(h,p).then(E=>u.dispatch({effects:[_t.of({text:s,from:o.from,to:o.to,title:"Synonyms",message:"",categoryId:"SYNONYMS",ruleId:"SYNONYMS",replacements:E})]})).catch(E=>{this.pushLogs(E),new oe.Notice(E.message,5e3)}),!0}setStatusBarReady(){this.isLoading=!1,this.statusBarText.empty(),this.statusBarText.createSpan({cls:"lt-status-bar-btn"},n=>{n.createSpan({cls:"lt-status-bar-check-icon",text:"Aa"})})}setStatusBarWorking(){this.isLoading||(this.isLoading=!0,this.statusBarText.empty(),this.statusBarText.createSpan({cls:["lt-status-bar-btn","lt-loading"]},n=>{(0,oe.setIcon)(n,"sync-small")}))}handleStatusBarClick(){var i;let n=(i=this.statusBarText.parentElement)==null?void 0:i.getBoundingClientRect(),r=this.statusBarText.getBoundingClientRect();new oe.Menu().addItem(u=>{u.setTitle("Check text"),u.setIcon("checkbox-glyph"),u.onClick(async()=>{let o=this.app.workspace.getActiveViewOfType(oe.MarkdownView);if(o&&o.getMode()==="source")try{let s=o.editor.cm;await this.runDetection(s)}catch(s){console.error(s)}})}).addItem(u=>{u.setTitle(this.settings.shouldAutoCheck?"Disable automatic checking":"Enable automatic checking"),u.setIcon("uppercase-lowercase-a"),u.onClick(async()=>{this.settings.shouldAutoCheck=!this.settings.shouldAutoCheck,await this.saveSettings()})}).addItem(u=>{u.setTitle("Clear suggestions"),u.setIcon("reset"),u.onClick(()=>{let o=this.app.workspace.getActiveViewOfType(oe.MarkdownView);if(!o)return;o.editor.cm.dispatch({effects:[gt.of(null)]})})}).showAtPosition({x:r.right+5,y:((n==null?void 0:n.top)||0)-5})}async runDetection(n,r){var f;let i=this.app.workspace.getActiveFile(),u=i&&this.app.metadataCache.getFileCache(i),o=(f=u==null?void 0:u.frontmatter)==null?void 0:f.lt_language,s=n.state.selection.main;!r&&!s.empty&&(r={...s});let c=0,a="";if(r?(r=Go(n,r),c=r.from,a=n.state.sliceDoc(r.from,r.to)):a=n.state.sliceDoc(0),!a.trim())return;let l;try{this.setStatusBarWorking(),l=await ie.check(this.settings,c,a,o)}catch(p){console.error(p),p instanceof Error&&(this.pushLogs(p),new oe.Notice(p.message,8e3));return}finally{this.setStatusBarReady()}let h=[];if(r?h.push(ve.of(r)):h.push(gt.of(null)),l){let p=this.settings.dictionary;for(let F of l)F.to>n.state.doc.length||F.categoryId==="TYPOS"&&p.includes(F.text)||h.push(_t.of(F))}h.length&&n.dispatch({effects:h})}async pushLogs(n){let r=`${new Date().toLocaleString()}: Error: '${n.message}' Settings: ${JSON.stringify({...this.settings,username:"REDACTED",apikey:"REDACTED"})} `;this.settings.username&&(r=r.replaceAll(this.settings.username,"<>")),this.settings.apikey&&(r=r.replaceAll(this.settings.apikey,"<>")),this.logs.push(r),this.logs.length>10&&this.logs.shift()}async loadSettings(){this.settings=Object.assign({},xi,await this.loadData())}async saveSettings(){await this.saveData(this.settings)}async onExternalSettingsChange(){this.settingTab.notifyEndpointChange(this.settings)}async syncDictionary(){if(!this.settings.syncDictionary||Ze(this.settings.serverUrl)!=="premium")return await this.saveSettings(),!1;try{let n=new Set(this.settings.remoteDictionary),r=new Set(this.settings.dictionary),i=new Set(await ie.words(this.settings)),u=Qe(n,r);u=mi(u,i);for(let h of u)await ie.wordsDel(this.settings,h);let o=Qe(n,i);i=Qe(i,u),r=Qe(r,o);let s=Qe(r,i);for(let h of s)await ie.wordsAdd(this.settings,h);let c=Mn(i,r),a=new Set(this.settings.dictionary),l=a.size!==c.size;return Mn(a,c).size,c.size,this.settings.dictionary=[...c].sort(Ke),this.settings.remoteDictionary=[...c].sort(Ke),await this.saveSettings(),l}catch(n){this.pushLogs(n),console.error("Failed sync spellcheck with LanguageTool",n)}return await this.saveSettings(),!1}};function Go(e,t){let n=null;if(t.from>0){n=(0,Di.syntaxTree)(e.state);let r=n.resolveInner(t.from,-1);r.type.name.startsWith("list-")?t.from=r.from:t.from=e.state.doc.lineAt(t.from).from}else t.from=0;return t.to * @license MIT *) */ /* nosourcemap */